From patchwork Mon Sep 6 15:55:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 159031 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o86G22wS023057 for ; Mon, 6 Sep 2010 16:02:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755450Ab0IFP76 (ORCPT ); Mon, 6 Sep 2010 11:59:58 -0400 Received: from va3ehsobe001.messaging.microsoft.com ([216.32.180.11]:48689 "EHLO VA3EHSOBE001.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755503Ab0IFP7x (ORCPT ); Mon, 6 Sep 2010 11:59:53 -0400 Received: from mail162-va3-R.bigfish.com (10.7.14.241) by VA3EHSOBE001.bigfish.com (10.7.40.21) with Microsoft SMTP Server id 8.1.340.0; Mon, 6 Sep 2010 15:59:51 +0000 Received: from mail162-va3 (localhost.localdomain [127.0.0.1]) by mail162-va3-R.bigfish.com (Postfix) with ESMTP id 510C11C01A1; Mon, 6 Sep 2010 15:59:51 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzz8275bhz32i87h2a8h62h) X-Spam-TCS-SCL: 1:0 X-FB-SS: 0, X-FB-DOMAIN-IP-MATCH: fail Received: from mail162-va3 (localhost.localdomain [127.0.0.1]) by mail162-va3 (MessageSwitch) id 1283788720869441_8893; Mon, 6 Sep 2010 15:58:40 +0000 (UTC) Received: from VA3EHSMHS008.bigfish.com (unknown [10.7.14.250]) by mail162-va3.bigfish.com (Postfix) with ESMTP id 63AF99D805A; Mon, 6 Sep 2010 15:57:42 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS008.bigfish.com (10.7.99.18) with Microsoft SMTP Server (TLS) id 14.0.482.44; Mon, 6 Sep 2010 15:57:21 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o86FwVfB011246; Mon, 6 Sep 2010 10:58:59 -0500 X-WSS-ID: 0L8C1L8-02-7A4-02 X-M-MSG: Received: from sausexhtp02.amd.com (sausexhtp02.amd.com [163.181.3.152]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 299CEC8969; Mon, 6 Sep 2010 10:55:55 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 6 Sep 2010 10:56:00 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Mon, 6 Sep 2010 11:55:59 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 6755649C2CB; Mon, 6 Sep 2010 16:55:58 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 18A73A0500; Mon, 6 Sep 2010 17:56:29 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: Alexander Graf , , , , Joerg Roedel Subject: [PATCH 18/27] KVM: MMU: Propagate the right fault back to the guest after gva_to_gpa Date: Mon, 6 Sep 2010 17:55:57 +0200 Message-ID: <1283788566-29186-19-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283788566-29186-1-git-send-email-joerg.roedel@amd.com> References: <1283788566-29186-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Mon, 06 Sep 2010 16:02:07 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index e5eb57c..173834b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -663,6 +663,7 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2, int kvm_read_guest_page_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, gfn_t gfn, void *data, int offset, int len, u32 *error); +void kvm_propagate_fault(struct kvm_vcpu *vcpu); bool kvm_require_cpl(struct kvm_vcpu *vcpu, int required_cpl); int kvm_pic_set_irq(void *opaque, int irq, int level); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 38d482d..65b00f0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -337,6 +337,22 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr, kvm_queue_exception_e(vcpu, PF_VECTOR, error_code); } +void kvm_propagate_fault(struct kvm_vcpu *vcpu) +{ + unsigned long address; + u32 nested, error; + + address = vcpu->arch.fault.address; + error = vcpu->arch.fault.error_code; + nested = error & PFERR_NESTED_MASK; + error = error & ~PFERR_NESTED_MASK; + + if (mmu_is_nested(vcpu) && !nested) + vcpu->arch.nested_mmu.inject_page_fault(vcpu, address, error); + else + vcpu->arch.mmu.inject_page_fault(vcpu, address, error); +} + void kvm_inject_nmi(struct kvm_vcpu *vcpu) { vcpu->arch.nmi_pending = 1; @@ -4130,8 +4146,7 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu) { struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; if (ctxt->exception == PF_VECTOR) - kvm_inject_page_fault(vcpu, vcpu->arch.fault.address, - vcpu->arch.fault.error_code); + kvm_propagate_fault(vcpu); else if (ctxt->error_code_valid) kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code); else