]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
kvm: x86: mmu: Do not use bit 63 for tracking special SPTEs
authorJunaid Shahid <junaids@google.com>
Wed, 7 Dec 2016 00:46:15 +0000 (16:46 -0800)
committerRadim Krčmář <rkrcmar@redhat.com>
Mon, 9 Jan 2017 13:46:10 +0000 (14:46 +0100)
MMIO SPTEs currently set both bits 62 and 63 to distinguish them as special
PTEs. However, bit 63 is used as the SVE bit in Intel EPT PTEs. The SVE bit
is ignored for misconfigured PTEs but not necessarily for not-Present PTEs.
Since MMIO SPTEs use an EPT misconfiguration, so using bit 63 for them is
acceptable. However, the upcoming fast access tracking feature adds another
type of special tracking PTE, which uses not-Present PTEs and hence should
not set bit 63.

In order to use common bits to distinguish both type of special PTEs, we
now use only bit 62 as the special bit.

Signed-off-by: Junaid Shahid <junaids@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/vmx.h
arch/x86/kvm/vmx.c

index 7e594a32515863f5a2edb0b63bf049dc5cd778e0..3272a5e4aaad659dfb73e511dcf4c0ca9a33a74f 100644 (file)
@@ -208,6 +208,13 @@ enum {
                                 PFERR_WRITE_MASK |             \
                                 PFERR_PRESENT_MASK)
 
+/*
+ * The mask used to denote special SPTEs, which can be either MMIO SPTEs or
+ * Access Tracking SPTEs. We use bit 62 instead of bit 63 to avoid conflicting
+ * with the SVE bit in EPT PTEs.
+ */
+#define SPTE_SPECIAL_MASK (1ULL << 62)
+
 /* apic attention bits */
 #define KVM_APIC_CHECK_VAPIC   0
 /*
index 25a482fb52415119b88e21f6f8a4f8944e2527f9..fc061cbb46e018151e4c54eceaf39d871c9cf644 100644 (file)
@@ -467,8 +467,13 @@ enum vmcs_field {
 #define VMX_EPT_WRITABLE_MASK                  0x2ull
 #define VMX_EPT_EXECUTABLE_MASK                        0x4ull
 #define VMX_EPT_IPAT_BIT                       (1ull << 6)
-#define VMX_EPT_ACCESS_BIT                             (1ull << 8)
-#define VMX_EPT_DIRTY_BIT                              (1ull << 9)
+#define VMX_EPT_ACCESS_BIT                     (1ull << 8)
+#define VMX_EPT_DIRTY_BIT                      (1ull << 9)
+
+/* The mask to use to trigger an EPT Misconfiguration in order to track MMIO */
+#define VMX_EPT_MISCONFIG_WX_VALUE           (VMX_EPT_WRITABLE_MASK |       \
+                                              VMX_EPT_EXECUTABLE_MASK)
+
 
 #define VMX_EPT_IDENTITY_PAGETABLE_ADDR                0xfffbc000ul
 
index 81159a3878f4e2589391d1df590b73750096cb5c..6f53dedd9b968062646fed6dce77f98aa7732684 100644 (file)
@@ -5236,10 +5236,10 @@ static void ept_set_mmio_spte_mask(void)
        /*
         * EPT Misconfigurations can be generated if the value of bits 2:0
         * of an EPT paging-structure entry is 110b (write/execute).
-        * Also, magic bits (0x3ull << 62) is set to quickly identify mmio
-        * spte.
+        * Also, special bit (62) is set to quickly identify mmio spte.
         */
-       kvm_mmu_set_mmio_spte_mask((0x3ull << 62) | 0x6ull);
+       kvm_mmu_set_mmio_spte_mask(SPTE_SPECIAL_MASK |
+                                  VMX_EPT_MISCONFIG_WX_VALUE);
 }
 
 #define VMX_XSS_EXIT_BITMAP 0