[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200227172306.21426-4-mgamal@redhat.com>
Date: Thu, 27 Feb 2020 19:23:04 +0200
From: Mohammed Gamal <mgamal@...hat.com>
To: kvm@...r.kernel.org, pbonzini@...hat.com
Cc: sean.j.christopherson@...el.com, vkuznets@...hat.com,
wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
linux-kernel@...r.kernel.org, Mohammed Gamal <mgamal@...hat.com>
Subject: [PATCH 3/5] KVM: SVM: Add guest physical address check in NPF interception
Check guest physical address against it's maximum physical memory. If
the guest's physical address exceeds the maximum (i.e. has reserved bits
set), inject a guest page fault with PFERR_RSVD_MASK.
Signed-off-by: Mohammed Gamal <mgamal@...hat.com>
---
arch/x86/kvm/svm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ad3f5b178a03..facd9b0c9fb0 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2754,6 +2754,13 @@ static int npf_interception(struct vcpu_svm *svm)
u64 error_code = svm->vmcb->control.exit_info_1;
trace_kvm_page_fault(fault_address, error_code);
+
+ /* Check if guest gpa doesn't exceed physical memory limits */
+ if (fault_address >= (1ull << cpuid_maxphyaddr(&svm->vcpu))) {
+ kvm_inject_rsvd_bits_pf(&svm->vcpu, fault_address);
+ return 1;
+ }
+
return kvm_mmu_page_fault(&svm->vcpu, fault_address, error_code,
static_cpu_has(X86_FEATURE_DECODEASSISTS) ?
svm->vmcb->control.insn_bytes : NULL,
--
2.21.1
Powered by blists - more mailing lists