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

[RFC PATCH v6 29/43] arm/altp2m: Add support for altp2m_vcpu_{initialise,destroy}


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
  • Date: Mon, 20 Apr 2026 17:26:34 -0400
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.12.2) 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=GvY1Hq4hwLu2aLmi7v9CAxN3huVX6llKANSCVnMm0ZU=; b=GGBSb/mLw7P0Qpkk5AaMOIXae8ImBNMRqGFyfaL2xDH/VsqyalQtgUkt/raDruzP0zUVGiDusIDj7hKOBbuSVBWl8GLK/Crpj5Bhch3DC49mOcms/zZffEk78t4UY/GpdZoH31LUx8dh+zjfONOOTUxTkhT3UqwzBz1iovnUQ8drPP0H1og9vlijcFMgdFti8P/V6dvfN1u2i49IpcUqVP2B/9k7+ELPeFv5XkofZ5KkndnwvH0XH2raoj7o9XWVhpr2V4pSoc3vWyX3qNj/n+TjGkypALbBhzcAXdjR0yFD1Nd3gFdMZpTVfLb/ACbdTJTDYRaZ9j9WziVMXijd1A==
  • 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=GvY1Hq4hwLu2aLmi7v9CAxN3huVX6llKANSCVnMm0ZU=; b=BubyTJy+uuFnZrB9UFpc3mcUWOc5LT0g0lloAqu/VU73OaXzNWQ5Y67D3IMEJKHR7px+JEZQXsiKrwvxTpuMYMlNdAgJxLU5NegLnNEYk4JeU+p1c+zHxhW7KHC6cuhp8aqjLm8mE/5ZwOC7D7yY+YRlzG0XAUt//0UO9gVAyXtog+Be1dnGI1pB4PqQzMr+KkbJ9+40PPp/fzay4MzA5xQiMsEtKIWK+avdE9MGlW9inxIx47XJBivkXksgR0YQfc6OfbWZxciw51HL4Bjc3CH4PudUKoHNex/wLhXKDiW1beVCfqm3mEnYIamlemJUJRr5vRzd5tElVix3dZafCw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=KmUHL3giBvDV90PUB9gQ+LCpR0oAsKIwFYcbFiBZipOm1uvMCTSObL/oQzUZgW6ZrRNF19JwiSoBZQYzxkuH17y3OXJMInw7p/uKg+uDF6KWeUqt9p9yDVYUtwrALI78UMNfEpX387TrwL8U48lG/IoZdMw44pAeikr1zalyjGrUZ+yAp8Y+yOicqFGvCMJ6oKO4DF1iP1s3LYnLt3GlbYagZxca7A4lGuLwfSk+JTsDoqnmXADdKJfMT4MiPYcdwHM7FAELn2xqFKtEresaClbGhd/oak+GC/76DcnVr6w7Ck6RyFad6AhiEqNNL6ljQSNnYbInusLwzuVJllLKfQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZJAPAsaPZf+I/CE95epreu456e3g8/wUPnmuc6msVkTaSW53LZ1fItsHA9oqGNheP8gukjyqmq2vI0G8b8jfFQ7eM1++BTQIE1R4m4dyhI4I6id5CMgOF6U8gH/IT/jBGCy+p7ak0jlwbegzZY60UXolOX8tJVecnatGFrupaa+c25zxo9FEF7WJmW7jxCUaG4yjphdvu/S/HigFYKvKkZv4izEu+4cW0TF7ovOKRDraGx3IsEKYBTq8lBWY67d4T6a6qyb/TKV4dyjQg/EnVxeaAe3NMMwGf5w9D5TdIi8dBNphDy3K5jNy+tH52VK7t46fw/7d6Vdbb7mvtGqvQA==
  • 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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, "Julien Grall" <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Mon, 20 Apr 2026 21:28:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This commit adds support for the altp2m_vcpu_initialise and
altp2m_vcpu_destroy functions on ARM. The x86-specific function calls,
altp2m_vcpu_disable_ve and altp2m_vcpu_update_p2m, are gated with #ifdef
CONFIG_X86.

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

Signed-off-by: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
---
v6: Introduced this patch.

    The equivalent to this patch in the v4/v5 was originally part of the
    patch named "arm/altp2m: Add HVMOP_altp2m_set_domain_state". In that
    patch, the check that the VCPU passed to altp2m_vcpu_initialise isn't
    the current CPU was removed. This was because ARM only implements the
    external altp2m mode, meaning the current VCPU could never be a VCPU of
    the guest for which altp2m is being initialized for. Therefore,
    skipping this check was a slight optimization. I've removed that here
    because altp2m_vcpu_initialise is only called during an HVMOP, and
    skipping this check on ARM (especially when x86 also implements the
    external altp2m mode) causes more confusion than the slight
    optimization is worth in my view.
---
 xen/common/altp2m.c      | 14 ++++++++++----
 xen/include/xen/altp2m.h |  2 --
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/xen/common/altp2m.c b/xen/common/altp2m.c
index e699b64678d8..7b80426c7798 100644
--- a/xen/common/altp2m.c
+++ b/xen/common/altp2m.c
@@ -11,6 +11,7 @@
 #include <xsm/xsm.h>
 
 #if defined(CONFIG_X86) && defined(CONFIG_HVM)
+#include <asm/hvm/hvm.h>
 #include <asm/hvm/nestedhvm.h>
 #endif
 
@@ -59,7 +60,6 @@ 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 )
@@ -68,10 +68,12 @@ void altp2m_vcpu_initialise(struct vcpu *v)
     if ( v != current )
         vcpu_pause(v);
 
-    vcpu_altp2m(v).p2midx = 0;
+    altp2m_set_vcpu_idx(v, 0);
     atomic_inc(&altp2m_get_altp2m(v)->active_vcpus);
 
+#ifdef CONFIG_X86
     altp2m_vcpu_update_p2m(v);
+#endif
 
     if ( v != current )
         vcpu_unpause(v);
@@ -90,15 +92,19 @@ void altp2m_vcpu_destroy(struct vcpu *v)
     if ( (p2m = altp2m_get_altp2m(v)) )
         atomic_dec(&p2m->active_vcpus);
 
+#ifdef CONFIG_X86
     altp2m_vcpu_disable_ve(v);
+#endif
 
-    vcpu_altp2m(v).p2midx = INVALID_ALTP2M;
+    altp2m_set_vcpu_idx(v, INVALID_ALTP2M);
+
+#ifdef CONFIG_X86
     altp2m_vcpu_update_p2m(v);
+#endif
 
     if ( v != current )
         vcpu_unpause(v);
 }
-#endif
 
 /*
  * altp2m operations are envisioned as being used in several different
diff --git a/xen/include/xen/altp2m.h b/xen/include/xen/altp2m.h
index 7defe6126563..37c875a52327 100644
--- a/xen/include/xen/altp2m.h
+++ b/xen/include/xen/altp2m.h
@@ -24,11 +24,9 @@ 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
 
-- 
2.34.1




 


Rackspace

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