Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
x86 cr3和linux swqpper_pg_dir_Linux_Assembly - Fatal编程技术网

x86 cr3和linux swqpper_pg_dir

x86 cr3和linux swqpper_pg_dir,linux,assembly,Linux,Assembly,在linux源代码2.6.18中: movl $swapper_pg_dir-__PAGE_OFFSET,%eax movl %eax,%cr3 movl %cr0,%eax orl $0x80000000,%eax movl %eax,%cr0 /* ..and set paging (PG) bit */ ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */ 以及load_cr3pgdir和writ

在linux源代码2.6.18中:

movl $swapper_pg_dir-__PAGE_OFFSET,%eax
movl %eax,%cr3
movl %cr0,%eax
orl $0x80000000,%eax
movl %eax,%cr0          /* ..and set paging (PG) bit */
ljmp $__BOOT_CS,$1f     /* Clear prefetch and normalize %eip */
以及load_cr3pgdir和write_cr3x宏:

#define load_cr3(pgdir) write_cr3(__pa(pgdir))

#define write_cr3(x) \
__asm__ __volatile__("movl %0,%%cr3": :"r" (x))
似乎整个cr3控制寄存器都存储了页面目录的地址。然而,当我参考intel ia-32Developer's_手册时,它讲述了一个不同的故事。以下是《英特尔手册》的内容:

name      0.............11   12.................31
cr3       flags              address of page directory
PDE       flags              address of page table
PTE       flags              address of 4kb page frame
手册说cr3的20MSB存储页面目录的地址,而不是整个cr3寄存器。这也是合理的,因为页面目录正好是4kb,所以地址的12 LSB始终为零

这是不是有点奇怪,因为linux代码只是将页面目录的地址分配给cr3,而不是swapper_pg_dir的20 MSB

我的问题是,cr3寄存器究竟是存储、地址还是英特尔手册建议的格式


以下链接是英特尔手册:

如果swapper\u pg\u dir-\uu PAGE\u偏移量是4096的倍数,这并不奇怪

CR3 LSB中的零是有效的:

保留位必须设置为0 更新的i80386功能可以通过将相关位设置为0来禁用,通常这是保持x86 CPU与旧软件向后兼容的方法。
对于32位分页,页面目录的地址必须是4096的倍数,即其12 LSB为零。但是,用于设置cr3的操作码加载的是32位,而不是20位。加载cr3时,其20位高位用于页面目录地址,12位低位被解释为标志,可能会影响较新处理器版本中的分页行为。这些标志的安全设置为零,这正是Linux所做的:它用一个32位值加载cr3,该值的12 LSB恰好等于零,因为该32位值被视为内存地址,是4096的倍数。

那么,你的问题是什么?你知道,一个带有问号的句子…很抱歉,我会编辑它。