From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
To: xen-devel@lists.xenproject.org
Cc: "Daniel P. Smith" <dpsmith@apertussolutions.com>,
jason.andryuk@amd.com, stefano.stabellini@amd.com,
agarciav@amd.com,
Christopher Clark <christopher.w.clark@gmail.com>
Subject: [RFCv2 37/38] x86/hyperlaunch: generalize domid assignment
Date: Thu, 15 May 2025 09:19:49 -0400 [thread overview]
Message-ID: <20250515131951.5594-8-dpsmith@apertussolutions.com> (raw)
In-Reply-To: <20250515131951.5594-1-dpsmith@apertussolutions.com>
Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
xen/common/domain-builder/fdt.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c
index 1b3492571b15..414bbf5d9fb1 100644
--- a/xen/common/domain-builder/fdt.c
+++ b/xen/common/domain-builder/fdt.c
@@ -16,6 +16,21 @@
#include "fdt.h"
+#define MAX_DOMID DOMID_FIRST_RESERVED
+static __initdata DECLARE_BITMAP(domid_alloc, MAX_DOMID);
+
+static domid_t __init find_next_domid(void)
+{
+ unsigned long n = find_next_zero_bit(domid_alloc, MAX_DOMID, 1);
+
+ if ( n == MAX_DOMID )
+ return DOMID_INVALID;
+
+ set_bit(n, domid_alloc);
+
+ return (domid_t) n;
+}
+
static int __init fdt_prop_as_u32(const struct fdt_property *prop,
uint32_t *val)
{
@@ -231,18 +246,17 @@ static int __init fdt_process_domain_node(
if ( val >= DOMID_FIRST_RESERVED )
{
- printk(XENLOG_ERR " invalid domain id for domain %s\n", name);
- return -EINVAL;
- }
-
- for ( unsigned int i = 0; i < bi->nr_domains; i++ )
- {
- if ( bi->domains[i].domid == val )
+ if ( (val = find_next_domid()) == DOMID_INVALID )
{
- printk(XENLOG_ERR " duplicate id for domain %s\n", name);
- return -EINVAL;
+ printk(" unable to allocate domid for domain %s\n", name);
+ return -EFAULT;
}
}
+ else if ( test_and_set_bit(val, domid_alloc) )
+ {
+ printk(XENLOG_ERR " duplicate id for domain %s\n", name);
+ return -EINVAL;
+ }
bd->domid = val;
printk(XENLOG_INFO " domid: %d\n", bd->domid);
--
2.30.2
next prev parent reply other threads:[~2025-05-15 13:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-15 13:19 [RFCv2 30/38] x86/hyperlaunch: introduce concept of core domains Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 31/38] common/gzip: add function to read isize field Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 32/38] x86/hyperlaunch: move headroom under domain builder Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 33/38] x86/hyperlaunch: move kernel extraction " Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 34/38] x86/hyperlaunch: introduce multidomain kconfig option Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 35/38] x86/hyperlaunch: add multidomain construction logic Daniel P. Smith
2025-05-15 13:19 ` [RFCv2 36/38] x86/hyperlaunch: enable unpausing mulitple domains Daniel P. Smith
2025-05-15 13:19 ` Daniel P. Smith [this message]
2025-05-15 13:19 ` [RFCv2 38/38] tools: introduce hyperlaunch domain late init Daniel P. Smith
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250515131951.5594-8-dpsmith@apertussolutions.com \
--to=dpsmith@apertussolutions.com \
--cc=agarciav@amd.com \
--cc=christopher.w.clark@gmail.com \
--cc=jason.andryuk@amd.com \
--cc=stefano.stabellini@amd.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.