Issue
How can I get the CR3 value?
Furthermore, how can I get the CR3 value of process A (say Firefox)?
Is there any command I could use to read the current CR3?
Thanks!
Solution
From here:
I am trying to understand in what extend the PGD (page global directory) value stored in the CR3 register indicate the running process/thread by the Linux scheduler.
I know that each process has its own PGD value but what I am confused about is the value of CR3 register when kernel threads are scheduled.
kernel thread(s) simply borrow latest scheduled process's PGD ( that means, the entire address space)....this is done to save unneccessary TLB flush since kernel thread operates in kernel space and that's the same to all processes
So to avoid TLB (Translation Lookaside Buffer) flushes, the kernel just uses the PGD from the current user mode process, whereas in User Mode, the CR3 register would change each time a new process is started, as they are located at different virtual address, so their mapping would be different I guess.
Answered By - Tony The Lion Answer Checked By - Candace Johnson (WPSolving Volunteer)