From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966522; cv=none; d=zohomail.com; s=zohoarc; b=mCxsrUXFp8thXVXu/6zH+0pLo++FcX6wrM/O8VopKH08tEv+npEcBOtpCBQEg3FZxaVXrs+iGCPClhf39dOWJFiN8nNrtzibOt0ZNHAgZUsDmpri7K9yjzS2fD8it9X6Wd5RIwFU03c1DprWKbwhFSqE47vrzKkSB38ECyVz2kE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966522; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lvvILD6LxqUZ5OrEiQyNFYfNqt1pXsQ3qXxqOC13MNM=; b=G6IRTsY9vM7AChliyyzn5fj1tWW6lfNpEyL7sgMEU1qqXUNe1s5Eh8iIWqTWveikrOy2CrVsJYeKZb+P4oKFjaaLRc5kIwF1N8bIwJL5miup1TPQE6d+Y2pCn2FYVkMOlDJSfADnmsAf8BIUHH5vPmcguTJebjylI8HviJYig1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966522678722.6973451369576; Wed, 9 Sep 2026 08:08:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413248.1643473 (Exim 4.92) (envelope-from ) id 1x4JuF-0000be-Ix; Wed, 09 Sep 2026 15:08:11 +0000 Received: by outflank-mailman (output) from mailman id 1413248.1643473; Wed, 09 Sep 2026 15:08:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuF-0000bX-G8; Wed, 09 Sep 2026 15:08:11 +0000 Received: by outflank-mailman (input) for mailman id 1413248; Wed, 09 Sep 2026 15:08:10 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuE-0000PH-J4 for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuD-00Cu0U-W9 for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:10 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17659-e002-0a2a0a5209dd-0a2a4507ddba-2 for ; Wed, 09 Sep 2026 17:08:09 +0200 Received: from [209.85.218.43] (helo=mail-ej1-f43.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17659-b4ea-0a2a45070019-d155da2bd548-3 for ; Wed, 09 Sep 2026 17:08:09 +0200 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-c2938116fefso119839866b.1 for ; Wed, 09 Sep 2026 08:08:09 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966489; x=1789571289; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lvvILD6LxqUZ5OrEiQyNFYfNqt1pXsQ3qXxqOC13MNM=; b=GDEnIhRzPILyaE228ezRTwzYTj3B9B3m6uXaFyEfqhvForn1hA7mhmaSm8uVzqEsNd 4EA5dJB18Su9P0X2pPD4Nw7WJB/rX8+IZ0TEA048U6HPE1PDKb7tqwz6uOvr9igU24YE lWM1yK38Fl6jdEtTH95k0s/3kvFzeJ1gOaouEgdIe8MVLqraGsv1+n++j4vn9AnMv76j UrRZLGvcHmoajNXfOi6ig90RrjKUDCEODgGAN5wr3P8ySodqRGq9d6/elDqIAGCoiKew PYTSn9cewm0sVczPK5p9/Yq+/AXLCdqli60wUbPeiuPdNRD9U+mJiU4qtMjHSgZICNCV rG/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966489; x=1789571289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lvvILD6LxqUZ5OrEiQyNFYfNqt1pXsQ3qXxqOC13MNM=; b=S/4wvBIVYbzsct/XP/ny9F2CplYRmg6Sx62dmFnz8Um4egTc0FCB1iVCOVw5neyZRn NXprSr/IhgZQsKoq3QoGGZw3Z2vlGbDjLCGrWV1InGZjbI/wwMANtjnhlAC4u3MyCjOs WnB6CaKP3q+Ebdu1lU9igaIcsF2gTVvbMiQI9EhMacA14Q7yGSHKwj/+c5QpElGKGnSM +12fTy1qXO+23KCQy+D/lFmzwOx58t/t7j+5labu5S6jW75MLNXUl/wjYT9DJdEYb4Tr GxG2TDwkGur3oYa2TleDzbFjHKhNbtiLwxZiCaRyZJpa7caO+UXhg/7lXKbY1Y83rbi0 38ow== X-Gm-Message-State: AFuF++l4deIk2x+OqZETq2KvlLvlDMNKn52wqk3Utin+ZHmlXep1IrxJ MiTjawqS+pQ7Vn2gz5jXUnoMO2HNyLOVjyHov0zGrCxTowzezVnZmuB7+qKxcl3v X-Gm-Gg: AYBFou30mG19p4jRvMwr+2m83iYI0PAbAcVgPJxZ9aasKAbSkpA9JGYeHvD1EL/HtfW ac656KnJXAbTIr8BhI3c3Vgu6Tk5aN29d9E0fWFHWTMIWxtZCR/wxXypuol47GikYcoWwdFXG0s +5hH6Lg1/noSLOoxrWtQwhKuvfcR2onVzTkqTxb4DrzWHO1P3V9II0c8zECre674vn/mwuIyCFu TSp724wqbAzClud7pj61/DqbZoydJwW4xnuleaTmAvr0guVAjK/sVxTEArJodhq3dq/nroFNbEC STugyJvvWEO7jyXAuqF+xorYayjOMLKTQD0v1BxanWtxxksjfSyfXRuNUayG1WzaPt4979/jGqI geAVl+linJfGzoNtGq1PcXZWkHC7ZEwKTd2Wv48JbF7wcQaBzO3yw37ARtUOCqHDgflvWrRjSq7 4AzhBH2tRIFTI22HaPxWzEievYGVzEE72b37RC0t7qaN4QI7apXFF9vslzYSQB0hzVBtCQXasOu Od6bZfiS/65PqJLECo= X-Received: by 2002:a17:907:94cc:b0:c26:19de:9ac5 with SMTP id a640c23a62f3a-c2619dea621mr1326204666b.29.1788966488902; Wed, 09 Sep 2026 08:08:08 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH v9 01/20] xen: introduce CONFIG_HAS_SHARED_INFO for archs without a shared page Date: Wed, 9 Sep 2026 17:07:19 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1788966489-34ECEAE4-E410B852/10/73395122804 X-purgate-type: spam X-purgate-size: 19187 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966523819158500 Content-Type: text/plain; charset="utf-8" On architectures that run guests in dom0less mode without the PV ABI (currently RISC-V), no shared_info page is allocated and d->shared_info remains NULL throughout the domain lifetime. Several places in common code access d->shared_info through the shared_info() macro or directly, causing UBSAN null-pointer errors on such architectures. Rather than adding runtime NULL guards that are logically unreachable on x86 and Arm (where shared_info is always allocated), introduce a new Kconfig symbol CONFIG_HAS_SHARED_INFO selected by x86 and Arm. On !HAS_SHARED_INFO the shared_info() macro expands to a dereference of shared_info_absent, an extern pointer that is declared but intentionally never defined. Any use of shared_info() that is not dead-code-eliminated will therefore cause a link-time failure, making missed guards impossible to overlook. The 2L event-channel ops call shared_info() and must not be compiled on architectures without a shared_info page, so event_2l.o is gated on CONFIG_HAS_SHARED_INFO. On such architectures evtchn_init() installs the FIFO ops as a placeholder instead, so that a later guest opt-in to the FIFO ABI via EVTCHNOP_init_control has no special-casing to do; if FIFO support itself is also unavailable (!CONFIG_EVTCHN_FIFO), a dedicated no-op evtchn_port_ops_none table is installed instead, so that d->evtchn_port_ops is never NULL. evtchn_fifo_word_from_port() is guarded against uninitialised d->evtchn_fifo so the FIFO ops are safe before evtchn_fifo_init_control() is called by the guest. With CONFIG_HAS_SHARED_INFO=3Dn all vCPUs fall back to the global dummy_vcpu_info, so writes through vcpu_info() could leak data between vCPUs. Reviewing the write paths in common code: the write in map_guest_area() stores the constant ~0 so nothing serious would happen if it were leaked; the event_2l.c paths are not compiled on !HAS_SHARED_INFO, as event_2l.o is gated on CONFIG_HAS_SHARED_INFO; the write in vcpu_info_populate() targets the new mapping buffer, not dummy_vcpu_info. Outside common code, the remaining writes are x86 PV-specific, for which CONFIG_HAS_SHARED_INFO=3Dy. No code changes are needed. Finally, struct domain's shared_info field itself is gated on CONFIG_HAS_SHARED_INFO, as it would otherwise be a permanently NULL pointer: every user of it is either arch code for an architecture that selects HAS_SHARED_INFO, or common code already guarded by the same Kconfig symbol. Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich Acked-by: Michal Orzel #Arm --- Changes in v9: - Nothing done. Only rebase. --- Changes in v8: - Introduce evtchn_preinit(). - Update some comments in the code. - Add Reviewed-by: Jan Beulich . --- Changes in v7: - domctl.c: use a plain #ifdef CONFIG_HAS_SHARED_INFO / #else instead of the IS_ENABLED() if/else in getdomaininfo(), and set info->shared_info_frame to ~0 in the !HAS_SHARED_INFO case. - sched.h: drop struct domain's shared_info field when !HAS_SHARED_INFO, rather than keeping a field that can only ever be NULL there. All of its users are either in arch code selecting HAS_SHARED_INFO or already guarded by CONFIG_HAS_SHARED_INFO, so no further changes are needed. Update the commit message accordingly. --- Changes in v6: - s/INVALID_GFN_RAW/gfn_x(INVALID_GFN) as INVALID_GFN_RAW was dropped. - event_channel.c: make evtchn_none_init() static, moving the evtchn_port_ops_none table and its definition above evtchn_reset(), their first caller; move the leftover prototype into the #else arm of the same #ifndef guard instead of leaving it as a free-standing non-static declaration. - event_channel.c: evtchn_reset() now follows the same IS_ENABLED(CONFIG_HAS_SHARED_INFO) / IS_ENABLED(CONFIG_EVTCHN_FIFO) / else cascade already used by evtchn_init(), rather than assuming the FIFO ABI is unconditionally available whenever d->evtchn_fifo was set. - event_channel.c: narrow the evtchn_port_ops_none / evtchn_none_init guard from !CONFIG_HAS_SHARED_INFO to !CONFIG_HAS_SHARED_INFO && !CONFIG_EVTCHN_FIFO, so the placeholder cf_check functions are only built for the one combination that actually needs them. - event_channel.c: fix the evtchn_port_ops_none comment, which claimed the ops were never reachable in practice; they are reached whenever an event is delivered to (or queried on) a !HAS_SHARED_INFO && !EVTCHN_FIFO domain, they just have no ABI to record it in and discard it. - event_channel.h / event_fifo.c: drop the static inline evtchn_fifo_init_ops() stub for !CONFIG_EVTCHN_FIFO; a plain declaration outside the #ifdef/#else is enough, matching the treatment already given to evtchn_2l_init() and evtchn_none_init(). Update the "only call site" comment in event_fifo.c to mention both evtchn_init() and evtchn_reset(). --- Changes in v5: - drop the static inline evtchn_2l_init() stub for !HAS_SHARED_INFO; a plain declaration is enough since the only call sites are guarded by IS_ENABLED(CONFIG_HAS_SHARED_INFO) and the dead call is eliminated before linking. - fix a NULL d->evtchn_port_ops dereference when CONFIG_HAS_SHARED_INFO=3Dn and CONFIG_EVTCHN_FIFO=3Dn: evtchn_init() was unconditionally calling evtchn_fifo_init_ops(), whose !EVTCHN_FIFO stub leaves d->evtchn_port_ops unset. Gate the FIFO branch on IS_ENABLED(CONFIG_EVTCHN_FIFO) and add a dedicated evtchn_port_ops_none table for the remaining case. Stubs are shared where signatures permit: evtchn_none_noop covers both clear_pending and unmask; evtchn_none_false covers both is_pending and is_masked. evtchn_none_init() is called only from event_channel.c, so its declaration is kept there rather than in event_channel.h. - gate evtchn_fifo_init_ops() on !CONFIG_HAS_SHARED_INFO; its only call site is in the IS_ENABLED(CONFIG_EVTCHN_FIFO) dead branch of evtchn_init(), which is never reached on HAS_SHARED_INFO=3Dy builds. --- Changes in v4: - event_channel.c: drop the redundant evtchn_fifo_init_ops() in the else branch of evtchn_reset(); evtchn_fifo_destroy() does not undo the ops installed by evtchn_init(), so only the switch back to 2-level ABI needs an explicit call. - shared.h: simplify the !HAS_SHARED_INFO shared_info() definition to use an undefined "extern struct shared_info *shared_info_absent" instead of shared_info_absent() with a typeof cast. - Extend the commit description to note that vcpu_info()/__vcpu_info() uses were also audited: on !HAS_SHARED_INFO vcpu_info_area.map points at dummy_vcpu_info, reads are harmless, and writes in common code do not open a cross-domain info-leak side channel, so no code changes are needed on that path. --- Changes in v3: - Introduce CONFIG_HAS_SHARED_INFO Kconfig symbol selected by x86 and Arm; RISC-V does not select it. - Gate shared_info() macro on CONFIG_HAS_SHARED_INFO; on !HAS_SHARED_INFO it calls shared_info_absent() (declared, never defined) so any unguarded use produces a link-time error. - Replace runtime if (!d->shared_info) guards with IS_ENABLED() at call sites so both branches type-check and dead code is eliminated. - Guard shared_info_frame assignment in domctl.c. - Gate event_2l.o on CONFIG_HAS_SHARED_INFO; use FIFO ops as placeholder on !HAS_SHARED_INFO archs instead of dedicated stub ops; guard evtchn_fifo_word_from_port() against uninitialised d->evtchn_fifo. - Add static inline stubs for evtchn_2l_init() (!HAS_SHARED_INFO) and evtchn_fifo_init_ops() (!EVTCHN_FIFO) so call sites can use IS_ENABLED() without #ifdef. - Drop inaccurate changelog entry about "only FIFO ABI" migration. - Update the commit message. - Drop R-by: Baptiste ... as some extra checks are added. --- Changes in v2: - Update commit message + subject. - Drop Fixes tag. --- xen/arch/arm/Kconfig | 1 + xen/arch/x86/Kconfig | 1 + xen/common/Kconfig | 3 +++ xen/common/Makefile | 2 +- xen/common/domain.c | 6 ++--- xen/common/domctl.c | 4 +++ xen/common/event_channel.c | 55 +++++++++++++++++++++++++++++++++++--- xen/common/event_channel.h | 6 +++++ xen/common/event_fifo.c | 18 ++++++++++++- xen/common/time.c | 2 ++ xen/include/xen/event.h | 2 +- xen/include/xen/sched.h | 2 ++ xen/include/xen/shared.h | 6 +++++ xen/include/xen/time.h | 5 ++++ 14 files changed, 104 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 843a43897e7b..d748404e82da 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -20,6 +20,7 @@ config ARM select HAS_DEVICE_TREE_DISCOVERY select HAS_DOM0LESS select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE + select HAS_SHARED_INFO select HAS_STACK_PROTECTOR select HAS_STATIC_MEMORY select HAS_UBSAN diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 3ce0774b8d76..e5535ac48467 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -29,6 +29,7 @@ config X86 select HAS_PCI_MSI select HAS_PIRQ select HAS_SCHED_GRANULARITY + select HAS_SHARED_INFO imply HAS_SOFT_RESET select HAS_UBSAN select HAS_VMAP diff --git a/xen/common/Kconfig b/xen/common/Kconfig index da80fdba8469..5b289e444fa5 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -158,6 +158,9 @@ config HAS_PMAP config HAS_SCHED_GRANULARITY bool =20 +config HAS_SHARED_INFO + bool + config HAS_STATIC_MEMORY bool =20 diff --git a/xen/common/Makefile b/xen/common/Makefile index 6018e256147f..f69d47d18934 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -12,7 +12,7 @@ obj-$(CONFIG_DEVICE_TREE_PARSE) +=3D device-tree/ obj-$(CONFIG_IOREQ_SERVER) +=3D dm.o obj-y +=3D domain.o obj-y +=3D domid.o -obj-y +=3D event_2l.o +obj-$(CONFIG_HAS_SHARED_INFO) +=3D event_2l.o obj-y +=3D event_channel.o obj-$(CONFIG_EVTCHN_FIFO) +=3D event_fifo.o obj-$(CONFIG_GRANT_TABLE) +=3D grant_table.o diff --git a/xen/common/domain.c b/xen/common/domain.c index e16f1ac38396..6b52713518da 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -316,9 +316,9 @@ void vcpu_info_reset(struct vcpu *v) struct domain *d =3D v->domain; =20 v->vcpu_info_area.map =3D - ((v->vcpu_id < XEN_LEGACY_MAX_VCPUS) - ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id]) - : &dummy_vcpu_info); + IS_ENABLED(CONFIG_HAS_SHARED_INFO) && v->vcpu_id < XEN_LEGACY_MAX_= VCPUS + ? (vcpu_info_t *)&shared_info(d, vcpu_info[v->vcpu_id]) + : &dummy_vcpu_info; } =20 static struct domain *alloc_domain_struct(void) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index a6210db4fb97..83405a766a54 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -102,9 +102,13 @@ void getdomaininfo(struct domain *d, struct xen_domctl= _getdomaininfo *info) #ifdef CONFIG_MEM_PAGING info->paged_pages =3D atomic_read(&d->paged_pages); #endif +#ifdef CONFIG_HAS_SHARED_INFO info->shared_info_frame =3D gfn_x(mfn_to_gfn(d, _mfn(virt_to_mfn(d->shared_info)))); BUG_ON(SHARED_M2P(info->shared_info_frame)); +#else + info->shared_info_frame =3D ~0; +#endif =20 info->cpupool =3D cpupool_get_id(d); =20 diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index a7f9cc5fe0ac..bd03e094d096 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -40,6 +40,54 @@ =20 #define consumer_is_xen(e) (!!(e)->xen_consumer) =20 +#if !defined(CONFIG_HAS_SHARED_INFO) && !defined(CONFIG_EVTCHN_FIFO) +/* + * Placeholder ops for domains with neither a shared_info page nor a FIFO + * control block. Such a domain has no ABI to record event state in, so th= ese + * are reachable whenever an event is delivered to (or queried on) one of = its + * ports; they just discard/no-op it. They exist to keep d->evtchn_port_ops + * non-NULL. + */ +static void cf_check evtchn_none_set_pending( + struct vcpu *v, struct evtchn *evtchn) {} +static void cf_check evtchn_none_noop( + struct domain *d, struct evtchn *evtchn) {} +static bool cf_check evtchn_none_false( + const struct domain *d, const struct evtchn *evtchn) { return false; } +static void cf_check evtchn_none_print_state( + struct domain *d, const struct evtchn *evtchn) {} + +static const struct evtchn_port_ops evtchn_port_ops_none =3D { + .set_pending =3D evtchn_none_set_pending, + .clear_pending =3D evtchn_none_noop, + .unmask =3D evtchn_none_noop, + .is_pending =3D evtchn_none_false, + .is_masked =3D evtchn_none_false, + .print_state =3D evtchn_none_print_state, +}; + +static void evtchn_none_init(struct domain *d) +{ + d->evtchn_port_ops =3D &evtchn_port_ops_none; +} +#else /* CONFIG_HAS_SHARED_INFO || CONFIG_EVTCHN_FIFO */ +/* + * Declaration only; the call in evtchn_preinit() is DCE'd unless both + * configs are off. + */ +void evtchn_none_init(struct domain *d); +#endif /* !CONFIG_HAS_SHARED_INFO && !CONFIG_EVTCHN_FIFO */ + +static void evtchn_preinit(struct domain *d) +{ + if ( IS_ENABLED(CONFIG_HAS_SHARED_INFO) ) + evtchn_2l_init(d); + else if ( IS_ENABLED(CONFIG_EVTCHN_FIFO) ) + evtchn_fifo_init_ops(d); + else + evtchn_none_init(d); +} + /* * Lock an event channel exclusively. This is allowed only when the channe= l is * free or unbound either when taking or when releasing the lock, as any @@ -1324,9 +1372,9 @@ int evtchn_reset(struct domain *d, bool resuming) rc =3D -EAGAIN; else if ( d->evtchn_fifo ) { - /* Switching back to 2-level ABI. */ + /* Switching back to the default ABI. */ evtchn_fifo_destroy(d); - evtchn_2l_init(d); + evtchn_preinit(d); } =20 write_unlock(&d->event_lock); @@ -1625,7 +1673,8 @@ void evtchn_check_pollers(struct domain *d, unsigned = int port) =20 int evtchn_init(struct domain *d, unsigned int max_port) { - evtchn_2l_init(d); + evtchn_preinit(d); + d->max_evtchn_port =3D min_t(unsigned int, max_port, INT_MAX); =20 d->evtchn =3D alloc_evtchn_bucket(d, 0); diff --git a/xen/common/event_channel.h b/xen/common/event_channel.h index dc94a43cc2dd..423c4ee77bd0 100644 --- a/xen/common/event_channel.h +++ b/xen/common/event_channel.h @@ -70,6 +70,12 @@ static inline void evtchn_fifo_destroy(struct domain *d) } #endif /* CONFIG_EVTCHN_FIFO */ =20 +/* + * Declaration only when !CONFIG_EVTCHN_FIFO; the call in evtchn_preinit()= is + * DCE'd in that case. + */ +void evtchn_fifo_init_ops(struct domain *d); + #endif /* EVENT_CHANNEL_H */ =20 /* diff --git a/xen/common/event_fifo.c b/xen/common/event_fifo.c index 611bf8a78801..e4225b1b668e 100644 --- a/xen/common/event_fifo.c +++ b/xen/common/event_fifo.c @@ -62,6 +62,9 @@ static inline event_word_t *evtchn_fifo_word_from_port(co= nst struct domain *d, */ smp_rmb(); =20 + if ( unlikely(!d->evtchn_fifo) ) + return NULL; + if ( unlikely(port >=3D d->evtchn_fifo->num_evtchns) ) return NULL; =20 @@ -419,6 +422,18 @@ static const struct evtchn_port_ops evtchn_port_ops_fi= fo =3D .print_state =3D evtchn_fifo_print_state, }; =20 +/* + * evtchn_fifo_init_ops()'s only call site is the + * IS_ENABLED(CONFIG_EVTCHN_FIFO) branch of evtchn_preinit(), which is nev= er + * reached on HAS_SHARED_INFO=3Dy builds because of DCE. + */ +#ifndef CONFIG_HAS_SHARED_INFO +void evtchn_fifo_init_ops(struct domain *d) +{ + d->evtchn_port_ops =3D &evtchn_port_ops_fifo; +} +#endif + static int map_guest_page(struct domain *d, uint64_t gfn, void **virt) { struct page_info *p; @@ -561,7 +576,8 @@ static void setup_ports(struct domain *d, unsigned int = prev_evtchns) =20 evtchn =3D evtchn_from_port(d, port); =20 - if ( guest_test_bit(d, port, &shared_info(d, evtchn_pending)) ) + if ( IS_ENABLED(CONFIG_HAS_SHARED_INFO) && + guest_test_bit(d, port, &shared_info(d, evtchn_pending)) ) evtchn->pending =3D true; =20 evtchn_fifo_set_priority(d, evtchn, EVTCHN_FIFO_PRIORITY_DEFAULT); diff --git a/xen/common/time.c b/xen/common/time.c index 0ddf65448d22..58d2b54a291b 100644 --- a/xen/common/time.c +++ b/xen/common/time.c @@ -98,6 +98,7 @@ struct tm gmtime(unsigned long t) return tbuf; } =20 +#ifdef CONFIG_HAS_SHARED_INFO void update_domain_wallclock_time(struct domain *d) { uint32_t *wc_version; @@ -126,6 +127,7 @@ void update_domain_wallclock_time(struct domain *d) =20 spin_unlock(&wc_lock); } +#endif /* CONFIG_HAS_SHARED_INFO */ =20 /* Set clock to after 00:00:00 UTC, 1 January, 1970. */ void do_settime(u64 secs, unsigned int nsecs, u64 system_time_base) diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 930190054cf0..595dedf0792c 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -211,7 +211,7 @@ static bool evtchn_usable(const struct evtchn *evtchn) =20 void evtchn_check_pollers(struct domain *d, unsigned int port); =20 -/* Close all event channels and reset to 2-level ABI. */ +/* Close all event channels and reset to the default ABI. */ int evtchn_reset(struct domain *d, bool resuming); =20 /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index e352e2b38e7d..73c54794ac02 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -404,7 +404,9 @@ struct domain =20 struct vcpu **vcpu; =20 +#ifdef CONFIG_HAS_SHARED_INFO shared_info_t *shared_info; /* shared data area */ +#endif =20 rcu_read_lock_t rcu_lock; =20 diff --git a/xen/include/xen/shared.h b/xen/include/xen/shared.h index 5b71342cab32..1589e8793f9d 100644 --- a/xen/include/xen/shared.h +++ b/xen/include/xen/shared.h @@ -43,7 +43,13 @@ typedef struct vcpu_info vcpu_info_t; =20 extern vcpu_info_t dummy_vcpu_info; =20 +#ifdef CONFIG_HAS_SHARED_INFO #define shared_info(d, field) __shared_info(d, (d)->shared_info, fiel= d) +#else +extern struct shared_info *shared_info_absent; +#define shared_info(d, field) (((void)(d), shared_info_absent)->field) +#endif /* CONFIG_HAS_SHARED_INFO */ + #define vcpu_info(v, field) \ __vcpu_info(v, (vcpu_info_t *)(v)->vcpu_info_area.map, field) =20 diff --git a/xen/include/xen/time.h b/xen/include/xen/time.h index 4db24617a97c..09da150c2a40 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -72,7 +72,12 @@ extern bool NOW_good; #define version_update_begin(v) (((v) + 1) | 1) #define version_update_end(v) ((v) + 1) extern void update_vcpu_system_time(struct vcpu *v); + +#ifdef CONFIG_HAS_SHARED_INFO extern void update_domain_wallclock_time(struct domain *d); +#else +static inline void update_domain_wallclock_time(struct domain *d) {} +#endif =20 extern void do_settime( u64 secs, unsigned int nsecs, u64 system_time_base); --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966532; cv=none; d=zohomail.com; s=zohoarc; b=LqD3+jvHWrAiHoYBjqc5j28o66qJeaSclxyU7ScPJv/aDJDu6SdI+5vPnNcpAkJVzE6C78gl2tfe6Jc0O91CMn7cVKJl16ftWmSZubB92ts5o2/AWDAvUiWvf/WlJQHwJPmjhNkuR89jXKjYG4IMrkHE81sXr94vLRkQ8XuJ2AE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966532; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SGIWlTbDaP0A9QeYN/SYThh0YL+nKcmDxCzTgmCJBSs=; b=CCmmFoxybMTZ1LHs8f2qXeTVjIvv26Wwa0jqAVh5Kr6cF5NU8RtAvoQkgNSbDUTLEl9EZ4EIaPGX1vy1PdsIK2tmqnyR9pt+X8UDFKGwMzKiO4GRO6oYuZB9ZSJfGAfadmYZ3ypvdGtNovM4il5Qo3w0UeguwhtjsqMBsuTwFxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966532542511.30829214006826; Wed, 9 Sep 2026 08:08:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413249.1643482 (Exim 4.92) (envelope-from ) id 1x4JuH-0000pp-Tm; Wed, 09 Sep 2026 15:08:13 +0000 Received: by outflank-mailman (output) from mailman id 1413249.1643482; Wed, 09 Sep 2026 15:08:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuH-0000pg-QR; Wed, 09 Sep 2026 15:08:13 +0000 Received: by outflank-mailman (input) for mailman id 1413249; Wed, 09 Sep 2026 15:08:12 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuG-0000p1-Oo for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuG-00Cu0U-5R for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:12 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17648-e002-0a2a0a5209dd-0a2a450ad012-42 for ; Wed, 09 Sep 2026 17:08:12 +0200 Received: from [209.85.218.42] (helo=mail-ej1-f42.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa1765c-f2d2-0a2a450a0019-d155da2ad51d-3 for ; Wed, 09 Sep 2026 17:08:12 +0200 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-c2938116fefso119849366b.1 for ; Wed, 09 Sep 2026 08:08:12 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:10 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966492; x=1789571292; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SGIWlTbDaP0A9QeYN/SYThh0YL+nKcmDxCzTgmCJBSs=; b=Vcy9qTzC5oyzOybAnphld3Lmoj0cnx8KFsgD5lvb/mRMRzB0z6mJCpJhxoS8EWtjl9 4mcFF77O+crTHEDO2lTZ0a0FoBSJDU8svU7G/ypCq+wQfuuZZpA1YfevjLVhJyJ8682s XRllNBpLrNwT/UzsckzmHpQidXqL94YM0PU/38KCmq2J+DLHcjj/6SMpAA09v/AOGlb5 efZxt0JVXs4WKAsOXlMbzXqf+zrzJCFnBvtPybO7toVQ029Sa3aK3c2FTG1IgN8xwImD IjJa/VYU9mlNKC9EYRN4QzF8Mv0Ky2Nw6oKQ/RGo6Y8mkswEnvkqyH5F5wJW4teFTyjE 4oMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966492; x=1789571292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SGIWlTbDaP0A9QeYN/SYThh0YL+nKcmDxCzTgmCJBSs=; b=USoYzmgAYOKNoA6HM4Tw/FsYxzlnXgZtWYCyabBvX5VxW8kCWa9fQm0XlJOlVt1L8q 0oxNYaOcprID5O6Of3lX9mp3pTZTpieXOy/i8TWMTd2qLc5vTfkywgRSoj4Tu8Sm6zYx f7lD+aqJqUHyHoK1iHubOXgFw+byvmrGbCgyDOapgXH7hrzAirifqXEgbyuQN1TIvbVW YbeMxkqDwbYCmxUeGAbHHZkIzlo2VHm9Yn4ovvrZ6zf//vBsF2AigPlN34gWjEQTC2yF hbIgfg8OyITWuN+JS3wCfyzM71BcsTcik+UHOEwZqrwiN77Z/3E3aSfu1/BagBN8DiQe NGbQ== X-Gm-Message-State: AFuF++m6OCp+o5UDFOjsmA73Ye/1qB3WN51B6piBqZS+AHuoyKkL/vdg NR5YVk2INqToACt/S5BWIcbL7pgdF4w65w0OCSGbbhuVnOhi+Sf7PW0GdHJ6QgH9 X-Gm-Gg: AYBFou3bHmF/MWzVIzVxGZ43UsR5mmG9xgGO1aAW6DTJeFJ+QWi3MGAIujm2kw17cmv 4F1jN69O1sSjfSmB5X0fSsNUks5cAVbM9RuPBR33LOqU7LJYBsBvmvSTWxVskhotnhFAq90xoRz t+9cxK1HJXjgfv1G7u5taqVSX7naArWDurHhcdsxy9qS4uq1kIhdnGf9yblayqWiNDsdsy1nPoT MRoglJIR5hKC8lSBmr/fwSK0X4tb/w9KUY1T20Sck6YJZN1a9icveLM6R0s2A67SdpLIul6i+8x sXAi4sUhmp386Q+TeoYDXSf5OZ/KN+lnHiaKqMze35nDqfKOsbREGlmhx3Dw/+PwABG1i2Wygry H+9tLVZQPbBkiDzEs1MQ9ZEWLVpYp5zfiIL6RlVqjZuuKQWP6tPECzUF7ECpCOa/D3CZqioZn5I qoDbhsJzjydy0smIYAur3Mn9orrTK2UZjqK9/WlieN4iXeMYD2TKeVEncwE3EhU6j7dwQf7/fRo O0uiwtjOziBICfcpoQ= X-Received: by 2002:a17:907:805:b0:c29:3a1b:ec7a with SMTP id a640c23a62f3a-c293a1bf1bfmr147233566b.10.1788966491349; Wed, 09 Sep 2026 08:08:11 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie Subject: [PATCH v9 02/20] xen/dom0less: turn max_init_domid into a common variable Date: Wed, 9 Sep 2026 17:07:20 +0200 Message-ID: <4d2919b7b191d6fa91c11043e7f08de228012852.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1788966492-59BC0CFC-D7DEA16E/10/73395122804 X-purgate-type: spam X-purgate-size: 6771 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966533214158500 Content-Type: text/plain; charset="utf-8" Until now every architecture carried its own notion of max_init_domid: Arm defined a real variable (declared in asm/setup.h, defined in setup.c), while ppc, riscv and x86 each provided a "#define max_init_domid (0)" stub in their asm/setup.h. This duplicated the same declaration across all arches and placed a purely dom0less concept in arch setup headers. Now that the dom0less build code lives in common (xen/common/ device-tree/dom0less-build.c sets max_init_domid, and the console serial-input switcher reads it), there is no reason for the symbol to be per-arch. Provide a single declaration in , with the !CONFIG_DOM0LESS_BOOT stub kept there as well, so there is one source of truth and the arch headers no longer need to mention it. Update console.c to include for the declaration instead of relying on asm/setup.h, and drop the now unneeded include. Place the definition in xen/common/domid.c rather than in dom0less- build.c. The latter is built as dom0less-build.init.o, i.e. the whole object is relocated into the .init.* sections and freed after boot, whereas max_init_domid must outlive boot because it is read at runtime by the console serial-input switcher. domid.c is always linked (obj-y) and resides in regular (non-init) sections, so it is a correct home for the variable. It is marked __ro_after_init since it is only updated while creating boot-time domains and read-only afterwards, and guarded by CONFIG_DOM0LESS_BOOT as domid.c itself is unconditional. While at it, make self-contained: it includes , which uses the fixed-width types provided by , so include the latter explicitly rather than relying on the includer having pulled it in first. This becomes necessary as soon as comes first in an alphabetically sorted include list, as it now does in domid.c. Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich Reviewed-by: Michal Orzel --- Changes in v9: - Sort the includes in domid.c alphabetically ("dom0less" before "domain") and add to , which the re-ordering requires. - Drop the leftover include from console.c as nothing from it depends in console.c anymore. - Add Reviewed-by: Michal Orzel . --- Changes in v6-8: - Nothing changed. Only rebase. --- Changes in v5: - Add Reviewed-by: Jan Beulich --- Changes in v4: - New patch. --- --- xen/arch/arm/include/asm/setup.h | 2 -- xen/arch/arm/setup.c | 2 -- xen/arch/ppc/include/asm/setup.h | 2 -- xen/arch/riscv/include/asm/setup.h | 2 -- xen/arch/x86/include/asm/setup.h | 2 -- xen/common/domid.c | 5 +++++ xen/drivers/char/console.c | 2 +- xen/include/xen/dom0less-build.h | 8 ++++++++ 8 files changed, 14 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 0adfa4993a8f..2af780512540 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -25,8 +25,6 @@ struct map_range_data struct rangeset *irq_ranges; }; =20 -extern domid_t max_init_domid; - void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); =20 size_t estimate_efi_size(unsigned int mem_nr_banks); diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 6310a47d68b6..86532d0a35b6 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -62,8 +62,6 @@ struct cpuinfo_arm __read_mostly system_cpuinfo; bool __read_mostly acpi_disabled; #endif =20 -domid_t __read_mostly max_init_domid; - static __used void noreturn init_done(void) { /* Must be done past setting system_state. */ diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/se= tup.h index e4f64879b68c..956fa6985adb 100644 --- a/xen/arch/ppc/include/asm/setup.h +++ b/xen/arch/ppc/include/asm/setup.h @@ -1,6 +1,4 @@ #ifndef __ASM_PPC_SETUP_H__ #define __ASM_PPC_SETUP_H__ =20 -#define max_init_domid (0) - #endif /* __ASM_PPC_SETUP_H__ */ diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/as= m/setup.h index 2215894cfbb1..73ce2f293348 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -5,8 +5,6 @@ =20 #include =20 -#define max_init_domid (0) - void setup_mm(void); =20 void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/se= tup.h index b01e83a8ed9f..5925c5f39cff 100644 --- a/xen/arch/x86/include/asm/setup.h +++ b/xen/arch/x86/include/asm/setup.h @@ -68,6 +68,4 @@ extern bool opt_dom0_verbose; extern bool opt_dom0_cpuid_faulting; extern bool opt_dom0_msr_relaxed; =20 -#define max_init_domid (0) - #endif diff --git a/xen/common/domid.c b/xen/common/domid.c index b0258e477c1a..c0cb025609b8 100644 --- a/xen/common/domid.c +++ b/xen/common/domid.c @@ -8,8 +8,13 @@ * Copyright 2025 Ford Motor Company */ =20 +#include #include =20 +#ifdef CONFIG_DOM0LESS_BOOT +domid_t __ro_after_init max_init_domid; +#endif + static DEFINE_SPINLOCK(domid_lock); static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED); =20 diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index fcacf37c52f0..e4df0bbc2eec 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include =20 diff --git a/xen/include/xen/dom0less-build.h b/xen/include/xen/dom0less-bu= ild.h index 4118dec76c0a..75bfaa185fa6 100644 --- a/xen/include/xen/dom0less-build.h +++ b/xen/include/xen/dom0less-build.h @@ -4,6 +4,9 @@ #define XEN_DOM0LESS_BUILD_H =20 #include +#include + +#include =20 struct domain; =20 @@ -13,6 +16,9 @@ struct boot_domain; struct dt_device_node; struct kernel_info; =20 +/* Highest domain ID assigned to a boot-time (dom0less) domain. */ +extern domid_t max_init_domid; + /* * List of possible features for dom0less domUs * @@ -72,6 +78,8 @@ static inline bool is_dom0less_mode(void) } static inline void set_xs_domain(struct domain *d) {} =20 +#define max_init_domid 0 + #endif /* CONFIG_DOM0LESS_BOOT */ =20 #endif /* __ASM_GENERIC_DOM0LESS_BUILD_H__ */ --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966527; cv=none; d=zohomail.com; s=zohoarc; b=aKwX1Eg5b72+dAFDywXEm+VZ5o9lVe2VKgoYmoYWKrIL/FHtVWAmsQpgjPJtNIcDlnqpH8pyM34eOUst3HyAUFiC0j3JjtaO/l527GQqk+JcmOrARJ3ufLQqkXa+Bm8whEDhD2FEqNEw3Y3Hywy2kfKlEfUFUDvZ0yAP20/ua38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966527; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r1oo8fqOn/g4Do2VHXYk4O/g0/dgS+YsUhtfJgbBmh8=; b=R+6avureAZA272jRdbnT8LczLwi5BwAhK/UEqES95WIczuYqrS3KfyXsFaSdOKZAhf4CG++By1HmaQAtRKKpz9FUBFcGoXrwT+52gZikhlIz9E6tAZN3P31xtrHzE28gQdMZdKKapFfpTSkZDXkGkRxbt6k7v28qkdpy3o5wr+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 178896652749667.14217080684682; Wed, 9 Sep 2026 08:08:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413250.1643490 (Exim 4.92) (envelope-from ) id 1x4JuK-00013Z-43; Wed, 09 Sep 2026 15:08:16 +0000 Received: by outflank-mailman (output) from mailman id 1413250.1643490; Wed, 09 Sep 2026 15:08:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuK-00013Q-17; Wed, 09 Sep 2026 15:08:16 +0000 Received: by outflank-mailman (input) for mailman id 1413250; Wed, 09 Sep 2026 15:08:15 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuJ-0000xL-0L for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:15 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuH-002k9M-Vc for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:13 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa1765c-8faa-0a2a0a5109dd-0a2a4508a5c0-8 for ; Wed, 09 Sep 2026 17:08:13 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa1765d-f659-0a2a45080019-4a7de48ca10e-3 for ; Wed, 09 Sep 2026 17:08:13 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c254f8694aeso186304066b.0 for ; Wed, 09 Sep 2026 08:08:13 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:13 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966493; x=1789571293; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=r1oo8fqOn/g4Do2VHXYk4O/g0/dgS+YsUhtfJgbBmh8=; b=J7PuxVxCvCFogSroI+hEUxacjogC3onZyTiqd7EJi6IqSq0bDSdCNLtC3xspKlGH2i Il16esjFMbRE14XVtwnMXV2kPna9t9FIcOxH69HhXzsIHl3xi9EHoJfWTkpczIsL+cS2 k8kISxcHN5xzEU0ETur6uE7rbNVX1fl/2U3OI6k/JP594Qleo2+Eb04KPK8RD6OIiI40 OCJ/KTIO2EllaOIGmmcNq/glNLtaZtcG29r3IH4Gh+i4PcZnRiEg4NrI4O4XZz5YT5vo jYxl4nlQTGbqE6jm7v4KqK8aBr/+gyTGyVv6tqhBHbqfH/z4aiDT56QOqIUmCa6enC1N h7gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966493; x=1789571293; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=r1oo8fqOn/g4Do2VHXYk4O/g0/dgS+YsUhtfJgbBmh8=; b=SBwD9wSDLzfyP0HyjBD/dBAncW0PC/vo6gghGSIakA5sW6FvgAeYdGLhIvmdJg/bjK +oJCRlSS/ER+DsVvWNi4YH7nA8WAjNmn5qUjAX6Q347WZneWa7ASSeZNXX5kPRE2Io2s 34mOqFVltIHRFTeEAC/5oaAnf7NNb59u61s6RC96p9G9LlMNgKbS8JQsd/LWHoTXTWQr abYTT7phfMPwYWjczExVSOjy/49E4klpFfcl7p++U2g2hD9g+y2p1fXowY0bgUFG5BPp ZYWHFMUo47+ZZ05ugGrH987hCFDEY2Ff59Dy/uP69PFzeHSuHg//oS4dZVWNKMDzG3yE M0WQ== X-Gm-Message-State: AFuF++k2K4LNmRNswB8GyhgDUI2+yOzOAZLVfhqWAtaY0wKIhdXZrP8e cqhqWT9r17V/QsW6wciIFhi7DfPFp4Gj2irlZCAm17ylpdyIHTANyh0ukyiZcmoP X-Gm-Gg: AYBFou1qnlT+Z+Str+OhZXVBJMN0cePynA+jb060rmvgDKH3YYTX74Qm1ZWiJ4YHzDq I2Doomp5aIAbWfAX3htwmMcrkfVb/OOTQx1dt4EIY4+KiglKGqnIFjFubaF4wx6Q/ktqn4PJmI3 tPg9ImUKEkxdjj0Lvwqkk/quN3DiK1Tl1/OyLR+kvgVeg6mYVX3+eFw6n3ZHrYhLwL8D1Fs/22U oDAb1TTbQpGtpKVf7pF40MeX0pdGLvXbpCXN33tU0yXsABR6W7y0as2HRTcXIwK+2Ii76Vgtiy1 PLHkoOVNsiJfFvWdrW0fhE13j+Y/5i+gT6+x2TqrUz5I9XnTijoPh5frMhK0l8kiyhxw0DjZ0tH Hx/vXnFSmaNIdsADenWF91m883pNWeYvJLxd72yI64C5OUc6F5peZpNBTAZWYQs8ZdtIAl9RXL1 YNjDG8souJexD4NUM3laqBU1BZw6FblR7AsTBOysXWzSRroSEXSydVEIflstp8MHGqvKxDKfj9X G+yEHGx8YIMAOQNgD+ovTIE+kjZSA== X-Received: by 2002:a17:907:3e0c:b0:c25:f7db:4bef with SMTP id a640c23a62f3a-c2904519fdamr700357866b.21.1788966493404; Wed, 09 Sep 2026 08:08:13 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 03/20] xen/riscv: Implement construct_domain() Date: Wed, 9 Sep 2026 17:07:21 +0200 Message-ID: <5e84ec86b5144a7387638fea98548a83db2ee03f.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1788966493-D5F4787B-83A6C472/10/73395122804 X-purgate-type: spam X-purgate-size: 3117 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966529269158500 Content-Type: text/plain; charset="utf-8" Implement construct_domain() function for RISC-V, which performs initial se= tup for the domain's first vCPU, loads the kernel, initrd, and device tree, and sets up guest CPU registers for boot. It also creates additional vCPUs up to max_vcpus and assigns the device tree address and boot cpuid in registers. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5-v9: - Only rebase. Nothing changed. --- Changes in v4: - Drop the blank before v%u in the printk() failure message so the output matches that of %pv. - Restore Acked-by that was lost in v3. --- Changes in v3: - s/%d/%u for printing vCPU index in the failure message. - Drop dprintk() for successful vCPU creation. --- Changes in v2: - Rework construct_domain() to print that vCPU1...n are created using %pv. - Use true instead of 1 for initialization of v->is_initialised. - Drop unnessary BUG_ON() in construct_domain(). - Add TODO comment above *_load() functions. --- --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/domain-build.c | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 xen/arch/riscv/domain-build.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 4fcdcf9e24de..2d24670dfc74 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,6 +1,7 @@ obj-y +=3D aplic.o obj-y +=3D cpufeature.o obj-y +=3D domain.o +obj-y +=3D domain-build.init.o obj-$(CONFIG_DOM0LESS_BOOT) +=3D dom0less-build.init.o obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-y +=3D entry.o diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c new file mode 100644 index 000000000000..5f6f4b6248a5 --- /dev/null +++ b/xen/arch/riscv/domain-build.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +#include +#include + +int __init construct_domain(struct domain *d, struct kernel_info *kinfo) +{ + struct vcpu *v =3D d->vcpu[0]; + struct cpu_user_regs *regs =3D vcpu_guest_cpu_user_regs(v); + + BUG_ON(v->is_initialised); + + /* + * At the moment *_load() don't return value and will just panic() + * inside. + * TODO: it will be good to change that. + */ + kernel_load(kinfo); + initrd_load(kinfo, copy_to_guest_phys); + dtb_load(kinfo, copy_to_guest_phys); + + regs->sepc =3D kinfo->entry; + + /* Guest boot cpuid =3D 0 */ + regs->a0 =3D 0; + regs->a1 =3D kinfo->dtb_paddr; + + for ( unsigned int i =3D 1; i < d->max_vcpus; i++ ) + { + const struct vcpu *tmp_v =3D vcpu_create(d, i); + + if ( !tmp_v ) + { + printk("Failed to allocate %pdv%u\n", d, i); + break; + } + } + + domain_update_node_affinity(d); + + v->is_initialised =3D true; + clear_bit(_VPF_down, &v->pause_flags); + + return 0; +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966540; cv=none; d=zohomail.com; s=zohoarc; b=l84YoPYOeSBiJRXBWidGwkjy0OX1ICgCHU3HbDZUR2z8RA2BXh0TLxPU/IFZ7d0jWDngpfPAqmEWcUaXrDli4gGTtmhlj9lXZy+dOVxUDjMeNNngYGf/Z3gcy8RvjD5laDjNz5bXQ7AcJGDavUQFLG8zx8M15znPaeraqSjmCzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966540; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x4D/wRNO94pIhJ33n24GH3v08GesvRDLwYVJ73G/CmU=; b=KxAPvG6O5wHEIkZzRjzMPw07V6+EIJqJe3QqmsWjC92cYisJiftJMCDWJdoSHYH23FAcVhrdyavxmcm9UesHqijcd5cycQS5n1xX86kTjALbziVL+p69TZUJjnfXXzLZ4Q706VKPrb2t0PXIuWylhpkS+cjP//0hqWfscI0qMlI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966540606906.1366744571728; Wed, 9 Sep 2026 08:09:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413251.1643500 (Exim 4.92) (envelope-from ) id 1x4JuM-0001Ja-D0; Wed, 09 Sep 2026 15:08:18 +0000 Received: by outflank-mailman (output) from mailman id 1413251.1643500; Wed, 09 Sep 2026 15:08:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuM-0001JP-8n; Wed, 09 Sep 2026 15:08:18 +0000 Received: by outflank-mailman (input) for mailman id 1413251; Wed, 09 Sep 2026 15:08:17 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuK-0001BI-QC for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:17 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuK-003DHh-74 for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:16 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17660-bab6-0a2a0a5309dd-0a2a450ad5b2-0 for ; Wed, 09 Sep 2026 17:08:16 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17660-f2d2-0a2a450a0019-4a7de48ca3e2-3 for ; Wed, 09 Sep 2026 17:08:16 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c254f9f0b20so195221966b.3 for ; Wed, 09 Sep 2026 08:08:16 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966495; x=1789571295; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=x4D/wRNO94pIhJ33n24GH3v08GesvRDLwYVJ73G/CmU=; b=TkJP8OLdsj1GdtulPzNPR2znLqbHJOpPwCF4aJyp84JZAv0LKq8V59kkoWyvb/pydU howajn9kXjrbWnTPBJdPFT4dYDcreV5qWCx08dYIR/IrloNvMib7eXSeiqd51aQ/MCXE k6jSFJJ7ZpGlgSdXB2Ds1r3UDBKKgXuSotM1OEaHEtiiiiY02GD4/XjUbvktMXzzQO0X cWC4qpzMgBlyiVV62rhE2l/ZCidHjtqadxYK+sJqj65B04UMhbO9adTvE3SHKxKOnwC8 jTkhMwB8Gk0R1Mo2p034782Uoz70SIhBDNdUwXbCw950QE59lpmmnKqLWHRYxM4YXBRv OziQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966495; x=1789571295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=x4D/wRNO94pIhJ33n24GH3v08GesvRDLwYVJ73G/CmU=; b=ine+KzdRFMa6bMJ6T17T6omgrnSV62AdNYN87e/n4u0XPokaLFm5z63KZODmbyeN3Q b1FatTnLy/N0TfesdyvORgXfW0XxSmbNRujZF2DlQCyIzevEh7nmaDWZSi7mszkZR6jA kjpJ2bSvp4gp4lqmPz0QPwcpAg86TNBhEXU8Rj8LqHvVK2CjRMhH/ALI0PFpYu8BO89B z6zcQJMe6fnS5H4Y3d5CzO61nuhNsZizpC6fmg98RCb/UGOHV4wFVH+GBsAIKvd9gcBP gtUoWaZ+GHz+GFp86mN+jinQfO9jFM2Y6a70Adtzdrk7k5Nc5/EtKNLTDzHNLwFx498W lWfw== X-Gm-Message-State: AFuF++l9fAer2RUjAiv/MKal/TC5pn6FvbQz8HOyD4zAO3Lwn4OxfzRL CXTJNUV/1HliMj1cpzQ8ScoMTfJhRCPAn/unqGSkg8tsqVmpUv5uh2an2r4aeLQv X-Gm-Gg: AYBFou36kd6NuKY8iv/7w0LODcJfW0dvWqbLmglshO5z4BnU8picy/V+64n1ZWMDbvu 3PQlyJtXektW4z87xM0UvKi34H3Dnt9d4zRwZtK1WVYTwyJV4x6NHXVLTaH1ZY3D/M4TtvpFc/E S+JskkPwdbssaxu9o31/AR8eN5TULkgErqlnHeTWTUtIm0KLlaTj4BLrdnUuQfqisoCmapmnavl ZD6UC8zOnyzWzs5xNZ+IwKWjQjM0ATEM0h7Bouins3I93PtGuwh0RXF07kp1rGDC1Upw0DI2r6V uUl05JZWvjFyU1lzPSLPDZbTi5m0XHtw2BxLDoXAEITmQKyhwMry1YmFgg1UeU3kjrN6dZVuN40 D/IlnBg9kipJ5Wv436dS4cFY9EylsyL97U/RCOjWlme2mYSJoIOYEE36YZNYWzMSWMCHofNrQ8Y fRTifmJst9BtBG1F9lDjRwPFQWecuwlFxcWkDUMq1n/cUO9KXjj3kTAExxCH7HTVTk7Kc0sX9fb f0MYdXehhxWcX1kSbnM2/XC1Hw37Q== X-Received: by 2002:a17:906:794b:b0:c25:938a:754c with SMTP id a640c23a62f3a-c292b1ac282mr583108366b.20.1788966495468; Wed, 09 Sep 2026 08:08:15 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 04/20] xen/riscv: introduce guest riscv,isa string Date: Wed, 9 Sep 2026 17:07:22 +0200 Message-ID: <6fc9e21cf24775a27ee38ddf62e643a4530a3fe0.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1788966496-524DFCFC-E752E469/10/73395122804 X-purgate-type: spam X-purgate-size: 16877 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966541350158500 Content-Type: text/plain; charset="utf-8" Introduce build_guest_isa_str() to generate the riscv,isa string to be passed to the guest via the Device Tree riscv,isa property. Introduce the per-domain guest ISA bitmap, populated during domain creation by calling init_guest_isa(). Introduce struct riscv_isa_ext_entry with a new guest_flags field to filter out ISA extensions that should not be exposed to guests: - f/d/q/v: FPU and vector context save/restore are not yet implemented for guests. - Z*inx are not exposed either: they aren't in riscv_isa_ext[], so they can never be set in riscv_isa and thus never reach a guest, and no current hardware/guest-OS advertises or expects them. Supporting them would be cheaper than F/D/Q (FP values stay in integer registers Xen already context-switches), but is left as future work. - h: Nested virtualisation is not supported. - sstc: Xen owns the supervisor timer; guests must use SBI. - svade: Xen manages hardware A/D bit updates in stage-2 page tables. - svpbmt: Page-based memory types are not yet wired up in stage-2 code. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v9: - Add string concatanation for initialization of .guest_flags in RISCV_ISA_EXT_ENTRY(). Also drop RISCV_ISA_EXT_GUEST_ prefix in riscv_isa_ext[] as it is covered by concatanation. - s/guest_flgs/guest. - Add Acked-by: Jan Beulich . --- Changes in v8: - Replace struct riscv_isa_ext_entry's bool guest_supported with an unsigned int guest_flags bitmask (RISCV_ISA_EXT_GUEST_{NONE,RV32,RV64,ANY= }), so an extension can be withheld from guests of one XLEN only; select the bit matching the guest's width with RISCV_ISA_EXT_GUEST_XLEN in compute_guest_isa(). Guests are currently of the same width as Xen, so RISCV_ISA_EXT_GUEST_XLEN is derived from CONFIG_RISCV_{32,64} for now. - Add some spaces between # and "error" in build_guest_isa_str(). --- Changes in v7: - build_guest_isa_str(): drop the struct domain argument and work directly = on the guest_isa bitmap; make the function static as it has no external users anymore. - build the guest "riscv,isa" string only once, in compute_guest_isa(), and store it in an __ro_after_init pointer, instead of rebuilding it for every domain: all domains are currently given the same guest ISA, so apply here the same reasoning as for the guest_isa bitmap. - panic() on length calculation, allocation or formatting failure, in line with the rest of riscv_fill_hwcap() initialization. - introduce get_guest_isa_str() accessor and expose it in asm/cpufeature.h instead of build_guest_isa_str(). --- Changes in v6: - build_guest_isa_str() now takes a `const struct domain *d` instead of a raw `const unsigned long *isa_bitmap`, to leave room for using more than just the bitmap in the future. - Compute the guest-visible ISA bitmap once at boot, into a new __ro_after_init `guest_isa` bitmap (compute_guest_isa(), called at the end of riscv_fill_hwcap()), instead of re-deriving it from riscv_isa_ext[] on every domain creation in init_guest_isa(). All guests currently get the same extension set, so this avoids repeating identical work per domain; will need revisiting if/when per-domain ISA policy is introduced. - struct arch_domain's `isa` field is now `const unsigned long *isa` instead of an embedded bitmap; init_guest_isa() just points it at the shared `guest_isa` bitmap rather than copying bits into a per-domain array. - Mark riscv_isa_ext[] __initconstrel, since its entries hold name pointers and the need for relocations requires that the compiler emit the data to a writable section. - Make build_guest_isa_str() __init as it is called during make_cpus_node() which is used only (at least, for now) in build time of domain. --- Changes in v5: - Introduce struct riscv_isa_ext_entry with a guest_supported field and RISCV_ISA_EXT_ENTRY(name, guest_supp) macro for riscv_isa_ext[], replacing the ad-hoc guest_unsupp bitmap and init_guest_unsupp(). Every entry now carries an explicit true/false decision, enforced at compile time. - init_guest_isa() builds d->arch.isa by iterating riscv_isa_ext[] directly instead of using bitmap_andnot() against guest_unsupp. - init_guest_isa() changed to void as it can no longer fail. - Drop isa_str from struct arch_domain; the ISA string does not need to persist over the domain lifetime. build_guest_isa_str() is made non-static and declared in cpufeature.h for use when building the guest device tree. - Updated the fix of underflow in build_guest_isa_str(). - Drop unnecessary empty line in cpufeature.h before enum riscv_isa_ext_id. --- Changes in v4: - Add an explicit overflow guard in build_guest_isa_str(): return -ENOSPC when buf is non-NULL and total >=3D size, to avoid the size - total underflow being passed to snprintf(). - Expand the commit message to explain why Zfinx/Zdinx/Zqinx are not added to guest_unsupp (not in riscv_isa_ext[], so never set in riscv_isa nor exposed to a guest; left as future work) --- Changes in v3: - s/set_bit/__set_bit in init_guest_unsupp() as atomicity isn't needed at init time. - Drop RISCV_GUEST_ISA_STR_MAX; allocate isa_str dynamically with xvmalloc_array(). - Drop "guest" prefix from d->arch.guest_isa and d->arch.guest_isa_str. - Introduce build_guest_isa_str() using snprintf(NULL, 0, ...) to determine the needed buffer size; init_guest_isa() calls it once for sizing and on= ce to fill, keeping both in a single function so they can't go out of sync. - Scope ret inside the loop; initialize total directly from the prefix snprintf(). - Merge "_" separator and extension name into a single snprintf() with "%s%s". - Replace ASSERT with an explicit error check: if the fill call returns a different length, free isa_str and return -EINVAL. --- Changes in v2: - s/guest_unsupp_bmp/guest_unsupp. - Drop guest_isa_str. - Provide init_guest_isa() instead of polluting match_isa_ext(). - Drop xlen. - Add the comment about guest_unsupp. - Update the way how guest_unsupp is init-ed. - Drop __initconst for riscv_isa_ext[] as it is used in init_guest_isa() which isn't marked as __init as it could be used after init stage. --- --- xen/arch/riscv/cpufeature.c | 200 +++++++++++++++++++++--- xen/arch/riscv/domain.c | 2 + xen/arch/riscv/include/asm/cpufeature.h | 5 + xen/arch/riscv/include/asm/domain.h | 3 + 4 files changed, 186 insertions(+), 24 deletions(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..aaf544d13fea 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include =20 #include #include @@ -34,9 +36,64 @@ struct riscv_isa_ext_data { .name =3D #ext_name, \ } =20 +/* + * Which guests an extension may be handed out to, by guest XLEN. + * + * These flags express Xen's policy, not the ISA's rules: extensions which + * are architecturally tied to one XLEN (Zilsd on RV32, say) need no speci= al + * treatment here, as they can only ever appear in the "riscv,isa" of a ho= st + * of that XLEN, and guest_isa is masked against the host ISA bitmap anywa= y. + * They are only of use for extensions Xen chooses not to expose to guests= of + * a given width despite the hardware implementing them. + */ +#define RISCV_ISA_EXT_GUEST_NONE 0 +#define RISCV_ISA_EXT_GUEST_RV32 (1U << 0) +#define RISCV_ISA_EXT_GUEST_RV64 (1U << 1) +#define RISCV_ISA_EXT_GUEST_ANY (RISCV_ISA_EXT_GUEST_RV32 | \ + RISCV_ISA_EXT_GUEST_RV64) + +/* + * Guests are of the same width as Xen itself for the time being; once gue= st + * XLEN can differ from host XLEN (hstatus.VSXL), this becomes a per-domain + * property, just as guest_isa below does. + */ +#if defined(CONFIG_RISCV_32) +#define RISCV_ISA_EXT_GUEST_XLEN RISCV_ISA_EXT_GUEST_RV32 +#elif defined(CONFIG_RISCV_64) +#define RISCV_ISA_EXT_GUEST_XLEN RISCV_ISA_EXT_GUEST_RV64 +#else +# error "Unsupported RISC-V bitness" +#endif + +struct riscv_isa_ext_entry { + unsigned int id; + const char *name; + unsigned int guest_flags; +}; + +#define RISCV_ISA_EXT_ENTRY(ext_name, guest) \ +{ \ + .id =3D RISCV_ISA_EXT_ ## ext_name, \ + .name =3D #ext_name, \ + .guest_flags =3D RISCV_ISA_EXT_GUEST_ ## guest, \ +} + /* Host ISA bitmap */ static __ro_after_init DECLARE_BITMAP(riscv_isa, RISCV_ISA_EXT_MAX); =20 +/* + * ISA bitmap handed out to every guest. + * + * All guests are given the same extensions for the time being, so this is + * computed once out of riscv_isa_ext[] and riscv_isa, rather than redoing + * the walk for every domain created. Should per-domain ISA policy ever be + * introduced, this will need to become per-domain again. + */ +static __ro_after_init DECLARE_BITMAP(guest_isa, RISCV_ISA_EXT_MAX); + +/* "riscv,isa" string corresponding to guest_isa, shared by all domains. */ +static char *__ro_after_init guest_isa_str; + static int __init dt_get_cpuid_from_node(const struct dt_device_node *cpu, unsigned long *dt_cpuid) { @@ -120,29 +177,30 @@ static int __init dt_get_cpuid_from_node(const struct= dt_device_node *cpu, * and strncmp() is used in match_isa_ext() to compare extension names ins= tead * of strncasecmp(). */ -const struct riscv_isa_ext_data __initconst riscv_isa_ext[] =3D { - RISCV_ISA_EXT_DATA(i), - RISCV_ISA_EXT_DATA(m), - RISCV_ISA_EXT_DATA(a), - RISCV_ISA_EXT_DATA(f), - RISCV_ISA_EXT_DATA(d), - RISCV_ISA_EXT_DATA(q), - RISCV_ISA_EXT_DATA(c), - RISCV_ISA_EXT_DATA(h), - RISCV_ISA_EXT_DATA(zicntr), - RISCV_ISA_EXT_DATA(zicsr), - RISCV_ISA_EXT_DATA(zifencei), - RISCV_ISA_EXT_DATA(zihintpause), - RISCV_ISA_EXT_DATA(zihpm), - RISCV_ISA_EXT_DATA(zba), - RISCV_ISA_EXT_DATA(zbb), - RISCV_ISA_EXT_DATA(zbs), - RISCV_ISA_EXT_DATA(smaia), - RISCV_ISA_EXT_DATA(smstateen), - RISCV_ISA_EXT_DATA(ssaia), - RISCV_ISA_EXT_DATA(sstc), - RISCV_ISA_EXT_DATA(svade), - RISCV_ISA_EXT_DATA(svpbmt), +static const struct riscv_isa_ext_entry __initconstrel riscv_isa_ext[] =3D= { + RISCV_ISA_EXT_ENTRY(i, ANY), + RISCV_ISA_EXT_ENTRY(m, ANY), + RISCV_ISA_EXT_ENTRY(a, ANY), + RISCV_ISA_EXT_ENTRY(f, NONE), + RISCV_ISA_EXT_ENTRY(d, NONE), + RISCV_ISA_EXT_ENTRY(q, NONE), + RISCV_ISA_EXT_ENTRY(c, ANY), + RISCV_ISA_EXT_ENTRY(v, NONE), + RISCV_ISA_EXT_ENTRY(h, NONE), + RISCV_ISA_EXT_ENTRY(zicntr, ANY), + RISCV_ISA_EXT_ENTRY(zicsr, ANY), + RISCV_ISA_EXT_ENTRY(zifencei, ANY), + RISCV_ISA_EXT_ENTRY(zihintpause, ANY), + RISCV_ISA_EXT_ENTRY(zihpm, ANY), + RISCV_ISA_EXT_ENTRY(zba, ANY), + RISCV_ISA_EXT_ENTRY(zbb, ANY), + RISCV_ISA_EXT_ENTRY(zbs, ANY), + RISCV_ISA_EXT_ENTRY(smaia, ANY), + RISCV_ISA_EXT_ENTRY(smstateen, ANY), + RISCV_ISA_EXT_ENTRY(ssaia, ANY), + RISCV_ISA_EXT_ENTRY(sstc, NONE), + RISCV_ISA_EXT_ENTRY(svade, NONE), + RISCV_ISA_EXT_ENTRY(svpbmt, NONE), }; =20 static const struct riscv_isa_ext_data __initconst required_extensions[] = =3D { @@ -181,7 +239,7 @@ static void __init match_isa_ext(const char *name, cons= t char *name_end, =20 for ( unsigned int i =3D 0; i < riscv_isa_ext_count; i++ ) { - const struct riscv_isa_ext_data *ext =3D &riscv_isa_ext[i]; + const struct riscv_isa_ext_entry *ext =3D &riscv_isa_ext[i]; =20 /* * `ext->name` (according to initialization of riscv_isa_ext[] @@ -480,6 +538,98 @@ bool riscv_isa_extension_available(const unsigned long= *isa_bitmap, return test_bit(id, isa_bitmap); } =20 +static int __init build_guest_isa_str(char *buf, size_t size) +{ + char *p =3D buf; + size_t left =3D size; + int total; + +#if defined(CONFIG_RISCV_32) + total =3D snprintf(p, left, "rv32"); +#elif defined(CONFIG_RISCV_64) + total =3D snprintf(p, left, "rv64"); +#else +# error "Unsupported RISC-V bitness" +#endif + + if ( total < 0 ) + return total; + + if ( buf ) + { + if ( (size_t)total >=3D left ) + return -ENOSPC; + + p +=3D total; + left -=3D total; + } + + for ( unsigned int i =3D 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) + { + const struct riscv_isa_ext_entry *ext =3D &riscv_isa_ext[i]; + int ret; + + if ( !riscv_isa_extension_available(guest_isa, ext->id) ) + continue; + + ret =3D snprintf(p, left, "%s%s", + ext->id >=3D RISCV_ISA_EXT_BASE ? "_" : "", + ext->name); + if ( ret < 0 ) + return ret; + + total +=3D ret; + + if ( buf ) + { + if ( (size_t)ret >=3D left ) + return -ENOSPC; + + p +=3D ret; + left -=3D ret; + } + } + + return total; +} + +static void __init compute_guest_isa(void) +{ + int len; + + for ( unsigned int i =3D 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) + { + const struct riscv_isa_ext_entry *ext =3D &riscv_isa_ext[i]; + + if ( (ext->guest_flags & RISCV_ISA_EXT_GUEST_XLEN) && + riscv_isa_extension_available(NULL, ext->id) ) + __set_bit(ext->id, guest_isa); + } + + /* + * All domains are given the same guest ISA, so the "riscv,isa" string + * is built only once here and then shared by all of them. + */ + if ( (len =3D build_guest_isa_str(NULL, 0)) < 0 ) + panic("Failed to calculate guest \"riscv,isa\" length: %d\n", len); + + if ( !(guest_isa_str =3D xvmalloc_array(char, len + 1)) ) + panic("Failed to allocate guest \"riscv,isa\" string\n"); + + if ( build_guest_isa_str(guest_isa_str, len + 1) !=3D len ) + panic("Failed to build guest \"riscv,isa\" string\n"); +} + +void init_guest_isa(struct domain *d) +{ + d->arch.isa =3D guest_isa; +} + +const char *get_guest_isa_str(void) +{ + return guest_isa_str; +} + void __init riscv_fill_hwcap(void) { unsigned int i; @@ -527,4 +677,6 @@ void __init riscv_fill_hwcap(void) if ( !all_extns_available ) panic("Look why the extensions above are needed in " "https://xenbits.xenproject.org/docs/unstable/misc/riscv/boo= ting.txt\n"); + + compute_guest_isa(); } diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index 2819ff4e7c92..c9933147595e 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -308,6 +308,8 @@ int arch_domain_create(struct domain *d, if ( is_idle_domain(d) ) return 0; =20 + init_guest_isa(d); + if ( (rc =3D p2m_init(d, config)) !=3D 0) goto fail; =20 diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/inclu= de/asm/cpufeature.h index 0c48d57a03bb..2973eb13a513 100644 --- a/xen/arch/riscv/include/asm/cpufeature.h +++ b/xen/arch/riscv/include/asm/cpufeature.h @@ -5,6 +5,7 @@ #ifndef __ASSEMBLER__ =20 #include +#include =20 /* * These macros represent the logical IDs of each multi-letter RISC-V ISA @@ -44,7 +45,11 @@ enum riscv_isa_ext_id { RISCV_ISA_EXT_MAX }; =20 +struct domain; + void riscv_fill_hwcap(void); +void init_guest_isa(struct domain *d); +const char *get_guest_isa_str(void); =20 bool riscv_isa_extension_available(const unsigned long *isa_bitmap, enum riscv_isa_ext_id id); diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index 6044ce0feee0..8ae01a5e4dcc 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -7,6 +7,7 @@ #include #include =20 +#include #include #include #include @@ -94,6 +95,8 @@ struct arch_domain { struct p2m_domain p2m; =20 struct paging_domain paging; + + const unsigned long *isa; }; =20 #include --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966531; cv=none; d=zohomail.com; s=zohoarc; b=DlLdq83WUNf1EFqz9SQPbGeD+kADEUMuYV3Se7SvDeXff9kQS/eVvPJ12D+vUJVfb7aJ0Cg2efvXVXfQ9cjkM7nUOgH6W4lfwn9G6LG2o43eRvj+EJoee+P7ICZgGK+76gXsafFft8af4zssHRNw9UI5lcILKauTM5JSRtA1mDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966531; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZgRpdRy/E2EC0N94y/FzcJNCbvvQyl1VngGFLh0kH90=; b=LC8qjgE/2eY6yT6g9uksChB7m7bFhtbjTEb6vj0NsMOBfW9eMiJAK/y/5jhRU0Ooj3vOYpyunvrOjKwHHyc/wy8NhN3JCp6oibJTpogzVjp0UbXtylvUUOgbyurPMjBeoG295CCp6KNQBHxOaDF6GNynOXbk1oAwcUDVmQyWB88= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966530958894.1205973274999; Wed, 9 Sep 2026 08:08:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413252.1643509 (Exim 4.92) (envelope-from ) id 1x4JuO-0001ZN-Q6; Wed, 09 Sep 2026 15:08:20 +0000 Received: by outflank-mailman (output) from mailman id 1413252.1643509; Wed, 09 Sep 2026 15:08:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuO-0001ZC-ND; Wed, 09 Sep 2026 15:08:20 +0000 Received: by outflank-mailman (input) for mailman id 1413252; Wed, 09 Sep 2026 15:08:19 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuN-0001Tv-Bv for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuM-003DHh-Oh for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:18 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17658-bab6-0a2a0a5309dd-0a2a4503bcf8-28 for ; Wed, 09 Sep 2026 17:08:18 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17662-fae8-0a2a45030019-4a7de48cb13c-3 for ; Wed, 09 Sep 2026 17:08:18 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c254fa663c2so45963866b.3 for ; Wed, 09 Sep 2026 08:08:18 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966498; x=1789571298; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZgRpdRy/E2EC0N94y/FzcJNCbvvQyl1VngGFLh0kH90=; b=p9JNTyDHwVirKvvMN/7RpnT1x39acqQ7AXVm0eLPPRPC20KmPeCCb92agyW9Zq/d6r tMlC3trRFokr9EUSMN3y/EiLOwfQznfNBVMkigN9qwt24vDmP4Zf1E0Aahe5vnbR+2Co uSa6xm8LvR4Wlwa/pjtXAGZ+R4dil2t9UxBv/bQgHkbvoNqkpG+beFETyDdID2d1XkaG sa6e0w0eLKkqZe9+juNcIyF2LLo7+4+z0PXC6ClwMBMchDANQgwT7WkiUyXvKw5f9IKA ufQDiinWs3GGwHc0Feo4Z3ng9GEf5zoVcSOKa3jthfXz9grfTSygx6uM+Tdz7ZXc+fhl ckKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966498; x=1789571298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZgRpdRy/E2EC0N94y/FzcJNCbvvQyl1VngGFLh0kH90=; b=b755eauxEsdj62KV587M03d3WqnWMoRiG309GsEa2T2MDyt7rCj/3fozFmXr8xkogM XUHgSADPp4kKStsH+tz4p7tweNF97Tmix8+tI8DetN299sbJOesOshrTXfwVBKASXQep z2QX39GtWL80PNFhOiX7/k0Z1W71WWGg+PX86qovSmryINguDSk8dyAFCzJrNMjrDl4w c83Iq4se/WJp+O6WEyVjtfaimEX8bbZZaScc9VvfQ2oEbOliKwsZsOVV49sPUb4BzXKT osUgxe+e7RaNXVaN7VmQBwIyjZYvlSHdJSe2KceR2ccPeGNoM0jlc2ldjuKYMOZWxxp6 NZcA== X-Gm-Message-State: AFuF++kUMo3G1TWZE/9ovqRPt4O0nfQG9+De3jhN76iE3Dt0LkAFP3TH MRJH+uGPRr0nquy9BGU35W5XTdPdgpaq+mkdUxKSlpxkKb4qGY2KcVflBLXM0Nt6 X-Gm-Gg: AYBFou3WrEGOFrkGn53O822uajv/4hQNUigwmKgiRFaxIe0SnwyZXvhZpG1f5vmOCxe YufOfHxAlfbq8cUH+MlV+rBrcu3lozmVs5RfIfzG8swrTiOijlUvUnxjbV0gS6aHVzpxbj/sPCn wSxWjqKKquo0Nks2JylQ/gczS6nAe27htuu7LKuKg9++hpYWXlkDj0IU0kijBmWRNYaP2gjLMwb /xZXGNH7z/M7QsgxwPhEJokEksiAB+/hyaTvyy82nezyUHI03UUPAoWDwmvTpBFhDY7CCBpRByn Xbn6M8JJx74fTZ1A8nM7O8J1r2TEE+UyXD30EPTXOK+uUOk1LmDGNkPC/MNI4xVytnzJ3Ve3B9F 55VRBu8NGE6OIrCg/tcUhLE9H6XjuahGozkNJ4Xq+8SsXYM59vrNnMbE/mB7yjOEI4Q5T7G1Gd0 7rxlkk1p53/gxoVb/623xp+BnVuSO1VNGM4DieF3f94VT6v8lTZaN6K+FFqWP14xF465hHq02/X +wzHrh35Zt1ZmERluams6wjxY6tjw== X-Received: by 2002:a17:907:728f:b0:c25:362e:fb8b with SMTP id a640c23a62f3a-c29419f9643mr142637266b.7.1788966498060; Wed, 09 Sep 2026 08:08:18 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 05/20] xen/riscv: implement make_cpus_node() Date: Wed, 9 Sep 2026 17:07:23 +0200 Message-ID: <123512c9a3686aac6c3c97e5624ae98c4ad26f3d.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1788966498-6DAD44E9-4DA18F8F/10/73395122804 X-purgate-type: spam X-purgate-size: 6219 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966533196158500 Content-Type: text/plain; charset="utf-8" Implement make_cpus_node() to create cpus node for a guest domain. This function is going to be use by common dom0less code during construction domain. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v9: - Only rebase. Nothing changed. --- Changes in v8: - Add Acked-by: Jan Beulich . --- Changes in v7: - use get_guest_isa_str() for the "riscv,isa" property instead of building the string per domain. - as a consequence, drop the isa_str/len local variables, the xvmalloc_array()/xvfree() pair and the inclusion; with no resource left to release, the error paths now return res directly and the "out" label is gone. - s/sizeof/ARRAY_SIZE for snprintf's argument. - Drop Acked-by: Jan B. as some changes were done so it would be nice if Jan B. will review them again. --- Changes in v6: - Update the two build_guest_isa_str() call sites for its new `const struct domain *d` signature. - Drop build/tools/fixdep from the patch. - Add Acked-by: Jan Beulich . --- Changes in v5: - Drop Acked-by: Jan Beulich as extra changes were done because of the changed in prev. patch. - Move isa_str allocation and construction out of arch_domain_create() and into make_cpus_node() as a local variable, since the string is only needed during FDT generation. Use a two-call build_guest_isa_str() pattern (size probe, then fill) with xvmalloc_array, and convert all post-allocation error returns to goto out so xvfree() runs on every path. --- Changes in v4: - Update the comment in make_cpus_node() to match code style. - Add Acked-by: Jan Beulich . --- Changes in v3: - Add blank line above make_cpus_node() function definition. - Move 'unsigned int cpu' from function-level declarations into the for lo= op. - Drop 'uint32_t reg =3D cpu_to_fdt32(cpu)'; use fdt_property_cell(fdt, "r= eg", cpu) instead of fdt_property(fdt, "reg", ®, sizeof(reg)) so byte-order adj= ustment is handled internally. - Add matching /* interrupt-controller */ start comment; fix end comment to /* end interrupt-controller */. - Update d->arch.guest_isa_str to ->isa_str in make_cpus_node() function. --- Changes in v2: - s/u32/uint32_t for timebase_frequency local variable. - Drop +1 from BUILD_BUG_ON(). - return fdt_end_node(fdt); instead of res at the end of the function. --- --- xen/arch/riscv/domain-build.c | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index 5f6f4b6248a5..1af4c48fb30c 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -3,8 +3,10 @@ #include #include #include +#include #include =20 +#include #include #include =20 @@ -48,3 +50,107 @@ int __init construct_domain(struct domain *d, struct ke= rnel_info *kinfo) =20 return 0; } + +int __init make_cpus_node(const struct domain *d, struct kernel_info *kinf= o) +{ + int res; + const struct dt_device_node *cpus =3D dt_find_node_by_path("/cpus"); + uint32_t timebase_frequency; + bool frequency_valid; + void *fdt =3D kinfo->fdt; + + dt_dprintk("Create cpus node\n"); + + if ( !cpus ) + { + dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n"); + return -ENOENT; + } + + frequency_valid =3D dt_property_read_u32(cpus, "timebase-frequency", + &timebase_frequency); + + res =3D fdt_begin_node(fdt, "cpus"); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#address-cells", 1); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#size-cells", 0); + if ( res ) + return res; + + if ( frequency_valid ) + res =3D fdt_property_cell(fdt, "timebase-frequency", timebase_freq= uency); + + for ( unsigned int cpu =3D 0; cpu < d->max_vcpus; cpu++ ) + { + char buf[64]; + + snprintf(buf, ARRAY_SIZE(buf), "cpu@%u", cpu); + res =3D fdt_begin_node(fdt, buf); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "reg", cpu); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "status", "okay"); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "riscv"); + if ( res ) + return res; + + BUILD_BUG_ON((sizeof("riscv,") + + sizeof_field(struct gstage_mode_desc, name)) >=3D si= zeof(buf)); + snprintf(buf, ARRAY_SIZE(buf), "riscv,%s", max_gstage_mode->name); + res =3D fdt_property_string(fdt, "mmu-type", buf); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "riscv,isa", get_guest_isa_str()); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "device_type", "cpu"); + if ( res ) + return res; + + /* Start of interrupt-controller */ + res =3D fdt_begin_node(fdt, "interrupt-controller"); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "riscv,cpu-intc"); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", 1); + if ( res ) + return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if ( res ) + return res; + + res =3D fdt_property_u32(fdt, "phandle", alloc_phandle(kinfo)); + if ( res ) + return res; + + /* End of interrupt-controller */ + res =3D fdt_end_node(fdt); + if ( res ) + return res; + + res =3D fdt_end_node(fdt); + if ( res ) + return res; + } + + return fdt_end_node(fdt); +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788968058; cv=none; d=zohomail.com; s=zohoarc; b=jrPg20/tWcGJUr3MJLAQoCswYeff6KI0gwkXsUpWuqP0pSP0iMaKmUZ5+0Orz3VJaWhILIRNDUDypyACrzUIxCgHGzRKZiq2e5fLsVBN1Az2TME4GnkN2YojsBStxm32810Dn3U4UwIzrQXEOuR5MEZ8b9xeO8e+iGE4MeDvNPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788968058; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EHF1dWy+i1zH0Zv8Fgb2tmZxyyTHJFjQ0vjmPRcM214=; b=MxuVkWraL6UdSYYIW7mXFxZydQGeNWA9HImTv/mFmqvWQPh/rqXwuyNixBRGqP08CE+yEvREbXpk9lISm5w6OPVIEYF96Px3J+2xRL/Y3mklQ1JR88THFo2jPfWldxM2PLYg9Bcxdu1WdNO9z6ojKE0nt98lvDqU2XfPXQwrliY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788968058824535.3718439578375; Wed, 9 Sep 2026 08:34:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413425.1643669 (Exim 4.92) (envelope-from ) id 1x4KJE-0007Rj-8b; Wed, 09 Sep 2026 15:34:00 +0000 Received: by outflank-mailman (output) from mailman id 1413425.1643669; Wed, 09 Sep 2026 15:34:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4KJE-0007Rc-63; Wed, 09 Sep 2026 15:34:00 +0000 Received: by outflank-mailman (input) for mailman id 1413425; Wed, 09 Sep 2026 15:33:59 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4KJD-0007RT-GJ for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:33:59 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4KJC-00CxjB-Ss for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:33:58 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17c66-8faa-0a2a0a5109dd-0a2a4501beb4-2 for ; Wed, 09 Sep 2026 17:33:58 +0200 Received: from [74.125.228.76] (helo=mail-ed2-f12.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17c66-5984-0a2a45010019-4a7de44cc0ff-3 for ; Wed, 09 Sep 2026 17:33:58 +0200 Received: by mail-ed2-f12.google.com with SMTP id 4fb4d7f45d1cf-6a6249b76a8so582740a12.2 for ; Wed, 09 Sep 2026 08:33:58 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788968038; x=1789572838; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EHF1dWy+i1zH0Zv8Fgb2tmZxyyTHJFjQ0vjmPRcM214=; b=P1v5vTKInZqBUHWgGrguDpfjmOaqO5VjPRnUG4dD05youW0WmOOSzn+kcmmz4PMLmp Wc4cYqDF4EurXS7soHfGLvPQIGPrPHeJGOckm7QE7AFV7lcO/y0YRvUwtm4YQDyGcoeD ocDLqe5SJbH40/LvLiZJpyXr+MdqqneBVxI3ZnxbxkdkE0inzQ0dCrrq4FSK72o48Xvc +lpWUQKP8ewdWFBx46lvy0kAPpYa/f25bNLBt4l1YWIqA1MymxLYt/Cn9tR6NpsT3NpC XHP9DEVJkBL658Qy8Thbfy9/15fBINFaL292OKAtN/5pIgigWoM+ccn1pYyPhfPS8Cmh 7YuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788968038; x=1789572838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EHF1dWy+i1zH0Zv8Fgb2tmZxyyTHJFjQ0vjmPRcM214=; b=n2kDFrv3NFgiH0TmAXw+igMNqYLjUp7Bh8j8la1cjLKfu5RTeJ5cfjKJ5lnYxF0VaK TLMkAVh4GnjVVp+rS0rA9nMnErM5gi8iktgQcNFzZsvR3IYxMLJF9BnDrTLUet80ll0k Ph6EC8rL4pGYQUBvnG0j+miFqVz7TxRaeCfynJNsTcWpLKGBucC9LclH4PhE+awmEOz7 Wp1n8P898wzZp0yym65AN+v7j9LqKlc4IEKQlE1NYnum/GKXwHecfKJwwSmcoLvokPVK +VcBOFHPlOTQffeVaj2aPBXwtsq9YeFZnvKmzPaFY2AaG/780OC+S8RZNt37ETO1m0jm DvFg== X-Gm-Message-State: AFuF++km/EBhXsOf8FWhtxTZuBa7UWvFyVHCZ4+wByrGDspm2pow5XPL jgIJYjgdtEdmEg5tcwm4S4z9Lbzfw1sWxaokYjQMScMg2gC226UY+6buOXXYXYd4 X-Gm-Gg: AYBFou0ADIJqe0rzw0yAJ8P91JWIm08YtXkA0048GcC4bHn3twkLQhEVLLvlQK9iUCH hr2hFR1+/IQTGbdJs5IZInQPMul6C0QpeIoJw2z522JufucfBDQ2H3DAYfaIIZs9wFTE4sVAu7b EFIRrfThx02sbY3Ul/TYJNQPLRAaXA0aO4YJ7ZuGS6CXajzXFPRPCA0qbz58M1OKReoe4U2zHaz WZTMKGBIH6keaIkKDfcDXs+J1fP7ZhxI/xcIxPMwV9euvIdbc14Yfeiuspmah5e8pivojBveecq IJy0xjmgYwO/eXKORumf6NJbug6r7k9iAOV55g1mrPwn1cIDF555WDNylpgbNcM8ZAkmATC00z6 InRsnENKDdGhB4mLYkiCZVdIAx4YK1eIyl9MDXtbFLfi3qD7NUUxTpnnlMacXr5+kmOX79g8YQ4 SKiiI/6mjd7NqDeG7FaDM7lIQKdVLbsNB9z2sF4zClKw7D2RwmnTK78p4/JYwZVtg0Q2nWNnyC4 kc/BOtpQyvAsa+6S+U= X-Received: by 2002:a17:907:c408:b0:c26:1648:a075 with SMTP id a640c23a62f3a-c2941be4cddmr61403866b.48.1788966500181; Wed, 09 Sep 2026 08:08:20 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 06/20] xen/riscv: implement make_timer_node() Date: Wed, 9 Sep 2026 17:07:24 +0200 Message-ID: <63d5e0a7f9e8d9891b248d503c33498a5bca4225.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1788968038-BE664757-B6A07A71/10/73395122804 X-purgate-type: spam X-purgate-size: 1618 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788968060602158500 Content-Type: text/plain; charset="utf-8" Generally, in DT for RISC-V there is a document which describes a timer node (riscv,timer.yaml or sifive,clint.yaml), but the Linux timer driver is declared with TIMER_OF_DECLARE(riscv_timer, "riscv", ...). It matches the CPU node (compatible "riscv"), not the timer node itself. It then calls of_find_compatible_node(NULL, NULL, "riscv,timer") only to read the optional riscv,timer-cannot-wake-cpu property. Since Xen does not care about that property for now, make_timer_node() is implemented to return 0, as no timer node needs to be created for RISC-V guests. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v3-9: - Nothing changed. Only rebase. --- Changes in v2: - Acked-by: Jan Beulich - Update the commit message. --- --- xen/arch/riscv/domain-build.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index 1af4c48fb30c..d7613721db95 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include =20 @@ -154,3 +155,10 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) =20 return fdt_end_node(fdt); } + +int __init make_timer_node(const struct kernel_info *kinfo) +{ + /* There is no need for timer node for RISC-V. */ + + return 0; +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966536; cv=none; d=zohomail.com; s=zohoarc; b=Axca98EkvRCO0oRbZ2jkTLjD7Qau3coEI6/cQ38a42leMvvdbNKvUbLPe89mttE2jSGe8yJReDDn+POKxdlcgKIWNXEtJ6RjFKRBdBkwm8NpAm9RJ4A1mFGZG+5BdZrq5t/iQ6bTagYEAL2jBR1frxdELy0CGbIxf5r0o2T7yfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966536; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/L1VhqjM9/gZZzhdCNypBrVlymm8xmNghq5Zkc3eF/E=; b=ZzVXCcbsAW5NY+2Ln1K/eaazJZtoy5FyHy7nNt3rMF6WDTQ3vanZ/XUufc2Ulz+r31hR5D87RlEabBF3oKKlE2vTEb3a0FE+RAcUpaHTZ9O3pPxindpdwoluOcS/ZXYmOF0T1rd6cEd93kO6EA05qLcHtD37dcCmucxwgrJjAn8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966536038163.19363382666847; Wed, 9 Sep 2026 08:08:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413254.1643518 (Exim 4.92) (envelope-from ) id 1x4JuU-0001vV-2H; Wed, 09 Sep 2026 15:08:26 +0000 Received: by outflank-mailman (output) from mailman id 1413254.1643518; Wed, 09 Sep 2026 15:08:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuT-0001vI-U8; Wed, 09 Sep 2026 15:08:25 +0000 Received: by outflank-mailman (input) for mailman id 1413254; Wed, 09 Sep 2026 15:08:24 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuS-0001sK-Kw for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuS-002kD3-1b for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:24 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17656-8faa-0a2a0a5109dd-0a2a4504bdce-40 for ; Wed, 09 Sep 2026 17:08:24 +0200 Received: from [209.85.218.43] (helo=mail-ej1-f43.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17667-b57f-0a2a45040019-d155da2ba8eb-3 for ; Wed, 09 Sep 2026 17:08:23 +0200 Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-c2569aa5116so928988666b.0 for ; Wed, 09 Sep 2026 08:08:23 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:23 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966503; x=1789571303; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/L1VhqjM9/gZZzhdCNypBrVlymm8xmNghq5Zkc3eF/E=; b=HJ/s9LKAUeGxT7JkjlX/o83bXoNqeH5tDwvQ2t1chcSBNh8VNpri/OfVPcvVQNv+6Q Ht3p4EyoKh+bod8LF94WHpFrTeCrC+Z8hiXYNHlSvL7zNq1EJzj9Vl1tM4QYJ5u8iYfz k40H8aZ7pwR3ARosIYab7NvK8WJDapRJBOLDPPvfF67robe4k9SMoF9CIWQZPXUiJwi1 6FlG9WOJA+Yk1797nVeYLXXALelIoX8W9LcZB+zPL127JhhIYxdzqwsCK4hSRvwhR8HF SuhZ/0mqaawg4pAUXgfE8R6fudV1kQBuTCc5NpXtNXA7vg5+EeVXySYSmddQhjzy6uiJ WSwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966503; x=1789571303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/L1VhqjM9/gZZzhdCNypBrVlymm8xmNghq5Zkc3eF/E=; b=K4C3u6OpdrPP5D4ooZjmRDJ9eOWpZ+BV2b1Zh8eIbnoon8JDu8cJ1KVaikJ80ueoXs QnM++XZ4vkbOF/EhkEZM1+4T6BsNTmTIEMxWzSMlxOmcX+f8Sl/7abDGmb7+H7ZyxwGq GhiiWn9m6aAyuEuz3RbYHIbMa3Rjs6V0zkW2FUwVhJU1/KMY3+OartwHtX+hu4Va0b8A 7Uok7v6zs1Lnh9fMGdZmNrm+96vOWUi/KR1l2jMvoViuwpAvz6ICRlSIZHtoG4LMoob8 KsSOTNh+BS5l9Rit72laDlq6RkcP7ybs/qnLjsAyxoNX6numb0izTJpadhhtrLotATvl oDPQ== X-Gm-Message-State: AFuF++kukREZboqrBfoD4qBejDscg4kbnlDUGw5ypoK4G+4W4swh8Fi4 n6iFRm32fLfAZuSaAcauRWkK1PCZQajEKCrH+BqOiHu0R6JBb3SR5eErE6cIDWks X-Gm-Gg: AYBFou0UL+me/gM0Mt6cF4JFHCPHYYaX9kqFuWAtQeWpVxw6cQhCaouKPTPXbyoEfrK 6S3mn2QrSoRS3bqmBGYcyaphkJdCMuB0B4RkQJ9jOeCloabXBrR6Ab2mnyXREhE9f/stwMUVUSC fBV1yh2hdMM95eAYeAbYqaB1QSy7rspSRRDz9kj1wfbfSknkRcpHtW64otI7tueWly08yHw3SuE QCS0HrVC2ojhRCEsKHx132o3EbdbG9aE9zdZ6/slOvsvTki/1PkmZQjaqcBsg3P2Qcvd2H2hmF6 MS8d3taeSOawxcpY/ufmiC1EK/1w2oBBNpG0VHl6DJVx4kk7Z1R9hjbCG+l88ERaJvyVhYTq2I8 uVelscTKLsH6dlyV19KOFWQeJh4QYDmZ1pdPc1V5zppleyn8MaKkQ3u0gPd6lFVRQIbDXTq5Wa4 5t2dxD+8/V73nxObqtJBwk0l6B/P3aszgIEO+xUX05rUT/b2KXIazKsJunM9RJvIzQNF7jqIHZE G/jwtKM0fW0QCbl6A7ZJVTzMPIJrw== X-Received: by 2002:a17:907:9810:b0:c25:c787:43c with SMTP id a640c23a62f3a-c25f01f0adcmr1884110266b.14.1788966503256; Wed, 09 Sep 2026 08:08:23 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 07/20] xen/riscv: implement make_arch_nodes() Date: Wed, 9 Sep 2026 17:07:25 +0200 Message-ID: <7f0f371c916fb7226f0ec82921e091804affc491.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1788966504-C2CCFB50-1294E092/10/73395122804 X-purgate-type: spam X-purgate-size: 1444 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966537258158500 Content-Type: text/plain; charset="utf-8" No RISC-V-specific nodes need to be created at the moment, so make_arch_nodes() is implemented to simply return 0. It is placed in dom0less-build.c as make_arch_nodes() is only used in the dom0less code path. In the future, it will be extended to create an emulated UART node. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v6-v9: - Nothing changed. Only rebase. --- Changes in v5: - Drop "Add" before Acked-by above the footer. --- Change in v4: - Add lost Acked-by. --- Changes in v3: - Add Acked-by: Jan Beulich . --- Changes in v2: - Update the commit message. --- --- xen/arch/riscv/dom0less-build.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-buil= d.c index a683972e9235..4cc00012aa8d 100644 --- a/xen/arch/riscv/dom0less-build.c +++ b/xen/arch/riscv/dom0less-build.c @@ -2,10 +2,18 @@ =20 #include #include +#include #include =20 #include =20 +int __init make_arch_nodes(struct kernel_info *kinfo) +{ + /* No RISC-V specific nodes need to be made, at the moment. */ + + return 0; +} + int __init arch_parse_dom0less_node(struct dt_device_node *node, struct boot_domain *bd) { --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966527; cv=none; d=zohomail.com; s=zohoarc; b=aW0YS7vBg3oEoEVRnSE3AlXilK7ecU6/LB38bs1nC9MTWdigYdJzo6r1QNPO0AdQ7CINi3RLAit7PZNl/RUWVmi41pbHbrhO50VxiOv95bz/DKSRsL1WTG+WesHKdEJxfv7FtGNamilcn9oTT0gz5j+BYQgM9aHyw2GYLZUaz7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966527; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yk8KF/HUlDCJZvlpTURbkM7U/Ti3G4IswH0NPpHEPoA=; b=hq4PeFErPgKrju0MOc0pIOz4c9ZvWEyytXX6crAPdhPA3XmkhLWOKVeTslXKpURt0ePGY7F5LJ+IFgfm1XfIoCldr51YY7TdCXuaw7uDLfmMqRSjOb8ZBVr2R9pPV/+NJ7XURNbw9eFS7DFh0jYcwBkkmsV8uMB9aYhklo2OMoE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966527032915.3365813381359; Wed, 9 Sep 2026 08:08:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413256.1643527 (Exim 4.92) (envelope-from ) id 1x4JuW-0002CH-CE; Wed, 09 Sep 2026 15:08:28 +0000 Received: by outflank-mailman (output) from mailman id 1413256.1643527; Wed, 09 Sep 2026 15:08:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JuW-0002C8-81; Wed, 09 Sep 2026 15:08:28 +0000 Received: by outflank-mailman (input) for mailman id 1413256; Wed, 09 Sep 2026 15:08:26 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JuU-0001yQ-Ej for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JuT-00DoJa-Qv for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:25 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17659-e002-0a2a0a5209dd-0a2a4507ddba-46 for ; Wed, 09 Sep 2026 17:08:25 +0200 Received: from [209.85.218.49] (helo=mail-ej1-f49.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17669-b4ea-0a2a45070019-d155da31e086-3 for ; Wed, 09 Sep 2026 17:08:25 +0200 Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-c1c52d920b8so799616666b.2 for ; Wed, 09 Sep 2026 08:08:25 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966505; x=1789571305; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yk8KF/HUlDCJZvlpTURbkM7U/Ti3G4IswH0NPpHEPoA=; b=QxoZodVZAtG29WKbXX2W0cP+45LEl/vCY9bE9pfV8GdNtQ0hUEbmdi9Kunw3LGegkf AbZbqty5Dj1Rn1u/3X3bagA029tPM5t8Bziaiz/9QdaWqk6foBVdeIwViF9qm9TTyeES C4/xkXX0BZsgrwOwYnNrngx/eUK33GuxRWahZhWARnyW/Pkvgc2q8P9h8PLxI+8EweY6 OdDoTWyl4lXxz3z5yR2D4dQ9Jllpq3fA+DlvI9vyi+e3flRexSF89lNSjsBB+3DmZgg5 sNVJgH1wZsVgFf81c28eTC/dXBianhei7r777L9OZPjYSHNsNsib6L4XfbPHGjKljrTf UpIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966505; x=1789571305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=yk8KF/HUlDCJZvlpTURbkM7U/Ti3G4IswH0NPpHEPoA=; b=iIAV2akK4K8jrtgoESaPdR9gVeWYIJTQkstRD1hfx4u42dkedCK7vh9E+Gcxv/h5Pl wagUxiNILaMy4caXoFXBduf6UVRwAZqh0dm4WV96ttbFyJHeX/+rmPY8AQ1PRORXwqOg hHgiNPXvKvyuFHEgBUzs6gF1cDrYQQu14cNRL2erH0PWGrR2oM0vXuVmhKgrXiGZEYmg cpGISTkzVrB8ePaIhKOPzFL80HlG6yJEsxc/ro8RKOmMvFrP+Kugu/7oJpfWyXYaFNNe RkuMhRvbP5QeAFsbSW1mykxucWYXjSUfwE/r2YFCZ5pDBKckV89jprCvAgxmm0Hsv5BS 3zeA== X-Gm-Message-State: AFuF++lywUroqMaU7h0uAMxbHbnPp798gSS4NynhoGL0TwzUI0JZYKOP 5834H44T6Ma9biDfxwWJv8NTLdXBVWcuQ5jj9sQUqISv2g7K4WSB9AhueQxVZUTq X-Gm-Gg: AYBFou2xtikHQnmv2mltBUihgbOZUuNEcs1bHzgjknOBfjLvNZoKaQuWkRW8awIKkf+ pDyvEC7Pmf4vDY4QYdGHNRFEtadc6wpy3bqbLK6dbPnGzCLJ9+3NUIiFdp5ymQmoFpiJ4YEjIQy TNKp9un2hapy7DlCLKUgu9KlJsZC6uQFeajsLlv7BMno9ckoKg/Mtp+vtytIgOS/XQsP7SKMiVN 0TyKAFLec8bhH0Bk0rOVBx86s70vLy18wcNarArixQq7GteoTC/RfX7eolvXCupRsGSZEiuF21W FEL7PpWsjpT8FMNxmcvbDuxmfblQbk+jWCRcVjOnCVr09EhTTEQwWObyJCjKJGtwL+cepyxs7Fc zNt2ycAJww4SAhhGZGfTo944m0SCKrtXXQagwE4AnW+kGRdlp90EelGoyDjeZLrAzENmCW7LNRI E+3qETK3rYItkVxonUs/m4tjmVS+uz+2M1NYfqgrWG6pzoIqC8ziuQo5NMresObqtU8fce8v+WD iBOCLG1hjF3wN6ILqA= X-Received: by 2002:a17:907:3d44:b0:c27:420b:7c90 with SMTP id a640c23a62f3a-c27420ba0camr957267066b.48.1788966505230; Wed, 09 Sep 2026 08:08:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 08/20] xen/riscv: introduce init interrupt controller operations Date: Wed, 9 Sep 2026 17:07:26 +0200 Message-ID: <5e0a955e030deb690f1a5f7fdd94d6ac7cee794f.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1788966505-A6AD8AE4-BCD9DC0F/10/73395122804 X-purgate-type: spam X-purgate-size: 4033 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966529257158500 Content-Type: text/plain; charset="utf-8" Introduce intc_hw_init_ops structure to avoid risky mix of init function and non-init function. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5-9: - Nothing changed. Only rebase. --- Changes in v4: - Use __initconstrel instead of __initconst for aplic_init_ops as both initialized fields incur a relocation. - Add Acked-by: ... . --- Changes in v3: - Use __initconst instead of __initdata for const intc_hw_init_ops. - Embed const struct intc_hw_operations *ops into intc_hw_init_ops so register_intc_ops() takes a single pointer argument. --- Changes in v2: - New patch. --- --- xen/arch/riscv/aplic.c | 8 ++++++-- xen/arch/riscv/include/asm/intc.h | 10 +++++++--- xen/arch/riscv/intc.c | 11 ++++++++--- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 9f023db5d525..d08401db46b3 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -325,12 +325,16 @@ static const hw_irq_controller aplic_xen_irq_type =3D= { =20 static const struct intc_hw_operations aplic_ops =3D { .info =3D &aplic_info, - .init =3D aplic_init, .host_irq_type =3D &aplic_xen_irq_type, .handle_interrupt =3D aplic_handle_interrupt, .set_irq_type =3D aplic_set_irq_type, }; =20 +static const struct intc_hw_init_ops __initconstrel aplic_init_ops =3D { + .ops =3D &aplic_ops, + .init =3D aplic_init, +}; + static int cf_check aplic_irq_xlate(const uint32_t *intspec, unsigned int intsize, unsigned int *out_hwirq, @@ -366,7 +370,7 @@ static int __init aplic_preinit(struct dt_device_node *= node, const void *dat) =20 dt_irq_xlate =3D aplic_irq_xlate; =20 - register_intc_ops(&aplic_ops); + register_intc_ops(&aplic_init_ops); =20 /* Enable supervisor external interrupt */ csr_set(CSR_SIE, BIT(IRQ_S_EXT, UL)); diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 675f703ec97f..d7b34fc15ad1 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -28,8 +28,6 @@ struct intc_info { struct intc_hw_operations { /* Hold intc hw information */ const struct intc_info *info; - /* Initialize the intc and the boot CPU */ - int (*init)(void); =20 /* hw_irq_controller to enable/disable/eoi host irq */ const struct hw_interrupt_type *host_irq_type; @@ -43,9 +41,15 @@ struct intc_hw_operations { void (*handle_interrupt)(struct cpu_user_regs *regs); }; =20 +struct intc_hw_init_ops { + const struct intc_hw_operations *ops; + /* Initialize the intc and the boot CPU */ + int (*init)(void); +}; + void intc_preinit(void); =20 -void register_intc_ops(const struct intc_hw_operations *ops); +void register_intc_ops(const struct intc_hw_init_ops *init_ops); =20 void intc_init(void); =20 diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index ea317aea5ad8..3600d23bdb5b 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -12,9 +12,12 @@ =20 static const struct intc_hw_operations *__ro_after_init intc_hw_ops; =20 -void __init register_intc_ops(const struct intc_hw_operations *ops) +static const struct intc_hw_init_ops *__initdata intc_hw_init_ops; + +void __init register_intc_ops(const struct intc_hw_init_ops *init_ops) { - intc_hw_ops =3D ops; + intc_hw_ops =3D init_ops->ops; + intc_hw_init_ops =3D init_ops; } =20 void __init intc_preinit(void) @@ -27,7 +30,9 @@ void __init intc_preinit(void) =20 void __init intc_init(void) { - if ( intc_hw_ops->init() ) + ASSERT(intc_hw_init_ops && intc_hw_init_ops->init); + + if ( intc_hw_init_ops->init() ) panic("Failed to initialize the interrupt controller drivers\n"); } =20 --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788967001; cv=none; d=zohomail.com; s=zohoarc; b=QhTklLG1xT2h6jntu454l6h/sRgCpZlzCTQu9ZJ10RwlP8LEVpeT9hUbEhirbiUy3fMSuhzZ2z4BbzmhPbuYoWahLnJMN+a4c4EP+XXg00HofT1dDSQxxUe3aIhT6rzIvHcKPrOIHqeDmPiGQx0y0KJEm+pVN6hfNzddnF3WXdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788967001; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pmK9naUMbOofZXsZTLQyyxB70Co/ElUNF72aKPXn/H8=; b=EVAyyHwChhHeZ8hXNmp/G7znrFpzZviLdY652YD+4M94tW4teat+VZoCQRyHgVtSpkF7FPvqoYEMKa3h8AScSnSeF7QO2ZaVzlTZvBnb+Cvixahw1nTUlTPQYqIFRSd8Tvmwuuxtrj+NtCfODf6Bh70OaVhaF0ommFmj27eMuGY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788967001517281.72599460685626; Wed, 9 Sep 2026 08:16:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413392.1643653 (Exim 4.92) (envelope-from ) id 1x4K2C-00033L-Jq; Wed, 09 Sep 2026 15:16:24 +0000 Received: by outflank-mailman (output) from mailman id 1413392.1643653; Wed, 09 Sep 2026 15:16:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4K2C-00033D-G4; Wed, 09 Sep 2026 15:16:24 +0000 Received: by outflank-mailman (input) for mailman id 1413392; Wed, 09 Sep 2026 15:16:23 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4K2B-000336-8x for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:16:23 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4K2A-00CvId-MD for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:16:22 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17835-8faa-0a2a0a5109dd-0a2a45079ebe-30 for ; Wed, 09 Sep 2026 17:16:22 +0200 Received: from [74.125.228.76] (helo=mail-ed2-f12.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17846-b4ea-0a2a45070019-4a7de44cb5bd-3 for ; Wed, 09 Sep 2026 17:16:22 +0200 Received: by mail-ed2-f12.google.com with SMTP id 4fb4d7f45d1cf-6a60591ae54so1999389a12.3 for ; Wed, 09 Sep 2026 08:16:22 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:26 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966982; x=1789571782; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pmK9naUMbOofZXsZTLQyyxB70Co/ElUNF72aKPXn/H8=; b=i8SMFLYLTsBjl487V7MNH5F3VWRKW11sToSG0c24UaNBwfVqQ2D5D+rhm0L58Jb50E ijCtSqaQsInXgoQu0oOJHTip6jfTv+mck9esKtEJcF7wLGky8p74Lmg/uTzxIcTFwyy9 sPutq6DDYMIp93ScZqy84mASqo2eJotcrbmnNSRl8aFio9oj5onwSxEzbFE7zkQIIprt 3ULyrSgNbQXMHTyGnzlb1aZAmoqpzLxvpY+3qeIe3zSPV+UGDuqtoYfx4PC4hu2WfPks 5xyuYjd/ZtRh9RLS8KSJu7QW+nxVmffpKgL0Xlp9jwbAssrh2zRdNAuyZgzt5Y3DwjW5 Ixqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966982; x=1789571782; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pmK9naUMbOofZXsZTLQyyxB70Co/ElUNF72aKPXn/H8=; b=AGx+O2ikbIJn2reGoek3f/4SwkAqol85B0wv5GL46/Xq/nQg1W3O0VX1wJfBdAFop0 Pas6BH/nbtgXYr9lsFJ8NyonKjqX7O8i7+PER+LM8TG9eOFpaHFQKiXF0djXUP8+ZJvZ g+uUUqemjtz2BQvAUCBAqZR4Laet5FiM7W+xEsn6ikiPOu4Ow/wrEnoa2ILuQDqPt+YT 2wtduiGUlHhjxODDs3attMcrbUSOFHVzns+7N1h/wgKHSY3pcfenFxhqDflxOIXvvLyo oN92UIqeqqXN5Pk54DLQ2Wk9qbRsYn4IKsXJA2J7yRZodfH2gZsabwcliNk+JGTTQ7F/ 3/kQ== X-Gm-Message-State: AFuF++mkoQz2zCBr6rOBmn953QtBn+fe64XCc/P7HAZNvv2xDMEl5WKq oBc5q2yZFPqFsTaYxsIeWFsQOJDM2/rYlXy6Hjhs6hEaHR5+IGsY1CnHfr69TMnj X-Gm-Gg: AYBFou2mONKv8P4oUJsuyYhn4QIgXpjA2OiKP60YUrXJysaVygf6zl2Q9l5M5dmMs01 MwRylESge+MdMyeJvtiGi1xpZbIkZ7A6uXgxSLIGimFKhQkm5QKyk2/EpCxxmgEmUSUbAd11paI ubSbiT+moQkG5wcHdC4sBYWj9CWs8/fRTqV+cis4JIN/3g8tTxR8VFwCMNbvK1rbXCH+9fNzmp0 gS1gXlO0NMY1lwDI2kxvIfkh9zEmr4ozqhd++udhxjVQ7hFCMOj0+NV7P9GEwea42ZRSVu1POL3 eQkvmAifCxsh55qe5A7GA6Mx1qFw2/2497AJf7EmWseZRDb3vZStHg4HzSwjGRFQL/8uBtMDmLc ESpkCEWLZaBRsvVWExuYwBQJT3M14+o5eSSIxr4sVjKwLyRCNUXqf55MeLCB6yC936M12ipGbvn RcbcYcHaboUaejCm94blyHCIBMq18rmLgN6pxQbY9Q06W2lQmcTY8NTCHmvR6He7oBsqPzlJFOu InmSm3tUg5RG03BLt0= X-Received: by 2002:a17:907:7214:b0:c25:ed6e:7edf with SMTP id a640c23a62f3a-c292b138196mr498302266b.11.1788966507316; Wed, 09 Sep 2026 08:08:27 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 09/20] xen/riscv: implement make_intc_domU_node() Date: Wed, 9 Sep 2026 17:07:27 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1788966982-A5AC0AE4-42CEE675/10/73395122804 X-purgate-type: spam X-purgate-size: 3439 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788967003196158500 Content-Type: text/plain; charset="utf-8" Introduce a RISC-V specific function to create an interrupt controller Device Tree node for DomU domains during dom0less build. Add make_intc_domU_node() to the dom0less build path and wire it to a new generic helper, intc_make_domu_dt_node(), which delegates DT node creation to the active interrupt controller implementation via vintc_init_ops. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5-9: - Nothing changed. Onlye rebase. --- Change in v4: - Made local variable vintc pointer-to-const. - Add Acked-by: Jan Beulich --- Changes in v3: - Use const struct vintc_init_ops *init_ops in struct vintc. - Drop redundant intc_hw_ops check in make_intc_domU_node(). - Drop NULL pointer checks in make_intc_domU_node() as we can't start domU without properly created interrupt contoller node. --- Changes in v2: - s/intc_make_domu_dt_node/make_intc_domU_node. - introduce separate intc_hw_init_ops structure for init operations. - Return -EOPNOTSUPP instead of -ENOSYS. - Drop const for kinfo argument as it could be changed by interrupt controller node creation code. - Refactor make_domu_dt_node(). - Make make_domu_dt_node part of vintc structure as it looks more logical = to be there. --- --- xen/arch/riscv/include/asm/domain.h | 2 ++ xen/arch/riscv/include/asm/intc.h | 10 ++++++++++ xen/arch/riscv/intc.c | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index 8ae01a5e4dcc..bd43ed08c22c 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -97,6 +97,8 @@ struct arch_domain { struct paging_domain paging; =20 const unsigned long *isa; + + struct vintc *vintc; }; =20 #include diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index d7b34fc15ad1..a4e678fad90b 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -16,6 +16,7 @@ enum intc_variant { =20 struct cpu_user_regs; struct irq_desc; +struct kernel_info; =20 struct intc_info { enum intc_variant hw_variant; @@ -47,6 +48,15 @@ struct intc_hw_init_ops { int (*init)(void); }; =20 +struct vintc_init_ops { + /* Create interrupt controller node for domain */ + int (*make_domu_dt_node)(struct kernel_info *kinfo); +}; + +struct vintc { + const struct vintc_init_ops *init_ops; +}; + void intc_preinit(void); =20 void register_intc_ops(const struct intc_hw_init_ops *init_ops); diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index 3600d23bdb5b..e63da5e22efc 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -72,3 +73,10 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsign= ed int priority) intc_set_irq_type(desc, desc->arch.type); intc_set_irq_priority(desc, priority); } + +int __init make_intc_domU_node(struct kernel_info *kinfo) +{ + const struct vintc *vintc =3D kinfo->bd.d->arch.vintc; + + return vintc->init_ops->make_domu_dt_node(kinfo); +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966558; cv=none; d=zohomail.com; s=zohoarc; b=c9R3nPXatc//7z/9QKH9Gm3U9scjwVggERuT2zH/m1GpNihWTf15br8vQf4znVMYXHzv09dJGa7TeREci9CK5iXzMQxx2M05/sCVNjsfmPckrl+9WEfZ54kpPRXRdDJS8FLux4cLJGsWzFcd/MN9EMfetx2OgdpN9l3sLZP73N4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966558; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/0W7LJeeRtFjbmuJPQsrOkLOl9/tUs9pbSj+ISpVBYg=; b=f43u0bdC+XSfKJbRFtarvj3NJQH67pX2UY8kuz13kJWfGWB4whhT5XdQENHnTNTr6tVAuzaJ1eMPUB1rDSDSKu6lkpkcyeF6yDMY0g5p71dWYMr4+Jbh8XddYRuHATg37b22TDoULxpod+QP3J4Iln6vAPJWLiXJl27IBIMmoho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966558485779.6118285898743; Wed, 9 Sep 2026 08:09:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413273.1643536 (Exim 4.92) (envelope-from ) id 1x4Juq-0003Sc-JD; Wed, 09 Sep 2026 15:08:48 +0000 Received: by outflank-mailman (output) from mailman id 1413273.1643536; Wed, 09 Sep 2026 15:08:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Juq-0003SV-GT; Wed, 09 Sep 2026 15:08:48 +0000 Received: by outflank-mailman (input) for mailman id 1413273; Wed, 09 Sep 2026 15:08:46 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Juo-0003Ef-GW for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:46 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jun-00DoNW-TR for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:45 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17665-e002-0a2a0a5209dd-0a2a4506ec68-38 for ; Wed, 09 Sep 2026 17:08:45 +0200 Received: from [209.85.218.42] (helo=mail-ej1-f42.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa1767d-195a-0a2a45060019-d155da2ae80b-3 for ; Wed, 09 Sep 2026 17:08:45 +0200 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-c262bc686d9so755811766b.2 for ; Wed, 09 Sep 2026 08:08:45 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966525; x=1789571325; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/0W7LJeeRtFjbmuJPQsrOkLOl9/tUs9pbSj+ISpVBYg=; b=QSNg//iiO1wdtmenxp2hOlm263UL1KyUdEwAhj/QCuphQTHIHazJKpMd42ELcU9cNv H3rXCsDOTKCnowz9ACl7L39tmn7l43rhHQxIsav4ZvyUbGOGUizMUtvREJxHze1ewJTK RMq8g3YgWw+Vz4T8hps2WD+KkRBvMAlsfY9OdKyByneZISTsC00ozF5Y/drVoV0yDlyO TAyJM+2Kc6vNSz9VNIT5zOnr80OdtT+4TBDxR66Uw6grouFCK1IN4rJsvZAAwcw01uW0 Xcyo25rrg9yqM8/0yL3k1b7vouEzMWHuoupWdrntTbkdzA2JLZjxSmYVn1j2G9+LbLTk SbCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966525; x=1789571325; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/0W7LJeeRtFjbmuJPQsrOkLOl9/tUs9pbSj+ISpVBYg=; b=ej6rIToaNfBhOfQpHL/2sEIC1gpD9wzIYNqTtjHzTD1VhU4tR4nIx9atqotyJExQI/ ufKbhbQbph9mne1yPLx4iHKEMyZe/PuBkrtIjfyJK1rfR6Om8uuqs96pZlSwZsAlRreV 5C7pwXZm1I54wXTZO3uvA4Tzkm7E3tl67YNHLAQd2ueu4whfrZ+TS8uJvUsnqrhc/wh1 FW/piyjLjpF4oabA030Gv67FZd0SvIQUmtAQdfaJlJ+VO6bE6pajBF2TdeiHN3Th9YJV 2RWoewZfDrg+3rL8VahOMW4DGvpBJpqnr6zEiB4nM8JfPM0KumgUNtBLI5wLfp0nmN4R 0/rg== X-Gm-Message-State: AFuF++m2sCKlNGWorZ+bR0DThApHSUSMhlioalsqiPfK7aqGiHQClDCx QpWKx3tPSV3q1v0MGGazhRksLGG4cxLaRDAS6puDvpuUgdwRB5YxOxltf/czyt3b X-Gm-Gg: AYBFou0X81ELmsSHtJVjem6fa66/qyDNu0Jgc7m0kMNn2ftO3U5Cqyrl/66NtcFkAmw MTYOcqGd+n/V3smw2qZJqvyRFZEoSqvsE/wK8wl2yo0rZNvVRZjNEbOBX+3Qnk1fzv8O9oYZx6w y2kOuv8SxO0EHtfMUmp+JPQonl91+qg0Y+H5g0FMhmgeZB5ocCZWHwmGkGPoHTPX2iHbCb6lWSL s4t9DrmVOeqDHR6kwoYPgXNJP2OXGj63AIBFLk6LlG7TUwwp8fUzdwop14P0WxQhCaDYw0wHLLe mBr5QUlZnAvqDFkUBsN89DYZZIuhqebazSP86XT7ttHWIQUVMxk9TnC97OM41wodz5ALW3srWJ8 5d+v+Kkpj4bjrJB5RMJml8b8RHA17KMsJwASub9hf7ldBQbe2GfEkQIRkt9fFlj6I8mghIMpuJk kSd4n6TCDdiHCdv5bPP54EZWLe1nXjo1f+MXGQqfCoSGwAC1vX34kN6vrvTWJKyN2jFEJhEXOKg aNQnhWAUt5hGcK85rQ= X-Received: by 2002:a17:907:c81a:b0:c21:726b:34eb with SMTP id a640c23a62f3a-c260c7ad2e2mr1393559666b.8.1788966525397; Wed, 09 Sep 2026 08:08:45 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 10/20] xen/riscv: introduce aia_init() and aia_usable() Date: Wed, 9 Sep 2026 17:07:28 +0200 Message-ID: <38e822dac4d22a8f8348b54a8d0f7dff9187b904.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1788966525-FDA0C77B-CC68EF0F/10/73395122804 X-purgate-type: spam X-purgate-size: 3240 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966559363158500 Content-Type: text/plain; charset="utf-8" aia_init() is going to contain all the logic related to AIA initialization. At the moment, it only checks whether the SSAIA extension is available, and if so, sets is_aia_usable (which indicates more than just the availability of the extension) to true; it also signifies that the necessary components (to be introduced in follow-up patches) have been initialized. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v6-9: - Nothing changed. Only rebase. --- Changes in v5: - Update the guards in asm/aia.h according to CODING_STYLE: s/ASM__RISCV__AIA_H/RISCV_AIA_H. --- Changes in v4: - Add Acked-by: Jan Beulich --- Changes in v3: - s/is_aia_usable/_aia_usable to drop the is_ prefix while avoiding conflict with the aia_usable() function name. --- Changes in v2: - s/is_aia_available/is_aia_usable. - Drop return value for aia_init(). - s/aia_available()/aia_usable(). --- --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/aia.c | 23 +++++++++++++++++++++++ xen/arch/riscv/include/asm/aia.h | 10 ++++++++++ xen/arch/riscv/intc.c | 3 +++ 4 files changed, 37 insertions(+) create mode 100644 xen/arch/riscv/aia.c create mode 100644 xen/arch/riscv/include/asm/aia.h diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 2d24670dfc74..8e7a6370eee2 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,3 +1,4 @@ +obj-y +=3D aia.o obj-y +=3D aplic.o obj-y +=3D cpufeature.o obj-y +=3D domain.o diff --git a/xen/arch/riscv/aia.c b/xen/arch/riscv/aia.c new file mode 100644 index 000000000000..e31c9c2d24b6 --- /dev/null +++ b/xen/arch/riscv/aia.c @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +#include + +static bool __ro_after_init _aia_usable; + +bool aia_usable(void) +{ + return _aia_usable; +} + +void __init aia_init(void) +{ + if ( !riscv_isa_extension_available(NULL, RISCV_ISA_EXT_ssaia) ) + return; + + _aia_usable =3D true; +} diff --git a/xen/arch/riscv/include/asm/aia.h b/xen/arch/riscv/include/asm/= aia.h new file mode 100644 index 000000000000..aaa4bf91fc75 --- /dev/null +++ b/xen/arch/riscv/include/asm/aia.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef RISCV_AIA_H +#define RISCV_AIA_H + +bool aia_usable(void); + +void aia_init(void); + +#endif /* RISCV_AIA_H */ diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index e63da5e22efc..2864a896b677 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -9,6 +9,7 @@ #include #include =20 +#include #include =20 static const struct intc_hw_operations *__ro_after_init intc_hw_ops; @@ -33,6 +34,8 @@ void __init intc_init(void) { ASSERT(intc_hw_init_ops && intc_hw_init_ops->init); =20 + aia_init(); + if ( intc_hw_init_ops->init() ) panic("Failed to initialize the interrupt controller drivers\n"); } --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966550; cv=none; d=zohomail.com; s=zohoarc; b=ZWWqCEKF8YmaCga4UI/Eb6pFeqtYkbQAVx6hdlxEfraNFcGsqRAlZ/ITmAWvMY1UbQOglc2tv1+YP+CPw61PHaE6TClEaDAofDcifSHAsrfyQ3kAH55pem1wTKaSBL4otCmiNRsGrZEXNg/ABDjgWZnR1QVzlt6gfadEtBOUlS8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966550; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w/c0Ov9Mx+pVjgOHFwnnwfC8nzGn8agSgog6oIobVXU=; b=mRlOba4lUsAhYSAf3PW1UB90Jk6g6SEDDT4XuQVRqlbhhj2DGN4PhbbWy9s4fpfapxO0ZbuUy/iojin79o6bseVyPG9ad2OG0eibPoGiHVdJajcP2qQrPZbxV++id4hv51szH4CDGpV8Fk1xw0v5qefIWx2+U9InyieqDnsR60A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966550830537.843690414496; Wed, 9 Sep 2026 08:09:10 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413280.1643545 (Exim 4.92) (envelope-from ) id 1x4Jus-0003hc-0q; Wed, 09 Sep 2026 15:08:50 +0000 Received: by outflank-mailman (output) from mailman id 1413280.1643545; Wed, 09 Sep 2026 15:08:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Jur-0003hS-U9; Wed, 09 Sep 2026 15:08:49 +0000 Received: by outflank-mailman (input) for mailman id 1413280; Wed, 09 Sep 2026 15:08:49 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Juq-0003SN-SI for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jup-007z99-TZ for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:47 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17668-8faa-0a2a0a5109dd-0a2a450cbeca-38 for ; Wed, 09 Sep 2026 17:08:47 +0200 Received: from [209.85.218.45] (helo=mail-ej1-f45.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa1767f-f479-0a2a450c0019-d155da2de946-3 for ; Wed, 09 Sep 2026 17:08:47 +0200 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c1670dad7a8so965968466b.3 for ; Wed, 09 Sep 2026 08:08:47 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:47 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966527; x=1789571327; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=w/c0Ov9Mx+pVjgOHFwnnwfC8nzGn8agSgog6oIobVXU=; b=Yf3hNfrCXlL3KsMPBBIiT2PvxEYMaSIZX6cJzDvN6G9J1f8yRujOd/1jGA1qw+37Hi 5WrXsaVjU+uwQmPzA1qdK7oV3ar+7BT16klwDDzosS6r36jpE24GH7B/C1nlRqjb0Gpl GZS+by6eUHGG3u8YOHA4cdc0d2a0WhVyFHtegCR97xcvCZXW8bg2b2ymHkb3wTZSW+fG d8O5q90NHS/BobMjUnISTPot+Bg7D+G0XxXYJV61GGBJdjhDqpvZU6irxuUJCinvtPM3 HzqsuaoPV1ZQY5wkpc0xXhUAtnX+DPLsWoj/VcFSB/eQgb0wqrviUpT8UwgQ6FoE1fPK rRcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966527; x=1789571327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=w/c0Ov9Mx+pVjgOHFwnnwfC8nzGn8agSgog6oIobVXU=; b=PGLcnsClMaGphpDiB41uFmIBCqv6AeljnkCqb3T26w23mnGgEI8YuG5Br4zkPlcGkY 4KW41pX5ZDU3WAOun9VZHZq+3Ri4wFOKxTi+5l+2vIq/rJTLvNlzsjBVNXQJpUJLNyk0 QVFw1EbB4+Ri2IKPapVEGH+yzVFIMCXntoua30s0PxBioD2dCY3fUbc6AHOF3YzvKlnv +WzBrrY5jFH+SeG1lyOh0URyJ26JiC9hg1Co6qb3eyrj2x70h21NKpkPbTaC7GbC24lQ X+rT1N93JAt+q6jvNGPRrE/Cu0Jz6G6yz5PBtI27OBxiMbwmMcftth/sn04FHlS2Jm1T fmYg== X-Gm-Message-State: AFuF++nGGoDnB3si7bnJLHnCa3n9SneVn3DwiXLwSCj7Wnkgv7iwVpBt tY+wnR6gfo8SOqosx4ZydycASLOkz2V1nnjMJrTKgxbD1kQQVbeSvEEeZrEyq10S X-Gm-Gg: AYBFou3oXRpO7SFqpFFHjxtugz6HxrP5CqYoletnLkmWS9mPyI84aHUHT0OIpHU3KRZ 6Aabe9JrV3jc3l3tdpGrZQ/2LphCnnIqLbaE9l1nUA5TgXySWtmUJUD6y04aAMJLpzAZ9ahxxfS P8bhOkYLOkyQJft/Ng5IR+OAhrZ/gXVrtEgYcFCYujpz/GzsS8HgL7bySdbTqujTkOx+q3DID/l ifleLAHsT3HQ+vsCk5Evs45lcGWFhmvcCILJLJjOE+hHmTSr9rH0AxgobkmVmgx4JD9tkdv3n1E V083WFQwuK9sX7tkPGcsDmr0J8odSfFqTmwyEdOEsx3uwL8gQ3+ywyRv5MTc9XrbUpvHLkZAY/i X0SI/Ml6iakppWqiav5M3I/7gjd4b5Z0SV6aGObH8dgikdC6ir4FA68xxOp1dgd9YzySSbyqcPa rBOiUlfw7WAjOhcAE5+URVZUXgcJn5NAvlCKhXV2xRHLg+0Riw5pWhMNG+U18/AeACrLtdZusJD ertbO0wtnq9qmStjRo= X-Received: by 2002:a17:907:3e90:b0:c29:448b:f5d0 with SMTP id a640c23a62f3a-c29448bfc23mr14248766b.33.1788966527314; Wed, 09 Sep 2026 08:08:47 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 11/20] xen/riscv: introduce per-vCPU IMSIC state Date: Wed, 9 Sep 2026 17:07:29 +0200 Message-ID: <630876d9cfd6ba0917c430bfd4ff03d997e7880d.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1788966527-76ADCA5B-DB51CAA7/10/73395122804 X-purgate-type: spam X-purgate-size: 6651 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966551377158500 Content-Type: text/plain; charset="utf-8" Each vCPU interacting with the IMSIC requires state to track the associated guest interrupt file and its backing context. Introduce a per-vCPU structure to hold IMSIC-related state, including the guest interrupt file identifier and the CPU providing the backing VS-file. Access to the guest file identifier is protected by a lock. Initialize this structure during vCPU setup and store it in arch_vcpu. The initial state marks the VS-file as software-backed until it becomes associated with a physical CPU. Add helper to retrieve the guest interrupt file identifier: - vcpu_guest_file_id() is going to be used during update of APLIC's target register with the pair of information (to have MSI delivery mode work properly) when guest is trying to access vAPLIC's target register. It will be used in the follow up patches. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v9: - Nothing changed. Only rebase. --- Change in v8: - Rename imsic_state->vsfile_pcpu to ->*_cpu to reflect better its sentinel NR_CPUS. --- Changes in v6-7: - Nothing changed. Only rebase. --- Changes in v5: - Move v->arch.vimsic_state =3D imsic_state; after full initialization of the struct, so the pointer only becomes globally visible once all fields are set up. - Add Acked-by: Jan Beulich . --- Changes in v4: - s/w vs h/w IMSIC VS-file commentary for struct vimsic_state: - fix the vsfile_pcpu h/w condition: "vsfile_pcpu >=3D 0" -> "vsfile_pcpu < NR_CPUS" (the old wording conflicted with the s/w "=3D=3D NR_CPUS" case). - reorder both comment blocks to the "s/w ... / h/w ..." form for readab= ility. - drop IMPOSSIBLE_GUEST_FILE_ID: the s/w IMSIC VS-file is always available and corresponds to guest_file_id =3D=3D 0, which xvzalloc() already prov= ides, so the explicit initializer in vcpu_imsic_init() and the macro itself are unneeded. --- Changes in v3: - Drop const from imsic_set_guest_file_id() and vcpu_imsic_deinit() as it only works due to vimsic_state being a pointer member. - Use XVFREE() in vcpu_imsic_deinit() to make it idempotent. - Fix SW-file typo in struct vimsic_state comments; should be VS-file. - Drop imsic_set_guest_file_id() here, it will be added later when it will be nessary to initialise guest file id as the correspondendt code in this patch series was reworked and there is no need to use this function in arch_vcpu_create(). - Introduce IMPOSSIBLE_GUEST_FILE_ID and init with it ->guest_file_id. --- Changes in v2: - Rename imsic_state to vimsic_state. - Use 'unsigned int' for vsfile_pcpu. - Drop initialzation of ->guest_file_id as it will be by default zero. - Add the comment about ->guest_file_id field. - Drop __init for vcpu_imsic_init() as it could be used during post-boot vCPU creation. - Update the commit message. - Drop locks around ->guest_file_id() in vcpu_guest_file_id() and imsic_s= et_guest_file_id(). --- --- xen/arch/riscv/imsic.c | 35 +++++++++++++++++++++++++++++ xen/arch/riscv/include/asm/domain.h | 2 ++ xen/arch/riscv/include/asm/imsic.h | 22 ++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 8da72c007225..4a2ef5069d0c 100644 --- a/xen/arch/riscv/imsic.c +++ b/xen/arch/riscv/imsic.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,11 @@ do { \ csr_clear(CSR_SIREG, v); \ } while (0) =20 +unsigned int vcpu_guest_file_id(const struct vcpu *v) +{ + return ACCESS_ONCE(v->arch.vimsic_state->guest_file_id); +} + void __init imsic_ids_local_delivery(bool enable) { if ( enable ) @@ -312,6 +318,35 @@ static int imsic_parse_node(const struct dt_device_nod= e *node, return 0; } =20 +int vcpu_imsic_init(struct vcpu *v) +{ + struct vimsic_state *imsic_state; + + /* Allocate IMSIC context */ + imsic_state =3D xvzalloc(struct vimsic_state); + if ( !imsic_state ) + return -ENOMEM; + + /* Setup IMSIC context */ + rwlock_init(&imsic_state->vsfile_lock); + + /* + * xvzalloc() already cleared the context, so guest_file_id =3D=3D 0, = i.e. the + * always-available s/w IMSIC VS-file. Only vsfile_cpu needs an explic= it + * initializer as its s/w VS-file value is NR_CPUS rather than 0. + */ + imsic_state->vsfile_cpu =3D NR_CPUS; + + v->arch.vimsic_state =3D imsic_state; + + return 0; +} + +void vcpu_imsic_deinit(struct vcpu *v) +{ + XVFREE(v->arch.vimsic_state); +} + /* * Initialize the imsic_cfg structure based on the IMSIC DT node. * diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index bd43ed08c22c..e035b33ddfdc 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -54,6 +54,8 @@ struct arch_vcpu { =20 struct vtimer vtimer; =20 + struct vimsic_state *vimsic_state; + register_t hcounteren; register_t hedeleg; register_t hideleg; diff --git a/xen/arch/riscv/include/asm/imsic.h b/xen/arch/riscv/include/as= m/imsic.h index c6c59215df20..5ee954bbf3ef 100644 --- a/xen/arch/riscv/include/asm/imsic.h +++ b/xen/arch/riscv/include/asm/imsic.h @@ -11,6 +11,7 @@ #ifndef ASM_RISCV_IMSIC_H #define ASM_RISCV_IMSIC_H =20 +#include #include #include #include @@ -61,7 +62,24 @@ struct imsic_config { spinlock_t lock; }; =20 +struct vimsic_state { + /* IMSIC VS-file */ + rwlock_t vsfile_lock; + /* + * s/w IMSIC VS-file -> guest_file_id =3D=3D 0 + * h/w IMSIC VS-file -> guest_file_id > 0 + */ + unsigned int guest_file_id; + /* + * s/w IMSIC VS-file -> vsfile_cpu =3D=3D NR_CPUS + * h/w IMSIC VS-file -> vsfile_cpu < NR_CPUS + */ + unsigned int vsfile_cpu; +}; + struct dt_device_node; +struct vcpu; + int imsic_init(const struct dt_device_node *node); =20 const struct imsic_config *imsic_get_config(void); @@ -71,4 +89,8 @@ void imsic_irq_disable(unsigned int hwirq); =20 void imsic_ids_local_delivery(bool enable); =20 +int vcpu_imsic_init(struct vcpu *v); +void vcpu_imsic_deinit(struct vcpu *v); +unsigned int vcpu_guest_file_id(const struct vcpu *v); + #endif /* ASM_RISCV_IMSIC_H */ --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966564; cv=none; d=zohomail.com; s=zohoarc; b=ecywgKn4jmq5NH9a/FubsiryL6js9N3WXMWH8ARXoeEyINhV42uxzr871EPl8yI6sjRImQcUCmWodRXDNG+CiWFDB88UPThS2hv2zQq7W7GVeCDLglduafxf3O/vqGyb/fvUxO5mBW2WoUnFpGCRUVj+o2lN8q9/OwXJ6cgfJSw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966564; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dt+oJbLlbJOl272w2oSgdeAx/VzdS+DDC/2pUVZckDs=; b=fcX9A/i1JUUjlIckDQS+8M+Ffoxc9whYJRs3eZQMynOKobB8yqvo1mnNAEuCH3OsFtOJ1SC2zSfTAop5qjtIm2Qo4kOHzd9DQK9zcnw2Ys0rWn/xQ7k1Qsu64kBBT7kZZH2eSuwrt6ypk+bcLwm03ZXbvrtKkeUG7OUjD83xx04= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966564890713.7955421461228; Wed, 9 Sep 2026 08:09:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413281.1643554 (Exim 4.92) (envelope-from ) id 1x4Juu-0003zJ-7Z; Wed, 09 Sep 2026 15:08:52 +0000 Received: by outflank-mailman (output) from mailman id 1413281.1643554; Wed, 09 Sep 2026 15:08:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Juu-0003z8-3a; Wed, 09 Sep 2026 15:08:52 +0000 Received: by outflank-mailman (input) for mailman id 1413281; Wed, 09 Sep 2026 15:08:51 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Jus-0003ra-VY for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jus-00DoNW-CD for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:50 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17680-e002-0a2a0a5209dd-0a2a45048b98-12 for ; Wed, 09 Sep 2026 17:08:50 +0200 Received: from [209.85.218.46] (helo=mail-ej1-f46.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17681-b57f-0a2a45040019-d155da2ed9b8-3 for ; Wed, 09 Sep 2026 17:08:49 +0200 Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c255c58156bso1230116666b.3 for ; Wed, 09 Sep 2026 08:08:49 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966529; x=1789571329; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Dt+oJbLlbJOl272w2oSgdeAx/VzdS+DDC/2pUVZckDs=; b=HuAUpCbos4lRFB/J4xlcz5OHPjwi6dJTZ2LdcaqS/jtojHTrsiX4aQ8BSQ+K88RyCY gkQWXGQf0uxh3KgAc5lQEM+M8LbKp7FfyA/CEnxchQwov3oWlc7BMmpzMhsJjMgUAx6B JWnW4v3kIMzlQKsnn/Lsj43FEKRuHWvQuOxURFXxATfbCaKtyujVShXvqC7qTENfU2Ux GwuzICfLP2mpl+lZIKCnz+oaF3JZolusN0zuBmDbeWjDSH1RXJCCaPhpeF5PsfVk3t8H 5CAq7y4z7EHdxVbtu+h5ut0mRMsXvAy0jvxyHgH39x6wDIOpBDLYYD8M+QW5HZF4AEYp iBsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966529; x=1789571329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Dt+oJbLlbJOl272w2oSgdeAx/VzdS+DDC/2pUVZckDs=; b=No5rS1RqeeHTXdw8UixBNHCdnwGxDg3WhHHyzoUkL8iW0lxZDjzDWZlBTl3SfqQm0X mq+c2iMY4p/a8iapfId+N908YFVqjyI9s7fqajGPYULSZOLeYlzICnY30XmNioH7JbTj Zv6iWxMEWnWd7XEoA23tiJN40LwHWZ7oBQVRs+f9vl0Gb/dkVUbokbijtyO7smowLfZ3 kknx26CnzkApBTUc0yOrBxk4JcfCeg/Y2/GBxIpg6BHy0aOtD2gmIXxrQreJC2zodaGK 3LuOOaP0uRc+Hn6mKf9GwzJkq9bMbwRVyE5kPV2ZzOS2nR5cNAvWXFIFaxliM3z/8Nx5 hzew== X-Gm-Message-State: AFuF++lhXknTGnHfIAAXNCGdnAQLx5e8VZpYHIlgAkjTkkiXFbqLrEHP Oeqi+4DihaXuYyY14FR5E4G2VELdalOoJB/nGtgGJTOLEkRvSRKCG4riEVD4EDWk X-Gm-Gg: AYBFou0+COdw4Sn2jRA9SBTumHmuW8fHzK3IIJeXTmNVTg5PMAvbPLeJhXVmEkfBNOi Kic9d8bNYjxit3p7b0QY3ULaR/Io+cwWqGAbd4QLoPJ1wO6cUs+iGMp3KqpDCrZ+U01MXiCeMeE jXn3R3IlcU4x0zm13l7d1px4AkRMl+vE5kxmea+6FCvrcrr6Jx94UU+SebjPtyuIJG4HdG8gegc FrfrkgjoZq9wAazpHi6mpLJ99Gl2ZSt1PdnQfVyD+VRUcAFnDJR6LSZj7l8bZIxIdBnk9kVQb1M CNkEVYhke7zD0FW/e7rUuJGaXCTYZfbWSFH5ODwxaS2LbQ+lPDMTXAe70alXtPUF6TKXztrFM9P xuE0xiJPran90lgm92ardK6TDQLSX5WmYE2KIquX4VdXtlwhKNTyzUsgCTfxz80sqTsQzpP4Tw8 71baRLTwDwkjuMrm61Eh65Amwp+auPOZMaZTjeEuEvvzFPzIw0XlwbA5ZTTSxoAqzTwGMUt4CrT FCxLhFg+KNaNAJcfEmPMmNWZDqaUw== X-Received: by 2002:a17:907:d90:b0:c24:6985:d7a1 with SMTP id a640c23a62f3a-c260c7aa1d2mr1326746266b.7.1788966529239; Wed, 09 Sep 2026 08:08:49 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 12/20] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Date: Wed, 9 Sep 2026 17:07:30 +0200 Message-ID: <2317c9e591944d29f77d5759f2b4c7570186e6cf.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1788966529-508D9B50-9E6824E9/10/73395122804 X-purgate-type: spam X-purgate-size: 10434 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966565531158500 Content-Type: text/plain; charset="utf-8" At the current development stage, only domain vINTC init and deinit operations are required, so implement those first. Initialize vAPLIC's domaincfg to with the interrupt-enable bit set and MSI delivery mode selected as the current solution is exepcted to have always IMSIC, and initialize vintc->ops. Other operations such as emulate_load(), emulate_store(), and is_access() will be needed once guests are running and MMIO accesses to APLIC MMIO range must be handled. These will be introduced separately later. Introduce a structure to describe a virtual interrupt controller (vINTC) and a vintc_ops structure, which provides operations to emulate load and store accesses to interrupt controller MMIOs and to check whether a given address falls within the MMIO range of a specific virtual interrupt controller. Note that already existed init_ops field in struct vintc will be init-ed for APLIC in the follow up patch. The vAPLIC implementation of these operations will be provided later once guests can be run and these operations are actually needed. Introduce these structures here as they are required for the implementation of domain_vaplic_init() and domain_vaplic_alloc(). Also, introduce vaplic_init() and init vintc_ops->vcpu_init() with it. Co-developed-by: Romain Caritey Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v9: - Nothing changed. Only rebase. --- Changes in v8: - Drop vaplic_init() and vcpu_imsic_deinit() as they are just calling IMSIC related files as we are expecting to work only MSI mode. - And add cf_check for vcpu_imsic_(de)init as they are directly used now for vintc_ops->vcpu_(de)init. --- Changes in v7: - Add Acked-by: Jan Beulich . - Update the comment above init_ops member of vintc structure. --- Changes in v6: - Nothing changed. Only rebase. --- Changes in v5: - Add explanational comments for fields in struct vintc. - Drop unnessary empty line in asm/aplic.h. - Update the commit message to tell that init_ops will be init-ed later in follow up patch. - Init. .domaincfg with only APLIC_DOMAINCFG_RO. - Update the comment above APLIC_DOMAINCFG_RO. - Add defintion for APLIC_DOMAINCFG_BE. --- Changes in v4: - Change subject of the commit. - s/APLIC_DOMAINCFG_RO80/APLIC_DOMAINCFG_RO + added a comment above defini= tion. - Drop unnessary blank lines. --- Changes in v3: - Drop ASSERT() before vintc->ops->vcpu_init() in arch_vcpu_create(); a NULL deref already produces a sufficient backtrace. - Parenthesize macro argument in to_vaplic(). - Drop __init from domain_vaplic_init() and domain_vaplic_deinit() since the caller domain_vintc_init() (follow-up patch) is not __init. - Remove pointless zero-initializer for rc in vcpu_vaplic_init(). - Fix domain_vaplic_deinit() to null d->arch.vintc before freeing, making the function idempotent. - Drop intc_irq_nums(), (*nr_irqs)(void) hook from intc_hw_operations, aplic_nr_irqs(), and vintc->nr_irqs field entirely. - Rename vcpu_vaplic_init() to vaplic_init() and drop vgein_assign() and imsic_set_guest_file_id() calls; those will be introduced/called later, where for sure we will know on which pCPU vCPU as it is required for proper h/w IMSIC interrupt file calculation, to have this initialization in one place. - Introduce vaplic_deinit(). --- Changes in v2: - s/vcpu/v for function arguments in struct vintc_ops(). - Update the comment above is_access() and drop const for addr argument. - Update to_vaplic() to work with 'struct domain *'. - Drop smsiaddrcfg{h} from vaplic_regs struct as they aren't used for now. - Drop inclusion of xen/schec.h from intc.c. - use result of xvzalloc() as initializer in vpalic_alloc(). - Drop goto in domain_vaplic_init(). - s/XVFREE/xvfree. - s/aplic/vintc. - Drop __init for vcpu_vaplic_init() as it could be called for secondary C= PU bring up. - Drop vaplic_alloc(). - Drop vintc_ops struct, embed callbacks iniside struct vintc. - Introduce and init vintc irqs for vAPLIC. - Introduce intc_irq_nums() to properly initialize number of vAPLIC's irqs. --- --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/domain.c | 11 ++---- xen/arch/riscv/imsic.c | 4 +-- xen/arch/riscv/include/asm/aplic.h | 7 ++++ xen/arch/riscv/include/asm/intc.h | 12 +++++++ xen/arch/riscv/include/asm/vaplic.h | 34 +++++++++++++++++++ xen/arch/riscv/vaplic.c | 52 +++++++++++++++++++++++++++++ 7 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 xen/arch/riscv/include/asm/vaplic.h create mode 100644 xen/arch/riscv/vaplic.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 8e7a6370eee2..fcd73c7a2dd5 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -25,6 +25,7 @@ obj-y +=3D smpboot.o obj-y +=3D stubs.o obj-y +=3D time.o obj-y +=3D traps.o +obj-y +=3D vaplic.o obj-y +=3D vmid.o obj-y +=3D vm_event.o obj-y +=3D vsbi/ diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index c9933147595e..45712d305975 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 @@ -155,14 +156,8 @@ int arch_vcpu_create(struct vcpu *v) if ( (rc =3D vcpu_vtimer_init(v)) ) goto fail; =20 - /* - * As interrupt controller (IC) is not yet implemented, - * return an error. - * - * TODO: Drop this once IC is implemented. - */ - rc =3D -EOPNOTSUPP; - goto fail; + if ( (rc =3D v->domain->arch.vintc->ops->vcpu_init(v)) ) + goto fail; =20 return rc; =20 diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 4a2ef5069d0c..809f29af860a 100644 --- a/xen/arch/riscv/imsic.c +++ b/xen/arch/riscv/imsic.c @@ -318,7 +318,7 @@ static int imsic_parse_node(const struct dt_device_node= *node, return 0; } =20 -int vcpu_imsic_init(struct vcpu *v) +int cf_check vcpu_imsic_init(struct vcpu *v) { struct vimsic_state *imsic_state; =20 @@ -342,7 +342,7 @@ int vcpu_imsic_init(struct vcpu *v) return 0; } =20 -void vcpu_imsic_deinit(struct vcpu *v) +void cf_check vcpu_imsic_deinit(struct vcpu *v) { XVFREE(v->arch.vimsic_state); } diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/as= m/aplic.h index b0724fe6f360..5a7fcb6ec4f1 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -15,8 +15,15 @@ =20 #include =20 +/* + * domaincfg read-only fields (AIA spec): + * - bits [31:24] -> read-only 0x80 + * - bit 7 -> read-only 0 + */ +#define APLIC_DOMAINCFG_RO (0x80U << 24) #define APLIC_DOMAINCFG_IE BIT(8, U) #define APLIC_DOMAINCFG_DM BIT(2, U) +#define APLIC_DOMAINCFG_BE BIT(0, U) =20 #define APLIC_SOURCECFG_SM_INACTIVE 0x0 #define APLIC_SOURCECFG_SM_DETACH 0x1 diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index a4e678fad90b..875728885292 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -17,6 +17,7 @@ enum intc_variant { struct cpu_user_regs; struct irq_desc; struct kernel_info; +struct vcpu; =20 struct intc_info { enum intc_variant hw_variant; @@ -53,8 +54,19 @@ struct vintc_init_ops { int (*make_domu_dt_node)(struct kernel_info *kinfo); }; =20 +struct vintc_ops { + /* Initialize some vINTC-related stuff for a vCPU */ + int (*vcpu_init)(struct vcpu *v); + + /* Deinitialize some vINTC-related stuff for a vCPU */ + void (*vcpu_deinit)(struct vcpu *v); +}; + struct vintc { + /* Callbacks invoked during domain construction only. */ const struct vintc_init_ops *init_ops; + /* Runtime callbacks used for the lifetime of the guest. */ + const struct vintc_ops *ops; }; =20 void intc_preinit(void); diff --git a/xen/arch/riscv/include/asm/vaplic.h b/xen/arch/riscv/include/a= sm/vaplic.h new file mode 100644 index 000000000000..96080bfbc23b --- /dev/null +++ b/xen/arch/riscv/include/asm/vaplic.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: MIT */ +/* + * xen/arch/riscv/vaplic.c + * + * Virtual RISC-V Advanced Platform-Level Interrupt Controller support + * + * Copyright (c) Microchip. + */ + +#ifndef ASM__RISCV__VAPLIC_H +#define ASM__RISCV__VAPLIC_H + +#include +#include + +#include + +struct domain; + +#define to_vaplic(d) container_of((d)->arch.vintc, struct vaplic, vintc) + +struct vaplic_regs { + uint32_t domaincfg; +}; + +struct vaplic { + struct vintc vintc; + struct vaplic_regs regs; +}; + +int domain_vaplic_init(struct domain *d); +void domain_vaplic_deinit(struct domain *d); + +#endif /* ASM__RISCV__VAPLIC_H */ diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c new file mode 100644 index 000000000000..c9f188b989a3 --- /dev/null +++ b/xen/arch/riscv/vaplic.c @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: MIT */ +/* + * xen/arch/riscv/vaplic.c + * + * Virtual RISC-V Advanced Platform-Level Interrupt Controller support + * + * Copyright (c) Microchip. + * Copyright (c) Vates + */ + +#include +#include +#include + +#include +#include +#include +#include + +#include "aplic-priv.h" + +static const struct vintc_ops vintc_ops =3D { + .vcpu_init =3D vcpu_imsic_init, + .vcpu_deinit =3D vcpu_imsic_deinit, +}; + +int domain_vaplic_init(struct domain *d) +{ + struct vaplic *vaplic =3D xvzalloc(struct vaplic); + + if ( !vaplic ) + return -ENOMEM; + + d->arch.vintc =3D &vaplic->vintc; + d->arch.vintc->ops =3D &vintc_ops; + + vaplic->regs.domaincfg =3D APLIC_DOMAINCFG_RO; + + return 0; +} + +void domain_vaplic_deinit(struct domain *d) +{ + struct vaplic *vaplic; + + if ( !d->arch.vintc ) + return; + + vaplic =3D to_vaplic(d); + d->arch.vintc =3D NULL; + xvfree(vaplic); +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966552; cv=none; d=zohomail.com; s=zohoarc; b=XSgF83SbPTfxpGjqsKz4pfx0u5AU6Pv6/9FlucM2n5iskb4ym5fkx/SRTDK9ywDU7NAu1HOlS9nViaLJcq6iAgbKltPMvd6Rko0EQ5F9UEjOnn/3kBCGHbd/m8/71f9W7JvbNAtVm7iibeMbc5oxXBanXXoVPgi/Kqg2/hlnwvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966552; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XBmqn5QW1wcqH90/ZG0vHM4CgtbXqvupt8SmP6XIcus=; b=HptiOKt5zewhB5iAXep9e3usZ5A6CvlBUPXgMEs2KUs5MuIjMRKozuNJcIHJzNvrNe8RmnCZB8snYnuUv0Z6tqk8VfeXniz/XcljGtBlon2cJDj8AFl7pSqSRjruK4iXrEg/bKraG/e0fq7jogogGvhy4qSsOF9SWHH+LFox9NM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966552868499.20053622898365; Wed, 9 Sep 2026 08:09:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413284.1643563 (Exim 4.92) (envelope-from ) id 1x4Juv-0004F1-H9; Wed, 09 Sep 2026 15:08:53 +0000 Received: by outflank-mailman (output) from mailman id 1413284.1643563; Wed, 09 Sep 2026 15:08:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Juv-0004Eq-DU; Wed, 09 Sep 2026 15:08:53 +0000 Received: by outflank-mailman (input) for mailman id 1413284; Wed, 09 Sep 2026 15:08:52 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Juu-0003yx-6p for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jut-007z99-Jn for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:51 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17682-8faa-0a2a0a5109dd-0a2a450c8274-2 for ; Wed, 09 Sep 2026 17:08:51 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17683-f479-0a2a450c0019-4a7de48c9210-3 for ; Wed, 09 Sep 2026 17:08:51 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c294496989aso15911166b.3 for ; Wed, 09 Sep 2026 08:08:51 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966531; x=1789571331; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XBmqn5QW1wcqH90/ZG0vHM4CgtbXqvupt8SmP6XIcus=; b=NZsNTGh80mlwrtH2WIm2Z+8QvqQhqheAerJa0op/12z2uUpkFGimIqnpTP0s8qJmtk 12hUKIMIoatn28V7Jgz8BDV4TmZD/ClcgQ9Uw7HrhGwCUqOgB7PMJRVaU/HXgTZY6FsP trbbUXzAoKKzpr7eEqb8L3kczfDAtbR+3jX1Y8ZyIyaOuB1LWJbZR7rGqrY2hvkijAfN RBadKHfLZUiNxCuuieASXfcH91YnmHqRZSQ+ITPSU6A7ZM7cEHk/4LDVQ+j+DSaQjyFg 7wfD107cOI5/oyH1m1JfZWvFSIexFXobwuNNfo7PraAIP8MGwrimPsZ7rvM+IccaoIen K+9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966531; x=1789571331; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XBmqn5QW1wcqH90/ZG0vHM4CgtbXqvupt8SmP6XIcus=; b=LzaVE5MtE70gHZtyMxWRYkF2hyuEhQf5eQ1Vz5lyEbBCysbjBvqGblH8O31TdD1rqL 4e+/ZhuspbSw1M3xSDYFgMJ685IPpnqq1+xlf58l/Vn3znD1mexWHj0tKgRqGfIZQ9AD LCm3EmFdtzFAxz171mR8IS56cUpiqGRP+l/ABvTvmVzX29RSiXf1Qq5b60fbi3qFNaqL /gCQynDirjGOyU4hW2FzLbm14Ad9/U4YQMxZnnU9tCSfkMHYJdUHoQnsof0bzGJlaWhm 6AjC2g3cQOsxMmYKF6zn486g3+85vDi97bxTs2n4Yi9clhvo/gOezOs2uT7vLHKd5fWs gVnw== X-Gm-Message-State: AFuF++ngALNpHhJm8Ni9dblpLNjoAIZ8XM+fNX9Gkm7qCIwEtilPtgOd yxQho2h5RL7qib6MJowVRxKNO4ATth02DkE0uJVEjFoUVkzNekZSx7bTvTdpxon/ X-Gm-Gg: AYBFou0O06SpyLSIRg272zvXlRtyeLDuwaMTE+jnCoKgd1uNPYPdbEigGXW6q/fAyB5 S+QPD2MHVDImZUJ66Sy+6pmcZ/mrYIqsBJWUjjf8hHhUP98xFpcD2wfYszEOiT1Ap63KIDTkQnK N+0up77wfKZ9wLOX5fH+bqcOC6U/tqQ55k3PmPtwHe8CFup6BhwmvjS7nLJ9plJiejCF1QjlkgX fCQGUKwtrvFfCXhvJNaz8H5gB+gKEp4C1zVSmv+Fuh/Mwl7N1Urj3fViruDa7I/ko8KsxJuKAZt LfA1g7DIwkDYZa1HkNbi37sQLHQq8zKn9LxGEuOhExnOzt3Mw8N81EWKjzYWiT+mCSVt5PL7OXy WMitO00HpeFRYafcSqutvtGjgVK+V2fOXx5Axg6+1NP+Lz6PVK4VG4NoNmWq/vKUXYguQvAVw4Y KuRC1qimFPrixyavk4zwFTWucvRmXYE+bTApfqgA700t91zLOheCKwIc2WgPfWc+WnxcMDkWh2N AbcShW2NpcqqUGKGZ4= X-Received: by 2002:a17:907:c244:b0:c26:1648:a076 with SMTP id a640c23a62f3a-c2941be4cc7mr63914866b.49.1788966530979; Wed, 09 Sep 2026 08:08:50 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 13/20] xen/riscv: introduce (de)initialization helpers for vINTC Date: Wed, 9 Sep 2026 17:07:31 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1788966531-768DDA5B-AB41261D/10/73395122804 X-purgate-type: spam X-purgate-size: 4217 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966553427158500 Content-Type: text/plain; charset="utf-8" Add common helpers domain_vintc_init() and domain_vintc_deinit() to allocate and deallocate a virtual interrupt controller (vINTC) structure and initialize basic virtual interrupt controller registers. domain_vintc_deinit() isn't called at the moment as arch_domain_destroy() is implemented as stub at the moment. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v9: - Add Acked-by: Jan Beulich . --- Changes in v8: - Add call of domain_vintc_deinit() to arch_domain_destroy(). - Update printk message. - Drop Acked-by. --- Changes in v6-7: - Nothing changed. Only rebase. --- Changes in v5: - s/printk/printk_once(). - Add Acked-by: Jan Beulich . --- Changes in v4: - Drop the comment from domain_vintc_init() about guests receiving a virtual interrupt controller that mirrors the host hardware as there can (and eventually should) be alternatives. - Finish renaming intc_version to intc_variant in domain_vintc_(de)init() (enum intc_variant, info->hw_variant, local variable) started in the prev patch. --- Changes in v3: - Drop redundant printk() from domain_vintc_deinit()'s default case to avoid duplicate messages when init fails. - Add a comment to domain_vintc_init() clarifying that guests currently receive a virtual interrupt controller that mirrors the host hardware. --- Changes in v2: - Drop __init for domain_vintc_(de)init(). - Update the commit message. --- --- xen/arch/riscv/domain.c | 7 ++++++- xen/arch/riscv/include/asm/intc.h | 3 +++ xen/arch/riscv/intc.c | 35 +++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index 45712d305975..d94652809e36 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -291,7 +291,9 @@ int arch_sanitise_domain_config(struct xen_domctl_creat= edomain *config) =20 void arch_domain_destroy(struct domain *d) { - printk(XENLOG_WARNING "%s: unimplemented\n", __func__); + printk(XENLOG_WARNING "%s: not fully implemented\n", __func__); + + domain_vintc_deinit(d); } =20 int arch_domain_create(struct domain *d, @@ -308,6 +310,9 @@ int arch_domain_create(struct domain *d, if ( (rc =3D p2m_init(d, config)) !=3D 0) goto fail; =20 + if ( (rc =3D domain_vintc_init(d)) ) + goto fail; + return rc; =20 fail: diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 875728885292..6fc0e620e937 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -79,4 +79,7 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsigne= d int priority); =20 void intc_handle_external_irqs(struct cpu_user_regs *regs); =20 +int domain_vintc_init(struct domain *d); +void domain_vintc_deinit(struct domain *d); + #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index 2864a896b677..f5c8af6ddea4 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -11,6 +11,7 @@ =20 #include #include +#include =20 static const struct intc_hw_operations *__ro_after_init intc_hw_ops; =20 @@ -83,3 +84,37 @@ int __init make_intc_domU_node(struct kernel_info *kinfo) =20 return vintc->init_ops->make_domu_dt_node(kinfo); } + +int domain_vintc_init(struct domain *d) +{ + int ret =3D -EOPNOTSUPP; + const enum intc_variant variant =3D intc_hw_ops->info->hw_variant; + + switch ( variant ) + { + case INTC_APLIC: + ret =3D domain_vaplic_init(d); + break; + + default: + printk_once("vintc (variant:%d) isn't implemented\n", variant); + break; + } + + return ret; +} + +void domain_vintc_deinit(struct domain *d) +{ + const enum intc_variant variant =3D intc_hw_ops->info->hw_variant; + + switch ( variant ) + { + case INTC_APLIC: + domain_vaplic_deinit(d); + break; + + default: + break; + } +} --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966559; cv=none; d=zohomail.com; s=zohoarc; b=Iz6Zk26aIdVhtfgYTL+47ztCtGPD4LTCuJ/ZVNiYDT5FCWsD3F5CX1upm0NhQZB/bPaDxSQtCC8JDzHY/QjAZWkgPipCJsuAMNkQNnGvwQsH19wS1/xmTDqwoxbgikBvbpGWRMb4N34xtpnPnNRzS+ukY3QGh8W/Fyj9BDbPRd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966559; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KTaQ9h189jrQ8PflO0q1KoloPtCJkXzXCsZXadZts+I=; b=RDBBiDEx4oZeBDizm5H5MBY/ektcJhktypEbniepV8k4ON2R4akT+4iBm8p6kHaGRRxXvvH9gJ1HvqQYGeUQ7F1CeFzEweygSf3Ex9mh0OVG2ugjrh3/k4ELlRLc3jEtyqD8PUmhuL6Aq7d1Zksldlc6TQ1r/npUArNYX2eu9Jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966559183656.9548864836377; Wed, 9 Sep 2026 08:09:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413285.1643571 (Exim 4.92) (envelope-from ) id 1x4Juy-0004Yy-0g; Wed, 09 Sep 2026 15:08:56 +0000 Received: by outflank-mailman (output) from mailman id 1413285.1643571; Wed, 09 Sep 2026 15:08:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Jux-0004Yk-Sz; Wed, 09 Sep 2026 15:08:55 +0000 Received: by outflank-mailman (input) for mailman id 1413285; Wed, 09 Sep 2026 15:08:54 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Juw-0004P5-CZ for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Juv-003DUG-Pj for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:53 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17672-2eae-0a2a0a5409dd-0a2a4501e5d2-46 for ; Wed, 09 Sep 2026 17:08:53 +0200 Received: from [209.85.218.42] (helo=mail-ej1-f42.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17685-5984-0a2a45010019-d155da2ae984-3 for ; Wed, 09 Sep 2026 17:08:53 +0200 Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-c1670dad7a8so965985966b.3 for ; Wed, 09 Sep 2026 08:08:53 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966533; x=1789571333; darn=lists.xenproject.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=KTaQ9h189jrQ8PflO0q1KoloPtCJkXzXCsZXadZts+I=; b=DSRuXFGGcE4SP7xaT531FHP64lCVLDfoI97NZwuAzIEpEyguFkJPGVLqVysZuXe4Ek /u77etr9wP9NLXgod77MuPV2zXfO3KREe6sJV2S41ao8uRFj9TOKOyArctzvFgxw/07O i54sY9WZgLrOywwrg2QRF7/Q0gyvKFIGJO1A/ges+tTtwD3+1aI61WMhY1UUI/fmxoe6 r+/0PJyeUR9D1PHF6j81JBUQXf0x3GbEgeiNlJgSIP7rDmbpATyNeWJ/b6CJkUJks4T8 WxuBamm6B+JnTGNPkux9WS+gzTDbZKUDymBvLGJHwNETMtxfI7nofO88D544K/80es4y BPzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966533; x=1789571333; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=KTaQ9h189jrQ8PflO0q1KoloPtCJkXzXCsZXadZts+I=; b=UaxuYnqSZDaAMTzChXT0z5rqAIHZa1+t06cBI807am7jQQm/zQvdoi9ffi+ac8jjVs StFB+Bu+TCSI2yP/PLnBgz4igbzfujILpsnRjbBrdt/i4g6jKl/lTJ2zyEE8CSW8aI1A crgIpQnFYGx494gp04EGelAyWs4+AVDluMACx8Lam0mFOuc2JPY2rvL0OqBkrTHIyEwk yEhTHlxIQSiC6tclcNTkVz5D6R2AI3pNOOJYLx6CYZxXN9QF9PZDSqaxr2llXpsJKthZ 2N8pfC5bkn7G36O8XnIqvADNb7SZrkR04d9lt59enIhR+pWVDg8iTvYW0C/J8tHSk400 UfZQ== X-Gm-Message-State: AFuF++kNvgF2NWUyj6u+07OmMHjrIg1BCHj8W/4OewsiFM9EZytWtbu8 Ymke9YWyyVlrwrCicYr7eh5/NKV36h6iiR4Xr9H0/98zZKJJPOadBLIRP6ikpnzB X-Gm-Gg: AYBFou2lD3vqBHc5tbt0xZHv0FNgsiU80OVuYs8RV/BcV/LjUIeYHSIM8YyPvJtNaGU DGk/LfrviKhlTg+Jj/vYsGCVnVzcl5txnkXOrv794N81I06ZinBS3WrD4Z8EMVBp4xCuoy0t9us 4wHHdMFD7YeVqAQS2xphy5LvOYgVLU7HK+sy9kThH0qV2H2KPoAiBfxUfbfQSppm6NWWy6ToSlw y0RqherUkJZq4DeOIUMiKIWO5EdqeIr5qkNXcczgf/l3kkEtoNKX5oSXZjt+7el0jslFGH3+9uF OJsLr20bXVXD9532amfVT0HVDM63+dQiZhK/dr+DDZwv2KO6jiuQKSJ4VMztU20Hcj4pX10E+2+ pb/0IT5x+oi9vwDwpzMdqu9fIAa10Z/0VfYCxJG39f6YfKGs8bCl7kddWbsmYIoRjVI6OL9/Tkp 0Vh98BQtHZSRrw5SaftJZiyQuRO92bNQQOjT9lQTfAbjcjeEa4v11PJ+cQ7F/Z5sGy5zK8dB5Yv P2tIlTL92aNnu3aHNk= X-Received: by 2002:a17:907:b045:20b0:c26:24ed:39e5 with SMTP id a640c23a62f3a-c2624ed44cfmr762869766b.18.1788966532972; Wed, 09 Sep 2026 08:08:52 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 14/20] xen/riscv: generate IMSIC DT node for guest domains Date: Wed, 9 Sep 2026 17:07:32 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1788966533-1E07B757-28D47B88/10/73395122804 X-purgate-type: spam X-purgate-size: 10790 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966559434158501 Guests using the IMSIC interrupt controller require a corresponding Device Tree description. Add support for generating an IMSIC node when building the guest DT. This allows guests to discover and use the IMSIC interrupt controller. The value choosen for GUEST_IMSIC_S_BASE is an address which is typically used for IMSIC and QEMU. DT-building functions are marked __init because domain creation happens at boot time, before the init sections are freed. In a typical deployment libxl creates the interrupt controller node in userspace and hands the complete FDT to Xen, so these functions are only called during early domain construction. Co-developed-by: Romain Caritey Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v8-v9: - Nothing changed. Only rebase. --- Changes in v7: - Add Acked-by: Jan Beulich . --- Changes in v6: - Simplify initialization of guest_num_msis. - s/sizeof(vimsic_name)/ARRAY_SIZE(...). - Add empty line between declaration(s) and statement(s) in make_domu_dt_n= ode(). - define GUEST_IMSIC_MAX_MSIS as 255U to avoid '+0U' when min(...) is used. --- Changes in v5: - s/GUEST_IMSIC_NUM_MSIS/GUEST_IMSIC_MAX_MSIS throughout. - Changed __read_mostly =E2=86=92 __ro_after_init on guest_num_msis, since= the value is set once during __init and never again. - Made imsic_parse_node() __init. - Moved the min(GUEST_IMSIC_MAX_MSIS, ...) cap into imsic_parse_node() rig= ht after guest_num_msis is assigned, so the bound is applied once at init time rather than on every DT node construction call. - Removed the now-unnecessary num_msis local variable from vimsic_make_domu_dt_node(); guest_num_msis is used directly. - s/snprintf(buf, sizeof(buf), ...)/snprintf(buf, ARRAY_SIZE(buf), ...) in guest_imsic_set_interrupt_extended_prop(). - Added decl. of vimsic_make_domu_dt_node() in this patch instead of next. --- Changes in v4: - Add a comment for guest_num_msis explaining that it is host-dependent and therefore identical for every domain, which is why a single global is used instead of a per-domain value. - Reduce vimsic_name[] from 128 to 32 bytes, which is enough to hold "/soc/imsic@" plus a 64-bit hex address. - Add a comment before GUEST_IMSIC_S_BASE noting that the value is the address typically used for IMSIC by QEMU. - s/__ULL/_UL for defintion of GUEST_IMSIC_S_BASE. --- Changes in v3: - s/__ro_after_init/__read_mostly for guest_num_msis. - Use IMSIC_MAX_ID as default for guest_num_msis instead of imsic_cfg.nr_i= ds. - Drop base_addr local variable in guest_imsic_make_reg_property(); use GUEST_IMSIC_S_BASE directly and introduce size to avoid spelling IMSIC_MMIO_PAGE_SZ * d->max_vcpus twice. - Change irq_ext type from uint32_t * to __be32 * in guest_imsic_set_interrupt_extended_prop(). - Move phandle declaration into the loop body. - Extend commit message to explain why __init is used for DT-building functions: libxl creates the interrupt controller node before handing the FDT to Xen, so these functions are only invoked during boot-time domain construction. - Re-order patch before APLIC DT node creation patch. - Update commit message. --- Changes in v2: - s/imsic_make_reg_property/guest_imsic_make_reg_property. - s/imsic_set_interrupt_extended_prop/guest_imsic_set_interrupt_extended_p= rop. - Use initalizer for regs[] array in imsic_make_reg_property(). - Move buf[] insde the for() loop. - Correct check of returned phandle. - Drop local variable len. - /s/XVFREE/xvfree in imsic_set_interrupt_extended_prop(). - Drop initializer for local variable data. - s/uint32_t/unsinged int for pos and cpu in imsic_set_interrupt_extended_= prop(). - Drop next_phandle as it is now in common code. - Introduce vcpu_imsic_deinit. - Refactor vimsic_make_domu_dt_node() to avoid usage of host IMSIC dt node. --- --- xen/arch/riscv/imsic.c | 143 +++++++++++++++++++++- xen/arch/riscv/include/asm/guest-layout.h | 6 + xen/arch/riscv/include/asm/imsic.h | 3 + 3 files changed, 151 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 809f29af860a..44b8640ea39a 100644 --- a/xen/arch/riscv/imsic.c +++ b/xen/arch/riscv/imsic.c @@ -13,8 +13,12 @@ #include #include #include +#include #include +#include +#include #include +#include #include #include #include @@ -34,6 +38,21 @@ static struct imsic_config imsic_cfg =3D { .lock =3D SPIN_LOCK_UNLOCKED, }; =20 +/* + * Number of MSIs available to a guest. Determined by the host interrupt + * controller, so it is identical for every domain -- hence a single global + * rather than a per-domain value. + */ +static unsigned int __ro_after_init guest_num_msis; + +#define GUEST_IMSIC_COMPATIBLE "riscv,imsics" + +/* + * Value is inspired by what QEMU is using for riscv,num-ids property for = IMSIC + * node. + */ +#define GUEST_IMSIC_MAX_MSIS 255U + #define IMSIC_DISABLE_EIDELIVERY 0 #define IMSIC_ENABLE_EIDELIVERY 1 #define IMSIC_DISABLE_EITHRESHOLD 1 @@ -182,7 +201,7 @@ static int __init imsic_get_parent_hartid(const struct = dt_device_node *node, * or IRQ_M_EXT if the IMSIC node corresponds to a machine-mode IMSIC, * which should be ignored by the hypervisor. */ -static int imsic_parse_node(const struct dt_device_node *node, +static int __init imsic_parse_node(const struct dt_device_node *node, unsigned int *nr_parent_irqs, unsigned int *nr_mmios) { @@ -285,6 +304,11 @@ static int imsic_parse_node(const struct dt_device_nod= e *node, return -ENOENT; } =20 + if ( dt_property_read_u32(node, "riscv,num-guest-ids", &tmp) ) + guest_num_msis =3D min(GUEST_IMSIC_MAX_MSIS, tmp); + else + guest_num_msis =3D GUEST_IMSIC_MAX_MSIS; + if ( (imsic_cfg.nr_ids < IMSIC_MIN_ID) || (imsic_cfg.nr_ids > IMSIC_MAX_ID) ) { @@ -526,3 +550,120 @@ int __init imsic_init(const struct dt_device_node *no= de) =20 return rc; } + +static int __init guest_imsic_make_reg_property(struct domain *d, void *fd= t) +{ + paddr_t size =3D IMSIC_MMIO_PAGE_SZ * d->max_vcpus; + __be32 regs[4] =3D { + cpu_to_be32(GUEST_IMSIC_S_BASE >> 32), + cpu_to_be32(GUEST_IMSIC_S_BASE), + cpu_to_be32(size >> 32), + cpu_to_be32(size), + }; + + return fdt_property(fdt, "reg", regs, sizeof(regs)); +} + +static int __init guest_imsic_set_interrupt_extended_prop(struct domain *d, + void *fdt) +{ + unsigned int cpu, pos =3D 0; + __be32 *irq_ext; + int res; + + irq_ext =3D xvzalloc_array(__be32, d->max_vcpus * 2); + if ( !irq_ext ) + return -ENOMEM; + + for ( cpu =3D 0; cpu < d->max_vcpus; cpu++ ) + { + char buf[64]; + uint32_t phandle; + + snprintf(buf, ARRAY_SIZE(buf), "/cpus/cpu@%u/interrupt-controller"= , cpu); + phandle =3D fdt_get_phandle(fdt, fdt_path_offset(fdt, buf)); + + if ( !phandle ) + { + res =3D -ENODEV; + goto out; + } + + irq_ext[pos++] =3D cpu_to_be32(phandle); + irq_ext[pos++] =3D cpu_to_be32(IRQ_S_EXT); + } + + res =3D fdt_property(fdt, "interrupts-extended", irq_ext, + d->max_vcpus * 2 * sizeof(*irq_ext)); + + out: + xvfree(irq_ext); + + return res; +} + +int __init vimsic_make_domu_dt_node(struct kernel_info *kinfo, + unsigned int *phandle) +{ + int res; + void *fdt =3D kinfo->fdt; + char vimsic_name[32]; + unsigned int vimsic_phandle; + + res =3D snprintf(vimsic_name, ARRAY_SIZE(vimsic_name), "/soc/imsic@%lx= ", + GUEST_IMSIC_S_BASE); + if ( res >=3D ARRAY_SIZE(vimsic_name) ) + { + dprintk(XENLOG_DEBUG, "vimsic name is truncated\n"); + return -ENOBUFS; + } + + res =3D fdt_begin_node(fdt, vimsic_name); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", GUEST_IMSIC_COMPATIBLE); + if ( res ) + return res; + + res =3D guest_imsic_make_reg_property(kinfo->bd.d, fdt); + if ( res ) + return res; + + res =3D guest_imsic_set_interrupt_extended_prop(kinfo->bd.d, fdt); + if ( res ) + return res; + + res =3D fdt_property_u32(fdt, "riscv,num-ids", guest_num_msis); + if ( res ) + return res; + + res =3D fdt_property(fdt, "msi-controller", NULL, 0); + if ( res ) + return res; + + res =3D fdt_property_u32(fdt, "#msi-cells", 0); + if ( res ) + return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if ( res ) + return res; + + res =3D fdt_property_u32(fdt, "#interrupt-cells", 0); + if ( res ) + return res; + + vimsic_phandle =3D alloc_phandle(kinfo); + if ( !vimsic_phandle ) + return -EOVERFLOW; + + res =3D fdt_property_cell(fdt, "phandle", vimsic_phandle); + if ( res ) + return res; + + if ( phandle ) + *phandle =3D vimsic_phandle; + + return fdt_end_node(fdt); +} diff --git a/xen/arch/riscv/include/asm/guest-layout.h b/xen/arch/riscv/inc= lude/asm/guest-layout.h index 68d95a09394c..5e566450bdfa 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -3,6 +3,12 @@ =20 #include =20 +/* + * Base address of the guest's supervisor-mode IMSIC. The value is the add= ress + * typically used for IMSIC by QEMU. + */ +#define GUEST_IMSIC_S_BASE _UL(0x28000000) + #define GUEST_RAM_BANKS 2 =20 /* diff --git a/xen/arch/riscv/include/asm/imsic.h b/xen/arch/riscv/include/as= m/imsic.h index 5ee954bbf3ef..2425430ed116 100644 --- a/xen/arch/riscv/include/asm/imsic.h +++ b/xen/arch/riscv/include/asm/imsic.h @@ -78,6 +78,7 @@ struct vimsic_state { }; =20 struct dt_device_node; +struct kernel_info; struct vcpu; =20 int imsic_init(const struct dt_device_node *node); @@ -93,4 +94,6 @@ int vcpu_imsic_init(struct vcpu *v); void vcpu_imsic_deinit(struct vcpu *v); unsigned int vcpu_guest_file_id(const struct vcpu *v); =20 +int vimsic_make_domu_dt_node(struct kernel_info *kinfo, unsigned int *phan= dle); + #endif /* ASM_RISCV_IMSIC_H */ --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966555; cv=none; d=zohomail.com; s=zohoarc; b=kV0rRwxHiJXfFhe1p/6qKxH0l3rkY8TwOyZwKbSPdm9ruaVIJ/3Bsi/koDNHHWU8g8o7Rp9ZYMUNNk/razApgHbVrACuEgq/yrG4UL8TzlqtHjZmn7HavxPIOH2WfxmsYCyBe9qSq0puU66kbPkx134g4GW2cdcQWtffjk4Hxsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966555; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YFhrvSESi6fuTpLM2ezR0PpqXfEfgOGaTAHwrSqOA/E=; b=EZP4TIpzA9oDdWkiDmkDJxNidHN9MOXd+4lyKvbvy36qPbq2r+8cmAoJuopciz26qEvZVMsBz5+1diLC4ItKR0n0DzBZLl9xffgOmZx0fHIsrsaUqqE+qx/i74sLP1meKshVytLqKWZ81EfH626LUjOb6ixeTojGIYd6P6DxbpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966555465202.67588635867037; Wed, 9 Sep 2026 08:09:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413288.1643581 (Exim 4.92) (envelope-from ) id 1x4Juz-0004rW-By; Wed, 09 Sep 2026 15:08:57 +0000 Received: by outflank-mailman (output) from mailman id 1413288.1643581; Wed, 09 Sep 2026 15:08:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Juz-0004qT-68; Wed, 09 Sep 2026 15:08:57 +0000 Received: by outflank-mailman (input) for mailman id 1413288; Wed, 09 Sep 2026 15:08:56 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Juy-0004av-Al for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:08:56 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jux-00DoNW-NW for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:08:55 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa1766f-e002-0a2a0a5209dd-0a2a4505af18-42 for ; Wed, 09 Sep 2026 17:08:55 +0200 Received: from [209.85.218.50] (helo=mail-ej1-f50.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17687-4cb1-0a2a45050019-d155da32e593-3 for ; Wed, 09 Sep 2026 17:08:55 +0200 Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c15e2dab83eso1042451966b.1 for ; Wed, 09 Sep 2026 08:08:55 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:08:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966535; x=1789571335; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YFhrvSESi6fuTpLM2ezR0PpqXfEfgOGaTAHwrSqOA/E=; b=N+maZJfail7MMaasnzjppekChzt5mDu3reYwp9qcGzxiCIUvnYW3ql0F/PvYdr9xB6 a1FvVNLokZfrew54TbiEeJx587u34vDi1rMxpoXlky6iHuCU8NYvDnrObB3Whtttd4eF BNwhXi2+nWLlimUrtcxMIePqYdCPzd9lSG42K3kUCltGIBQVawlnobQHEEcbh2SAUZ19 qMjwAcfWHtWEq6jgUWhdF93E6A5FWnQ7DzJ+1/ISteN8YKoH43AOYl1J/eovsDJ1bg0g M74A6GV3qT/DnoSDxD2EwAwBxu+euA6ps5Jogh/Urxx0kDfI9tSRoN/yAONqwyrV0Zvl 7ekQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966535; x=1789571335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=YFhrvSESi6fuTpLM2ezR0PpqXfEfgOGaTAHwrSqOA/E=; b=oLq9ErnqVmHAA2RCC9SlzxXiWYlt0dqWrkM5oEZy+2pNvxMLXJPWgzzWac1MAyubS9 GnFv4gEU6I6WA+Y7tAsStNBPtCLJIiyd9bbsmdGPuP4D6gy6qBwQwXe3nYWWwR5KWK1n zGud5l3xs8gm7nh6nKX+9W884q2eoVqnIJ+1jcflpqhxrMOLa6JBWwmb/s24vQnNcrlu hTE5yvHhlBpdHVOdzcBsJpAXrl5JaAM6mK3pddTgP/7+76kEW5ZivNtmKMm1AMRdwbo4 ZFU6Jv/GMowSwB5wCzqZdwtzVCVwGYcXTdRaqM5fPpHqzIvGb0Q4RuY9PYdRACh8sbW0 ePAw== X-Gm-Message-State: AFuF++kLcvYnKA54cBEzXhInqwZ2bfKkNafgIQntNrEBCFGK/faBMI8g FsbMKMwjxW/OGctJ1imL5iPLG71S4oMNePx0LOH5HfTI+WMCpiZ+zqu9UmRLI6e2 X-Gm-Gg: AYBFou2ZFZLsUw7YhjL7fdtisURET7vJDB22DOUAzMi0qe/bdKL9yXQNreWN1Btqzcn KyadfedoesYsrayYMNDDEBo6CtGfJps6H52OXDLjoLRGjGcoVwxTdf/XPTbjQ7fJqXDIwe0aBZ7 GSTy4hmnYUocw2VDKYy9v3W6zFQWRNOyWYOJEK/F1e1u1LKKLWXX372EkeZQFy2GVwxmCe6mehM +ONFTqfpF2qegoTkUVJnbzIXGtLu8xl6AJC6emoAEZHWSmkeiki1fIMKAVl+Q1LgzmRXgsVPPir SttC5koGxBCgJCWJJa40gLKPTLK2G4WF/k/nFnHBgFz0y6l1CNIsyWkWRRWlmzpKKlGUPnDZvXL SrwdjKPhMNrT/poUncabf99+IliLPo0dUfqZxMvUnAJ94g29NWPGpy7tlkEW695vomUS3FHyKB6 maTqtxsZimDdW5C/uDI+fxSTX6yncdjRzdQ37oUT1X7dws2FXerNmYDQBGtL3JDFaS5P7Jd/BOg KXwo/YweLl5m4a1YYY= X-Received: by 2002:a17:906:c151:b0:c26:19de:912c with SMTP id a640c23a62f3a-c2619dea162mr1489635866b.31.1788966534970; Wed, 09 Sep 2026 08:08:54 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 15/20] xen/riscv: create APLIC DT node for guest domains Date: Wed, 9 Sep 2026 17:07:33 +0200 Message-ID: <6ca287c7944692cd86720871eaf441071450563b.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1788966535-716AD2A1-AD4769AD/10/73395122804 X-purgate-type: spam X-purgate-size: 8888 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966557678158500 Content-Type: text/plain; charset="utf-8" Guests require a Device Tree description of the interrupt controller topology. Add support for creating an APLIC node when building the guest DT. Provide stub for imsic_make_dt_node() it will be introduced properly in follow-up patch. The value chosen for GUEST_APLIC_S_BASE is based on QEMU one. DT-building functions are marked __init because domain creation happens at boot time, before the init sections are freed. In a typical deployment libxl creates the interrupt controller node in userspace and hands the complete FDT to Xen, so these functions are only called during early domain construction. Co-developed-by: Romain Caritey Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- changes in v8 - v9: - Nothing changed. Only rebase. --- Changes in v7: - Update the comment for guest_aplic_num_sources: drop "wired" to be less confusing, and mention that it is identical for every domain only for now. - Use ARRAY_SIZE() instead of sizeof() for the size argument of snprintf() in vaplic_make_domu_dt_node(). - Add Acked-by: Jan Beulich --- Changes in v6: - Redefine GUEST_APLIC_MAX_SOURCES as 96U to avoid '+OU' in min(...). - s/guest_num_sources/guest_aplic_num_sources. --- Changes in v5: - Drop pointless initializer for local variable res in vaplic_make_domu_dt_node(). - Limit guest_num_sources in the similar way to IMSIC. - Rename VAPLIC_NUM_SOURCES to GUEST_APLIC_MAX_SOURCES to be aligned with the similar place in vIMSIC related code. --- Changes in v4: - Drop spurious and includes from aplic.c (mistakenly added, they belong to vaplic.c). - Reduce vaplic_name[] from 128 to 32 bytes in vaplic_make_domu_dt_node(). - Use __initconstrel (with const) for init_ops instead of __initdata. - s/__ULL/_UL for defintion of GUEST_APLIC_S_BASE. --- Changes in v3: - Fix rebase conflicts becuase of this patch is reordered after IMSIC DT node creation is intoduced. - Update the commit message. - Move initialization of domaincfg with APLIC_DOMAINCFG_RO80 from this patch to earlier. - Change paddr_t aplic_size to unsigned int in vaplic_make_domu_dt_node() and replace the UB (after it started to be uint) aplic_size >> 32 with an explicit 0 in the DT reg property. - Add BUILD_BUG_ON() to be sure that aplic size isn't bigger then UINT32_MAX. --- Changes in v2: - Avoid as max as possible of host properties inheritance. Only number of APLIC's irqs are checked what leads to an introduction of get_aplic_irqs_num(). - Move this patch earlier what leads to an introduction of vimsic_make_domu_dt_node() stub. - s/vimsic_make_domu_dt_node/imsic_make_domu_dt_node. - Refactor vimsic_make_domu_dt_node() to avoid re-usage of APLIC host properties. - Drop next_phandle as it is now in common code. - Drop const for kinfo argument of vimsic_make_domu_dt_node() is is going to be updated inside vimsic_make_domu_dt_node(). - Use introduced before vintc->num_irqs. --- --- xen/arch/riscv/aplic-priv.h | 13 ++++ xen/arch/riscv/aplic.c | 2 + xen/arch/riscv/include/asm/aplic.h | 8 +++ xen/arch/riscv/include/asm/guest-layout.h | 6 ++ xen/arch/riscv/vaplic.c | 77 +++++++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/xen/arch/riscv/aplic-priv.h b/xen/arch/riscv/aplic-priv.h index 85e0d028d1ae..35100d3a64fe 100644 --- a/xen/arch/riscv/aplic-priv.h +++ b/xen/arch/riscv/aplic-priv.h @@ -34,4 +34,17 @@ struct aplic_priv { const struct imsic_config *imsic_cfg; }; =20 +/* + * Value is inspired by what QEMU is using for riscv,num-sources property = for + * APLIC node. + */ +#define GUEST_APLIC_MAX_SOURCES 96U + +/* + * Specifies the number of interrupt sources supported by guest APLIC doma= in. + * Could be limited by host interrupt controller and is identical for every + * domain for now. + */ +extern unsigned int guest_aplic_num_sources; + #endif /* ASM_RISCV_APLIC_PRIV_H */ diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index d08401db46b3..c2d7183e1852 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -92,6 +92,8 @@ static int __init cf_check aplic_init(void) panic("%s: failed to get number of interrupt sources\n", node->full_name); =20 + guest_aplic_num_sources =3D min(GUEST_APLIC_MAX_SOURCES, aplic_info.nu= m_irqs); + if ( aplic_info.num_irqs > ARRAY_SIZE(aplic.regs->sourcecfg) ) aplic_info.num_irqs =3D ARRAY_SIZE(aplic.regs->sourcecfg); =20 diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/as= m/aplic.h index 5a7fcb6ec4f1..07318aaac25d 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -34,6 +34,14 @@ =20 #define APLIC_TARGET_HART_IDX_SHIFT 18 =20 +#define APLIC_IDC_SIZE 32 + +#define APLIC_MIN_SIZE 0x4000 +#define APLIC_SIZE_ALIGN(x) ROUNDUP(x, APLIC_MIN_SIZE) + +#define APLIC_SIZE(nr_cpus) (APLIC_MIN_SIZE + \ + APLIC_SIZE_ALIGN(APLIC_IDC_SIZE * (nr_cpu= s))) + struct aplic_regs { uint32_t domaincfg; /* 0x0000 */ uint32_t sourcecfg[1023]; /* 0x0004 */ diff --git a/xen/arch/riscv/include/asm/guest-layout.h b/xen/arch/riscv/inc= lude/asm/guest-layout.h index 5e566450bdfa..90603f06bb91 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -3,6 +3,12 @@ =20 #include =20 +/* + * Base address of the guest's supervisor-mode APLIC. The value is the add= ress + * typically used for APLIC by QEMU. + */ +#define GUEST_APLIC_S_BASE _UL(0xd000000) + /* * Base address of the guest's supervisor-mode IMSIC. The value is the add= ress * typically used for IMSIC by QEMU. diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index c9f188b989a3..a529a5b1dc49 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -9,6 +9,8 @@ */ =20 #include +#include +#include #include #include =20 @@ -19,6 +21,80 @@ =20 #include "aplic-priv.h" =20 +unsigned int __ro_after_init guest_aplic_num_sources; + +#define VAPLIC_COMPATIBLE "riscv,aplic" + +#define FDT_VAPLIC_INT_CELLS 2 + +static int __init cf_check vaplic_make_domu_dt_node(struct kernel_info *ki= nfo) +{ + struct domain *d =3D kinfo->bd.d; + int res; + void *fdt =3D kinfo->fdt; + unsigned int msi_parent_phandle; + char vaplic_name[32]; + unsigned int aplic_size =3D APLIC_SIZE(d->max_vcpus); + const __be32 reg[] =3D { + cpu_to_be32(GUEST_APLIC_S_BASE >> 32), + cpu_to_be32(GUEST_APLIC_S_BASE), + cpu_to_be32(0), + cpu_to_be32(aplic_size), + }; + + BUILD_BUG_ON(APLIC_SIZE(MAX_VIRT_CPUS) > UINT_MAX); + + res =3D snprintf(vaplic_name, ARRAY_SIZE(vaplic_name), "/soc/aplic@%lx= ", + GUEST_APLIC_S_BASE); + if ( res >=3D sizeof(vaplic_name) ) + { + dprintk(XENLOG_DEBUG, "vaplic name is truncated\n"); + return -ENOBUFS; + } + + res =3D vimsic_make_domu_dt_node(kinfo, &msi_parent_phandle); + if ( res ) + return res; + + res =3D fdt_begin_node(fdt, vaplic_name); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", FDT_VAPLIC_INT_CELL= S); + if ( res ) + return res; + + res =3D fdt_property(fdt, "reg", reg, sizeof(reg)); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "riscv,num-sources", guest_aplic_num_so= urces); + if ( res ) + return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", VAPLIC_COMPATIBLE); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "msi-parent", msi_parent_phandle); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "phandle", kinfo->phandle_intc); + if ( res ) + return res; + + return fdt_end_node(fdt); +} + +static const struct vintc_init_ops __initconstrel init_ops =3D { + .make_domu_dt_node =3D vaplic_make_domu_dt_node, +}; + static const struct vintc_ops vintc_ops =3D { .vcpu_init =3D vcpu_imsic_init, .vcpu_deinit =3D vcpu_imsic_deinit, @@ -33,6 +109,7 @@ int domain_vaplic_init(struct domain *d) =20 d->arch.vintc =3D &vaplic->vintc; d->arch.vintc->ops =3D &vintc_ops; + d->arch.vintc->init_ops =3D &init_ops; =20 vaplic->regs.domaincfg =3D APLIC_DOMAINCFG_RO; =20 --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966580; cv=none; d=zohomail.com; s=zohoarc; b=ElK8WTxQJrTOzXnkoYFvHvIIJ28ITNtroVO6MzGUaH1r5PJzAVWG/xvDonWgpMT84ej7Ixv4iieLuU2D7b/RTpXh9jho2O29yjcbiwoZZk/c4tbtPLM+e//17q5TbwHnSrf7a8fFmSTvNoJPnhcMOc1NCbKXn0o0MXuWvDnCCqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966580; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H5HNH6k6iCxxkoSMpv3sBw0b64bZYiUjkym7mIw7F1o=; b=lJVXDAJ/mC01A6oaCObOSRgnYnG7DtR5YFmfjjS++cXvoFT1MxM63swLOZk/WkvboUWD6UwhRoGp+0V9PJAIHgvxsaImqdqvbMTxPEhSQwHMcE2MiR/XeziWi8hPd/TQMPJRBo9CrtvsMLdW1ZzAvZwyfNSBFnvmG29oa9ZPutM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966580809687.2031326107872; Wed, 9 Sep 2026 08:09:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413305.1643590 (Exim 4.92) (envelope-from ) id 1x4Jv9-0005iJ-Rm; Wed, 09 Sep 2026 15:09:07 +0000 Received: by outflank-mailman (output) from mailman id 1413305.1643590; Wed, 09 Sep 2026 15:09:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4Jv9-0005iC-Ob; Wed, 09 Sep 2026 15:09:07 +0000 Received: by outflank-mailman (input) for mailman id 1413305; Wed, 09 Sep 2026 15:09:06 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4Jv8-0005cI-5K for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:09:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jv7-00DoQS-I6 for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:09:05 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17686-e002-0a2a0a5209dd-0a2a45018c2e-22 for ; Wed, 09 Sep 2026 17:09:05 +0200 Received: from [209.85.218.45] (helo=mail-ej1-f45.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17691-5984-0a2a45010019-d155da2de5bb-3 for ; Wed, 09 Sep 2026 17:09:05 +0200 Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c15e2dab83eso1042489266b.1 for ; Wed, 09 Sep 2026 08:09:05 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:09:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966545; x=1789571345; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=H5HNH6k6iCxxkoSMpv3sBw0b64bZYiUjkym7mIw7F1o=; b=TIIOko2H+zKfPZfFFAUavUo+VW1QFOl8T+ZwvTcGJSnxG9aPwSEJrUDmlWiN24nG2m jJuOj+gXBl+XtJ82JKZv+/t5WjJ+9FR+hKX5CV5KTvb50NCopDui1/gsaRgR7foDHNFU 1EL8ZtXVKFP9Fznk22l5qdF06RcAMCujqAfITzZWkB2ZE1qsSKD6pwf/rTjtpqdCKzqw Ee9i04knoxjhdXvCeyy36psD+XqyjaTB4wc5XHZQlHIHYct54ZGz1i7oQNOna5WZrznd yyOwhAw0IOPHPBzWLFwIjDLR4L0hRPSqcsdGB/HE65IXVKc9e9QP8MgNR/9WLfSl4j/q YpSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966545; x=1789571345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=H5HNH6k6iCxxkoSMpv3sBw0b64bZYiUjkym7mIw7F1o=; b=R9OkFlaUEw5NcfN1/EB5k/MhsSQ5GSwpo86gX+n2IH9YFnPTa5vzSQRciT+Mxm6N03 BbTs/pxxT6VQkrzpNzHt+GdS1/OfHXY0wckfzVBiH35mGgTVD/qMN0isETskOFQSKSn1 KI/4M3CV/s1CBt6ea7kVpV5SXhWd2dMUuAkPdtryv6OsAceUVQrp5ddzj/9vX7ntsTC4 IMMeQtR7myEJ9l8b/rW7HocmcDvtQYLW2rvN0rETvfOIBh4TmjFGPq9iziA4STAaMPK6 BYKAnfjc6cc5UWiKVoBm7nPY/0zU27lVF/8exWga8zG0yCFa1rTsnuq5A5TJZAzY4BQO djCw== X-Gm-Message-State: AFuF++l0GBx5kOOFaQJHkptqhL/IrcdPyxDlQA55ALJInSbIGjqOCl2m LlXTwHS3PQ/efBYYzvr7nfxuB7wlkUufbAPfgGsGhF6munp4SsKRnJpnSgeJPH6q X-Gm-Gg: AYBFou1EUy81R3GgJUhPcXn/TUNW7fwujP0b2EXAg8arU74URxKHk7LxaISfAI9rw8W W3qQp8VZl3fVkdDToDz1TYIr/eJsgxAAQjDLTKWhmD2NEoKhq7ggd04draGWioa6+LWU5xdtHA0 ld+nUdOKEn2m6FTxiMrb8NbMLd2F8aAn3g3KdADDJbwO53JT2UBL8ChU1gIt/8QOFFIZvtilNtf bzzkRe/JNhZbIra1sEQ/Oqudcd0dYre4KaICzeT2GBn0QlazkbULx7aXnAAVebMNuaqVe4bI6TF ylSb87ZA2QDF/tSJmGyAgHvJwpT2CQ9N+2uOorhEHmYoVHeZuLzIzmMGtYqLMPCDUWiQiV6xHYO 3Mx6zhFHfhjGHFSCJ6aFQ7Oal6SgILoiUAn7WzjSuMSWbBNMKqF4zHRkBefHdm9AFUsc132h5Nu 8nWENT7Nfgqc6j5Q3M0rP0F1HxUFJybYuPnjNtnWy1cc8Xz26DKzgiAhsrVqBiInfFUJ1Hewt2z 6xAe9DHmmBdWXKdyLc= X-Received: by 2002:a17:906:eec9:b0:c26:19de:912a with SMTP id a640c23a62f3a-c2619dea136mr1237650566b.29.1788966544563; Wed, 09 Sep 2026 08:09:04 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Alistair Francis , Connor Davis , "Daniel P. Smith" Subject: [PATCH v9 16/20] xen/riscv: implement IRQ routing for device passthrough Date: Wed, 9 Sep 2026 17:07:34 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1788966545-BEC61757-C521D6DB/10/73395122804 X-purgate-type: spam X-purgate-size: 30424 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966581678158500 Content-Type: text/plain; charset="utf-8" dom0less device passthrough requires granting guest domains access to device interrupts. Introduce map_device_irqs_to_domain() to enumerate a DT node's interrupt properties, skipping those not owned by the primary interrupt controller (as at the moment I haven't seen usages of it), and map_irq_to_domain() to grant domain access and configure Xen's interrupt descriptor accordingly. Sharing IRQ between domains is rejected. Both map_irq_to_domain() and map_device_irqs_to_domain() are marked __overlay_init, mirroring Arm: without CONFIG_OVERLAY_DTB this expands to __init, so the functions are init-only and need no XSM check; with CONFIG_OVERLAY_DTB they become runtime-callable, but the only runtime entry point is dt_overlay_domctl(), which performs the XSM checks at the domctl layer. RISC-V does not wire up DT overlay yet, so today these are strictly __init; if/when overlay support is added, the domctl-level XSM gating must be added together with it, as on Arm. route_irq_to_guest() and release_irq() manage irq_desc ownership for guest-assigned interrupts. Each assignment carries a small irq_guest structure as irqaction::dev_id, recording the owning domain and virtual IRQ number which is 1:1 mapped to physical IRQ number. A per-domain vIRQ allocation bitmap (used_irqs in struct vintc), managed by vintc_reserve_virq(), prevents the same vIRQ being claimed twice. Host and guest interrupts may differ in some operations (EOI timing in particular, possibly others): a host IRQ is completed once Xen's handler runs, whereas a passthrough IRQ must defer the physical completion until the guest issues its own EOI, otherwise a still-asserted level line would immediately retrigger and storm. This affects only the .end callback; the rest of hw_interrupt_type is shared, hence the separate host and guest hw_interrupt_type instances. With APLIC+IMSIC, guest interrupts are delivered directly by hardware through the IMSIC, bypassing do_IRQ(). The _IRQ_GUEST branch in do_IRQ() is therefore left as BUG() until a platform without direct IMSIC delivery is encountered. Signed-off-by: Oleksii Kurochko --- Changes in v9: - s/aplic_guest_irq_type/aplic_guest + introduce stubs for callbacks instead of re-using callbacks used for Xen itself. - Correct the comment above action member of struct irq_guest. - Drop test_bit() from ASSERT() in irq_get_guest_info(). - Use bit operations instead of __clear_bit() in irq_detach_action(). - Fomrat do () while () in irq_release_action() according to code style. - Update the comment above irq_release_action() and inside (before smp_rmb(= )). - Make an argument of release_guest_irq() pointer to const. - Drop init. of info->action.free_on_release as it will be false because of= how info is allocated. - Align comments in printk() inside route_irq_to_guest(). - Move smp_rmb() after the wait loop in irq_release_action() (inside it, it ordered nothing useful) and spin with cpu_relax(). --- Changes in v8: - vintc_reserve_virq(): return an error code instead of a bool: 0 on success, -EEXIST when the vIRQ has already been reserved (which legitimately happens for an IRQ shared between devices) and -ERANGE when the vIRQ is outside the range the vINTC provides. Document the function and its return values. - vintc_reserve_virq(): mark it __overlay_init, as its only caller map_irq_to_domain() is __overlay_init too. Add the and includes this needs. - map_irq_to_domain(): check the return value of vintc_reserve_virq() and propagate anything but -EEXIST. Otherwise the IRQ would end up routed to the domain without domain_vintc_deinit() ever releasing it again. Update the stale comment accordingly. - domain_vintc_deinit(): only walk used_irqs and free it if it has actually been allocated. domain_vintc_init() can fail after the vINTC itself has been allocated, leaving used_irqs NULL. - irq.c: split the body of release_irq() into two helpers: irq_detach_action(), which removes the action matching dev_id from desc->action with desc->lock held, and irq_release_action(), which waits for a handler still running on another CPU and frees the action with desc->lock dropped. Both document the locking rules they rely on. release_irq() is now just a wrapper around the two. - release_guest_irq(): use irq_detach_action()/irq_release_action() instead of open-coding __clear_bit(_IRQ_GUEST, ...) followed by release_irq(), which looked the action up by dev_id a second time. - release_guest_irq(): drop the -EBUSY restriction that only allowed unrouting from a dying domain. Detaching the action under desc->lock now closes the window this was working around. - route_irq_to_guest(): on the intc_route_irq_to_guest() failure path, detach the action while desc->lock is still held and only release it after the lock has been dropped, instead of dropping the lock first and calling release_irq(). - route_irq_to_guest(): initialise desc at its declaration. - irq_get_guest_info(): use ASSERT(desc->action) instead of ASSERT(desc->action !=3D NULL). --- Changes in v7: - Build device.c as device.init.o: everything it provides is __overlay_init, which is plain __init as long as CONFIG_OVERLAY_DTB stays Arm-only. Unlike Arm, which picks device.o/device.init.o based on that config, RISC-V cannot enable it, so the choice is unconditional for now. - Don't have release_irq() free the guest IRQ info anymore: set free_on_release =3D false and free 'info' explicitly in release_guest_irq(), i.e. reinstate the xvfree() dropped in v5. The action stays embedded in struct irq_guest, so a single allocation still covers both, but it no longer has to be the structure's first member: the offsetof() BUILD_BUG_ON and the xvfree() of a pointer that merely happened to coincide with the allocation base are gone. The ->dev_id concern from v5 doesn't apply: release_irq() clears desc->action under desc->lock and waits for in-flight handling before returning, so nothing can observe ->dev_id once 'info' is freed. - Move 'action' to the end of struct irq_guest and reword its comment accordingly. - Use xvzalloc() instead of xvmalloc() for struct irq_guest, so that the embedded action is fully initialized (action.handler was left uninitialized before). - route_irq_to_guest(): free 'info' via the common free_info label when intc_route_irq_to_guest() fails, now that release_irq() no longer frees it. - Drop a stray blank line ahead of release_irq(). --- Changes in v6: - size nr_virqs as guest_aplic_num_sources + 1 to reserve APLIC's 1-indexed source 0, so the highest source/irq could be reserved. --- Changes in v5: - add early -EINVAL return in route_irq_to_guest() if domain is dying - use __clear_bit() instead of clear_bit() in release_guest_irq() since desc->lock is already held - remove irq_get_domain() wrapper; inline irq_get_guest_info(desc)->d at its single call site - reword IRQ_GUEST comment in do_IRQ() for clarity - move XVFREE(used_irqs) before the switch so it is freed prior to variant-specific vintc teardown - fix missing space in dt_dprintk() format string split across lines - Drop 'inline' for irq_get_guest_info() and leave it only static. - Drop xfree(info) from release_guest_irq() to avoid a potential dangling-pointer issue with the ->dev_id field. Now that 'struct irqaction action;' is embedded into 'struct irq_guest', 'info' will be freed as part of release_irq() at the end. --- Changes in v4: - Update the commit message. - Mark map_irq_to_domain() and map_device_irqs_to_domain() as __overlay_init (mirroring Arm) and include . - Fix grammar in the controller-skip comment ("IRQ" -> "IRQs"). - Drop the redundant 'base' local in guest_imsic_make_reg_property(); use GUEST_IMSIC_S_BASE directly. - Rename vintc::irq_nums -> nr_virqs and update all users. - Guard domain_vintc_deinit() against a NULL d->arch.vintc. - Use smp_rmb() instead of smp_mb() in release_irq()'s wait loop and document how it pairs with the spin_unlock() in do_IRQ(). - In release_guest_irq(), reject live unrouting from a non-dying domain (-EBUSY) and clear _IRQ_GUEST under desc->lock so a concurrent release for the same IRQ bails out instead of double-freeing 'info'. - Tidy spurious whitespace in release_irq()'s spin_lock/unlock calls. --- Changes in v3: - Drop extraneous "to" from "Unable to permit to %pd" message. - Move res/irq/rirq to loop scope; use nirq as declaration initializer. - Hoist irq_ranges check before the loop (it is loop-invariant). - Remove spurious forward declarations (struct dt_device_node, struct rangeset) from intc.h; remove all three from setup.h. - Use __set_bit() instead of set_bit() in intc_route_irq_to_guest() since desc->lock is always held on every write path for desc->status. - Use XVFREE() instead of xvfree() in domain_vintc_deinit(). - Rename allocated_irqs -> used_irqs in struct vintc. - Fix dangling desc->action in release_irq()'s !IRQ_HAS_MULTIPLE_ACTION path by nulling *action_ptr after saving the action pointer. - Use true (not 1) for free_on_release in route_irq_to_guest(). - Use %pd for domain printing in route_irq_to_guest() error paths. - Introduce release_guest_irq() to pair with route_irq_to_guest() and plug the irq_guest info leak; call it from domain_vintc_deinit() for each vIRQ recorded in used_irqs. --- Changes in v2: - Rework IRQ mapping in more common (similar approach to Arm). --- xen/arch/arm/irq.c | 2 +- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/aplic.c | 31 ++++ xen/arch/riscv/device.c | 100 ++++++++++++ xen/arch/riscv/include/asm/intc.h | 9 ++ xen/arch/riscv/include/asm/irq.h | 5 + xen/arch/riscv/intc.c | 60 +++++++ xen/arch/riscv/irq.c | 261 ++++++++++++++++++++++++++++++ xen/arch/riscv/vaplic.c | 9 ++ 9 files changed, 477 insertions(+), 1 deletion(-) create mode 100644 xen/arch/riscv/device.c diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 73e58a5108ad..866fd4c4c6e6 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -205,7 +205,7 @@ void __init init_IRQ(void) static inline struct irq_guest *irq_get_guest_info(struct irq_desc *desc) { ASSERT(spin_is_locked(&desc->lock)); - ASSERT(test_bit(_IRQ_GUEST, &desc->status)); + ASSERT(desc->status & IRQ_GUEST); ASSERT(desc->action !=3D NULL); =20 return desc->action->dev_id; diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index fcd73c7a2dd5..3b948c11dd61 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,6 +1,7 @@ obj-y +=3D aia.o obj-y +=3D aplic.o obj-y +=3D cpufeature.o +obj-y +=3D device.init.o obj-y +=3D domain.o obj-y +=3D domain-build.init.o obj-$(CONFIG_DOM0LESS_BOOT) +=3D dom0less-build.init.o diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index c2d7183e1852..422c65ece4f7 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -325,9 +325,40 @@ static const hw_irq_controller aplic_xen_irq_type =3D { .set_affinity =3D aplic_set_irq_affinity, }; =20 +static unsigned int cf_check aplic_guest_irq_startup(struct irq_desc *desc) +{ + BUG_ON("unimplemented"); +} + +/* + * Shared by ->shutdown(), ->enable(), ->disable() and ->end(), which have + * no state. + */ +static void cf_check aplic_guest_irq_stub(struct irq_desc *desc) +{ + BUG_ON("unimplemented"); +} + +static void cf_check aplic_guest_set_irq_affinity(struct irq_desc *desc, + const cpumask_t *mask) +{ + BUG_ON("unimplemented"); +} + +static const hw_irq_controller aplic_guest =3D { + .typename =3D "aplic", + .startup =3D aplic_guest_irq_startup, + .shutdown =3D aplic_guest_irq_stub, + .enable =3D aplic_guest_irq_stub, + .disable =3D aplic_guest_irq_stub, + .end =3D aplic_guest_irq_stub, + .set_affinity =3D aplic_guest_set_irq_affinity, +}; + static const struct intc_hw_operations aplic_ops =3D { .info =3D &aplic_info, .host_irq_type =3D &aplic_xen_irq_type, + .guest_irq_type =3D &aplic_guest, .handle_interrupt =3D aplic_handle_interrupt, .set_irq_type =3D aplic_set_irq_type, }; diff --git a/xen/arch/riscv/device.c b/xen/arch/riscv/device.c new file mode 100644 index 000000000000..fc41c075c772 --- /dev/null +++ b/xen/arch/riscv/device.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include +#include + +#include + +int __overlay_init map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devnam= e) +{ + int res; + + res =3D irq_permit_access(d, irq); + if ( res ) + { + printk(XENLOG_ERR "Unable to permit %pd access to IRQ %u\n", d, ir= q); + return res; + } + + if ( need_mapping ) + { + /* + * -EEXIST merely means that the IRQ has already been reserved, wh= ich + * legitimately happens when the IRQ is shared between devices. Any + * other failure has to be fatal: the IRQ would otherwise be route= d to + * the domain without domain_vintc_deinit() ever releasing it agai= n. + */ + res =3D vintc_reserve_virq(d, irq); + if ( res && (res !=3D -EEXIST) ) + { + printk(XENLOG_ERR "Unable to reserve vIRQ %u for %pd\n", irq, = d); + return res; + } + + res =3D route_irq_to_guest(d, irq, irq, devname); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to map IRQ%u to %pd\n", irq, d); + return res; + } + } + + dt_dprintk(" - IRQ: %u\n", irq); + + return 0; +} + +int __overlay_init map_device_irqs_to_domain(struct domain *d, + struct dt_device_node *dev, + bool need_mapping, + struct rangeset *irq_ranges) +{ + unsigned int i, nirq =3D dt_number_of_irq(dev); + + if ( irq_ranges ) + return -EOPNOTSUPP; + + /* Give permission and map IRQs */ + for ( i =3D 0; i < nirq; i++ ) + { + int res, irq; + struct dt_raw_irq rirq; + + res =3D dt_device_get_raw_irq(dev, i, &rirq); + if ( res ) + { + printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + /* + * Don't map IRQs that have no physical meaning + * ie: IRQs whose controller is not APLIC/IMSIC/PLIC. + */ + if ( rirq.controller !=3D dt_interrupt_controller ) + { + dt_dprintk("irq %u not connected to primary controller. Connec= ted to %s\n", + i, dt_node_full_name(rirq.controller)); + continue; + } + + irq =3D platform_get_irq(dev, i); + if ( irq < 0 ) + { + printk("Unable to get irq %u for %s\n", i, dt_node_full_name(d= ev)); + return irq; + } + + res =3D map_irq_to_domain(d, irq, need_mapping, dt_node_name(dev)); + if ( res ) + return res; + } + + return 0; +} diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 6fc0e620e937..1bfba7c6155b 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -15,6 +15,7 @@ enum intc_variant { }; =20 struct cpu_user_regs; +struct domain; struct irq_desc; struct kernel_info; struct vcpu; @@ -34,6 +35,9 @@ struct intc_hw_operations { /* hw_irq_controller to enable/disable/eoi host irq */ const struct hw_interrupt_type *host_irq_type; =20 + /* hw_irq_controller to enable/disable/eoi guest irq */ + const struct hw_interrupt_type *guest_irq_type; + /* Set IRQ type */ void (*set_irq_type)(struct irq_desc *desc, unsigned int type); /* Set IRQ priority */ @@ -63,6 +67,8 @@ struct vintc_ops { }; =20 struct vintc { + unsigned int nr_virqs; + unsigned long *used_irqs; /* Callbacks invoked during domain construction only. */ const struct vintc_init_ops *init_ops; /* Runtime callbacks used for the lifetime of the guest. */ @@ -76,10 +82,13 @@ void register_intc_ops(const struct intc_hw_init_ops *i= nit_ops); void intc_init(void); =20 void intc_route_irq_to_xen(struct irq_desc *desc, unsigned int priority); +int intc_route_irq_to_guest(struct irq_desc *desc, unsigned int priority); =20 void intc_handle_external_irqs(struct cpu_user_regs *regs); =20 int domain_vintc_init(struct domain *d); void domain_vintc_deinit(struct domain *d); =20 +int vintc_reserve_virq(const struct domain *d, unsigned int virq); + #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ diff --git a/xen/arch/riscv/include/asm/irq.h b/xen/arch/riscv/include/asm/= irq.h index 62648bdc4252..57e814d90cf4 100644 --- a/xen/arch/riscv/include/asm/irq.h +++ b/xen/arch/riscv/include/asm/irq.h @@ -52,6 +52,11 @@ void init_IRQ(void); =20 void do_IRQ(struct cpu_user_regs *regs, unsigned int irq); =20 +int route_irq_to_guest(struct domain *d, unsigned int virq, + unsigned int irq, const char *devname); + +int release_guest_irq(const struct domain *d, unsigned int virq); + #endif /* ASM__RISCV__IRQ_H */ =20 /* diff --git a/xen/arch/riscv/intc.c b/xen/arch/riscv/intc.c index f5c8af6ddea4..bca83b4f4fa3 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -3,11 +3,15 @@ #include #include #include +#include +#include #include #include #include #include +#include #include +#include =20 #include #include @@ -78,6 +82,22 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsign= ed int priority) intc_set_irq_priority(desc, priority); } =20 +int intc_route_irq_to_guest(struct irq_desc *desc, + unsigned int priority) +{ + ASSERT(spin_is_locked(&desc->lock)); + + ASSERT(intc_hw_ops->guest_irq_type); + + desc->handler =3D intc_hw_ops->guest_irq_type; + __set_bit(_IRQ_GUEST, &desc->status); + + intc_set_irq_type(desc, desc->arch.type); + intc_set_irq_priority(desc, priority); + + return 0; +} + int __init make_intc_domU_node(struct kernel_info *kinfo) { const struct vintc *vintc =3D kinfo->bd.d->arch.vintc; @@ -101,6 +121,15 @@ int domain_vintc_init(struct domain *d) break; } =20 + if ( !ret ) + { + d->arch.vintc->used_irqs =3D + xvzalloc_array(unsigned long, + BITS_TO_LONGS(d->arch.vintc->nr_virqs)); + if ( !d->arch.vintc->used_irqs ) + ret =3D -ENOMEM; + } + return ret; } =20 @@ -108,6 +137,20 @@ void domain_vintc_deinit(struct domain *d) { const enum intc_variant variant =3D intc_hw_ops->info->hw_variant; =20 + if ( !d->arch.vintc ) + return; + + if ( d->arch.vintc->used_irqs ) + { + unsigned int virq; + + for ( virq =3D 0; virq < d->arch.vintc->nr_virqs; virq++ ) + if ( test_bit(virq, d->arch.vintc->used_irqs) ) + release_guest_irq(d, virq); + + XVFREE(d->arch.vintc->used_irqs); + } + switch ( variant ) { case INTC_APLIC: @@ -118,3 +161,20 @@ void domain_vintc_deinit(struct domain *d) break; } } + +/* + * Mark @virq as used by @d so that domain_vintc_deinit() knows that it ha= s to + * be released. + * + * Returns 0 on success, -EEXIST if @virq has already been reserved, which + * legitimately happens when an IRQ is shared between devices, and -ERANGE= if + * @virq is outside the range of the interrupt sources the vINTC provides. + */ +int __overlay_init vintc_reserve_virq(const struct domain *d, + unsigned int virq) +{ + if ( virq >=3D d->arch.vintc->nr_virqs ) + return -ERANGE; + + return test_and_set_bit(virq, d->arch.vintc->used_irqs) ? -EEXIST : 0; +} diff --git a/xen/arch/riscv/irq.c b/xen/arch/riscv/irq.c index b5066fc3e981..df0c4668dbbf 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -12,11 +12,27 @@ #include #include #include +#include #include +#include =20 #include #include =20 +/* Describe an IRQ assigned to a guest */ +struct irq_guest +{ + struct domain *d; + unsigned int virq; + /* + * The action of a guest IRQ has the same lifetime as this structure, = so + * embed it here to have both covered by a single allocation. Conseque= ntly + * it must not be freed on its own, which is why free_on_release is le= ft + * false for it (see irq_release_action()). + */ + struct irqaction action; +}; + static irq_desc_t irq_desc[NR_IRQS]; =20 struct irq_desc *irq_to_desc(unsigned int irq) @@ -198,6 +214,14 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int i= rq) if ( desc->handler->ack ) desc->handler->ack(desc); =20 + if ( desc->status & IRQ_GUEST ) + /* + * With APLIC + IMSIC, guest interrupts bypass Xen and are deliver= ed + * directly to the guest. Without IMSIC, interrupts would be trapp= ed + * by Xen and would need injecting into the guest here. + */ + panic("unimplemented"); + if ( desc->status & IRQ_DISABLED ) goto out; =20 @@ -227,3 +251,240 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int = irq) spin_unlock(&desc->lock); irq_exit(); } + +static struct irq_guest *irq_get_guest_info(struct irq_desc *desc) +{ + ASSERT(spin_is_locked(&desc->lock)); + ASSERT(test_bit(_IRQ_GUEST, &desc->status)); + ASSERT(desc->action); + + return desc->action->dev_id; +} + +/* + * Detach the action registered with 'dev_id' from 'desc' and, if it was t= he + * last one, shut the interrupt down. + * + * To be called with desc->lock held, which is still held upon return. The + * detached action is returned (NULL if 'dev_id' had no action registered)= and + * has to be handed to irq_release_action() once the lock has been dropped. + */ +static struct irqaction *irq_detach_action(struct irq_desc *desc, + const void *dev_id) +{ + struct irqaction *action, **action_ptr =3D &desc->action; + + ASSERT(spin_is_locked(&desc->lock)); + +#ifdef CONFIG_IRQ_HAS_MULTIPLE_ACTION + for ( ;; ) + { + action =3D *action_ptr; + if ( !action || (action->dev_id =3D=3D dev_id) ) + break; + + action_ptr =3D &action->next; + } +#else + action =3D *action_ptr; +#endif + + if ( !action ) + { + printk(XENLOG_WARNING "Trying to free already-free IRQ %u\n", + desc->irq); + return NULL; + } + + /* Found it - remove it from the action list */ +#ifdef CONFIG_IRQ_HAS_MULTIPLE_ACTION + *action_ptr =3D action->next; +#else + *action_ptr =3D NULL; +#endif + + /* If this was the last action, shut down the IRQ */ + if ( !desc->action ) + { + desc->handler->shutdown(desc); + desc->status &=3D ~IRQ_GUEST; + } + + return action; +} + +/* + * Complete the release of an action detached by irq_detach_action(). + * + * To be called with desc->lock dropped: the lock cannot be held all the w= ay + * through, as waiting for a handler still running on another CPU to compl= ete + * requires do_IRQ() to be able to acquire the very same lock. + * + * Once this function has returned, the action (and hence any object embed= ding + * it) is no longer referenced by anyone and may be freed. + */ +static void irq_release_action(const struct irq_desc *desc, + struct irqaction *action) +{ + /* Wait to make sure it's not being used on another CPU. */ + while ( test_bit(_IRQ_INPROGRESS, &desc->status) ) + cpu_relax(); + + /* + * _IRQ_INPROGRESS is cleared in do_IRQ() after re-acquiring desc->loc= k, + * and lock acquisition implies a full barrier, so the handler's acces= ses + * are ordered before the clearing becomes visible here. The barrier b= elow + * adds the missing load-load ordering (the loop's exit branch already + * prevents the store in xvfree() from becoming visible early), so that + * having observed the bit cleared we also see whatever the handler di= d on + * that CPU. Only then is it safe to free the action. + */ + smp_rmb(); + + if ( action->free_on_release ) + xvfree(action); +} + +void release_irq(unsigned int irq, const void *dev_id) +{ + struct irq_desc *desc =3D irq_to_desc(irq); + struct irqaction *action; + unsigned long flags; + + spin_lock_irqsave(&desc->lock, flags); + action =3D irq_detach_action(desc, dev_id); + spin_unlock_irqrestore(&desc->lock, flags); + + if ( action ) + irq_release_action(desc, action); +} + +int release_guest_irq(const struct domain *d, unsigned int virq) +{ + struct irq_desc *desc =3D irq_to_desc(virq); + struct irqaction *action; + struct irq_guest *info; + unsigned long flags; + int ret =3D -EINVAL; + + spin_lock_irqsave(&desc->lock, flags); + + if ( !test_bit(_IRQ_GUEST, &desc->status) ) + goto unlock_err; + + info =3D irq_get_guest_info(desc); + if ( d !=3D info->d ) + goto unlock_err; + + /* + * Detaching the action happens with desc->lock still held, so that a + * concurrent release_guest_irq() for the same IRQ sees _IRQ_GUEST alr= eady + * cleared and bails out, rather than capturing the same 'info' and + * double-freeing it below. + */ + action =3D irq_detach_action(desc, info); + + spin_unlock_irqrestore(&desc->lock, flags); + + if ( action ) + irq_release_action(desc, action); + + xvfree(info); + + return 0; + + unlock_err: + spin_unlock_irqrestore(&desc->lock, flags); + return ret; +} + +/* Route an IRQ to a specific guest */ +int route_irq_to_guest(struct domain *d, unsigned int virq, + unsigned int irq, const char *devname) +{ + struct irq_guest *info; + struct irq_desc *desc =3D irq_to_desc(irq); + unsigned long flags; + int retval =3D 0; + + if ( d->is_dying ) + return -EINVAL; + + info =3D xvzalloc(struct irq_guest); + if ( !info ) + return -ENOMEM; + + info->d =3D d; + info->virq =3D virq; + + info->action.dev_id =3D info; + info->action.name =3D devname; + /* The action is part of 'info', thus it is freed together with it. */ + info->action.free_on_release =3D false; + + spin_lock_irqsave(&desc->lock, flags); + + /* + * If the IRQ is already used by someone + * - If it's the same domain -> Xen doesn't need to update the IRQ de= sc. + * For safety check if we are not trying to assign the IRQ to a + * different vIRQ. + * - Otherwise -> For now, don't allow the IRQ to be shared between + * Xen and domains. + */ + if ( desc->action !=3D NULL ) + { + if ( test_bit(_IRQ_GUEST, &desc->status) ) + { + struct domain *ad =3D irq_get_guest_info(desc)->d; + + if ( d !=3D ad ) + { + printk(XENLOG_G_ERR "IRQ %u is already used by %pd\n", + irq, ad); + retval =3D -EBUSY; + } + else if ( irq_get_guest_info(desc)->virq !=3D virq ) + { + printk(XENLOG_G_ERR + "%pd: IRQ %u is already assigned to vIRQ %u\n", + d, irq, irq_get_guest_info(desc)->virq); + retval =3D -EBUSY; + } + } + else + { + printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq); + retval =3D -EBUSY; + } + goto out; + } + + retval =3D _setup_irq(desc, 0, &info->action); + if ( retval ) + goto out; + + retval =3D intc_route_irq_to_guest(desc, IRQ_NO_PRIORITY); + if ( retval ) + { + struct irqaction *action =3D irq_detach_action(desc, info); + + spin_unlock_irqrestore(&desc->lock, flags); + + if ( action ) + irq_release_action(desc, action); + + goto free_info; + } + + spin_unlock_irqrestore(&desc->lock, flags); + + return 0; + + out: + spin_unlock_irqrestore(&desc->lock, flags); + free_info: + xvfree(info); + + return retval; +} diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index a529a5b1dc49..14f6e3164a9b 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -113,6 +113,15 @@ int domain_vaplic_init(struct domain *d) =20 vaplic->regs.domaincfg =3D APLIC_DOMAINCFG_RO; =20 + /* + * APLIC source 0 is reserved; sources are numbered 1..guest_aplic_num= _sources + * and used directly as indices into used_irqs. Size the bitmap to + * guest_aplic_num_sources + 1 so the highest source has a valid slot + * (index 0 stays unused). Without the +1, vintc_reserve_virq() can't = record + * the top source, so domain_vintc_deinit() never releases it. + */ + d->arch.vintc->nr_virqs =3D guest_aplic_num_sources + 1; + return 0; } =20 --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966564; cv=none; d=zohomail.com; s=zohoarc; b=k9OsmQgEhj+7/mvEu3Efyfra5exmZboyLWRDh52K59Xu/qSPmkjCdbWgskQh0EHYOqZKtC+E7EaY3c+Vk7kSVfgMlFHhSvjfD7bQPO/RK5ZFA9+VqgCFc4BG67iOhCpiomgGU4Ot0DcwEaFWGkJ6Ds7l8xarcVoN0X4tAon/tzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966564; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2X2VEgPXszXG0oyqHbVR3NMIcSkcalO4zvs2bK/KDwI=; b=HdP/el1jETh6tv/dQb+ufqLegDF+zkPk4SHhGHx7n33CmnWCFZzOyH9kh+EulzQJ82XR8qmZMVno7zbYa5CvOXh33fG2Lub6ofjgidCR9iaMCmZuAkYllcYONiWx/e4OOH0igquUqtsCdGIG3zvNKGJdLdnuFLaaIG0WmA6md8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966564760439.02326228313336; Wed, 9 Sep 2026 08:09:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413308.1643599 (Exim 4.92) (envelope-from ) id 1x4JvB-0005y6-Bn; Wed, 09 Sep 2026 15:09:09 +0000 Received: by outflank-mailman (output) from mailman id 1413308.1643599; Wed, 09 Sep 2026 15:09:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JvB-0005xp-7Q; Wed, 09 Sep 2026 15:09:09 +0000 Received: by outflank-mailman (input) for mailman id 1413308; Wed, 09 Sep 2026 15:09:08 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JvA-0005pP-HG for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:09:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4Jv9-007zEL-U9 for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:09:07 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17692-2eae-0a2a0a5409dd-0a2a4503b4d4-10 for ; Wed, 09 Sep 2026 17:09:07 +0200 Received: from [209.85.218.41] (helo=mail-ej1-f41.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17693-fae8-0a2a45030019-d155da29cdaf-3 for ; Wed, 09 Sep 2026 17:09:07 +0200 Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-c2941f7229dso45907066b.1 for ; Wed, 09 Sep 2026 08:09:07 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:09:07 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966547; x=1789571347; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2X2VEgPXszXG0oyqHbVR3NMIcSkcalO4zvs2bK/KDwI=; b=cUoFw3E7EihKMubAZAa+sRY1cB67G9SxB6stNh6MaeTVbxsdHcxDri9OUSgR56QTsj 0wzJgFp+53wpniop+7N8iaIm0HyX8uLBw5VPXKrehsJtjxAdX283l1bnFzeUu/U0KKRb DluM+GCKs/FX1l5viUyQrSkMHb5HDwfWddJ2DvCYbv7U3wNG2G9Oos+GDuDtCHg3UJDW QwkmSqrl4Rzei3Lx15rF8IOReUKLlQWOxlniP6lKmWi3w5ibzAkadzXYx5XwPyHOylFO jdE6dXlS42NpQJwTqEAymM9GFZOsB93uEcsl/QaiYHMy4D+NkJw0yi8XNRYDkMftNIQy WF/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966547; x=1789571347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=2X2VEgPXszXG0oyqHbVR3NMIcSkcalO4zvs2bK/KDwI=; b=HVoW+i3ld+nfIWrVIT8YRgsvGf8n/04DIRv5WuBgfX0yrvhYCADJrX9Cq3HRGvt+FD nueHWZhqCMR5UVnaY8RMV/R8x3rdElp0MaW7gUkO7i4JabIP1U+aJ12yAU7MXUVBmAfo lIXV+1/6+K0EBumEs1ihfetVfG9+W3cmgRpIOM+FIopzxwPKlf9M/6kufgivY8dHIORR 5ON33qbpXuh9cFaBFu/x3vr/ukbGdOH8Q9O/5nPrKAjupWG6cGn026Anqkk1sH98eKEm NGZUbu2DyS6BUU7nDexp1w/r4qBPrggQgUsZoJIz6Ylye2Z2AXU4CWZgUCjA550bSnyo 8joQ== X-Gm-Message-State: AFuF++nCqfa33KnEKTUr2RW9vnt6PRokJ8ua14ldB2FS/VV/P+C/niCZ mQcp8uJ5KpqxAYjT+sWKNoORnqeYRmszzDf9DTt/xJ7ow+m9t1VkiJr+dMGsGh0I X-Gm-Gg: AYBFou16Aj32WZ1fZpg6lwXOJquLEndyfrg2X+WAB+STEfTV5wZHgEkjLp4PaNGtUby jVMxOs3bDvcuiZt6VXa+LhTB9G+fQwF4QwANaBb9p/3660Rt6s9Yb3nV5AMwrIo9sgD194pftbR +z9w+sZGBw70rgrhKUdEM8x6AJaGOq/RxWytLG3jqQbWdafwcDVtZWwEa8dtgFR0/3zLxsOCpKm kAOEW9x/ufMkLuT0q7W8269nkrjRaecpHAVnHnoUxo+ZxbZvWZvyFnnPUSVQOcPXfadgdEVJLta 6UmHm10RI6gIGVT2yWjo/dzyDIS4vbsA7YqLoo1qpiFF6Na9pgCktuhuLcLUbH31WSQo9fl5TLd dKDIozqsJEqryRJmR+dBSWAT8/SnNrYQopBgdUvuO5mMHvGonoZPKQyXKnThE5SdH5UkrBARAjT pxdgsYULwqK+xi72285uF89m+6qMdND0IPrzowj4gJnVph3FU4vndAG++A3CeqzBV6dqoccfFlq NJxL6wQr2CYuNzXpEY= X-Received: by 2002:a17:907:7281:b0:c25:cb7a:12d6 with SMTP id a640c23a62f3a-c260c9972aemr1413358966b.14.1788966547335; Wed, 09 Sep 2026 08:09:07 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 17/20] xen/riscv: implement init_intc_phandle() Date: Wed, 9 Sep 2026 17:07:35 +0200 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1788966547-768FA4E9-CDF77EAF/10/73395122804 X-purgate-type: spam X-purgate-size: 1373 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966565376158500 Content-Type: text/plain; charset="utf-8" Implement init_intc_phandle() to read phandle of interrupt controller node and save it in kernel->phandle_intc for the future usage during creation of guest interrupt controller node. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v4-9: - Nothing changed. Only rebase. --- xen/arch/riscv/dom0less-build.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-buil= d.c index 4cc00012aa8d..a1fa51b996a7 100644 --- a/xen/arch/riscv/dom0less-build.c +++ b/xen/arch/riscv/dom0less-build.c @@ -4,9 +4,26 @@ #include #include #include +#include =20 #include =20 +int __init init_intc_phandle(struct kernel_info *kinfo, const char *name, + const int node_next, const void *pfdt) +{ + if ( dt_node_cmp(name, "intc") =3D=3D 0 ) + { + uint32_t phandle_intc =3D fdt_get_phandle(pfdt, node_next); + + if ( phandle_intc !=3D 0 ) + kinfo->phandle_intc =3D phandle_intc; + + return 0; + } + + return 1; +} + int __init make_arch_nodes(struct kernel_info *kinfo) { /* No RISC-V specific nodes need to be made, at the moment. */ --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966578; cv=none; d=zohomail.com; s=zohoarc; b=TEDRnmsHV47qc6RWBEar4MFy3F22JmgZUzkBLZhg/GREEPRE/a+aE3kkClMiTuV1NudG3SL+aNY8mNWEixC+eCRtOm6fP6dM5cOZyqZzRJSe3O8X4c5bM5P/znZLV/8Ijcm/mmZuGR9Gi7clKTsQUr6a97EJ8rzVyDD70e9vz9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966578; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NRZDx0chfMO39A9GRZrF50iTQKdAjHPK16jqhdN5EMw=; b=CSDALcGB2IKuV9EIqXLF49ZBvmmAzC+W/DvkczqM4l6XlixEyMt7fVsLi9kt//uOTMw59EhMYUv55todvwfJlu1qyrxesP3BKlQwFz7bU6gEY9TZxpBB4zWVGtbwe6LfgL63NFk2aUHUylp+ZCkcYKCtKbVv7DARl4rlLvTNZ7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966578164113.58639502818403; Wed, 9 Sep 2026 08:09:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413312.1643609 (Exim 4.92) (envelope-from ) id 1x4JvD-0006LW-OU; Wed, 09 Sep 2026 15:09:11 +0000 Received: by outflank-mailman (output) from mailman id 1413312.1643609; Wed, 09 Sep 2026 15:09:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JvD-0006Kq-GO; Wed, 09 Sep 2026 15:09:11 +0000 Received: by outflank-mailman (input) for mailman id 1413312; Wed, 09 Sep 2026 15:09:10 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JvC-0006DU-HR for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:09:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JvB-003DYK-UB for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:09:09 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa1768c-8faa-0a2a0a5109dd-0a2a4505e412-24 for ; Wed, 09 Sep 2026 17:09:09 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17695-4cb1-0a2a45050019-4a7de48c9262-3 for ; Wed, 09 Sep 2026 17:09:09 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c294496989aso15988166b.3 for ; Wed, 09 Sep 2026 08:09:09 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:09:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966549; x=1789571349; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NRZDx0chfMO39A9GRZrF50iTQKdAjHPK16jqhdN5EMw=; b=qe/7EVF5HDwkYa29mb6UMD7aiaNVCK/0OjOmgroXrl+CfQSmbADxq0tAeUo55qV/Nu xBSXsn3fZAnRVRoMPRVayAvH3H1oPcL8rpRWQvVMOAf7+coGYWaMY4/UyP8Jp11U+QxS /p9c2E+uRsHlWv6H2vaRBg0Bx4FLQ1h6OSTictMvodiEyU55u2lQbMwyDC1Lpr7EmA4L VIwvXyjVFi/bC/N3EDT7Stcx2Szpf08GK+gFtga4O9Vx1xE6DQ0sHACM0WqZCE30wibO XlnVNYtLAkeQIO0xnepXpPp1yVGy9kHTQ95ZodUmOcVqygSMHpVlBtvVH+lYvPEogLbK hJng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966549; x=1789571349; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NRZDx0chfMO39A9GRZrF50iTQKdAjHPK16jqhdN5EMw=; b=fwc+mwFjib9d0t9Pn2OBE9tmHzoRMB3HvuiCUsU+2+oxcjPh0EgxCJynLvqxlEIDLA eQe23zOKhqiApVnut1C5FGrl4AsjUerSTmI2lf5B0dTWcS6k+yMoM9RZOJlbBtHYOUkJ qQu8xthDGw8quy0lUv/RqNYEWOcbP4wp1tt8O6R6eGaj2ZDw/9tUceRhlHfBTZEdSTYu 3y+Qfv34372+jHQOp7u1V3mUkT4fB9S3Vl3arTzK+RENksSPmUEnD8QP6+h7dl4mumUt yJ64LaqsfksMLHxFKKJnbHjiR4mT1iWy/pJ45DxofpCRBu2kcrWBd3lJrt7pT00GVhle PJDw== X-Gm-Message-State: AFuF++mL/yGQJEaydyMNK05CDKLfPDV3DaeBSfzNQ12iypAQJOphxUti iEBkUay5GY85lZZxerdi+ldaZNHxdz/iIC9/6qtBCQWaXr2o6STbXtF9Mf6LDLr3 X-Gm-Gg: AYBFou0SZuMIyE5Fyq2XAbxJUhHxSbdOZKuTJPpis9JBiB+94/SG7RBnpGJPA4lxlei KPbGnHDhY3/nRUZIRtvnjHVlaVxRjm48E5jIl/Kglk2Z1V9fCieKip0/pcvaBc+C0csWUlj1PZ1 ZwsV4R6XeE1gjuvCfYk4+4bNNP6LmQw5g6f2HsLy7wfj1ykh5TagVpoxMz0ec3YeFa5j3AqTD7J vQWHv0wbPVT7Jd5CNq5XcQwfESXnNTwbceSe81U9KwVSGOgmaAA0M/ffjEgfTSplQ2FO2tQeX2r +RX/4Okcsb5+TfnndK0QZQpjD6TZzhx1VIkubwB21MwO/lIWZcgxtk3xolWO9zdQai+/eSnuV5k +rGD9ENWDw73j4/YJHR1ijl6EpAPO8nbBYnHwfEj+pWysabaavd4sedjk9fg+kapC7uStnx1UjW KB/U0BOO6MOBSv3dAcCRTvhXr4ACLYlK6K+L2zjSdsoJUCw7JVksXsQK67s4F/V4A1eh27Rt2Pv +OFtQSkeG/1svyB68M= X-Received: by 2002:a17:907:3f16:b0:c25:977e:5377 with SMTP id a640c23a62f3a-c2941866b25mr73624966b.10.1788966549400; Wed, 09 Sep 2026 08:09:09 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 18/20] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Wed, 9 Sep 2026 17:07:36 +0200 Message-ID: <8d5aa546940bc94610fb24e90b7ab3868ab18420.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1788966549-72CB02A1-D99ED192/10/73395122804 X-purgate-type: spam X-purgate-size: 1560 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966579513158500 Content-Type: text/plain; charset="utf-8" Wire up the missing early-boot initialization steps in start_xen(). The scheduler must be initialized prior to do_initcalls() because cpupool_create_pool() is called during initcalls; without it, BUG_ON(IS_ERR(pool)) is triggered inside cpupool_create_pool(). Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v4-9: - Nothing changed. Only rebase. --- Changes in v3: - Add Acked-by: Jan Beulich . --- Changes in v2: - New patch. Several patches were folded into one. --- --- xen/arch/riscv/setup.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 56a0907a855f..c3e98733ebc3 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -6,9 +6,12 @@ #include #include #include +#include #include #include #include +#include +#include #include #include #include @@ -156,12 +159,21 @@ void __init noreturn start_xen(unsigned long bootcpu_= id, =20 timer_init(); =20 + rcu_init(); + + setup_system_domains(); + local_irq_enable(); =20 console_init_postirq(); =20 guest_mm_init(); =20 + scheduler_init(); + set_current(idle_vcpu[0]); + + do_initcalls(); + printk("All set up\n"); =20 machine_halt(); --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966576; cv=none; d=zohomail.com; s=zohoarc; b=Iu2lDg4apq8SXW7eLz0Zf02EhMk/c1t+2JBdQpnwtP4U82OobRcrNUnYDMfgstRzaltijZhl0LpW9YX5A6p7patdXH/H0xtqb3ocsHaKLZjXi7TYsMWRfefyndvBrxWkisiZmj+oKP8p3CopDfyFmtihCXYQUoB8tkG3WhcDcxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966576; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Vye8DtWFQY9KBcaSdJnoE64blVyzkPlMXr9ggX+iVYM=; b=eXwpf79Ypi/iWUse5VvXRbBW8DQoQ99hqP7WjXRYiwqrv3AmMsEU1Ka/mI1i8r40GP+sectwBivvF9X5FXysbizloUOwQCDDpvlQ19cbjEyxczcEmSiz1dPdLG9PNOJTyr1Ak5gVZU7W7S3RrFUBrbmmLXZ+wqzEG9KoWZqCgvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966576193601.4702974964385; Wed, 9 Sep 2026 08:09:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413316.1643616 (Exim 4.92) (envelope-from ) id 1x4JvF-0006gB-UG; Wed, 09 Sep 2026 15:09:13 +0000 Received: by outflank-mailman (output) from mailman id 1413316.1643616; Wed, 09 Sep 2026 15:09:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JvF-0006g0-R8; Wed, 09 Sep 2026 15:09:13 +0000 Received: by outflank-mailman (input) for mailman id 1413316; Wed, 09 Sep 2026 15:09:12 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JvE-0006X6-MZ for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:09:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JvE-007zEL-3V for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:09:12 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17692-2eae-0a2a0a5409dd-0a2a4503b4d4-34 for ; Wed, 09 Sep 2026 17:09:12 +0200 Received: from [209.85.218.52] (helo=mail-ej1-f52.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa17697-fae8-0a2a45030019-d155da34e5a0-3 for ; Wed, 09 Sep 2026 17:09:11 +0200 Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-c15e2dab83eso1042514866b.1 for ; Wed, 09 Sep 2026 08:09:11 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:09:10 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966551; x=1789571351; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Vye8DtWFQY9KBcaSdJnoE64blVyzkPlMXr9ggX+iVYM=; b=UqTVnUfhE7qWw5I9ygN5vrIRvv4W0CWHlOT98ZujTx5FBhLOVDcE8CFV+1fXCOAz0f wwBjDXUmgolF1LcioS4WUJx9vBtyvBEM66arlHae0NMTPRDqKo1jKnzv/X2PVStkx2sm ldTrxUiUrqnt5BHNtZ7LbErww2PWGezp5ZhcGvFB89u2FbZ7sncLxymAhFB8OR5KeuA8 GmeN0M6ndrsYMR5YJ8pSv4LENLJzqBvRvhzJLKDw9vWOF85Zzzoln/Lm+5/3XeE8jKU/ sgsOdcw0N/IlODq4szTYerg0RbrmLu1IHukxcC3k+Jud35dRvYwJA2we88TBdl9DhVLH 6RbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966551; x=1789571351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Vye8DtWFQY9KBcaSdJnoE64blVyzkPlMXr9ggX+iVYM=; b=lZ7KLeYmXobiXyctbm71zRl/OhRgy1EFcm24jTeCACQpd3cEisN8hZIKa1f65/S7TG N5SLdfI8zmf/gb9W6nxTy8MX7DePc5GkQkXxIZV24ufRJWTD6oFmjNjtmy6w8uPgw7Uu mAP0mlErEYkonUR25sgoNQtI4meJWZHaOvlgGVmEF4P2UWFtA+TNhOFy/vXsE3WW9C6W Dy3xndXUi4hUe9ilvAO+ELSXpzXafQkZCokkAllvzxT0RtVZ8vR9FJkCHDcX1sUUrQgH 5lZcqAudXPqw5SfHhn0vuGKm239NBOMe1qsIhi4PTTUyy797EYYalkpA7aU7XH8JoEA/ UChA== X-Gm-Message-State: AFuF++kgGKjd/4hd99UKPy99ffS6I2CuIkJp8w1YO5SFR/sQDEcTZdJZ e5cb8XUlq1wqoBEgz8gZuuYzkoP4wrfBodRPlO+bxdjGe2pa2VHJ0ncr73GS+wQV X-Gm-Gg: AYBFou3xnaKbz5ZKW2ZygWeqoqq/syYOY9Ayxhpqei2lnOYNkTCzcSS6RgZwIsS6PL/ 09xNJ1n+aKOgZ7zZ3fYZ+6pxqM5EGxWDe2zT0t7gmtlHkDMXY5Cecd7WDPmFCFKDsqJHIlj1JXG eimRHtMS2uxj4FZK+3dckc7TH8SCD4StRILvPxnsJhgAwIcJZE2CAMeDOVsYOf3dh3ng+AA+5o4 Sw8jPciS3QPM664D1jE9f248OQlTAeB8xxAT81XdP8G5BmXNsZAp6rzIDp1+pnrlBTLvkoyQ+Oz WiFJ/ZcfW7La4UmGtToVjTaau8OGEKWrXXgY021yu+iPXY/v+0FmC3UprqZvgOLxL6Hv/DrSpRW v7N04K2vBGATqVVVX+dvEsIklsCVpSW4PDfMZCfFBcOxc9fOCOif89hBHVi5PLSmT6+BK/jTGcr fmyohetMpyPiEwfkwRH4RyFgVEF4Pk6R5pvM1e9FEHJ97rtlNlZRtxPHYqn7SMIJgSeZwUATitW h1S X-Received: by 2002:a17:907:c81a:b0:c21:726b:34eb with SMTP id a640c23a62f3a-c260c7ad2e2mr1393683466b.8.1788966551230; Wed, 09 Sep 2026 08:09:11 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 19/20] xen/riscv: provide init_vuart() Date: Wed, 9 Sep 2026 17:07:37 +0200 Message-ID: <91853d1537d3222998d82fd1319631b0dc36a36c.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1788966551-6CCDB4E9-19B190E9/10/73395122804 X-purgate-type: spam X-purgate-size: 1391 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966577515158500 Content-Type: text/plain; charset="utf-8" For debug purpose is enough to have only print messages from guest what is now implemented in vsbi_legacy_ecall_handler(). For full guesst console support it will better to have something similar to [1], thereby there is nothing specific should be done, at least, for now and init_vuart() is provided to make dom0less code buildable. [1] https://lore.kernel.org/xen-devel/alpine.DEB.2.22.394.2602041533440.317= 5371@ubuntu-linux-20-04-desktop/ Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v3-v9: - Nothing changed. Only rebase. --- Changes in v2: - Add Acked-by: Jan Beulich . --- --- xen/arch/riscv/dom0less-build.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-buil= d.c index a1fa51b996a7..d1a51b92936a 100644 --- a/xen/arch/riscv/dom0less-build.c +++ b/xen/arch/riscv/dom0less-build.c @@ -8,6 +8,14 @@ =20 #include =20 +int __init init_vuart(struct domain *d, struct kernel_info *kinfo, + const struct dt_device_node *node) +{ + /* Nothing to do at the moment */ + + return 0; +} + int __init init_intc_phandle(struct kernel_info *kinfo, const char *name, const int node_next, const void *pfdt) { --=20 2.55.0 From nobody Thu Sep 24 19:40:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1788966590; cv=none; d=zohomail.com; s=zohoarc; b=TaoE5FliroypOogk1ew9l3qEArhUrbaOO9eARkunTx14qSQqdqpzNafWoh+OhKM1CDiMsUdXkVgd7rYsIR6cDXynYNLZsvVlAr1RwIsd+j3Hfmp+k4acN5pZGDLXVUXq/pAk/b0Djpxz3w3BFm9PSEL8t1fBbghr3sGaX3veQqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788966590; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0ob9SOR6fkbhNbTtoSGEUBOvglDU9/ukL9qvQqIiBtg=; b=al1hg+oVNJx6XSGoCxSJ0dI8OtlcT2XBuBenoSr8ad7A+ilVVRHPNvUHHGDsFK1t7dLaVeUpicu5LCF9w1yrqE47B9UKxws8C2wWnEuUA03YeX2ZbgQ486MC047/8/NpqKvMb2dzXX8FCyiCII6+UdV0qE8NyIPgsyaJIiXz3qg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1788966590960919.0698143320941; Wed, 9 Sep 2026 08:09:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1413319.1643626 (Exim 4.92) (envelope-from ) id 1x4JvK-0007H0-9D; Wed, 09 Sep 2026 15:09:18 +0000 Received: by outflank-mailman (output) from mailman id 1413319.1643626; Wed, 09 Sep 2026 15:09:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1x4JvK-0007GJ-4m; Wed, 09 Sep 2026 15:09:18 +0000 Received: by outflank-mailman (input) for mailman id 1413319; Wed, 09 Sep 2026 15:09:16 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1x4JvI-000724-6b for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 15:09:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1x4JvH-007zEL-JX for xen-devel@lists.xenproject.org; Wed, 09 Sep 2026 17:09:15 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6aa17690-2eae-0a2a0a5409dd-0a2a450ad276-22 for ; Wed, 09 Sep 2026 17:09:15 +0200 Received: from [74.125.228.140] (helo=mail-ej2-f12.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6aa1769b-f2d2-0a2a450a0019-4a7de48ca1bb-3 for ; Wed, 09 Sep 2026 17:09:15 +0200 Received: by mail-ej2-f12.google.com with SMTP id a640c23a62f3a-c254f8694aeso186373966b.0 for ; Wed, 09 Sep 2026 08:09:15 -0700 (PDT) Received: from fedora (IW396200.net.t-com.hr. [195.29.234.54]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c261f673000sm709991666b.24.2026.09.09.08.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2026 08:09:13 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788966554; x=1789571354; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0ob9SOR6fkbhNbTtoSGEUBOvglDU9/ukL9qvQqIiBtg=; b=E9mYlKZpnx2qYl+g28RrvGiIRdnB9Uw3FR62pmuXncQnbtBGz8TWsQ0B9OcvRx5aXU qYTk+aV0ZdMYmCJaSPj8EUQyf8ZhcKDApmpzTriqtujOJ6r/80b5059FAHty6USXeMKN QE2PAj30WHjlvHaRUb+Q4fC0GNRkcKz7ODc7HEiKP64zDuP3813TcRqxhtVMEDJgt+xg eZU3QBuCTIpFei9sOIlReYPnDvywgfLLGylXwo3SO39bArIZgm+UZ4dgRumD53C/DQ/J RDdCP1SzDHU3sDn1StKnV85LsaidnfxPpQIqR3ZVtk2RdAW03k7TNWF9OdqmHkJ9TvwQ 1NHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788966554; x=1789571354; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0ob9SOR6fkbhNbTtoSGEUBOvglDU9/ukL9qvQqIiBtg=; b=JqReOxjI9XSddQR1x7Lwagnq7Lsg1f0XR4rqzQwlMDFQAJPt2Se9agkthboHbbMWb1 HX2tgsE2l1UiEU34f9QluMA8FqhZ04fwn8YbCB89HUupl2J5hNnclzulgsxcfh1sx0lc HtWX/sKV4v/69UtyFEHYUyGrIebq2kEWo0peHlI4FppIyNDKh4bd725QQAb7ShO0zgjZ 3cOWBep9h608DU4Gz6nSCqzJZj7nLP+G5+CHx5rh3l5tYUoMKah3bt/8HB0Uv1iVzf4A UkO0XjTZIiw4NOPhvWVjCaXc+/19WCmVri6X5LCa+YEoWrhLdhmM4lMx0Kie3WmLhVfR OZ8Q== X-Gm-Message-State: AFuF++kgWA4KF04RsHBmZgiTOgf/w92ZKUza3vv58OHX/HGScJwa4ngj swL7mdtG4FY+inrfLkMpHrnDGE2sAdr6QflN1uJqZTuvF6Ca05SMfnrxNGAeG9Xt X-Gm-Gg: AYBFou3LUaX/7RVj1XA8I2fRIHpFyUbeQVO5wWDmrGCoKaCVW0LlqtPsH9wCN6/Kpsl tjiSQo/0ZJEQ4EfMjkVyc95TKSjkArVq+8KBnZxdEF2bAMNNpNGxxGYemS4hDbB+Za0ehPxqyDJ Ls0WcYLQhBg2Rd3zAlh6ZTQXmRhYMAl3kzMrp9J6g1D0T87RMnuHH8qbp0Vh4QG5Rhy/TLPlCc8 8ZZ8SPEZXJBfiHdgIqLiUGGu/Sq7l+seOXmmKCGfkQkYLVHugGywAsL82xAtRaiO9UnTyOhA26W KHnMhjQwIwTXUThK0rNZmsu1Lyq5uEqkgdiaE4wT+iWbFZxaTo/vrmMlr0dVjdIIJfj0qbaVSYQ xyLL0eUAOL/4nGJ0Jg+wLLlqt10HiENg6GiMj8DqKyIJ14beNiL3K1cXgKNCKbm3yRzR7HSNgq7 aDg6YOtY8q7yAc3bo7sPi52op9WKsUM2rAHeOiXLGsaXeu1Id4O0Z0YM/6QwgzQqK8azZddliS3 +0qUNmaDFpUY5DEWek= X-Received: by 2002:a17:907:84e:b0:c25:35cd:fdb2 with SMTP id a640c23a62f3a-c29042fd596mr642560666b.7.1788966553927; Wed, 09 Sep 2026 08:09:13 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Zheng Zhang , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v9 20/20] xen/riscv: add initial dom0less infrastructure support Date: Wed, 9 Sep 2026 17:07:38 +0200 Message-ID: <913c29fc85190a131e88dc7bf300ab734e570ebb.1788876411.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1788966555-51EC2CFC-9AC3BCFD/10/73395122804 X-purgate-type: spam X-purgate-size: 7399 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1788966592028158500 Content-Type: text/plain; charset="utf-8" Enable dom0less support for RISC-V by selecting HAS_DOM0LESS and providing the minimal architecture hooks required by the common dom0less infrastructure. Add stub implementations for architecture-specific helpers used when building domains from the device tree. These allow the generic dom0less code to build and let a basic DomU be constructed on RISC-V. construct_hwdom() and make_hypervisor_node() are still stubs returning an error: Dom0/hwdom construction isn't supported yet, and the hypervisor node generation (needed by domains with DOM0LESS_ENHANCED_NO_XS set) is not implemented. Both are marked with a TODO and are not reached by the currently supported configurations. Provide missing helpers and definitions required by the domain construction code, including domain bitness helpers and the p2m_set_allocation() prototype. Additionally define the guest magic memory region (GUEST_MAGIC_BASE / GUEST_MAGIC_SIZE) in asm/guest-layout.h. The base is arbitrary; the only constraint is that the region must not overlap guest RAM or the emulated device regions. It is placed in the unused gap below GUEST_RAM0_BASE (0x80000000); the constraints are documented next to the #define-s. A separate region for grant tables will be introduced at the same time as the introduction of the grant table for RISC-V. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v8-9: - Nothing changed. Only rebase. --- Changes in v6-7: - Acked-by: Jan Beulich . --- Changes in v5: - Reword the comment above defintion of GUEST_MAGIC_BASE. - Shrunk the size of GUEST_MAGIC_SIZE to 2Mb as looking on the Arm only 4 pages are used and there is no technical reason to have 16Mb for that region. (Maybe in case of Arm it is connected that Arm has these definitions in public header so more space is reserved to not "break" public API in future) - Update the commit message with a remark about grant table region in guest-layout.h. --- Changes in v4: - Reword the description: the stubs do not let dom0less fully "run" since construct_hwdom() and make_hypervisor_node() return an error; spell out these limitations instead. - Add a TODO comment to construct_hwdom() explaining that Dom0/hwdom construction isn't supported yet. - Add a TODO comment to make_hypervisor_node() explaining that returning an error breaks building of domains with DOM0LESS_ENHANCED_NO_XS set, and why that is harmless for now. - Document the constraints on GUEST_MAGIC_BASE/GUEST_MAGIC_SIZE next to the #define-s and drop the QEMU-based justification (QEMU is not involved); the base is simply an arbitrary non-overlapping address. Changes in v3: - Add /* Nothing specific to do for now */ comment to arch_handle_passthrough_prop(). - Use _ULL() instead of xen_mk_ullong() for GUEST_MAGIC_BASE and GUEST_MAGIC_SIZE (xen_mk_ullong() is intended for public headers only). - Fix GUEST_MAGIC_BASE from 0x39000000 to 0x79000000 to avoid the QEMU RISC-V virt machine PCIE_ECAM range. - Drop CONFIG_STATIC_MEMORY=3Dn from the CI randconfig; now redundant since STATIC_MEMORY depends on HAS_STATIC_MEMORY which RISC-V does not select. Changes in v2: - Move declaration of p2m_set_allocation() to p2m-common.h. - Add __initdata for max_init_domid and drop initalizer for it. - Add CONFIG_STATIC_MEMORY=3Dn to CI's randconfig to avoid compilation error because of guest_physmap_add_pages() isn't provided. --- xen/arch/riscv/Kconfig | 2 ++ xen/arch/riscv/dom0less-build.c | 7 ++++++ xen/arch/riscv/domain-build.c | 28 +++++++++++++++++++++++ xen/arch/riscv/include/asm/guest-layout.h | 12 ++++++++++ 4 files changed, 49 insertions(+) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 48520588fe40..d8a348c0cf07 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -6,6 +6,8 @@ config RISCV select GENERIC_BUG_FRAME select GENERIC_UART_INIT select HAS_DEVICE_TREE_DISCOVERY + select HAS_DOM0LESS + select HAS_DOMAIN_TYPE select HAS_EX_TABLE select HAS_PMAP select HAS_UBSAN diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-buil= d.c index d1a51b92936a..0801d7e25059 100644 --- a/xen/arch/riscv/dom0less-build.c +++ b/xen/arch/riscv/dom0less-build.c @@ -102,3 +102,10 @@ int __init arch_parse_dom0less_node(struct dt_device_n= ode *node, =20 return 0; } + +int __init arch_handle_passthrough_prop(struct kernel_info *kinfo, + struct dt_device_node *node) +{ + /* Nothing specific to do for now */ + return 0; +} diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index d7613721db95..1e3abe259ccd 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -156,9 +156,37 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) return fdt_end_node(fdt); } =20 +int __init construct_hwdom(struct kernel_info *kinfo, + const struct dt_device_node *node) +{ + /* + * TODO: Dom0/hwdom construction isn't supported on RISC-V yet, so this + * is a stub returning an error. It must be implemented before a hardw= are + * domain can be built from the device tree. + */ + + return -EOPNOTSUPP; +} + int __init make_timer_node(const struct kernel_info *kinfo) { /* There is no need for timer node for RISC-V. */ =20 return 0; } + +int __init make_hypervisor_node(struct domain *d, + const struct kernel_info *kinfo, + int addrcells, int sizecells) +{ + /* + * TODO: Generating the hypervisor node isn't implemented yet. Returni= ng + * an error here breaks building of any domain (DomU included) whose + * dom0less_feature has DOM0LESS_ENHANCED_NO_XS set. This is harmless = for + * now because Dom0/hwdom construction isn't supported on RISC-V yet + * either, and no RISC-V DomU sets that flag, so this path is never ta= ken. + * It must be implemented before DOM0LESS_ENHANCED_NO_XS is used. + */ + + return -EOPNOTSUPP; +} diff --git a/xen/arch/riscv/include/asm/guest-layout.h b/xen/arch/riscv/inc= lude/asm/guest-layout.h index 90603f06bb91..ceed9125e7e2 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -32,4 +32,16 @@ #define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE, GUEST_RAM1_BASE } #define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE } =20 +/* + * The guest magic region holds the Xen-reserved pages mapped into the + * guest's physical address space. The only real constraint on + * GUEST_MAGIC_BASE/SIZE is that the region must not overlap guest RAM + * (the GUEST_RAMx banks) or the emulated device regions defined above; + * the exact base is otherwise arbitrary. Here it is placed in the unused = gap + * below GUEST_RAM0_BASE (0x80000000), but a hole after a RAM bank would w= ork + * equally well. + */ +#define GUEST_MAGIC_BASE _UL(0x79000000) +#define GUEST_MAGIC_SIZE _UL(0x00200000) + #endif /* ASM_RISCV_GUEST_LAYOUT_H */ --=20 2.55.0