From nobody Thu Aug 13 09:15:26 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=1785858527; cv=none; d=zohomail.com; s=zohoarc; b=XsPsEiGyYH8FtLM1FUyrBFdNBwThRin7xwlhSwDMDw5OEDlWb0nyF9EdlHwL3V+DExNqfXHOYc947Oou5J27XtmxB0EtPKLL+bMk0xHCwAhqup5+2Bh73+zBnPBna7ac7UCCDOS+sEyBiKbv2Kqt9WsRBqhCO+Ml7R4PKSNFAgo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858527; 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=s2giNu/4S6jw/BG8lbsrBR4JasbJ4ALaPWnt21NbdkI=; b=Bo+wLN83zxOj5MqNFlB5Yr2qB4TchbzfuCqa6yfqxMhvjlytMwWWaFB2PhqRoFpTviZVNrAKXzHQO3dJ7gXi7pOFJ1HsiSlCi3F8yXjTO7MeXBWNN6gH2mo+rRxtLvf3mB7RahTiPZ9HEQjsY2FCE5NhZcrJShUkqv/oqkMG7tA= 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 1785858526911663.3368628839754; Tue, 4 Aug 2026 08:48:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382261.1625607 (Exim 4.92) (envelope-from ) id 1wrHNP-0006uX-Bk; Tue, 04 Aug 2026 15:48:23 +0000 Received: by outflank-mailman (output) from mailman id 1382261.1625607; Tue, 04 Aug 2026 15:48:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNP-0006uP-8L; Tue, 04 Aug 2026 15:48:23 +0000 Received: by outflank-mailman (input) for mailman id 1382261; Tue, 04 Aug 2026 15:48:22 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNO-0006uD-8C for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNN-009Gcw-9j for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:21 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209b7-bab6-0a2a0a5309dd-0a2a4505e25a-20 for ; Tue, 04 Aug 2026 17:48:21 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209c5-4cb1-0a2a45050019-d155802cd0a8-3 for ; Tue, 04 Aug 2026 17:48:21 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-495757ccbc1so33610805e9.2 for ; Tue, 04 Aug 2026 08:48:21 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:20 -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=1785858501; x=1786463301; 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=s2giNu/4S6jw/BG8lbsrBR4JasbJ4ALaPWnt21NbdkI=; b=WATOEZxONXg73Qtji13WhyZ7hCo7PQR4uWDhWB3FgXl2npZw1+dwocSRcNPOzoGwak a4IsN9RQemtkaLND9SVcpV24XmtvxYaCccrqzNOS9sF7HgFYrvckN3zSS+XsCh8oVjSo /82VrDQTviISxVytTN5GBk7taRFhtuv6dClyFKnt18qj6MLwiL3F0qI3Dsv0KLdIZanY iIPy1pl3/HYyoKNeHqY7ueyTWyWiLm6IJQAqG/fN/kPl/kAOYKZ9QD7f8ajFIXciwPxv rW2sGPwFVoLTVQqLv7gj9pdaBg7LRy9T+Xyo952v9TKyq4rrTlL/+wofYqEtBa/grcHe g55A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858501; x=1786463301; 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=s2giNu/4S6jw/BG8lbsrBR4JasbJ4ALaPWnt21NbdkI=; b=XTFRYRP228BZSGpG+DKz/TNVMrKRPU6NerRmmpGxfIWpGAyMcgU0yQkNveaNcse3jZ OUjsyo/+/HpJZGJnEC/4wkozKN0F7mRxnJq5cDOdHVutt5kWO34+s2Gb1i3hMD6CkVjl DvkEi10P7LVy2iNH0bW8p3e/luPwltEONZiQcKK3s2YxqBRKS19DhYzuYsYH9c/VKz7m uavlZBybHQevH7qXc31QZc6CJpL0wLYdmsDhA9bhgY1Epsqx69V1ngZtMLdM36A2Hxm1 0oa/+r4lgex/NinKfZqXiZx+wmTbF5w0o4d9IfSTkcoCyWNYQEdaHCFO5xjDtJlX97Dl 0ZTQ== X-Gm-Message-State: AOJu0YzY1GbxvjYC9nl0eA03fAYLJmB4dO8hOI+dJ+u8NLr71vURgiIG b4KWOY/nIK0aPuolW1xl1MwzfXtcaCcAb+U1wBbZSI3luLvbAw6+a2ym/vFoOA== X-Gm-Gg: AR+sD13F9ihAZu4St0THtNU/pJ1ZIkHjFWPefAF40o/Iqkx2IgmRQSoHmLgRS2+9+bD i2CtgKNqga/cNTwPV0ogbdwg14hF9p57NxU7aCLvATyzpSqwIEV+YMv6yl+zvKB6s/N1zCSdzWA 3FTK1TZ7i4OZNxw5lEabRgq1HSmNN/MwhANcq9FZRQ+IY84bI20l/Os+KJT634udbRTNBoTeMg6 RUe58tUDV1LkDhY9cqa5bzpmQ4Q7YOPitgyzOwvpZV2XaQP5do09+BQ468Hxwwct9O4cUBDAwZe eXKeM7+aEPfcMawFugBUWIL85pL7PWjUROU7S4PAa1/fzWxUcl5oPXsl7khSpnTUUNW7uZZOOSb 8PnyjdG3vZFyKFtB3L8EbS33IuouNS5EpVoJWUvIzrNmDBo2TrL96fn4Ih+iP+JgXrvj2sKM3Wf Vv5w1UaHQISSsToB2bnZ19gDfkxP4HIdiUfpGBKQLjqImOIIQEFuVwbbd36BZD1zsG8gmz7Q8UN x1OC+2TORrM5rwfaQKmqLwFKxYbyM2jlw== X-Received: by 2002:a05:600c:840f:b0:496:c379:b2a1 with SMTP id 5b1f17b1804b1-4980c66d7bbmr299592255e9.2.1785858500271; Tue, 04 Aug 2026 08:48:20 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 01/20] xen: introduce CONFIG_HAS_SHARED_INFO for archs without a shared page Date: Tue, 4 Aug 2026 17:47:51 +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-c201ff/1785858501-F68B62A1-243AE8C1/10/73395122804 X-purgate-type: spam X-purgate-size: 18652 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858528690158500 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 --- 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 | 53 +++++++++++++++++++++++++++++++++++--- xen/common/event_channel.h | 6 +++++ xen/common/event_fifo.c | 19 +++++++++++++- xen/common/time.c | 2 ++ xen/include/xen/sched.h | 2 ++ xen/include/xen/shared.h | 8 +++++- xen/include/xen/time.h | 4 +++ 13 files changed, 102 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..0911808fe861 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -40,6 +40,41 @@ =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 (CONFIG_HAS_SHARED_INFO=3Dn and CONFIG_EVTCHN_FIFO=3Dn). = Such + * a domain has no ABI to record event state in, so these 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 +/* Declaration only; the calls below are DCE'd unless both configs are off= . */ +void evtchn_none_init(struct domain *d); +#endif /* !CONFIG_HAS_SHARED_INFO && !CONFIG_EVTCHN_FIFO */ + /* * 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 +1359,15 @@ int evtchn_reset(struct domain *d, bool resuming) rc =3D -EAGAIN; else if ( d->evtchn_fifo ) { - /* Switching back to 2-level ABI. */ evtchn_fifo_destroy(d); - evtchn_2l_init(d); + + if ( IS_ENABLED(CONFIG_HAS_SHARED_INFO) ) + /* Switching back to 2-level ABI. */ + evtchn_2l_init(d); + else if ( IS_ENABLED(CONFIG_EVTCHN_FIFO) ) + evtchn_fifo_init_ops(d); + else + evtchn_none_init(d); } =20 write_unlock(&d->event_lock); @@ -1625,7 +1666,13 @@ 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); + 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); + 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..c8ee09807008 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 (dead) calls in + * evtchn_init() and evtchn_reset() are 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..3b6e619c5278 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,19 @@ 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 sites are in the + * IS_ENABLED(CONFIG_EVTCHN_FIFO) dead branches of evtchn_init() and + * evtchn_reset(), which are never 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 +577,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 04a65f00b35c..cdfdc53b6a17 100644 --- a/xen/common/time.c +++ b/xen/common/time.c @@ -89,6 +89,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; @@ -117,6 +118,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/sched.h b/xen/include/xen/sched.h index eef10c2ea2c0..53ba5ed8c257 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..f20a46801181 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 -#define shared_info(d, field) __shared_info(d, (d)->shared_info, fiel= d) +#ifdef CONFIG_HAS_SHARED_INFO +#define shared_info(d, field) __shared_info(d, (d)->shared_info, field) +#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 e9c0822e6f31..2f872f580ffc 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -66,7 +66,11 @@ struct tm wallclock_time(uint64_t *ns); #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 Aug 13 09:15:26 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=1785858531; cv=none; d=zohomail.com; s=zohoarc; b=lnyBRNlVJaACV5b9T3Y+UaaXmhk+jLAZkFAsmMQ3t+lf5qrF1EPwP2jvBJTyejV29uECHa17qDmSLbojwfR2zwUJ2U81qSzqTHKytg1sp/M2FyYLSGouK2aAZTAINjFR8SypN69wBdtkjbfedmtEl8lR4HS9vsEawgupL7QKoEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858531; 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=eQRAf5Du6pYWboeiDXqOeIZI6NQJ2iFJlkGQQHsxk/w=; b=XWN5Gju/64F45VEYzHIB4uMDjFtuZcpFhp6nADkjXzqimjGKjgkI7w/HBk8piO74cm4t/mjAz2SjcYB0iMxos7nZSFTyJMBhHVjinHaWmcSRyMhfFGt9YuQy9RolbWxmbLK3+69l4cHcivIEkO8GDS+e9GgRLrfw4iigMMv/9eQ= 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 178585853095541.141996527363744; Tue, 4 Aug 2026 08:48:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382262.1625614 (Exim 4.92) (envelope-from ) id 1wrHNP-0006xa-Mz; Tue, 04 Aug 2026 15:48:23 +0000 Received: by outflank-mailman (output) from mailman id 1382262.1625614; Tue, 04 Aug 2026 15:48:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNP-0006x3-GR; Tue, 04 Aug 2026 15:48:23 +0000 Received: by outflank-mailman (input) for mailman id 1382262; Tue, 04 Aug 2026 15:48:23 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNO-0006uJ-Sj for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNO-009Gcw-9m for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:22 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c5-bab6-0a2a0a5309dd-0a2a4509cbee-2 for ; Tue, 04 Aug 2026 17:48:22 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209c6-be1a-0a2a45090019-d155802ba947-3 for ; Tue, 04 Aug 2026 17:48:22 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4954a9e8490so6653095e9.1 for ; Tue, 04 Aug 2026 08:48:22 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:21 -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=1785858502; x=1786463302; 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=eQRAf5Du6pYWboeiDXqOeIZI6NQJ2iFJlkGQQHsxk/w=; b=M4Hnq68nWPuVsC7lwgbAoKk1HmzP+ekLiazSJ9amNCGZrUyd5PPFNyX4ZACZhyInPB +FPOcowBJDZvRU6z43RqtTb8wOZXe1LM685hOsXwkbT6xY329trAZuihjeobWc6m3MKW y3QQYIN+8S937Xn7IVM/4lUsRywVLRPxXl7PaFtb90k3zIrs2eqS2MCghJKQZtfQzK3c sIVnSqsCnz0bqNndrHGG4sPNpli+AFMnZORD2ylnLg6jpT0QWLHZ0IOWfq7NWPceq+0t N7jG/aj0tUDzTPm8Y0hKHUMJAzZimT2lDxACqPjtA1z4cMgBY8VSfTZpB9UyXDo/nxHc JNLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858502; x=1786463302; 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=eQRAf5Du6pYWboeiDXqOeIZI6NQJ2iFJlkGQQHsxk/w=; b=oIekdbC+hCOxA0FU1+lFisS8TfuYcEW3ikZSnXYdJmsbl9rWolqudbhAmXWGMBx3Bm IrR9k4U2EweMJ73p5qg1XCe4y6aWpeNibKE/GIGOQO1M/AUYh8JXnePYqwYjhVc2ZaMw rujDOie4q+83coloujMuHnAtOjaS8zLJJ9pCrI7qnRNsP34IQADK8G6GlIDJOHVBeRaF Rfgn8tw5hYfGMo61rJYbaEqOoxn3LuqOlQqA1iKBuLEnbRrgkCnlRXmSeI3Bnoebbf0O XCpsW4/L1mDP6Jl95qkh7O6f9Z8oACi5FiG3K0f0OsL3Xp40BQvW/2BopPzEPFt4dCVq kVeQ== X-Gm-Message-State: AOJu0Yzo339f+YbOXfILuBoS12MiOE/viBqYPXB71j9zMh7aj+ky2JY6 fN2UiHKXahhUzozcqbWnnF51XDwAl485uvoguhLk+Ywz4EQxTU8HS1VUXKrVjQ== X-Gm-Gg: AR+sD100IJ8y2i4hca2J14u2pOK/D7zXXYUqTTQNuqtmEsyGitmNSSIsWe1nMjC+K5A VxPFDRxjIUoK12QeTltI43lg3wvWiBrfoGUK2puunVJkRdMkSKMemUlJX1vpKrXd8B/DWwqQh1e aA8czR96T+f09XUbP5kgq2cLk2LsX0s6KD1Ar2JrZ3zSEl2ZLHCF9QPAF+KVUQQPTZe4TE/ZuWZ 7L+yx0gsdVlVeKkwPHeY0SE0/+/ALW2yuhB3jydRpk/uO+wUariM2JBpqsWc3GTqzK0gm8lACy2 OjsPPhS/iwatyvc1ImUiv8dKoGVN++a41NCtkFLTwWh5gM43roQkYfF6DqcNfVE0sgzcMMVtkhw rRwlmDUdQ42FCNzYGnrrzHfN6+sQYC/UScNIqZOxMxXYg56sXXgS1QIYzzyVLGoxvxPdvH+WsBR rJxf1TT2/7ylNlo8xnU1hGLGspKJKwePDy0ZAo0RDuGYsOFrQ3r1jGGlTmRDBTRkj0xIEFiXSio I6UZmZU5Q19aHIVRImmTZzCatp2tj+FWw== X-Received: by 2002:a05:600c:3ba6:b0:495:3a52:71b1 with SMTP id 5b1f17b1804b1-4994e374ad3mr1342475e9.5.1785858501675; Tue, 04 Aug 2026 08:48:21 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 02/20] xen/dom0less: turn max_init_domid into a common variable Date: Tue, 4 Aug 2026 17:47:52 +0200 Message-ID: <6cd23822f5427a67f8f77300b09bc78d65a1d317.1785836421.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-bad1c0/1785858502-BE6DA034-95C89CCA/10/73395122804 X-purgate-type: spam X-purgate-size: 5825 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858532154158501 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. 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. Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich --- Changes in v6-7: - 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 | 1 + xen/include/xen/dom0less-build.h | 7 +++++++ 8 files changed, 13 insertions(+), 10 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..cd46cf952be6 100644 --- a/xen/common/domid.c +++ b/xen/common/domid.c @@ -9,6 +9,11 @@ */ =20 #include +#include + +#ifdef CONFIG_DOM0LESS_BOOT +domid_t __ro_after_init max_init_domid; +#endif =20 static DEFINE_SPINLOCK(domid_lock); static DECLARE_BITMAP(domid_bitmap, DOMID_FIRST_RESERVED); diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index ea4e3ff34178..4c735cc04c67 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -31,6 +31,7 @@ #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..8d4da16d1f0a 100644 --- a/xen/include/xen/dom0less-build.h +++ b/xen/include/xen/dom0less-build.h @@ -5,6 +5,8 @@ =20 #include =20 +#include + struct domain; =20 #ifdef CONFIG_DOM0LESS_BOOT @@ -13,6 +15,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 +77,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 Aug 13 09:15:26 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=1785858531; cv=none; d=zohomail.com; s=zohoarc; b=G+kGKUAP/8kARyKKNmBHSh/+wbGi/VT+sN15fLDRgV1WWlw40rzjyftaL/lLCFHGcQjY3jzQbGqF4BxpCFF9pgZp1EXHs8bknfoaEmcL21whPVtYZNKZgRZ2FTDICckWI4zYlG/l+hnH7oXgwdMmGqV4OxZ3zkVPMNFTutAw0KA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858531; 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=MP/1zoasJWckGByg7jAKnBbEmQnEEwAq1X/Es6dlPOM=; b=kYiv7LHx+AVlxZpgqnngUEGRqUX3CFHqpIXdhsUyyl2mk6xFVTTqSU0mhYo7J+sPr0WzDsKbmSgCtzEWElM7aVWb0PavcROhEDCz2RvAum9OA6lIUYdDPxoe3Aa9+Ima0Rvq0cOLhpptFItYAlit/8ecNohAL4OFCqAgIDwF+x4= 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 1785858531152839.2812768336502; Tue, 4 Aug 2026 08:48:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382266.1625638 (Exim 4.92) (envelope-from ) id 1wrHNT-0007YY-UJ; Tue, 04 Aug 2026 15:48:27 +0000 Received: by outflank-mailman (output) from mailman id 1382266.1625638; Tue, 04 Aug 2026 15:48:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNT-0007WN-PR; Tue, 04 Aug 2026 15:48:27 +0000 Received: by outflank-mailman (input) for mailman id 1382266; Tue, 04 Aug 2026 15:48:26 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNS-0007KO-6m for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNR-009GfZ-Jj for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:25 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c9-2eae-0a2a0a5409dd-0a2a4507c9be-2 for ; Tue, 04 Aug 2026 17:48:25 +0200 Received: from [209.85.128.46] (helo=mail-wm1-f46.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209c7-b4ea-0a2a45070019-d155802eb8ac-3 for ; Tue, 04 Aug 2026 17:48:23 +0200 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so36540035e9.2 for ; Tue, 04 Aug 2026 08:48:23 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:22 -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=1785858503; x=1786463303; 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=MP/1zoasJWckGByg7jAKnBbEmQnEEwAq1X/Es6dlPOM=; b=SP+gnfjuQEudbjUeaC+DElxqkKK4NHG/SdzMh13jcpTvcHHZ4Nk3C1G8WBcR0nzBJ1 xfGBsC327fKshsOVjXV0oCwymy+cnOGB0IxZzZ1GPuzFZhvz+Dby16YDyveAAsbCyck+ 7mPOlJe7Oug+dRbyZmkLZP8onBSp0JH3Z0mJdF/LXW0mgfuFYRJNQR3R4nS94Ms0ODHT lx7vGsNY1p5Vq61TUWPdKjgTk3QFolBqC/l3jdJipkByuZK5C6yyATZSttIuJnjo0D7T B3KDwavPa940NO8DwvtdUkYnkY8P0Jo73+oJQQe0NvR6QnHmVsFibSCd+ho9+UOYtztc w4DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858503; x=1786463303; 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=MP/1zoasJWckGByg7jAKnBbEmQnEEwAq1X/Es6dlPOM=; b=Z39tjLd/JiwA9UVlluN6d5LoJyh/VJnMmKP0Q8f9rQP8sGkhUuNC9VStR3Syv8LLpd qwrm0IpcbvBwA9ateLRL6j+k6th44NK5M96mPNvjFxZabwxW0g5jZVCTTOCqwd2+4QS7 ahjrMUaMYRaIxFtznjIez+2wQkd/LgDjgIEpTMMvzXdkzLE2JVnMFcwwq4WYyhT0QWDq w0XqfA0w3VWeMu1UTRXZbwb3o0YkbKCVkwi/d26cdvkqbSqnFOzuSJ/mAMESiA5ILaSF hyd3lwxF24wOt2CL7ofKNSTk4OAzT3TeTmYONPpQBmcbudW31v+QyZM4/lU3mFkj4h5W OGFg== X-Gm-Message-State: AOJu0YyHZb4byQWXealrac2AEDbxmmGAQgAqktdcqjyZZNs9vNPaojpU pgmLy4Lry8MAk0Dx8EtzGDyF7NLPPVJ8HMbijqg6deu7B6pj5VUHzlcbpwmEzQ== X-Gm-Gg: AR+sD13+U1ZsVOZJ3y6gdcxaN9RoZxTGKhnpcHdf2uIiM9iM2NAv7FeF1J7aWsYGIzJ +GSQmYWnrEyc9dC4O+wiGeMPZsrSYnIjziBdeAoU/UA49TMso3lcQiXWNdwAMCUl4Lywv2LT0xm tMLObZVM4wKOc70u/3r1kP2xU3tL91XJI512qHhnVoDw3DiZQAB5lknko/bhfTdSx8qKZetrmt9 S1giWJcl56/MKIKo8Mc0fFu/lG0DSJj8OxN/zr+LqWYNo6hREjOJ1pOZ2eh7PxHa8R1Kk4xGner 7JfDNZNwJT7CB2dgyCL7yniPiSpzrqX3yHNsHkx/v8X4gcPDqA+efMRk/DwRGrnJRJ6y8lHIUdD 2PNF1UogGvPeW56cX0U4FwdeTVTeKQQ5J+KmlQquhbKeqsJ8gGSaX/ZOC02tqwrsqoVHB2lBlBJ PeefhtqOZcxdOZ9Qnr45HKLfRfcb44v1KEi28xaXD5XGoXu86uwS2nW+YKlv/GzxboQQPmyn16n dWsW4k3APnuWhme2CfLX0n29u6f9uztBg== X-Received: by 2002:a05:600c:8711:b0:495:52a5:8829 with SMTP id 5b1f17b1804b1-4980c652515mr416359285e9.11.1785858502781; Tue, 04 Aug 2026 08:48:22 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 03/20] xen/riscv: Implement construct_domain() Date: Tue, 4 Aug 2026 17:47:53 +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/1785858503-3C610AE4-0BE0FE40/10/73395122804 X-purgate-type: spam X-purgate-size: 3117 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858532114158500 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-v7: - 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 Aug 13 09:15:26 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=1785858534; cv=none; d=zohomail.com; s=zohoarc; b=n2+zmFypooUzQjn1JKTdEcA332sJqKohns/nPqRWsZ6Nps48K1X7xkO6B8YyZjXPZV34JVFvW4aYwLY3nr8kPX7BXSH4FDDHjIbrR9sKPjuUyiDxbdo+93IV+X04U2GC6qtJHuceetpirKdoBD9qhnZTLTxmDrDkiBFugoDkGsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858534; 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=oqMXCnK01BlYFZDe0+XHyH0PuzocnmSdtMYh4s8i6/I=; b=NRXNM82SeVATufuHrCmWeHx6kG22bxQ8wipUUs4n0vcXmTf83DnIetC/wJIS9mwAz+ss6gUDo0aKwJSUUMUI0OSSkMkBJ6WZ0nIqiBXtQVqjNB7BNOfI8+9m7ts6NsxeorI+iwYPTxFynp1jfzfFnoGwqF6Rq8ovQSVaMN+FrPo= 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 1785858534937811.7664288206057; Tue, 4 Aug 2026 08:48:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382263.1625625 (Exim 4.92) (envelope-from ) id 1wrHNS-0007L9-Ue; Tue, 04 Aug 2026 15:48:26 +0000 Received: by outflank-mailman (output) from mailman id 1382263.1625625; Tue, 04 Aug 2026 15:48: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 1wrHNS-0007L2-Rt; Tue, 04 Aug 2026 15:48:26 +0000 Received: by outflank-mailman (input) for mailman id 1382263; Tue, 04 Aug 2026 15:48:25 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNR-0007Jq-FB for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNQ-009GfZ-SJ for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:24 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209a3-2eae-0a2a0a5409dd-0a2a450b975e-48 for ; Tue, 04 Aug 2026 17:48:24 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209c8-b7e8-0a2a450b0019-d155802ca8ce-3 for ; Tue, 04 Aug 2026 17:48:24 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4980fe6b3beso8471115e9.0 for ; Tue, 04 Aug 2026 08:48:24 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48: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=1785858504; x=1786463304; 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=oqMXCnK01BlYFZDe0+XHyH0PuzocnmSdtMYh4s8i6/I=; b=NrCqbKI/e42GXKnbhw/FVaj72OlfJPNqbFXidSkQs8p6efGG4TnQfNIrf6X3s80Vfe xDTRcvGW+wJeUwL0a76tdMkEAvk4NHC7HdQ41ozE/7gi+uTM9gkynlAsZ0CFpUe00vl+ dc+BDeKdRmMGSdW4gBNyBs+zT6Tz8Ooa1WdSn9+dI2YMIGBMYcashyEwqYOuD/090orW pY0xqGF5ZNfcFEn93izd2EB7nrlJogsfBdzbFzGbXv3AcIwZ8pCUaQ5MNQD9jB5VqHHy jnelwbZILQPwFTZNzU1zVWRz8fG04F5BqsvJEPCVns1mOM+l3SA/r5SJ+SmO+uK1Ea5v REGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858504; x=1786463304; 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=oqMXCnK01BlYFZDe0+XHyH0PuzocnmSdtMYh4s8i6/I=; b=LGg99nNJygfUDPjrnxNDkDgGAujrS2ZyCvGimevc9DqA1vTl0X9+SoDB2tyhM8ttAa kmuDJ7mgUHogn3CnEd6UaUm+gPpzcehBD1f8yQRTsm+9CFm7Dgalm1Vh195T63FoAlUN 2ifg2+jBarurpXzaq2Vq8L6Swq2tVb6lrXQJPgyszx0CAU3I9bOBZfCkr3OIbYdpCA/R OT8ss7j7IUwdcLXtOpY30nTWDzHO4yz5uZ+Rjn5F5wWq9HK0Uh+pWbYcNyeUPmw3pluu eUV9mS7Tv3YPmkrsg63WJSP+YKIJIgq45XPowUdHmqKzqCKwDfl/yrNpbjNfPpTlKLAM 3pzA== X-Gm-Message-State: AOJu0YyI936rsMG3YtpYZWzmSYJi95fCPTYnM1TeanV8dD1bXI6/QyVx Y7wZgreNmXVa3Xv7oH7GJluJ5XFgqP1P74Hjmj2Pgd0pw192GCT9GjC3TD9zow== X-Gm-Gg: AR+sD12ssa4QbH03qv+JiPSZM0buAJomrIIdPs/nCVVBWgtN/mYHlRdNJjarIfo4nK4 K9qPP59137iLQyv4guJWVWTUomKEQt7mWptqq7yot7xB4daJjLk3/ymgbQbFJ6Z7WlSvuRkrsBU Td9W2qMTfzryEsbjoL167RYLWRB4nccg3z8/4NFDluxs5NNxNvmGXfJJlrHWRaeNmr6ViEh6hle Y1yDY1m81HgK78p2g0+xMA2VqUvUdt96Cck+jbM7nu/gAKy7KAru1bYgpeV+FHQnuu+340stpXU zhT1VfbTvvR73DGw61tm9FL8OxIUY8lctpEL9CH3XgF/nfH5o3183SLX0wt2RqTg0FUiE2PJcVQ 9ut0QaOLygHTWpglGd9PchQCRUDIlmLq77CTxhulALWFio0728Kv8HzBJUFp25XfM+OUSsYOk3b 8Y8G5jxTi93PacA8DOd2dKyu1Bk802DNgdz/pdn+8dDMEXzKiWo1az79HNAdHQdiUWloIoAJYM/ 15O6ZY07Yek3jcBndR8pvg6vZbVDhmGhw== X-Received: by 2002:a05:600c:468d:b0:493:f478:4c71 with SMTP id 5b1f17b1804b1-4994e382cacmr889265e9.7.1785858503857; Tue, 04 Aug 2026 08:48:23 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 04/20] xen/riscv: introduce guest riscv,isa string Date: Tue, 4 Aug 2026 17:47:54 +0200 Message-ID: <59b5b69f53ef81d68fd279d9ee0c03f5ffbbc2ae.1785836421.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-42698a/1785858504-1BED69EA-756EA657/10/73395122804 X-purgate-type: spam X-purgate-size: 14745 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858536208158500 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_supported 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 --- 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 | 171 ++++++++++++++++++++---- 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, 157 insertions(+), 24 deletions(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..c963c3d556b4 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,35 @@ struct riscv_isa_ext_data { .name =3D #ext_name, \ } =20 +struct riscv_isa_ext_entry { + unsigned int id; + const char *name; + bool guest_supported; +}; + +#define RISCV_ISA_EXT_ENTRY(ext_name, guest_supp) \ +{ \ + .id =3D RISCV_ISA_EXT_ ## ext_name, \ + .name =3D #ext_name, \ + .guest_supported =3D guest_supp, \ +} + /* 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 +148,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, true), + RISCV_ISA_EXT_ENTRY(m, true), + RISCV_ISA_EXT_ENTRY(a, true), + RISCV_ISA_EXT_ENTRY(f, false), + RISCV_ISA_EXT_ENTRY(d, false), + RISCV_ISA_EXT_ENTRY(q, false), + RISCV_ISA_EXT_ENTRY(c, true), + RISCV_ISA_EXT_ENTRY(v, false), + RISCV_ISA_EXT_ENTRY(h, false), + RISCV_ISA_EXT_ENTRY(zicntr, true), + RISCV_ISA_EXT_ENTRY(zicsr, true), + RISCV_ISA_EXT_ENTRY(zifencei, true), + RISCV_ISA_EXT_ENTRY(zihintpause, true), + RISCV_ISA_EXT_ENTRY(zihpm, true), + RISCV_ISA_EXT_ENTRY(zba, true), + RISCV_ISA_EXT_ENTRY(zbb, true), + RISCV_ISA_EXT_ENTRY(zbs, true), + RISCV_ISA_EXT_ENTRY(smaia, true), + RISCV_ISA_EXT_ENTRY(smstateen, true), + RISCV_ISA_EXT_ENTRY(ssaia, true), + RISCV_ISA_EXT_ENTRY(sstc, false), + RISCV_ISA_EXT_ENTRY(svade, false), + RISCV_ISA_EXT_ENTRY(svpbmt, false), }; =20 static const struct riscv_isa_ext_data __initconst required_extensions[] = =3D { @@ -181,7 +210,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 +509,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_supported && + 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 +648,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 Aug 13 09:15:26 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=1785858531; cv=none; d=zohomail.com; s=zohoarc; b=iGKpHGpf7mulRMNO/mOvzy8MhRq1oTz67cI79K02mRpdbO7DfZeqhXcclsCU0GqF8AshWKn3+GGxgyWbcidsVAoawt9qgI1Xj+l4dxZeQLNmIP18va78zaGOLpBFvhrxWhLSRQ7WA0cFISh3NgHJyq+2zZ+2IYOJOQKKtz4KL7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858531; 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=OtCr8wU2t2GJWhHJ8VA4gfjPYB+rOSURYzxYVnJJT30=; b=M++FqMxMv96WW9CGlcmDuBKuj/zO15pwdAP9gKaEnVqfhPaH+oAxn5NxPG3S9EWcwvb01oBnqHsDoU9nw2HXl/+F/8WmHfEEa/Vj9VJhUqDTSC56FZ9Y3ycdQk5z1qCyiQ+HAnRQLD8pZUpqv9NT4haidH6kqHZ4cYl9DrvPCRw= 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 1785858531753965.4512842835974; Tue, 4 Aug 2026 08:48:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382265.1625636 (Exim 4.92) (envelope-from ) id 1wrHNT-0007TP-Md; Tue, 04 Aug 2026 15:48:27 +0000 Received: by outflank-mailman (output) from mailman id 1382265.1625636; Tue, 04 Aug 2026 15:48:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNT-0007Qz-DD; Tue, 04 Aug 2026 15:48:27 +0000 Received: by outflank-mailman (input) for mailman id 1382265; Tue, 04 Aug 2026 15:48:26 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNS-0007KG-25 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNR-009GfZ-F6 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:25 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209b0-2eae-0a2a0a5409dd-0a2a450cd344-36 for ; Tue, 04 Aug 2026 17:48:25 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209c9-f479-0a2a450c0019-d1558032ad18-3 for ; Tue, 04 Aug 2026 17:48:25 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-49558ce01afso26773375e9.1 for ; Tue, 04 Aug 2026 08:48:25 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48: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=1785858505; x=1786463305; 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=OtCr8wU2t2GJWhHJ8VA4gfjPYB+rOSURYzxYVnJJT30=; b=Ks6kTuoOKfbkOPaqFnIMGRYHtWGNOL5PZdg9hLvfUylqpaC5qVz3RP2x4Z42TI875k Tr0fppbdAUwUVq4zU186c3UBIfmr4SfvtbkEYhW9i747ytaEDADTB3Zrm0uX9QqBxaOZ 03sLgVZuj/bpLyFtHA4anvYHeScykWsh3YyHFBERcd8qvkn7+F59tg8yEbu3r0f34wcj jyi44PjNxZ6aTLVLMes5P8HFOt17xBJAzdA8S/BfmcsWiO8ZpWDEB7gkl0rxb31P6KW/ X85B3RHKeeCywUnzwLGwOuoc4Ag8rz0ARrhERHOg/vMEZyR5E99XyHkhkfwZ0dfyypPW pLRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858505; x=1786463305; 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=OtCr8wU2t2GJWhHJ8VA4gfjPYB+rOSURYzxYVnJJT30=; b=Z2H/rPGbEDzOAUDuI2mdcOsL4DJyIPkD5lctirG02Rk5I9n539aV8sTYVXdBoraehx 9S3JyQQ2J+x9UpMpe2gPv8rd3Ii6IKj3Iye3HJxi9kJpN3iHu5uBl27vaQzMSFwKI0ED DiaS1KcuaSJf1NkB3l1uufHvNIfSxx5g7c/P49v0azjwPYmwm1NB83uxLL/aEL3mocCV pzytKDBf0dMnhZr1sq2kBp5TN8xVsJUaUqnHjc3XM+Uw3Zmn4ySeDlVm4e6JYH87rg3z 2gPPskBjM8rczrGqBJiV6qo93DdCXWj0jHdCHCIPJ+kvkys3tVIiBxhuJ7QDMr+txKQI WM+Q== X-Gm-Message-State: AOJu0YytdCqg9lxqVpAh8z0XXoYkBMByw/6oD6rhUKmVu81A+fXbJk2t BQHggT7S+Pbu6I/UY2lJiCakSZ4jmIB+jQMSJjCoEVp5xjTJ11I8Y/wZ556TmQ== X-Gm-Gg: AR+sD13GTTpOQ+AB0R1mea0O2+WUoMpx23LnsfC5CO0iKl9rC5aFhnGebZtxaKEEO5+ ArByreEMrbs6kpgn7UGY7Tfa9g2mYCWzStFEhNlv+qUzfMyIVOCgIiD23/p3pm850tSUZbBov5V Kv0VnoXSm05yPd/9VP9JKoRu21M9wtdCD115d2cf5hHz/+s+agMLsdEJkIX4hWfYP44d2SiohVW H6XLbRxHiDSXQVJwafpoeUFK13zPRWRQu5ksZg5J5UlI6jB2p1DI7sqyqb0d/TamCS2suscZ/qn qgMNqqV4Ol1V+xjy9qOnFy5FYOPsdl7s3Rz0ONLABPKMwGqJR8btPw070jdzd7ZpR9eebYE3aLc c2JgsJEv9Xp64uG+cb0RRZ4XrfESKCEJUEANotnBM7t4Yc7jW7jpFSb9GeVTSaQjxA4ZX1iV4Gd s5o9U0X0YEUIC2A20fmngOHjAx1Hb4k9ccFEm+JoC2qEEIIh2VNk9qCKZOvXUZvbcFdV3N3QOv6 StonN0onK+o+/1gZ/OCwPFxIXOsRaP72Q== X-Received: by 2002:a05:600c:c490:b0:494:596e:e8c4 with SMTP id 5b1f17b1804b1-4980c67d1cbmr317723855e9.17.1785858504857; Tue, 04 Aug 2026 08:48:24 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 05/20] xen/riscv: implement make_cpus_node() Date: Tue, 4 Aug 2026 17:47:55 +0200 Message-ID: <4df84f91703588ca55c2c0fa73cadb9f94437571.1785836421.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/1785858505-02CDBA5B-A8231C93/10/73395122804 X-purgate-type: spam X-purgate-size: 6049 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858532147158500 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 --- 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 Aug 13 09:15:26 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=1785858536; cv=none; d=zohomail.com; s=zohoarc; b=jL7tzgmcpCbaN/hkVXyBilKHggluruudDqDYVR4W0IBvbI/LVKTVqqVTyKeY5zlVgn9JYd5B3nTOM0/wgMGuYUaYKIBQGTWGRvkmI6vthOmfWCFzbBCmDMBeOxCKmDwFfvH6E8iHXv9jaMyUW/P4pI76u6w5H9YIPSQUzw3dqZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858536; 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=xLkIYss1rW/F2qb2oVl9fc594E2EtP3QPXzs49dm0sw=; b=aHISCdH+uXOxK0Zm6BjyLvL3rd9u3IF5aEVjskdMAITyoJQrhz7CkJyRiRwWbrHqBmt0q1LEn0uG65qTEIheHMUUPWT3Tg1ekpWZ943Wu4ip9czlzm2QZbVG41SZRCIx9wke+oduybXZ5Sz/7XsD6+LWWo22UFXakOxLk1BnVE8= 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 178585853617261.58508031347765; Tue, 4 Aug 2026 08:48:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382267.1625658 (Exim 4.92) (envelope-from ) id 1wrHNV-00089I-Fq; Tue, 04 Aug 2026 15:48:29 +0000 Received: by outflank-mailman (output) from mailman id 1382267.1625658; Tue, 04 Aug 2026 15:48:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNV-00086R-AR; Tue, 04 Aug 2026 15:48:29 +0000 Received: by outflank-mailman (input) for mailman id 1382267; Tue, 04 Aug 2026 15:48:27 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNT-0007LB-3D for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNS-009Gcw-Fw for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:26 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209b7-bab6-0a2a0a5309dd-0a2a4505e25a-32 for ; Tue, 04 Aug 2026 17:48:26 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209ca-4cb1-0a2a45050019-d1558032b837-3 for ; Tue, 04 Aug 2026 17:48:26 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so36541325e9.2 for ; Tue, 04 Aug 2026 08:48:26 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:25 -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=1785858506; x=1786463306; 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=xLkIYss1rW/F2qb2oVl9fc594E2EtP3QPXzs49dm0sw=; b=b1BwFxD+XbEtmhYCLlAGre2G5NtvTNmLE/etUJpULzhzJ5NMPdu155LyF9YV/4UmiR YvJGsloZRiWGva+hUIod38oQU9jhjMnw8eGG4PcpVPuqHx1FaClOuiDTTixUVv/eFcdh V0iBVwRgkhA7wWs9l/AMAumpWHJOIY23h1CLTfm3tg5XRMclK9sGinXCn6GVIXLwJ/4L a/3skOBNozAyO2/RWQNPQTHWN+0fcPw/xiQ53znripQVoCicQOMwgexvLWUMH5p2euNO zNjXJXT773I9hQ/5HxGkHjs8ieAIPnSQDmaoYaLtcFEvh9RUuvdcBOqqt3noUAwGWE4e 51ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858506; x=1786463306; 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=xLkIYss1rW/F2qb2oVl9fc594E2EtP3QPXzs49dm0sw=; b=Aa/7UgDDBtsYoJRu9aGDYTVPVMCq37DwsWYZTEXEsb4opUKAHJNHp6mvLIzOFUIMcG LeZIyooLZB1DTeCSdMxI2goyhCMJt2jNSWQKwYe4+laL9vx/Mzp8b8wUbCfixUcVj/c5 j6cFzSN5wcYIqrEU/O6qUm0BKRcBZV4LKfd7q43z1iKWZD4swonOoWI+kZuW1KuOsYsy Di8C/cLWEn+YWav1oqHagicGMPkQcNjzkLubcTc/5Ow5EhW9Kalw8PTCqkQANogwOuI5 JuoqLq+51szPP+zdvc8CWKS54a4gfPpCaYbDHYXlN4dyI/FVBCfYvPcJ+XOJ/wVlQXoc CuWg== X-Gm-Message-State: AOJu0YyM7ELom/nPK28YLj84L73fuMdP7esJ8ztLWZNMxNgBLI6+oLqY TtyYQqY+G3MDYG3yivLxabqmYyB8FJeKkAEpcICLt9vjrC3qcjHglqBGPmjW8g== X-Gm-Gg: AR+sD11romr588/THHmwTkR4eqgZ9YBFx987Ug1ZOiVKJgRKK0qijA1d1TISxijSXg/ Ev/8nelQGW8J2fm3SUYECz25X1gFIydoImSs9o96VTaraxPo5lhAyrX1UeKRpWHS2rySm7LwKjt /IGBLgZUzD6Fz6ZQZWLsWWHGBHh3QMR8rl8vefkRkpBAM21N/zZsWTTBxcWLsiFvKIhRaXVCG0O 5IJpgiwO0SKurNilZQkpK9jrlDZZrFL2uz1cEqXXC94oonRCdRPx/YgblHHR6GY4J4ouic7ziQx k22pSjsgY5biaAa+5hwlnOsawtr3GgRVzkQ3na+LxqNp1LORBrxYkJp2S7Q25Pp0itpkBiOEx14 alZKNEBJotskajiWTXAwsxFyM5UOWYqrMLQ8U2Q+B7y8V67NirMsIQpxc1AqR8GfvOYgLX/x6Up 3bc+YVM13QO9TnXz/YdL2fI6sIGeX+CcnBqOu5uy65UODTYCmlyjEtkHKXx4keN8suV2T1P1CyW l00DSRPIbWtctT/yXX8FavyxLHgH3GYTw== X-Received: by 2002:a05:600c:1d0a:b0:495:5dcc:52b4 with SMTP id 5b1f17b1804b1-4994d9ef0b5mr33072185e9.3.1785858505967; Tue, 04 Aug 2026 08:48:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 06/20] xen/riscv: implement make_timer_node() Date: Tue, 4 Aug 2026 17:47:56 +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-c201ff/1785858506-F60AA2A1-EB1945B8/10/73395122804 X-purgate-type: spam X-purgate-size: 1618 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858538127158500 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-7: - 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 Aug 13 09:15:26 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=1785858530; cv=none; d=zohomail.com; s=zohoarc; b=iPiGzn9l4VaS2widzOpyt7TUGRp572VTgV8TJc3iIwnLHgio6fTdMBArjDnFIMLeptvSGR4NQqSepEzMF7PvZvTlHpJRj7ZGvFgq0+3+wsjoN0lFpFaJcaAm23XpBtdvN6sryEkrofpEnttqfG4ZrEvK4EqP4+g5bXgFSzkv5Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858530; 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=Rya0M33QFFZ2ZUtKRPpGLKlS3qYbQXw2r8chWSRTMZ4=; b=aVRgsqqAAwwq/ZqAb58Pxu4xBeZLYDRu7GxER+tXFDL3MqZihUxCwuFGK/pO5R8AlHJM50mfcDqTja7gXqVH5gPVmaqxG1vplN1IbFxkTnCOsM6jwMW+FuXN1TeD+SoK95TpcMWu9VK0NPpJvJLPPnfldJxjIfjBkuqw/ws0S6A= 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 1785858530397752.643733521884; Tue, 4 Aug 2026 08:48:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382268.1625670 (Exim 4.92) (envelope-from ) id 1wrHNW-0008Rt-RS; Tue, 04 Aug 2026 15:48:30 +0000 Received: by outflank-mailman (output) from mailman id 1382268.1625670; Tue, 04 Aug 2026 15:48:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNW-0008RZ-Kq; Tue, 04 Aug 2026 15:48:30 +0000 Received: by outflank-mailman (input) for mailman id 1382268; Tue, 04 Aug 2026 15:48:28 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNU-0007gh-Fy for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNT-009QHz-SM for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:27 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c8-5cb7-0a2a0a5109dd-0a2a450bdaba-8 for ; Tue, 04 Aug 2026 17:48:27 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209cb-b7e8-0a2a450b0019-d1558031e9ac-3 for ; Tue, 04 Aug 2026 17:48:27 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4955de8797cso21143195e9.3 for ; Tue, 04 Aug 2026 08:48:27 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48: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=1785858507; x=1786463307; 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=Rya0M33QFFZ2ZUtKRPpGLKlS3qYbQXw2r8chWSRTMZ4=; b=cfbY1msnd39EcO4GDxFdxC01xMFVr7SpVkJ9oPRgn9rDEu0Cs1AAcORr697/qthwfS nK+Psr0OIwV8BnvvKdbgAy7PEO2+YjBl2WluLDu1/EgUtV9BQPHBe6dqYg7kXv+4W6j3 Y1U1YarQO7ErvGXTMsd17ZmCXCNMCjB5n84gMnP2F1uPtcksmv8bjE4JR9N0zIdJ1Ug4 QzsG35CQHq/a4F9iK3eqe0ARfjcTzOpcqYGrP6IrODKuZpkul19gPekabLR32XZogGco Gwp5pZ9bwic/nJH/wLpQ1hoSJW/Sz7mo7Kan9B46jMS11iMCNx6Z2MzYgLBvRWpOFOdj WLmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858507; x=1786463307; 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=Rya0M33QFFZ2ZUtKRPpGLKlS3qYbQXw2r8chWSRTMZ4=; b=c4vIKlqb2vTmWvbRmZqp1m7JrQkHMktXnl8+6v82Q+OeRKe44Bv6MyJ2odXdfAWjZl T1gk7ihyd5fSl4a87IfOBNAoYA8WAoPbM+13TerULaUXtatckW68JH3vXCJ8EExffZTD +QJepOeKGSetkvM951kuqRo7Ummt+cvj3e65/Pqd4DyjltOvqChK/f31xiHQXoHHUL41 mtj5Eyo/F8GTwdMWtaBlaZHdHO5ARCsqkTJKzGu4rH4SWkwb3+yix5Mn2Um/ZyA84sT3 jW77PfbVgJb7ApFwOcy24KGrau43YZuek5wiTkeZ9TdDihNvAvRBln+HnGzu18xCxUge MH3g== X-Gm-Message-State: AOJu0Yw3/UQ/yX2fzcWfoe05vvPKoXu57eIUo5kLIIK+mw5Cdhv+nE0p zzsNj+x0+GAn0/h6Vmjg4jiYnQ//nxHWp4r7bcF4EWSktIai1M0VjEhpUfyVZw== X-Gm-Gg: AR+sD11jhv3dpsW+6gC1PElWwURVzh75OCjffG6yt4ek0Yv2qONMNCt4um4fm1+sVS1 SxWpmXz0gkrZHG+GqAFB3djXqACBhLZbDhSqqpqJpgkCvZUFEPZSg04lbz2+Po+iMmvZ6EtPTQs EzW4pvdQPJ19d9+UXNZNDu/7y5P4XbELCpltwWZ0zZ3ORVW7keBJHoAReF/06Shxp/GwzFSODve FMpP+yugC2IDPRBHXArfrk8s3do251ajHdhZKgqa6+hX4qWClPBM1U92efraxwX41CGwadTtZT8 fQgAA4jPiK+UAQhiGcOL7TZMiKeq4kFx849a+8OC9IS/vH1UAwuWy0ObfewBfRWGNWT9p3lM9lN GKFb5AZPs+TVyEUIF4eae3wXtv0pqLnXNhUHPhUDFeQeYH7WO+ZVVNfynCdjvzeWOiy9ouCfJzl no+C8NjLeDdSA3CbznM4gRbTImwnsJm08K5oAbbXcetKmAhKzfYkPT4Mqmn7+Ji8AkoLPO1CAtC w3xMCy0iFDT3JwXL0UzcmCwjHozrVsF2WlZHrnnGMkC X-Received: by 2002:a05:600c:628c:b0:496:c0f6:78d6 with SMTP id 5b1f17b1804b1-4980c64b5a7mr388460645e9.2.1785858506985; Tue, 04 Aug 2026 08:48:26 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 07/20] xen/riscv: implement make_arch_nodes() Date: Tue, 4 Aug 2026 17:47:57 +0200 Message-ID: <6bc1edc29160d7758d71402632309aeb7029d7fa.1785836421.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-42698a/1785858507-AB8D19EA-DE3A0F14/10/73395122804 X-purgate-type: spam X-purgate-size: 1444 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858532092158500 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-v7: - 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 Aug 13 09:15:26 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=1785858538; cv=none; d=zohomail.com; s=zohoarc; b=YXTRzW8lGGqG9xg1yXeaVKGK6hrqNcUeyEhjr9+cb+bMA+h0vpqFf1zf5F28Ju4A7qr2poaUttP6ZME8CNNImThbNW+4XGRp7FYhndzmguwAfYyA8d6MUiAl/5XBIEKg2MDqXTjJx3UGnGHuxkxsjvObP4e180hAo2AxxRmbwgc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858538; 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=ebyF9U3D/MvFmcX3JXdHMfkwonGwN8CEi9ANlVWdpho=; b=fx0ca/d7YFW8PNqdpZY2q2NPwNLbN03zpp/H3N/gnkSIsZv8z7gIWXeuq8RvhIqQIpGiqe0bCyWS5s9xA9G8CfaJm44Xl4SJ5ZRJaQ7wWO0w/5UWOMTeJcsHcCauocLO+vlvParYv+47G2hSjO5ro44HFEsp8YgwsE7561Jprkk= 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 1785858538784585.5091181078766; Tue, 4 Aug 2026 08:48:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382269.1625676 (Exim 4.92) (envelope-from ) id 1wrHNX-00005D-Iv; Tue, 04 Aug 2026 15:48:31 +0000 Received: by outflank-mailman (output) from mailman id 1382269.1625676; Tue, 04 Aug 2026 15:48:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNX-0008VU-7C; Tue, 04 Aug 2026 15:48:31 +0000 Received: by outflank-mailman (input) for mailman id 1382269; Tue, 04 Aug 2026 15:48:29 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNV-000889-ID for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:29 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNU-009QHz-UW for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:28 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c8-5cb7-0a2a0a5109dd-0a2a450bdaba-10 for ; Tue, 04 Aug 2026 17:48:28 +0200 Received: from [209.85.128.51] (helo=mail-wm1-f51.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209cc-b7e8-0a2a450b0019-d1558033b807-3 for ; Tue, 04 Aug 2026 17:48:28 +0200 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so36542205e9.2 for ; Tue, 04 Aug 2026 08:48:28 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:27 -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=1785858508; x=1786463308; 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=ebyF9U3D/MvFmcX3JXdHMfkwonGwN8CEi9ANlVWdpho=; b=cX/6V6ybntMPMEf/atcWFMKZPIuvZ6LUlu0I1s+X/rguGNPs9RXhaj5p189ilgD6e/ Eh5UpzFMd8lKbZPqDxOFidX7Ztta4TMjtUy+PwnY8LmYV/3919QN4dIR6YyOFpAJyq5H K7cO11KxobVpW90IqXXGHmPnx8CW4Lzq6uYpbe1JobY5QrHE/BPYvmEMDkCoUTABZhal Z67JsxG/5Pjru1A9cOy83Liku4fd7UYUdR2sjvxeTeJSXxgljbOMIHije/CdWNRBKJJq nXmofN0yjhAlgJwyCOYsvdXmsRzk+H62Psfs8bwfvxyZYh2BTy0I3EX295B95GOqaiQO N/Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858508; x=1786463308; 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=ebyF9U3D/MvFmcX3JXdHMfkwonGwN8CEi9ANlVWdpho=; b=LE/pIyY1ZHKPYxDnpqWVqvsG90Rw1BpHkFHJ0nZFM2sQACak9E2b+SewmFMdmArPM8 pkMfcieZnUpHeMjK0GeQ5X9IQRccYhIMXIrRkTs22UC0LkRl51vaI57EcYST/ybOpIXW aolHhr5sxPxYOcVjEmAX48KpjAj+vLre8SGLV9v/fC2t9IXxGvjzi7okdk6Nt2Pgjfac a8hiJhqHXtp7aOzeE/0j1bEJ8brXsDTxEfbQcr21b4ecLnBRD3l2WwzbIgsbpdRN6MtG 0wq2COXQQeDPg++wzqVfEXOXToEuM0yndZtF8Fzola3MYQDq9X3z8HkJBlV2w9rAPxA0 rM5g== X-Gm-Message-State: AOJu0YywabMODMY7xeBJtxvhNfHwz0QDs5jSviSkSVrOB+SIyr1tl1QJ nyWRg+3Oc59MavNqaukYlxyqDWFULjNJmOpsTtX3oBO/vrDWc4HK+85cmdyCLw== X-Gm-Gg: AR+sD11H9xPPpHxSA1ubHCEqpFM/tQZJo+kxEwQpBoV84ES+B1Iv4ezvoY1ZQm0yLGB uCwGvM2GdrWx4S8h5YRVCrwh87wTfzzPK7PE18gLYrw91Bd++OEKl5/uqGYmodWDkyyleC6zZHJ Aww7RPjdV3ayyBTBtWY2RWq5nEFH9EzNzNVDFVnnOYnlayFt2sH7sxb0wzxYys9VolueZ5nS5ux laB88PpSGjuKXnY17JXrM2QuboZgODj1HCApUnoPwBArIzRvQrEdTJpbF28jNs+dtmwyBQF0+Pr rHo2mEkybMmu1J6yOEQyVQ5GG/XA3bbq31bZd7ulOYElUZf6pt94UGiPUFm72/ILnkmna9cG7RU ZruROax/qm0YkKehHrdf+mdkXCSS+pbjH/yI6IksLgx91bakzLG37Nox5qYcGUP0CLVQ81tlpoZ +UzXleOA4A+x7D8ucI4yJkrPkY+boSlfLfezD/UFn0aPpp+/O8sn7N5VSxc4QVC3e/YcZMcIXcw wmWUUkOAEDPMDGt9g8RPWvBQ8XvJ1EPdg== X-Received: by 2002:a05:600c:a016:b0:495:573e:1c54 with SMTP id 5b1f17b1804b1-4980c6523bamr409034915e9.9.1785858508247; Tue, 04 Aug 2026 08:48:28 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 08/20] xen/riscv: introduce init interrupt controller operations Date: Tue, 4 Aug 2026 17:47:58 +0200 Message-ID: <370ce245e6974650bd6efab9a4eba841f14552d5.1785836421.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-42698a/1785858508-18ECE9EA-DC2254E9/10/73395122804 X-purgate-type: spam X-purgate-size: 4032 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858540181158500 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-7: - Nothin 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 Aug 13 09:15:26 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=1785858533; cv=none; d=zohomail.com; s=zohoarc; b=fGmfubdMqzr9h5fvfGdMaJ8nDqUclM7icRoVrlcIcZbzxr7neYu+I7TDzhz/3Ye3ZNpHr1Hrl74UfsKGOGZrYF/87/3qTfVT0FOp2IqH063KrbRuW/+0sAl3T3T+Y3OlGZXrXNH5LhEZ/cVeXrniggaBmki5RaWlrxlj9LON8C4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858533; 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=ER+uu35/NuCBQKkMFT6UQDxN44ZmROCjZqSQxG2REVI=; b=RcPHk8lgbqZkxcm/qCequgjsoJwy7nWhgT2YI7F4TyLe2G9pxEGWa6/0igOjI8aKAIaltIv/6syDpSZ8o+iChh8Lg8QzrMIRinDHZ23Zw71pT7YFixKNkARGsa8XyYQuulmDjIliSw9zPCK9LzD4GsoNSaB29YM3b8UNJlOMr8I= 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 1785858533181456.9899296217261; Tue, 4 Aug 2026 08:48:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382271.1625688 (Exim 4.92) (envelope-from ) id 1wrHNZ-0000XC-0j; Tue, 04 Aug 2026 15:48:33 +0000 Received: by outflank-mailman (output) from mailman id 1382271.1625688; Tue, 04 Aug 2026 15:48:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNY-0000VR-Oq; Tue, 04 Aug 2026 15:48:32 +0000 Received: by outflank-mailman (input) for mailman id 1382271; Tue, 04 Aug 2026 15:48:31 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNX-0008SN-08 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:31 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNW-009QHz-CE for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:30 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c8-5cb7-0a2a0a5109dd-0a2a450bdaba-14 for ; Tue, 04 Aug 2026 17:48:30 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209ce-b7e8-0a2a450b0019-d155802cd52a-3 for ; Tue, 04 Aug 2026 17:48:30 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so21020405e9.1 for ; Tue, 04 Aug 2026 08:48:30 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:29 -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=1785858509; x=1786463309; 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=ER+uu35/NuCBQKkMFT6UQDxN44ZmROCjZqSQxG2REVI=; b=F54137HGfFFkXinnUZXnS7aXsO5/c6pfNP0uqQi3BtZ/TxB4/ncciWBE/X9lnMeKvB aMkKUTdvllYkgyFLEBUQoyEcv9SAqEab47Ltz6PwZklfEU+Gh5WGm4xpOjU6Riqi92/Y lzdAPinMymdF8+Ol5l3B4QI4OSu/5tFPFTb7/zti6Lgkb7CJVFpynTuDfWJvXRJtJpPT EpbQ3hzv3uHF6liBeGRaQMwS3NoYM927o/RMhg7NPddHzBWX/6GQ8bcxxOTdeea7RZQR cwQpCfHM5iyA5YyoYiE/PXceSrNvhNjWE7IaalLFjcTW2PPt4ZrSD6fN37j/RQ6zrBL4 UZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858509; x=1786463309; 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=ER+uu35/NuCBQKkMFT6UQDxN44ZmROCjZqSQxG2REVI=; b=esN7SLpwAfrVa+6ydYijbtIrQ18+8cAZ3pVvoQqqiw2rLb1oKedSHz3YyuEtV5MkxN LCc+jtLi08PcD1qersDP0irsbMxbfVZFWmbf2XjkjoAxtl+KZmlhrhmJodoLIBUVAuQt QxhBSn9Zj40IoASGll/9Am8QDQYhXo8H3ic6K6KXJ0SkCP5MFNGGiWbCyQF6JDZFKHEn H8rsE2nzBz1C6xDldz2u7jL8gfKZlzuSgfpADnNOBSX7QscaVHSf8nnBiEsS4MDb8Z81 wHM0JH5nTrQqTJzzBQW6NpqMq7vlG3hXz3EsqRXTtLG+o0d+UaCHHwWUJDScJmCy/hNn t2AQ== X-Gm-Message-State: AOJu0Yy/fUALqaYi7mZNFBz0hkhqbnNnHvdkLQIhNfbvbSHu2mDd8hgl szYiFtQ5ykDmDs1P6USpfgaDPdbtmY3o6qrECDo6MTjaduNitfKwkarqhUIyXQ== X-Gm-Gg: AR+sD10yWPMyOlfN3rVnNMaO1XZl2aCyosP5EsIdAXwb4kXBvuTHFmxnv/9nMEwXfoP jP/6mYYmjMZm7sxIvrKfcDIeRa10D5kRXwr/yAqMEdaU6r5i2wWJUN6iBDZHlmplMvZ6rGN+wUE kozU7YyEfrcVJ/c5BpG3czrqX0fjCn4QFBPRofQQYRmj2Yya9bTyRwgGbesdanajBGGxPdpXYVN PwAE57cEpP/vzvIo7cjcf2gJRJAfIX1e6b2FZds5V9D5O3B1qpXjhzAzup5FGYVH7oGgyKcvBj9 bxOXJ9yrfjzxKxoGc9RK3E8o5old9Q70FB1MmeA5nA5WajwpTRSYcl+FxoDwsIONphTv79QHDod eZb5+gaQXRoHwin38+JgRYtJrlVinUod+Abmo52KtHpg9MXhELqoNYzkOmg851WcWtn6daTwmJd g7sXrLuWlya+j2VYCJF/A/VHkO3y8pjpFoPTicK9e0Y3+lSVW40T9xJYl7e4vid2cMRGDOky4EO eYFg7rb1tfAZmO8sRzOMox77RkIOrbaUD5h2Hbh1qOn X-Received: by 2002:a05:600c:3550:b0:495:607e:5ee7 with SMTP id 5b1f17b1804b1-4980c679513mr352247215e9.17.1785858509525; Tue, 04 Aug 2026 08:48:29 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 09/20] xen/riscv: implement make_intc_domU_node() Date: Tue, 4 Aug 2026 17:47:59 +0200 Message-ID: <17901dd6707a12daef4aa1200c01fc1e0a754f63.1785836421.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-42698a/1785858510-AA2C49EA-10D82817/10/73395122804 X-purgate-type: spam X-purgate-size: 3439 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858534130158500 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-7: - 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 Aug 13 09:15:26 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=1785858544; cv=none; d=zohomail.com; s=zohoarc; b=hGV77R+r3daBECLEwb2g/9nqPrw0R2s9AG+aC4S3fUyhkyQeYJE8mhj/MVdfXTVFompwFXCSeDWLJZ9MHRGGeLqh6Epi6t1e4hyyEnQSI0F+zRX2//nqbSdA2F94ej2Wmtpgw+42pYovpbJyFcLINVR8BzuUM5hQ4BohD9pWyjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858544; 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=SDS5pojmUe3g07xF2AfnOz4IjY2ac3KvA+3GWL6CRYM=; b=DBjUolshS2GRLczAyQ44rtJIPf+Mpopf566fNlBIU85RkKcSQi7gzzewwngkeq2+KEl6oSitRQwQMES23EU5KgPKqJvi2HDjxCEKNXFbPo2/XsArA1xvr2KSjyuqtXxAOQ1V7oSgyewVeNw198NcslLtgqjp5W9cZ0LefiqGjrQ= 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 178585854418874.9296738005736; Tue, 4 Aug 2026 08:49:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382272.1625693 (Exim 4.92) (envelope-from ) id 1wrHNZ-0000du-Kx; Tue, 04 Aug 2026 15:48:33 +0000 Received: by outflank-mailman (output) from mailman id 1382272.1625693; Tue, 04 Aug 2026 15:48:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNZ-0000cn-9P; Tue, 04 Aug 2026 15:48:33 +0000 Received: by outflank-mailman (input) for mailman id 1382272; Tue, 04 Aug 2026 15:48:32 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNY-0000H8-3W for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNX-009QIN-GW for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:31 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209ce-e002-0a2a0a5209dd-0a2a45039d84-4 for ; Tue, 04 Aug 2026 17:48:31 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209cf-fae8-0a2a45030019-d155802ae1c7-3 for ; Tue, 04 Aug 2026 17:48:31 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49554ebb87dso29813805e9.3 for ; Tue, 04 Aug 2026 08:48:31 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:30 -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=1785858511; x=1786463311; 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=SDS5pojmUe3g07xF2AfnOz4IjY2ac3KvA+3GWL6CRYM=; b=rExF+rEmSxmns9/JGLQkUQ/vd3TB1JZ/fiz/f0i6v57laz3Eo2/o6P2J8Ai8sYqJab funUWIHDqSm7j13kM/9dIwfSEDDaZR2uCtmBxJQckmsZ6hvjwSSN0nMgOBl53b2IGyuS GKazF+Hu/fXgjq80QIzzVhXm1WeZ9X1vHJEakIwsiPSNCeyJPM/nghtm3lNkDo1qe10e sKzHWjDcPR868Gv+An6oy2S7VF75dIl7agVir5I0L2K1DH1Yg8H5OzxFZ4CDiRGCuRCb fngfvjNkq9EBNkvq2R2r9fAFLy78ikkcbzTx3XtG2Ht04fgZqyofxViGeCC7Xd/k6Hxu Ytag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858511; x=1786463311; 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=SDS5pojmUe3g07xF2AfnOz4IjY2ac3KvA+3GWL6CRYM=; b=hvGvTRD1j69g6jn+fcki4wxQAkwAGySkgNnayD6Pk6pbn1VeskE2z3IvkG8bc/Fa/1 oCDBdFXoQiU8va9deZD53x5SwHtTHHbF9DBoj4+Nm77sBi/PWzE0lH3SAp+MDdZsaLX9 DqfmEIXb1JiYq4l07WNYRH0aoe3Gdr+IqqA89LUU66dCzulgDzo3UFZlhvmnHD6Xm4WA W4Wn5VIlCl93SgeBdnPXcslW3jpxcwhilYyPwTXRNv1WMpaH8bNl4w48tXVqc+z7Or7l e04/PkQ8X+BIf20qBSrpynJ7576g4pToJ1gZmvgICMQpEIJMpOZbTphk8f6O5qi8dSp6 /bWQ== X-Gm-Message-State: AOJu0Yy1EUTNMZXnBF2Pk/yVSTHrq5hzXwlOmEbOjUqHJjdIxySXx+BG wznDGUHlF4ddRwGylHR60is+ph6j3menmBvWZKCHAA58uEXuc8rn8QqkfEghhg== X-Gm-Gg: AR+sD12w+X8tMWLBs1apKm3jEYuUWdXswNGYhL3W4jaox5pHAVwVJZ3eF9Y2ZBUKHIP Na0RDHBP5HcSr+lwo0BfqxvNTltS0/BCLJyPm5wq3SIjrjKULbq+vaMoYGLaFXbtf42Z49gzqtV u02crfHxtWUvWQ/L2TCadeKqiiHwKq3UsZNM1z8EfjziQJUtpjC/WQSGI1/boIPdbIuccvkZmWa T395fqhdtKhmI95F34eEID0IlRsKTO/JKyjsbD8qKc892wtMgOJxynGDbG7O6+lY2fRip14TEfI 329Y8Wse/cQd5fzp+5s0vCS7XIx+ae0dq1zv4RGQZoJoZ38Y5L7R3iba855w2lLlHSkAqHsRPdl 96Ugtx8aMNAqFtZfxdcqZuRyXZ2D3LbNfyyiO+GHRrY17vCLQgh+f9lgX1cScQkB30QZeM46k4b FOmcVIyIOvdIZ6jHq+iBcK3/CtifmheEY5xGIbsepB0+lAuXNVJvDXWnc1RelPdTDjnXUv5PR4A YEJNamdxcBwxWcF6MTKe2RULa/6WnbAnkU++nCiAP4JEw== X-Received: by 2002:a05:600c:6990:b0:495:4d00:2fc0 with SMTP id 5b1f17b1804b1-4980c673907mr369134765e9.12.1785858510888; Tue, 04 Aug 2026 08:48:30 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 10/20] xen/riscv: introduce aia_init() and aia_usable() Date: Tue, 4 Aug 2026 17:48:00 +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/1785858511-6E6CE4E9-47FC6A01/10/73395122804 X-purgate-type: spam X-purgate-size: 3240 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858546191158500 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-7: - 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 Aug 13 09:15:26 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=1785858534; cv=none; d=zohomail.com; s=zohoarc; b=JD2AU2dQ4bykxfvzHQlGoseDJ18k8TWOjSs7AquQCiQ9BJxstZv+snWwOCWhtYl45vn/fmIjowjn3IwYsKIRrb5n/Yp+ZFtdOpzrdEHSDvI9meiL9jjj9fgKm+HZ1olOAJkk7AVmRD5t+hU0R1lQ63iaOs+YSBPQQ2aekV8t5Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858534; 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=JS4Pww1oLiCPhcc0rWFj9bF1S4Vy0n1GnD6OKYVDJuA=; b=Ozf+0ZZz2guYmKSupnhvMsW/e1bgXU+GZiuKxhRdPdquSs+XM+xusB/AhfR+u/STUACoWD1oHTFiPXDL5mswI/mdt7ndCVWzQJXOohzG6VIV5g8cmI7NZguGj1IFaeSsrkPFBcENoTQQedrvZDjXh5XK106mCNw975Y8GwdXZcg= 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 1785858534852869.9223799123345; Tue, 4 Aug 2026 08:48:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382273.1625702 (Exim 4.92) (envelope-from ) id 1wrHNb-0000xj-0v; Tue, 04 Aug 2026 15:48:35 +0000 Received: by outflank-mailman (output) from mailman id 1382273.1625702; Tue, 04 Aug 2026 15:48:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNa-0000xH-Pk; Tue, 04 Aug 2026 15:48:34 +0000 Received: by outflank-mailman (input) for mailman id 1382273; Tue, 04 Aug 2026 15:48:33 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNZ-0000bs-Bx for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:33 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNY-009QNa-Oj for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:32 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c8-5cb7-0a2a0a5109dd-0a2a450bdaba-22 for ; Tue, 04 Aug 2026 17:48:32 +0200 Received: from [209.85.128.46] (helo=mail-wm1-f46.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d0-b7e8-0a2a450b0019-d155802ee5bf-3 for ; Tue, 04 Aug 2026 17:48:32 +0200 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4957eefd361so24591975e9.1 for ; Tue, 04 Aug 2026 08:48:32 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:31 -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=1785858512; x=1786463312; 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=JS4Pww1oLiCPhcc0rWFj9bF1S4Vy0n1GnD6OKYVDJuA=; b=GxGg0aJjEi0m0SDLi8hUlSnkPYL7fkDsdYH5sUjZYE9DPYOUVk92VETxiGbwsEJzZ4 N9yjlkiCGRDgM2PBvw0yo67d0v5olYejPsCrVQjyYtvu8nX5SLZKHIkqbH52KDHt8JLf ZQvMsLybG00c21voFJrp8UCwgy3zDR7dyo9rOV72Tt0DdAuvOS26mRFcertf8Qj4xcKV ao/7e7ktoJSnjcoTSCLOwvXTJDfS/NgTB5GfrFqzS7ZSIbesexKjpJo2pprtAAJXUT0d xkUO90/Sqt8PuoYKMajMSHwnyNLaXiYl4VCSiJz12IZdLPfAg93z8fHfeddPg5sWrwmZ Ms3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858512; x=1786463312; 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=JS4Pww1oLiCPhcc0rWFj9bF1S4Vy0n1GnD6OKYVDJuA=; b=eXXVUQP4ITueUjVnKTuLWh7/HkgS54/mEmKqyK+KYNODb9iMOMvDsB7oSTBUhcopJ4 /2CG8XanovWRAcpwhdon4//8grM3q1qUsquViMBIEkdXf1S0cQg/mXZMu+VXukjqHTnf C/yjkD903RBbDR4Y8tuYkD7yyZsjoYYxwHIeNgqiSc/L8ww0bnok8AhAxx2ujwibAgX0 9QU5atu3XNsbA5iizkyVm78PvW3hYbV2BMePlcdowXdL4XdXbyAehh2QptnlhMVzrarJ N7NbjGgnwWrNTD6ZyCX7JbUgjKib+3YWB6f8a6/Cahuehx+ey8p24bjYZmcL2YM5GZc0 n+rQ== X-Gm-Message-State: AOJu0YwDIhOowEV22sQhG8gziZBZ5ioC546q2hXafGGhdWZ0tUFXI910 cyGKY+Zs+NlYHvGWeto3DrAPesMw27e7lhVbpupCzitvRi2taIBDE4lg+MoDDQ== X-Gm-Gg: AR+sD10KKuSCcPtxPd0eS455nQJ4Mj3rd+CzQoxv1eRJrzvSlm5TLHkme/+U5iHE5Pq 0lV89gsNeymYzRM1p/IJMfcKumwUrlsUIRFHOj2/Y93exiffhnHaZ8rMkz6dRMlJkxPqPMMfI8Z KndRIjdXMNrGo7WS4XBUmBUsosiC1iF07rATXJDYlJ1eXZRrJ97nfhfjJVLRCLT3j5qjx0nYVhs 2q6tUFwCS1MyoGbW6jbERGJJD+sudbcDU3LoxjE8jNSROKBOR8fQmHWlkJv9TKNNmsvcVnSbgp7 7HSfxYcpi0iEmX7HD7U5ib/K/fzVY8ulJ52ACxIuRdhX2+fXArJpnb6k0Gi+aaYzrUqaPU4Rl71 ceepsywiz1ou6ZBV6vUlA7qCfzbhuNwyKJsujRofLS1f4nY9zA0X62blet1CHHC1LvqaxHiTPcq paawXl37CFwXntOIAac117B3ogdnnKpsWl948WrF2EZQp2yU3f5ewF7H0OLBAHTfoQc4J/LC12M bb1FtUeqHZByqLOWez97Lps0gM+7yWMLb0RTJmcw72l X-Received: by 2002:a7b:cd93:0:b0:495:3de8:33a6 with SMTP id 5b1f17b1804b1-4980c65ed1bmr280281485e9.16.1785858512100; Tue, 04 Aug 2026 08:48:32 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 11/20] xen/riscv: introduce per-vCPU IMSIC state Date: Tue, 4 Aug 2026 17:48:01 +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-42698a/1785858512-A86CA9EA-71F21E10/10/73395122804 X-purgate-type: spam X-purgate-size: 6490 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858536169158500 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 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 f7b70a8da09e..5a5758e45dc2 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_pcpu needs an expli= cit + * initializer as its s/w VS-file value is NR_CPUS rather than 0. + */ + imsic_state->vsfile_pcpu =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..e2c413487d24 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_pcpu =3D=3D NR_CPUS + * h/w IMSIC VS-file -> vsfile_pcpu < NR_CPUS + */ + unsigned int vsfile_pcpu; +}; + 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 Aug 13 09:15:26 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=1785858545; cv=none; d=zohomail.com; s=zohoarc; b=ny499wFRDx9otdJNNBFbbzQNRLLcrBY9m84gOLFBAWMOh4b5RfGfPOc619cS8ah2Zee518BeLSnxds4idz+lNQQ3s+irr8KhPkdgxwnVeyJtNvJHuwC/v1amdqntPvIo886ozd4pygqA7dQ2tUxs6sOwP5Pl95La9d5Ub3+RHWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858545; 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=yz5kOHNRF0KkwzsTFaIMw1rEUEyM76GxO23CT2jclP4=; b=C69Sblr9Clhg4X2GqpZokgGMau4WqGfs0XM8vdI4fDnWs6d03dayC8WX1n7PBQy+ob506F26v2PvUw57GSh1D9y6bB0AQo1CGLMk+d59QUIjvJ2OEj4ouBxWmezoPlkCYs1uEn6tcn0/o2hvPVIb5k+BcAkBqiSCDYV418sFQJU= 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 1785858545523475.25837504131937; Tue, 4 Aug 2026 08:49:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382277.1625713 (Exim 4.92) (envelope-from ) id 1wrHNd-0001MP-04; Tue, 04 Aug 2026 15:48:37 +0000 Received: by outflank-mailman (output) from mailman id 1382277.1625713; Tue, 04 Aug 2026 15:48:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNc-0001KD-Nc; Tue, 04 Aug 2026 15:48:36 +0000 Received: by outflank-mailman (input) for mailman id 1382277; Tue, 04 Aug 2026 15:48:34 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNa-0000sO-GY for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:34 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNZ-009QNa-T6 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:33 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c8-5cb7-0a2a0a5109dd-0a2a450bdaba-26 for ; Tue, 04 Aug 2026 17:48:33 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d1-b7e8-0a2a450b0019-d1558030a46a-3 for ; Tue, 04 Aug 2026 17:48:33 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4994c49f588so545515e9.0 for ; Tue, 04 Aug 2026 08:48:33 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:32 -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=1785858513; x=1786463313; 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=yz5kOHNRF0KkwzsTFaIMw1rEUEyM76GxO23CT2jclP4=; b=Tvvh/o2fIIsOxbOs2SpkVCmn09HO2alCl9520s1PtkvRUkLSkPYcf0K0DfO6AD8Xm0 SKObNcqVl1LUlaRYc1h5PK45h8tl76FJ7x0smlvHFsU+KqU/fnGx/B/JQuiuHrx7cUXe p7BjeUdaQ6ld1JLAIAvE0D+9OZeG0NsEulO8ZhQjnbKS4VEPeaN0jCJ75AMxyhJLvyf7 FlSK9pGSpvRwb0UvQcpaoh39/0CWfVHsqIAJuaxPvthN8IVe6uldzTo4xL9s57u6nyQK Z/6W492qUgVjSZaHV/RNq4/Yp3/FqY7grg2B5ePEmAx8Zfau21i7oH32uL+DvtMGNo6G hF8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858513; x=1786463313; 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=yz5kOHNRF0KkwzsTFaIMw1rEUEyM76GxO23CT2jclP4=; b=SjEAAWK/kV+pPXx8djLzuhekMbub36j/x5ISTc+jhbX9RjH/1KhCQHzmdJbIw1BVpa 4L1GpftR0selvYIATuZxwVJ9IJKszbM7VPP0ElmfEzk4ZBqj8kys7VUBM/hSyivREPP1 VZq5xCH4fQugJPYsRWOWRx91afAjeIxP00LqLFgyEtT7wDTqVtrabvPjS/9LtFqgZ1jI MmQ0YAaYE1zPHHSdCGd8qRlV3miEwsBuJz/CbNErTa7I6bFD5l0JNhTKyXG/y0AP+pFO JS7n2+1PwTVgWBblKmmfBC47teoC2xWo4P7M5cEmaaRCa2nssL36vdC6NKYshkDI4xAj fFAw== X-Gm-Message-State: AOJu0Yw3S8WxZWaWaDyl6WXmT+F+8kShUCBd9DVahoT3q3TKo1oPk/+6 k+ksuX0e9GlTDVNm0EycgEYbUU1TFJcoh0z1igDTeFpU/r0sqcd52BLQoZCOWA== X-Gm-Gg: AR+sD10CiLcnlPOZWrgVFekWp49QrRr89PSEtPhGFOZiGsZaIOpyYcJ7D+RehsDgo2A f30Fm25lLFhGfuF1d82XLgE6xm6bwCrX1hbwts747vX81+lbbJYr3OJp5n1+z36sgx+nd2zpWul TMA2cWvCX20tDGYOq/A9PKKE4zpUu1zaIYpCHJvOYsAkxPIyhIiQ9lOiedN3Ud7IFy3GWua3rq2 sdR3RfNLyj5qd+f4mFgAChMgNtKtU5fg8dQ0HpFTT0iWk0gPIbpQ5U3VIJr22I7hsnCigmgJrLS SBCQyIT9N6ZtQNGOtQSjrgvXK5Y3l04DTLx8vy4jx+O/IC+Cwd9faFOJPGIcQvU1P/NwY/huAWS dZOmPbSziGE46QGpr6pMQXfiFn18o4sx6t9Kd1NiuwU5k7NGZZpUvDpkHeRl2cvjkOpfpzoMwD0 Uo40g7Snfl86fWf+FymPt2va2yumILGJWxWVnaY+kfRQfDDAmoIkX4f6fNMUuKPsIoFoZhn37ez EJDfHeVyioXr8FsMRWfBrX3WNyaN7fjIw== X-Received: by 2002:a05:600c:1d1f:b0:497:ff5a:38b9 with SMTP id 5b1f17b1804b1-4994e39509emr554855e9.9.1785858513177; Tue, 04 Aug 2026 08:48:33 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 12/20] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Date: Tue, 4 Aug 2026 17:48:02 +0200 Message-ID: <7a592e36adcb805d87cb0d4c41f3aa96d7eb88e0.1785836421.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-42698a/1785858513-A9CC79EA-2B2B96C7/10/73395122804 X-purgate-type: spam X-purgate-size: 9625 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858546265158500 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 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/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 | 62 +++++++++++++++++++++++++++++ 6 files changed, 119 insertions(+), 8 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/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..c813979a2ecb --- /dev/null +++ b/xen/arch/riscv/vaplic.c @@ -0,0 +1,62 @@ +/* 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 int cf_check vaplic_init(struct vcpu *v) +{ + return vcpu_imsic_init(v); +} + +static void cf_check vaplic_deinit(struct vcpu *v) +{ + return vcpu_imsic_deinit(v); +} + +static const struct vintc_ops vintc_ops =3D { + .vcpu_init =3D vaplic_init, + .vcpu_deinit =3D vaplic_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 Aug 13 09:15:26 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=1785858537; cv=none; d=zohomail.com; s=zohoarc; b=DzpEDdOal47GmSN6a9WM4ETwv2lEc8EiUbQYOGVTIjud9KFUnmnBbUekqAQ/nOFjFqzrmqyEbZEchVIgP5UMCe+nvLTZ8QRzv8ofSNE6AgdugmuH5nUpMxxoLjLK1x0A6M2MLLyshNW/EbyMFLjFAW0wPyILvCtuROzQSrs7RUI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858537; 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=pNfWXKz7OiThFTVcFdBZ62/fmTIqtlbdTWRNjBnnGpc=; b=lKHRwjbjvTWCDrvbjq8ocfKCM7EEHIf420VXKudKFxl+yrDENfEqdcsxWw9qPo6+WIbB7zZYgCKabHq1q2ualxV4U5zZOvGiXoJ0ePEg7p639ZbZlbdnJ8ErTgbW1ld6ZbNzqrEcBr75Icm1MWraOTskErPmpMl1s+mcj6Npe2k= 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 1785858537354411.14482345142085; Tue, 4 Aug 2026 08:48:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382279.1625719 (Exim 4.92) (envelope-from ) id 1wrHNd-0001U4-QT; Tue, 04 Aug 2026 15:48:37 +0000 Received: by outflank-mailman (output) from mailman id 1382279.1625719; Tue, 04 Aug 2026 15:48:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNd-0001SR-Cl; Tue, 04 Aug 2026 15:48:37 +0000 Received: by outflank-mailman (input) for mailman id 1382279; Tue, 04 Aug 2026 15:48:35 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNb-00010v-Fh for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNa-009Gcw-SF for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:34 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c5-bab6-0a2a0a5309dd-0a2a4509cbee-26 for ; Tue, 04 Aug 2026 17:48:34 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d2-be1a-0a2a45090019-d1558031d14e-3 for ; Tue, 04 Aug 2026 17:48:34 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4955158f26aso23065955e9.3 for ; Tue, 04 Aug 2026 08:48:34 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:33 -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=1785858514; x=1786463314; 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=pNfWXKz7OiThFTVcFdBZ62/fmTIqtlbdTWRNjBnnGpc=; b=Dk6uZXJA6qAlrAEqZEzvjVa6D3gz9tyNKvBzDAAAQgXzM6TrstVeX6i/Kx9Wtd8slt wBrXRXMnQ2B13Pu0HJoZhB2VtqgBgIJE81v7HYSoRc07qMi6JG325CgQCJ3G/4tfJKrN t7115Sh2s5NnvwkimPGnReFyoFTBguMWT3T+THso8gnCSNKj/FTnijMed0ZTRX9eycV5 7XvyPUDv/2Fc2JIF6uvwXqKF2sCiK76hrC72/w4uAJ05CVYD1g50Kv8/TgzgB5U9QRsV rZz61yeDNVn/rOsD8q3WtFQVU7sJ0niKRxEl5PHsLuJeEHeJDuoWfWY9wMgZ/vtst+Ya YbMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858514; x=1786463314; 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=pNfWXKz7OiThFTVcFdBZ62/fmTIqtlbdTWRNjBnnGpc=; b=MhObpbTaYk2WRVx5jlNxzYZs/0plYNqVlwgVwDV4c3VDQcsyXCulswdVzZ/r/YdYpp s6GAqCyiBKQI5u2DqC5MzUWLXAbLvNB3F+rFfmgcXzAiwaB/fUvh3e/7g5TufJIhwoWq yHP+cKBcPIg9+9d6tOB2zOrGYS9sONw/vRi2e6DsZTBQekkjX9jEqzTnRMaCEQ8DkJvM TsFkisdP2VYZMmR+ns4XnjGTyNcE/rR01DaPAD71OwOPfZhWQafUA9MgHZztOUd37ZhI IytT0INBabW+9+HSI5rkrsOaIRTHpHKQE8/GDb1wcDvosMoEb33C3pxZBb6m8GJ4/0fd w/Mg== X-Gm-Message-State: AOJu0YzATc0rCfseCtAQKT5WMH+OLSjzsvczPd2qiQCGrd2gG2am8F/3 gR5/JGurlyDywMau3twEd4dCT5EvOWvBf4KaRbc1ghwrjfvWYiTM72t4AmWOyw== X-Gm-Gg: AR+sD127y/ABlsbUx3uvRb3z4y9MRGbMBC+31svGRHtDi543iAuj8l27akIMYknTjCm 5HyGXBcLijvg565hfdsZNxfm3bZOqaCHGu+PA8iROrenPlmtvsFDKXhkKMlx2GXMI1tUdxUaN7B HF1/qYwvbTMu7K4PBR76PyWeZEkD11KBVoANxiUIOqAqTa0XKEBHHqyjkw8EIIbXGD2O2WWvq0p DM4QRBaxuD8Th0V/kZ3gzcWvUIRxCYN4gA2nYfJvoZ4JUc3j9tEi6e1UShbqOM9u/Le0qaxCV05 f+0/ixr1K6oGVT5rIGb5zHWvgDFfgqLHb8omPy3Q0rbctSrIFkwaf8POQRs7guoAmL38myJg7Z9 RFBvNBYBJbw1U/hUrMOHycZFwqLUXVbmog9tG4bL5jU09EscHD+F4iejAWKnpZl5x7MeUGI3Hpi FNXt7hbUSv/ZkHDudYEDhnTjP/ydpwCu0wpTHzVCm8R4e+yesBeA0pyKyc4P+sfjI5jcsxEj2JR DcYVHK070iqgP6yzxkEF9MBHuRISipnZg== X-Received: by 2002:a05:600c:c113:b0:495:4689:1e98 with SMTP id 5b1f17b1804b1-4980c674e1dmr306196645e9.10.1785858514288; Tue, 04 Aug 2026 08:48:34 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 13/20] xen/riscv: introduce (de)initialization helpers for vINTC Date: Tue, 4 Aug 2026 17:48:03 +0200 Message-ID: <30c9d0f24a2e9b8ffafebb33a832ff0d61671544.1785836421.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-bad1c0/1785858514-FCE14034-DB5ECD08/10/73395122804 X-purgate-type: spam X-purgate-size: 3635 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858538143158500 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 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 | 3 +++ xen/arch/riscv/include/asm/intc.h | 3 +++ xen/arch/riscv/intc.c | 35 +++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index 45712d305975..4db9c28662c7 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -308,6 +308,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 Aug 13 09:15:26 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=1785858546; cv=none; d=zohomail.com; s=zohoarc; b=RXFdqhd5Bp67+fWHRpqZUk14kk+6ySlXKUnSz+uyjwKprhZ/gHPuhz4+LEfFtohJP4VhtiU6gB/WhE62C4tVWNb0sib9C8Uxd2fjg/3yMo/6yinGC0kOQgfD2p46pm3se0WnN+elCp3xV0/uTBGi5QOa3pgWMWjbEU9Te7pxZqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858546; 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=l7ZIghm4wlZpqQWikoFDy/4FVF6m3wHWKUUWrNvkWao=; b=hDqN9lD1EvEABqOVB7zRh/h1jNKL8+Mr6fgJEZn3UaQfdqa2ZHqgUoaCSWPVbz8T1Unr5GePjCrHS/uaS4QjqYOjDcRHLfNozMadbYhf3K03pEiAk45FHybupsefup6tf2MXUQdkYwUxba7qNxFnb3MzjenoQ5UUnbzmc3xzy44= 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 1785858546172466.4384440232518; Tue, 4 Aug 2026 08:49:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382280.1625725 (Exim 4.92) (envelope-from ) id 1wrHNf-0001dU-3X; Tue, 04 Aug 2026 15:48:39 +0000 Received: by outflank-mailman (output) from mailman id 1382280.1625725; Tue, 04 Aug 2026 15:48:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNe-0001bl-6I; Tue, 04 Aug 2026 15:48:38 +0000 Received: by outflank-mailman (input) for mailman id 1382280; Tue, 04 Aug 2026 15:48:37 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNc-0001I1-LM for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:36 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNc-009Gcw-1e for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:36 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c9-bab6-0a2a0a5309dd-0a2a4508eace-12 for ; Tue, 04 Aug 2026 17:48:35 +0200 Received: from [209.85.128.51] (helo=mail-wm1-f51.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d3-f659-0a2a45080019-d1558033ac15-3 for ; Tue, 04 Aug 2026 17:48:35 +0200 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-495590dde14so34298045e9.0 for ; Tue, 04 Aug 2026 08:48:35 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:35 -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=1785858515; x=1786463315; 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=l7ZIghm4wlZpqQWikoFDy/4FVF6m3wHWKUUWrNvkWao=; b=ZTtd98gIekj8jEQRyKWKcBTNE6Pd8sn+nYTZsJfn9tDcE+mMVW6LsaZUhPpweZEZAV 37nmU3i9gsPYsg9lbi3vicfBjZ1yy0o2DgdlW3ziIxeg8OHGW1SnmEPCZCMeps6MGIzJ 2s9h+ueoOnnXUyS7FVarmeF1fUEedBnStMq13Udth8vYkoxRzgdBI5a7tEJuajHUelEU dxWJu/sYCvTrRldA3ILn/tQISeAkMw1vm+eGBa4S1fgKMYPJnDD4bAGuX7sNj3wAD445 nCP9FutvThgjTvJVO5W8HRXYiiA5Y7UZwrVgKQT7mfi3aDf+PiqQf+IcifOCU0twdeH5 URPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858515; x=1786463315; 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=l7ZIghm4wlZpqQWikoFDy/4FVF6m3wHWKUUWrNvkWao=; b=CHHoqig/WU5M6+xWzN0oz8sH0uc7pwR/LIXLJeULMxJXPVD90hFIFI80K1Uw6up+SY wRGA6UeKqSQkIZ4qpDSY+9k4c39NYhbkrJo7uOpbhesbXQ1PNMwc7ysx68INwZ+uGbt4 3fNygtA9XMxddfWZO841tsPXfklWoS4Kw61BYh6q+oePcUCuDpBaWXdQOepyuNH78/Ar Pi06yfrO0xiv7dUEe724ysWPm1i/Q1NJM3jCrRRt0gkSdyLOcvSlyrQeJ9DlRWUSQvCv Bp3Mr7cnlYZ8EoPazIurtFqZRahRDQxiXqpzC0llD7x1KW2cko88v3MCIlMGVcmGQpFC HvWA== X-Gm-Message-State: AOJu0Yx3K58epaimVj6G4JIdnLs6nSZI6ivtF6zoSU7uVkDtE64jlCOy lcu1Nlv6IVKPi1pkQ+znmU1NesGgLfJQyg7tOMsA/97zg0gfnN6AdXYMhfMcNg== X-Gm-Gg: AR+sD11xTBXWCcEWlh0tETy/kgeLuVl8+tE3FbxhpIL9EDM+XVnWvumrff9V1OBv/N5 icQSGWhuRDodfOotMQs2lnejplhuVD+1GNe5OAWaInX/1O1jpBEpg40o3iiPb14wn4i77wOhyms 7MUhMRX3VZtlhwwcj4Vn9DDC4tXRJzAmcDdQcgHgHxOvVkwex5XNVMhN27+qReImL7Zzqr+UgqJ 7uLJmSUx/4lC08hjE8j7O5Sue13H0EOEM3mMC/L4WaSAXvUaFIYRCmOGcX5tMztdFlL/eyRQP8N KA9m8qW8/ywWxNDVkBnjNUS4aRznjU/tUzHSskz/z6aXBIqCt0XMktlU+Rb2d22ghQ3kc9hftix MFFiDQTxoH4Tu2T1iPHI3sMEAyqJ/bYtZ5I8NDoE6RbEY6qJ0wGdXNB7QNaVBnO0udUhBNlOuzI TR1bTRPdCac8L3/N7Y1L4m0UmMpyGaoGlgsKRGinoUNXrCDWijjNES0ZSNcq9/Zl2krVZPypZqi J0wVLXV3UkFnyhmgrr++419v1tpYYvKDg== X-Received: by 2002:a05:600c:8b54:b0:495:4859:8f9b with SMTP id 5b1f17b1804b1-4980c674f25mr402292425e9.9.1785858515349; Tue, 04 Aug 2026 08:48:35 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 14/20] xen/riscv: generate IMSIC DT node for guest domains Date: Tue, 4 Aug 2026 17:48:04 +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-c1860d/1785858515-D497287B-E186827D/10/73395122804 X-purgate-type: spam X-purgate-size: 10732 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858548258158500 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 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 5a5758e45dc2..ffce77209c26 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) ) { @@ -522,3 +546,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 e2c413487d24..e1ec3d03c4e9 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 Aug 13 09:15:26 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=1785858543; cv=none; d=zohomail.com; s=zohoarc; b=ZrgexbNyox+pUx+8ahFRKoW+3TnFJllBdGQF3M55MzkAss0O9MOuE/cQeD4QzQXUhR8UWZb5q9Uf6/i7ZVB9GZOxGm4pl+hnV5VhRk8709FBgpJm1o3oPJk5/IN+kTVqV4qC5m3biXBWBElAKanoi/K7z0jqCCF01Ai4Q2TRZZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858543; 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=lLGWWikfegmq1d6uXZbQV5K+lLsNHD8dZ0j3uuHsqqQ=; b=LAHGjHGKp+dkuSdh3T/embNoYYIwVNy+wmh/NDb+aFb+9gi14tngCAJCGYtoqwlmrVRA/SuqB6rTsMApuUl0uCmtVuB2tfPY8VacEj28KAOhJMzrKcfHDXXZ1ha1G+F6HBIdeUFn3H2phwmGoR0k179l9BygDlt3et+Ah7UhmpU= 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 1785858543053869.1820784540907; Tue, 4 Aug 2026 08:49:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382281.1625732 (Exim 4.92) (envelope-from ) id 1wrHNi-00024O-A0; Tue, 04 Aug 2026 15:48:42 +0000 Received: by outflank-mailman (output) from mailman id 1382281.1625732; Tue, 04 Aug 2026 15:48:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNh-00020M-7G; Tue, 04 Aug 2026 15:48:41 +0000 Received: by outflank-mailman (input) for mailman id 1382281; Tue, 04 Aug 2026 15:48:38 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNd-0001Uq-S6 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNd-009GkK-8R for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:37 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209d5-e002-0a2a0a5209dd-0a2a4507cb76-2 for ; Tue, 04 Aug 2026 17:48:37 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d4-b4ea-0a2a45070019-d1558030d9a3-3 for ; Tue, 04 Aug 2026 17:48:37 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4954a32cf1eso16288195e9.3 for ; Tue, 04 Aug 2026 08:48:37 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:36 -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=1785858516; x=1786463316; 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=lLGWWikfegmq1d6uXZbQV5K+lLsNHD8dZ0j3uuHsqqQ=; b=rA8tZNhn33A8EsPIN5q3K4SEIb1pdOnMsx0lSgwwovCe5Ti2znKlsierFNKMYnAWuc DpTy42hvPgraFOb748R1Bl2fivVGnA6cj2r32qKW4Gmbg2qb7gRf6B0RlTA0QUj7M4nV 1IX9Sj4D1EFjnGPbHIlCdetDNqbjq2appRBHUKD0n9ORgBoyFN0kczY/090VhotUqf+C YPsuiExbi5WTgM8mSU5F5zWhybVpcLESBrZDtLXBj4RGGeyVJz4OIHcQNLHvEUHkgk9O LXonRg5GbFAFjOP6MPbx4HaEHyQaV4VW2hgqenWcmXbXqE5Ffw03LAjqTWqushO2KyS8 ZLmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858516; x=1786463316; 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=lLGWWikfegmq1d6uXZbQV5K+lLsNHD8dZ0j3uuHsqqQ=; b=FthLbcK+N1WLynPLnxUOfyRGJGTq8FbxzQovsCh/SdSiV7x8j2aNQB6ktMm33VSnPG dz8BmlsvvUaXKpnu8T7u7vlnDL1RorZQvjkg1JGAjosv7JAbvMdPGmJ4s/hwxkkJT0Tg Tj8qjOgKpfyGa2yUoaLWRXO8wPcgiBfN4LGlDc5AeDwn6Zbpc7rYHBfuh5cnNrRl2cIY RjfMzUoVPNGMAauOoTsbDb8NfEA/6ralNKwvFkn2niMjFW3cAfy1UlFufYSbOTq5iGRJ rge1x0ysJ+nmy5kFyMu9uf/mQzaNxV/g07WJCiVpWCpElqo6EImYJGYf+VH6MBmeSBUO MH4A== X-Gm-Message-State: AOJu0YzzxLdP7N5iHv99E+t3LVJiMZ2fnUkI9Ka1VGEf6HWa/DmJe00j YI+cLdJebG25nNvZvwirYlIAAhpTPNmDy/nmCp4Mk5DyOKt6UApRzKS3dD6nvQ== X-Gm-Gg: AR+sD13fyewUVOxokvqTyyPw/S12dwQQwaQVnGS2t2H5tWvOEd7FnTxmdxSUoleJeLH Bgf4fATc8Dx+LDS+6c/7NkvbZXvLzqDVl188H9qnzpx6s8wzBzXE39RjwJlOYTFR7qur5bg8Wqw uKCQR5dYmhAkiPY6AZYnBAWlT4V707mOe7SrL47GfYjcBN4yi7rW7ttKn1s/OOZFeY0mjQ6W7Jz D9BE9YdljV4NPmr/ImokTD8Mqd0yRGwKlnll15b+9otVuEovjsge+NqL2A4GIKmhcVur2QBTVM8 vUBeP2RIcSfk2roZp2AcA1liRLDBmhnTxV5XbhcyrTS2hwJ4i2Mr6h0wUu16I2c5ylmAn0Hpe7q ADn0Clf2sN55CL1jY8I2PJQBgSaMu68nlnyg4zg8BbDKRnNGzBKVG15cn3G7/hl7EnjoMPBmW4D /1QksUlHdn0/xCZfQfTkEHXBPKymaLvjGcaDG5R1rG4EEmsgVQBJRBbrQKrRHg+HD4Lx1lKhyzk m54JY1rRha+H8CEOqLVQCx5npVPvtKVa+hXdSS30h/+ X-Received: by 2002:a05:600c:19cf:b0:498:2b1f:e0c6 with SMTP id 5b1f17b1804b1-4982b1fe255mr170113975e9.18.1785858516531; Tue, 04 Aug 2026 08:48:36 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 15/20] xen/riscv: create APLIC DT node for guest domains Date: Tue, 4 Aug 2026 17:48:05 +0200 Message-ID: <6ecfa02afc7237ee229a1ca2d12369b226ca816f.1785836421.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/1785858517-A5CC7AE4-A83E76A3/10/73395122804 X-purgate-type: spam X-purgate-size: 9020 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858544292158500 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 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 c813979a2ecb..72bb2c4dc3c5 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,12 @@ =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 cf_check vaplic_init(struct vcpu *v) { return vcpu_imsic_init(v); @@ -29,6 +37,74 @@ static void cf_check vaplic_deinit(struct vcpu *v) return vcpu_imsic_deinit(v); } =20 +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 vaplic_init, .vcpu_deinit =3D vaplic_deinit, @@ -43,6 +119,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 Aug 13 09:15:26 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=1785858552; cv=none; d=zohomail.com; s=zohoarc; b=W7ZM90TscLqeHx7jpxuxwiSsY6w0f6wI3kQDujjgV043F+9q8qhA6FupCJAxkHg6Ai8xG86eNW5mYRTYqZPQXgDO3y3FRCMt9H2xFtDL4DOB3CGAuSMCPfSnakIIUXs2hHLC46J0MDJ6O5eZjcEKzylEkSvb4HFYiPEqbCk/u+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858552; 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=C5MjzH6tWZC1vulhg4mfpL7kW1xzkWEA9okhBx32l/4=; b=lK2rsGq3jGhewX2ZAbQk4bdMZLR0xaKGROUK90CUN+5zeXJbeudcjCbq3tdJgRJKMhtzwMq8TylJiZ8Mw/Uw5ZBX//O3FhFsJpsd1vbW/F2n5MSOoKl0etnKqL3H369D4o6uhCdX3MoF7pPpzac7+PL5t9CyOni9lnDeYuLCjpI= 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 1785858552912645.7856258411955; Tue, 4 Aug 2026 08:49:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382283.1625736 (Exim 4.92) (envelope-from ) id 1wrHNj-0002CY-34; Tue, 04 Aug 2026 15:48:43 +0000 Received: by outflank-mailman (output) from mailman id 1382283.1625736; Tue, 04 Aug 2026 15:48:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNi-0002Af-8q; Tue, 04 Aug 2026 15:48:42 +0000 Received: by outflank-mailman (input) for mailman id 1382283; Tue, 04 Aug 2026 15:48:39 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNf-0001hs-7W for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNe-009GkK-I9 for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:38 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c7-e002-0a2a0a5209dd-0a2a450a9cf8-22 for ; Tue, 04 Aug 2026 17:48:38 +0200 Received: from [209.85.128.45] (helo=mail-wm1-f45.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d6-f2d2-0a2a450a0019-d155802dcd15-3 for ; Tue, 04 Aug 2026 17:48:38 +0200 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-498028b3d5eso35007495e9.1 for ; Tue, 04 Aug 2026 08:48:38 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:37 -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=1785858518; x=1786463318; 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=C5MjzH6tWZC1vulhg4mfpL7kW1xzkWEA9okhBx32l/4=; b=BGjXKKHSX+OxGm7JiMS1/+msZoeIiY5qyUFqLHUIdRsrBHFK17RTbIRW95oZ08j2wM raXjmOXfF5+GoKrRxvuVNNUo2S6O05ZFoBLEOWJtK3ke3MSbdFYLKqCsEeIv451L5asx x2QfIMgkGw9ji3EzMa6XDdijhIx1TC8U4RYdRa0+yI1rRYQxli+Pw5+dDiLqxH1LuUCD DnpGO6lkwEOnJPOilk92piO47bMch1/vg5skTT07F2BttPdx0kfkyHok+D9jxLAv/kIB qhLV5NaGCk35Un9R16yu/huoV39ChkK1pWHh0i8QBatsvJa6rAfOPCTUph4VUv/g2l6e XPTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858518; x=1786463318; 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=C5MjzH6tWZC1vulhg4mfpL7kW1xzkWEA9okhBx32l/4=; b=HwwiqPx+x53H+p9DfMSDj32dUZ3ws/RUQ12d8tIoxRbvn2XL79Gdz7PKPih28nnmZq uHfA4EFvn+j8la6no5ByajWzQ5WAGA8R0M25yPJuQ/bFRFKJ0R4Pr32e6N3P0xKbuwHS NBJooGSE/AvoLz4xCUmHeZNVqopPQ1hJVXkFv23K1XmdH03te1el0ojFompJsyBIGYcC f054z4eWekL/2Dqax4FoSSEIQjHTEtJZMMeASpR5KFI+R7gI7wbgQAIirna8ODr+vOSm 6mDmlS7bz4Gukn6nZu12H1Co3G3MB7lODWNDXIYVWP8ccpnLdsHbJfZ9WJI2cWq3Y0+G pWWQ== X-Gm-Message-State: AOJu0YzsMnX+dVxDxV8Uk0+RaWj3i3FUzUbOMnC/29kPT425iPnX6x0A iC3bAXVFkrF8fOCBLErFe8dHnkM1HmZ4LTnqricVSHoupqMCuPzBUDZXmeS10g== X-Gm-Gg: AR+sD13F6tuWyjWPuRUWLft3eV6A10hivuEwc+niIlQYm+kfiNBMc2sLG5tr/9wJ8hH 6NaQqtUFy3OZbTSdJQ/H8KhGzegq5bQErlYpo+1coEWuZIjzLZv40d6JrqcNtly1tfYR/uvUI7c CoPeLGotAj05wszCQmvtsIRXsq0C4F1/XgNRlfrt0Hj8awiLExi11TMx5A3KuKmb93tkNNczpBA F7+NkwdssCdhZmarneHxaI5DPZ0CPCcmybEbUQ8j4DFV2mBF4HXVxTGwa+A0iUfP2xU667ipPdn pDoNo8+Nd0OhZePCdfuCforJYGQ8ARngZr4cAFj588YMNU/XCXAHdiQimUEtbNwz9jbJKboahsY o1YOp07vBEsH623eOjzGftuFacblM8HrHKecjd7Q/6LWELj9OMH4SpfUzs4+CV7RX3fsVjdsScG MBLwr0mXhERLyHCEasmX5mn72ejHQy4/sLncUMG+w797S4DxDiaM2IAXGVsSJcuvM8go07yF7cx J0fTPFjKEEf8PDzg0eVlbjvVhvlEU6VfBbZL0npYlTp X-Received: by 2002:a05:600c:840f:b0:496:c379:b2a1 with SMTP id 5b1f17b1804b1-4980c66d7bbmr299616715e9.2.1785858517394; Tue, 04 Aug 2026 08:48:37 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , "Daniel P. Smith" Subject: [PATCH v7 16/20] xen/riscv: implement IRQ routing for device passthrough Date: Tue, 4 Aug 2026 17:48:06 +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-4011c0/1785858518-508CDCFC-81DEB2F6/10/73395122804 X-purgate-type: spam X-purgate-size: 25224 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858554344158500 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 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). --- Updates Signed-off-by: Oleksii Kurochko 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(). --- --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/aplic.c | 4 + xen/arch/riscv/device.c | 94 +++++++++++++ xen/arch/riscv/include/asm/intc.h | 9 ++ xen/arch/riscv/include/asm/irq.h | 5 + xen/arch/riscv/intc.c | 45 ++++++ xen/arch/riscv/irq.c | 226 ++++++++++++++++++++++++++++++ xen/arch/riscv/vaplic.c | 9 ++ 8 files changed, 393 insertions(+) create mode 100644 xen/arch/riscv/device.c 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..3681f0669efb 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -325,9 +325,13 @@ static const hw_irq_controller aplic_xen_irq_type =3D { .set_affinity =3D aplic_set_irq_affinity, }; =20 +/* At the moment there is no difference between guest and Xen ops */ +#define aplic_guest_irq_type aplic_xen_irq_type + 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_irq_type, .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..f54d0fdaa7ab --- /dev/null +++ b/xen/arch/riscv/device.c @@ -0,0 +1,94 @@ +/* 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 ) + { + /* + * Checking the return of vintc_reserve_virq is not + * necessary. It should not fail except when we try to map + * the IRQ twice. This can legitimately happen if the IRQ is share= d. + */ + vintc_reserve_virq(d, irq); + + 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..a9bf909a436e 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 +bool 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..66067747dc0f 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(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..372c8d3a20f9 100644 --- a/xen/arch/riscv/intc.c +++ b/xen/arch/riscv/intc.c @@ -7,7 +7,9 @@ #include #include #include +#include #include +#include =20 #include #include @@ -78,6 +80,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,12 +119,31 @@ 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 void domain_vintc_deinit(struct domain *d) { const enum intc_variant variant =3D intc_hw_ops->info->hw_variant; + unsigned int virq; + + if ( !d->arch.vintc ) + return; + + 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); =20 switch ( variant ) { @@ -118,3 +155,11 @@ void domain_vintc_deinit(struct domain *d) break; } } + +bool vintc_reserve_virq(const struct domain *d, unsigned int virq) +{ + if ( virq >=3D d->arch.vintc->nr_virqs ) + return false; + + return !test_and_set_bit(virq, d->arch.vintc->used_irqs); +} diff --git a/xen/arch/riscv/irq.c b/xen/arch/riscv/irq.c index b5066fc3e981..9a8cd013e857 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -12,11 +12,26 @@ #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 by release_irq() (see free_on_release below). + */ + struct irqaction action; +}; + static irq_desc_t irq_desc[NR_IRQS]; =20 struct irq_desc *irq_to_desc(unsigned int irq) @@ -198,6 +213,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 +250,206 @@ 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 !=3D NULL); + + return desc->action->dev_id; +} + +void release_irq(unsigned int irq, const void *dev_id) +{ + struct irq_desc *desc; + unsigned long flags; + struct irqaction *action, **action_ptr; + + desc =3D irq_to_desc(irq); + + spin_lock_irqsave(&desc->lock, flags); + + action_ptr =3D &desc->action; +#ifdef CONFIG_IRQ_HAS_MULTIPLE_ACTION + for ( ;; ) + { + action =3D *action_ptr; + if ( !action ) + { + printk(XENLOG_WARNING "Trying to free already-free IRQ %u\n", = irq); + spin_unlock_irqrestore(&desc->lock, flags); + return; + } + + if ( action->dev_id =3D=3D dev_id ) + break; + + action_ptr =3D &action->next; + } + + /* Found it - remove it from the action list */ + *action_ptr =3D action->next; +#else + action =3D *action_ptr; + *action_ptr =3D NULL; +#endif + + /* If this was the last action, shut down the IRQ */ + if ( !desc->action ) + { + desc->handler->shutdown(desc); + __clear_bit(_IRQ_GUEST, &desc->status); + } + + spin_unlock_irqrestore(&desc->lock, flags); + + /* + * Wait to make sure it's not being used on another CPU. + * + * The read barrier pairs with the spin_unlock() in do_IRQ(): once we + * observe _IRQ_INPROGRESS cleared, we are guaranteed to also see the + * writes do_IRQ() made to desc (e.g. desc->action) before releasing t= he + * lock, so it is safe to free the action below. + */ + do { smp_rmb(); } while ( test_bit(_IRQ_INPROGRESS, &desc->status) ); + + if ( action->free_on_release ) + xvfree(action); +} + +int release_guest_irq(struct domain *d, unsigned int virq) +{ + struct irq_desc *desc =3D irq_to_desc(virq); + 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; + + /* + * Live IRQ unrouting from a running domain is not supported: the tear= -down + * drops desc->lock across release_irq()/xvfree() and relies on no + * concurrent route_irq_to_guest() being issued for this domain. Only = permit + * it for a dying domain, where assignment is frozen and no new routes= can + * appear. + */ + if ( !d->is_dying ) + { + ret =3D -EBUSY; + goto unlock_err; + } + + /* + * Clear _IRQ_GUEST while still holding the lock so that a concurrent + * release_guest_irq() for the same IRQ observes it and bails out, rat= her + * than capturing the same 'info' and double-freeing it below. + */ + __clear_bit(_IRQ_GUEST, &desc->status); + + spin_unlock_irqrestore(&desc->lock, flags); + + release_irq(desc->irq, info); + 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; + unsigned long flags; + int retval =3D 0; + + if ( d->is_dying ) + return -EINVAL; + + desc =3D irq_to_desc(irq); + + 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); + + spin_unlock_irqrestore(&desc->lock, flags); + + if ( retval ) + { + release_irq(desc->irq, info); + goto free_info; + } + + 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 72bb2c4dc3c5..8af748b1f1ed 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -123,6 +123,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 Aug 13 09:15:26 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=1785858537; cv=none; d=zohomail.com; s=zohoarc; b=iRy03QfJ/y819Ln10Tdvi7QH8UehwC+MtWbQ79XyOmNhS+YrqY0CHdo1ozIV61ZuWjagmfCH1FockU79OEB8m9euKz3SBl46ZCHYR+kT5Us7QMXObFJsHONI93t+Uppw/19i8lucP1+Nnsp2os1rp0/fpLrhLknwe2Svw3HZN/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858537; 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=fJC5+YtFPL568P1Nwi/6zQXEX1Gc8Q+IUKJN5b49m2w=; b=RKYCZw9A/1qijhhxhflWprYHffgndw7qD6HBW023+9UquvHnxuN97brsRZVAD8IGqNcm5jKgky/BaJr3h6Pe2y3bM2Ec2exhYwvSx5bhyEKfHICsflLAjlvpNhxUrvL0+gM0c8+xHDuZAsYTIAXFlNEVpp91eeFcC+TI4N+m6yA= 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 1785858537855986.2514398205062; Tue, 4 Aug 2026 08:48:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382284.1625744 (Exim 4.92) (envelope-from ) id 1wrHNk-0002Oo-Kn; Tue, 04 Aug 2026 15:48:44 +0000 Received: by outflank-mailman (output) from mailman id 1382284.1625744; Tue, 04 Aug 2026 15:48:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNj-0002KO-IX; Tue, 04 Aug 2026 15:48:43 +0000 Received: by outflank-mailman (input) for mailman id 1382284; Tue, 04 Aug 2026 15:48:40 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNf-0001mH-Lq for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNf-009GkK-0p for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:39 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209ce-e002-0a2a0a5209dd-0a2a45039d84-26 for ; Tue, 04 Aug 2026 17:48:39 +0200 Received: from [209.85.128.46] (helo=mail-wm1-f46.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d6-fae8-0a2a45030019-d155802ead15-3 for ; Tue, 04 Aug 2026 17:48:38 +0200 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49558ce01afso26775235e9.1 for ; Tue, 04 Aug 2026 08:48:38 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:38 -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=1785858518; x=1786463318; 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=fJC5+YtFPL568P1Nwi/6zQXEX1Gc8Q+IUKJN5b49m2w=; b=sBzQ2F05A/eqIYdR9SxI/+qK+dW8EEqOZo0y/tYH37zqMKyijk8OoTC/gP4cuHigVs AGnVRuoDszt4mAtKovMyIJyCkM1XIyRusfdicgsyUjWUtdlsv1mnzWqvDbAKDeg6+b56 1a78yp0JkjC+jsavsnbhg4jDUMGBztPYmgCrHOIfZoU1F09CiCyjphO1ti0YqKOk3YRG rC6EOcCIsrPk9bvCLRkQV5xaU2yuerBM07oLE3xCUoHCSqY9fmSDLz6F3btw7fw9LIgf 4vgRvGg35QbbOIjie18hE2n4FTm5XYd03ZleacweTAmrO5a/6rCF6OSK2+Rf72Wb4vHs QBOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858518; x=1786463318; 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=fJC5+YtFPL568P1Nwi/6zQXEX1Gc8Q+IUKJN5b49m2w=; b=FS+8oYyR740BMdHP0/OjR2G/Eo74ORp81tk7GXSy17t2Bpze6biN/C3ZtiHuYmayjm nuF+R7+8tGihju0vNo6fR9tnFfpR5LJxsPS5kjCFJmwLpaXyOlPOzRJxViBDGkq288JG mocWdJWo0EiBnM6+ktyzyCrwOCLQwMAuUa7nCnY2FKBx5wEhNF+NXP8rLHswl+QHwzjp W1uLvB+tYYVbrRHdxDVrIa0B3zmNNfdgz8r8u7moTZTsvd+/9exZvLCGbq+gW/7a5PVn HSeUPxe/OZ1AySlMmbIelCQgE2Jf1XBitYPOsNvW2LBfj9cQekXrUTi6GC9JbqiMq+9l ZBmA== X-Gm-Message-State: AOJu0YyzSiioIoaG5BD6t9obbgPGcI8xis9s47ebgjUgQYYEDlOJ8fuw 0rtubE+Zu5OSTz20ZCx/aVSwdM1/Z3ZhSyTlR4OGtNChjhxmPc40nEtevjpK+A== X-Gm-Gg: AR+sD10AcgyMz4Mgbn0ERB/cQmXyDETfG83fU07f2PXl4wUuuRPKZia4EGxp2mxTFDC j03D7gjixuwPiO66ew7B+gfPXZHdX2KJnOudun8XoBerjQZNmwkaGiyeaDMPsc3wyDwQgQ3QdLj 4Vhns6D8R8dvzVkKgerSiIfJHsxLSpRcJbEf1jRe522HCiwiT4uUo84GGPAYHyTzoFSt1B+MTid FPsx10271CLquPc0LLABPvLMeQ7QaKZUmPmbzPPf/M/aqHINYPaeQeazK8e2ZVSUenzNhsALMFs Uel1oazAQnJZb2WNQY2xZIMPhaXOSjQ1crTJrVsC+chNjUNehz876c2teUPguA/ZAeNNZMYe97l epERil6SXongVd8NnwH6Lo4W1/FJZcnwFzDneavyYfycKUiwhkgogoOGJwe8BVPPiT4zZSX9uzd CN5l9oTKbSnROrHtU7FRC/4IwPOs+cmhQFDiKkOYWJW2s42/W5Zw5oTbPAWlUTiFfjlvhLOSRAg PwSb3W0t5AHB8r5bri1BowhKiNrpWflFg== X-Received: by 2002:a05:600c:a45:b0:492:45a0:dcef with SMTP id 5b1f17b1804b1-4980c66d8a5mr305184025e9.5.1785858518366; Tue, 04 Aug 2026 08:48:38 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 17/20] xen/riscv: implement init_intc_phandle() Date: Tue, 4 Aug 2026 17:48:07 +0200 Message-ID: <2cfa77799f1605bbe4f7dc70662e356e52d4581e.1785836421.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/1785858518-74A894E9-26B688DB/10/73395122804 X-purgate-type: spam X-purgate-size: 1378 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858538128158500 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-7: - 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 Aug 13 09:15:26 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=1785858552; cv=none; d=zohomail.com; s=zohoarc; b=ZM5L4cM0qmh7eXJ3LMOwt9UnYVnCwUF4Pwnbgo/hEyWQU/zZcsM/yJzJgtRNJhU8Nw+rFNCP2RLtt9rVP8u5Y7XeSX+5xtMG+ejPS9aBukalE+MAdH0n/1xD1dx7+rEQzvCvNjVDegBzAfzuF2K4MwIyWGOIVGcuGlkbrXM/JNA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858552; 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=DmOaTFmnk9rQJklV5xKX1lfHsimIvxxfep8LTck6j7s=; b=QRsopIPRMA/8IwT/ZKQ0iPIoaoXjNQD+UE6igspJT/ydMQiTAw0UWboUS0QtjQDqnn0FAIowRnC5AuF8BnRj9lmxvVm3OptGFUgUpCrdT/V3Pw8GlCVNeC0kQ+/QQz7pYKYj7NLMjBhiJQOb/k+gf0FUdiwA8TBQ3Ym1ULquRNg= 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 1785858552931216.25580295283453; Tue, 4 Aug 2026 08:49:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382288.1625749 (Exim 4.92) (envelope-from ) id 1wrHNn-0002wp-2j; Tue, 04 Aug 2026 15:48:47 +0000 Received: by outflank-mailman (output) from mailman id 1382288.1625749; Tue, 04 Aug 2026 15:48:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNl-0002qo-U1; Tue, 04 Aug 2026 15:48:45 +0000 Received: by outflank-mailman (input) for mailman id 1382288; Tue, 04 Aug 2026 15:48:41 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNg-0001vc-PV for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNg-009Gjx-4P for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:40 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209d3-bab6-0a2a0a5309dd-0a2a4505c19c-10 for ; Tue, 04 Aug 2026 17:48:40 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d7-4cb1-0a2a45050019-d1558034e023-3 for ; Tue, 04 Aug 2026 17:48:40 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4956242332dso28508505e9.2 for ; Tue, 04 Aug 2026 08:48:40 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:39 -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=1785858519; x=1786463319; 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=DmOaTFmnk9rQJklV5xKX1lfHsimIvxxfep8LTck6j7s=; b=Vcc0xrNL6uChNjtytBWRdaeF46dVLqNQD2/9aFisMeGX4xjugFGPUyRwSdjUw9MCfp OsmAwT/NoRQpr6mLrrC8ttiVc2VP+YfMt1ch5SQAidObAYJTnWAry8E60z4lezzNlDcf bX2iO3ym1gAaq4CfY2din4h0BYmpoiYqek8l6+ve+W42d4JPLDyMBbzQd89DW2It4Lj4 EMWogMkg+XYDuvzjo7GE6UPeIG0Lgw5UgwUENmYfwitPayjviULd/EoF+CVUDA8aHVFx XgUyozznGj3um45vf8V/sm6Tyt7R5KQYy/UXxlLEpkrcejIHYzAs++wuQFSEfPC5CXeA Gtfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858519; x=1786463319; 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=DmOaTFmnk9rQJklV5xKX1lfHsimIvxxfep8LTck6j7s=; b=p7bBwazFwzO2N/gMz26ymT7LyC6kRzojuYXrb/eFKsH5ResTkoeMvu993QGwMRHx1V zSXvBilq9kZa8g7rmZ204Wk7ahIxgdbyhhyURD2d09sEIOpLo9RXas2rl0lNFDwkWe0B 4zUW+WGNpm3UWenvO6/u9gC3LECCSFiJRusJpyZHmyz8MGFBIN3qfbiw/c8I/Z38ABv3 brO2itWZbmT14gr5Ob1ZNr127DQnJOsQI0UFUIFBXYbSzbtQxw0kco9IwVz79eOEQRAo ueYhYlp0dZ6SyUP28j/g7+mvrY/wSjc386Xn1wVl97UenZ6eQ0V0sb/sIeGvG09cfHb4 1a4Q== X-Gm-Message-State: AOJu0YxNnU4Rdrao2bXen8vI6mFINvuzfwMrmRESUpb22Yqh11MpKsim JwAdn59z8gzdKkP68P9TT5qdv6sRsxG++L7mynU+34GB5p8rvvbAVKMh+6rU8A== X-Gm-Gg: AR+sD107eatE7hEq20e4N3z4ARq9ha12qSeQrnLRub51/G1/FnkIjX6OhqcPbIbRM2K cN6mUoQGjcownymnTvIHXFtqhvTvKTgqOdl6F668719V3wcFz/Jl113bnf4i3DZ3zFrFd6uY/7p 87stRIsgUX2g/rKa3lD+KR6bGm50u3kKHdZzDNFbiMStD+Irjt/2pUv7/Gcz4JHhvSxCICzN2bB Ron6SdytYdn0fcXxG0rJyv4gN7SCHC5jcVlRAzB5mHESkVCV3F0TFx5+RDJwRu78+F1Bjs/q5Sb fLV+FJDs5TCi3r47yz92EZcomLwDZzPnXPV6yWb7iYKtchcrbRmUmnKJZ8KAtxBcgiY8sJ08MnS 9cac9jXtrIQD3Ipu2zlO1nFvCu/pn+4HEGIV0qXvIAi+PLGVrzziTqFkUqBHeLw7aTVBuqne5ra zTb8w9b1CyuUYeXGuX+paFImAAYO5A/CkxJ/7AFDVwSdwcsgwlMJfQlDyovHJ4W5c9jBBxpaovr 0qpIzoHrTKI+uN5t2EheUQmK24fZ1AVyUGDWcVUiHPe X-Received: by 2002:a05:600c:3151:b0:496:c378:6420 with SMTP id 5b1f17b1804b1-4980c66c843mr278491605e9.8.1785858519419; Tue, 04 Aug 2026 08:48:39 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 18/20] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Tue, 4 Aug 2026 17:48:08 +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-c201ff/1785858520-732B32A1-8BF7E448/10/73395122804 X-purgate-type: spam X-purgate-size: 1560 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858554226158500 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-7: - 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 Aug 13 09:15:26 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=1785858547; cv=none; d=zohomail.com; s=zohoarc; b=G2LvvxhO7/tkilwCXfPGjgqsbfPFRjjidKH2jrklE7xa5pkt5Jo95S22FO/JREGnK6LpdB4jg8EbzNwB+tPwUYPpt7o+/ptMeQwbsob7bED3RmLsjpk+4w3H7n5S0qvaMHwFpDa9Wn+1o/o5ealyBDvRVeS77HzUUj1KT0kHkHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858547; 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=GAWkDWNVTDEeajRUovPN0Ndt/ZkdBsFcfwqhXKheFEA=; b=Oqho7gSPLE3TuD713Kd1PGSn0aqZa72JWOJu2ByyoZhhaOnPv6Ztz7/k/dJqtrn2r++6Eb+dbsnhQeMpNZSiCk2mnuZYCo/e3HSj1770mxtXJQ7cP6hpTS7vUFshUu6tK0E8SsRY+rQRme1y3Mh07eFBFsjL0Z6kNgYL69EAIao= 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 1785858547629445.11892190353126; Tue, 4 Aug 2026 08:49:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382290.1625757 (Exim 4.92) (envelope-from ) id 1wrHNo-0003FX-Py; Tue, 04 Aug 2026 15:48:48 +0000 Received: by outflank-mailman (output) from mailman id 1382290.1625757; Tue, 04 Aug 2026 15:48: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 1wrHNn-0003BB-DT; Tue, 04 Aug 2026 15:48:47 +0000 Received: by outflank-mailman (input) for mailman id 1382290; Tue, 04 Aug 2026 15:48:42 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNh-00025v-UD for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:41 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNh-009QPZ-Ag for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:41 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209d6-2eae-0a2a0a5409dd-0a2a4504c160-8 for ; Tue, 04 Aug 2026 17:48:41 +0200 Received: from [209.85.221.44] (helo=mail-wr1-f44.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209d9-b57f-0a2a45040019-d155dd2ce4e9-3 for ; Tue, 04 Aug 2026 17:48:41 +0200 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-47f703a9d05so2912747f8f.0 for ; Tue, 04 Aug 2026 08:48:41 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:40 -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=1785858521; x=1786463321; 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=GAWkDWNVTDEeajRUovPN0Ndt/ZkdBsFcfwqhXKheFEA=; b=BEMNLqjCMBlrrpVC5UiKeqk/4aIGkgCQb/6Xrt/fQ19RHuIQAiohM1nV06FouG1b3u t3f43xQPmyICYVF9B1MAfLngQYpKYyPhrqfWPVNOBWv+nrq9oITE0XVad1qMp169z9B1 eC62Nss6jT6AYgjwl8w96qsnb7P0t9KT2qr+jPmiUmWubexoFPQWe/yJxgfMErFoilGD G2Adz9jU30Kxsd7mV+Dbv6Vhome4ZdsU3XNtAkZGyDt/l7VCo7upCHknT6J1sfbSZvmL 8u650YLPq369RFm7BXCO42oLl6G3h+3MadgJVZvdP1Tj83xQ8/N/Kf4Rf8W+xdTixwWC G4HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858521; x=1786463321; 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=GAWkDWNVTDEeajRUovPN0Ndt/ZkdBsFcfwqhXKheFEA=; b=QZ1WqELJczrgF6FpDa3S77hFvXnIfAxeADZ/WwcMPkAKtyMMKrBY6sEJDyvuzFAl4u MQUx7ai94/FLvHvmsc+QDtaRJpGIyW58VoH+4PilVDdcOUpW5bBCHjLB9nE9wIsaMGmQ DOmlyNfrkg/lLAq3tXZZLikUnaDZVFub391s7g6vDvTYoyBlkODyv7/aM/uduVJ+gywS yIqFIZGruXiUe5dEQUNncFJe5VLylNVeXemAjVIZXSoNAcbo5l8bbfaXvpz/HT8Aw/ul Ywfyl3kHFY6udHtWeRjFK7P4kIbNZQcTFFy62kRFHywvqZxocjxE5XodIZplwVQNTFRV 2CPA== X-Gm-Message-State: AOJu0YxluezbycgJKtFLoVTHwXwSzJuJ5i6kfdNZDD3fX3eG7bgxXDbu Dl3EaCPR2qK/R5x1uGIMkOzpOdbVP3Ckq1B5A2y/N0eGHtC7vgjUvi9z3EoZNQ== X-Gm-Gg: AR+sD111E5mS8nTTEZp0QJGzy8czL4GJs78+0TuUO3tA8HU4HoOcos0SmPJ0v9gJLwr x+HLdTP4v+4hmuQuQqZ4M6brb3dKrTPtcHbmI2LbGfCNDKrAHJ0/4EIVPeQud3hClcjD3tihuta AFBg202K62NKhRq1j94GYhQG5Qx5nVwN60nA5TXvX3qGmCCv+2vioMYxRdeahQ9Jm9Jj7GW7YIX eQ2XBaaLU1bMIx/X9xV0QGQSQ8+CfBuRGTiyTi+BByY9f4iWVLBhoQRQQlOwL3R5Vron6TanL4r sqK8yZxbJ5j+ED1pmVXgcJNluwcUzmVHl5eCehPJr37uhFS7ev31OdyGCUR8Q+D6MCCX6yPpEtN VPQAd695A3fwtH0v4CnfzLGhqvW5frES7XK2wzVicxdPm6ac3++T1bm6XGOuEUGIMu1OnKIN3NK 24KQGo1+BC3jbiyNixLGgE9kiH3IxnEMFM1HClJs2HSlmn0fZK7QO+GIX+BlcmESPLTz3W7O0wI Zq3jHUxJ51hLrRtruGVWkSRMxLIzZQc+A== X-Received: by 2002:a05:600c:c8c:b0:493:f318:3bc6 with SMTP id 5b1f17b1804b1-4980c6564d5mr316112725e9.13.1785858520601; Tue, 04 Aug 2026 08:48:40 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 19/20] xen/riscv: provide init_vuart() Date: Tue, 4 Aug 2026 17:48:09 +0200 Message-ID: <41598060f3f96d27da1c90299592bb908edd8910.1785836421.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/1785858521-C0CDFB50-679FDBBD/10/73395122804 X-purgate-type: spam X-purgate-size: 1391 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858548199158500 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-v7: - 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 Aug 13 09:15:26 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=1785858552; cv=none; d=zohomail.com; s=zohoarc; b=P5R97pZE/h79PpEeI2RkskursX1STWj5q9CPerSB1Ad/7jaysqcasmdJu1L5qMaBPYLLCIl9iFgB5GTMMhxDQn7WLZTOGTK4C6BUPfLzvD9GKt/yDOvmHCQQxRYlkeFuYaOAbpOLx6Asss/lQfncqj5jwS2pPl2Ht6PasgiZDG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785858552; 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=mU8gqNd7fh25EXrT+sx22hsxtXPyXu1gA9iMQ0AEA40=; b=SgVaj5IRz6eaVn3DnIOxzyFG5IFBdqZqn8qxseu2fEtpR6QRE/CEQmH/Pf5Kz9g/BHB4Fy9ckIQWnAS9n0ovmUwxSeY5W9cvHamexImaCnnyyN1RUWsvoT1pUKQEkDiNwBxynk+JjWDsvv0iUoaiqUWMP4RJmMwXphiAdJyJmYc= 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 1785858552864575.1268034840567; Tue, 4 Aug 2026 08:49:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1382294.1625766 (Exim 4.92) (envelope-from ) id 1wrHNq-0003gc-RC; Tue, 04 Aug 2026 15:48:50 +0000 Received: by outflank-mailman (output) from mailman id 1382294.1625766; Tue, 04 Aug 2026 15:48:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wrHNp-0003YL-AF; Tue, 04 Aug 2026 15:48:49 +0000 Received: by outflank-mailman (input) for mailman id 1382294; Tue, 04 Aug 2026 15:48:44 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wrHNj-0002FV-1s for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 15:48:43 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wrHNi-00Fkwn-EG for xen-devel@lists.xenproject.org; Tue, 04 Aug 2026 17:48:42 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a7209c2-5cb7-0a2a0a5109dd-0a2a4502e47a-46 for ; Tue, 04 Aug 2026 17:48:42 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a7209da-6ca4-0a2a45020019-d1558029dc3a-3 for ; Tue, 04 Aug 2026 17:48:42 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4954afac04bso39788275e9.0 for ; Tue, 04 Aug 2026 08:48:42 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49949fcb46esm116430355e9.5.2026.08.04.08.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 08:48:41 -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=1785858522; x=1786463322; 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=mU8gqNd7fh25EXrT+sx22hsxtXPyXu1gA9iMQ0AEA40=; b=U9uM+0BWUx54E3p3oARTBXFN52DxEUN/nQ3zIv9Qi/sGG4yu3YGGOjsn8ZnKLSBkHq 0VUtK3r+Bcdf907qUynx/eudQTHTciMwsw+WRiyRFGiZd5ZDY4M5finLD0A3XCIA6wpI Tb9kDZUNAgDS9tkYA+xYdUhVmhgflBf03gsfAlSyZnRfSndisXD2Z5f2s9/kiR2hD91V rylPyx4ygn6qBh4X9WMLpv7Tlb1o5o++rrxxqdgfgJ18YYgFYX54aeGl4vsTZNjt3KsL Q4IYpWLN2T29kSXlgb1eh3xgkB/pxGXolR6ZbfW6C+9ZyaVHsc5lttdCYoVl6ky2ZSyb zBMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785858522; x=1786463322; 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=mU8gqNd7fh25EXrT+sx22hsxtXPyXu1gA9iMQ0AEA40=; b=d1zKLDxJ27a2ttg2RLNlZWUbFztuqfXXllnrcL8i8pahY0rX1e00sQIUTOq6H1lOwf Bh27/M7jcJOz231Cjve+2hX1GNeOMj5kg0QcTN/SrHRea/sSibYMgdofUzS+8Yf1vP/8 /l7oowdQ+aMSKSmnkjUaUZRxZlK/jKjkfwL1SbyBjI8B9ez5jLQEyV9SE/KbnF0gxQtP aW5qBRhPQ2O5qdrRkIl+UoXxKxE1GSVoT27QtmiQQx0b77my+tcyVbPjuX9bIoQMfS2f XQM0jlYnmT7FdhToRj9JqBMnliI6W0msxHjqcTEsdaVinaYoJPoNE2Zt7MhkuTJtAMtZ hwKg== X-Gm-Message-State: AOJu0YwnfU13j8gmnXRv5JQuoq1Cf5jQVZWeOy7M5FnrBfEog2PZ+8ow tzFVmVYUM7dt2wc5rFobXcfnTP2nfGJW243wgOQbyV3Lu/Sn7a+2lTW2Ue+3qw== X-Gm-Gg: AR+sD12JB0smAKeeqOTkDdWc3lSIKDHXoRiyH8Q96NM5B1ufarKfNnKD4GJBQt2fSN/ /4Dfvwmk/L9vyiC//z2kTKWoZQ7pydgu9DYeNa357MgCZksKaf8UCVb9dA+s031iXaydfuLMi21 cNmlleQLFuTI/rxkbJir+6aM8iJxlW3KaGRLlO0u0Ma9mIX6wuAGJ7VEYBNjcy9PZg9OzkSFXuu fjn1KZ0I+UXLkVTT54G4fOP/TqTrgc6fN+XpRPmZx8TwJc+WNeq8IazzQbrLEaF4HqBIBCj0C77 nEa+E1rv+66P4RlAvwI6TUMM/Je4cQM4287YGPavEJEyY6UYgt2Vv06Grk40iP7D3R8Tyn+sb83 iRF/9mWbvtud4k7QwN4/sjJweicZSL5y0kyO9NyrUYZIYeyLnlXmummovAuGOXsk9IcMudumEcV STDWajmmKrbO2DYzzJpyjI4XleeXNwtadqeMp0cQk0HuCpU22cX43yFpdz+wwHzA2dNqLPdpZ2M lCasJpZLihoBPj+Gurr+5Dtjs9H4IhpBuL8V/0c617x/RDxrfHhNdKd X-Received: by 2002:a05:600c:6990:b0:495:4d00:2fc0 with SMTP id 5b1f17b1804b1-4980c673907mr369152375e9.12.1785858521751; Tue, 04 Aug 2026 08:48:41 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , 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 v7 20/20] xen/riscv: add initial dom0less infrastructure support Date: Tue, 4 Aug 2026 17:48:10 +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-720697/1785858522-F28B42AC-6F1C9BE7/10/73395122804 X-purgate-type: spam X-purgate-size: 7342 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785858554312158500 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 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