Linux – Does Linux not use segmentation but only paging

kernellinuxvirtual-memory

The Linux Programming Interface shows the layout of a virtual address space of a process. Is each region in the diagram a segment?

enter image description here

From Understanding The Linux Kernel,

is it correct that the following means that the segmentation unit in MMU maps the segments and offsets within segments into the virtual memory address, and the paging unit then maps the virtual memory address to the physical memory address?

The Memory Management Unit (MMU) transforms a logical address into a linear
address by means of a hardware circuit called a segmentation unit; subsequently, a second hardware circuit called a paging unit transforms the linear address into a physical address (see Figure 2-1).

enter image description here

Then why does it say that Linux doesn't use segmentation but only paging?

Segmentation has been included in 80×86 microprocessors to encourage
programmers to split their applications into logically related
entities, such as subroutines or global and local data areas. However,
Linux uses segmentation in a very limited way. In fact, segmentation and paging are somewhat redundant, because both can be
used to separate the physical address spaces of processes:
segmentation can assign a different linear address space to each
process, while paging can map the same linear address space into
different physical address spaces. Linux prefers paging to
segmentation for the following reasons:

• Memory management is simpler when all processes use the same segment
register values—that is, when they share the same set of linear
addresses.

• One of the design objectives of Linux is portability to a wide range
of architectures; RISC architectures, in particular, have limited
support for segmentation.

The 2.6 version of Linux uses segmentation only when required by the
80×86 architecture.

Best Answer

The x86-64 architecture does not use segmentation in long mode (64-bit mode).

Four of the segment registers: CS, SS, DS, and ES are forced to 0, and the limit to 2^64.

https://en.wikipedia.org/wiki/X86_memory_segmentation#Later_developments

It is no longer possible for the OS to limit which ranges of the "linear addresses" are available. Therefore it cannot use segmentation for memory protection; it must rely entirely on paging.

Do not worry about the details of x86 CPUs which would only apply when running in the legacy 32-bit modes. Linux for the 32-bit modes is not used as much. It may even be considered "in a state of benign neglect for several years". See 32-Bit x86 support in Fedora [LWN.net, 2017].

(It happens that 32-bit Linux does not use segmentation either. But you don't need to trust me on that, you can just ignore it :-).