From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v2 06/12] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator. Date: Wed, 24 Jun 2015 15:26:00 +0100 Message-ID: <558ADA180200007800088FD1@mail.emea.novell.com> References: <1434999372-3688-1-git-send-email-edmund.h.white@intel.com> <1434999372-3688-7-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: <1434999372-3688-7-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 , Andrew Cooper , Ian Jackson , xen-devel@lists.xen.org, tlengyel@novetta.com, Daniel De Graaf List-Id: xen-devel@lists.xenproject.org >>> On 22.06.15 at 20:56, wrote: > @@ -1826,6 +1827,20 @@ static void vmx_vcpu_update_vmfunc_ve(struct vcpu *v) > vmx_vmcs_exit(v); > } > > +static bool_t vmx_vcpu_emulate_vmfunc(struct cpu_user_regs *regs) > +{ > + bool_t rc = 0; > + > + if ( !cpu_has_vmx_vmfunc && altp2mhvm_active(current->domain) && > + regs->eax == 0 && > + p2m_switch_vcpu_altp2m_by_id(current, (uint16_t)regs->ecx) ) > + { > + regs->eip += 3; What if the instruction has some (bogus but not invalid) opcode prefix? > @@ -2091,6 +2108,13 @@ static void vmx_invlpg_intercept(unsigned long vaddr) > vpid_sync_vcpu_gva(curr, vaddr); > } > > +static int vmx_vmfunc_intercept(struct cpu_user_regs *regs) > +{ > + gdprintk(XENLOG_ERR, "Failed guest VMFUNC execution\n"); > + domain_crash(current->domain); > + return X86EMUL_OKAY; > +} What is this unconditional crashing of the guest good for? > --- a/xen/arch/x86/x86_emulate/x86_emulate.c > +++ b/xen/arch/x86/x86_emulate/x86_emulate.c > @@ -3837,6 +3837,14 @@ x86_emulate( > goto rdtsc; > } > > + if (modrm == 0xd4) /* vmfunc */ > + { > + fail_if(ops->vmfunc == NULL); > + if ( (rc = ops->vmfunc(ctxt) != 0) ) > + goto done; > + break; > + } Together with the two preceding if()-s this is now finally the point where switch() should be used instead. Jan