如何获得CR3值?

发布于 2024-12-05 10:49:00 字数 100 浏览 0 评论 0原文

我怎样才能得到CR3值?

此外,我怎样才能获得进程A(比如Firefox)的CR3值?

有什么命令可以用来读取当前的 CR3 吗?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红焚 2024-12-12 10:49:00

此处

我试图了解 PGD(页面全局目录)的扩展范围
CR3寄存器中存储的值指示正在运行的进程/线程
Linux 调度程序。

我知道每个进程都有自己的 PGD 值,但我对此感到困惑
是内核线程调度时CR3寄存器的值。

内核线程只是借用最新调度进程的 PGD(即
意味着整个地址空间)...这样做是为了节省不必要的
TLB 刷新,因为内核线程在内核空间中运行,这就是
所有进程都相同

因此,为了避免 TLB(转换后备缓冲区)刷新,内核仅使用当前用户模式进程中的 PGD,而在用户模式下,每次启动新进程时,CR3 寄存器都会更改,因为它们位于不同的虚拟地址,所以我猜它们的映射会不同。

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.

﹉夏雨初晴づ 2024-12-12 10:49:00

但如今,在易受 Spectre 漏洞影响的英特尔处理器上,引入了一种新的缓解措施:KPTI(内核指针表隔离)。它使得进程的 cr3 仅映射内核的一小部分(仅访问中断/系统调用所必需的代码/结构)。接下来,cr3 寄存器被切换并替换为内核的 cr3,它相当于进程的 cr3,尽管它还映射了设置了 NX 位的所有内核和用户态页面(调用进程的)。

But today on intel processors vulnerable to for example the spectre vulnerability, a new mitigation has been introduced: KPTI (kernel pointer table isolation). It makes that the cr3 of your process maps only a very small part of the kernel (only the code / structures mandatory to access to the interrupts/syscalls). Next the cr3 register is switched and replaced by the cr3 of your kernel which is equivalent to the cr3 of your process albeit it also maps all the kernel and the userland pages (of the calling process) with the NX bit set.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文