From patchwork Thu Apr 25 07:52:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nakajima, Jun" X-Patchwork-Id: 2487481 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 68831DFE86 for ; Thu, 25 Apr 2013 07:53:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756264Ab3DYHwu (ORCPT ); Thu, 25 Apr 2013 03:52:50 -0400 Received: from mail-vb0-f41.google.com ([209.85.212.41]:54145 "EHLO mail-vb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755416Ab3DYHwt (ORCPT ); Thu, 25 Apr 2013 03:52:49 -0400 Received: by mail-vb0-f41.google.com with SMTP id f12so411809vbg.14 for ; Thu, 25 Apr 2013 00:52:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=W1SM4CFgmV8bfv+hno3Kvjrlg4MkSjV5NUHqzX7geas=; b=LDtkC7bskcHm9iAw2BR2Y1PjDZhcMKV5/YWwfJUvdbtaJGgHIVuJvih/KDxkjJqlu2 wk2PvY34oP+I/XLXKM0ISCo+u2mNinyg0AKMGV4MXR2vJyapliHXJ6QX9la+rqkrXIvc S0BeAjxVAJ7uU4btyFbltOLx/vyhC9IhpgM5IUUon0Zw2qLDXiF2a5V/s906CxxdU4Ls RQcgK5ngcj7L/+0aPl8YwsKj6asSbA9JlbNdGVEJ4WR4ZKkeiBcDvDNbcCsqQrOWJv5T WpPVptlabfmp4Ik6vWTmXQUOqwKwKbtwW7SDP2Lh0dGn3ff4AG5Nf2yx6/y2dE9/A1E6 wZng== MIME-Version: 1.0 X-Received: by 10.58.164.131 with SMTP id yq3mr26767816veb.31.1366876369246; Thu, 25 Apr 2013 00:52:49 -0700 (PDT) Received: by 10.58.64.196 with HTTP; Thu, 25 Apr 2013 00:52:49 -0700 (PDT) Date: Thu, 25 Apr 2013 00:52:49 -0700 Message-ID: Subject: [PATCH 12/12] Provide the correct exit qualification upon EPT violation to L1 VMM. From: "Nakajima, Jun" To: "kvm@vger.kernel.org" X-Gm-Message-State: ALoCoQn7jhhHArDu5YQRp8cshSOb9mqUJXbB5beP+pETamoY5jPfe5J6QvHHfUBOH1N/Kj3O/QSV Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Since vcpu_vmx is contained in vmx.c, use kvm_vcpu_arch so that we can use the exit quaflication in paging_tmpl.h. Signed-off-by: Jun Nakajima modified: arch/x86/include/asm/kvm_host.h modified: arch/x86/kvm/paging_tmpl.h modified: arch/x86/kvm/vmx.c --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/paging_tmpl.h | 4 ++++ arch/x86/kvm/vmx.c | 3 +++ 3 files changed, 9 insertions(+) -- 1.8.2.1.610.g562af5b -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 4979778..5d1fdf2 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; }; struct kvm_lpage_info { diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 6226b51..0da6044 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -349,7 +349,11 @@ error: walker->fault.vector = PF_VECTOR; walker->fault.error_code_valid = true; +#if PTTYPE != PTTYPE_EPT walker->fault.error_code = errcode; +#else + walker->fault.error_code = vcpu->arch.exit_qualification & 0x7; /* exit_qualificaiton */ +#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); }