Notes about Intel’s Linear Address Masking(LAM).

1. Background

A 64-bit pointer can address a lot of memory — far more than just about any application could ever need. As a result, there are bits within that pointer that are not really needed to address memory, and which might be put to other needs. Storing a few bits of metadata within a pointer is a common enough use case.

2. Motivation

In Intel CPU, 假设使用64 bit pointer(虚拟地址)的57位到62位存放metadata,当想要dereferencing a pointer时:

  • Without LAM,软件需要显示地unmask掉pointer的57位到62位,说白了,每次dereferencing时,软件都需要做一个操作
  • With LAM,软件无需unmask掉pointer的57位到62位,硬件直接完成unmask的功能,这样,每次dereferencing时,软件无需操作了

通俗地说,LAM的作用是将软件unmask pointer meatadata的功能offload到硬件上了。

3. Details

Intel’s LAM feature offers two modes:

  • LAM_U57 allows six bits of metadata in bits 62 to 57.
  • LAM_U48 allows 15 bits of metadata in bits 62 to 48.

3.1 Why not use bit 64 as metadata

可以带着这个问题去Support for Intel’s Linear Address Masking中寻找答案。

3.2 LAM_U48与five-level page tables的配合使用

说白了,五级页表会使用到LAM_U48中的bit 48到56,因而可能会产生冲突。如何解决这个冲突呢?可以带着这个问题去Support for Intel’s Linear Address Masking中寻找答案。


参考资料:

  1. Support for Intel’s Linear Address Masking
  2. LWN:支持Intel线性地址屏蔽功能!