Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


optionPHYSICAL_STARTdetermines the position in RAM in this case, subjected to physical alignment
specified by the configuration optionPHYSICAL_ALIGN.

Additionally, the kernel can be built as arelocatablebinary, and the physical start address given at compile
time is completely ignored in this case. The boot loader can decide where to put the kernel. Since both
options are either only required in corner cases or are still considered experimental, I will not discuss
them any further.

Figure 3-11 shows the lowest megabytes of physical RAM memory in which the various parts of the
kernel image reside.

First page frame Kernel text Available

ROM Kernel data Initialization data

0x9e800

_text _etext

_end

0x1000
0x0 (4 KiB)

640 KiB

0x100000
(1 MiB)

_edata

Figure 3-11: Arrangement of the Linux kernel in RAM memory.

The figure shows the first megabytes of physical memory — how much is exactly required depends on
how big the kernel binary is. The first 4,096 KiB — the first page frame — are omitted because they are
oftenreservedfortheBIOS.Thenext640KiBwouldbeusableinprinciple,butareagainnotusedfor
kernel loading. The reason is that this area is immediately followed by an area reserved for the system
into which various ROM ranges are mapped (typically the system BIOS and the graphic card ROM). It
is not possible to write to these areas. However, thekernel should always be loaded into a contiguous
memory range, and this would be possible only for kernels smaller than 640 KiB if the start address of
RAM memory were used as the start position for the kernel image.

To resolve these problems, IA-32 kernels use0x100000as the start address; this corresponds to the start
of the first megabyte in RAM memory. There is sufficient contiguous memory at this point to hold the
entire kernel.

The memory occupied by the kernel is split into several sections whose bounds are held in variables.

❑ _textand_etextare the start and end address of the text section that contains the compiled
kernel code.
❑ The data section in which most kernel variables are kept is located between_etextand_edata.
❑ Initialization data no longer needed after the kernel boot process is finished (among others, e.g.,
the BSS segment that contains allstaticglobal variables initialized to 0) are held in the last
section, which extends from_edatato_end. Once kernel initialization has completed, most of
the data can be removed from memory leaving more space for applications. The interval is split
Free download pdf