From patchwork Fri Apr 26 06:43:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nakajima, Jun" X-Patchwork-Id: 2491131 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3BC9C40208 for ; Fri, 26 Apr 2013 06:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759534Ab3DZGoJ (ORCPT ); Fri, 26 Apr 2013 02:44:09 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:49730 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754657Ab3DZGoG (ORCPT ); Fri, 26 Apr 2013 02:44:06 -0400 Received: by mail-pa0-f46.google.com with SMTP id ld11so20616pab.5 for ; Thu, 25 Apr 2013 23:44:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=Yfbts4uCo2rAeFMlb49QH1Gw/B66TIU+h6Qq18kf7f4=; b=BYkCJyOYJvjOAjnKcxTKQCNYMAtMSqszWCWfExSMU72lUyMXSr38gmg0g1dr6zqoDK QLnRqzLG+q+JT8tyAEAUhpkzXZt88lYyOAwVNkWHon0WAophhUlJey9lya9N6cKH+/2v gz0vX73FCajYaxDBsRCliuEyB4AEHk4EciHd7WOyzNpTTlXGU7xZgggpl8WVDwHro8or TxOknwoBqh5N9g72e2rTyIvp5f9ud8Ejj2GR5AAREOsjzmpEH8H9gPQJrcynTKZL9z5B fEsw93zx8nzaJOIyyZwV7LNWCq+B/b06K1MgIO2vZnTqR2/WxkjWMao3OtSwjs3P3XLV jQYg== X-Received: by 10.68.196.1 with SMTP id ii1mr58126251pbc.200.1366958645919; Thu, 25 Apr 2013 23:44:05 -0700 (PDT) Received: from localhost (c-98-207-34-191.hsd1.ca.comcast.net. [98.207.34.191]) by mx.google.com with ESMTPSA id lo7sm11417731pab.19.2013.04.25.23.44.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 25 Apr 2013 23:44:04 -0700 (PDT) From: Jun Nakajima To: kvm@vger.kernel.org Subject: [PATCH 11/11] nEPT: Provide the correct exit qualification upon EPT Date: Thu, 25 Apr 2013 23:43:31 -0700 Message-Id: <1366958611-6935-11-git-send-email-jun.nakajima@intel.com> X-Mailer: git-send-email 1.8.2.1.610.g562af5b In-Reply-To: <1366958611-6935-10-git-send-email-jun.nakajima@intel.com> References: <1366958611-6935-1-git-send-email-jun.nakajima@intel.com> <1366958611-6935-2-git-send-email-jun.nakajima@intel.com> <1366958611-6935-3-git-send-email-jun.nakajima@intel.com> <1366958611-6935-4-git-send-email-jun.nakajima@intel.com> <1366958611-6935-5-git-send-email-jun.nakajima@intel.com> <1366958611-6935-6-git-send-email-jun.nakajima@intel.com> <1366958611-6935-7-git-send-email-jun.nakajima@intel.com> <1366958611-6935-8-git-send-email-jun.nakajima@intel.com> <1366958611-6935-9-git-send-email-jun.nakajima@intel.com> <1366958611-6935-10-git-send-email-jun.nakajima@intel.com> X-Gm-Message-State: ALoCoQlqv+vn6X9qO2lMMB44y7JfVJmChqDvG9FkRcZsXc6NVUpyGHNd5rR7fF/odcglpOEqlCLG Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Save [2:0] of exit qualificaiton at EPT violation, and use the information when injecting EPT violation. Signed-off-by: Jun Nakajima Signed-off-by: Xinhao Xu --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/paging_tmpl.h | 5 +++++ arch/x86/kvm/vmx.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 4979778..e029bba 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -504,6 +504,8 @@ struct kvm_vcpu_arch { * instruction. */ bool write_fault_to_shadow_pgtable; + + unsigned long exit_qualification; /* set at EPT violation at this point */ }; struct kvm_lpage_info { diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index e13b6c5..bd370e7 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -349,7 +349,12 @@ error: walker->fault.vector = PF_VECTOR; walker->fault.error_code_valid = true; +#if PTTYPE != PTTYPE_EPT walker->fault.error_code = errcode; +#else + /* Reuse bits [2:0] of EPT violation */ + walker->fault.error_code = vcpu->arch.exit_qualification & 0x7; +#endif walker->fault.address = addr; walker->fault.nested_page_fault = mmu != vcpu->arch.walk_mmu; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 95304cc..61e2853 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -425,6 +425,7 @@ struct vcpu_vmx { ktime_t entry_time; s64 vnmi_blocked_time; u32 exit_reason; + unsigned long exit_qualification; bool rdtscp_enabled; @@ -5074,6 +5075,8 @@ static int handle_ept_violation(struct kvm_vcpu *vcpu) /* ept page table is present? */ error_code |= (exit_qualification >> 3) & 0x1; + vcpu->arch.exit_qualification = exit_qualification; + return kvm_mmu_page_fault(vcpu, gpa, error_code, NULL, 0); }