gpt4 book ai didi

Linux 内核 mmu create_page_tables

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:18:26 29 4
gpt4 key购买 nike

正在阅读Linux内核,对MMU相关的部分比较感兴趣。在ARM64 cpu中,有如下代码:

__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_SIZE。为什么要将 PAGE_SIZE 添加到 x25

最佳答案

函数create_pgd_entry是在PGD中创建一个表项,在“add x0,x25,#PAGE_SIZE”之后,x0指向下一级表。

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

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

关于Linux 内核 mmu create_page_tables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47589226/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com