From: "Daniel K." Subject: Re: [PATCH 15/18] KVM: MMU: Propagate the right fault back to the guest after gva_to_gpa Date: Mon, 15 Mar 2010 04:30:47 +0000 Message-ID: <4B9DB7F7.6010902@uw.no> References: <1267643541-451-1-git-send-email-joerg.roedel@amd.com> <1267643541-451-16-git-send-email-joerg.roedel@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , Marcelo Tosatti , Alexander Graf , kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Joerg Roedel Return-path: Received: from in.cluded.net ([195.159.98.120]:38148 "EHLO in.cluded.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752610Ab0COEkl (ORCPT ); Mon, 15 Mar 2010 00:40:41 -0400 In-Reply-To: <1267643541-451-16-git-send-email-joerg.roedel@amd.com> Sender: kvm-owner@vger.kernel.org List-ID: Joerg Roedel wrote: > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 2883ce8..9f8b02d 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -314,6 +314,19 @@ 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 addr, u32 error_code) > +{ > + u32 nested, error; > + > + nested = error_code & PFERR_NESTED_MASK; > + error = error_code & ~PFERR_NESTED_MASK; > + > + if (vcpu->arch.mmu.nested && !(error_code && PFERR_NESTED_MASK)) This looks incorrect, nested is unused. At the very least it should be a binary & operation if (vcpu->arch.mmu.nested && !(error_code & PFERR_NESTED_MASK)) which can be simplified to if (vcpu->arch.mmu.nested && !nested) but it seems wrong that the condition is that it is nested and not nested at the same time. > + vcpu->arch.nested_mmu.inject_page_fault(vcpu, addr, error); > + else > + vcpu->arch.mmu.inject_page_fault(vcpu, addr, error); > +} > + > void kvm_inject_nmi(struct kvm_vcpu *vcpu) > { > vcpu->arch.nmi_pending = 1; Daniel K.