Reputation: 2251
When an OS is booted, what's the type of memory management ,paging or no-paging? That's is to say what is the value in the cr0 register that control the on/off of paging.I guess paging is off in the begining of kernel initialization, otherwise, all the memory access will be invalid. Paging is set during the kernel initialization,and all the maps of the kernel space must be set to be valid. Am I right?
Upvotes: 1
Views: 285
Reputation: 18316
I assume that by "when an OS is booted", you mean "when the processor is powered on". In that case, it obviously depends on the processor's architecture.
For the x86, paging is controlled by bit 31 in the CR0 register (if this bit is set, paging is enabled). From Intel's Software Developer Manual, Volume 3, Section 8.1.1. "Processor State After Reset", you can see that the value in CR0 is 0x60000010 after a reset, which means paging is disabled.
If you want to know if paging is enabled just before the kernel is started, it depends on what the bootloader does. The Multiboot specification (implemented by, for example, GRUB) dictates that paging should be disabled:
‘CR0’
Bit 31 (PG) must be cleared. Bit 0 (PE) must be set. Other bits are all undefined.
Upvotes: 2
Reputation: 62048
x86 CPUs start execution in the real address mode following a reset. The OS needs to first switch the CPU into the protected mode and only then enable page translation. You cannot enable it together with switching into the protected mode from the real mode (you get a #GP) nor can you enable it in the real mode. So, on the x86 the OS first runs with page translation disabled (unless it has been previously enabled by the OS bootloader, which is rare) and then enables it when it's ready (i.e. has constructed page tables and loaded CR3).
Upvotes: 1