]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - arch/x86/kvm/mmu.c
KVM: SVM: Limit PFERR_NESTED_GUEST_PAGE error_code check to L1 guest
authorBrijesh Singh <brijesh.singh@amd.com>
Mon, 7 Aug 2017 19:11:30 +0000 (14:11 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 10 Aug 2017 14:44:04 +0000 (16:44 +0200)
commit64531a3b70b17c8d3e77f2e49e5e1bb70f571266
tree9b681ebeef4001a1fe164bdb4308a98b7fa2803b
parentbbeac2830f4de270bb48141681cb730aadf8dce1
KVM: SVM: Limit PFERR_NESTED_GUEST_PAGE error_code check to L1 guest

Commit 147277540bbc ("kvm: svm: Add support for additional SVM NPF error
codes", 2016-11-23) added a new error code to aid nested page fault
handling.  The commit unprotects (kvm_mmu_unprotect_page) the page when
we get a NPF due to guest page table walk where the page was marked RO.

However, if an L0->L2 shadow nested page table can also be marked read-only
when a page is read only in L1's nested page table.  If such a page
is accessed by L2 while walking page tables it can cause a nested
page fault (page table walks are write accesses).  However, after
kvm_mmu_unprotect_page we may get another page fault, and again in an
endless stream.

To cover this use case, we qualify the new error_code check with
vcpu->arch.mmu_direct_map so that the error_code check would run on L1
guest, and not the L2 guest.  This avoids hitting the above scenario.

Fixes: 147277540bbc54119172481c8ef6d930cc9fbfc2
Cc: stable@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Thomas Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c