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

[RFC PATCH v6 28/43] altp2m: Move altp2m_vcpu_{initialise,destroy} to common code


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
  • Date: Mon, 20 Apr 2026 17:26:33 -0400
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.20.97) smtp.rcpttodomain=amd.com smtp.mailfrom=elektrobit.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=elektrobit.com; dkim=pass (signature was verified) header.d=elektrobit.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=elektrobit.com] dmarc=[1,1,header.from=elektrobit.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 213.95.148.172) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=elektrobit.com; dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=elektrobit.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=2; 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=RlgX5a6AGvq5jH49n4U+x4WcIr+mTwnUzMyljWt2R54=; b=vgeV2FN5iGinNtMhFvvsJRyI3O8sqt1DrN61s2S2lEqPvahh0nvLJYTY9nIpUK4cvFV7J2BSl+Ahqj5zMygMH0UNnVk32H+JMZPTu+pf0A6spyK3AV53UBR+JITn2eocfcIDkQAs2erLmLZNry7kLdrgf5urziYrUKxsANX0WnQ0Jj50shIb4eMBX2mtqVyrs19L1vD7bb9s6ObLW2iKQ8p2osA+cwKET9NXLz1kQr9X1u8tCFzR0yFblEMbC9HFNmN2DQwPECvM4/2LlmBSz6a7tmkVD0AWEI82R7mK/Q+2Wn80no3nhjL06RH0F7MO4BKX6KTJCD66hOZeTgNDfg==
  • 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=RlgX5a6AGvq5jH49n4U+x4WcIr+mTwnUzMyljWt2R54=; b=qqi/7/bp+gdUjehPqCVIlzAL3CC61xNG6I+nCO5cSrjTYbwIL50nCdpSrR0MzniKpALEbIDKNsTzTNUKCrY96lOvqTgc/jnV7liZfpc91hz0XrSDC23I4FFrj+C+AFgN/DEZhDyv2XoWZkcUOY4oosu8jYjKOGHUdSNrG6HAONcp5Vxy1Q3DXdH4oaMc8fTF+PCIkI1chGRcdkHjo4IHZWHOxVxHEi6OfxDUwXdbsh4oxCVaJzRTADt0SW40UmrWT0FWhAtPKfCanERChSVRAfgwZE2sTctd62QgcBWQjEjwpmJURworqg1dBT2wVfiIkSMmx1rkh8BIJPhM5QceiA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=rhUuKMqadSoC/m/FDl/vnkeqMM37pzUvjs4KajgHH4cK35h4VSA1zPZFrfu6Q9WXiSeSa0yFyxQ9GRlhh0vNZXG+HiPd2EkiuBCmK/GkVyZDVrJMCGrS17zBoud+KywkHXQJDsT+LD5ngTu7XwIMqRDNeReCAMlE8dZWiV+nre5u4GOmOj1TEebKBx7hyzhPXoQtLt6PIwdGWB71Eh36mxYAeEq3+D411zt9gqeC/4WEJmRCvGAILe+dnBH4sPsutRx8KXZ6GyHKC/XeBDYb4UQZMglhlV5yVN0TkNdXQvS2oQ3kWU443XXbFJ0AmsD3IIDlqhmuZ1cVC+C18VkgcA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kiHyvJyPhUPpJW0xJFynuZcS0VdiVf+sfoz5XKQkrSlad/noyMFhOknVxF6lUT9kLzmlHUtIA1FDq4UGmYynAIbvoqTtLj1r56SWI0Km8GHHYBkaMcB6m9Y3oTNS9cba608lMnCsyScr4yVzcwMXmFNVAL2tz8+/jpFgbWZUBMVyymHBTpprglL35HkymSpw1Iw7Vc/N3u/llORMIIwnVIoPvfv/yzpTd7HhPFRz/MWJxqy/A5WxlCJz7NOOdDfM5/oUmj3PM++OW7aOeeAavAwa98FsanIKzEnMAlwNj4RUEOE+mrBYb+QrdNBnBS0LWH14YIUYFnYghvdKh/5XKQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=elektrobit.com header.i="@elektrobit.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=elektrobit.com header.i="@elektrobit.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, "Michal Orzel" <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>
  • Delivery-date: Mon, 20 Apr 2026 21:28:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This commit moves the altp2m_vcpu_initialise and altp2m_vcpu_destroy
functions to common code. This makes it possible to use them in the common
implementation of HVMOP_altp2m_set_domain_state.

This commit contains only code movement, and no change in functionality is
intended.

This is commit 1/2 of the altp2m_vcpu_{initialise,destroy} phase.

Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.
---
 xen/arch/x86/include/asm/altp2m.h |  6 -----
 xen/arch/x86/mm/altp2m.c          | 41 -------------------------------
 xen/common/altp2m.c               | 41 +++++++++++++++++++++++++++++++
 xen/include/xen/altp2m.h          |  6 +++++
 4 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/xen/arch/x86/include/asm/altp2m.h 
b/xen/arch/x86/include/asm/altp2m.h
index b3d348386a00..43dd5d2acd9c 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -105,10 +105,6 @@ int altp2m_get_effective_entry(struct p2m_domain *ap2m, 
gfn_t gfn, mfn_t *mfn,
                                p2m_type_t *t, p2m_access_t *a,
                                bool prepopulate);
 
-/* Alternate p2m VCPU */
-void altp2m_vcpu_initialise(struct vcpu *v);
-void altp2m_vcpu_destroy(struct vcpu *v);
-
 int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn);
 void altp2m_vcpu_disable_ve(struct vcpu *v);
 
@@ -151,8 +147,6 @@ static inline int _altp2m_get_effective_entry(struct 
p2m_domain *ap2m,
 
 /* Only declaration is needed. DCE will optimise it out when linking. */
 uint16_t altp2m_vcpu_idx(const struct vcpu *v);
-void altp2m_vcpu_initialise(struct vcpu *v);
-void altp2m_vcpu_destroy(struct vcpu *v);
 int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn);
 void altp2m_vcpu_disable_ve(struct vcpu *v);
 
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 46374373848d..0542e3ef9196 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -14,47 +14,6 @@
 #include "mm-locks.h"
 #include "p2m.h"
 
-void
-altp2m_vcpu_initialise(struct vcpu *v)
-{
-    if ( !v->domain->nr_altp2m )
-        return;
-
-    if ( v != current )
-        vcpu_pause(v);
-
-    vcpu_altp2m(v).p2midx = 0;
-    atomic_inc(&altp2m_get_altp2m(v)->active_vcpus);
-
-    altp2m_vcpu_update_p2m(v);
-
-    if ( v != current )
-        vcpu_unpause(v);
-}
-
-void
-altp2m_vcpu_destroy(struct vcpu *v)
-{
-    struct p2m_domain *p2m;
-
-    if ( !v->domain->nr_altp2m )
-        return;
-
-    if ( v != current )
-        vcpu_pause(v);
-
-    if ( (p2m = altp2m_get_altp2m(v)) )
-        atomic_dec(&p2m->active_vcpus);
-
-    altp2m_vcpu_disable_ve(v);
-
-    vcpu_altp2m(v).p2midx = INVALID_ALTP2M;
-    altp2m_vcpu_update_p2m(v);
-
-    if ( v != current )
-        vcpu_unpause(v);
-}
-
 int altp2m_vcpu_enable_ve(struct vcpu *v, gfn_t gfn)
 {
     struct domain *d = v->domain;
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index a731ad7cdab8..e699b64678d8 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -59,6 +59,47 @@ void altp2m_teardown(struct domain *d)
     XVFREE(d->altp2m_p2m);
 }
 
+#ifdef CONFIG_X86
+void altp2m_vcpu_initialise(struct vcpu *v)
+{
+    if ( !v->domain->nr_altp2m )
+        return;
+
+    if ( v != current )
+        vcpu_pause(v);
+
+    vcpu_altp2m(v).p2midx = 0;
+    atomic_inc(&altp2m_get_altp2m(v)->active_vcpus);
+
+    altp2m_vcpu_update_p2m(v);
+
+    if ( v != current )
+        vcpu_unpause(v);
+}
+
+void altp2m_vcpu_destroy(struct vcpu *v)
+{
+    struct p2m_domain *p2m;
+
+    if ( !v->domain->nr_altp2m )
+        return;
+
+    if ( v != current )
+        vcpu_pause(v);
+
+    if ( (p2m = altp2m_get_altp2m(v)) )
+        atomic_dec(&p2m->active_vcpus);
+
+    altp2m_vcpu_disable_ve(v);
+
+    vcpu_altp2m(v).p2midx = INVALID_ALTP2M;
+    altp2m_vcpu_update_p2m(v);
+
+    if ( v != current )
+        vcpu_unpause(v);
+}
+#endif
+
 /*
  * altp2m operations are envisioned as being used in several different
  * modes:
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index f5a4d0e60562..7defe6126563 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -24,6 +24,12 @@ int altp2m_init(struct domain *d);
 /* Free altp2m views */
 void altp2m_teardown(struct domain *d);
 
+#ifdef CONFIG_X86
+/* Alternate p2m VCPU */
+void altp2m_vcpu_initialise(struct vcpu *v);
+void altp2m_vcpu_destroy(struct vcpu *v);
+#endif
+
 #ifdef CONFIG_ALTP2M
 
 /* Alternate p2m HVM on/off per domain */
-- 
2.34.1




 


Rackspace

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