[PATCH] x86: accept LOCK on control register accesses only with ModR/M.reg == 0

Jan Beulich jbeulich@suse.com
Fri Jul 10 08:04:27 GMT 2026


On 10.07.2026 09:42, Christian Ludloff wrote:
> If you zoom out, there are four variants of MOV
> from/to CRx, listed here in chronological order:
> 
> 1) 32-bit CR0/2/3 (386, !PM64)
> 2) 32-bit CR4 (486, !PM64)
> 3) 64-bit CR0/2/3/4/8 (x64, PM64)
> 4) 32-bit CR8D (LockMovCr0/AltMovCr8, !PM64)

5) 64-bit CR8 (LockMovCr0/AltMovCr8, PM64)

gas wouldn't encode CR8 accesses like this (albeit from an abstract pov
we probably should offer a way to do so, just that I can't think of any
reasonable one), but objdump will now disassemble them correctly.

> In theory 1) and 2) are D-suffixed just like 4). As
> they predate x86, the suffix was always omitted.
> 
> Some tools support the entire 0-7/15/31 ranges
> that can be encoded with classic/x64/APX. And
> the mod=00b/01b/10b aliases, for the 11b case.
> 
> Anyway... treating 64-bit CR8 and 32-bit CR8D
> as distinct... can make x86 asm life less painful.

Hmm. I've never seen CRn suffixed by D, and I never would have thought
that could be useful. All control registers are always machine-word
size (64 bits in 64-bit mode, 32 bits outside). There's also no such
distinction in SDM or APM, afaia.

Requiring people to write %cr8d in 32-bit code would also break existing
code (if any exists at all).

Jan


More information about the Binutils mailing list