使用嵌套分页进行应用程序级分页
我对较新CPU的嵌套分页虚拟化功能不太熟悉,所以这个问题可能不是一个很好的问题,但我想到了一个想法:
是否可以在我们的应用程序中使用嵌套分页来启用我们自己的某种分页机制(类似于内存映射文件)?
这可以让您将内存访问从应用程序的任何位置重定向到其他任何位置,即使您无权访问正在重定向的代码。 (不过,它甚至不需要映射到文件——当页面错误发生时,您可以动态生成数据。)
I'm not too familiar with the Nested Paging virtualization feature of newer CPUs, and so this question might not be a great question, but I've thought of an idea:
Is it possible to use nested paging in our applications to enable our own kind of paging mechanism (something like memory-mapped files)?
This could allow you to redirect memory accesses from anywhere the application to anywhere else, even if you don't have access to the code you're redirecting. (It wouldn't even require mapping to files, though -- you could produce the data on the fly, when the page fault happens.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是不可行的。我不知道细节,但我认为设置嵌套页表必须在虚拟机管理程序模式下完成,这甚至比内核模式更有特权。要在用户模式下使用它,您需要运行一个虚拟机管理程序,该管理程序向用户模式(或内核模式,然后将其提供给用户模式)提供某种 API。使用用户模式应用程序中的一些扩展 CPU 指令并不是一件简单的事情。我怀疑所取得的成果能否证明所付出的努力是值得的。
编辑:听起来我是对的。引自AMD-V™嵌套分页白皮书,
第 4.2.3 节:“使用嵌套分页”:
I don't think it's feasible. I don't know the details, but I think setting up the nested page tables would have to be done in hypervisor mode, which is even more privileged than kernel mode. To make use of it in user mode you'd need to have a hypervisor running which provided some sort of API to user mode (or to kernel mode, which then provided it to user mode). It wouldn't be a simple matter of using some extended CPU instructions from a user-mode application. I doubt that the gains would justify the effort required.
Edit: it sounds like I am right. Quoting from AMD-V™ Nested Paging white paper,
Section 4.2.3: "Using Nested Paging":