[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] x86: add new pte_get_and_clear hypercall


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Date: Mon, 27 Jul 2026 16:06:15 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ujfQculv3wHfFyekrZ5tWOrthojOAbuyk/54bXUGct4=; b=RGoDZDx3ikcs5wm77zia7brzx6sQ8wcD18HI9QZlaoUAkFiG4vLrT374sVtYXRggMNj3v9/jDFUHcZzGfzQ8Mvw7JYYElO1i11tv0bjsnQY1sG8RYzLyIcykJ/V6/LPg1wAe6P30AjnBFI/DjEeFE9of6uivXvb+KiSXYr5Ns3TcGuOU7zjz41GWbAHxv9GKSYdBlTF9wnVkX46k5igvc29cv+6XWGlWplGtDD7uTSwv9WfOl9untPfGuLRQltIoQDGrgOQWr4XXIjMnhfKEo0ectIhdnHWDBp+hldXe486UEYceWdFhUlyq692VFW3/bBxirGJSeGZKmCOysvjviA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bagaMyk3/tc1uanchugvAElI5+0lYM2n/edTxQsDtAW0exAagpCWDRF9bwH85fTSBb/92uE8zTh+xiIrO+HCa4oQ1fGCSw682+ufakIsk64l+yGv86wF/6T9ZLj0dQtp43uPBzci13l1FjRTTAKXlcNBeM3gzfUkQqj2pQ38Foippqtv0ufeG9EF3B14mP8jQoGZzsiQNaJ23xOg6AD8+ZsSQy0MnOXcUzAfUpFDZDDbHlsisV1gp7MZMuxa1G1gFeZf9ZQ3LDI9zdAXrwoRuG/0dFDd9FvEcSUKvDCklJfAYcnaPDlrAtPbLBw6Gh9qJMGjk4pq90lcOPBSFQMPUQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: jbeulich@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, roger.pau@xxxxxxxxxx, Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Delivery-date: Mon, 27 Jul 2026 15:05:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This new hypercall uses the same interface as the mmu_update hypercall except
the old PTE value is returned in the mmu_update_t->val field.

The purpose of this new hypercall is to improve performance over the current
trap and emulate behavior. Only l1 PTEs are supported because they have the
biggest performance impact.

Signed-off-by: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
---
 xen/arch/x86/mm.c            | 24 +++++++++++++++++-------
 xen/include/hypercall-defs.c |  2 ++
 xen/include/public/xen.h     |  1 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 278b992aca5c..e5fdfc66081a 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -3993,6 +3993,7 @@ static long __do_mmu_update(
     unsigned int count,
     XEN_GUEST_HANDLE_PARAM(uint) pdone,
     unsigned int foreigndom,
+    unsigned int op,
     bool write_back_old)
 {
     struct mmu_update req;
@@ -4013,8 +4014,7 @@ static long __do_mmu_update(
     {
         if ( likely(rc == -ERESTART) )
             rc = hypercall_create_continuation(
-                     __HYPERVISOR_mmu_update, "hihi", ureqs, count, pdone,
-                     foreigndom);
+                     op, "hihi", ureqs, count, pdone, foreigndom);
         return rc;
     }
 
@@ -4316,8 +4316,8 @@ static long __do_mmu_update(
 
     if ( rc == -ERESTART )
         rc = hypercall_create_continuation(
-            __HYPERVISOR_mmu_update, "hihi",
-            ureqs, (count - i) | MMU_UPDATE_PREEMPTED, pdone, foreigndom);
+            op, "hihi", ureqs, (count - i) | MMU_UPDATE_PREEMPTED,
+            pdone, foreigndom);
     else if ( curr->arch.old_guest_table )
     {
         XEN_GUEST_HANDLE_PARAM(void) null;
@@ -4330,8 +4330,7 @@ static long __do_mmu_update(
          * on the fact that this argument isn't needed anymore.
          */
         rc = hypercall_create_continuation(
-                __HYPERVISOR_mmu_update, "hihi", null,
-                MMU_UPDATE_PREEMPTED, null, rc);
+                op, "hihi", null, MMU_UPDATE_PREEMPTED, null, rc);
     }
 
     put_pg_owner(pg_owner);
@@ -4417,7 +4416,18 @@ long do_mmu_update(
     XEN_GUEST_HANDLE_PARAM(uint) pdone,
     unsigned int foreigndom)
 {
-    return __do_mmu_update(ureqs, count, pdone, foreigndom, false);
+    return __do_mmu_update(ureqs, count, pdone, foreigndom,
+                           __HYPERVISOR_mmu_update, false);
+}
+
+long do_pte_get_and_clear(
+    XEN_GUEST_HANDLE_PARAM(mmu_update_t) ureqs,
+    unsigned int count,
+    XEN_GUEST_HANDLE_PARAM(uint) pdone,
+    unsigned int foreigndom)
+{
+    return __do_mmu_update(ureqs, count, pdone, foreigndom,
+                           __HYPERVISOR_pte_get_and_clear, true);
 }
 
 #endif /* CONFIG_PV */
diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index a625d634b694..0552e93ab560 100644
--- a/xen/include/hypercall-defs.c
+++ b/xen/include/hypercall-defs.c
@@ -174,6 +174,7 @@ multicall(multicall_entry_t *call_list, unsigned long 
nr_calls)
 #ifdef CONFIG_PV
 mmuext_op(mmuext_op_t *uops, unsigned int count, unsigned int *pdone, unsigned 
int foreigndom)
 mmu_update(mmu_update_t *ureqs, unsigned int count, unsigned int *pdone, 
unsigned int foreigndom)
+pte_get_and_clear(mmu_update_t *ureqs, unsigned int count, unsigned int 
*pdone, unsigned int foreigndom)
 stack_switch(unsigned long ss, unsigned long esp)
 fpu_taskswitch(int set)
 set_debugreg(int reg, unsigned long value)
@@ -232,6 +233,7 @@ caller: arm
 table:                             pv32     pv64     hvm32    hvm64    arm
 set_trap_table                     compat   do       -        -        -
 mmu_update                         do:1     do:1     -        -        -
+pte_get_and_clear                  do:1     do:1     -        -        -
 set_gdt                            compat   do       -        -        -
 stack_switch                       do:2     do:2     -        -        -
 set_callbacks                      compat   do       -        -        -
diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h
index 2149b8dd3808..9e2ba0107d3b 100644
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -118,6 +118,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
 #define __HYPERVISOR_xenpmu_op            40
 #define __HYPERVISOR_dm_op                41
 #define __HYPERVISOR_hypfs_op             42
+#define __HYPERVISOR_pte_get_and_clear    43
 
 /* Architecture-specific hypercall definitions. */
 #define __HYPERVISOR_arch_0               48
-- 
2.52.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.