LeBa
LeBa

Reputation: 11

Linux kernel mmu create_page_tables

I am reading the Linux kernel and I am interested in the MMU-related part. In the ARM64 cpu, there is the following code :

__create_page_tables:
    pgtbl   x25, x26, x28           // idmap_pg_dir and swapper_pg_dir addresses
    mov x27, lr

    /*
     * Invalidate the idmap and swapper page tables to avoid potential
     * dirty cache lines being evicted.
     */
    mov x0, x25
    add x1, x26, #SWAPPER_DIR_SIZE
    bl  __inval_cache_range

    /*
     * Clear the idmap and swapper page tables.
     */
    mov x0, x25
    add x6, x26, #SWAPPER_DIR_SIZE
    1:  stp xzr, xzr, [x0], #16
    stp xzr, xzr, [x0], #16
    stp xzr, xzr, [x0], #16
    stp xzr, xzr, [x0], #16
    cmp x0, x6
    b.lo    1b

    ldr x7, =MM_MMUFLAGS

    /*
     * Create the identity mapping.
     */
    **add   x0, x25, #PAGE_SIZE     // section table address**
    ldr x3, =KERNEL_START
    add x3, x3, x28         // __pa(KERNEL_START)
    create_pgd_entry x25, x0, x3, x5, x6
    ldr x6, =KERNEL_END
    mov x5, x3              // __pa(KERNEL_START)
    add x6, x6, x28         // __pa(KERNEL_END)
    create_block_map x0, x7, x3, x5, x6

I do not understand this code:

add x0, x25, #PAGE_SIZE

My understanding is x25 is the address idmap_pg_dir, and we do not need to add a PAGE_SIZE to it. Why should a PAGE_SIZE be added to x25?

Upvotes: 1

Views: 369

Answers (1)

LeBa
LeBa

Reputation: 11

The function create_pgd_entry is to create an entry in PGD, after "add x0, x25, #PAGE_SIZE", x0 is pointed to the next level table.

There are two 4KB@idmap_pg_dir, the first 4KB is PGD, the second 4KB is next-level table.

Notes: Only one entry in PGD is used.

Upvotes: 0

Related Questions