public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sheng Yang <sheng@linux.intel.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org, Sheng Yang <sheng@linux.intel.com>
Subject: [PATCH] KVM: VMX: Judge MMIO based on PFN rather than HVA in EPT violation
Date: Tue, 10 Feb 2009 17:43:41 +0800	[thread overview]
Message-ID: <1234259021-26007-1-git-send-email-sheng@linux.intel.com> (raw)

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

Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 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


             reply	other threads:[~2009-02-10  9:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10  9:43 Sheng Yang [this message]
2009-02-10 12:14 ` [PATCH] KVM: VMX: Judge MMIO based on PFN rather than HVA in EPT violation Marcelo Tosatti
2009-02-11  2:43   ` Sheng Yang
2009-02-11  3:29     ` Sheng Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1234259021-26007-1-git-send-email-sheng@linux.intel.com \
    --to=sheng@linux.intel.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox