From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v5 07/15] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator. Date: Tue, 14 Jul 2015 15:04:04 +0100 Message-ID: <55A532F40200007800090C39@mail.emea.novell.com> References: <1436832903-12639-1-git-send-email-edmund.h.white@intel.com> <1436832903-12639-8-git-send-email-edmund.h.white@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1436832903-12639-8-git-send-email-edmund.h.white@intel.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ed White Cc: Tim Deegan , Ravi Sahita , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, tlengyel@novetta.com, Daniel De Graaf List-Id: xen-devel@lists.xenproject.org >>> On 14.07.15 at 02:14, wrote: > --- a/xen/arch/x86/hvm/emulate.c > +++ b/xen/arch/x86/hvm/emulate.c > @@ -1436,6 +1436,19 @@ static int hvmemul_invlpg( > return rc; > } > > +static int hvmemul_vmfunc( > + struct x86_emulate_ctxt *ctxt) > +{ > + int rc; > + > + rc = hvm_funcs.altp2m_vcpu_emulate_vmfunc(ctxt->regs); > + if ( rc != X86EMUL_OKAY ) > + { > + hvmemul_inject_hw_exception(TRAP_invalid_op, 0, ctxt); > + } > + return rc; Pointless braces and missing blank line before final return. > @@ -1830,6 +1831,19 @@ static void vmx_vcpu_update_vmfunc_ve(struct vcpu *v) > vmx_vmcs_exit(v); > } > > +static int vmx_vcpu_emulate_vmfunc(struct cpu_user_regs *regs) > +{ > + int rc = X86EMUL_EXCEPTION; > + struct vcpu *curr = current; > + > + if ( !cpu_has_vmx_vmfunc && altp2m_active(curr->domain) && > + regs->eax == 0 && > + p2m_switch_vcpu_altp2m_by_id(curr, (uint16_t)regs->ecx) ) Documentation suggests that the upper 32 bits of RAX are being ignored, and that all 32 bits of ECX are being used. > @@ -3234,6 +3263,15 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs) > update_guest_eip(); > break; > > + case EXIT_REASON_VMFUNC: > + if ( (vmx_vmfunc_intercept(regs) == X86EMUL_EXCEPTION) || > + (vmx_vmfunc_intercept(regs) == X86EMUL_UNHANDLEABLE) || > + (vmx_vmfunc_intercept(regs) == X86EMUL_RETRY) ) Why would you want to invoke the function 3 times? How about simply != X86EMUL_OKAY? Jan