Linux 内核 mmu create_page_tables

Linux kernel mmu create_page_tables

我正在阅读Linux内核,我对MMU相关的部分很感兴趣。在ARM64cpu中,有如下代码:

__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

我不明白这段代码:

add x0, x25, #PAGE_SIZE

我的理解是x25是地址idmap_pg_dir,不需要加PAGE_SIZEx25为什么要加一个PAGE_SIZE

函数create_pgd_entry是在PGD中创建一个入口,"add x0, x25, #PAGE_SIZE"之后x0指向下一层table。

有两个4KB@idmap_pg_dir,第一个4KB是PGD,第二个4KB是下一级table。

注意:PGD 中只使用了一个条目。