Skip to content

Commit 9a65d0b

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86/mmu: Get CR4.SMEP from MMU, not vCPU, in shadow page fault
Use the current MMU instead of vCPU state to query CR4.SMEP when handling a page fault. In the nested NPT case, the current CR4.SMEP reflects L2, whereas the page fault is shadowing L1's NPT, which uses L1's hCR4. Practically speaking, this is a nop a NPT walks are always user faults, i.e. this code will never be reached, but fix it up for consistency. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20210622175739.3610207-54-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent fdaa293 commit 9a65d0b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/mmu/paging_tmpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gpa_t addr, u32 error_code,
903903
* then we should prevent the kernel from executing it
904904
* if SMEP is enabled.
905905
*/
906-
if (kvm_read_cr4_bits(vcpu, X86_CR4_SMEP))
906+
if (is_cr4_smep(vcpu->arch.mmu))
907907
walker.pte_access &= ~ACC_EXEC_MASK;
908908
}
909909

0 commit comments

Comments
 (0)