Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[sfrench/cifs-2.6.git] / arch / x86 / kvm / x86.c
index fb2bc9f5fe96757a772684f7094c6e235c4f86d5..47d9f03b7778373393b9853fe32b153dadd9de29 100644 (file)
@@ -1620,7 +1620,8 @@ static bool kvm_is_immutable_feature_msr(u32 msr)
         ARCH_CAP_SKIP_VMENTRY_L1DFLUSH | ARCH_CAP_SSB_NO | ARCH_CAP_MDS_NO | \
         ARCH_CAP_PSCHANGE_MC_NO | ARCH_CAP_TSX_CTRL_MSR | ARCH_CAP_TAA_NO | \
         ARCH_CAP_SBDR_SSDP_NO | ARCH_CAP_FBSDP_NO | ARCH_CAP_PSDP_NO | \
-        ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO | ARCH_CAP_GDS_NO)
+        ARCH_CAP_FB_CLEAR | ARCH_CAP_RRSBA | ARCH_CAP_PBRSB_NO | ARCH_CAP_GDS_NO | \
+        ARCH_CAP_RFDS_NO | ARCH_CAP_RFDS_CLEAR)
 
 static u64 kvm_get_arch_capabilities(void)
 {
@@ -1652,6 +1653,8 @@ static u64 kvm_get_arch_capabilities(void)
                data |= ARCH_CAP_SSB_NO;
        if (!boot_cpu_has_bug(X86_BUG_MDS))
                data |= ARCH_CAP_MDS_NO;
+       if (!boot_cpu_has_bug(X86_BUG_RFDS))
+               data |= ARCH_CAP_RFDS_NO;
 
        if (!boot_cpu_has(X86_FEATURE_RTM)) {
                /*
@@ -8062,6 +8065,16 @@ static int emulator_cmpxchg_emulated(struct x86_emulate_ctxt *ctxt,
 
        if (r < 0)
                return X86EMUL_UNHANDLEABLE;
+
+       /*
+        * Mark the page dirty _before_ checking whether or not the CMPXCHG was
+        * successful, as the old value is written back on failure.  Note, for
+        * live migration, this is unnecessarily conservative as CMPXCHG writes
+        * back the original value and the access is atomic, but KVM's ABI is
+        * that all writes are dirty logged, regardless of the value written.
+        */
+       kvm_vcpu_mark_page_dirty(vcpu, gpa_to_gfn(gpa));
+
        if (r)
                return X86EMUL_CMPXCHG_FAILED;