[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v4 2/2] x86/Intel: virtualize support for cpuid faulting



> From: Kyle Huey [mailto:me@xxxxxxxxxxxx]
> Sent: Tuesday, October 18, 2016 9:57 PM
> 
> >> diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
> >> index 6ed7486..a713ff3 100644
> >> --- a/xen/arch/x86/hvm/emulate.c
> >> +++ b/xen/arch/x86/hvm/emulate.c
> >> @@ -1544,16 +1544,35 @@ static int hvmemul_wbinvd(
> >>
> >>  static int hvmemul_cpuid(
> >>      unsigned int *eax,
> >>      unsigned int *ebx,
> >>      unsigned int *ecx,
> >>      unsigned int *edx,
> >>      struct x86_emulate_ctxt *ctxt)
> >>  {
> >> +    /*
> >> +     * x86_emulate uses this function to query CPU features for its own 
> >> internal
> >> +     * use. Make sure we're actually emulating CPUID before emulating 
> >> CPUID
> >> +     * faulting.
> >> +     */
> >> +    if ( ctxt->opcode == X86EMUL_OPC(0x0f, 0xa2) &&
> >> +         hvm_check_cpuid_fault(current) ) {
> >> +        struct hvm_emulate_ctxt *hvmemul_ctxt =
> >> +            container_of(ctxt, struct hvm_emulate_ctxt, ctxt);
> >> +
> >> +        hvmemul_ctxt->exn_pending = 1;
> >> +        hvmemul_ctxt->trap.vector = TRAP_gp_fault;
> >> +        hvmemul_ctxt->trap.type = X86_EVENTTYPE_HW_EXCEPTION;
> >> +        hvmemul_ctxt->trap.error_code = 0;
> >> +        hvmemul_ctxt->trap.insn_len = 0;
> >> +
> >> +        return X86EMUL_EXCEPTION;
> >
> > I'm unclear about this change. So once guest enables CPUID faulting,
> > emulation of other instructions which require internal cpuid query in
> > x86_emulate will lead to a GP(0) injected to guest... Is this behavior
> > change expected? Sorry if I overlooked something here.
> 
> This is the situation the 'ctxt->opcode == X86EMUL_OPC(0x0f, 0xa2)'
> handles.  If the emulator is querying feature support the opcode will
> be something else.
> 

Make sense. Thanks
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.