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

Re: [Xen-devel] [PATCH for-4.8] x86/emul: Move CPUID Faulting fault generation into the emulator



>>> On 26.10.16 at 13:09, <andrew.cooper3@xxxxxxxxxx> wrote:
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -5011,8 +5011,16 @@ x86_emulate(
>          unsigned int eax = _regs.eax, ebx = _regs.ebx;
>          unsigned int ecx = _regs.ecx, edx = _regs.edx;
>          fail_if(ops->cpuid == NULL);
> -        if ( (rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt)) != 0 )
> +        switch ( rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt) )
> +        {
> +        case X86EMUL_OKAY:
> +            break;
> +        case X86EMUL_EXCEPTION: /* CPUID Faulting active. */
> +            generate_exception_if(true, EXC_GP, 0);
> +            /* unreachable */
> +        default:
>              goto done;
> +        }

Since this makes the cpuid hook different from other hooks (where
a return of X86EMUL_EXCEPTION means an exception was raised,
not that the emulator should raise one), this should be
accompanied by a comment adjustment in x86_emulate.h. Also I
think this would end up easier to read as

        rc = ops->cpuid(&eax, &ebx, &ecx, &edx, ctxt);
        generate_exception_if(rc == X86EMUL_EXCEPTION, EXC_GP, 0);
        if ( rc != X86EMUL_OKAY )
             goto done;

And then I think we should eventually alter X86EMUL_EXCEPTION:
This should be a macro taking both exception type and error code as
arguments, at which point the raising of exceptions could be done
solely by the emulator.

Jan

_______________________________________________
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®.