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 <xen-devel@lists.xenproject.org>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Subject: Re: [PATCH v4 05/20] x86emul: support 3DNow! insns
Date: Mon, 5 Mar 2018 14:55:23 +0000	[thread overview]
Message-ID: <c9225289-6cd0-fc96-6e08-6dfa21490657@citrix.com> (raw)
In-Reply-To: <5A96B5CE02000078001ACB90@prv-mh.provo.novell.com>

On 28/02/18 12:59, Jan Beulich wrote:
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -356,6 +356,41 @@ static const struct twobyte_table {
>  };
>  
>  /*
> + * The next two tables are indexed by high opcode extension byte (the one
> + * that's encoded like an immediate) nibble, with each table element then
> + * bit-indexed by low opcode extension byte nibble.
> + */
> +static const uint16_t _3dnow_table[16] = {
> +    [0x0] = (1 << 0xd) /* pi2fd */,
> +    [0x1] = (1 << 0xd) /* pf2id */,
> +    [0x9] = (1 << 0x0) /* pfcmpge */ |
> +            (1 << 0x4) /* pfmin */ |
> +            (1 << 0x6) /* pfrcp */ |
> +            (1 << 0x7) /* pfrsqrt */ |
> +            (1 << 0xa) /* pfsub */ |
> +            (1 << 0xe) /* pfadd */,
> +    [0xa] = (1 << 0x0) /* pfcmpge */ |

"pfcmgt" - copy/paste mistake from above?

> +            (1 << 0x4) /* pfmax */ |
> +            (1 << 0x6) /* pfrcpit1 */ |
> +            (1 << 0x7) /* pfrsqit1 */ |
> +            (1 << 0xa) /* pfsubr */ |
> +            (1 << 0xe) /* pfacc */,
> +    [0xb] = (1 << 0x0) /* pfcmpeq */ |
> +            (1 << 0x4) /* pfmul */ |
> +            (1 << 0x6) /* pfrcpit2 */ |
> +            (1 << 0x7) /* pmulhrw */ |
> +            (1 << 0xf) /* pavgusb */,
> +};
> +
> +static const uint16_t _3dnow_ext_table[16] = {
> +    [0x0] = (1 << 0xc) /* pi2fw */,
> +    [0x1] = (1 << 0xc) /* pf2iw */,

It turns out that the AMD manual has a typo in the cross reference for
this instruction.  I've asked for a correction to be made.

> +    [0x8] = (1 << 0xa) /* pfnacc */ |
> +            (1 << 0xa) /* pfpnacc */,

1 << 0xe

> +    [0xb] = (1 << 0xb) /* pfswapd */,

There is no f in the AMD mnemonic.

> +};
> +
> +/*
>   * "two_op" and "four_op" below refer to the number of register operands
>   * (one of which possibly also allowing to be a memory one). The named
>   * operand counts do not include any immediate operands.
> @@ -1662,6 +1697,8 @@ static bool vcpu_has(
>  #define vcpu_has_rdrand()      vcpu_has(         1, ECX, 30, ctxt, ops)
>  #define vcpu_has_mmxext()     (vcpu_has(0x80000001, EDX, 22, ctxt, ops) || \
>                                 vcpu_has_sse())
> +#define vcpu_has_3dnow_ext()   vcpu_has(0x80000001, EDX, 30, ctxt, ops)
> +#define vcpu_has_3dnow()       vcpu_has(0x80000001, EDX, 31, ctxt, ops)
>  #define vcpu_has_lahf_lm()     vcpu_has(0x80000001, ECX,  0, ctxt, ops)
>  #define vcpu_has_cr8_legacy()  vcpu_has(0x80000001, ECX,  4, ctxt, ops)
>  #define vcpu_has_lzcnt()       vcpu_has(0x80000001, ECX,  5, ctxt, ops)
> @@ -5524,6 +5561,26 @@ x86_emulate(
>      case X86EMUL_OPC(0x0f, 0x19) ... X86EMUL_OPC(0x0f, 0x1f): /* nop */
>          break;
>  
> +    case X86EMUL_OPC(0x0f, 0x0e): /* femms */
> +        host_and_vcpu_must_have(3dnow);
> +        asm volatile ( "femms" );
> +        break;
> +
> +    case X86EMUL_OPC(0x0f, 0x0f): /* 3DNow! */
> +        if ( _3dnow_ext_table[(imm1 >> 4) & 0xf] & (1 << (imm1 & 0xf)) )
> +            host_and_vcpu_must_have(3dnow_ext);
> +        else if ( _3dnow_table[(imm1 >> 4) & 0xf] & (1 << (imm1 & 0xf)) )
> +            host_and_vcpu_must_have(3dnow);

I'd switch these two if's around.  We're more likely to get a hit in the
plain 3dnow space than the 3dnow_ext space.

~Andrew

> +        else
> +            generate_exception(EXC_UD);
> +
> +        get_fpu(X86EMUL_FPU_mmx, &fic);
> +
> +        d = DstReg | SrcMem;
> +        op_bytes = 8;
> +        state->simd_size = simd_other;
> +        goto simd_0f_imm8;
> +
>  #define CASE_SIMD_PACKED_INT(pfx, opc)       \
>      case X86EMUL_OPC(pfx, opc):              \
>      case X86EMUL_OPC_66(pfx, opc)
> --- a/xen/include/asm-x86/cpufeature.h
> +++ b/xen/include/asm-x86/cpufeature.h
> @@ -71,6 +71,8 @@
>                                   && boot_cpu_has(X86_FEATURE_FFXSR))
>  #define cpu_has_page1gb         boot_cpu_has(X86_FEATURE_PAGE1GB)
>  #define cpu_has_rdtscp          boot_cpu_has(X86_FEATURE_RDTSCP)
> +#define cpu_has_3dnow_ext       boot_cpu_has(X86_FEATURE_3DNOWEXT)
> +#define cpu_has_3dnow           boot_cpu_has(X86_FEATURE_3DNOW)
>  
>  /* CPUID level 0x80000001.ecx */
>  #define cpu_has_cmp_legacy      boot_cpu_has(X86_FEATURE_CMP_LEGACY)
>
>


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

  reply	other threads:[~2018-03-05 14:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-28 12:50 [PATCH v4 00/20] x86: emulator enhancements Jan Beulich
2018-02-28 12:57 ` [PATCH v4 01/20] x86emul: extend vbroadcasts{s, d} to AVX2 Jan Beulich
2018-03-02 19:08   ` Andrew Cooper
2018-02-28 12:58 ` [PATCH v4 02/20] x86emul: support most remaining AVX2 insns Jan Beulich
2018-03-05 13:39   ` Andrew Cooper
2018-03-05 14:50     ` Jan Beulich
2018-02-28 12:58 ` [PATCH v4 03/20] x86emul: support AVX2 gather insns Jan Beulich
2018-03-05 14:15   ` Andrew Cooper
2018-02-28 12:59 ` [PATCH v4 04/20] x86emul: support XOP insns Jan Beulich
2018-02-28 12:59 ` [PATCH v4 05/20] x86emul: support 3DNow! insns Jan Beulich
2018-03-05 14:55   ` Andrew Cooper [this message]
2018-02-28 13:00 ` [PATCH v4 06/20] x86emul: place test blobs in executable section Jan Beulich
2018-03-06 11:28   ` Andrew Cooper
2018-03-06 13:33     ` Jan Beulich
2018-02-28 13:00 ` [PATCH v4 07/20] x86: move and rename XSTATE_* Jan Beulich
2018-02-28 13:01   ` Jan Beulich
2018-02-28 13:06     ` Paul Durrant
2018-03-05 15:27   ` Andrew Cooper
2018-02-28 13:03 ` [PATCH v4 08/20] x86emul: abstract out XCRn accesses Jan Beulich
2018-03-05 15:56   ` Andrew Cooper
2018-03-08  9:33     ` Jan Beulich
2018-02-28 13:04 ` [PATCH v4 09/20] x86emul: adjust_bnd() should check XCR0 Jan Beulich
2018-02-28 13:04 ` [PATCH v4 10/20] x86emul: make all FPU emulation use the stub Jan Beulich
2018-02-28 13:05 ` [PATCH v4 11/20] x86/HVM: eliminate custom #MF/#XM handling Jan Beulich
2018-02-28 13:06 ` [PATCH v4 12/20] x86emul: support SWAPGS Jan Beulich
2018-03-05 15:58   ` Andrew Cooper
2018-02-28 13:08 ` [PATCH v4 13/20] x86emul: tell cmpxchg hook whether LOCK is in effect Jan Beulich
2018-02-28 13:08 ` [PATCH v4 14/20] x86/PV: convert page table emulation code from paddr_t to intpte_t Jan Beulich
2018-02-28 13:09 ` [PATCH v4 15/20] x86emul: correctly handle CMPXCHG* comparison failures Jan Beulich
2018-03-01  7:16   ` Tim Deegan
2018-02-28 13:10 ` [PATCH v4 16/20] x86emul: add read-modify-write hook Jan Beulich
2018-02-28 13:11 ` [PATCH v4 17/20] x86/HVM: do actual CMPXCHG in hvmemul_cmpxchg() Jan Beulich
2018-02-28 13:12 ` [PATCH v4 18/20] x86/HVM: make use of new read-modify-write emulator hook Jan Beulich
2018-02-28 13:13 ` [PATCH v4 19/20] x86/shadow: fully move unmap-dest into common code Jan Beulich
2018-02-28 13:13 ` [PATCH v4 20/20] x86/shadow: fold sh_x86_emulate_{write, cmpxchg}() into their only callers Jan Beulich
2018-03-02  9:21 ` [PATCH v4 00/20] x86: emulator enhancements Razvan Cojocaru

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=c9225289-6cd0-fc96-6e08-6dfa21490657@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --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.