linux kernel: why swapper_pg_dir is loaded into cr3 twice

时间:2018-02-03 10:29:11

标签: linux-kernel kernel

I'm reading linux 2.6.26 source code.

During kernel startup, the swapper_pg_dir is loaded into cr3 twice.

First time, in arch/x86/kernel/head_32.S, to start paging

331     movl $pa(swapper_pg_dir),%eax
332     movl %eax,%cr3      /* set the page table pointer.. */

And later, in arch/x86/mm/init_32.c

519 void __init paging_init(void)
520 {
521 #ifdef CONFIG_X86_PAE
522     set_nx();
523     if (nx_enabled)
524         printk(KERN_INFO "NX (Execute Disable) protection: active\n");
525 #endif
526     pagetable_init();
527 
528     load_cr3(swapper_pg_dir);                                                                                                                                                                
529 
530     __flush_tlb_all();
531 
532     kmap_init();
533 }

Is the 528 line load_cr3(swapper_pg_dir) necessary, since swapper_pg_dir is already loaded into cr3 in head_32.S ?

1 个答案:

答案 0 :(得分:0)

arch / x86 / mm / init_32.c +376中的注释答案:

http-parser-js