public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "Jiang, Haochen" <haochen.jiang@intel.com>
Cc: "Zhang, Jun" <jun.zhang@intel.com>,
	"binutils@sourceware.org" <binutils@sourceware.org>,
	"hjl.tools@gmail.com" <hjl.tools@gmail.com>
Subject: Re: [PATCH] x86: Add Evw to emit w suffix for several instrctions for word ptr
Date: Wed, 31 May 2023 10:43:30 +0200	[thread overview]
Message-ID: <3a1ab1f6-c7d4-3e0b-7a6f-7ac2fa1ec90e@suse.com> (raw)
In-Reply-To: <SA1PR11MB5946E0AF801D560C642BD9EEEC489@SA1PR11MB5946.namprd11.prod.outlook.com>

On 31.05.2023 07:48, Jiang, Haochen wrote:
>>>> Maybe I got some wrong understanding on that. It comes from the
>>>> current testcase.
>>>> Trying to clarify that on disassembler.
>>>>
>>>> Let's take lldt as example. Will 0f00d2 emit eax register or ax register for
>> lldt?
>>>
>>> One thing to add the current behavior for disassembler or trunk is to
>>> emit ax register. Which I mean always is to as always with other instructions.
>>
>> I'm afraid I don't really get what you concern is. Yes, ...
> 
> I mean, for bytecode 0f00d2, should it emit 'lldt %ax' or 'lldt %eax'?

The former in 16-bit code, the latter elsewhere.

> Currently, in the testcase, it emits 'lldt %ax'. I suppose it actually fits documentation
> and we should not change it.

I think we should change it. Expressing operand size by proper GPR
selection is better than emitting (bogus imo) prefixes. Plus, as
said, before, please see the (in principle similar) move to/from
SREG insn handling.

> BTW, I read SDM today again, for SLDT/STR, they have the exact explanation for
> handling of r32/r64.
> 
> For STR, we have:
> "When the destination operand is a 32-bit register, ..."
> "In 64-bit mode, operation is the same. The size of the memory operand is fixed at 16 bits.
> In register stores, the 2-byte TR is zero extended if stored to a 64-bit register."
> 
> For SLDT, we have:
> "Outside IA-32e mode, when the destination operand is a 32-bit register,..."
> "In compatibility mode, when the destination operand is a 32-bit register,..."
> "In 64-bit mode, using a REX prefix in the form of REX.R permits access to additional
> registers (R8-R15). "
> 
> But for LLDT/LTR/VERW/VERR, things are different. The operands at least will be fixed at 16 bits
> in 64-bit mode.
> For LLDT, we have:
> "The operand-size attribute has no effect on this instruction.
> The LLDT instruction is provided for use in operating-system software; it should not be used
> in application programs. This instruction can only be executed in protected mode or 64-bit mode.
> In 64-bit mode, the operand size is fixed at 16 bits."
> 
> For LTR, we have:
> "The operand-size attribute has no effect on this instruction.
> In 64-bit mode, the operand size is still fixed at 16 bits."
> 
> For VERR/VERW, we have:
> "This instruction’s operation is the same in non-64-bit modes and 64-bit mode. The operand size
> is fixed at 16 bits."
> 
> Therefore, I suppose for VERR/VERW, the 32/64 bit register should never be allowed under any
> circumstances. For LLDT/LTR, in 64-bit mode, it should also the same conclusion. In protected mode
> and compatibility mode, it is questionable. The current implementation of assembler might need a
> fix.

Once again, please compare to other insns where we handle things properly.
Moves to/from SREG, as mentioned above, and things like PEXTRW/PINSRW. The
way the SDM puts things isn't always best; the main goal ought to be
consistency within the disassembler (and, just that it's not relevant here,
the assembler as well, of course).

Jan

  reply	other threads:[~2023-05-31  8:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  6:07 [PATCH v2] Support Intel FRED LKGS Zhang, Jun
2023-05-22  9:11 ` Jan Beulich
2023-05-24  6:36   ` Jiang, Haochen
2023-05-25  7:57     ` Jiang, Haochen
2023-05-25  8:42       ` Jan Beulich
2023-05-26  6:50         ` Jiang, Haochen
2023-05-26  7:00           ` Jan Beulich
2023-05-26  8:26             ` [PATCH] x86: Add Evw to emit w suffix for several instrctions for word ptr Haochen Jiang
2023-05-26  8:46               ` Jan Beulich
2023-05-26  8:54                 ` Jiang, Haochen
2023-05-26 10:52                   ` Jan Beulich
2023-05-29  2:01                     ` Jiang, Haochen
2023-05-29  2:08                       ` Jiang, Haochen
2023-05-30  8:09                         ` Jan Beulich
2023-05-31  5:48                           ` Jiang, Haochen
2023-05-31  8:43                             ` Jan Beulich [this message]
2023-06-01  2:14               ` H.J. Lu

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=3a1ab1f6-c7d4-3e0b-7a6f-7ac2fa1ec90e@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=haochen.jiang@intel.com \
    --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).