什么是 assisted/assisting 负载?

What is an assisted/assisting load?

RIDL 漏洞需要攻击者触发页面错误才能从行填充缓冲区读取陈旧数据。但是根据,也可以使用辅助负载。

该问题提到 assisted/assisting 加载九次,但我仍然无法理解此类加载的作用或触发方式。这与 TLB 和 "cause a page walk that requires an microcode assist".

有关

谁能解释一下什么是 assisted/assisting 负载,最好能给出一个已解决的例子?

您遗漏了该引用中的其余句子,它解释了为什么页面遍历可能需要微码辅助:“...导致需要微码辅助的页面遍历 (设置页面 table 条目中的访问位).

x86 ISA 表示读取或写入页面将设置该映射的页面 table 条目 (PTE) 中的 "accessed" 位,如果该位尚未设置的话。 OSes 可以使用它来查看哪些页面实际上被定期访问(通过清除访问位并让 HW 再次设置它),以便他们可以决定在需要释放一些物理页面时将哪些页面调出。 "dirty" 位的情况相同,它让 OS 知道页面是否需要同步回文件或其他后备存储(如果有)。 (例如 OS 如何实现 mmap(MAP_SHARED,PROT_WRITE)

填充 TLB 条目的页面遍历是纯粹的专用硬件,但是用存储更新那些 PTE 位很少见,可以留给微码; CPU 基本上陷入内部微代码并在恢复之前运行它。

一些 CPU 中使用了类似的机制来处理硬连线 FPU 无​​法处理的次正规浮点结果。这使得常见情况(标准化浮点数)具有更低的延迟。

相关:


英特尔性能计数器(至少在 Skylake 上):perf stat -e other_assists.any

[Number of times a microcode assist is invoked by HW other than FP-assist. Examples include AD (page Access Dirty) and AVX* related assists]


触发助攻来自用户-space:我不确定哪种方法好。

msync(MS_SYNC) 在文件支持的映射上应该清除脏位。 IDK 是否会清除访问位。大概是一个新的文件支持 mmap 和 MAP_POPULATE 会清除它的访问位,但是被连接到页面 table 所以它不会出现 #PF 页面错误异常.也许也适用于 MAP_ANONYMOUS.

如果您有多个页面,其访问位已清除,您可以遍历它们以能够执行多个辅助加载,而无需在其间进行昂贵的系统调用。


在 Linux 内核 4.12 及更高版本上,我怀疑私有匿名页面上的 madvise(MADV_FREE) 根据 the man page 描述的方式清除了脏位。它还可能会清除访问位,因此加载可能还需要帮助,IDK。

MADV_FREE (since Linux 4.5)
The application no longer requires the pages in the range specified by addr and len. The kernel can thus free these pages, but the freeing could be delayed until memory pressure occurs. For each of the pages that has been marked to be freed but has not yet been freed, the free operation will be canceled if the caller writes into the page. After a successful MADV_FREE operation, any stale data (i.e., dirty, unwritten pages) will be lost when the kernel frees the pages. However, subsequent writes to pages in the range will succeed and then kernel cannot free those dirtied pages, so that the caller can always see just written data. If there is no subsequent write, the kernel can free the pages at any time. Once pages in the range have been freed, the caller will see zero-fill-on-demand pages upon subsequent page references.

The MADV_FREE operation can be applied only to private anonymous pages (see mmap(2)). In Linux before version 4.12, when freeing pages on a swapless system, the pages in the given range are freed instantly, regardless of memory pressure.

或者 mprotect,或者 mmap(MAP_FIXED|MAP_POPULATE) 一个新的匿名页面来替换当前页面。使用 MAP_POPULATE 它应该已经连接到 HW 页面 tables(第一次访问时不需要软页面错误)。脏位应该很清楚,也许还有访问位。


vpmaskmovd 掩码=0 的存储(无实际存储)将触发对写保护页面的帮助,例如延迟分配的 mmap(PROT_READ|PROT_WRITE) 页面,仅被读取,未被写入。所以它仍然是 CoW 映射到零的共享物理页面。

它使页面保持干净,因此如果每个商店都具有 mask=0 以不替换任何元素,则每次在数组循环中都会发生这种情况。

这与Accessed / Dirty page有点不同-table助您一臂之力。我认为这个辅助是为了抑制错误,因为它不需要 #PF 页面错误。 (该页面实际上是写保护的,而不仅仅是干净的。)

IDK 如果它对 MDS/RIDL 有用的话。

我还没有使用来自新分配的 mmap(MAP_POPULATE) 缓冲区的屏蔽负载进行测试,以查看它们是否需要帮助但未设置访问位。