diff options
author | Junaid Shahid <junaids@google.com> | 2016-12-21 23:29:29 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2017-01-27 09:46:39 -0500 |
commit | 312b616b30d87581b88d3db54c14ed89610cc97b (patch) | |
tree | b3da81c92416497ad410978534d2096dbe39dfe4 | |
parent | ab22a4733fe919d22bc2957680506ed17e40941e (diff) |
kvm: x86: mmu: Set SPTE_SPECIAL_MASK within mmu.c
Instead of the caller including the SPTE_SPECIAL_MASK in the masks being
supplied to kvm_mmu_set_mmio_spte_mask() and kvm_mmu_set_mask_ptes(),
those functions now themselves include the SPTE_SPECIAL_MASK.
Note that bit 63 is now reset in the default MMIO mask.
Signed-off-by: Junaid Shahid <junaids@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/mmu.c | 5 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 6 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 64821ca3a7c3..e3312e22e8db 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -208,7 +208,7 @@ static void mmu_free_roots(struct kvm_vcpu *vcpu); | |||
208 | 208 | ||
209 | void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask) | 209 | void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask) |
210 | { | 210 | { |
211 | shadow_mmio_mask = mmio_mask; | 211 | shadow_mmio_mask = mmio_mask | SPTE_SPECIAL_MASK; |
212 | } | 212 | } |
213 | EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask); | 213 | EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask); |
214 | 214 | ||
@@ -318,6 +318,9 @@ void kvm_mmu_set_mask_ptes(u64 user_mask, u64 accessed_mask, | |||
318 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, | 318 | u64 dirty_mask, u64 nx_mask, u64 x_mask, u64 p_mask, |
319 | u64 acc_track_mask) | 319 | u64 acc_track_mask) |
320 | { | 320 | { |
321 | if (acc_track_mask != 0) | ||
322 | acc_track_mask |= SPTE_SPECIAL_MASK; | ||
323 | |||
321 | shadow_user_mask = user_mask; | 324 | shadow_user_mask = user_mask; |
322 | shadow_accessed_mask = accessed_mask; | 325 | shadow_accessed_mask = accessed_mask; |
323 | shadow_dirty_mask = dirty_mask; | 326 | shadow_dirty_mask = dirty_mask; |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 81c301def1af..d850d5d36182 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -5236,10 +5236,8 @@ static void ept_set_mmio_spte_mask(void) | |||
5236 | /* | 5236 | /* |
5237 | * EPT Misconfigurations can be generated if the value of bits 2:0 | 5237 | * EPT Misconfigurations can be generated if the value of bits 2:0 |
5238 | * of an EPT paging-structure entry is 110b (write/execute). | 5238 | * of an EPT paging-structure entry is 110b (write/execute). |
5239 | * Also, special bit (62) is set to quickly identify mmio spte. | ||
5240 | */ | 5239 | */ |
5241 | kvm_mmu_set_mmio_spte_mask(SPTE_SPECIAL_MASK | | 5240 | kvm_mmu_set_mmio_spte_mask(VMX_EPT_MISCONFIG_WX_VALUE); |
5242 | VMX_EPT_MISCONFIG_WX_VALUE); | ||
5243 | } | 5241 | } |
5244 | 5242 | ||
5245 | #define VMX_XSS_EXIT_BITMAP 0 | 5243 | #define VMX_XSS_EXIT_BITMAP 0 |
@@ -6585,7 +6583,7 @@ void vmx_enable_tdp(void) | |||
6585 | enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull, | 6583 | enable_ept_ad_bits ? VMX_EPT_DIRTY_BIT : 0ull, |
6586 | 0ull, VMX_EPT_EXECUTABLE_MASK, | 6584 | 0ull, VMX_EPT_EXECUTABLE_MASK, |
6587 | cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK, | 6585 | cpu_has_vmx_ept_execute_only() ? 0ull : VMX_EPT_READABLE_MASK, |
6588 | enable_ept_ad_bits ? 0ull : SPTE_SPECIAL_MASK | VMX_EPT_RWX_MASK); | 6586 | enable_ept_ad_bits ? 0ull : VMX_EPT_RWX_MASK); |
6589 | 6587 | ||
6590 | ept_set_mmio_spte_mask(); | 6588 | ept_set_mmio_spte_mask(); |
6591 | kvm_enable_tdp(); | 6589 | kvm_enable_tdp(); |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6e2c71ea0627..4fd4d4f35caf 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -5952,9 +5952,6 @@ static void kvm_set_mmio_spte_mask(void) | |||
5952 | /* Mask the reserved physical address bits. */ | 5952 | /* Mask the reserved physical address bits. */ |
5953 | mask = rsvd_bits(maxphyaddr, 51); | 5953 | mask = rsvd_bits(maxphyaddr, 51); |
5954 | 5954 | ||
5955 | /* Bit 62 is always reserved for 32bit host. */ | ||
5956 | mask |= 0x3ull << 62; | ||
5957 | |||
5958 | /* Set the present bit. */ | 5955 | /* Set the present bit. */ |
5959 | mask |= 1ull; | 5956 | mask |= 1ull; |
5960 | 5957 | ||