Are x86 segment registers of particular importance / use on modern processors and OS?

x86 processors had all sorts of complex modes and memory segmentation in generations from 16-bit to 32-bit to 64-bit.

These days, with modern OSs using modern processors in modern operating modes, you don’t need to worry about memory segments, but you can still run legacy applications on legacy OSs on modern processors, in which case I believe that the processors are running into a special aging mode (protected mode, real mode, etc.).

So segment registers exist for backward compatibility reasons, but is this the only reason?

Are there modern segment registers? Or have they just turned into general registers these days, which simply have names that reflect their historical functions?

This question was inspired by comments on this old thread: Why use the mov instruction?

+3
x86 cpu-registers history memory-segmentation
source share
1 answer

In 2002, the Linux kernel hacker Ingo Molnar used segmentation to implement Exec Shield , a form of data execution prevention on x86 32-bit systems. This is one modern segmentation use that I know of, but mainly because of the large amount of hardware mileage mechanisms that you cannot change. Segmentation is not used to implement data execution prevention on x86-64 processors with NX support.

FS and GS segment registers are still used on x86-64: "In 64-bit mode, segmentation is usually (but not completely) disabled, creating a flat 64-bit space with a linear address. The processor processes the base of CS, DS, ES, SS segments as zero, creating a linear address that is equal to the effective address. The FS and GS elements are exceptions. These segment registers (which contain the segment base) can be used as additional base registers in linear address calculations that facilitate the addressing of local data and certain operating system data structures. " (from Intel's System Programming Guide, chapter 3.2.4)

On x86-64, Linux uses FS for local thread storage and GS for kernel space per processor. See How are fs / gs registers used in Linux AMD64? and Details on MSR_GS_BASE on Linux x86 64

+7
source share

All Articles