From patchwork Tue Feb 10 09:43:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 6372 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1A9hmER029366 for ; Tue, 10 Feb 2009 09:43:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751212AbZBJJnq (ORCPT ); Tue, 10 Feb 2009 04:43:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752027AbZBJJnq (ORCPT ); Tue, 10 Feb 2009 04:43:46 -0500 Received: from mga03.intel.com ([143.182.124.21]:60817 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbZBJJnp (ORCPT ); Tue, 10 Feb 2009 04:43:45 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 10 Feb 2009 01:43:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.38,185,1233561600"; d="scan'208";a="109055754" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.13.102]) by azsmga001.ch.intel.com with ESMTP; 10 Feb 2009 01:43:43 -0800 Received: from yasker by syang10-desktop with local (Exim 4.69) (envelope-from ) id 1LWp9Z-0006lp-Mk; Tue, 10 Feb 2009 17:43:41 +0800 From: Sheng Yang To: Avi Kivity Cc: kvm@vger.kernel.org, Sheng Yang Subject: [PATCH] KVM: VMX: Judge MMIO based on PFN rather than HVA in EPT violation Date: Tue, 10 Feb 2009 17:43:41 +0800 Message-Id: <1234259021-26007-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.5.6.3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org One page can be unmapped from userspace, then HVA seems legal, but in fact, PFN is illegal. Signed-off-by: Sheng Yang --- 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");