Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"The one charm of marriage is that it makes a life of deception a necessity." -- Oscar Wilde


devel / comp.arch / Redundant prefixes break fsrm in Ice Lake

SubjectAuthor
* Redundant prefixes break fsrm in Ice LakeTavis Ormandy
`* Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
 `* Re: Redundant prefixes break fsrm in Ice LakeScott Lurndal
  +* Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  |+* Re: Redundant prefixes break fsrm in Ice LakeBGB
  ||`* Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  || `* Re: Redundant prefixes break fsrm in Ice LakeBGB
  ||  `- Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  |+* Re: Redundant prefixes break fsrm in Ice LakeScott Lurndal
  ||`* Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  || `* Re: Redundant prefixes break fsrm in Ice LakeScott Lurndal
  ||  +- Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  ||  `* Re: Redundant prefixes break fsrm in Ice LakeEricP
  ||   +- Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  ||   `* Re: Redundant prefixes break fsrm in Ice LakeEricP
  ||    +* Re: Redundant prefixes break fsrm in Ice LakeScott Lurndal
  ||    |`- Re: Redundant prefixes break fsrm in Ice LakeTerje Mathisen
  ||    +* Re: Redundant prefixes break fsrm in Ice LakeJohn Levine
  ||    |+* Re: Redundant prefixes break fsrm in Ice LakeAnton Ertl
  ||    ||`- Re: Redundant prefixes break fsrm in Ice LakeJohn Levine
  ||    |`- Re: Redundant prefixes break fsrm in Ice LakeChris M. Thomasson
  ||    `* Re: Redundant prefixes break fsrm in Ice LakeAnton Ertl
  ||     `* Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
  ||      `* Hints in the instruction set (was: Redundant prefixes break fsrm ...)Anton Ertl
  ||       `* Re: Hints in the instruction set (was: Redundant prefixes breakThomas Koenig
  ||        +- Re: Hints in the instruction set (was: Redundant prefixes break fsrm ...)Scott Lurndal
  ||        `* Re: Hints in the instruction set (was: Redundant prefixes break fsrm ...)Anton Ertl
  ||         +* Re: Hints in the instruction set (was: Redundant prefixes breakThomas Koenig
  ||         |+* Re: Hints in the instruction set (was: Redundant prefixes break fsrm ...)Scott Lurndal
  ||         ||`- Re: Hints in the instruction set (was: Redundant prefixes breakThomas Koenig
  ||         |`- Re: Hints in the instruction set (was: Redundant prefixes break fsrm ...)Anton Ertl
  ||         +- Re: Hints in the instruction set (was: Redundant prefixes break fsrm ...)Scott Lurndal
  ||         +* Re: Hints in the instruction setMitchAlsup
  ||         |+- Re: Hints in the instruction setStephen Fuld
  ||         |+* Re: Hints in the instruction setGeorge Neuner
  ||         ||+* Re: Hints in the instruction setThomas Koenig
  ||         |||`- Re: Hints in the instruction setGeorge Neuner
  ||         ||`* Re: Hints in the instruction setNiklas Holsti
  ||         || `* Re: Hints in the instruction setStefan Monnier
  ||         ||  `- Re: Hints in the instruction setMitchAlsup
  ||         |`- Re: Hints in the instruction setScott Lurndal
  ||         `* Re: Hints in the instruction setNiklas Holsti
  ||          +* Re: Hints in the instruction setAnton Ertl
  ||          |`- Re: Hints in the instruction setNiklas Holsti
  ||          `- Re: Hints in the instruction setStefan Monnier
  |`- Re: Redundant prefixes break fsrm in Ice LakeTerje Mathisen
  `* Re: Redundant prefixes break fsrm in Ice LakeJohn Levine
   +- Re: Redundant prefixes break fsrm in Ice LakeMitchAlsup
   +- Re: Redundant prefixes break fsrm in Ice LakeTerje Mathisen
   `- Re: Redundant prefixes break fsrm in Ice LakePaul A. Clayton

Pages:12
Redundant prefixes break fsrm in Ice Lake

<krk4lqF2q4oU1@mid.individual.net>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35007&group=comp.arch#35007

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: taviso@gmail.com (Tavis Ormandy)
Newsgroups: comp.arch
Subject: Redundant prefixes break fsrm in Ice Lake
Date: 15 Nov 2023 14:59:06 GMT
Lines: 16
Message-ID: <krk4lqF2q4oU1@mid.individual.net>
X-Trace: individual.net IKT5O/qZ7ZFjGrd1SX49wQOQbpPuQMcILViqqP/BsfS8Bw0R74
Cancel-Lock: sha1:0i3/tYM/iqa0+xiuK5DVuVjG3es= sha256:K48Zoo+JypGHgVsrw8L0dHQfYLpHDxfx6MA6cZj0g7M=
User-Agent: slrn/1.0.3 (Linux)
 by: Tavis Ormandy - Wed, 15 Nov 2023 14:59 UTC

I thought this might interest some posters here, I wrote up a bug we
discovered in the fast short repeat move feature added in Ice Lake.

The quick summary is that adding a redundant rex.r prefix to movsb seems
to cause ROB entries to be associated with incorrect addresses. I have
no special insight into what the microcode is doing, maybe some reader
here can read between the lines and explain what is going on :)

https://lock.cmpxchg8b.com/reptar.html

Tavis.

--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger taviso@sdf.org
_\_V _( ) _( ) @taviso

Re: Redundant prefixes break fsrm in Ice Lake

<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35012&group=comp.arch#35012

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 19:10:13 +0000
Organization: novaBBS
Message-ID: <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1025270"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$yOTUInEm8jOpRzmfUnvk.e8jY8ZDtZtvhKYduOPLNZeaoN7s4qlvm
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
 by: MitchAlsup - Wed, 15 Nov 2023 19:10 UTC

Tavis Ormandy wrote:

> I thought this might interest some posters here, I wrote up a bug we
> discovered in the fast short repeat move feature added in Ice Lake.

> The quick summary is that adding a redundant rex.r prefix to movsb seems
> to cause ROB entries to be associated with incorrect addresses. I have
> no special insight into what the microcode is doing, maybe some reader
> here can read between the lines and explain what is going on :)

> https://lock.cmpxchg8b.com/reptar.html
<
My GUESS has to do with how instruction-boundaries are determined.
When the decoder encounters a prefix, it latches prefix data and goes
on decoding. So, if you have multiple prefixes of the same flavor,
instead of latching only the last (or first) prefix data, but instead
ORs all the prefix data of a "kind" of prefix into a prefix container
then execution is delivered a different pattern of bits than the programmer
expected.
<
But who ever decided multiple prefixes of the same kind are LEGAL ??

> Tavis.

Re: Redundant prefixes break fsrm in Ice Lake

<uH95N.42963$BbXa.19732@fx16.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35015&group=comp.arch#35015

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Newsgroups: comp.arch
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
Lines: 24
Message-ID: <uH95N.42963$BbXa.19732@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 15 Nov 2023 20:17:30 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 15 Nov 2023 20:17:30 GMT
X-Received-Bytes: 1853
 by: Scott Lurndal - Wed, 15 Nov 2023 20:17 UTC

mitchalsup@aol.com (MitchAlsup) writes:
>Tavis Ormandy wrote:
>
>> I thought this might interest some posters here, I wrote up a bug we
>> discovered in the fast short repeat move feature added in Ice Lake.
>
>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>> to cause ROB entries to be associated with incorrect addresses. I have
>> no special insight into what the microcode is doing, maybe some reader
>> here can read between the lines and explain what is going on :)
>
>> https://lock.cmpxchg8b.com/reptar.html
><
>My GUESS has to do with how instruction-boundaries are determined.
>When the decoder encounters a prefix, it latches prefix data and goes
>on decoding. So, if you have multiple prefixes of the same flavor,
>instead of latching only the last (or first) prefix data, but instead
>ORs all the prefix data of a "kind" of prefix into a prefix container
>then execution is delivered a different pattern of bits than the programmer
>expected.
><
>But who ever decided multiple prefixes of the same kind are LEGAL ??

The compiler people use multiple prefixes to align code.

Re: Redundant prefixes break fsrm in Ice Lake

<20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35020&group=comp.arch#35020

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 20:57:58 +0000
Organization: novaBBS
Message-ID: <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1035075"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Rslight-Site: $2y$10$zJOZof0cobmmTcec7LNQg./NRxsdFvlB8pn/GgyMFSmlJDar8FbB2
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
 by: MitchAlsup - Wed, 15 Nov 2023 20:57 UTC

Scott Lurndal wrote:

> mitchalsup@aol.com (MitchAlsup) writes:
>>Tavis Ormandy wrote:
>>
>>> I thought this might interest some posters here, I wrote up a bug we
>>> discovered in the fast short repeat move feature added in Ice Lake.
>>
>>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>>> to cause ROB entries to be associated with incorrect addresses. I have
>>> no special insight into what the microcode is doing, maybe some reader
>>> here can read between the lines and explain what is going on :)
>>
>>> https://lock.cmpxchg8b.com/reptar.html
>><
>>My GUESS has to do with how instruction-boundaries are determined.
>>When the decoder encounters a prefix, it latches prefix data and goes
>>on decoding. So, if you have multiple prefixes of the same flavor,
>>instead of latching only the last (or first) prefix data, but instead
>>ORs all the prefix data of a "kind" of prefix into a prefix container
>>then execution is delivered a different pattern of bits than the programmer
>>expected.
>><
>>But who ever decided multiple prefixes of the same kind are LEGAL ??

> The compiler people use multiple prefixes to align code.

The code is already byte aligned, what more is necessary ??

Re: Redundant prefixes break fsrm in Ice Lake

<uj3h67$1u35v$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35028&group=comp.arch#35028

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: cr88192@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 16:36:51 -0600
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <uj3h67$1u35v$1@dont-email.me>
References: <krk4lqF2q4oU1@mid.individual.net>
<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
<uH95N.42963$BbXa.19732@fx16.iad>
<20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 15 Nov 2023 22:36:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="34db5d9d29960da6baf9b79e620d060a";
logging-data="2034879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XClyVZqi6e4sI7vjnskAA"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:vvTZwucPxbFRek79ABG3+YZU7jo=
Content-Language: en-US
In-Reply-To: <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
 by: BGB - Wed, 15 Nov 2023 22:36 UTC

On 11/15/2023 2:57 PM, MitchAlsup wrote:
> Scott Lurndal wrote:
>
>> mitchalsup@aol.com (MitchAlsup) writes:
>>> Tavis Ormandy wrote:
>>>
>>>> I thought this might interest some posters here, I wrote up a bug we
>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>
>>>> The quick summary is that adding a redundant rex.r prefix to movsb
>>>> seems
>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>> no special insight into what the microcode is doing, maybe some reader
>>>> here can read between the lines and explain what is going on :)
>>>
>>>> https://lock.cmpxchg8b.com/reptar.html
>>> <
>>> My GUESS has to do with how instruction-boundaries are determined.
>>> When the decoder encounters a prefix, it latches prefix data and goes
>>> on decoding. So, if you have multiple prefixes of the same flavor,
>>> instead of latching only the last (or first) prefix data, but instead
>>> ORs all the prefix data of a "kind" of prefix into a prefix container
>>> then execution is delivered a different pattern of bits than the
>>> programmer
>>> expected.
>>> <
>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>
>> The compiler people use multiple prefixes to align code.
>
> The code is already byte aligned, what more is necessary ??

I think it is semi-common to align function entry points and some labels
and similar, but IME this was usually done with NOP or "INT 3"
instructions or similar...

I think the idea here is that aligning a function entry points can
potentially make the function calls slightly faster due to "cache magic"
or similar. Also INT3 crashes the program if it tries to branch into
this padding space.

But, at least, much beyond this, it is unclear how alignment would be
needed or beneficial on x86 or x86-64.

And, to this end (if one needs inline padding), using one of the
multi-byte NOP sequences seems less likely to invoke weird/undefined
behavior than trying to do something weird with opcode prefixes...

Re: Redundant prefixes break fsrm in Ice Lake

<C_b5N.1151$PJoc.138@fx04.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35030&group=comp.arch#35030

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx04.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Newsgroups: comp.arch
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
Lines: 36
Message-ID: <C_b5N.1151$PJoc.138@fx04.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 15 Nov 2023 22:54:26 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 15 Nov 2023 22:54:26 GMT
X-Received-Bytes: 2232
 by: Scott Lurndal - Wed, 15 Nov 2023 22:54 UTC

mitchalsup@aol.com (MitchAlsup) writes:
>Scott Lurndal wrote:
>
>> mitchalsup@aol.com (MitchAlsup) writes:
>>>Tavis Ormandy wrote:
>>>
>>>> I thought this might interest some posters here, I wrote up a bug we
>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>
>>>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>> no special insight into what the microcode is doing, maybe some reader
>>>> here can read between the lines and explain what is going on :)
>>>
>>>> https://lock.cmpxchg8b.com/reptar.html
>>><
>>>My GUESS has to do with how instruction-boundaries are determined.
>>>When the decoder encounters a prefix, it latches prefix data and goes
>>>on decoding. So, if you have multiple prefixes of the same flavor,
>>>instead of latching only the last (or first) prefix data, but instead
>>>ORs all the prefix data of a "kind" of prefix into a prefix container
>>>then execution is delivered a different pattern of bits than the programmer
>>>expected.
>>><
>>>But who ever decided multiple prefixes of the same kind are LEGAL ??
>
>> The compiler people use multiple prefixes to align code.
>
>The code is already byte aligned, what more is necessary ??

I refer you to the Intel Architecture Software Optimization Guide.

Specifically:

"Assembly/Compiler Coding Rule 12. (M impact, H generality) All branch
targets should be 16-byte aligned."

Re: Redundant prefixes break fsrm in Ice Lake

<d68814642879e7a41e62931f7c9f7374@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35034&group=comp.arch#35034

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 23:34:46 +0000
Organization: novaBBS
Message-ID: <d68814642879e7a41e62931f7c9f7374@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <uj3h67$1u35v$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1046635"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$qeuZ7Lxn8Yk3.pnzt.lPQeYz8t8CbeAN.mzumdF96yVcgZ8070wBm
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
 by: MitchAlsup - Wed, 15 Nov 2023 23:34 UTC

BGB wrote:

> On 11/15/2023 2:57 PM, MitchAlsup wrote:
>> Scott Lurndal wrote:
>>
>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>> Tavis Ormandy wrote:
>>>>
>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>
>>>>> The quick summary is that adding a redundant rex.r prefix to movsb
>>>>> seems
>>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>>> no special insight into what the microcode is doing, maybe some reader
>>>>> here can read between the lines and explain what is going on :)
>>>>
>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>> <
>>>> My GUESS has to do with how instruction-boundaries are determined.
>>>> When the decoder encounters a prefix, it latches prefix data and goes
>>>> on decoding. So, if you have multiple prefixes of the same flavor,
>>>> instead of latching only the last (or first) prefix data, but instead
>>>> ORs all the prefix data of a "kind" of prefix into a prefix container
>>>> then execution is delivered a different pattern of bits than the
>>>> programmer
>>>> expected.
>>>> <
>>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>>
>>> The compiler people use multiple prefixes to align code.
>>
>> The code is already byte aligned, what more is necessary ??

> I think it is semi-common to align function entry points and some labels
> and similar, but IME this was usually done with NOP or "INT 3"
> instructions or similar...
<
Yes, this is common (and useful)
<
How many functions start off with REP REP REP MOVS ??
<
> I think the idea here is that aligning a function entry points can
> potentially make the function calls slightly faster due to "cache magic"
> or similar. Also INT3 crashes the program if it tries to branch into
> this padding space.
<
But REP REP REP MOVS never occurs at the entry point of a function !!
<
> But, at least, much beyond this, it is unclear how alignment would be
> needed or beneficial on x86 or x86-64.

> And, to this end (if one needs inline padding), using one of the
> multi-byte NOP sequences seems less likely to invoke weird/undefined
> behavior than trying to do something weird with opcode prefixes...

Re: Redundant prefixes break fsrm in Ice Lake

<bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35035&group=comp.arch#35035

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 23:36:15 +0000
Organization: novaBBS
Message-ID: <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1047086"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$VlR5pn3lUU0cDDBbxGY07OQo76KQ7rkNdNfeq4k/eTlfFe0F8Pp3q
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
 by: MitchAlsup - Wed, 15 Nov 2023 23:36 UTC

Scott Lurndal wrote:

> mitchalsup@aol.com (MitchAlsup) writes:
>>Scott Lurndal wrote:
>>
>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>Tavis Ormandy wrote:
>>>>
>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>
>>>>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>>> no special insight into what the microcode is doing, maybe some reader
>>>>> here can read between the lines and explain what is going on :)
>>>>
>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>><
>>>>My GUESS has to do with how instruction-boundaries are determined.
>>>>When the decoder encounters a prefix, it latches prefix data and goes
>>>>on decoding. So, if you have multiple prefixes of the same flavor,
>>>>instead of latching only the last (or first) prefix data, but instead
>>>>ORs all the prefix data of a "kind" of prefix into a prefix container
>>>>then execution is delivered a different pattern of bits than the programmer
>>>>expected.
>>>><
>>>>But who ever decided multiple prefixes of the same kind are LEGAL ??
>>
>>> The compiler people use multiple prefixes to align code.
>>
>>The code is already byte aligned, what more is necessary ??

> I refer you to the Intel Architecture Software Optimization Guide.

> Specifically:

> "Assembly/Compiler Coding Rule 12. (M impact, H generality) All branch
> targets should be 16-byte aligned."
<
How many branch targets have REP REP REP MOVS at the label??
<
You see, these REP REP REP MOVS's almost invariably have preceding instructions
following label boundaries.

Re: Redundant prefixes break fsrm in Ice Lake

<uj3llo$1un68$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35037&group=comp.arch#35037

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: cr88192@gmail.com (BGB)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Wed, 15 Nov 2023 17:53:25 -0600
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <uj3llo$1un68$1@dont-email.me>
References: <krk4lqF2q4oU1@mid.individual.net>
<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
<uH95N.42963$BbXa.19732@fx16.iad>
<20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
<uj3h67$1u35v$1@dont-email.me>
<d68814642879e7a41e62931f7c9f7374@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 15 Nov 2023 23:53:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a1f463517c6df1b99222afdffecdc56c";
logging-data="2055368"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kC73GgCwxUf7dE7Hikurb"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:K19uwaRsKPxQv2Q97e5EA07NV0Q=
In-Reply-To: <d68814642879e7a41e62931f7c9f7374@news.novabbs.com>
Content-Language: en-US
 by: BGB - Wed, 15 Nov 2023 23:53 UTC

On 11/15/2023 5:34 PM, MitchAlsup wrote:
> BGB wrote:
>
>> On 11/15/2023 2:57 PM, MitchAlsup wrote:
>>> Scott Lurndal wrote:
>>>
>>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>> Tavis Ormandy wrote:
>>>>>
>>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>>
>>>>>> The quick summary is that adding a redundant rex.r prefix to movsb
>>>>>> seems
>>>>>> to cause ROB entries to be associated with incorrect addresses. I
>>>>>> have
>>>>>> no special insight into what the microcode is doing, maybe some
>>>>>> reader
>>>>>> here can read between the lines and explain what is going on :)
>>>>>
>>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>>> <
>>>>> My GUESS has to do with how instruction-boundaries are determined.
>>>>> When the decoder encounters a prefix, it latches prefix data and goes
>>>>> on decoding. So, if you have multiple prefixes of the same flavor,
>>>>> instead of latching only the last (or first) prefix data, but instead
>>>>> ORs all the prefix data of a "kind" of prefix into a prefix container
>>>>> then execution is delivered a different pattern of bits than the
>>>>> programmer
>>>>> expected.
>>>>> <
>>>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>>>
>>>> The compiler people use multiple prefixes to align code.
>>>
>>> The code is already byte aligned, what more is necessary ??
>
>> I think it is semi-common to align function entry points and some
>> labels and similar, but IME this was usually done with NOP or "INT 3"
>> instructions or similar...
> <
> Yes, this is common (and useful)
> <
> How many functions start off with REP REP REP MOVS ??
> <
>> I think the idea here is that aligning a function entry points can
>> potentially make the function calls slightly faster due to "cache
>> magic" or similar. Also INT3 crashes the program if it tries to branch
>> into this padding space.
> <
> But REP REP REP MOVS never occurs at the entry point of a function !!
> <

Granted, yes, I have not seen this one.

IME, it is usually something like:
...; INT3; INT3; INT3; PUSH RBP; MOV RBP, RSP; ...
Or similar...

And, at the end of a function:
RET; NOP; NOP; ...; INT3; INT3; ...

With any label-alignment via one of the multi-byte NOP encodings.

>> But, at least, much beyond this, it is unclear how alignment would be
>> needed or beneficial on x86 or x86-64.
>
>> And, to this end (if one needs inline padding), using one of the
>> multi-byte NOP sequences seems less likely to invoke weird/undefined
>> behavior than trying to do something weird with opcode prefixes...

Re: Redundant prefixes break fsrm in Ice Lake

<jud5N.2430$DADd.1857@fx38.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35041&group=comp.arch#35041

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx38.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Newsgroups: comp.arch
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com>
Lines: 52
Message-ID: <jud5N.2430$DADd.1857@fx38.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 16 Nov 2023 00:36:31 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 16 Nov 2023 00:36:31 GMT
X-Received-Bytes: 2885
 by: Scott Lurndal - Thu, 16 Nov 2023 00:36 UTC

mitchalsup@aol.com (MitchAlsup) writes:
>Scott Lurndal wrote:
>
>> mitchalsup@aol.com (MitchAlsup) writes:
>>>Scott Lurndal wrote:
>>>
>>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>>Tavis Ormandy wrote:
>>>>>
>>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>>
>>>>>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>>>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>>>> no special insight into what the microcode is doing, maybe some reader
>>>>>> here can read between the lines and explain what is going on :)
>>>>>
>>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>>><
>>>>>My GUESS has to do with how instruction-boundaries are determined.
>>>>>When the decoder encounters a prefix, it latches prefix data and goes
>>>>>on decoding. So, if you have multiple prefixes of the same flavor,
>>>>>instead of latching only the last (or first) prefix data, but instead
>>>>>ORs all the prefix data of a "kind" of prefix into a prefix container
>>>>>then execution is delivered a different pattern of bits than the programmer
>>>>>expected.
>>>>><
>>>>>But who ever decided multiple prefixes of the same kind are LEGAL ??
>>>
>>>> The compiler people use multiple prefixes to align code.
>>>
>>>The code is already byte aligned, what more is necessary ??
>
>> I refer you to the Intel Architecture Software Optimization Guide.
>
>> Specifically:
>
>> "Assembly/Compiler Coding Rule 12. (M impact, H generality) All branch
>> targets should be 16-byte aligned."
><
>How many branch targets have REP REP REP MOVS at the label??
><
>You see, these REP REP REP MOVS's almost invariably have preceding instructions
>following label boundaries.

In looking at a fairly recent ELF binary, mostly I see various length
nops, and a bunch of 'repz retq' sequences.

58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)

58eaf0: f3 c3 repz retq

Re: Redundant prefixes break fsrm in Ice Lake

<uj3pc4$30tr$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35043&group=comp.arch#35043

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 00:56:36 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <uj3pc4$30tr$1@gal.iecc.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad>
Injection-Date: Thu, 16 Nov 2023 00:56:36 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="99259"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Thu, 16 Nov 2023 00:56 UTC

According to Scott Lurndal <slp53@pacbell.net>:
>>But who ever decided multiple prefixes of the same kind are LEGAL ??
>
>The compiler people use multiple prefixes to align code.

What? Why wouldn't you use a NOP? The Intel manual has a list
of NOPs with sizes from one byte to nine.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Redundant prefixes break fsrm in Ice Lake

<5655dfb69e02f3329c612cf93d25fa2f@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35047&group=comp.arch#35047

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 03:00:41 +0000
Organization: novaBBS
Message-ID: <5655dfb69e02f3329c612cf93d25fa2f@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <uj3h67$1u35v$1@dont-email.me> <d68814642879e7a41e62931f7c9f7374@news.novabbs.com> <uj3llo$1un68$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1061119"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Rslight-Site: $2y$10$FPaUmXhohhAfJ5hE3OzFtOUkEPkuyuJ/mU2vh6ktnSl.K5VkxH3qe
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
 by: MitchAlsup - Thu, 16 Nov 2023 03:00 UTC

BGB wrote:

> On 11/15/2023 5:34 PM, MitchAlsup wrote:
>> BGB wrote:
>>
>>> On 11/15/2023 2:57 PM, MitchAlsup wrote:
>>>> Scott Lurndal wrote:
>>>>
>>>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>>> Tavis Ormandy wrote:
>>>>>>
>>>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>>>
>>>>>>> The quick summary is that adding a redundant rex.r prefix to movsb
>>>>>>> seems
>>>>>>> to cause ROB entries to be associated with incorrect addresses. I
>>>>>>> have
>>>>>>> no special insight into what the microcode is doing, maybe some
>>>>>>> reader
>>>>>>> here can read between the lines and explain what is going on :)
>>>>>>
>>>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>>>> <
>>>>>> My GUESS has to do with how instruction-boundaries are determined.
>>>>>> When the decoder encounters a prefix, it latches prefix data and goes
>>>>>> on decoding. So, if you have multiple prefixes of the same flavor,
>>>>>> instead of latching only the last (or first) prefix data, but instead
>>>>>> ORs all the prefix data of a "kind" of prefix into a prefix container
>>>>>> then execution is delivered a different pattern of bits than the
>>>>>> programmer
>>>>>> expected.
>>>>>> <
>>>>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>>>>
>>>>> The compiler people use multiple prefixes to align code.
>>>>
>>>> The code is already byte aligned, what more is necessary ??
>>
>>> I think it is semi-common to align function entry points and some
>>> labels and similar, but IME this was usually done with NOP or "INT 3"
>>> instructions or similar...
>> <
>> Yes, this is common (and useful)
>> <
>> How many functions start off with REP REP REP MOVS ??
>> <
>>> I think the idea here is that aligning a function entry points can
>>> potentially make the function calls slightly faster due to "cache
>>> magic" or similar. Also INT3 crashes the program if it tries to branch
>>> into this padding space.
>> <
>> But REP REP REP MOVS never occurs at the entry point of a function !!
>> <

> Granted, yes, I have not seen this one.

> IME, it is usually something like:
> ...; INT3; INT3; INT3; PUSH RBP; MOV RBP, RSP; ...
> Or similar...

> And, at the end of a function:
> RET; NOP; NOP; ...; INT3; INT3; ...

> With any label-alignment via one of the multi-byte NOP encodings.

Yes, but control leaves the previous function at RET and control arrives at
the next function at INT3 so the NOPs are never actually executed. And if
you looked at the ASCII assembly, you will see::

RET
NOP
NOP
label:
INT3

>>> But, at least, much beyond this, it is unclear how alignment would be
>>> needed or beneficial on x86 or x86-64.
>>
>>> And, to this end (if one needs inline padding), using one of the
>>> multi-byte NOP sequences seems less likely to invoke weird/undefined
>>> behavior than trying to do something weird with opcode prefixes...

Re: Redundant prefixes break fsrm in Ice Lake

<46957b847effa62b7a85c220b446ac82@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35048&group=comp.arch#35048

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 03:07:17 +0000
Organization: novaBBS
Message-ID: <46957b847effa62b7a85c220b446ac82@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <uj3pc4$30tr$1@gal.iecc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1061337"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Rslight-Site: $2y$10$uYYrNRg26GDhr/kJIqstiuOUSeq1GWIitpeG0dZu0EUPHpirdk6cG
 by: MitchAlsup - Thu, 16 Nov 2023 03:07 UTC

Is there somethings wrong with

...
RET
.align 64B
Function:
...

??

Re: Redundant prefixes break fsrm in Ice Lake

<686ab3e35da46a8f406226417bc25246@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35049&group=comp.arch#35049

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 03:06:11 +0000
Organization: novaBBS
Message-ID: <686ab3e35da46a8f406226417bc25246@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1061337"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Site: $2y$10$TPf4msJ1idvAwXP7jxp/cOpP/S2Q066q3XHUWBIf7cRDx9XPtPaWW
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
 by: MitchAlsup - Thu, 16 Nov 2023 03:06 UTC

Scott Lurndal wrote:

> mitchalsup@aol.com (MitchAlsup) writes:
>>Scott Lurndal wrote:
>>
>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>Scott Lurndal wrote:
>>>>
>>>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>>>>Tavis Ormandy wrote:
>>>>>>
>>>>>>> I thought this might interest some posters here, I wrote up a bug we
>>>>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>>>>
>>>>>>> The quick summary is that adding a redundant rex.r prefix to movsb seems
>>>>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>>>>> no special insight into what the microcode is doing, maybe some reader
>>>>>>> here can read between the lines and explain what is going on :)
>>>>>>
>>>>>>> https://lock.cmpxchg8b.com/reptar.html
>>>>>><
>>>>>>My GUESS has to do with how instruction-boundaries are determined.
>>>>>>When the decoder encounters a prefix, it latches prefix data and goes
>>>>>>on decoding. So, if you have multiple prefixes of the same flavor,
>>>>>>instead of latching only the last (or first) prefix data, but instead
>>>>>>ORs all the prefix data of a "kind" of prefix into a prefix container
>>>>>>then execution is delivered a different pattern of bits than the programmer
>>>>>>expected.
>>>>>><
>>>>>>But who ever decided multiple prefixes of the same kind are LEGAL ??
>>>>
>>>>> The compiler people use multiple prefixes to align code.
>>>>
>>>>The code is already byte aligned, what more is necessary ??
>>
>>> I refer you to the Intel Architecture Software Optimization Guide.
>>
>>> Specifically:
>>
>>> "Assembly/Compiler Coding Rule 12. (M impact, H generality) All branch
>>> targets should be 16-byte aligned."
>><
>>How many branch targets have REP REP REP MOVS at the label??
>><
>>You see, these REP REP REP MOVS's almost invariably have preceding instructions
>>following label boundaries.

> In looking at a fairly recent ELF binary, mostly I see various length
> nops, and a bunch of 'repz retq' sequences.

> 58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)

> 58eaf0: f3 c3 repz retq

face it:: x86 is so broken it is amazing that it works at all.

And never postulate that this is the BEST way of padding to some useful
boundary--just like 68K used to

CMP D1,#7
BNE ELSE
// then clause
...
...
MOV dummy,#DW // consume the inst in the Else clause
ELSE:
INST // The immediate of the MOV consumes this instruction
// join point

And if you EVER get the chance of do your own ISA, make sure there is no
way to and no need to do these kinds of things.

Re: Redundant prefixes break fsrm in Ice Lake

<uj4g7v$25rvl$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35050&group=comp.arch#35050

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 08:26:55 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <uj4g7v$25rvl$1@dont-email.me>
References: <krk4lqF2q4oU1@mid.individual.net>
<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
<uH95N.42963$BbXa.19732@fx16.iad>
<20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 16 Nov 2023 07:26:56 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ce828b1a04a3eb4bcdc69e7ccad4aa04";
logging-data="2289653"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OPLWBHp7eXflBzz0YXaHhU4OgK1D6gV98zZdLemCQ7g=="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:O0hXAgTYwEQalA7iADcvCmdjXyI=
In-Reply-To: <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com>
 by: Terje Mathisen - Thu, 16 Nov 2023 07:26 UTC

MitchAlsup wrote:
> Scott Lurndal wrote:
>
>> mitchalsup@aol.com (MitchAlsup) writes:
>>> Tavis Ormandy wrote:
>>>
>>>> I thought this might interest some posters here, I wrote up a bug we
>>>> discovered in the fast short repeat move feature added in Ice Lake.
>>>
>>>> The quick summary is that adding a redundant rex.r prefix to movsb
>>>> seems
>>>> to cause ROB entries to be associated with incorrect addresses. I have
>>>> no special insight into what the microcode is doing, maybe some reader
>>>> here can read between the lines and explain what is going on :)
>>>
>>>> https://lock.cmpxchg8b.com/reptar.html
>>> <
>>> My GUESS has to do with how instruction-boundaries are determined.
>>> When the decoder encounters a prefix, it latches prefix data and goes
>>> on decoding. So, if you have multiple prefixes of the same flavor,
>>> instead of latching only the last (or first) prefix data, but instead
>>> ORs all the prefix data of a "kind" of prefix into a prefix container
>>> then execution is delivered a different pattern of bits than the
>>> programmer
>>> expected.
>>> <
>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>
>> The compiler people use multiple prefixes to align code.
>
> The code is already byte aligned, what more is necessary ??

Some loops, on some machines, run faster if the loop top is cache line
aligned (or maybe 16-byte/32-byte aligned), since that allows the entire
loop to fit within a single cache line, or whatever the loop buffer is?

I'm not arguing with you that it shouldn't be needed, just that there
have been and are several machines which do benefit from it.

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Redundant prefixes break fsrm in Ice Lake

<uj4rd5$27jh1$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35051&group=comp.arch#35051

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: terje.mathisen@tmsw.no (Terje Mathisen)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Thu, 16 Nov 2023 11:37:25 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uj4rd5$27jh1$1@dont-email.me>
References: <krk4lqF2q4oU1@mid.individual.net>
<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
<uH95N.42963$BbXa.19732@fx16.iad> <uj3pc4$30tr$1@gal.iecc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 16 Nov 2023 10:37:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ce828b1a04a3eb4bcdc69e7ccad4aa04";
logging-data="2346529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jyhPMqZlvvQSnmiNxlcWfT2w4iMyxLeVufQuCPmbXCw=="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Firefox/91.0 SeaMonkey/2.53.17.1
Cancel-Lock: sha1:VByVTZ2VMhmeLJWzKtHjuEBo5GY=
In-Reply-To: <uj3pc4$30tr$1@gal.iecc.com>
 by: Terje Mathisen - Thu, 16 Nov 2023 10:37 UTC

John Levine wrote:
> According to Scott Lurndal <slp53@pacbell.net>:
>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>>
>> The compiler people use multiple prefixes to align code.
>
> What? Why wouldn't you use a NOP? The Intel manual has a list
> of NOPs with sizes from one byte to nine.

Maybe because a few added/redundant prefix bytes on an instruction you
are going to do anyway could be even cheaper/faster than a NOP?

I.e. 0 vs 1 cycle (or a fraction thereof on average)?

Terje

--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

Re: Redundant prefixes break fsrm in Ice Lake

<gnr5N.37909$AqO5.27034@fx11.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35057&group=comp.arch#35057

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
From: ThatWouldBeTelling@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad>
In-Reply-To: <jud5N.2430$DADd.1857@fx38.iad>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 28
Message-ID: <gnr5N.37909$AqO5.27034@fx11.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Thu, 16 Nov 2023 16:24:44 UTC
Date: Thu, 16 Nov 2023 11:23:05 -0500
X-Received-Bytes: 1870
 by: EricP - Thu, 16 Nov 2023 16:23 UTC

Scott Lurndal wrote:
> mitchalsup@aol.com (MitchAlsup) writes:
>> <
>> How many branch targets have REP REP REP MOVS at the label??
>> <
>> You see, these REP REP REP MOVS's almost invariably have preceding instructions
>> following label boundaries.
>
>
> In looking at a fairly recent ELF binary, mostly I see various length
> nops, and a bunch of 'repz retq' sequences.
>
> 58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
>
> 58eaf0: f3 c3 repz retq

Intel Instruction manual vol2 section 2.1:

"Use of repeat prefixes and/or undefined opcodes with other Intel 64 or
IA-32 instructions is reserved; such use may cause unpredictable behavior"

These prefix rules were added relatively recently (maybe last 10 years?).
While they only allow one prefix from each of Group 1..4,
they still allow prefix bytes to be in any order thereby wasting
much opcode space on redundant premutations and combinations.

Re: Redundant prefixes break fsrm in Ice Lake

<dc93663877eddc7d7ba231ee1fbbf1ad@news.novabbs.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35069&group=comp.arch#35069

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!.POSTED!not-for-mail
From: mitchalsup@aol.com (MitchAlsup)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Fri, 17 Nov 2023 18:42:18 +0000
Organization: novaBBS
Message-ID: <dc93663877eddc7d7ba231ee1fbbf1ad@news.novabbs.com>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: i2pn2.org;
logging-data="1244319"; mail-complaints-to="usenet@i2pn2.org";
posting-account="t+lO0yBNO1zGxasPvGSZV1BRu71QKx+JE37DnW+83jQ";
User-Agent: Rocksolid Light
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on novalink.us
X-Rslight-Posting-User: 7e9c45bcd6d4757c5904fbe9a694742e6f8aa949
X-Rslight-Site: $2y$10$PY5Iv78qmMPgEK9dw9PimuRjydtvrtAd4f/L5GPM8ZfJpPhistTSa
 by: MitchAlsup - Fri, 17 Nov 2023 18:42 UTC

EricP wrote:

> Scott Lurndal wrote:
>> mitchalsup@aol.com (MitchAlsup) writes:
>>> <
>>> How many branch targets have REP REP REP MOVS at the label??
>>> <
>>> You see, these REP REP REP MOVS's almost invariably have preceding instructions
>>> following label boundaries.
>>
>>
>> In looking at a fairly recent ELF binary, mostly I see various length
>> nops, and a bunch of 'repz retq' sequences.
>>
>> 58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
>>
>> 58eaf0: f3 c3 repz retq

> Intel Instruction manual vol2 section 2.1:

> "Use of repeat prefixes and/or undefined opcodes with other Intel 64 or
> IA-32 instructions is reserved; such use may cause unpredictable behavior"

> These prefix rules were added relatively recently (maybe last 10 years?).
> While they only allow one prefix from each of Group 1..4,
> they still allow prefix bytes to be in any order thereby wasting
> much opcode space on redundant premutations and combinations.

This is what I was talking about; the decoder is just routing data to
a set of storage containers and only after identifying the OpCode, do
these containers modify the behavior of the instruction during execution.
The decoder would not "count" the prefixes, just route data, and if
data came from multiple locations, what gets latched in the container
becomes mask specific.

And since they are reserved, your random code generator should not be
generating them.

Re: Redundant prefixes break fsrm in Ice Lake

<uj9bjk$364a7$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35078&group=comp.arch#35078

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!nntp.comgw.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: paaronclayton@gmail.com (Paul A. Clayton)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Fri, 17 Nov 2023 22:38:26 -0500
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <uj9bjk$364a7$1@dont-email.me>
References: <krk4lqF2q4oU1@mid.individual.net>
<36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com>
<uH95N.42963$BbXa.19732@fx16.iad> <uj3pc4$30tr$1@gal.iecc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 18 Nov 2023 03:38:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9193afc5587e9a4ddd0cbd7767e23453";
logging-data="3346759"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JsBtu2H/pG7y/2SzrZaiMzZfHML2xoUA="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.0
Cancel-Lock: sha1:OpUdwFppS1U6ewiHi2NPIc4g9Q8=
In-Reply-To: <uj3pc4$30tr$1@gal.iecc.com>
 by: Paul A. Clayton - Sat, 18 Nov 2023 03:38 UTC

On 11/15/23 7:56 PM, John Levine wrote:
> According to Scott Lurndal <slp53@pacbell.net>:
>>> But who ever decided multiple prefixes of the same kind are LEGAL ??
>>
>> The compiler people use multiple prefixes to align code.
>
> What? Why wouldn't you use a NOP? The Intel manual has a list
> of NOPs with sizes from one byte to nine.

It is possible that a NOP is more expensive than bloating one or
more instructions with alternative encodings. Even if a NOP is
never "executed" (and, of course, early microprocessors did just
execute NOPs), it might consume a ROB entry (to facilitate precise
trapping when an instruction address is fetched, e.g. — obviously
one could have coarser-grained ROB entries and replay from an
earlier point even just "fusing" a NOP with the following
instruction).

Even if every compiler did "the right thing" to provide target
alignment, clever programmers could include assembly to do "the
clever thing". A clever programmer might reason that a NOP
increases instruction count and therefore is harmful to
performance. Also there may be a greater fear that some other
programmer would remove a NOP as useless when a useless prefix
might not be recognized as useless.

Re: Redundant prefixes break fsrm in Ice Lake

<mO46N.42717$_Oab.15279@fx15.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35083&group=comp.arch#35083

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx15.iad.POSTED!not-for-mail
From: ThatWouldBeTelling@thevillage.com (EricP)
User-Agent: Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version: 1.0
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad>
In-Reply-To: <gnr5N.37909$AqO5.27034@fx11.iad>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 37
Message-ID: <mO46N.42717$_Oab.15279@fx15.iad>
X-Complaints-To: abuse@UsenetServer.com
NNTP-Posting-Date: Sat, 18 Nov 2023 15:32:34 UTC
Date: Sat, 18 Nov 2023 10:32:15 -0500
X-Received-Bytes: 2235
 by: EricP - Sat, 18 Nov 2023 15:32 UTC

EricP wrote:
> Scott Lurndal wrote:
>> mitchalsup@aol.com (MitchAlsup) writes:
>>> <
>>> How many branch targets have REP REP REP MOVS at the label??
>>> <
>>> You see, these REP REP REP MOVS's almost invariably have preceding
>>> instructions
>>> following label boundaries.
>>
>>
>> In looking at a fairly recent ELF binary, mostly I see various length
>> nops, and a bunch of 'repz retq' sequences.
>>
>> 58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
>>
>> 58eaf0: f3 c3 repz retq
>
> Intel Instruction manual vol2 section 2.1:
>
> "Use of repeat prefixes and/or undefined opcodes with other Intel 64 or
> IA-32 instructions is reserved; such use may cause unpredictable behavior"
>
> These prefix rules were added relatively recently (maybe last 10 years?).
> While they only allow one prefix from each of Group 1..4,
> they still allow prefix bytes to be in any order thereby wasting
> much opcode space on redundant premutations and combinations.

Actually the prefix rules go back farther - they are present in
an Intel x86 instruction manual from 2001 I had on a backup.
Older backups are not readily accessible.

So the 'REP REP MOVS' and 'repz retq' have been clearly documented
as unpredictable for a long time.

Re: Redundant prefixes break fsrm in Ice Lake

<8w56N.59568$BbXa.29079@fx16.iad>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35084&group=comp.arch#35084

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Newsgroups: comp.arch
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad> <mO46N.42717$_Oab.15279@fx15.iad>
Lines: 65
Message-ID: <8w56N.59568$BbXa.29079@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 18 Nov 2023 16:21:24 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 18 Nov 2023 16:21:24 GMT
X-Received-Bytes: 3305
 by: Scott Lurndal - Sat, 18 Nov 2023 16:21 UTC

EricP <ThatWouldBeTelling@thevillage.com> writes:
>EricP wrote:
>> Scott Lurndal wrote:
>>> mitchalsup@aol.com (MitchAlsup) writes:
>>>> <
>>>> How many branch targets have REP REP REP MOVS at the label??
>>>> <
>>>> You see, these REP REP REP MOVS's almost invariably have preceding
>>>> instructions
>>>> following label boundaries.
>>>
>>>
>>> In looking at a fairly recent ELF binary, mostly I see various length
>>> nops, and a bunch of 'repz retq' sequences.
>>>
>>> 58eae6: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
>>>
>>> 58eaf0: f3 c3 repz retq
>>
>> Intel Instruction manual vol2 section 2.1:
>>
>> "Use of repeat prefixes and/or undefined opcodes with other Intel 64 or
>> IA-32 instructions is reserved; such use may cause unpredictable behavior"
>>
>> These prefix rules were added relatively recently (maybe last 10 years?).
>> While they only allow one prefix from each of Group 1..4,
>> they still allow prefix bytes to be in any order thereby wasting
>> much opcode space on redundant premutations and combinations.
>
>Actually the prefix rules go back farther - they are present in
>an Intel x86 instruction manual from 2001 I had on a backup.
>Older backups are not readily accessible.
>

The iAPX 86,88 manual from 1981 states when discussing REP/REPE/REPNE
in the context of interrupts:

"The processor 'remembers' only one prefix in effect
at the time of the interrupt, the prefix that immediately precedes
the string instruction."

Which implies that segment overrides in conjunction with a repeat
prefix won't be preserved if the MOVS is interrupted (they suggest
CLI/STI during string operations with segment override(s), noting
that won't help if an NMI occurs).

I could find no text describing any other restrictions on prefix
bytes. For that matter, while there were references to segment
override prefixes, they weren't actually enumerated in the data sheet.

The instruction set reference data is interesting with respect
to the clock counts for each instruction. A 16-bit integer
multiply, for example, took between 128 and 154 clocks when
using register operands.

Conditional branches were 16 or 4 clocks (presumably taken vs.
not-taken).

>So the 'REP REP MOVS' and 'repz retq' have been clearly documented
>as unpredictable for a long time.
>
>
>

Re: Redundant prefixes break fsrm in Ice Lake

<ujap69$1v6c$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35085&group=comp.arch#35085

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Sat, 18 Nov 2023 16:36:25 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <ujap69$1v6c$1@gal.iecc.com>
References: <krk4lqF2q4oU1@mid.individual.net> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad> <mO46N.42717$_Oab.15279@fx15.iad>
Injection-Date: Sat, 18 Nov 2023 16:36:25 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="64716"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <krk4lqF2q4oU1@mid.individual.net> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad> <mO46N.42717$_Oab.15279@fx15.iad>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 18 Nov 2023 16:36 UTC

According to EricP <ThatWouldBeTelling@thevillage.com>:
>> These prefix rules were added relatively recently (maybe last 10 years?).
>> While they only allow one prefix from each of Group 1..4,
>> they still allow prefix bytes to be in any order thereby wasting
>> much opcode space on redundant premutations and combinations.
>
>Actually the prefix rules go back farther - they are present in
>an Intel x86 instruction manual from 2001 I had on a backup.

I have the October 1979 8086 Family User's Manual here. (The actual
paper one, not a scan.)

In the discussion of repeat prefixes, it says they're interruptible,
and if a second or third segment or lock prefix is present it won't
work because it only remembers one prefix for the interrupt. You can
turn off interrupts, but an NMI might still break stuff.

The only plausble two prefix instruction I can think of is an exchange
with a segment override:

LOCK XCHG ES:FOO,AX

The assembler will generate the lock prefix first. I doubt they gave
much thought to what would happen if the prefixes were in the other
order.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Re: Redundant prefixes break fsrm in Ice Lake

<2023Nov18.172146@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35086&group=comp.arch#35086

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Sat, 18 Nov 2023 16:21:46 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 44
Message-ID: <2023Nov18.172146@mips.complang.tuwien.ac.at>
References: <krk4lqF2q4oU1@mid.individual.net> <36c8d1eb522845d35d66a460ebd49b17@news.novabbs.com> <uH95N.42963$BbXa.19732@fx16.iad> <20daecfcb524f4591d1e5edff449d9f4@news.novabbs.com> <C_b5N.1151$PJoc.138@fx04.iad> <bda8a6e9e3919725886a8d74f744a1f8@news.novabbs.com> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad> <mO46N.42717$_Oab.15279@fx15.iad>
Injection-Info: dont-email.me; posting-host="169a4acc7fcfabbaa2e8a92d7bbf35d6";
logging-data="3565421"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++q9MB/S28O86y/HHeq3It"
Cancel-Lock: sha1:92ITTCZRwhJzzqyCucbeyuFKp2k=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 18 Nov 2023 16:21 UTC

EricP <ThatWouldBeTelling@thevillage.com> writes:
>Actually the prefix rules go back farther - they are present in
>an Intel x86 instruction manual from 2001 I had on a backup.
>Older backups are not readily accessible.
>
>So the 'REP REP MOVS' and 'repz retq' have been clearly documented
>as unpredictable for a long time.

Fortunately, unlike "undefined behaviour" advocates and others who
point to documentation, Intel is aware of Hyrum's law and does not do
"unpredictable behaviour" on any instruction sequence on purpose.
Consequently, they treated the REX MOVSB issue as a bug that they
should fix. However, in this case probably not because they expected
to see such code in the wild (AFAIK it was only found by fuzzing), but
because it allows priviledge escalation.

In particular, if they now implemented a CPU where "repz retq" did
something different than "retq", that would mean that a lot of
binaries would no longer work, and no amount of pointing to
documentation from 2001 or from 1978 to 2023 would stop the reputation
damage that would ensue. That's because compilers (and probably also
assembly language programmers) actually followed other documentation
that recommended using repz retq (see
<https://repzret.org/p/repzret/>).

In this case, one interesting aspect is that the K8 is the first AMD64
CPU, years before any Intel CPU could be bought that would be
compatible with this instruction set. So by the time Intel brought
out their AMD64-compatible CPU (although they had their own names for
the architecture: IA32e, then EM64T, finally Intel64), there were a
lot of binaries with repz retq around, and if Intel wanted to sell
those CPUs into the 64-bit market, they had better support these
binaries, and the 2001 documentation for a different architecture did
not matter in any case.

If you or Intel want to reserve some encoding space, the way to do it
is to either trap on the encoding, or treat it as noop. The noops are
for encodings that you later want to define as hints, because hints
architecturally are noops.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: Redundant prefixes break fsrm in Ice Lake

<2023Nov18.184810@mips.complang.tuwien.ac.at>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35088&group=comp.arch#35088

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Sat, 18 Nov 2023 17:48:10 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 56
Message-ID: <2023Nov18.184810@mips.complang.tuwien.ac.at>
References: <krk4lqF2q4oU1@mid.individual.net> <jud5N.2430$DADd.1857@fx38.iad> <gnr5N.37909$AqO5.27034@fx11.iad> <mO46N.42717$_Oab.15279@fx15.iad> <ujap69$1v6c$1@gal.iecc.com>
Injection-Info: dont-email.me; posting-host="169a4acc7fcfabbaa2e8a92d7bbf35d6";
logging-data="3595703"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2XmL+IF+ijlLY9X/3f2lC"
Cancel-Lock: sha1:BbcELdgFPEJOt9wO2Yc/RYgGk38=
X-newsreader: xrn 10.11
 by: Anton Ertl - Sat, 18 Nov 2023 17:48 UTC

John Levine <johnl@taugh.com> writes:
>The only plausble two prefix instruction I can think of is an exchange
>with a segment override:
>
> LOCK XCHG ES:FOO,AX

When looking for REPZ, I found
<https://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz>, and it
lists, e.g.,

F3 REX.W A4

F3 is the REP prefix. This instruction is a REP MOVSB, and the REX prefix
seems redundant to me in this case. I don't know if that's the one
the OP was about, though.

It also lists

F3 REX.W A5

That's REP MOVSQ, and the REX prefix is not redundant here. But
that's AMD64.

However, the page also lists

F3 A5

which is either REP MOVSW or REP MOVSD (REP MOVSL for AT&T syntax),
depending on mode. But there is also the 66/67 prefix for switching
to the other mode. E.g., of the mode is 32-bit addresses and 32-bit
data, and you want a REP MOVSW that uses 16-bit address registers,
maybe you would do something like

66 67 F3 A5

But that's IA-32; for 8086 I indeed cannot think of other prefixes.

For MOVS, a segment override prefix overrides the implicit DS: of the
source operand; the segment of the destination (implicitly ES:) cannot
be overridden. The page on REP above says nothing about segment
override limitations, so I expect that this limitation was dropped in
the 386 and later processors (probably already in the 286, where the
idea was to use segment registers (and overrides) a lot).

>The assembler will generate the lock prefix first. I doubt they gave
>much thought to what would happen if the prefixes were in the other
>order.

For the original decoder, each prefix probably set a bit, and the
order did not matter. Therefore later implementations had to accept
all orders.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Re: Redundant prefixes break fsrm in Ice Lake

<ujbcir$73r$1@gal.iecc.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=35093&group=comp.arch#35093

  copy link   Newsgroups: comp.arch
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!not-for-mail
From: johnl@taugh.com (John Levine)
Newsgroups: comp.arch
Subject: Re: Redundant prefixes break fsrm in Ice Lake
Date: Sat, 18 Nov 2023 22:07:23 -0000 (UTC)
Organization: Taughannock Networks
Message-ID: <ujbcir$73r$1@gal.iecc.com>
References: <krk4lqF2q4oU1@mid.individual.net> <mO46N.42717$_Oab.15279@fx15.iad> <ujap69$1v6c$1@gal.iecc.com> <2023Nov18.184810@mips.complang.tuwien.ac.at>
Injection-Date: Sat, 18 Nov 2023 22:07:23 -0000 (UTC)
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970";
logging-data="7291"; mail-complaints-to="abuse@iecc.com"
In-Reply-To: <krk4lqF2q4oU1@mid.individual.net> <mO46N.42717$_Oab.15279@fx15.iad> <ujap69$1v6c$1@gal.iecc.com> <2023Nov18.184810@mips.complang.tuwien.ac.at>
Cleverness: some
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: johnl@iecc.com (John Levine)
 by: John Levine - Sat, 18 Nov 2023 22:07 UTC

According to Anton Ertl <anton@mips.complang.tuwien.ac.at>:
>For MOVS, a segment override prefix overrides the implicit DS: of the
>source operand; the segment of the destination (implicitly ES:) cannot
>be overridden. The page on REP above says nothing about segment
>override limitations, so I expect that this limitation was dropped in
>the 386 and later processors (probably already in the 286, where the
>idea was to use segment registers (and overrides) a lot).

I looked at my 1985 i286 manual. The LOCK prefix waa fairly useless
since XCHG now always locks, so it only affected MOVS, INS, and OUTS,
I guess for unaligned word transfers. They describe REP MOVS and say
that segment overrides work for the source address, no warning about
interrupts.

Appendix D on compatibility with the 86/88 has cryptic advice not to
use duplicate prefixes because the 286 has a maximum instruction
length of 10 bytes, while the 86/88 had no limit.

So I guess you're right about the 86/88 prefixes setting a flag bit
and otherwise being forgotten, but the 286 remembered the whole
instruction with the prefixes so long as it wasn't excesively long.

--
Regards,
John Levine, johnl@taugh.com, Primary Perpetrator of "The Internet for Dummies",
Please consider the environment before reading this e-mail. https://jl.ly

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor