[PATCH] KVM: VMX: Judge MMIO based on PFN rather than HVA in EPT violation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



One page can be unmapped from userspace, then HVA seems legal, but in fact,
PFN is illegal.

Signed-off-by: Sheng Yang <sheng@xxxxxxxxxxxxxxx>
---
 arch/x86/kvm/vmx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 9913a1d..a4fa1b5 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3061,7 +3061,7 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	u64 exit_qualification;
 	enum emulation_result er;
 	gpa_t gpa;
-	unsigned long hva;
+	pfn_t pfn;
 	int gla_validity;
 	int r;
 
@@ -3086,8 +3086,8 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	}
 
 	gpa = vmcs_read64(GUEST_PHYSICAL_ADDRESS);
-	hva = gfn_to_hva(vcpu->kvm, gpa >> PAGE_SHIFT);
-	if (!kvm_is_error_hva(hva)) {
+	pfn = gfn_to_pfn(vcpu->kvm, gpa >> PAGE_SHIFT);
+	if (!is_error_pfn(pfn)) {
 		r = kvm_mmu_page_fault(vcpu, gpa & PAGE_MASK, 0);
 		if (r < 0) {
 			printk(KERN_ERR "EPT: Not enough memory!\n");
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux