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

[RFC PATCH v6 30/43] arm/altp2m: Add altp2m view validity/visibility indicator


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
  • Date: Mon, 20 Apr 2026 17:31:53 -0400
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.14.103) 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=s+lzv+re9KLW9t3mTXnO2Av9Vu/LGRGNe05U4kI1kS4=; b=oX9XN1ezG9ZrmRxAEbp8Wv9sLawvJawHrUZhHeGy2b3UKh36mFIBbGVMd37fXtKre2B4JsIbhDXdFemDgMfAIeOdZk/6oQnhSVIzABylebNTg333gu+Z0qkolDAq9SqcXfDk0tTXNY6WjfGvxs5Jv7wKs5R7iTpf9hYqCS5x1GbZZ1gXeK513VXU6JK/vrqhNwpYdY/Z0GhqzYaxvhRWtvEIMeYm9Pz7JoPMV6QRH3IqjSiFgr94tsgJ1kl/j1GS6Xlqy62IrAbeCsNkQuB68bddkpYqWqP/ZeM5t5m2GzMDws0v1eGHREiBv7icEHVf4GUfH7vKW7zRfykiWbAVhw==
  • 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=s+lzv+re9KLW9t3mTXnO2Av9Vu/LGRGNe05U4kI1kS4=; b=Gbd83PjGQD/z0PAcJ2qrO/+trBMhY5fgRcrqrOQfGY7iCAb+04mVEwgmiljbk2qsvRbktXzpwW4mi8n/OHi5W3v0mMPEQ/zGU2HFjJ55cP/b7hMlxZWI9qb6I6UfttE8322kaB3Oq8nL7uNIXVrkAB6Ba1TNGb05ZyfMytqBaVUgx6v2qzuj1cb0UHo3VhBkX56pSClxLJqi9zAoC3mUrFP4n/IB9CS9Lhw4rTHvD5Qgs1vmhLoUUx+9FXFZYTb/VqhnD6gQsK7ydj7y8H9vxYrDdHU6BJr7iR+V1S2jUuucR7Q+6Xx6DIn9i1EynXA1DDpCFVDiRkiI9O9OSspidg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=fW5rgLRalDXniPNbEihUK4JOh5AWQthuEfqMxSR+HAp4ijP6sZyGW2OjWKIYMdVXIaZ590RxWflqyTQ8jaNKWopH/Lez1KDSk4QtLQhKVnZXx7ie9b6nyb1bIHm191H3v+dxK3GArjQRatsWpvZVI2sZHL44xWggd9F/2z/SlFDh6Fn0IUXvWqdeFfl7ZltKVRDb+9Wc0pfKGPbQ220oF1ZklSBNenb2uXrwI/Clhc0svLVuK00OBU4KdQFR3tR5L/8K1pYahwG8n3qz9Y6MeZsbPPgHkrV7sw67ayR1hMT7fD8JpdGaz2PzqICZulw0V8lnAimNhsiU0/25BYRVng==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oCWcyenad4h9ix7aAbJT5eBdWqviFeYRmMnsIKg0HuvGrAXdcdx330dNd5xRw6tZ7gnr4D73mYzdJIQFqpqHU0OjJ2nHBSJfUkDD9LdkKVomym2bBZaKkAAhZVKcLqofZKhzZ/8pHJ8W2c9YLTYiq34w25EvEEqolI2otuG8iKuI6U483r3BP9ViD2jIj7OPzf1LFBc8AHfcmZIr/7MuKqoUPUt81L72NX4Z2M7huTo3M9XsX4SmthCP2VBE5ThVfLqiKsRlRwnsQv+KYz9bqSlhrLGjaQ16wRX7xTfHD/5++baohYlo18/0ABfYY3akEcxTCF/ZFMTKL1XF0Y92Uw==
  • 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>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 20 Apr 2026 21:33:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This commit adds the altp2m_view_state enum, which indicates whether an
altp2m view is invalid, visible, or invisible. The altp2m_state array is
comprised of altp2m_view_state values, where each entry corresponds to the
altp2m view with the same entry. This is analogous to the altp2m_eptp and
altp2m_visible_eptp arrays on x86.

This addition is necessary to tell whether an altp2m is valid, in addition
to whether it is visible. Since all altp2m views are allocated up-front
during p2m initialization, there must be an additional mechanism to
determine whether an altp2m view is valid. Since the implementation of
HVMOP_altp2m_set_visibility also needs an additional mechanism to determine
whether a view is visible, it makes sense to combine altp2m view validity
and visibility into a single mechanism. Therefore, the altp2m_state array
is used to track both view validitity and visibility.

This is commit 1/5 of the altp2m view validity/visibility phase.

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

    In the v4/v5 patch series, view validity was determined by simply
    checking if the altp2m p2m_domain pointer is NULL. This isn't possible
    in the v6 patch series, since altp2m views are allocated up-front
    during altp2m_init.

    Since the altp2m_view_state enum definition has to be available in
    asm/domain.h, this commit removes the sched.h dependency from altp2m.h.
    Unfortunately, this means that it's not possible to have static inline
    functions in altp2m.h which need a complete definition of arch_domain
    and arch_vcpu. If there would be a better place to put the
    altp2m_view_state definition, feedback would be appreciated.
---
 xen/arch/arm/altp2m.c             | 13 +++++++++++++
 xen/arch/arm/include/asm/altp2m.h | 23 +++++++++++++----------
 xen/arch/arm/include/asm/domain.h |  4 ++++
 xen/arch/arm/mmu/p2m.c            | 14 +++++++++++++-
 4 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/altp2m.c b/xen/arch/arm/altp2m.c
index 339f82835caf..e741648ff5a1 100644
--- a/xen/arch/arm/altp2m.c
+++ b/xen/arch/arm/altp2m.c
@@ -5,6 +5,8 @@
  * Copyright (c) 2016 Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
  */
 
+#include <xen/sched.h>
+
 #include <asm/p2m.h>
 
 /* Check to see if vcpu should be switched to a different p2m. */
@@ -14,6 +16,17 @@ void altp2m_check(struct vcpu *v, uint16_t idx)
     BUG();
 }
 
+/* Alternate p2m VCPU */
+uint16_t altp2m_vcpu_idx(const struct vcpu *v)
+{
+    return v->arch.ap2m_idx;
+}
+
+void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx)
+{
+    v->arch.ap2m_idx = idx;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/arm/include/asm/altp2m.h 
b/xen/arch/arm/include/asm/altp2m.h
index f001e022a213..05beb7f698a7 100644
--- a/xen/arch/arm/include/asm/altp2m.h
+++ b/xen/arch/arm/include/asm/altp2m.h
@@ -9,7 +9,10 @@
 #ifndef __ASM_ARM_ALTP2M_H
 #define __ASM_ARM_ALTP2M_H
 
-#include <xen/sched.h>
+#include <xen/mem_access.h>
+
+struct domain;
+struct vcpu;
 
 #ifdef CONFIG_ALTP2M
 
@@ -24,15 +27,15 @@ static inline bool altp2m_supported(void)
 #define altp2m_unlock(d)    spin_unlock(&(d)->arch.altp2m_lock)
 
 /* Alternate p2m VCPU */
-static inline uint16_t altp2m_vcpu_idx(const struct vcpu *v)
-{
-    return v->arch.ap2m_idx;
-}
-
-static inline void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx)
-{
-    v->arch.ap2m_idx = idx;
-}
+uint16_t altp2m_vcpu_idx(const struct vcpu *v);
+void altp2m_set_vcpu_idx(struct vcpu *v, unsigned int idx);
+
+/* The current state of an altp2m view */
+enum altp2m_view_state {
+    ALTP2M_INVALID,
+    ALTP2M_VISIBLE,
+    ALTP2M_INVISIBLE,
+};
 
 #else /* CONFIG_ALTP2M */
 
diff --git a/xen/arch/arm/include/asm/domain.h 
b/xen/arch/arm/include/asm/domain.h
index 4d497a21b648..28533b08db1f 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -3,6 +3,7 @@
 
 #include <xen/cache.h>
 #include <xen/timer.h>
+#include <asm/altp2m.h>
 #include <asm/page.h>
 #include <asm/p2m.h>
 #include <asm/suspend.h>
@@ -135,6 +136,9 @@ struct arch_domain
      * concurrently.
      */
     spinlock_t altp2m_lock;
+
+    /* Validity/visibility of altp2m views */
+    enum altp2m_view_state *altp2m_state;
 #endif
 }  __cacheline_aligned;
 
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index 04d17e787259..7c23995f8074 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -1494,6 +1494,8 @@ int p2m_teardown(struct domain *d)
 
     d->altp2m_active = false;
 
+    FREE_XENHEAP_PAGE(d->arch.altp2m_state);
+
     for ( i = 0; i < d->nr_altp2m; i++ )
     {
         rc = p2m_teardown_one(d->altp2m_p2m[i]);
@@ -1617,7 +1619,7 @@ struct p2m_domain *p2m_init_one(struct domain *d)
 static int p2m_init_altp2m(struct domain *d)
 {
 #ifdef CONFIG_ALTP2M
-    int rc;
+    int rc, i;
 
     rc = altp2m_init(d);
     if ( rc )
@@ -1626,6 +1628,16 @@ static int p2m_init_altp2m(struct domain *d)
         return rc;
     }
 
+    if ( (d->arch.altp2m_state = alloc_xenheap_page()) == NULL )
+    {
+        return -ENOMEM;
+    }
+
+    for ( i = 0; i < d->nr_altp2m; i++ )
+    {
+        d->arch.altp2m_state[i] = ALTP2M_INVALID;
+    }
+
     d->altp2m_active = false;
 #endif
 
-- 
2.34.1




 


Rackspace

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