summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu/mmu.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-08-31 02:15:28 +0200
committerSean Christopherson <seanjc@google.com>2024-09-10 05:16:28 +0200
commit29e495bdf847ac6ad0e0d03e5db39a3ed9f12858 (patch)
treeca39bc1349c668ced079ec46b0cc66054f91daee /arch/x86/kvm/mmu/mmu.c
parentKVM: x86/mmu: Don't try to unprotect an INVALID_GPA (diff)
downloadlinux-29e495bdf847ac6ad0e0d03e5db39a3ed9f12858.tar.xz
linux-29e495bdf847ac6ad0e0d03e5db39a3ed9f12858.zip
KVM: x86/mmu: Always walk guest PTEs with WRITE access when unprotecting
When getting a gpa from a gva to unprotect the associated gfn when an event is awating reinjection, walk the guest PTEs for WRITE as there's no point in unprotecting the gfn if the guest is unable to write the page, i.e. if write-protection can't trigger emulation. Note, the entire flow should be guarded on the access being a write, and even better should be conditioned on actually triggering a write-protect fault. This will be addressed in a future commit. Reviewed-by: Yuan Yao <yuan.yao@intel.com> Link: https://lore.kernel.org/r/20240831001538.336683-14-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'arch/x86/kvm/mmu/mmu.c')
-rw-r--r--arch/x86/kvm/mmu/mmu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index bafec04b07ea..937fa9a82a43 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -2751,7 +2751,7 @@ static int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva)
if (vcpu->arch.mmu->root_role.direct)
return 0;
- gpa = kvm_mmu_gva_to_gpa_read(vcpu, gva, NULL);
+ gpa = kvm_mmu_gva_to_gpa_write(vcpu, gva, NULL);
if (gpa == INVALID_GPA)
return 0;