public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Zhang, Jun" <jun.zhang@intel.com>
Cc: hjl.tools@gmail.com, binutils@sourceware.org
Subject: Re: [PATCH] Support Intel FRED LKGS
Date: Fri, 19 May 2023 09:08:56 +0200	[thread overview]
Message-ID: <4e4e8321-ce3f-0ee6-2d9d-1855db110978@suse.com> (raw)
In-Reply-To: <20230518034102.1747564-1-jun.zhang@intel.com>

On 18.05.2023 05:41, Zhang, Jun wrote:
> This patch aims to add Intel FRED and LKGS instructions.
> 
> The information is based on newly released
> Intel Flexible Return and Event Delivery(FRED).
> 
> The document comes following:
> https://cdrdv2.intel.com/v1/dl/getContent/678938

You say "newly released", but this link points to a document from May
2022.

> --- a/gas/testsuite/gas/i386/i386.exp
> +++ b/gas/testsuite/gas/i386/i386.exp
> @@ -494,6 +494,7 @@ if [gas_32_check] then {
>      run_dump_test "raoint"
>      run_dump_test "raoint-intel"
>      run_list_test "amx-complex-inval"
> +    run_dump_test "fred"

According to my reading of the spec the new insns aren't legal outside
of 64-bit mode. That's not even "long mode", seeing the spec saying
"FRED transitions also prevents entry to compatibility mode in ring 0."

> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-lkgs.s
> @@ -0,0 +1,21 @@
> +# Check 64bit LKGS instructions
> +
> +	.allow_index_reg
> +	.text
> +_start:
> +	lkgs	%r12	 #LKGS
> +	lkgs    %r12w    #LKGS
> +	lkgsw   %r12w    #LKGS
> +	lkgs	0x10000000(%rbp, %r14, 8)	 #LKGS
> +	lkgs	(%r9)	 #LKGS
> +	lkgs	254(%rcx)	 #LKGS Disp32(fe000000)
> +	lkgs	-256(%rdx)	 #LKGS Disp32(00ffffff)
> +
> +.intel_syntax noprefix
> +	lkgs	r12	 #LKGS
> +	lkgs    r12w     #LKGS
> +        lkgsw   r12w     #LKGS

Nit: Indentation (want to use tab here just like everywhere else).

> @@ -2755,7 +2758,7 @@ static const struct dis386 reg_table[][8] = {
>      { "ltr",	{ Ew }, 0 },
>      { "verr",	{ Ew }, 0 },
>      { "verw",	{ Ew }, 0 },
> -    { Bad_Opcode },
> +    { X86_64_TABLE (X86_64_0F00_REG_6) },
>      { Bad_Opcode },
>    },
>    /* REG_0F01 */
> @@ -2996,6 +2999,14 @@ static const struct dis386 prefix_table[][4] = {
>      { NULL, { { NULL, 0 } }, PREFIX_IGNORED }
>    },
>  
> +  /* PREFIX_0F00_REG_6_X86_64 */
> +  {
> +    { Bad_Opcode },
> +    { Bad_Opcode },
> +    { Bad_Opcode },
> +    { "lkgs",  { Ew }, 0 },
> +  },

While consistent with LTR et al (visible above), I question the use
of Ew here (and there). See below for the assembler side of things,
which this would better be consistent with.

> --- a/opcodes/i386-opc.tbl
> +++ b/opcodes/i386-opc.tbl
> @@ -3351,3 +3351,16 @@ aor, 0xf20f38fc, RAO_INT, Modrm|IgnoreSize|CheckOperandSize|NoSuf, { Reg32|Reg64
>  axor, 0xf30f38fc, RAO_INT, Modrm|IgnoreSize|CheckOperandSize|NoSuf, { Reg32|Reg64, Dword|Qword|Unspecified|BaseIndex }
>  
>  // RAO-INT instructions end.
> +
> +// FRED instructions.
> +
> +erets, 0xf20f01ca, FRED, NoSuf, {}
> +eretu, 0xf30f01ca, FRED, NoSuf, {}

As per above, I think this lacks |x64 (and the disassembler parts would
then need adjusting accordingly).

> +//FRED instructions end.

Nit: Missing blank.

> +// LKGS instructions.
> +
> +lkgs, 0xf20f00/6, LKGS|x64, Modrm|IgnoreSize|No_bSuf|No_lSuf|No_sSuf|No_qSuf|NoRex64, { Reg16|Reg32|Reg64|Word|Unspecified|BaseIndex }

Word is redundant with Reg16, and once omitted you'll notice how what you
have doesn't achieve the intended effect. Please take other similar insns
as reference. Some were split not all that long ago, to properly express
both their register forms (allowing all three widths) and their memory
ones (allowing only 16-bit operands). The set of permitted suffixes also
varies between both.

Jan

      reply	other threads:[~2023-05-19  7:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18  3:41 Zhang, Jun
2023-05-19  7:08 ` Jan Beulich [this message]

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=4e4e8321-ce3f-0ee6-2d9d-1855db110978@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=jun.zhang@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).