All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wl@xen.org>, RogerPau Monne <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v9 05/23] x86emul: support AVX512F gather insns
Date: Thu, 4 Jul 2019 15:16:40 +0100	[thread overview]
Message-ID: <e28b72a5-8c3e-104d-027e-225d04cfc12f@citrix.com> (raw)
In-Reply-To: <6f03fb10-6339-610f-0620-86675d76a4ee@citrix.com>

On 04/07/2019 15:10, Andrew Cooper wrote:
> On 01/07/2019 12:18, Jan Beulich wrote:
>> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
>> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
>> @@ -9100,6 +9100,133 @@ x86_emulate(
>>           put_stub(stub);
>>   
>>           if ( rc != X86EMUL_OKAY )
>> +            goto done;
>> +
>> +        state->simd_size = simd_none;
>> +        break;
>> +    }
>> +
>> +    case X86EMUL_OPC_EVEX_66(0x0f38, 0x90): /* vpgatherd{d,q} mem,[xyz]mm{k} */
>> +    case X86EMUL_OPC_EVEX_66(0x0f38, 0x91): /* vpgatherq{d,q} mem,[xyz]mm{k} */
>> +    case X86EMUL_OPC_EVEX_66(0x0f38, 0x92): /* vgatherdp{s,d} mem,[xyz]mm{k} */
>> +    case X86EMUL_OPC_EVEX_66(0x0f38, 0x93): /* vgatherqp{s,d} mem,[xyz]mm{k} */
>> +    {
>> +        typeof(evex) *pevex;
>> +        union {
>> +            int32_t dw[16];
>> +            int64_t qw[8];
>> +        } index;
>> +        bool done = false;
>> +
>> +        ASSERT(ea.type == OP_MEM);
>> +        generate_exception_if((!evex.opmsk || evex.brs || evex.z ||
>> +                               evex.reg != 0xf ||
>> +                               modrm_reg == state->sib_index),
>> +                              EXC_UD);
>> +        avx512_vlen_check(false);
>> +        host_and_vcpu_must_have(avx512f);
>> +        get_fpu(X86EMUL_FPU_zmm);
>> +
>> +        /* Read destination and index registers. */
>> +        opc = init_evex(stub);
>> +        pevex = copy_EVEX(opc, evex);
>> +        pevex->opcx = vex_0f;
>> +        opc[0] = 0x7f; /* vmovdqa{32,64} */
>> +        /*
>> +         * The register writeback below has to retain masked-off elements, but
>> +         * needs to clear upper portions in the index-wider-than-data cases.
>> +         * Therefore read (and write below) the full register. The alternative
>> +         * would have been to fiddle with the mask register used.
>> +         */
>> +        pevex->opmsk = 0;
>> +        /* Use (%rax) as destination and modrm_reg as source. */
>> +        pevex->b = 1;
>> +        opc[1] = (modrm_reg & 7) << 3;
>> +        pevex->RX = 1;
>> +        opc[2] = 0xc3;
>> +
>> +        invoke_stub("", "", "=m" (*mmvalp) : "a" (mmvalp));
>> +
>> +        pevex->pfx = vex_f3; /* vmovdqu{32,64} */
>> +        pevex->w = b & 1;
>> +        /* Switch to sib_index as source. */
>> +        pevex->r = !mode_64bit() || !(state->sib_index & 0x08);
>> +        pevex->R = !mode_64bit() || !(state->sib_index & 0x10);
>> +        opc[1] = (state->sib_index & 7) << 3;
>> +
>> +        invoke_stub("", "", "=m" (index) : "a" (&index));
>> +        put_stub(stub);
>> +
>> +        /* Clear untouched parts of the destination and mask values. */
>> +        n = 1 << (2 + evex.lr - ((b & 1) | evex.w));
>> +        op_bytes = 4 << evex.w;
>> +        memset((void *)mmvalp + n * op_bytes, 0, 64 - n * op_bytes);
>> +        op_mask &= (1 << n) - 1;
>> +
>> +        for ( i = 0; op_mask; ++i )
>> +        {
>> +            signed long idx = b & 1 ? index.qw[i] : index.dw[i];
> No signed.  However, surely this needs to be int64_t anyway, to function
> correctly in a 32bit build of the test harness?
>
> The SDM says VPGATHERQD is encodable in 32bit with quadword indices.
>
> ~Andrew
>
>> +
>> +            if ( !(op_mask & (1 << i)) )
>> +                continue;
>> +
>> +            rc = ops->read(ea.mem.seg,
>> +                           truncate_ea(ea.mem.off + (idx << state->sib_scale)),

Actually, what SDM says is:

"The scaled index may require more bits to represent than the address
bits used by the processor (e.g., in 32-bit mode, if the scale is
greater than one). In this case, the most significant bits beyond the
number of address bits are ignored."

That reads as if it is it means "ea.mem.off + (u32)(idx <<
state->sib_scale)".

However, given the overall truncation, I'm not sure how to confirm what
the real behaviour is.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-07-04 14:17 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 11:13 [Xen-devel] [PATCH v9 00/23] x86emul: remaining AVX512 support Jan Beulich
2019-07-01 11:16 ` [Xen-devel] [PATCH v9 01/23] x86emul: support AVX512{F, _VBMI2} compress/expand insns Jan Beulich
2019-07-04 13:12   ` Andrew Cooper
2019-07-01 11:17 ` [Xen-devel] [PATCH v9 02/23] x86emul: support remaining misc AVX512{F, BW} insns Jan Beulich
2019-07-01 11:17 ` [Xen-devel] [PATCH v9 03/23] x86emul: prepare for AVX512F S/G insns Jan Beulich
2019-07-04 13:50   ` Andrew Cooper
2019-07-01 11:18 ` [Xen-devel] [PATCH v9 04/23] x86emul: test harness adjustments " Jan Beulich
2019-07-04 13:52   ` Andrew Cooper
2019-07-01 11:18 ` [Xen-devel] [PATCH v9 05/23] x86emul: support AVX512F gather insns Jan Beulich
2019-07-04 14:10   ` Andrew Cooper
2019-07-04 14:16     ` Andrew Cooper [this message]
2019-07-04 14:25       ` Jan Beulich
2019-07-04 18:26         ` Andrew Cooper
2019-07-04 14:22     ` Jan Beulich
2019-07-04 18:40       ` Andrew Cooper
2019-07-01 11:19 ` [Xen-devel] [PATCH v9 06/23] x86emul: add high register S/G test cases Jan Beulich
2019-07-01 11:20 ` [Xen-devel] [PATCH v9 07/23] x86emul: support AVX512F scatter insns Jan Beulich
2019-07-04 14:19   ` Andrew Cooper
2019-07-01 11:20 ` [Xen-devel] [PATCH v9 08/23] x86emul: support AVX512PF insns Jan Beulich
2019-07-04 14:44   ` Andrew Cooper
2019-07-04 14:50     ` Jan Beulich
2019-07-04 18:29       ` Andrew Cooper
2019-07-01 11:21 ` [Xen-devel] [PATCH v9 09/23] x86emul: support AVX512CD insns Jan Beulich
2019-07-01 11:21 ` [Xen-devel] [PATCH v9 10/23] x86emul: complete support of AVX512_VBMI insns Jan Beulich
2019-07-01 11:22 ` [Xen-devel] [PATCH v9 11/23] x86emul: support of AVX512* population count insns Jan Beulich
2019-07-04 14:47   ` Andrew Cooper
2019-07-04 14:54     ` Jan Beulich
2019-07-04 18:38       ` Andrew Cooper
2019-07-05  8:10         ` Jan Beulich
2019-07-01 11:22 ` [Xen-devel] [PATCH v9 12/23] x86emul: support of AVX512_IFMA insns Jan Beulich
2019-07-01 11:23 ` [Xen-devel] [PATCH v9 13/23] x86emul: support remaining AVX512_VBMI2 insns Jan Beulich
2019-07-01 11:23 ` [Xen-devel] [PATCH v9 14/23] x86emul: support AVX512_4FMAPS insns Jan Beulich
2019-07-04 14:49   ` Andrew Cooper
2019-07-01 11:24 ` [Xen-devel] [PATCH v9 15/23] x86emul: support AVX512_4VNNIW insns Jan Beulich
2019-07-01 11:24 ` [Xen-devel] [PATCH v9 16/23] x86emul: support AVX512_VNNI insns Jan Beulich
2019-07-04 14:50   ` Andrew Cooper
2019-07-01 11:25 ` [Xen-devel] [PATCH v9 17/23] x86emul: support VPCLMULQDQ insns Jan Beulich
2019-07-01 11:25 ` [Xen-devel] [PATCH v9 18/23] x86emul: support VAES insns Jan Beulich
2019-07-01 11:26 ` [Xen-devel] [PATCH v9 19/23] x86emul: support GFNI insns Jan Beulich
2019-07-04 15:10   ` Andrew Cooper
2019-07-01 11:26 ` [Xen-devel] [PATCH v9 20/23] x86emul: restore ordering within main switch statement Jan Beulich
2019-07-01 11:27 ` [Xen-devel] [PATCH v9 21/23] x86emul: add an AES/VAES test case to the harness Jan Beulich
2019-07-01 11:28 ` [Xen-devel] [PATCH v9 22/23] x86emul: add a SHA " Jan Beulich
2019-07-01 11:28 ` [Xen-devel] [PATCH v9 23/23] x86emul: support VPCLMULQDQ insns Jan Beulich
2019-07-03 16:05 ` [Xen-devel] [PATCH v9 00/23] x86emul: remaining AVX512 support Jan Beulich
2019-07-03 16:06 ` [Xen-devel] [PATCH v9 23/23] x86emul: add a PCLMUL/VPCLMUL test case to the harness Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e28b72a5-8c3e-104d-027e-225d04cfc12f@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.