From: "Petr Beneš" <w1benny@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: "Petr Beneš" <w1benny@gmail.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Tamas K Lengyel" <tamas@tklengyel.com>,
"Alexandru Isaila" <aisaila@bitdefender.com>,
"Petre Pircalabu" <ppircalabu@bitdefender.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Julien Grall" <julien@xen.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Michal Orzel" <michal.orzel@amd.com>,
"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
"Anthony PERARD" <anthony.perard@vates.tech>
Subject: [PATCH v2 0/2] x86: Add Support for Paging-Write Feature
Date: Thu, 19 Dec 2024 23:55:00 +0000 [thread overview]
Message-ID: <cover.1734652343.git.w1benny@gmail.com> (raw)
From: Petr Beneš <w1benny@gmail.com>
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 | 4 ++++
xen/include/public/memory.h | 9 +++++++++
xen/include/xen/mem_access.h | 6 ++++++
13 files changed, 41 insertions(+), 3 deletions(-)
--
2.34.1
next reply other threads:[~2024-12-19 23:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 23:55 Petr Beneš [this message]
2024-12-19 23:55 ` [PATCH v2 1/2] x86: Rename _rsvd field to pw and move it to the bit 58 Petr Beneš
2024-12-19 23:55 ` [PATCH v2 2/2] x86: Add Support for Paging-Write Feature Petr Beneš
2024-12-20 13:09 ` Jan Beulich
2024-12-20 16:34 ` Petr Beneš
2024-12-24 8:39 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1734652343.git.w1benny@gmail.com \
--to=w1benny@gmail.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=aisaila@bitdefender.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bertrand.marquis@arm.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=ppircalabu@bitdefender.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tamas@tklengyel.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.