从内存加载寄存器时是否有可能“中止”而不是触发页面错误? [英] Is it possible to “abort” when loading a register from memory rather the triggering a page fault?
问题描述
我正在考虑'最小化页面错误(和TLB错误),同时遍历大图'
'如何知道指针是否在物理内存中或它将触发Page Fault?'是从另一个角度看问题的一个相关问题,但没有解决方案。
'How to know whether a pointer is in physical memory or it will trigger a Page Fault?' is a related question looking at the problem from the other side, but does not have a solution.
我希望能够将内存中的某些数据加载到寄存器中,但是如果当前内存已被调出,则将中止加载而不是发生页面错误。我需要代码可以在Windows和Linux上的用户空间中工作,而无需任何标准权限。
I wish to be able to load some data from memory into a register, but have the load abort rather than getting a page fault, if the memory is currently paged out. I need the code to work in user space on both Windows and Linux without needing any none standard permission.
(理想上,我也想可以在TLB错误时中止。)
(Ideally, I would also like to abort on a TLB fault.)
推荐答案
TXT-NI功能的RTM(受限事务存储)部分可以禁止例外:
The RTM (Restricted Transactional Memory) part of the TXT-NI feature allows to suppress exceptions:
在交易区域中必须暴露给软件的任何错误或陷阱将被抑制。 事务性
执行将中止,并且执行将转换为非事务性执行,就好像错误或陷阱从未发生过
一样。
[。 。]
同步异常事件(#DE,#OF,#NP,#SS,#GP,#BR,#UD,#AC,#XM,#PF,#NM,#TS,#在事务执行期间发生的MF,#DB,#BP / INT3)可能会导致执行无法通过事务提交,并且
需要进行非事务执行。这些事件好像从未发生过一样被抑制。
Any fault or trap in a transactional region that must be exposed to software will be suppressed. Transactional execution will abort and execution will transition to a non-transactional execution, as if the fault or trap had never occurred.
[...]
Synchronous exception events (#DE, #OF, #NP, #SS, #GP, #BR, #UD, #AC, #XM, #PF, #NM, #TS, #MF, #DB, #BP/INT3) that occur during transactional execution may cause an execution not to commit transactionally, and require a non-transactional execution. These events are suppressed as if they had never occurred.
我从没使用过RTM,但是它应该像这样工作:
I've never used RTM but it should work something like this:
xbegin fallback
; Don't fault here
xend
; Somewhere else
fallback:
; Retry non-transactionally
请注意,由于多种原因可以中止交易,请参见第16.8.3.2章。英特尔手册第1卷。
另请注意,RTM并非无处不在。
Note that a transaction can be aborted for many reasons, see chapter 16.8.3.2 of the Intel manual volume 1. Also note that RTM is not ubiquitous.
除了RTM之外,我无法想出另一种抑制负载的方法,因为它必须返回一个值或最终发出中止状态的信号(与#PF相同) 。
Besides RTM I cannot think of another way to suppress a load since it must return a value or eventually signal an abort condition (which would be the same as a #PF).
这篇关于从内存加载寄存器时是否有可能“中止”而不是触发页面错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!