binutils Newspaper
JULY 29, 2026
x86 Proposed

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

Patch adjusts assembler and disassembler support for LOCK prefix on CR0/CR8 accesses.

Jan Beulich proposes a patch to restrict LOCK prefix handling for MOV to CR0/CR8 instructions, aligning with documented behavior. The patch introduces a new feature indicator for assemblers to denote CPU support for this instruction form. For the disassembler, it ensures correct handling in 64-bit mode and distinguishes it from ‘intel64’ option usage. The changes also update the documentation to include the new altmovcr8 mnemonic.

In the Thread 1 participant
  1. Jan Beulich <jbeulich@suse.com> proposer

    Submits a patch to enforce that the LOCK prefix is only accepted for MOV instructions accessing CR0 or CR8, specifically when ModR/M.reg is 0. This change also adds a new feature indicator `altmovcr8` to gas to track CPU support, restricts CR9-CR15 outside of 64-bit mode, and handles LOCK prefix usage in 64-bit mode f…

    “Reportedly (e.g. [1]) the LOCK handling is special to %cr0 / %cr8 only. Deal with it this way also in assembler and disassembler. For the assembler also introduce a separate feature indicator: Not all 64-bit CPUs support this insn form; only most AMD (and presumably all Hygon) ones do. Register names %cr9 ... %cr15 thus become invalid outside of 64-bit mode altogether (unprefixed forms become or…”

In Details

This patch refines the x86 assembler and disassembler's handling of the LOCK prefix in conjunction with MOV instructions targeting control registers CR0 and CR8. Historically, LOCK prefixes are not generally permitted on instructions modifying CRs, but exceptions exist for CR0 and CR8 under specific encoding conditions (ModR/M.reg == 0). The patch introduces an altmovcr8 feature flag for gas to gate this behavior based on CPU support, as it's not universal. It also rectifies disassembler behavior, ensuring correct parsing in 64-bit mode and avoiding misinterpretation with the intel64 CPU…

For Context
ModR/M.reg
A field within the ModR/M byte of an x86 instruction that specifies a register, often used to denote the destination register or an extension of the opcode.
LOCK prefix
An x86 instruction prefix that makes the subsequent instruction uninterruptible and ensures atomicity, typically used for memory access synchronization.
CR0/CR8
Control Registers in x86 architecture used for system control and configuration. CR0 holds flags for CPU mode, paging, etc., while CR8 is used for extended system registers.
assembler
A program that translates assembly language source code into machine code.
disassembler
A program that translates machine code back into assembly language.
gas
The GNU Assembler, part of the GNU Binutils package.
altmovcr8
A feature flag indicating support for the alternative MOV to/from CR8 instruction with LOCK prefix.
Filed Under: x86assemblerdisassemblerLOCK prefixcontrol registers