KVM: x86/mmu: Use MMU's role to detect CR4.SMEP value in nested NPT walk
authorSean Christopherson <seanjc@google.com>
Tue, 22 Jun 2021 17:56:49 +0000 (10:56 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:55:43 +0000 (16:55 +0200)
commit9aae145dc500db7e6e441b67d314887e2e3d5a1b
treee1772adc1d486d86d6140f4a40b5b5d4dd27d30e
parenta9ac58f85f1277ad7c046b0bdc3e94df85a3cb92
KVM: x86/mmu: Use MMU's role to detect CR4.SMEP value in nested NPT walk

commit ef318b9edf66a082f23d00d79b70c17b4c055a26 upstream.

Use the MMU's role to get its effective SMEP value when injecting a fault
into the guest.  When walking L1's (nested) NPT while L2 is active, vCPU
state will reflect L2, whereas NPT uses the host's (L1 in this case) CR0,
CR4, EFER, etc...  If L1 and L2 have different settings for SMEP and
L1 does not have EFER.NX=1, this can result in an incorrect PFEC.FETCH
when injecting #NPF.

Fixes: e57d4a356ad3 ("KVM: Add instruction fetch checking when walking guest page table")
Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210622175739.3610207-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/mmu/paging_tmpl.h