本文介绍了从内存加载寄存器时是否有可能“中止”而不是触发页面错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑''

''是从另一个角度看问题的一个相关问题,但没有解决方案。

'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:

我从没使用过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).

这篇关于从内存加载寄存器时是否有可能“中止”而不是触发页面错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 15:12