x86: Add Support for Paging-Write Feature
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 10 repliesIn review
- v22 patches 3 repliesSuperseded
- v12 patches 3 repliesSuperseded
Changes in v3 from the cover letter
- Reset entry->pw in all cases in p2m_set_entry, except for p2m_access_r_pw
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | x86: Rename _rsvd field to pw and move it to the bit 58xen/ | +2 | 1 reply | |
| 2/2 | x86: Add Support for Paging-Write Featurexen/ xen/ xen/ +9 more | +47 | 5 replies |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Tamas K Lengyel | Jan Beulich |
|---|---|---|
| 1/2 | A-b | A-b |
| 2/2 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v3 0/2] x86: Add Support for Paging-Write Feature
From: Petr Beneš <[email protected]>
Changes since v2:
- Reset entry->pw in all cases in p2m_set_entry, except for p2m_access_r_pw
Changes since v1:
- Added signed-off-by tags
This patch introduces a new XENMEM_access_r_pw permission. Functionally, it is similar to XENMEM_access_r, but for processors with TERTIARY_EXEC_EPT_PAGING_WRITE support (Intel 12th Gen/Alder Lake and later), it also permits the CPU to write to the page during guest page-table walks (e.g., updating A/D bits) without triggering an EPT violation.
This behavior works by both enabling the EPT paging-write feature and setting the EPT paging-write flag in the EPT leaf entry.
This feature provides a significant performance boost for introspection tools that monitor guest page-table updates. Previously, every page-table modification by the guest—including routine updates like setting A/D bits—triggered an EPT violation, adding unnecessary overhead. The new XENMEM_access_r_pw permission allows these "uninteresting" updates to occur without EPT violations, improving efficiency.
Additionally, this feature simplifies the handling of race conditions in scenarios where an introspection tool:
- Sets an "invisible breakpoint" in the altp2m view for a function F
- Monitors guest page-table updates to track whether the page containing F is paged out
- Encounters a cleared Access (A) bit on the page containing F while the guest is about to execute the breakpoint
In the current implementation:
- If xc_monitor_inguest_pagefault() is enabled, the introspection tool must emulate both the breakpoint and the setting of the Access bit.
- If xc_monitor_inguest_pagefault() is disabled, Xen handles the EPT violation without notifying the introspection tool, setting the Access bit and emulating the instruction. However, Xen fetches the instruction from the default view instead of the altp2m view, potentially causing the breakpoint to be missed.
With this patch, setting XENMEM_access_r_pw for monitored guest page-tables prevents EPT violations in these cases. This change enhances performance and reduces complexity for introspection tools, ensuring seamless breakpoint handling while tracking guest page-table updates.
Petr Beneš (2):
x86: Rename _rsvd field to pw and move it to the bit 58
x86: Add Support for Paging-Write Feature
xen/arch/arm/mem_access.c | 4 ++++ xen/arch/arm/mmu/p2m.c | 1 + xen/arch/x86/hvm/hvm.c | 1 + xen/arch/x86/hvm/monitor.c | 1 + xen/arch/x86/hvm/vmx/vmcs.c | 4 +++- xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 3 +++ xen/arch/x86/include/asm/hvm/vmx/vmx.h | 4 ++-- xen/arch/x86/include/asm/p2m.h | 1 + xen/arch/x86/mm/hap/nested_hap.c | 3 +++ xen/arch/x86/mm/mem_access.c | 3 +++ xen/arch/x86/mm/p2m-ept.c | 12 ++++++++++++ xen/include/public/memory.h | 9 +++++++++ xen/include/xen/mem_access.h | 6 ++++++ 13 files changed, 49 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1