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

[RFC PATCH v6 37/43] altp2m: Move altp2m_init_by_id to common code


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
  • Date: Mon, 20 Apr 2026 17:32:00 -0400
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.20.102) 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=DZVQd2YS2Dc072OkbjYDsSwvSmp2EL0f2N2Sbux/YCg=; b=i4L21idI0hr2NGqfQmDBrWdKBFLvn1Dh2iTGl6X2ilN/TAsmBZhXTPLXaI6HNsy0n/xA7qjQ+5PTO7gl07TX46px8tL4Sn+MrxpEyQ51gUyNSjILkIJYiXCe7/Q9IGyRLqTsNWa7E0PNPtoCl6SWUTgHaOQkWn8evImfI2/TIPNAelGOklVf1FQwNJwv1DOt5Y3o9TR3aVKmEjh3oaEQEckSYjA1nf+XeizGQk+7i58bIoUU4H5puAOJbVflamb4bGryaoJrjaEb8IB7kMV8frlY0E9igtMc4wgdsN3kXE7YDQF3a06fI47ZwrU/29tTeWj5nKm7aNx8YBICGtPxcQ==
  • 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=DZVQd2YS2Dc072OkbjYDsSwvSmp2EL0f2N2Sbux/YCg=; b=vqDebuhy54vfnb3FugiQZiBdkLg5jIs3OaZaF3Yjj5ACnQhpdV43wqvFRHxCEU1F/pFBuzQAFgHKw2IyoLH/JdoCl3ugDTPZQ1MOpbqlf4XAEZmLp7U5gxasU/pcKiu2nUDzyhVaI/331xTt4jmed0Q+hLY0S3Eet13UgRxIJpOtXtqHPxlvLG4fXSeJlPL5XjrZQuohJyqSvZEZRUs07ISICTr/nPl5cNAftCyTVyNZ/lc14pQ6CWXI50IP1g74NaEU0bxh4xeBwKakx9OuT+N8GoxywwAfilEfoUlaLRfryGJt3FlfRUl7v5D5WbIczyyw3c+rHLQI2KYfNyS2LQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=Ljlm4EOKSp3cm5SZ/LDxSZnszcH6gQ0HmAyddQCrs9gAom86BBAeFpWO0zfDExQxQy4loLUWDMi7e9PcdMCOgO1a+pifhvT9EUYPcA08W2davzoYxxxZqU8AyUBM7vFhE7TdArd+BxC47suLrH+pv76oeTqrfj5J3Eyox4k87SBkbVjzcy0sKbD8sQulkjNfwf+gmAilex3Ud9Hlyexafo8VRjPfOh5Ho0QFnxz+/VlyQoX9klRAvm1RZ6V6vru5bYmkblEbFRpClUEUyh9y6EjfElnxDbiO371zCgzs12pkpZfhJLVwA5i4XX5mxQwH7Vs4zE+zeDlNfPgQ7CJmXw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G3kS4OWo3p8fTIR0139thXroFifVHuZqb36sJyOhMyfW8dlsdKhtU6XiM/potRkwd9fkUv9N0nSmVVh7jNiAXnJqOabvF4lkKpo8JP93uQijwtaAfkTkAP320c4nP3PAqgFs++/gPMrcurb8J3yrih8okouTYe8z+9XtxVaOhQQGGW4n5VXjCSOTlSOg3A3vJU2ubs5gEhKKzfWZRXCSYCTizI+CY7Yq0/u9YfnBaO7gH9+uWTiLqkczMjmhT/lAhnq+2z0YU4EI71Id3Gp/QrYvLejeHOpu9zf9hBjqYDpOATRQWF0pBg3RXfhHFQ34G7v3AkG/C4r2YKfHwjtDPg==
  • 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:33:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This commit moves the altp2m_init_by_id function to common code, gated to
only compile on x86. This makes it possible to call in the common
HVMOP_altp2m_set_domain_state command implementation.

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

This is commit 1/2 of the altp2m_init_by_id phase.

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

diff --git a/xen/arch/x86/include/asm/altp2m.h 
b/xen/arch/x86/include/asm/altp2m.h
index 203dba44e2bf..e7239326c71d 100644
--- a/xen/arch/x86/include/asm/altp2m.h
+++ b/xen/arch/x86/include/asm/altp2m.h
@@ -85,9 +85,6 @@ bool altp2m_switch_vcpu_by_id(struct vcpu *v, unsigned int 
idx);
 /* Flush all the alternate p2m's for a domain */
 void altp2m_flush(struct domain *d);
 
-/* Make a specific alternate p2m valid */
-int altp2m_init_by_id(struct domain *d, unsigned int idx);
-
 /* Find an available alternate p2m and make it valid */
 int altp2m_init_next_available(struct domain *d, uint16_t *idx,
                                xenmem_access_t hvmmem_default_access);
diff --git a/xen/arch/x86/mm/altp2m.c b/xen/arch/x86/mm/altp2m.c
index 40c6ea72a621..edbaf54c3761 100644
--- a/xen/arch/x86/mm/altp2m.c
+++ b/xen/arch/x86/mm/altp2m.c
@@ -315,24 +315,6 @@ int altp2m_activate_altp2m(struct domain *d, unsigned int 
idx,
     return rc;
  }
 
-int altp2m_init_by_id(struct domain *d, unsigned int idx)
-{
-    int rc = -EINVAL;
-    struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
-
-    if ( idx >= d->nr_altp2m )
-        return rc;
-
-    altp2m_lock(d);
-
-    if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] ==
-         mfn_x(INVALID_MFN) )
-        rc = altp2m_activate_altp2m(d, idx, hostp2m->default_access);
-
-    altp2m_unlock(d);
-    return rc;
-}
-
 int altp2m_init_next_available(struct domain *d, uint16_t *idx,
                                xenmem_access_t hvmmem_default_access)
 {
diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index c234bb3774f4..9f5f98e1e8a5 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -106,6 +106,26 @@ void altp2m_vcpu_destroy(struct vcpu *v)
         vcpu_unpause(v);
 }
 
+#ifdef CONFIG_X86
+int altp2m_init_by_id(struct domain *d, unsigned int idx)
+{
+    int rc = -EINVAL;
+    struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
+
+    if ( idx >= d->nr_altp2m )
+        return rc;
+
+    altp2m_lock(d);
+
+    if ( d->arch.altp2m_eptp[array_index_nospec(idx, MAX_EPTP)] ==
+         mfn_x(INVALID_MFN) )
+        rc = altp2m_activate_altp2m(d, idx, hostp2m->default_access);
+
+    altp2m_unlock(d);
+    return rc;
+}
+#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 37c875a52327..cd96c3b4792a 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -71,6 +71,11 @@ static inline bool altp2m_set_altp2m(struct vcpu *v, 
unsigned int idx)
 
 int do_altp2m_op(XEN_GUEST_HANDLE_PARAM(void) arg);
 
+#ifdef CONFIG_X86
+/* Make a specific alternate p2m valid */
+int altp2m_init_by_id(struct domain *d, unsigned int idx);
+#endif
+
 #else /* CONFIG_ALTP2M */
 
 static inline bool altp2m_active(const struct domain *d)
-- 
2.34.1




 


Rackspace

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