Linux Kernel Architecture

(Jacob Rumans) #1

Chapter3:MemoryManagement


The functions often appear in groups of three to set, delete, and query a specific attribute, for instance,
write permission for a page. The kernel assumes that access to page data can be regulated in three dif-
ferent ways — by means of write, read, and execution permission. (Execution permission indicates that
page binary data may be executed as machine code in the same way as programs are executed.) How-
ever, this assumption is a little too optimistic for some CPUs. IA-32 processors support only two control
modes to allow reading and writing. In this case, the architecture-dependent code tries to emulate the
desired semantics as best it can.

3.3.2 Creating and Manipulating Entries


Table 3-4 lists all functions for creating new page table entries.

Table 3-4: Functions for Creating New Page Table Entries

Function Description

mk_pte

Createsapteentry;apageinstance and the desired page access permissions must
be passed as parameters.

pte_page

Yields the address of thepageinstance belonging to the page described by the
page table entry.

pgd_alloc
pud_alloc
pmd_alloc
pte_alloc

Reserve and initialize memory to hold a complete page table (not just a single
entry).

pgd_free
pud_free
pmd_free
pte_free

Free the memory occupied by the page table.

set_pgd
set_pud
set_pmd
set_pte

Set the value of an entry in a page table.

The functions in the table must be implemented by allarchitectures to enable memory management code
to create and destroy page tables.

3.4 Initialization of Memory Management


In the context of memory management,initializationcan have multiple meanings. On many CPUs, it is
necessary to explicitly set the memory model suitable for the Linux kernel, for example, by switching
toprotected modeon IA-32 systems, before it is possible to detect the available memory and register it
with the kernel. In the course of initialization, it is also necessary to set up the data structures of memory
management, and much more. Because the kernel needs memory before memory management is fully
Free download pdf