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

[RFC PATCH v6 21/43] arm/p2m: Change func prototype and impl of p2m_{alloc,free}_vmid


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Rose Spangler <Rose.Spangler@xxxxxxxxxxxxxx>
  • Date: Mon, 20 Apr 2026 17:26:26 -0400
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 40.93.13.101) 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=oIAPv9xmUqmZOQALhD1wFmf2mfwJESnPZqbe9aDV5X0=; b=f7GCRVS8dCCMLyaUx6gwhC5HypeIS9dI3B4Ty32W/xGcmQeBvbMyxNB5miIIqCB+fvLy8QbTiAtBnPZs3zVbhno9QEd1dtKQZAAeakd/JOvaG6qwm08KBCdLiUkqnlALzLBHV0S3z6XxLicLlEk3ZnxB+1kbnab79zogaDpIcIm2n8WcUOn6DpKFvQHJTzP3l/BIoOK+3Cge3zGvAkmryvFOi6b4k7O5Eo+LtF2alTezV9s0wDg9HhWcKO32VjBXpzcQlcyRyiucELOjDvytNVX/SX6yrRE/lE1wseIvuX58IsTxOewX/7zfgThZXrOmHyScbiAyaYkeo/Zu92riHg==
  • 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=oIAPv9xmUqmZOQALhD1wFmf2mfwJESnPZqbe9aDV5X0=; b=D7dWM80FtLHyjW71hMh5L2JZ1SJPgopyIs0SwbKYAyDCt4lHE4O+66DKdhDEu2KvUhtv30gWBse5Jyhh4iPSeG3/t/DyW+61d2eu6SM1YWRJUBzW+a0KNw3TzGvRntm6uzatXtCqnyXEEqIhv5mxoH18cZJn6MWROSR2eqTuw/NfT9fXpyUWC0y8zp5c2vKlOY6+Hlu3slABwPAXF7H91OduD6cOGLL1v+SxDXRwaqr5rp+3MakBuYAkFi8fk3EQP2GkUTghR+1agAwVgfh9zI7CPYHR6NsOd91jRq/41KsU0ix1L6IHklYe+j1mkOwEv2FJ0QRvZNiiatVLOAGEMQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=GiaKOdP7Rh+1SxptvOYJi0BY3N3yj0dpLS2KOih34S8kNq5DQx1ihQXLjis9t0l24wfo17QeXY3MgMlMAOO1t+CNfjW7ANUfsZ8tMrSmGqLzTcRMZ5f7gKbAcerQsQEvFPmfoLD+zZMgyOE7A7sCy7jVDOseJ1UKhflB0UXREKIIl/3xzm17+cglKDinsBU+qnuN7I41x9fQ+luIyVEWRhaaz1ulFHutd+UTqgX4O953wXdQ96+Cm8oNPlGlSy5mw/GNUjPFRzdIY1RdIKJLpQ0/6o+6JWesSIK9l09Q8H+Y0BA6g+YoFuio4y7kJijZzF7bUGYwZxnaFqoSNh+TLQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ow4F/7lO5VaHfhzHxTG8lJr1L7xJ9w6Fcmr2vUDfkoI8EcjOrjoWeIKyntut9UXNZMcV0aGymggLVXe29pFUNDbezJ1Jl1l4UmmOCUakaYgyYanZ0SYhj0LHn7IF7TnEyYnm/i9qsArFwPWKg2+lcZkrcIXaa81pHgU/k4a4wemx1y+inj3lPqgdog6vitll6kutuXNT7nFcIR290qIrSRiJKQiBvN+xE8ULMLOF0qAxYqIlI1qVj821O0gbqOtjl6r9vt6EFbzhQx22tL/QPgeI5iyQFKZHuvGAlJZ4S56nws0ql/Ucdc5OmxljpQJ1d5fmeuNdqfOVb5dAIQfUtw==
  • 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: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>, 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:27:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>

This commit changes the prototype and implementation of the functions
"p2m_alloc_vmid" and "p2m_free_vmid". The function "p2m_alloc_vmid" does
not expect the struct domain as argument anymore and returns an
allocated vmid. The function "p2m_free_vmid" takes only the vmid that is
to be freed as argument.

This is commit 10/12 of the altp2m_init/altp2m_teardown routines phase.

Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
---
v3: Changed function prototypes and implementation of the functions
    "p2m_alloc_vmid" and "p2m_free_vmid".

    Changes in "p2m_alloc_vmid":
    This function does not expect any arguments. Also, in this commit,
    the function "p2m_alloc_vmid" returns either the successfully
    allocated vmid or the value INVALID_VMID. Thus, it is now the
    responsibility of the caller to set the returned vmid in the
    associated fields.

    Changes in "p2m_free_vmid":
    This function expects now only the vmid of type uint8_t.
---
 xen/arch/arm/include/asm/p2m.h |  4 ++--
 xen/arch/arm/mmu/p2m.c         |  8 ++++----
 xen/arch/arm/p2m.c             | 23 ++++++++---------------
 3 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h
index 5c6dfe4a9789..62261d41e780 100644
--- a/xen/arch/arm/include/asm/p2m.h
+++ b/xen/arch/arm/include/asm/p2m.h
@@ -195,8 +195,8 @@ static inline bool arch_acquire_resource_check(struct 
domain *d)
 void p2m_restrict_ipa_bits(unsigned int ipa_bits);
 
 void p2m_vmid_allocator_init(void);
-int p2m_alloc_vmid(struct domain *d);
-void p2m_free_vmid(struct domain *d);
+uint8_t p2m_alloc_vmid(void);
+void p2m_free_vmid(uint8_t vmid);
 
 /* Second stage paging setup, to be called on all CPUs */
 void setup_virt_paging(void);
diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c
index f546f63f2489..0d37760ef5d5 100644
--- a/xen/arch/arm/mmu/p2m.c
+++ b/xen/arch/arm/mmu/p2m.c
@@ -1519,7 +1519,7 @@ void p2m_free_one(struct p2m_domain *p2m)
 
     p2m->root = NULL;
 
-    p2m_free_vmid(p2m->domain);
+    p2m_free_vmid(p2m->vmid);
 
     radix_tree_destroy(&p2m->mem_access_settings, NULL);
 
@@ -1570,9 +1570,9 @@ static int p2m_initialise(struct domain *d, struct 
p2m_domain *p2m)
      */
     p2m->domain = d;
 
-    rc = p2m_alloc_vmid(d);
-    if ( rc )
-        return rc;
+    p2m->vmid = p2m_alloc_vmid();
+    if ( p2m->vmid == INVALID_VMID )
+        return -EBUSY;
 
     rc = p2m_alloc_table(p2m);
     if ( rc )
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 2c43b6033360..3342fafcc8a7 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -282,11 +282,9 @@ void p2m_vmid_allocator_init(void)
     set_bit(INVALID_VMID, vmid_mask);
 }
 
-int p2m_alloc_vmid(struct domain *d)
+uint8_t p2m_alloc_vmid(void)
 {
-    struct p2m_domain *p2m = p2m_get_hostp2m(d);
-
-    int rc, vmid;
+    uint8_t vmid;
 
     spin_lock(&vmid_alloc_lock);
 
@@ -296,28 +294,23 @@ int p2m_alloc_vmid(struct domain *d)
 
     if ( vmid == MAX_VMID )
     {
-        rc = -EBUSY;
-        printk(XENLOG_ERR "p2m.c: dom%d: VMID pool exhausted\n", d->domain_id);
+        vmid = INVALID_VMID;
+        printk(XENLOG_ERR "p2m.c: VMID pool exhausted\n");
         goto out;
     }
 
     set_bit(vmid, vmid_mask);
 
-    p2m->vmid = vmid;
-
-    rc = 0;
-
 out:
     spin_unlock(&vmid_alloc_lock);
-    return rc;
+    return vmid;
 }
 
-void p2m_free_vmid(struct domain *d)
+void p2m_free_vmid(uint8_t vmid)
 {
-    struct p2m_domain *p2m = p2m_get_hostp2m(d);
     spin_lock(&vmid_alloc_lock);
-    if ( p2m->vmid != INVALID_VMID )
-        clear_bit(p2m->vmid, vmid_mask);
+    if ( vmid != INVALID_VMID )
+        clear_bit(vmid, vmid_mask);
 
     spin_unlock(&vmid_alloc_lock);
 }
-- 
2.34.1




 


Rackspace

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