arm64: KVM: Handle Set/Way CMOs as NOPs if FWB is present
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 17 May 2018 10:05:08 +0000 (11:05 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Mon, 9 Jul 2018 10:37:41 +0000 (11:37 +0100)
Set/Way handling is one of the ugliest corners of KVM. We shouldn't
have to handle that, but better safe than sorry.

Thankfully, FWB fixes this for us by not requiering any maintenance
(the guest is forced to use cacheable memory, no matter what it says,
and the whole system is garanteed to be cache coherent), which means
we don't have to emulate S/W CMOs, and don't have to track VM ops either.

We still have to trap S/W though, if only to prevent the guest from
doing something bad.

Reviewed-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm64/kvm/sys_regs.c

index a4363735d3f8e11e1cac77f57cab32d23fac4915..774d7215590433289b17c9b0c69fb53096bd3a51 100644 (file)
@@ -194,7 +194,16 @@ static bool access_dcsw(struct kvm_vcpu *vcpu,
        if (!p->is_write)
                return read_from_write_only(vcpu, p, r);
 
-       kvm_set_way_flush(vcpu);
+       /*
+        * Only track S/W ops if we don't have FWB. It still indicates
+        * that the guest is a bit broken (S/W operations should only
+        * be done by firmware, knowing that there is only a single
+        * CPU left in the system, and certainly not from non-secure
+        * software).
+        */
+       if (!cpus_have_const_cap(ARM64_HAS_STAGE2_FWB))
+               kvm_set_way_flush(vcpu);
+
        return true;
 }