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

Re: [Xen-devel] [PATCH v9 12/13] test_x86_emulator.c: Add tests for #GP usage



>>> On 24.02.15 at 19:29, <dslutz@xxxxxxxxxxx> wrote:
> +    /*
> +     * Test out special #GP handling for the VMware port 0x5658.
> +     * This is done in two "modes", j=0 and j=1.  Testing 4
> +     * instructions (all the basic PIO) in both modes.
> +     *
> +     * The port used is based on j.
> +     *
> +     * For IN, eax should change.  For OUT eax should not change.
> +     *
> +     * All 4 PIO instructions are 1 byte long, so eip should only
> +     * change by 1.
> +     */

Thanks, this looks reasonable.

> +        /*
> +         * In j=0, there should not be an error returned.
> +         * In j=1, there should be an error returned.
> +         */
> +        if ( rc != X86EMUL_OKAY )
> +        {
> +            if ( j == 0 )
> +                goto fail;
> +        }
> +        else if ( j == 1 )
> +            goto fail;

I'd appreciate if this could be expressed in a little fewer lines. I'm not
sure

    if ( (rc == X86EMUL_OKAY) == j )
        goto fail;

would be deemed readable, but surely

    if ( rc == X86EMUL_OKAY ? j : !j )
        goto fail;

would suffice.

> So I have checked and read, write_gp, cmpxchg_gp, read_segment,
> and inject_hw_exception are not needed.  So that leaves:
> 
> static struct x86_emulate_ops emulops_gp = {
>     .insn_fetch = fetch,
>     .read_io    = read_io,
>     .write_io   = write_io,
>     .vmport_check = vmport_check,
> };

Quite a bit better, thanks.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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