From: Tim Deegan Subject: Re: [PATCH 07/14] Nested Virtualization: trap Date: Mon, 9 Aug 2010 13:44:57 +0100 Message-ID: <20100809124457.GA13291@whitby.uk.xensource.com> References: <201008051702.35039.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Return-path: Content-Disposition: inline In-Reply-To: <201008051702.35039.Christoph.Egger@amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Christoph Egger Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org > +int hvm_inject_exception(unsigned int trapnr, int errcode, unsigned long cr2) > +{ > + uint64_t exitcode; > + bool_t is_intercepted; > + struct vcpu *v = current; > + struct nestedhvm *hvm = &VCPU_NESTEDHVM(v); > + > + if ( !nestedhvm_enabled(v->domain) ) { > + hvm_funcs.inject_exception(trapnr, errcode, cr2); > + return 0; > + } > + > + if ( nestedhvm_vmentry_emulate(v) ) { > + hvm_funcs.inject_exception(trapnr, errcode, cr2); > + return 0; > + } > + > + if ( !nestedhvm_vcpu_in_guestmode(v) ) { > + hvm_funcs.inject_exception(trapnr, errcode, cr2); > + return 0; > + } > + > + exitcode = nestedhvm_exception2exitcode(trapnr); > + hvm->nh_hostflags.fields.forcevmexit = 1; > + hvm->nh_forcevmexit.exitcode = exitcode; > + is_intercepted = hvm_nestedhvm_vm_intercepted_by_guest(v, exitcode); > + hvm->nh_hostflags.fields.forcevmexit = 0; > + > + if ( is_intercepted ) > + { > + enum nestedhvm_vmexits nsret; > + > + hvm->nh_forcevmexit.exitcode = exitcode; > + hvm->nh_forcevmexit.exitinfo1 = errcode; > + hvm->nh_forcevmexit.exitinfo2 = cr2; > + > + hvm->nh_hostflags.fields.forcevmexit = 1; > + nsret = nestedhvm_vcpu_vmexit(v, guest_cpu_user_regs(), 0 /* dummy */); > + hvm->nh_hostflags.fields.forcevmexit = 0; > + > + switch (nsret) { > + case NESTEDHVM_VMEXIT_DONE: > + case NESTEDHVM_VMEXIT_ERROR: /* L1 guest will crash L2 guest */ > + return 1; > + case NESTEDHVM_VMEXIT_HOST: > + case NESTEDHVM_VMEXIT_CONTINUE: > + case NESTEDHVM_VMEXIT_FATALERROR: > + default: > + gdprintk(XENLOG_ERR, "unexpected nestedhvm error %i\n", nsret); > + return -1; This new [-1,0,1] return value is ignored by almost all callers. Would it be possible to get rid of the special case for #PF, and go back to returning void? Cheers, Tim. -- Tim Deegan Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)