From nobody Thu Jul 23 21:11:29 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=1784563248; cv=none; d=zohomail.com; s=zohoarc; b=AJNOqK/wrH8h6W51dxyp8lq/MRfVP6mqdE782aZyMm0Fb1NWh9gBTxBTh6HvNFhGjHEc0DN1ig27AfYyCw114FuzRW3Wn6uM1JHHIVGnXeeMhMi7Zqgz4JBcSH/MxjI+tutYCZIG4QExZLr/Ch9hWhtnVtktoulXYQAc+tD522M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563248; 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=u0tVfRurSQlJB30p9PK7u+3dBQjjBEmfhYIggxhj1ck=; b=kBWB45Vd12hQjjn+dupbzTwM9q7De+dBMIDmZ2gtJIG3AV8iD1SwR6/kUJctycOHiGjsGshdluTf6sgmi0EkQP7uJBKBFZ3QiTJYCOEAyIoI2XU/NdQOo9E3cb0hC7hkGVkRNw6JVuNm2qfHtRoXXM/D/gFgpuuc0MwDN6JEn8I= 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 1784563248667388.8702845675591; Mon, 20 Jul 2026 09:00:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366947.1616737 (Exim 4.92) (envelope-from ) id 1wlqPj-0004E7-Rj; Mon, 20 Jul 2026 16:00:19 +0000 Received: by outflank-mailman (output) from mailman id 1366947.1616737; Mon, 20 Jul 2026 16:00:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqPj-0004E0-Of; Mon, 20 Jul 2026 16:00:19 +0000 Received: by outflank-mailman (input) for mailman id 1366947; Mon, 20 Jul 2026 16:00:18 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPi-00041M-2Q for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:18 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPh-00GLIp-8E for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:17 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460c-5cb7-0a2a0a5109dd-0a2a450887e0-20 for ; Mon, 20 Jul 2026 18:00:17 +0200 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4611-f659-0a2a45080019-d155dd33dd9b-3 for ; Mon, 20 Jul 2026 18:00:17 +0200 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47f7854678cso512791f8f.1 for ; Mon, 20 Jul 2026 09:00:17 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:16 -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=1784563217; x=1785168017; 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=u0tVfRurSQlJB30p9PK7u+3dBQjjBEmfhYIggxhj1ck=; b=Wag4V7CTo/QnxU54XXoEPpWt+ts5zQ5zTQiLCs60UH1jKJIEmfPjSaHDwFP7mCiA0R jmP1E12XyOe545bNX7jyFkj6Pp9mHQgdISFSTHNVpVQKRwGJ6kcgvucJh48TOkCRTViX yZYECJQ5wh2dA812nqRt/s/VJkMzAsM7M9CAjmz8CS+GftDkKs+UIPFc0paMdgJppth4 W9hllHNQUVjVIUtGzwZF7DeZfVs58ajI8seGuP4RDdsR0XuoEtbj3V+0x3CfBNyjR+Jm ZryLn2d6W6k/rTffvibYYD5wHzC9Zgg0MnV305+oiUVppcHV6+/6xY/tm2NU2mI7nT0y 5Zsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563217; x=1785168017; 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=u0tVfRurSQlJB30p9PK7u+3dBQjjBEmfhYIggxhj1ck=; b=nuJZmetznlN4FDTKABjLoFlLbBS06gnddtwinTRIJ2voMzut2o9WGjrzurlhU7PXd0 b0mQlGK+D3JhNQTnHe/yFyhhcXRK4wQts1213Uc/sTYWVp5UUDwjFOD2JjXEVVvzjv4a +VztzxxLnZmRh+EpUumD9gs51DjiX6e53MIDyHZSXzOln6RpxzxNxmVOxEFYND/2X2pm WAfyCRYvqhbtsKxSJiZSUT7BKcMP/dYjZoF5QV8wgFGpTXA61+SmT1Cy9y1Vzg3vPi39 TYmhXJCJIK2bPXKEG6MLcsXsZP3Se3MCTAt6bWBEUsKnZQhis8ywW9+nx3CFo38JqFvc lczw== X-Gm-Message-State: AOJu0Yx2bJ0Z3QGtgffYAE0s9dkmwP/Jh4NB1KhJLQ8+jDxNROVV9I4+ SAChLXQP53BY2z8rnAkX9kerzBqSCZM5gwwiLpcB6kwU7/S/ALRwhfopZ+NGdg== X-Gm-Gg: AR+sD10FIt7FUkqkPHeqffB+30JfGGksOha5ZMdcKXTLvAE8JgDwoS4vN3HdVbXwheN Z9FvF+uGa6zgXzRA+OdtmmZCgfSty/9FtRFfF2EWhhD9x1NOaNhpqe/Crr1lOZ7gMfQbrVjuJDE RQSuFxHXUhthQyhMviGbetN+edzawrLyLikk1YAFrVXYlFmcor08riRpIG7hlFaqMjo/gDw74pF KEijXZ3S77z2oVfYDm/bAza3z9X63cLB3hs90EqAqxUMhkVUmaOJhgK9+KbI8iE4Mh+Bg/0557o vQqZBp4UetupoKPF9WoYT5GLWJ/TGN3tnj/Drz6MoBhKdEyv9bZ34JV+nrNEkO8UCVBjOTiO+Zp Js87HwnIi3XPNyZk6t/PvzLzYtie5QalkSrSUG2JUK3qx8ogPdXJcmIvhUyhAgB1PvuoiPB/eFR Wo/tvwiP8zUFldQLov2GBafI/QR8EvGZ3dQ+HPr59t5IZh4+E= X-Received: by 2002:a05:6000:18af:b0:47f:539f:9f82 with SMTP id ffacd0b85a97d-47f6232240dmr17669275f8f.39.1784563216343; Mon, 20 Jul 2026 09:00:16 -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 v6 01/23] xen: introduce CONFIG_HAS_SHARED_INFO for archs without a shared page Date: Mon, 20 Jul 2026 17:59:42 +0200 Message-ID: <01df5be27b502a19dd51ded7577af68cee234c58.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1784563217-CFED287B-D0C5046F/10/73395122804 X-purgate-type: spam X-purgate-size: 17604 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563249771158500 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. Signed-off-by: Oleksii Kurochko --- 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 | 11 +++++--- 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/shared.h | 8 +++++- xen/include/xen/time.h | 4 +++ 12 files changed, 104 insertions(+), 12 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 2ce4747f6ea7..49697b795259 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 53ac1d6c4034..af5b596f3893 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 e30b38a337ac..0085b1777b40 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -102,9 +102,14 @@ void getdomaininfo(struct domain *d, struct xen_domctl= _getdomaininfo *info) #ifdef CONFIG_MEM_PAGING info->paged_pages =3D atomic_read(&d->paged_pages); #endif - 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)); + if ( IS_ENABLED(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 gfn_x(INVALID_GFN); =20 info->cpupool =3D cpupool_get_id(d); =20 diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index a3d18bc464e8..52dec4bb8931 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 @@ -1323,9 +1358,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); @@ -1624,7 +1665,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 37cba9bc4564..b0acbc68d9ff 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 @@ -420,6 +423,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; @@ -562,7 +578,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/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.54.0 From nobody Thu Jul 23 21:11:29 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=1784563245; cv=none; d=zohomail.com; s=zohoarc; b=W3x8J40HXWJXoVe23keVYHkHzJB/4laICTG+LI89wQucdCPgWU/T01t5fQnAEWJjmcMqLIYKxKHw7+2vthT7f/3MCFuybjrwV+47ekmzxCA10wBNnH59aoEwARJ1gEvU7qGyofZVw04p5gtriyDExqOMYacY/X+pJCIydwlgaRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563245; 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=EKkncs/MVbSUd+vQGpfC/FsRQ3Kf/ToKIui4GZQixqs=; b=UyCgXjS14inCVVu+xr2+F7Ez6x856Xzs8VU5wZZpPExzLfBOdVH+s1bqtaWaLMBZ94c3PFPYD0l6yvPQRFOw11sSof5JgBrTXb2brPc8K++PoD7MzAKuapWERgSU7pn/Q+V59M1Wpj9TnvsXi7cg0F2AdbdvMlNKMN42E5uAvrs= 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 1784563245615497.9446169731692; Mon, 20 Jul 2026 09:00:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366948.1616747 (Exim 4.92) (envelope-from ) id 1wlqPl-0004RU-6s; Mon, 20 Jul 2026 16:00:21 +0000 Received: by outflank-mailman (output) from mailman id 1366948.1616747; Mon, 20 Jul 2026 16:00:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqPl-0004RJ-3R; Mon, 20 Jul 2026 16:00:21 +0000 Received: by outflank-mailman (input) for mailman id 1366948; Mon, 20 Jul 2026 16:00:19 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPj-0004Dz-Q0 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPj-001mbV-6s for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:19 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460b-2eae-0a2a0a5409dd-0a2a4506bcec-16 for ; Mon, 20 Jul 2026 18:00:19 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4612-195a-0a2a45060019-d1558034c9d6-3 for ; Mon, 20 Jul 2026 18:00:19 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493b966dd74so43738535e9.3 for ; Mon, 20 Jul 2026 09:00:19 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:17 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784563218; x=1785168018; 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=EKkncs/MVbSUd+vQGpfC/FsRQ3Kf/ToKIui4GZQixqs=; b=bqZ17V+bGIXKY7/QgylU6GScGT+lx4r2hAaL0vxNJ4ONrrRZFyvLI0PHmvO6u2YdsF Bj9xI4fQP7YrK0S4fd7UMrgm4X/MxVHyhoL+Z5mKbDzCy+AJbWjpCrX2nl5o9n7kLCH5 nSTrX09wgzBATrYu52OkbgspmCSc2nw3n69B76T2sKnaMxk5riHuFU3IU4CXfu/34J2R 63IkdI94YPRybF35HpMou4g5OawwZqckYKMeFTUpOnV0w5ul6Kv7ArEQeOiqhPJeQZTZ afAT3ddIEnFBBoDJBYn5SkXSuhyVZszQeiqUbqVmP/JLTyThNSuVnjHVLdEfNzto4XY4 lpyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563218; x=1785168018; 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=EKkncs/MVbSUd+vQGpfC/FsRQ3Kf/ToKIui4GZQixqs=; b=mMcRJQg6VkGwZednnWLoLeuCFLY3aJGWxvFP2cy7Td3sVTCCYvgwvOJy+DAPfMNJ+v bB31E11YtjLISrONv0pZxo19QfUFObXm9J5hq3lzlrOSHPJ2mNHKmBFuKTjwDpGYQuSG DYQPL2Y1eutbewuwFNAcN23eBGHI1kTAw0ID//WesxAeP1APO9jntQRcU4F+EwZCM0Bu 2dpnNYEAU2vQvfch01YpqZHzuyK+ELAkSIhX2/aIq2n0vLHTOd/4ftMGZYfFkr3oG9eO ZYA5R2psk2pOtVeUiyQJ/UgfW4cz2xA4YZLqZ4DvWCcGoX4xm8lXpjR6Q/zQb9TNalJ8 Fpdg== X-Gm-Message-State: AOJu0YzhWXRPE5ckCHf+TOyYR7askEb5TDatN4LHr6dIl4PV4pvBafv2 QJdCnKBtpCKE0TGgi08oqkbBXZLCuYSqKhAHlupAzZLsOdUWgEzlhbnImWuAyg== X-Gm-Gg: AfdE7cmc3+jGIDst6L/48WSlxamtt7uhC5cMxtQPT5aWJITYkzKk8Xy0KMfLCpTNelV MnRcJKysVEJQ3wJJbF8jXAu5NML1KcbANCc4H0dG3K4H3zGD4+lmY9fgL9hnWQC0xxYDLCfUIqO ETQJtc4VyACzfxKCPK2m72Jg23VCYDclBs5JE3Ins0qg7vItZW1/Nlbsh/KzTJ0NAli1H5Xdcb6 us9flHhqnBByfBUr3LNNGw/PZ09ZTj9yIpg8cJbydSL/quEOS3SpbBKQkr+W6JkYNWK2z4PUcXL bEW9tZ8L+ns2IjqmvpqAaL/uk0tpPa6OZiXkk9LbYdbYsBTl0TnwMHm0gauHv86Hepsr7tIH+Fh /YHtwl4qM0gCwj47hlUM/pw1nS2/nAcy/qbSrKVSzYNHluO208jw+H165BkolcvhqP67c68ViwM mhVrXfAXwGWFzwg9F+kXIVe3lOcAzooZzOXHs6BsW1ZivZYP4= X-Received: by 2002:a05:600c:3b8e:b0:495:4bf3:2150 with SMTP id 5b1f17b1804b1-4954bf3216amr178623735e9.8.1784563218062; Mon, 20 Jul 2026 09:00:18 -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 v6 02/23] xen/dom0less: turn max_init_domid into a common variable Date: Mon, 20 Jul 2026 17:59:43 +0200 Message-ID: <7dac805d42b3adb6df3cdd1c2be4f0e511f30439.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1784563219-F4C0777B-0E330D7F/10/73395122804 X-purgate-type: spam X-purgate-size: 5823 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563247690158500 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: - 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.54.0 From nobody Thu Jul 23 21:11:29 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=1784563243; cv=none; d=zohomail.com; s=zohoarc; b=dHjeffRaxTKrslctofqmcvBBIUm0zs0xHpC17GaCzpMW04mx4dkI9t66sx7eXfvqA6mQnk4J65KsoV4azWgkXf6kcK2Nhmi51Lvx1UjiBUF6S3JCnwOqWn8p4K/1TJ+aOlj8hDnvdp6q30d01QR1bI01EySE1B8lSiyM2b0TD84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563243; 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=Jpi1OQhQ+cckOTheI6EzqlufPMg8rElGByM+dRD5uB4=; b=mdDAyw0BqYstIeGybaq9nAzQIVfIPj+HOnD9dvzUQylvlvw80mp14GoHrvTKpwVcDfokNtM+62cF+0pT8wJtFTF8E6mZkcuk46a9Qizv9CmgE/xZm4zCRbNC2v4EmdAXUa4XBQL8jrndVNBZ1ZKci9xv8DwQpPaqWm31ePekAz4= 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 178456324372549.2060350509131; Mon, 20 Jul 2026 09:00:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366949.1616753 (Exim 4.92) (envelope-from ) id 1wlqPl-0004UK-Hi; Mon, 20 Jul 2026 16:00:21 +0000 Received: by outflank-mailman (output) from mailman id 1366949.1616753; Mon, 20 Jul 2026 16:00:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqPl-0004U1-Bw; Mon, 20 Jul 2026 16:00:21 +0000 Received: by outflank-mailman (input) for mailman id 1366949; Mon, 20 Jul 2026 16:00:20 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPk-0004Oc-QL for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:20 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPk-00CGfz-75 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:20 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460a-bab6-0a2a0a5309dd-0a2a4509cfca-20 for ; Mon, 20 Jul 2026 18:00:20 +0200 Received: from [209.85.221.43] (helo=mail-wr1-f43.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4614-be1a-0a2a45090019-d155dd2bd5d7-3 for ; Mon, 20 Jul 2026 18:00:20 +0200 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-47c6e9a694bso5724921f8f.1 for ; Mon, 20 Jul 2026 09:00:20 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:18 -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=1784563220; x=1785168020; 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=Jpi1OQhQ+cckOTheI6EzqlufPMg8rElGByM+dRD5uB4=; b=Aj9TeBKiwfyGD4b3qH0HXQMp5qM20UcckCbPaXxLAauS7aLWg7lgkXQYQXVZIQHTpT OcSX4kGerfdWNolKihRjMoMZIoKtHWhy0abVZWVWSM8MRoGlLvT8n+IA65V9EQb6pMtS 5EBFVt9/pSZVhle0tYI6v592RKLsfRDLzJsmvuwthtgrCOil4248qYSF0c0WCbPhe5lM EeJKuKio/P7Rreb9l8tbQi5ImZxB0FZSsHKqxuRfm3SgeQhvltQ6AADCBvsRhjtcY+m1 dr6FzipyNxvJykf3uxUQNZ3n1IDw0lwykBGtcEbpex9CsagC9pYIovnhvx/DkH29o2hG S1Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563220; x=1785168020; 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=Jpi1OQhQ+cckOTheI6EzqlufPMg8rElGByM+dRD5uB4=; b=qDhJf2JcDUtJaZjDDjNv73KLfXVrF6xfOeEpLSBi57W1NHPhZO+heDJrImwzXTMbf5 zX0VkxKP5Gqt7YUj1bvQl3D5KFb8LDY2nXV5bYXrgDTvR2KFeP4DGypp92Gfn9ipE43B gpCSvCSn1RDKtKsh+RYlv11tIhkct4tWXu/hX4lUz1AANYpwdSJSwvYByVerVzFV/EaN NFXEHkTF76qBRdjD/DEelJkYFJ4Uz3siu7xm1V4hAlM/xJGRE409eZkBhIKa5itm0+xF 8L0TYWLDr9om7bRoBJdq8Pph0kYdt1MJr91EUJmOru9pU/jPeLhZUeDe8XZREQVLrVDi TfqQ== X-Gm-Message-State: AOJu0YyWKj1zAzC6W1k6C8am1uhKSOK0WBMkCHoLaf8WH3aMnPZ/hqlA DJ7SwI1hHk6W62ajh/Da9w7wm+NY5mlSzg7if+KnvPtm7Q8FTR6BH/LYfzSm9w== X-Gm-Gg: AR+sD12iz72M5BzufQFtAEdVqgLOUxV7Oj5q08TdDskcRMyic+PFk4gF/WfYWiv5kAd X+wKqs9myzEKjMJn2PPYyK7NDAT6DHA9lkz1SzIPUaMSyIw0IJYPhrFl8qVO7+PY7EU3MWxd1Hs UiKEGBFZ02t92Bzx3CCMc5cMAOfVOy5Gib/U6Dj4r4KijNCPLdRYA81P1uYTXMJ2z3r2JMBZFHQ /A61D0qR408t7pDrGQFM0q/mkORyCoqV7ih7OMfd7EtCJAh1pZpaqvXZ4DWRoCpNi58Sjew/UlS P7EbJM1sKDG80GnixJPyp+xftl5cfPRWdrFwZsFRTie8QdAEXH0xEL6bSF30cJE7FemsYKcqxEB +M1Inc17XloNBK/E9s8GOCrPj6V3k0rgt6fwxl7NAAQuMeNergkCiRaxk7Z7aRNtLzivD9KC9yb Dnd6YkTkirgH++pHCzfvDJ4ZMJXhZaDdFn X-Received: by 2002:a05:6000:607:b0:47f:5367:73a3 with SMTP id ffacd0b85a97d-47f62305a1cmr17834461f8f.13.1784563219337; Mon, 20 Jul 2026 09:00:19 -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?= , Alistair Francis , Connor Davis Subject: [PATCH v6 03/23] xen: arm: update p2m_set_allocation() prototype Date: Mon, 20 Jul 2026 17:59:44 +0200 Message-ID: <2ebda180488310a6f862242cb173ffc9b106756e.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.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-bad1c0/1784563220-BF6D2034-1ABBD91C/10/73395122804 X-purgate-type: spam X-purgate-size: 8946 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563245906158500 p2m_set_allocation() uses a bool *preempted out-argument that overloads two meanings. When non-NULL, the value written back (true) duplicates informati= on already carried by the -ERESTART return code =E2=80=94 pure redundancy, whi= ch the caller-side ASSERT(preempted =3D=3D (rc =3D=3D -ERESTART)) only documents. = Separately, a NULL pointer is an implicit calling convention meaning "preemption is not permitted in this context". Replace the pointer with a plain bool can_preempt that explicitly controls whether the preemption check runs, making the NULL-to-suppress convention type-safe and self-documenting, and rely on the -ERESTART return code alone= to report that preemption occurred. Since p2m_set_allocation() is called by the common dom0less build code, move its declaration from the ARM-specific asm/p2m.h to xen/p2m-common.h. Reported-by: Jan Beulich Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel --- Changes in v6: - Nothing changed. Only rebase. --- Changes in v5: - Add Reviewed-by: Michal Orzel --- Changes in v4: - Reword commit message: a NULL pointer was a calling convention meaning "preemption not permitted", not pure redundancy. - Annotate the explicit can_preempt arguments at the call sites with /* can_preempt */ comments for readability. - Move the function's doc comment to the prototype in xen/p2m-common.h (dropping the duplicate above the Arm and RISC-V definitions) and clarify that -ERESTART is only returned when can_preempt is true. - Add __must_check to the prototype, since the return code is now the only preemption-status indicator. --- Changes in v3: - Nothing changed. Only rebase. --- Changes in v2: - new patch --- --- xen/arch/arm/include/asm/p2m.h | 1 - xen/arch/arm/mmu/p2m.c | 24 ++++++------------------ xen/arch/riscv/include/asm/paging.h | 2 +- xen/arch/riscv/p2m.c | 9 ++------- xen/arch/riscv/paging.c | 7 ++----- xen/common/device-tree/dom0less-build.c | 2 +- xen/include/xen/p2m-common.h | 8 ++++++++ 7 files changed, 20 insertions(+), 33 deletions(-) diff --git a/xen/arch/arm/include/asm/p2m.h b/xen/arch/arm/include/asm/p2m.h index 4a4913716bdd..737da60dcf58 100644 --- a/xen/arch/arm/include/asm/p2m.h +++ b/xen/arch/arm/include/asm/p2m.h @@ -238,7 +238,6 @@ void p2m_restore_state(struct vcpu *n); /* Print debugging/statistial info about a domain's p2m */ void p2m_dump_info(struct domain *d); =20 -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted); int p2m_teardown_allocation(struct domain *d); =20 static inline void p2m_write_lock(struct p2m_domain *p2m) diff --git a/xen/arch/arm/mmu/p2m.c b/xen/arch/arm/mmu/p2m.c index 51abf3504fcf..2cf35d8a3709 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -65,12 +65,7 @@ int arch_get_paging_mempool_size(struct domain *d, uint6= 4_t *size) return 0; } =20 -/* - * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. - * Call with d->arch.paging.lock held. - */ -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted) +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_pre= empt) { struct page_info *pg; =20 @@ -112,11 +107,8 @@ int p2m_set_allocation(struct domain *d, unsigned long= pages, bool *preempted) break; =20 /* Check to see if we need to yield and try again */ - if ( preempted && general_preempt_check() ) - { - *preempted =3D true; + if ( can_preempt && general_preempt_check() ) return -ERESTART; - } } =20 return 0; @@ -125,7 +117,6 @@ int p2m_set_allocation(struct domain *d, unsigned long = pages, bool *preempted) int arch_set_paging_mempool_size(struct domain *d, uint64_t size) { unsigned long pages =3D size >> PAGE_SHIFT; - bool preempted =3D false; int rc; =20 if ( (size & ~PAGE_MASK) || /* Non page-sized request? */ @@ -133,27 +124,24 @@ int arch_set_paging_mempool_size(struct domain *d, ui= nt64_t size) return -EINVAL; =20 spin_lock(&d->arch.paging.lock); - rc =3D p2m_set_allocation(d, pages, &preempted); + rc =3D p2m_set_allocation(d, pages, /* can_preempt */ true); spin_unlock(&d->arch.paging.lock); =20 - ASSERT(preempted =3D=3D (rc =3D=3D -ERESTART)); - return rc; } =20 int p2m_teardown_allocation(struct domain *d) { int ret =3D 0; - bool preempted =3D false; =20 spin_lock(&d->arch.paging.lock); if ( d->arch.paging.p2m_total_pages !=3D 0 ) { - ret =3D p2m_set_allocation(d, 0, &preempted); - if ( preempted ) + ret =3D p2m_set_allocation(d, 0, /* can_preempt */ true); + if ( ret =3D=3D -ERESTART ) { spin_unlock(&d->arch.paging.lock); - return -ERESTART; + return ret; } ASSERT(d->arch.paging.p2m_total_pages =3D=3D 0); } diff --git a/xen/arch/riscv/include/asm/paging.h b/xen/arch/riscv/include/a= sm/paging.h index e487c89a4ccd..103384723dc5 100644 --- a/xen/arch/riscv/include/asm/paging.h +++ b/xen/arch/riscv/include/asm/paging.h @@ -9,7 +9,7 @@ struct page_info; int paging_domain_init(struct domain *d); =20 int paging_freelist_adjust(struct domain *d, unsigned long pages, - bool *preempted); + bool can_preempt); =20 int paging_ret_to_domheap(struct domain *d, unsigned int nr_pages); int paging_refill_from_domheap(struct domain *d, unsigned int nr_pages); diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index 703b9f4d2540..566266e3e78f 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -428,17 +428,12 @@ int p2m_init(struct domain *d, const struct xen_domct= l_createdomain *config) return 0; } =20 -/* - * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. - * Call with d->arch.paging.lock held. - */ -int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted) +int p2m_set_allocation(struct domain *d, unsigned long pages, bool can_pre= empt) { struct p2m_domain *p2m =3D p2m_get_hostp2m(d); int rc; =20 - if ( (rc =3D paging_freelist_adjust(d, pages, preempted)) ) + if ( (rc =3D paging_freelist_adjust(d, pages, can_preempt)) ) return rc; =20 /* diff --git a/xen/arch/riscv/paging.c b/xen/arch/riscv/paging.c index 76a203edbb0c..35f572689a7c 100644 --- a/xen/arch/riscv/paging.c +++ b/xen/arch/riscv/paging.c @@ -47,7 +47,7 @@ static int _paging_add_to_freelist(struct domain *d) } =20 int paging_freelist_adjust(struct domain *d, unsigned long pages, - bool *preempted) + bool can_preempt) { ASSERT(spin_is_locked(&d->arch.paging.lock)); =20 @@ -66,11 +66,8 @@ int paging_freelist_adjust(struct domain *d, unsigned lo= ng pages, return rc; =20 /* Check to see if we need to yield and try again */ - if ( preempted && general_preempt_check() ) - { - *preempted =3D true; + if ( can_preempt && general_preempt_check() ) return -ERESTART; - } } =20 return 0; diff --git a/xen/common/device-tree/dom0less-build.c b/xen/common/device-tr= ee/dom0less-build.c index 9513c1c83766..fcbeb8adbd73 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -760,7 +760,7 @@ static int __init domain_p2m_set_allocation(struct doma= in *d, uint64_t mem, domain_p2m_pages(mem, d->max_vcpus); =20 spin_lock(&d->arch.paging.lock); - rc =3D p2m_set_allocation(d, p2m_pages, NULL); + rc =3D p2m_set_allocation(d, p2m_pages, /* can_preempt */ false); spin_unlock(&d->arch.paging.lock); =20 return rc; diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index f0bd9a6b9896..0eb061991283 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -43,5 +43,13 @@ int __must_check check_get_page_from_gfn(struct domain *= d, gfn_t gfn, bool readonly, p2m_type_t *p2mt_p, struct page_info **page_p); =20 +/* + * Set the pool of pages to the required number of pages. + * Returns 0 for success, -ERESTART if preempted (only when can_preempt is + * true), or a negative error code on failure. + * Call with d->arch.paging.lock held. + */ +int __must_check p2m_set_allocation(struct domain *d, unsigned long pages, + bool can_preempt); =20 #endif /* _XEN_P2M_COMMON_H */ --=20 2.54.0 From nobody Thu Jul 23 21:11:29 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=1784563241; cv=none; d=zohomail.com; s=zohoarc; b=kjRo9UxsJ+nby++d6DG8LAqOy6EUEEQtpZPZN/28k0/fRRvwT2OIkm4r8nslZ8bkezhbPeQH+RcBt/CuyZXwZHJSaVQ7DldgkQo99k5bv0AJesKAtdp2wyCLeA660pjQ6L1/UjF3oXv+h8l/zOzkWVZK+f9wwZGPRy3OOSOyNF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563241; 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=bB3OQj6Kva47FxFhgjMEGNOUR6jc4N6mMAW+8vLlz0k=; b=l0vIjqAM32G3UO1BZPahKR+/XywOPOZG5zHBKevYpY5vISNZjqTYE1RamWQ9l7AOMXKRPH05Ozfx0PLM2cRnqEdDj7xvVsmMD+au2iO8jInNnoj3vDjrfDtZQAT1n3pdngOkSsMMXHHaT7pUmDZY554H23/VB8gg+kRm4gvJZHs= 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 1784563241763525.1961919114979; Mon, 20 Jul 2026 09:00:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366950.1616766 (Exim 4.92) (envelope-from ) id 1wlqPm-0004s2-P1; Mon, 20 Jul 2026 16:00:22 +0000 Received: by outflank-mailman (output) from mailman id 1366950.1616766; Mon, 20 Jul 2026 16:00:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqPm-0004ro-K9; Mon, 20 Jul 2026 16:00:22 +0000 Received: by outflank-mailman (input) for mailman id 1366950; Mon, 20 Jul 2026 16:00:22 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPm-0004fH-0q for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPl-00HTTh-Ds for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:21 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460c-e002-0a2a0a5209dd-0a2a4503e392-48 for ; Mon, 20 Jul 2026 18:00:21 +0200 Received: from [209.85.128.45] (helo=mail-wm1-f45.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4615-fae8-0a2a45030019-d155802db58d-3 for ; Mon, 20 Jul 2026 18:00:21 +0200 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-49557167508so18691905e9.1 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563221; x=1785168021; 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=bB3OQj6Kva47FxFhgjMEGNOUR6jc4N6mMAW+8vLlz0k=; b=pIK7h/fKmZQuhkYUQlVf+NBKadHOt4f3jhfwD02c6Yev1vUNaiXPGbfb0YLo5/POhs XSb38TzjnNZysAzQzKwFaNraRO32TkqN6YtuT8UyH+uN9rTwSGheCyjNPQdgLfyv0ycR jML0/MVWju4PyDdATvoiE7z3bmQDnIIi8K0SPbrZPADs8TWbTOrKVcmU9sieAmvYvyaY /TmeR4BObztFEr3dd560HkG6CIIGJz7af2X1AR+TFwNxYhZs7swHL0JkuYMzsxahE6Lq HT8gh0IwQ4+jhx4ITQYivuJ2BwIBAOnIlEniKA+oZCVMBIVoPzueNzjs9/6bVxMkJL9M Ws1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563221; x=1785168021; 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=bB3OQj6Kva47FxFhgjMEGNOUR6jc4N6mMAW+8vLlz0k=; b=qvOFX7hVn4IEBopkBwzXCUVVGjPeHF1mNKvhXCJHdFvN3swIuJFEuCdbgQ8dKhFx02 w/FvLsPrN7yHQBPjQkWSUnaXCOCdmtkqKdOhG/mIuc9y7y2NntOatslcf4krrNgBkA81 b9UY5nAI1KwWR6t3+1ZmlL8miDIde64j6t+TclMrQ8g6RE0y0bxMCRvc11AAcyqrdA42 C2fQ4v7qOXHuUcDP+1DSwLeS43ommQntUTUfCwew6RxrBMNE6Xi9KH2KZmGr2GIoQcs+ n9iwc3C0rrSsqnyeWb+Gps4wc9GcTBImkWmJeHykzF+2hJLCUNvlOcI6lTvYO9EHLK0P GXLw== X-Gm-Message-State: AOJu0YxKBYQL+t+dcay4pvREinK3lKPEo2q1x9B+fL4MIUKb4caJ4HMi xv2VUUheIffFBhD5Vj1Bn1MTCWJwUk1VD9I3CJqc17UQhmLayRD60WgqUoOTDQ== X-Gm-Gg: AfdE7cmEXEjZS24ieVgPTNT9MVvo1NUdNl3c+S+ng5udTSiADXHPdP6rk5Xrq9sCRT1 1B36BhJBCdR8wX9y9zCXVRc4XGDzVevCacTZaSDaZOUUlX7w1CMyrqQ5JhIiH8LwNrdhL3wl1y8 JqBYbxpJF4vA+kRGvDJJIR22QqAwBBxI8fbs2Qou95M9mPjWmPYS3unhFcfVarVUhKopBvUqGaT Q8DG9mTzm+WNKLHdfSaWTNorzpMj/D6r5BTtByVDmie+c59sjUvTcyNu5DBeM8bkuejpO6cgkxm 3aRvhGh/vFNkTDGe8etHnbetuV4MM5FfQpCxmsL+ClkWlomBvDF11N59vj1VoXptPpKeHG2cXiu cdojifgkCZNizjZmz48b+v57q5yJ/h9fYvFDRhgBmRX2pilZ2qtFTqsvwpDumFV8SfL6APSVrzP qgJNNE4GN2yVaNY6Xut1guzOA8wpvFbHvFqLdhR1KYYRQg1Vc= X-Received: by 2002:a05:600c:3107:b0:495:6400:ab62 with SMTP id 5b1f17b1804b1-4956400ab9dmr20795265e9.20.1784563220383; Mon, 20 Jul 2026 09:00:20 -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 v6 04/23] xen/riscv: Implement ARCH_PAGING_MEMPOOL Date: Mon, 20 Jul 2026 17:59:45 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1784563221-6D8D54E9-FD62546C/10/73395122804 X-purgate-type: spam X-purgate-size: 2633 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563243772158500 Content-Type: text/plain; charset="utf-8" The p2m_freelist is used to allocate pages for the P2M. To initialize this list, domain_p2m_set_allocation() may be called from construct_domU() in the common Dom0less code, so RISC-V provides an implementation and enables CONFIG_ARCH_PAGING_MEMPOOL unconditionally. Additionally, implement arch_{set,get}_paging_mempool_size(). They are not directly used yet, but are required to support the XEN_DOMCTL_{get,set}_paging_mempool_size hypercalls. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v4-v6: - Nothing changed. Only rebase. --- Changes in v3: - Drop stray blank space in arch_get_paging_mempool_size(). - Add Acked-by: Jan Beulich . --- Changes in v2: - Turn on CONFIG_ARCH_PAGING_MEMPOOL=3Dy unconditionally and drop all ifde= f-s related to this config. - Optimize check inside arch_set_paging_mempool_size which verify size argument. - Use pfn_to_paddr() inside arch_get_paging_mempool_size() instead of open coding the stuff. - Drop ASSERT() from arch_set_paging_mempool_size() as it is impossible to have here preempted =3D true and rc !=3D -ERESTART. --- --- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/p2m.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 41426c205292..48520588fe40 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -1,5 +1,6 @@ config RISCV def_bool y + select ARCH_PAGING_MEMPOOL select DOMAIN_BUILD_HELPERS select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index 566266e3e78f..1cea86512c8c 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -1600,3 +1600,27 @@ struct page_info *get_page_from_gfn(struct domain *d= , unsigned long gfn, =20 return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn), t); } + +int arch_set_paging_mempool_size(struct domain *d, uint64_t size) +{ + unsigned long pages =3D PFN_DOWN(size); + int rc; + + /* Non page-sized request or 32-bit overflow? */ + if ( pfn_to_paddr(pages) !=3D size ) + return -EINVAL; + + spin_lock(&d->arch.paging.lock); + rc =3D p2m_set_allocation(d, pages, true); + spin_unlock(&d->arch.paging.lock); + + return rc; +} + +/* Return the size of the pool, in bytes. */ +int arch_get_paging_mempool_size(struct domain *d, uint64_t *size) +{ + *size =3D pfn_to_paddr(ACCESS_ONCE(d->arch.paging.total_pages)); + + return 0; +} --=20 2.54.0 From nobody Thu Jul 23 21:11:29 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=1784563257; cv=none; d=zohomail.com; s=zohoarc; b=JjDDIw17Ywe80Erq1xMN6O3HU8am2TZXGHDiCS17Y7408F2cGprazbqUWTfUejMyZlVeJtzqz1d79/ltK/9siN4VPY0VabdYSdLOUXaIpMu8fykf1ap0Q+cQgN9ikNuL+erEaDs/mdwkSOZg8wzUEWiOgtTKHrWb6fzsd55WyiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563257; 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=ALyLLkJ/FueWGNpU6AdvBuLz9jp+wMzaqsUT95MAEFA=; b=H4n7r3pRNcqUdnMSKc4F4O859OxPjwI9KwUqxiZaP3CKRTJpYU2KQQzrHYTzygBn0pgAHCoLPC8UKCh4yUJLn1fd5e0D0O1884Uy+ajEdtpibpZisdveK1nR8zsElUKR3lvN+KDq2Ilx7di3/Rkzqbhyq7JEs1BUCqcgqqHh+/I= 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 1784563257001990.3289436608079; Mon, 20 Jul 2026 09:00:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366951.1616774 (Exim 4.92) (envelope-from ) id 1wlqPq-0005Av-8k; Mon, 20 Jul 2026 16:00:26 +0000 Received: by outflank-mailman (output) from mailman id 1366951.1616774; Mon, 20 Jul 2026 16:00: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 1wlqPq-0005Ag-3X; Mon, 20 Jul 2026 16:00:26 +0000 Received: by outflank-mailman (input) for mailman id 1366951; Mon, 20 Jul 2026 16:00:24 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPo-00057U-PT for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPo-00CGfz-6M for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:24 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4617-bab6-0a2a0a5309dd-0a2a4507ca5a-2 for ; Mon, 20 Jul 2026 18:00:24 +0200 Received: from [209.85.221.42] (helo=mail-wr1-f42.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4618-b4ea-0a2a45070019-d155dd2ad4e4-3 for ; Mon, 20 Jul 2026 18:00:24 +0200 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-47f7444576cso1008605f8f.0 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563223; x=1785168023; 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=ALyLLkJ/FueWGNpU6AdvBuLz9jp+wMzaqsUT95MAEFA=; b=htaIcNgLnZXiqy5j+OrYU822uiNoKhJOC9eItJFBg7tM1tjWCqlVdFXEXhR0ExmwvZ p6aJfN1i709NGfV369VNu+HJrOqcT8Y4EJRACLQDNm/7ha+yi/HG4IcBZWGxgo71W+5D lJivWHdCeh27zi0KSc/KJPhFX/vytgKJ7NakKzaGH0U5YpRENlVwaizvqW0W9d8bBYt0 +sH2mqs5ilAcPDCCEUebKsPorqqIXjC43Keg53KdIJGE+5+q/5ZL+b1oBpVXQD5fCP3z Wak1zVo+ziQeLTxS8UetA50PjPohdL2d5j+EDlUnqVpZnZRDGW71nfM1Fq4Z5XrbNmtJ +YwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563223; x=1785168023; 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=ALyLLkJ/FueWGNpU6AdvBuLz9jp+wMzaqsUT95MAEFA=; b=Oo3ba/6uYh3tN40n9La5WAYOKh/PhNJ3u9ELqJcTncn111W/+FOmrIiZgzDdZ95Ljc PHuC/dCOjFhZT/D2P3Q50nw99fIdJa+3UwgBPtQd9Iltn06flArW71kz1Ag1wm5Y2AdR 9CVE8V9+BmVnVkVvNiptENlRcZm3oVDIxjQaSHHq9DBu1YrOMSZqiYKVynqxshkFF8Sf +P1TNGOAji7zXaTIYpjIcrwQPM+yCwC1Q8hfndSBI5rbzcFUJ7YMWCYk6+EMGyZ6legP 4pZUQ4bLTFVjoNCfz40jk9RO7qZhOAavqdYGus2BoLQsmR0tAuUyyXspKZXgNMrcx1qr MSfA== X-Gm-Message-State: AOJu0Yzb8Y2kp/64WRZqfPMNQ597kUINA2W2KJCnhaMEeNwwfSuSs7KL 3IcmZS+WFmk7tfxmeIIQ2BXXK3xeoJkI4AZchHaywpD43F0exHd1rRVvtZpGqw== X-Gm-Gg: AR+sD127EPyLOQo8qirHQJ0rTxlMCH7+TreSNbHGq0mVhJ67RNyrxMoUgbSrZRJkRFZ 0fT49cn4FVDRhLPR9ACLHReJtKEUqd+R4q+jmofnWV2fy02brFgY8CKe9N7Uogdk+BWzvLo0nCh Vpd1a3Jl3J8i8FiCx86BCMQxhGKI+z7c0FAqzNiqI9bxV97sUacS+bGmwi891wTFA1Wb/BD8Yp4 t28SZJHJxwUV9auDbwOLlz/gwVG2lAbtTonwzwKdSWwq5cUEGrj5x4YotnJrysjzOVVGyrgGGKb dH+oFpYYynO5XWqdCgQ930Ae8OZzq8QYSCHGuf3yS+veviyQLG/zdA0hAz3/RmOM2HOtgBc3YKX alzCTDAnT8fC7cN72F7myp0Eapf5XTNbKsFgHx+441DfEKC6ZJgfJWJ9urbLotWZmzBp18U0JlS t8M/hCYow6tMnxDQN9+e0ybF4ph0ncxIHkZYavOyui7xhPxgQK99zBtB+OnQ== X-Received: by 2002:a5d:6285:0:b0:47e:f4c:508e with SMTP id ffacd0b85a97d-47f62330d27mr12254241f8f.46.1784563223545; Mon, 20 Jul 2026 09:00: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 v6 05/23] xen/riscv: Implement construct_domain() Date: Mon, 20 Jul 2026 17:59:46 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1784563224-A62C4AE4-4C6512DF/10/73395122804 X-purgate-type: spam X-purgate-size: 3117 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563257752158501 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-v6: - 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 8f7fd625dddd..fd5e499eb4b9 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.54.0 From nobody Thu Jul 23 21:11:29 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=1784563253; cv=none; d=zohomail.com; s=zohoarc; b=kKSCDIGEthSH+GmTwyVg4TPCHeT8I1ZRVPbxLR1iPalqZCWtf8bUA9QXyV2xWuOLz9wN/6PLb4pUZvkVNuV2FHezgKAUS2u8Jy+DoWdvlD84wa9QACXw+th3vGm2iIb+EjlrtlX6exe5wklfUaOEy4/NVyzet5IErRzH3JKOQSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563253; 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=3Q2X5G2Kf4mmDkHK1SaF1TQrXLIPr2aHrkwYphanNOM=; b=KEet7fsK4+bu0eDBCtsEhjjyri8+JbbyViVaBqu5aEt+L+hnl+ihed/bNi1RGRn7y57QkQe229jfzBc46IjVtnh5tv46FVwgh6NZOA5cSWCeTZMSjwVyQ6KTp2MwzJvplf5fi5FYe1CtkJ2br97nRZUnuT/7+4FsMKCLF6nyAu8= 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 1784563253697318.4788762219324; Mon, 20 Jul 2026 09:00:53 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366952.1616783 (Exim 4.92) (envelope-from ) id 1wlqPs-0005TW-Dk; Mon, 20 Jul 2026 16:00:28 +0000 Received: by outflank-mailman (output) from mailman id 1366952.1616783; Mon, 20 Jul 2026 16:00:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqPs-0005TL-Al; Mon, 20 Jul 2026 16:00:28 +0000 Received: by outflank-mailman (input) for mailman id 1366952; Mon, 20 Jul 2026 16:00:26 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPq-0005Bt-Nk for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPp-00AdEr-TC for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:25 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460c-5cb7-0a2a0a5109dd-0a2a450887e0-42 for ; Mon, 20 Jul 2026 18:00:25 +0200 Received: from [209.85.221.42] (helo=mail-wr1-f42.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4619-f659-0a2a45080019-d155dd2ad1c1-3 for ; Mon, 20 Jul 2026 18:00:25 +0200 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-471eeac43bfso9621760f8f.3 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563225; x=1785168025; 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=3Q2X5G2Kf4mmDkHK1SaF1TQrXLIPr2aHrkwYphanNOM=; b=N50VorBEAMYYTdcD5oABAkZ6PJCDGCoH9Gw2ngC+ZfZa/IGssd9T3qh/26amKgYyz1 fgNdRumqSYGJ6AG9feFczMGhC/1Ba9/MlrvkRSIPXgjgiCdRWUkzrZw4PswyaAFOhrb0 6GEq15gxZ5RP9nNPJcaXfLjlP0xT1rs7/9vYAcJxIsmZ/BsXEhGjFow8J5x/8cEAjVCa rFi9QYheVkwkoZeyd6ScXRfFnhcnrm0QSJFfQKD73bPmRAJTKgwTuKTFQVLlIVmG/Qu3 xIGCI3SNXqRayQCvLoFLkK/mi12aUpf4gIvhSNN0Zf3gJooxhhU+JoR9VE2vkhGUtij+ /+aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563225; x=1785168025; 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=3Q2X5G2Kf4mmDkHK1SaF1TQrXLIPr2aHrkwYphanNOM=; b=TbW6l2xxlyktQyIFX6Z0vtEc8+PBLxLBWd4hiZ1/QG6g+rxZYzbg8p1fzqP9HVIQO4 HrJnTFKDVKaZsnt7kIy+MFGg9Dzo0KIElR/8UazIphoaIQ4LqG3VvshZLMZBK6w7d7Ys w86himJEL++g+lDj2zsfyXR0cmQoyykoHJ6wUklKqJqpamUwSYy5LDwRBXGMbrfnBDTl 3MYlgrO2g/uE5y2dd2W59MrCd6wVn8wArWrLocrTy4/IPowO7OO1WVdRPt/qE6WLSnEm i6Dfr3rxYXp0T349ExT2v7X2iVVBgWqDxTIaLHqMZ5erdWH6sSVRownUG8ZRNPBalOTc uarA== X-Gm-Message-State: AOJu0YyzlTtgcde4YixPtaBe9NReYJxLrVFU8MAG/TNMUzDPKlOl0u4k bgy35D8qUUHt1jyZZywaY6UB0l5Mbn2wF60GSB4UtyZofZoQ01P0PQa8mwOGmA== X-Gm-Gg: AR+sD13W0wxkFiNlxv5QlufXJ4kosF6++k0kB7m3u43pGE7UIIS7qX3tmSF5PZhs13h /eiPOO2LEij9DDaxliCuzJ4qgLSvN7srEQh3tRt6lqXKAvPD1pBiZHGl9Y7R7VD07pLOznre2Wn tzZE+DpWqDVopzAwALX3u8G8ke/TTq7DcmppF6rEmdCqj+0a05DeHNw4RouD1I76yntLNSgyg+B tFjNstaWOfGO0cW8XUQTCX0OMQTAOkjI8F186ktceoU35Os7cDfieUOxLvGcQKDgpNS5s3kjD0l 8yFhtfVUB6sPDApBG8zZTnA5SYi4tbOPPBVblJ0pVlRAKkhnp0dUL2rgIbqtFiNnXmUZp5F7zYv MG+ZLGgwIoFuoMbY7Ff9AhQG/kfBYwBd+vAi0rygED0coOF0sFViSmbO5Kqw3XZCWVwYWNqw85a 3KeL1meukVKsAgJgOgYIR/AFl7W99DTSOB5b185gztgkPNUW0= X-Received: by 2002:a5d:5d0e:0:b0:46e:8226:96ba with SMTP id ffacd0b85a97d-47f623036aamr18223366f8f.13.1784563224914; Mon, 20 Jul 2026 09:00: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 v6 06/23] xen/riscv: introduce guest riscv,isa string Date: Mon, 20 Jul 2026 17:59:47 +0200 Message-ID: <9f5d1005611daa4ba9e4324950fcfe10adbebc32.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1784563225-D7B5987B-7460C020/10/73395122804 X-purgate-type: spam X-purgate-size: 13301 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563255821158500 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 Acked-by: Jan Beulich --- 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 | 148 ++++++++++++++++++++---- 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, 134 insertions(+), 24 deletions(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..a016568cce68 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -14,6 +14,7 @@ #include #include #include +#include #include =20 #include @@ -34,9 +35,32 @@ 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); + static int __init dt_get_cpuid_from_node(const struct dt_device_node *cpu, unsigned long *dt_cpuid) { @@ -120,29 +144,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 +206,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 +505,79 @@ bool riscv_isa_extension_available(const unsigned long= *isa_bitmap, return test_bit(id, isa_bitmap); } =20 +int __init build_guest_isa_str(char *buf, size_t size, const struct domain= *d) +{ + const unsigned long *isa_bitmap =3D d->arch.isa; + 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(isa_bitmap, 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) +{ + 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); + } +} + +void init_guest_isa(struct domain *d) +{ + d->arch.isa =3D guest_isa; +} + void __init riscv_fill_hwcap(void) { unsigned int i; @@ -527,4 +625,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..3c2be9f0954c 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); +int build_guest_isa_str(char *buf, size_t size, const struct domain *d); =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.54.0 From nobody Thu Jul 23 21:11:29 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=1784563256; cv=none; d=zohomail.com; s=zohoarc; b=ZrLq2NBuuDJg3k9qxAGfw11X/hMt7QWsPV2hm+TbEtql4GXX0F0qTEojlNUvM5Uofk57zLx6MlmxX4ErO5VWg05IcvUrfgkArjiXqnwy5g0AWI4eOv+U1q4ult3uDTKR2jS1sWvWlZ92bcXlU5hWlJ6Jr61MC3fAjJas7M2Psns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563256; 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=jcKzxBSEA3zmGWed+Cw9No+MDgy3l+QGW15O4E+abXs=; b=GstgfwpFdR++jGRY6iGb7QRgqi4cdKCCdvYnL3Jdkmh+spZi7ztJf4IDQgOcPNMn/dNp+vOQHpkcAOLdWAxSF2KTfX3PyuYCErVfNkmoj7EclxAWFWs06ewT4/TFRkTga18c2x0nS4fU37co6xuDBEv8J8T5EDBEf3nM3UbX5rI= 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 1784563256110459.6741389543663; Mon, 20 Jul 2026 09:00:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366954.1616792 (Exim 4.92) (envelope-from ) id 1wlqPt-0005jA-PV; Mon, 20 Jul 2026 16:00:29 +0000 Received: by outflank-mailman (output) from mailman id 1366954.1616792; Mon, 20 Jul 2026 16:00: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 1wlqPt-0005iM-LY; Mon, 20 Jul 2026 16:00:29 +0000 Received: by outflank-mailman (input) for mailman id 1366954; Mon, 20 Jul 2026 16:00:28 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPs-0005TP-HB for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPr-00HTTh-UK for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:27 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4612-e002-0a2a0a5209dd-0a2a450abd5a-24 for ; Mon, 20 Jul 2026 18:00:27 +0200 Received: from [209.85.221.43] (helo=mail-wr1-f43.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e461b-f2d2-0a2a450a0019-d155dd2bc516-3 for ; Mon, 20 Jul 2026 18:00:27 +0200 Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-47640541585so5210877f8f.1 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563227; x=1785168027; 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=jcKzxBSEA3zmGWed+Cw9No+MDgy3l+QGW15O4E+abXs=; b=oAxT/Z1T0CBfYC5xnr0p4IN1SJwiDAiqvTSGJHXVCgatFHLvLHgJ1KwDY5VID0EiF8 gR5ZogEZtjak1FlxMqHzg0W2V0Ar7ub71SdjEBcRZq+C2CJYxy4CDQx2joxmBvWbcAft gf9dMj14W8BnGcQZRRdzwmtc8bl+o8XZO8dtilXTnX1gXo6Ry016RHG7Xx6LXDxma/6Z gvFzackoWvnsM4QpIUvR6sFsUYyZ6Y1r+2JKaXXat0cKdqN129p/d5By+Msp8VdtWgp7 rsHSsmPahb0p3CTBNfb2EttdKvQogYlUMgksFIhvQhc/WwZw81bXxhgTLla84v7MFItb L2RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563227; x=1785168027; 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=jcKzxBSEA3zmGWed+Cw9No+MDgy3l+QGW15O4E+abXs=; b=gkOVG/nCcGXINpvTKo3rTM//IAPrKi8+ssBkBjHOEvJixZrUpdHMdj1mwIz9aPi2Tt M8MibfkEuUIZw2v1lT6AhwSxAJu3rCDpwIFasrSAEzXNXZY6cMrd/x0k3znruzgbHJWp Fu0gN7RRvYoRsRQslqReZik9RaGFDadh7jJxUetlbVTtkX/YLgPbVpkLJC8AtQti2AZj 3za7vhoF1cCfcf7QLisLa7CLxRssfY8RjrGOto6eXTOQUVzGWvPK5X6uBZo48hrdunNS ZFexk2PD6yJfg2w1yHBluDQOUyQVk0XtTpBUJ6Jh3kFy32cxN1N+SS0yQ3MuAbBpiRk+ Jpjw== X-Gm-Message-State: AOJu0YyWUL2y4R8514rITXy8ImCbUZdh4VAAQD4qlcUohJva/+pBgQSD /Nj1qcSdGcvhzz3ZkJoxcX0LOXk9KOarDd2y2HZnJfIHGcENhVRfCE/suZ6hkA== X-Gm-Gg: AR+sD12cPFbvdXvO8N3orJ9isQbsr0ZZouu0vh+Fs3edMNxlxuPqvmLL3FZFxp56Z4+ kZDuRMiihdTcvrVBQuje+Ld8gIK21VPnD/PEF6rJfAZJvlKLZ8R9UIOKkS3j8MzJ5iVDiM93E6C CCRB3SI91Nh5ulyUfyWCny9FRHnB6+cq8JdUIVM5ZZlk5QtMymVL7umDiJoXxvoftVn5G2r3KTl k6v6CzTtSDn7K6fr8Cy1fJvXsjoAoiYbhLvwBFiiiLULgq5zTLQUMqBmPkGlZL2ZO17/QlgbZT6 KH3I38HT9177CI4wnGH+EY5/T9hjRZ2MP19XaAUXUCjD8k0EerXOSYabF7YMSHPicA9j6rZ9tOW VbZHeFZnkM+hJ/r5yeLHq2ZtE+QjjbWNiBEgbOu4yeRs8tEzs4VxmktsxY1B1ARtmckJzTMakMj 7G4swNDHcVRBhKSrlVUSgh+EjgpxppwIe0ZQy2VMXekXyiz0I= X-Received: by 2002:a05:6000:4310:b0:47d:ecaa:3f97 with SMTP id ffacd0b85a97d-47f6233db68mr17060164f8f.45.1784563226487; Mon, 20 Jul 2026 09:00: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 v6 07/23] xen/riscv: implement make_cpus_node() Date: Mon, 20 Jul 2026 17:59:48 +0200 Message-ID: <4d7eba7501a43727cdc30efcff56f422c1bc376d.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1784563227-593C4CFC-F13F8CD8/10/73395122804 X-purgate-type: spam X-purgate-size: 5924 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563257792158500 Content-Type: text/plain; charset="utf-8" Implement make_cpus_node() to create cpus node for a guest domain. This function is going to be use by common dom0less code during construction domain. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in 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 | 125 ++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index 5f6f4b6248a5..8be29d9331d2 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -3,8 +3,11 @@ #include #include #include +#include #include +#include =20 +#include #include #include =20 @@ -48,3 +51,125 @@ 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; + char *isa_str; + int len; + + 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); + + if ( (len =3D build_guest_isa_str(NULL, 0, d)) < 0 ) + return len; + + if ( !(isa_str =3D xvmalloc_array(char, len + 1)) ) + return -ENOMEM; + + if ( build_guest_isa_str(isa_str, len + 1, d) !=3D len ) + { + res =3D -EINVAL; + goto out; + } + + res =3D fdt_begin_node(fdt, "cpus"); + if ( res ) + goto out; + + res =3D fdt_property_cell(fdt, "#address-cells", 1); + if ( res ) + goto out; + + res =3D fdt_property_cell(fdt, "#size-cells", 0); + if ( res ) + goto out; + + 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, sizeof(buf), "cpu@%u", cpu); + res =3D fdt_begin_node(fdt, buf); + if ( res ) + goto out; + + res =3D fdt_property_cell(fdt, "reg", cpu); + if ( res ) + goto out; + + res =3D fdt_property_string(fdt, "status", "okay"); + if ( res ) + goto out; + + res =3D fdt_property_string(fdt, "compatible", "riscv"); + if ( res ) + goto out; + + BUILD_BUG_ON((sizeof("riscv,") + + sizeof_field(struct gstage_mode_desc, name)) >=3D si= zeof(buf)); + snprintf(buf, sizeof(buf), "riscv,%s", max_gstage_mode->name); + res =3D fdt_property_string(fdt, "mmu-type", buf); + if ( res ) + goto out; + + res =3D fdt_property_string(fdt, "riscv,isa", isa_str); + if ( res ) + goto out; + + res =3D fdt_property_string(fdt, "device_type", "cpu"); + if ( res ) + goto out; + + /* Start of interrupt-controller */ + res =3D fdt_begin_node(fdt, "interrupt-controller"); + if ( res ) + goto out; + + res =3D fdt_property_string(fdt, "compatible", "riscv,cpu-intc"); + if ( res ) + goto out; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", 1); + if ( res ) + goto out; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if ( res ) + goto out; + + res =3D fdt_property_u32(fdt, "phandle", alloc_phandle(kinfo)); + if ( res ) + goto out; + + /* End of interrupt-controller */ + res =3D fdt_end_node(fdt); + if ( res ) + goto out; + + res =3D fdt_end_node(fdt); + if ( res ) + goto out; + } + + res =3D fdt_end_node(fdt); + + out: + xvfree(isa_str); + return res; +} --=20 2.54.0 From nobody Thu Jul 23 21:11:30 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=1784563273; cv=none; d=zohomail.com; s=zohoarc; b=S3tRkbwA8Pz4F92SLI0LwgJeMEqbmigCH41we/YnScZTMnBfNvIPL5ViPiVq71FD+J7iGmg6tvSGjryg2FOI2cJGbEu/WcW87MUCimioJr01ImmuLOTYfr+O0d0fJ8BoPovyL3FoWiLrRewbQ38VpA81T00QmKHa3d3ycml53IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563273; 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=KhEGDhlXrwyiseqyPc30kooLsaCELsXAQVmwDU9aLvI=; b=aMUQlawsXqeicAMFcWa+Yy48JPId73zVrpvsP7yfSXQsaQ75eZRpemBSod6WRDJw4Iz63Q8BbiWJYnzRoG3pBJMRAHPBTx7x6PLjy5tKYpXqjO+42b7jvHDlMN0bzsiQFG8cISf/dmhPvNK4ZGlEuK77tmJPJLOk2L7SSDe4vBM= 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 1784563273068192.18808403049923; Mon, 20 Jul 2026 09:01:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366958.1616805 (Exim 4.92) (envelope-from ) id 1wlqPx-00069U-0m; Mon, 20 Jul 2026 16:00:33 +0000 Received: by outflank-mailman (output) from mailman id 1366958.1616805; Mon, 20 Jul 2026 16:00: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 1wlqPw-00068b-Ot; Mon, 20 Jul 2026 16:00:32 +0000 Received: by outflank-mailman (input) for mailman id 1366958; Mon, 20 Jul 2026 16:00:31 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPv-0005yR-64 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:31 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPu-00HTTh-Ix for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:30 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4612-e002-0a2a0a5209dd-0a2a450abd5a-30 for ; Mon, 20 Jul 2026 18:00:30 +0200 Received: from [209.85.221.45] (helo=mail-wr1-f45.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e461e-f2d2-0a2a450a0019-d155dd2dd0bf-3 for ; Mon, 20 Jul 2026 18:00:30 +0200 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4799b3f7c83so7492115f8f.2 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563230; x=1785168030; 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=KhEGDhlXrwyiseqyPc30kooLsaCELsXAQVmwDU9aLvI=; b=Wvv0tZfdRLS00CiA2IFBQuXPXujQeOgP+t87r3c+LaP3lhs/KB3CyP3jUxER+f0rIm T1ak5L9GvfPtYO4Pwn+AdqALpfRGzhKDnAurZJXfVv+GmJRkeCwZGqDiVySsEFz/LCS/ ft7ZI3sHxMARm4CgMZmx2ElTLweqT1n9Ccmr1EiZg3aShh2vtNaBb+0bqLdMGjFjYhCU YJztXbdePtJ9PyIdnsCe84qMAfDDxxyKNEIxBCgWHLUoIgZ48CS/toID+2ge+jiUrAc4 Zi7qXqYZdag3eXBu8D6J6wX3+zgrqGFP52HFEQyHpJoCO2ANo2UBmUIwI3yMeMTHgE+6 GhCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563230; x=1785168030; 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=KhEGDhlXrwyiseqyPc30kooLsaCELsXAQVmwDU9aLvI=; b=OQImWkp2Wd9UDMPz0d4lxZrVcm6BhgFzyg6/er0nNFWXFcWi8CC0LtNqm24RyvYkB3 axRDZpF0Nt9eG19ys4yr9GdpE65bopZ5uFjh+sPbgncnY4kUoVyPnaJxanyt2uKGsAsp 09zEAtO+04an1rKicvBxd2HD56Lex6DdUTJKAVNjAvWBiy7uGPOOtfxH9hA5ROdgeiGz 2oduXn5KyReRpXXLFHN08/vfAWXGXfJfvNLANComT4qKMAolp00LjkCPMF2IOmalmNwS JCyi6t3vpQ4P+xls1NObSOLpfkSlp/C4XR8lt4wzO9BXDPURKSzJrDGCeWrIzyTrbZbA ghiQ== X-Gm-Message-State: AOJu0YzjxvxhqQo7GQlKnP7wLT35BaMlmjVF+m0iK4ShM75CFb+B610b SBSWrHUabbdQvR5R5S2+u4kV9teGIOyJaH7F663Y3YtmAEVtTtp0CxWp0YrxPw== X-Gm-Gg: AR+sD120bFkkWT2JUZ8s6X86xdtaTSLNjtrK3/SzvOREPvM3aN5F288sJ0VYSp7gZx2 BkTD4wlR11RG5RKPhtyWMudgdMciCsp4cvMgNZBarW0465vrgaqoU1QC032Ns3iwLhSAwaPawlX iYHhS7EtgvbayAAank6JyddWi+Jq9pXoWJASY4UAf+2zDfgR5xlvjz32PSBlWUcAA7tPNBX6EFT ARWpbxHg3Lcsn+oWCV61QZSS0lblvX4YPztrtASfrcLbHhNFPuJJmvEFYTDthWD7MiDn6tIxBLX QTqAqEGP67jp+YR4cv+3/GkikkdlQpAcTkCaiG86TipfsiodWM6r7mqOsYusrPDPkATCUjq83uG MlPcQUTarw/ve2erJa7HCRCGPAz2fO5KPn5tvqhBi00JqXQMbADXy5rPeUEWzMKMrwqu5l9HGp3 Sl9GeXovmfxiv2ni8Vd28wGM103bNTYC8I6t226TRpgf4nyeo= X-Received: by 2002:a05:6000:4b03:b0:47f:4b20:e616 with SMTP id ffacd0b85a97d-47f622fccc2mr16913038f8f.8.1784563227764; Mon, 20 Jul 2026 09:00:27 -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 v6 08/23] xen/riscv: implement make_timer_node() Date: Mon, 20 Jul 2026 17:59:49 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1784563230-59BC0CFC-C7BCC07A/10/73395122804 X-purgate-type: spam X-purgate-size: 1649 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563273879158500 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-5: - 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 8be29d9331d2..6b14dce9c0a6 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 #include @@ -173,3 +174,10 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) xvfree(isa_str); return res; } + +int __init make_timer_node(const struct kernel_info *kinfo) +{ + /* There is no need for timer node for RISC-V. */ + + return 0; +} --=20 2.54.0 From nobody Thu Jul 23 21:11:30 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=1784563251; cv=none; d=zohomail.com; s=zohoarc; b=haF0hZjckmA2Z50ysj2MrbbrddZz4gvMFQC+0V4bKyNrbGi8LXlEZlaePb65mERLWX7PvlRA6q1TWpnHojXobgP8nB7GVD0DUYvNnLIXfLl73O+hZaAOyDkGJHf1p+K0AqwFcUDZkCnb6lDFBA5wH++A7HACzSF6hRdIxyFeGVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563251; 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=4zPPT5yH4g3srmqRgr/MmJI9wmQx9NN5+pUlXZUXu18=; b=Zq9wiXKXJS/uYHTVjFJqi7XRcd3KkIYUVAFMp8aHmKDzzatURBg0HMPIN5msKzgXxpgBmVy5ibgy+GPUyYGs5Zr0puZNO5LgSNNNG+BWKJA93jTzR83Um45IJhF/uRCdfjo5gMQbwxu89wG/3twCQmsqvjB3u0P4TSBEr70vde4= 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 1784563251484137.577802509491; Mon, 20 Jul 2026 09:00:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366956.1616801 (Exim 4.92) (envelope-from ) id 1wlqPw-00065L-Ea; Mon, 20 Jul 2026 16:00:32 +0000 Received: by outflank-mailman (output) from mailman id 1366956.1616801; Mon, 20 Jul 2026 16:00: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 1wlqPw-000653-An; Mon, 20 Jul 2026 16:00:32 +0000 Received: by outflank-mailman (input) for mailman id 1366956; Mon, 20 Jul 2026 16:00:30 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPu-0005uT-RY for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPu-00HTTt-7l for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:30 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e460b-2eae-0a2a0a5409dd-0a2a4506bcec-34 for ; Mon, 20 Jul 2026 18:00:30 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e461e-195a-0a2a45060019-d155802ce97d-3 for ; Mon, 20 Jul 2026 18:00:30 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4955de8797cso7144655e9.3 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:28 -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=1784563230; x=1785168030; 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=4zPPT5yH4g3srmqRgr/MmJI9wmQx9NN5+pUlXZUXu18=; b=Riy69QMQYpcNsro1P+lh9mHOcA6jK7D94GSwu3H04YHwUlZy29r+H1+GnE9OAScOLr wlUUOhY47w5s/YG96FvttyP2FGusvU2Rq4PU/CvEA4IMUGk8rqBuz+B5NCmRsf1fa+gy ihHZ3ir10bAMVh6TGeWvzOZ4Yy/yCpJYLt0UHb7PgeYxHTrBK38wOm6zcCr/gdJ1ZUAD zBVD2R70/+80jG9ESoFG+ySO5JEEYbgXG0bz/q44XbPIrYPNZbQLvmz89E3TPSQk0GsK clif6m8hqlp8SyG/YwOQ8hJGZ7YOaBohhpRtZCyVF0nIH27nICtYACVc+uyvSKPvVKx0 IEaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563230; x=1785168030; 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=4zPPT5yH4g3srmqRgr/MmJI9wmQx9NN5+pUlXZUXu18=; b=jN07vRd/qWBkwfevQv08Ig305OJZD2pYqM+WlCdUYI/2O0UjhXTn4uJJi7WtO4MvnD MowrnnAjgTcMH1HAsjn6L9alv5QG7Y0sSI2133dLCpahdFEtBK9Cgjz7Nw3CRytmghim 2lwuFr5r+8REbhC6IEiLPL2x62GCaIestPzgCVWdojPTfJKeYhp7Gk5/W34WsSVGeFRs UQk+FTDRbNvT6FMLaeycmG8qP8FJaAbsOHJ3Wg1vovb62IuLwWabfFOItOYKuLWfXLwA ddA1x1dcInttzwD7LJ0nCkyH018GY+KQACguUONYRihmy3R/XC/dd1zwb/6zYtQ1fkVk ZASg== X-Gm-Message-State: AOJu0YwsPVyMXJMnlippn6QNXY3AwctF7KZOga6hD7VKESG3klI3cUMx NvIcQPq/avInyBtJWdFerd3U//huIW+hY2xszO3x6c/t9I7Q6PcBRGY1z68LNA== X-Gm-Gg: AfdE7ck1f+mwUO9Voqud+l4+umTVm7UUeQhE3M67MpFbo0c90+F928T2WoOiaERGwin QNQ/k+Tx8gDIcnAFxGkz3NH+Lt3Jolk+xH/SrYHwNveuovwDeseu2zJnIfRxplB0wrF9c1ZdD3d PDpYATH+paA51ko6YYSl91VEtXpfJu8CKtQ1dmOf54/5iVL1Yo6pOroQoP8ZxNUvVMf+7UemhYD 5jnPU2h2vNDYJZgAgjtm+Aiq8SanE+YYEaLks2ttVYEz0cZsWBQ1MRxvG4na+/ZFFJ4cXr5lLHY w1JPyipMmzaY4MuH5G3WyJKLOgtbeJfCr9GjoOkSqrSua99e9ZxcaSX1tpHoW9sheXpWuK7W6My 24optnGcQYvOnRF/rRGVpMQ/eMwGhbp3S/9+POgCljF95HxJ8goL+3WZpurUSBgzkanCUdG8RBr WeODigMeo0LTDCOCSciMDRjMVNwPuuEhdACZ5RtvhWTPnZaKM= X-Received: by 2002:a05:600c:4f86:b0:495:3e81:76fa with SMTP id 5b1f17b1804b1-4954e1e065cmr134233615e9.15.1784563229340; Mon, 20 Jul 2026 09:00: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 v6 09/23] xen/riscv: implement make_arch_nodes() Date: Mon, 20 Jul 2026 17:59:50 +0200 Message-ID: <0a9656edf379bdafffef71fa3ae176ea62dfe4c2.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1784563230-F580D77B-47B79E7E/10/73395122804 X-purgate-type: spam X-purgate-size: 1386 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563253777158500 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 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563252; cv=none; d=zohomail.com; s=zohoarc; b=Lfi9pYEchD9qj0hg0X0rAGh84W/zvdQzkgTvwsMpkADhYfgOJmtHM9vS7FC7CPFa55liqB2uOktH0E0V0i+UveehjnhLbfwZmOIqMNIhQUtLj1dYNmsiCe+z8dZb0E/SuRSgpxMrhuv/WdQ7zhXYMrVVL0SCisyFKy3RVx/1tV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563252; 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=kj+Ys9sE4vz8rN4cl1XewN5jOlLycBUmGkH75Llh0pg=; b=B0Dx+XGneuKdr1K4BAqNkAvTs9nhhrPPo2ykbpiu8yOnOuV7/LeWdadF4+h4rXZdH37XBYuYQbD0tc3hNKZtQHCvue2g51xiE8dGw7VrENn4sRMaCyVn271jpOlEOFIemdeRlp1oPICwUqM2ifAiVNrs7AesKqGNW7wzmW3yzuc= 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 1784563252708378.3900250454574; Mon, 20 Jul 2026 09:00:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366959.1616817 (Exim 4.92) (envelope-from ) id 1wlqPy-0006Uz-C4; Mon, 20 Jul 2026 16:00:34 +0000 Received: by outflank-mailman (output) from mailman id 1366959.1616817; Mon, 20 Jul 2026 16:00: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 1wlqPy-0006TY-2t; Mon, 20 Jul 2026 16:00:34 +0000 Received: by outflank-mailman (input) for mailman id 1366959; Mon, 20 Jul 2026 16:00:32 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPw-00064Z-C3 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPv-00HTTt-Oq for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:31 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e461b-2eae-0a2a0a5409dd-0a2a4509ec1a-8 for ; Mon, 20 Jul 2026 18:00:31 +0200 Received: from [209.85.221.42] (helo=mail-wr1-f42.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e461f-be1a-0a2a45090019-d155dd2ae865-3 for ; Mon, 20 Jul 2026 18:00:31 +0200 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-47f6609c657so1134819f8f.2 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563231; x=1785168031; 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=kj+Ys9sE4vz8rN4cl1XewN5jOlLycBUmGkH75Llh0pg=; b=VYsJj5lBqGmBbc4NKSysBqPXhjPRKfZZpp7TMehoxDEO8QB38iKr5kj42tsynBaL08 pps/ArSaNpJ7g6q0UeWKoFpVNbykFp4BlyJJsYdt2aBzOUqMFy/1sjkFS/BYZcTGiteE Z/K4c5gxZBfbnNqx8nooG4SLaUPmjM1mWzLAZZBf9Ve0FtcIkxnGpeDWNf/arMFWNoMQ 64SkQBzo7u0CxXjppHhaLwJJkjldYf6M/f50NQ9VuOAm8Iedd3jDfXIkmOzSMqx8pB/J kT/Rxyhg1dIrcvr2dlU585c/mMZ9cfSMus+HFFym6OxcETXybJC6sS1QUyNGeirvLOwh 5rNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563231; x=1785168031; 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=kj+Ys9sE4vz8rN4cl1XewN5jOlLycBUmGkH75Llh0pg=; b=ZEtECmR1VKuSJ0NUFezOQdov/Y6SY911fRgmY4333E7ZpbyrEgxhoQq3dTR/sdgNTO hQ+wwJz3lUi4pTlUdStIlcdAvHAxRw69FVbMvuCbBGmsvxcz33+WW+cd7wLbSut4q603 vRKo0G6EM7DCeEdQ8Hns9aVMmcpZ+UpO+TxmlnGNDwqyBx+RE7fG8ZCgirK62NnFfpU6 mONrARHIgfU6eQ6vxtDUU2c9GHx/5FnzQI6Ffb0yJ7coAxT/07YXmKfutVTGtlfwZghs ca3ghfh9Dw+Hrzc7++BorRswu5Kz7R+q+mO8G6VJEHvVBUPlZAc1hf2AepljlFcdsZNm KlqQ== X-Gm-Message-State: AOJu0YyT0xiXz1BHaVcmS+hhzmzEktGNMy4Sl4ZUuF4BvSj2sput/75q 8f7DAjFbAT/SsjPid070M/m6WtXFvB8efnGcb3NEN+vI2sq/WMr53H0kurlR0Q== X-Gm-Gg: AR+sD13mqes3yplrWciHVZ8d59BdlYDez3g1/SHlGS6J0joDo/sn9IFaV2gzq/oElLm i6yuWX2/hZgdCLr716KSVCrS4FVbNNQzOwyQ2XNg4eCnO5wSyn7abyUO3LWzPDG3nMReLvJP9lu +wQ6qbILV6PNKrbAAayh0VCGxNgJIhQPh5Nd1OMZE/PjuNaAkq8kw7Kllr0mgNd9qTI+zlNlsnS 4dGPPw6N7Ewdk3AIr+vvFnCHhIUV2yJCqOD217o2DO3owT7ZGZRRv+uAbPN12P2GJzDtSWJVq1N BIooqxCQV0Pd5ik/eeYiuGReR1oLbZyJUoKLASwH5kYNPtc0vLSOc9379l4MuOYKe6pRmASet+F rxkY2nWuwYpK5vJTawbJcMqJkCAw4Kby1GacAGuQPwvwAxs3eT5Pqey4wMVKlvHLq/aoAAZAZt3 lWTO/65WNTnYaFYoVAetVdbv6q6K3pOvteeaZSaohzK1yyM+E= X-Received: by 2002:a05:6000:4b19:b0:47f:28e2:d4c4 with SMTP id ffacd0b85a97d-47f623052e7mr16737852f8f.2.1784563230946; Mon, 20 Jul 2026 09:00: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 v6 10/23] xen/riscv: introduce init interrupt controller operations Date: Mon, 20 Jul 2026 17:59:51 +0200 Message-ID: <88db8417c667d027944469a4b8b8adc8e094b3b2.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1784563231-FCE14034-BABDF88B/10/73395122804 X-purgate-type: spam X-purgate-size: 4030 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563253803158500 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: - 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 6a1255c5f403..126d56fb7ea8 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -306,12 +306,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, @@ -347,7 +351,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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563257; cv=none; d=zohomail.com; s=zohoarc; b=hXGhYujolkCck4zX54TpAbuUEI0SByPhJrqH9cBZShFDDH8Y+Ge8h4Ws2yfIbMA45XoOjt2yoblSfKT6o3jxAMyOSX0dxSgsxPeoEZ4Vkeb0LDezoae8CKQI8IogkOEXtKfsaJ9KTJYzKeuzxC1uyJwP6IWte7yYgURA/6q1i5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563257; 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=5Hr1g/e/xXcDb/D7IngZWRsUaR/73i2SVKxkYoNQW+Y=; b=CnYFNV7XS+YBFAGFFrirYO0bZ8xbTiuaSqN+PcKLsG9EDoz+MggO813/wOoh9TBa9LgcKYAT11XittPj6YhVzBR53FIQD0i+1RLMWOTylWxpKiDDJZX2nnLTi22/mZFGxMUpN1vAADVHUuWzLow/pJCpfx1x7RciYtlaHEW26fE= 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 17845632571006.12899652476392; Mon, 20 Jul 2026 09:00:57 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366961.1616828 (Exim 4.92) (envelope-from ) id 1wlqQ0-0006wO-NA; Mon, 20 Jul 2026 16:00:36 +0000 Received: by outflank-mailman (output) from mailman id 1366961.1616828; Mon, 20 Jul 2026 16:00: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 1wlqQ0-0006w5-Ha; Mon, 20 Jul 2026 16:00:36 +0000 Received: by outflank-mailman (input) for mailman id 1366961; Mon, 20 Jul 2026 16:00:35 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqPy-0006dT-W6 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqPy-00AdEr-BV for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:34 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4615-5cb7-0a2a0a5109dd-0a2a4501a09c-20 for ; Mon, 20 Jul 2026 18:00:34 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4622-5984-0a2a45010019-d1558036cd4c-3 for ; Mon, 20 Jul 2026 18:00:34 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-493f75f7172so81100485e9.1 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563234; x=1785168034; 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=5Hr1g/e/xXcDb/D7IngZWRsUaR/73i2SVKxkYoNQW+Y=; b=CJIFCxnfi1ntWNYnxSS2QgyXaz0Ve7929NzTBFCAqC+yqMcbCYXXuOxQqIa9ifhQen DhDybGmXS6UVbfkcyOS+/eZmL0Uho7I87AD6+h8SIejcY+PozwaZ2/KbW0qkdMEpQE7O 8UxC2/RBOb5JzyIEiP+RA3l6VgNhX5Iuzo36skUMc3zYPJRQ4ucDJhAl6YsE0/HtYh0O l4+wNbEr0UeDZzEeXYs025yN+w0n97E0q01mpgkPeMgJesQCWWmCW5U1rzjr0UMFjoEs jP78vhHLqHeitbmg5RaFg81KpWa3A7Es3TDzzAJcitiPeXAgmN+0krzMgN/3rnWu1GA5 0ptw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563234; x=1785168034; 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=5Hr1g/e/xXcDb/D7IngZWRsUaR/73i2SVKxkYoNQW+Y=; b=bZAFRky05Rmj/1wFXvbUb2xP+ogkYKwYMCJYnGeIwCtmC4t4c2RM5XTG8K35bVnZM7 F4aTXMIsVmXrManqL0aCXBcWRtM4At8rw6s9xbzp3SiBvoAdBvgwFlIKtQtgl7h6U3z4 nZvnYr57JijoFyBd/5KaCWXWpzKMcZAmkDlWzqocxrDl8fnxBhFaV9CGEmZC5R4WjA5L 8c+0WUX3+imGcGLuUuGoJX0z4uUpbjaUSdKZB+nE72wI9tFem5ZR4sy66qBt5h7szwCg z4sXoiVnWYgWjPZJRLxS3xmFU//YDlxxNT2rgbJV6jc/GmaHs/i54W/bCKZGZwgwXRRB w4Sg== X-Gm-Message-State: AOJu0YwHDJeNTRnTvEomhueOV5MLiQ2ah/TWxzBnXl/6euA9W+G1QQ1R UN3DcNf+oYbn7fXFolgdn+kIyer+ZpdsXAAXtZcX7+LQ/OH3fEQPqnaPuyN5zw== X-Gm-Gg: AfdE7clw1vnhMidIDGG/RCBFkJxGRRhWnZbX1vFDQKr27f4s12ypkGsoq0or0tZ/9jo Sb6iKm566/tcheSMc38my7Yy3irExUEGxqzSJVu1lpyFGThMQLmdfoweza0WHWd94giqzUoxEK6 5Uk6YcPuPm/naguZNasA7m72LwkzXIo99cYQnQ4WRh6UG2XvPEEoJGUeXM2NC2DHmIQrduOTjSR z+nJDAUN2pWQBd8DtYSUyNzFnO3Q12dFR8slzQey5bnX9lTDoIZSVNEZi8RhoP02CXCi271xP9G JOahfsM0pE0jjubpm4h2cKU7n7+PWcmjReOAFklfe6E9BJd0BCbMWsyQThpJlQ0lRNTMkocPpfH h6Hjjq+sIrrB45dmoNBeMn5SssUj2KZjNqOiv78eYVd3RaBrXLGip3EhN3VWZW6wL6mUn6/iGtN bg2Y8S5Kid82F+a1Z1sjxVbU564MBDR3LoeMN9Ng9RgWdq0BQ= X-Received: by 2002:a05:600c:e54a:10b0:490:5057:f5f7 with SMTP id 5b1f17b1804b1-4954a3ed516mr114597095e9.11.1784563233430; Mon, 20 Jul 2026 09:00: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 v6 11/23] xen/riscv: implement make_intc_domU_node() Date: Mon, 20 Jul 2026 17:59:52 +0200 Message-ID: <93a8222f2033567ea207d4c81b509cb32701f9d3.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1784563234-C5146757-AE09C739/10/73395122804 X-purgate-type: spam X-purgate-size: 3437 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563257797158500 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: - 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563254; cv=none; d=zohomail.com; s=zohoarc; b=XRswoiCGoUwmyBwz70ea3MsE292V6IU80maUk/bdN980kCMk3WVC/ngw3eGZsFxSVmfeDSLlNt2NR3c2hAaYceyeuTLQ7QwNoWLwJ3d+qxLnlqYiA0J2W0HJLVKBm+ft5dgvsX+xzFgQnBmX5LJVjeAfcOvpIktW4gEXJMK4JKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563254; 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=bw1hrTkQ2ATB1SLL0iu4tNbNK40JrBmaLHXXypeFp0c=; b=e1m8wYCRVWKUlRf1HkwXXwd7B5J13OFEPR7q9izCTVu3wl28o7uot9n9Hgida2jRGUXYMIos1/2OFSj9wwulk8CxY5KiYmcl89qSbj6XR1CyuCel3MyJxKO99lcnd+VMWNIYWrs4xopKq327U5JWXVekY0hVl1jBsA1oUmzefE0= 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 1784563254158570.2277198571292; Mon, 20 Jul 2026 09:00:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366963.1616836 (Exim 4.92) (envelope-from ) id 1wlqQ2-0007Fz-Im; Mon, 20 Jul 2026 16:00:38 +0000 Received: by outflank-mailman (output) from mailman id 1366963.1616836; Mon, 20 Jul 2026 16:00: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 1wlqQ2-0007F6-6g; Mon, 20 Jul 2026 16:00:38 +0000 Received: by outflank-mailman (input) for mailman id 1366963; Mon, 20 Jul 2026 16:00:37 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ0-0006ws-Sw for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ0-00AdEr-9U for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:36 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e461a-5cb7-0a2a0a5109dd-0a2a4505a692-20 for ; Mon, 20 Jul 2026 18:00:36 +0200 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4624-4cb1-0a2a45050019-d155dd33f1db-3 for ; Mon, 20 Jul 2026 18:00:36 +0200 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47f7872abb6so520820f8f.3 for ; Mon, 20 Jul 2026 09:00:36 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:34 -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=1784563236; x=1785168036; 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=bw1hrTkQ2ATB1SLL0iu4tNbNK40JrBmaLHXXypeFp0c=; b=s2xuyZgC9l4bMLrmjMxRnRscz/ReOB0pOL+tgBnQ6DzQgcbkKFAi5Wdxhmc356KS04 1woABZG+5kPhNmCbX66LmUAxtu0hpo3xwBflALv6GwSGmLShUJFsUvhtthcYy8tSZFU4 NrdpOl5937cQ2fYkyZ2m7sDOrDlT+B6fVp8Npd9bR021OdQl56ejBji5xwz08HqIc9rN vUDZ0KArD4BtjjJJaCAv96nKFI+Knnoz/F2ygkK5ZiyuuXYdlV2Shrz1QTb4c9/M0uEW O2g2Ls5uUk61ddnSGr2rHV7ckKjFBYpSUk4VfxGcCDAg4Gm2TlVOViGuaVhbrF86kzSt l/qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563236; x=1785168036; 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=bw1hrTkQ2ATB1SLL0iu4tNbNK40JrBmaLHXXypeFp0c=; b=MLVYJgcpGDq77fGc+fnSpcoz8BqsZQuNpwlvv4zwQ0yJkwVgqnbFP82QwdeQbcJaXJ OCKtPufp4pOipm5C4rz0Yi2kzei41nJtlJgk9FLFnJn5nd4Ccflk84hPX8LajyC2EF/C NLmZE1xpH0HfP19EmRl4Hf4fSY3ckj8rzVYuqSdgbKmaVquziiE35ErSLaz1noGnG7/D tNnbjhl5AILwfmK6VWcw7lI6jjHv7VwOiwlVt6oNBlLgYdt/rQdxit+isLmqJLRk1nUM RGgUbM42u0RNyw+TidrQsGeiQOG2fv5QKEYrOGpOSKgTb80+Tb7mC3On5BUDiTQm1cCD x1Dw== X-Gm-Message-State: AOJu0YyCqsR43KrFa/RVQepPDBjFycZCpjJOAufe7lHqfeB875gHAGQ6 95CvK2Fr5pkjokNXh6WmJLfrK6wMCSVnTV5rj7Ie1lbfn0Nxte4fq5bWMAcYgg== X-Gm-Gg: AR+sD12rDqJNcAzxkR6RMog70lWQqbq3IYWaeMSNIeiSr7VNUWJO8FYzqyDBjTJQ408 sWTlrxCA385MwzIHnrfourBi6mAIrz9KY+SHRqIDDRkbVEPGM1NY+onJXsm27XV/xyb5SkcS9w+ x8Yj5KXQxp1bzkuEwpLzP2cx6R+2m7v6zaaFWh3Mg1iJqZpmOQzm81yLLrm0LCGyE7bodf5LFuT FPQCuYkXr/5rXVZU1cAU0W8c3vSGxAdwY+o3+WMg7kaXw0Ior8Xr2cGC8n3fYzuEYLMu1Dh+BYh Vc3YmPShnZaYUHvwFjmBZg80k1Lr+OEejMQ8h/72Aq5jUjJPziD3Azwwv+yolpbCwHUXIo7F+xc pdRhDdJigvQHsLAkDC2ur1pRRzDgIz0LtObxpE1axFIe7lPbMsw66zKsznJG+a+IAu2YaK4eXX6 R/KwuHzu0Pa60OhdL+aMakSuEmBbo78cmtaCpbVCXGGA7P86QKmpRfwzAslw== X-Received: by 2002:adf:e190:0:b0:47f:6981:a043 with SMTP id ffacd0b85a97d-47f6981a0f3mr11625636f8f.26.1784563235540; Mon, 20 Jul 2026 09:00: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 v6 12/23] xen/riscv: introduce aia_init() and aia_usable() Date: Mon, 20 Jul 2026 17:59:53 +0200 Message-ID: <5d8739f32ae69ee845559ae1a03442e1a583c39d.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1784563236-730B22A1-55F362FC/10/73395122804 X-purgate-type: spam X-purgate-size: 3183 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563255741158500 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 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 fd5e499eb4b9..9df8b72b5494 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563274; cv=none; d=zohomail.com; s=zohoarc; b=WJQmLObdP2RbpzfuPD5mksKpKYY6WRMKPSlhJeIbUPQS+msPjElq3ZMWdMr+plVEF87IMDjChF36AQafdpUsxoaU9Gm4ZNNzxxOpYnxwULeaqbAjLIYwJrfr1stq8cvVS1fDbG3eW3lBZWOSdO6QpFiDhHepuXBjMaYnYWuutKE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563274; 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=Nt+NrnSnYUFOVhjqk40/HqYFF4+MZAvheFHPqYsSxEw=; b=YXN8yCLFTeTAkj5erbKda3tk5Hp6hh/fJUjfN2tmg8RGM+M8yyWC+rDlGL5cpRZlETVASTxx/y/pY4WpJmRpkOpt+wdpTYdNoy/Ijd1AVixtAqlNhOTn4ALOhdogioL94Mf/R7oCILUBruGatTlfswQ7fCiSVkN+DPQh779bKOY= 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 1784563274225192.81992435293148; Mon, 20 Jul 2026 09:01:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366966.1616847 (Exim 4.92) (envelope-from ) id 1wlqQ5-0007nV-ED; Mon, 20 Jul 2026 16:00:41 +0000 Received: by outflank-mailman (output) from mailman id 1366966.1616847; Mon, 20 Jul 2026 16:00:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQ4-0007lj-UT; Mon, 20 Jul 2026 16:00:40 +0000 Received: by outflank-mailman (input) for mailman id 1366966; Mon, 20 Jul 2026 16:00:39 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ2-0007Kc-Vu for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ2-00AdIU-Cr for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:38 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4615-5cb7-0a2a0a5109dd-0a2a4501a09c-24 for ; Mon, 20 Jul 2026 18:00:38 +0200 Received: from [209.85.221.45] (helo=mail-wr1-f45.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4626-5984-0a2a45010019-d155dd2db476-3 for ; Mon, 20 Jul 2026 18:00:38 +0200 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-476d8e647e9so9386703f8f.0 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563238; x=1785168038; 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=Nt+NrnSnYUFOVhjqk40/HqYFF4+MZAvheFHPqYsSxEw=; b=C8fFM7xShaB+BSJ4rhxBsU2SqDL3TYZPmvZ0zXikqJBbIfSg6WbN1LBROKz+rR+wHt gv/UFLFj04bt0nKqotCWUR6+y+PW2bAK6GYYi3JXHWmOoW9bkbFZIwQXriA2ZXaYUIiV dpTU4IzEOfAfEqTdIAisgBQmcgKK6pwOR0y4IOeeKabT4lXHCxUt0/Fh0yrQQ5a/rxIT z2otW3FY4IvAVnCaYo+vP5PGZhcECuV1H4crY5uGrX5eQHHo1VXhfuXxYz4wNUNJZ1AH 0ipqT6zjVC6xS5snEaWFHkag47krYapFTrf9yytDe/FAhODWSVY2YCJBPs6FMZiJjwsZ NNwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563238; x=1785168038; 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=Nt+NrnSnYUFOVhjqk40/HqYFF4+MZAvheFHPqYsSxEw=; b=BV/arIAYhSMHppjYSJUsvvBGyqZ+wPuJb4cnXp7EsUHfK7727/dl72UsKnTw6hNKxc cJ4gN0wPWZDqcLFbZHLrJ/PuEYZ1hP7JyJ96U4qKziYn0tWkCcSnHWSPu5JF+Ys30tP+ vzLJwhlpC8nE2wlVGcA7S27kcmmVreJ/ExPDvNcNUXrnBNgviWL1T/k+7jtbXxS8SC6b eYObiK7HMH5yaVPZIGFTKILmdsceJhQC+MT3MgbamY6GF407yAREYAizPkj+yst1FCq8 2NfeL7eJIUYr7jkko733ijccVzl1VX+DExo9sqP9CTZ9SlaLtz0bEKn1/u/anSblM0zi S2bg== X-Gm-Message-State: AOJu0YxqECQbWLPZqmyOt4H3gYenCGU/MYU7bbrFGcuNFOK8W7XuGWdT USnx059qD/44FpG3zeRHKsr3S1mA+vn9hdqtANCyKiyg9xkWoqjg9DpTvhQ1PA== X-Gm-Gg: AR+sD10s9Gy977LDzuAErgg1gxs/SdUTbKyUZPagRTNTzHTbF+XnhB35xVHYo+v3hwx jvENxQCUfcurrnDcGSof9feiETWlZUJvEhutWlUGbHbWCL21j8PsvB8N89jE2EDbZjwv00PEL6v JoEe0Qd12/gASTQ8vW4j/rIJ8ECxmKHtCm0Ak1NV1p9JFIAr3p6GN+UItUN8syOZkPpCnqZRiKl dKgo0JoZxqlG2UoNYlSlRmL+Xn/+hqvXuDpv0jvYd9HlP4uC7lZZZG2MOklqNCQORWO5nWKB1ds ZcvzknjpSZ3rsy4UXJqIhlVuX2C8aIk56ru8S2afG9gobc1AmWGSXOW2U6OeMVB4jZHlV6pjjB3 om0rmHV7amqEob0dP9/3oea3UURP7avvd1xUF/s0Q4Hvr0npTqo9Y41YP6ApCo7yPRkLOsM5nWV oUv9Nn6WHbZ06lRq+JjJGBNVdrxOXXGazJ9EQKKv/nqDBK5gd4CvYXioGWgQ== X-Received: by 2002:a05:6000:26c5:b0:47f:73d3:bfc6 with SMTP id ffacd0b85a97d-47f73d3c168mr8281995f8f.46.1784563237647; Mon, 20 Jul 2026 09:00:37 -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 v6 13/23] xen/riscv: introduce per-vCPU IMSIC state Date: Mon, 20 Jul 2026 17:59:54 +0200 Message-ID: <6bbe9231eed3b1c1e233828e6658940eb0bec749.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1784563238-1F063757-5D133E5A/10/73395122804 X-purgate-type: spam X-purgate-size: 6433 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563275974158500 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 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563264; cv=none; d=zohomail.com; s=zohoarc; b=BuRtzxI4bu5pMB/v0PgC9Ft1JO+Xs5yRj0NbGd6skPFGeMmjXranRmSTdJEdkjheVaVojZOV3BVl9YISg8NzHKwEz4bqu8jGlTEfEONy6NfxQJ059wxwNo6X/Py0R103ZIvWMCa0QKy/o/5seZH74mqwb4DpHEnK+M8y99Hozxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563264; 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=SRI8/DhJqHkfjtaOZ5/QBIWxP9MG6J3k2xsPuJ3HNgc=; b=VzJ8X5JgRaQovgswu3VKujG4iJLfOkjPwJQoZwA0GKSMYigfLwNp5cr8JrCg0A0yrnqAY0dbo4YFkpRMNMlr2RPvvVhcgI/2Gj2nMMTT9Dbx1v5YQb0R/ZQnOOpnT0r6hbzov87uXWZ/aLjE2+AWFHXCTSKpjwWWaGLQh8eFmWs= 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 1784563264010154.6925120689632; Mon, 20 Jul 2026 09:01:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366972.1616851 (Exim 4.92) (envelope-from ) id 1wlqQ6-0007sS-1i; Mon, 20 Jul 2026 16:00:42 +0000 Received: by outflank-mailman (output) from mailman id 1366972.1616851; Mon, 20 Jul 2026 16:00:41 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQ5-0007qk-Ia; Mon, 20 Jul 2026 16:00:41 +0000 Received: by outflank-mailman (input) for mailman id 1366972; Mon, 20 Jul 2026 16:00:40 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ4-0007fX-FV for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ3-00CGik-SJ for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:39 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4610-bab6-0a2a0a5309dd-0a2a4504d308-44 for ; Mon, 20 Jul 2026 18:00:39 +0200 Received: from [209.85.221.48] (helo=mail-wr1-f48.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4627-b57f-0a2a45040019-d155dd30edb9-3 for ; Mon, 20 Jul 2026 18:00:39 +0200 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-47ddf7b09e5so6479433f8f.1 for ; Mon, 20 Jul 2026 09:00:39 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563239; x=1785168039; 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=SRI8/DhJqHkfjtaOZ5/QBIWxP9MG6J3k2xsPuJ3HNgc=; b=szeYuEgwK5CZ/ava9190sMy/dAUSa/MkTdMbeDfaAyZ24CY09lbWD8mIY4PriqXDb1 bpmsyYteqGhIOknNOGHMvHqbFhZ3PHDJ/HKQXrkRwhah7RAtsoUSZppeSQxcogbpVbAM M0vJSl/MbZvmW2f6kbntCqgJUykHdipi5Bzca6Z2kzMp7LGtGoiYcl7Eh0bLcoIdpuyN Qt4apDmqJW7VX0w/nZDcB3vWBpovSuvp3qdLMTKkZYvnolvXQL0VZtqAl/b+5FmGcuoj Wsr/1fIe5exd2NSln+k4s7Pd8Hy8dLye6e+zTuffVqg2fmliDpcF1HfysojHPkoTXSL4 E0GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563239; x=1785168039; 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=SRI8/DhJqHkfjtaOZ5/QBIWxP9MG6J3k2xsPuJ3HNgc=; b=fvzYzvh0rK5CbLiJX7ia0rdCXmcvIwiqFI4zbvjoRMzFMSYeL9LsH+b+K7vfdLASQ4 kyvXaeDlY8AFUfCGKwLyDPcu2gNawzYcA9858Pg9Rkgmp3RSZ90mtVNU0HuDwMyqGGej I4EQCaY+565WkbBXd14EkQkm1gxLtL3f8ol3frg7WsDlM1pIdotrKRFdl6Y1FG9NokvB JaP8RDguuPWAKUSJuBSyb8GmYDOYfxIaTT8qTlDFNZD/+bOfKVJx+to13ajXXn9sd14N eefat7XSf3ZKmzQtAbWgoZyOgPt9wGu+zWpO+ZhFtDYfO7NWA5wXBsY64yHf4ttadV/w gVcg== X-Gm-Message-State: AOJu0YwHXIGO3xi7mwHBk/oIv/1B2Rcebw7lK/iOtTHmh+ng6sBW37mi nsNu/L1ig+2qZuDouKV+EiAqwQB4/WgNhVAbyTYnLv/NvDI5J6mNgPFWlsXriw== X-Gm-Gg: AR+sD12qotipgrIo2PYekrctP+vmZTthPpLVkDo8UAfGJSTiFbXz6svpcMLb23DdWpf CYuVNK2XeAf/7QrDyKXpQZj0kqA8oHW4i+q1iqMY//H1u1FKwzCCQnQ9rIdzBO3zTZqirFK14wH MlolrGVUtqO5HqfXm4NWiGp5c+7Aw53YITcSvtXHLm5pYeTOp7LB61MZix+btcrATLOUADkDPbd TG4askqAXd8dAZ5VvcGy6joBOOG5XHtYHUUI0BuZhPHuvDmGJJraFU5uKyIJDBs8FgAunAgBm6V 2dOcx3OWoYZ5EyhdYpWy5O4i1KBpqEUNsqngnac7niwPz5maktMtjxeKkL560t+PZ/PXo23BNHC qWhWz2vK13LL77hhAHGit0Dkc3W4fpp99pTrhLGetcDWq3HORbLfAaAY45zsxtW0Ae3MIUiqVru 4wpXQHrW7ZSZ4KMeFHFN0XEvjLFr0dFy3GODMSuYMnELDLjoo= X-Received: by 2002:a05:6000:2dc5:b0:47f:73dc:c5aa with SMTP id ffacd0b85a97d-47f73dcc5d1mr6702810f8f.30.1784563239041; Mon, 20 Jul 2026 09:00: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 v6 14/23] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Date: Mon, 20 Jul 2026 17:59:55 +0200 Message-ID: <98bcad12ca4e5ee270cc1ef9db09d89a32f863f8.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1784563239-C1CD7B50-FD7351B0/10/73395122804 X-purgate-type: spam X-purgate-size: 9390 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563265893158500 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 --- 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 9df8b72b5494..9d8d21b65188 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..5330666e139e 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 { + /* Used during domain build only; dropped afterwards. */ 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563279; cv=none; d=zohomail.com; s=zohoarc; b=dmCCDB2P/shMJ2BP79krM8DSIA9DZPL1/T3NWFpy4BH2q53Z7P0P9Pb09chc6xHmwdmZKis+qdPHJeXF5PcV0zd+CuP15A0CPheh538/SkVnXLYdqZ4W88iEg2qK7neLIi9NnDtFddm2um2KtmW8XIB6TEvBqgbNXmnMK6REbcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563279; 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=7PR8dTPk2Iy7WHpPzeSLIaD4BXd6K6Qr9Xmib8pSojg=; b=iIouDH1kyjXaLlrOb52ZuO+CgGdsLwxNmjG2ln+0j4cG87AgeGdQpzSRYVgvSpRe1A3SLpEJRIm1vgoVJVbN7S0Hg2PdzqRaTeiusVs6MQwHjAHahf786183cCmzLMxbsh6NvTs39bRQeUw1MB+ChBDzRiTwCra/IGMFL+UPwxg= 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 178456327923645.469673698461065; Mon, 20 Jul 2026 09:01:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366979.1616862 (Exim 4.92) (envelope-from ) id 1wlqQ9-0008Vt-Dy; Mon, 20 Jul 2026 16:00:45 +0000 Received: by outflank-mailman (output) from mailman id 1366979.1616862; Mon, 20 Jul 2026 16:00:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQ8-0008Uj-No; Mon, 20 Jul 2026 16:00:44 +0000 Received: by outflank-mailman (input) for mailman id 1366979; Mon, 20 Jul 2026 16:00:43 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ6-00085f-Sc for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:42 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ6-00HTZO-9C for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:42 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4615-2eae-0a2a0a5409dd-0a2a4503ae26-44 for ; Mon, 20 Jul 2026 18:00:42 +0200 Received: from [209.85.221.44] (helo=mail-wr1-f44.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e462a-fae8-0a2a45030019-d155dd2ce029-3 for ; Mon, 20 Jul 2026 18:00:42 +0200 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-47f3b39f2a1so4922713f8f.2 for ; Mon, 20 Jul 2026 09:00: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 ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00: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=1784563242; x=1785168042; 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=7PR8dTPk2Iy7WHpPzeSLIaD4BXd6K6Qr9Xmib8pSojg=; b=F7eJfKV2Rexz6eN/YHHtkdxIiH3lJrJEgG1kfJXXhIEd+QJvWaIoFipDTe25G0TH1R J80uOZ5SIj3Skv8mGYwnrUpf/rN90ruJ0c9KQnCvpcbu/iW2xU14Y8pVh0ddJ3jnhA+Y qQ5V8TPn9MFyY17TH/c7WL26W2WWzhyf5Z1lsnxHOSf/pcJRYlZ1Dbqms0yNSMQpj/wc lfyOxmDPhn3GSUA7yaut1x6BT6CPzBObFL8/j5k15CslFjl10ALKqe+NBNqmAxq+PwD9 hAQ6NyXAgiXb8RZ/kLhVP0NIB5lLv5yJgSQJRZyxkOxKh6SP7fmoShCnfJWwYkWLMiwg 6GNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563242; x=1785168042; 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=7PR8dTPk2Iy7WHpPzeSLIaD4BXd6K6Qr9Xmib8pSojg=; b=nnO91MWfO2du+1/AzcPkQuu1Rls6HI2T7aBCkhGjTbMnPGpi1ULUzSKOTkf9aK9pZP doEte33Onhf29WSWJ7x4G65tyWHQq8OXwAMcS0Nfw4o9xpoVWVlWkZ7Mgrh2kmZ5V1Rz q+bXZs0c5CHwGAzE8JPtER2ePLNfJ0L/g3OqC1KdFDGc1N84w3TQf8SwI2u5PM8KhQwY HksRBx8sQq+GCb54LNVs6mh1RFUn5tU3cfcWbmfM52/izd80VSxC8aw1it65/9JZODsh WJCAuCW2klXAItmsqR2lXh3Zs5/chJAy07vmQ3BIcrN5rD8CR2dXFSVR8/TmDaPvDbs7 CXTA== X-Gm-Message-State: AOJu0Ywk/8cZGyDZ+bj5zUtAR/e4toLui57gxbfj7N8HLPGL6Zt3GB9Z dg2W258BfUA6TT4x1pLagRAJyN78udZ7BsB0byLIbedXbANdunQJDCuxdSWwlQ== X-Gm-Gg: AR+sD130cKYyHaVRjum8Sa/kkvHONhe5G+htLJN6GAA6XTcGzwuOqE9VbcUPMGsxUqq p8cxa7E+qsufPwwu/Vtb1PzsUeX1WUNu8x1IHGNrYY6ns4bF+UuVLi7giPbwbIlirqK9etqT7q+ Xia4d77EXVqged/Vg6i6q0uVdx455p35jnjwGem6VEqSFbQRfp4WOQNlQS1kEctf8X1yMwz8Sry BAcP70IQ8wtuJbYbz4ZTuxBO4ioYhf7D1JLqXl5+6Lo0eU6X3Nbxn0sPuH+eE46X9l8uLMaqj2z ASgSDp///sJX3BixpqYiME43C/TyD52AgRZV64ZarNmbdCugfGv9zjpFZ1E7HdfanIHrESJJWV1 I4Lzw9diMe+AD5Q6kUufsT3haY5pXfnqgTGE32O86xSXzulnU1DWl7+GGGkq72g6WIbRm4EHw1t hWafaf0GWcPgzcwzb9LMvUI6Ay1Y18kJUlDSZAu2KLGazwo5s= X-Received: by 2002:a05:6000:188f:b0:476:8d5:cf34 with SMTP id ffacd0b85a97d-47f622f2c57mr17730288f8f.8.1784563241247; Mon, 20 Jul 2026 09:00: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 v6 15/23] xen/riscv: introduce (de)initialization helpers for vINTC Date: Mon, 20 Jul 2026 17:59:56 +0200 Message-ID: <13bdc64635f7c87b7bb574bdf3f3139422fa8c59.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1784563242-756834E9-E96D372C/10/73395122804 X-purgate-type: spam X-purgate-size: 3633 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563280007158500 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: - 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 5330666e139e..dad4c5fab08b 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563268; cv=none; d=zohomail.com; s=zohoarc; b=RYtGbhEgpKDlOSQYIyLf4rw/pyXb4cBNdi3HMnvfIjgWoGo+Z73aygICJkdMIUBwtIpyF6Y8vRVKQxEzqUYbyhVfMYgN1tRht4KvDlYrSrHsO+CX1YLRS7RpJUrruey+Pb3tNM7cEa4v2Nr8dIdIH2NI8k+5V8Lm+BDYpUzN5ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563268; 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=NbuRmpC39myLZBOcrqwxf/JV61XKJOSd3/cfGeKXU4w=; b=PZbiG9yAe8yOP979QKzwHXGlkpS7h6PbBM55Lwv2lqCSItHb/emOZbeH5XsTtipX2rKFvRbiai1rPHJa0gWsPzUD2wdEXMRzMvWCGJOw92EgLzYI0h603smoed3hb6fG2bEA4/TjczSG6SV72URUpmS58LPVnMH0niGESmO9trw= 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 1784563268466421.63681524693095; Mon, 20 Jul 2026 09:01:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366988.1616867 (Exim 4.92) (envelope-from ) id 1wlqQB-0000Ry-0a; Mon, 20 Jul 2026 16:00:47 +0000 Received: by outflank-mailman (output) from mailman id 1366988.1616867; Mon, 20 Jul 2026 16:00: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 1wlqQA-0000QN-Jy; Mon, 20 Jul 2026 16:00:46 +0000 Received: by outflank-mailman (input) for mailman id 1366988; Mon, 20 Jul 2026 16:00:44 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ8-0008OC-BE for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ7-00CGmJ-OE for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:43 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4621-bab6-0a2a0a5309dd-0a2a4506c59a-20 for ; Mon, 20 Jul 2026 18:00:43 +0200 Received: from [209.85.221.44] (helo=mail-wr1-f44.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e462b-195a-0a2a45060019-d155dd2cbd28-3 for ; Mon, 20 Jul 2026 18:00:43 +0200 Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-4798bea72f9so5375167f8f.1 for ; Mon, 20 Jul 2026 09:00:43 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:42 -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=1784563243; x=1785168043; 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=NbuRmpC39myLZBOcrqwxf/JV61XKJOSd3/cfGeKXU4w=; b=AtoosRv9v35cl7kMjhcv8ZPpF2Tppo2jg5Q65uLySIWEuiKShAcdxXCR3yCiyFM5+m BKaWaTp5aCnsMfJN6vaJ/HWPscKwR20nsf1wTtpb2pCPOWR6ldq3HswOuMjx3d2mu6oK jZ1cjItVD6cw1fhhtMSxbS8kNDEAgJKdmKtM33MLs2aqHMr5TRwXeAy51c5newz54p8G B2oTuHxn+wsCOq2uwMqORMLNXZHtNks3vdIl6XLdRSoB5CyMqEzgMrztBicGmlOjZ24Q puS1eEm0wgPieGYM8ZxAZ0n1+Lj5Lt+wZVHlKcAhD6AOXh/F6dzL6NHBI726EgH6pMni wneg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563243; x=1785168043; 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=NbuRmpC39myLZBOcrqwxf/JV61XKJOSd3/cfGeKXU4w=; b=ex7bnpqgeTxeAX3BtFJAkU5GT4VPVmcX9UfeVPAkfcYz93hJnKFsRXLIwXWeBnyQYv VjrMR642TZ79bjpUHNXa9gvx1LT4tBlC+778MYFs2trR0XOcPyT2sRdX3mZXwM5G9d0n 0CELIKWkUyYBi3AFFCRRdRDHdSbhWi/ODfNodFt2BrD4c4UkOjvAUi1O1dlIwDUciOW3 cHW1jWxPmSPVQ03TWAmaubgJP1YU2T4Lm6vfjBmp5hw+FjT7p67NfRW+6vD3ysDqPmgw 4Z+P2xNSAriDc04wYc94nOSieynOTx3fb0rTxZQdVNzv6XfMe2EdYSO9voXmHhWIEldX feAQ== X-Gm-Message-State: AOJu0YwZ/hDaStVHOj4JLNYAp/mDoG886AE0C5DSVtDkAH2N9sdI8hgU NbwGF44XK/R0mUNuP4FsG33EyC88FZp5UkdPbnqOoWdrMCdQ+vwakble76Cl0Q== X-Gm-Gg: AR+sD120woPyqPJ0NOXzwZE5pbw4XCjaMMTRm8y9vYAUzqGXAeZyKo1vRaMqo+v+69O a6PVGJNZU6gowW5AptGv+ZfcV3fqhnJIh9UcLP+yt12LfF5GwPKSJiMsXcWkbWKulPdL7p/1gcu VtXsSFRkgtgWKRrFFkItlbGBczD8EZr7yfGczASQRe1OXJ5opF0oCm43elk2miWHdkxTL0YgspX mSnKON2bVpnaAOPb7dq3JEh8SzOTfNtgZBhpfX9zY5eG/AmLUuwuVArYWnjk8h2gqQe5awXlHrr /1vwH14iGjRKuHHAnTAx/KSbG9TuPmD1Ycv0Bjqwv6CJ6tRLHUoGyWsujHfH5GF854RLGxUL/c5 nJv67j+I4iQstvXzIdXqiuC5W1a1CXXGh/GgwdCO2SDYmMQAmA3aBzt5sLpP4SHPbxDnEJCrVFS 5RKhsdRjGL6XTKUsc0aSON4FIpZ7eKwdpKT+iuhuaN7AezK4I= X-Received: by 2002:a05:6000:ec7:b0:47f:77a8:7e20 with SMTP id ffacd0b85a97d-47f77a87e95mr4561762f8f.35.1784563242953; Mon, 20 Jul 2026 09:00:42 -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 v6 16/23] xen/riscv: generate IMSIC DT node for guest domains Date: Mon, 20 Jul 2026 17:59:57 +0200 Message-ID: <332481b9d8e17126a1ca9b52c6e7f0fefb34ca1b.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.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-16d1c6/1784563243-F647377B-A45CF9F6/10/73395122804 X-purgate-type: spam X-purgate-size: 10617 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563269941158500 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 --- 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563273; cv=none; d=zohomail.com; s=zohoarc; b=AY0I5VqqhusDaF2AxuWY3d33TBJiKEWTmRd4sO9z0lfYLaNsZx14ppacOYZQwUrtHcvCSjISVk5dRM6cBVz75LC3o/6wGttKnkhpet9Iw5tzFauaCGj8wDOgjN7xW4gxgtXLPr/dK6uOduKoH0qVxlu+tWdLqBtPcN8FqsYtHZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563273; 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=/v9AJtlwqp03/iX7Ft7ZUikj9vvUmz3xSjpbTVKP9RU=; b=d+FUQU4964fjPD12TrWZHz9JhbVKYKp4EA4ooD6mSGz/mufX9kvtstfYyh67iwkc924NujNw5GowN+cnXkZfmeGGqy+ok/xIcRtFt0iThMLAnIHSYEzU1DSfe26glslIiqOEq9bR/lTcj4GymUwGH3PwwyPE1ChWR6lqvCcUk6c= 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 1784563273101630.5042313042802; Mon, 20 Jul 2026 09:01:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366992.1616877 (Exim 4.92) (envelope-from ) id 1wlqQC-0000nB-Nd; Mon, 20 Jul 2026 16:00:48 +0000 Received: by outflank-mailman (output) from mailman id 1366992.1616877; Mon, 20 Jul 2026 16:00: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 1wlqQC-0000lS-9W; Mon, 20 Jul 2026 16:00:48 +0000 Received: by outflank-mailman (input) for mailman id 1366992; Mon, 20 Jul 2026 16:00:46 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQ9-0000FN-Vn for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:46 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQ9-00HTZO-BR for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:45 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e462a-2eae-0a2a0a5409dd-0a2a450c925a-18 for ; Mon, 20 Jul 2026 18:00:45 +0200 Received: from [209.85.221.48] (helo=mail-wr1-f48.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e462d-f479-0a2a450c0019-d155dd30c02f-3 for ; Mon, 20 Jul 2026 18:00:45 +0200 Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-47f64ca1c2dso595671f8f.2 for ; Mon, 20 Jul 2026 09:00:45 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:43 -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=1784563245; x=1785168045; 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=/v9AJtlwqp03/iX7Ft7ZUikj9vvUmz3xSjpbTVKP9RU=; b=TiL0DxML06IMTkiLQk82n3XWti5bxr5RxGibbFjJWZJneV+dVXf+j5bbSsP92JYoi9 I1J2+CGQqo95CVhysrxfIi1iL2jH5a45PH+x0s0ldMQNLwZrKvEXh7IgAtF+Wh8H+MCW xXBOyX/a7kYTkoX4+NqTphxbapK0KuzIdNV03tynWRYDYLh401/4eOPcfjDq5Hkqc4K6 0lR+4wPcv4aYazARnVqWZKAgY3f2ycPPXas3qStkJ9I2oLe+v1OXskclE/54MpR+zLLq rf5llBbiaRTZWIHbYxoP4KwO91pimy1ZPyk1BWZuIwpxVa7j32vV8ALBQjZHSR0cpFrE vvMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563245; x=1785168045; 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=/v9AJtlwqp03/iX7Ft7ZUikj9vvUmz3xSjpbTVKP9RU=; b=QanBWIK/rxnpzw6rGcVTXnnaM4eb6Pm4KywTJ1Te7Dt/g0D7N/Cm0eNGMjLCLxbIy3 0NE8QcIPknmX4VDC0RU9Or52HdH3vyFP3eNpeyBUNnC+Nsxg6ZQep1RSSBzAZ9YcEFy6 ViClv+yKtcUnHn2LCwL/fVvGFugPVSe9J5ggkHtEkGlbs/Q6n2AJT2qrL5C3oTrbubWC QlEx9exgXUNHLi5osyBSc2U7yuKojHjmJ14yzCHwZVraaf5yzVZlawVfwlcRiAtJGK98 W6MMRsA4/hnCTITYp6KvDuljV03qJSzFrkKTIz14/Ht/NIk7K8xNHbfbX4PEghq5GhTW PHyA== X-Gm-Message-State: AOJu0YyYwPXmWIdtSd6IrX1dtjFd8PscTcFbSG3GQU62cCgBS+VJP9hw snAEGcbQG10R3BLMluNyWUy1dnYx/MqrcMreW0JJJqlpAsJgHBYX702dLVACog== X-Gm-Gg: AR+sD13NiOYvXzgRzvMp+bzGfswwYVpGZJFCp6AWe+2MwhvyapT8/NX1oPQLRt2T51+ K5T3f7mr4NA21XUa989nhr2Hn+1wcFk93VbznEI3jWGsxy79o2c/4PT+A34BgZZ39KOK71Tdxmf ZsCtsz1RaJ7XMORd5h4QLvpimHusQCadW1dEZGy/0RKtueWoPJdPcdoCh0rGx6Gt9KhjBOuKdJO pkiSx/5U/d0vKjoFkdUlckt/nDPWp9wPDnA7IEpBWEU3f674fFOYl00OyF52UmueZtZSHflKZNi FDpcYvT8culKrjX28CSpJD/RoRjmnMCEEpLXYVn9kDIDpB20eJKpM2i21mEwwaA6OwuEtxwlh/C 5M1Pk2pRfQvd4I2XWkHW791pHNqokA6aQFCwTNm0LyMqU5rbOLxMzH/KwgfnJCl6ZiebOq0EvYX exVE2vaaxOkJn3zMiX2n2qAeRgxV2iKDHXafhCkNVIAb2i0agFgqOnnak0kg== X-Received: by 2002:a05:6000:2991:10b0:47f:6fd2:12ff with SMTP id ffacd0b85a97d-47f6fd214b0mr7719793f8f.9.1784563244450; Mon, 20 Jul 2026 09:00:44 -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 v6 17/23] xen/riscv: create APLIC DT node for guest domains Date: Mon, 20 Jul 2026 17:59:58 +0200 Message-ID: <06c022159e9cf70bacd0c061b7460b99a3dc88ea.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1784563245-034D7A5B-A8AB01CC/10/73395122804 X-purgate-type: spam X-purgate-size: 8635 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563273989158500 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 --- 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 | 14 +++++ 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, 107 insertions(+) diff --git a/xen/arch/riscv/aplic-priv.h b/xen/arch/riscv/aplic-priv.h index 85e0d028d1ae..1391837f89b9 100644 --- a/xen/arch/riscv/aplic-priv.h +++ b/xen/arch/riscv/aplic-priv.h @@ -34,4 +34,18 @@ 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 wired interrupt sources supported by guest APLIC + * domain. + * Could be limited by host interrupt controller and is identical for every + * domain. + */ +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 126d56fb7ea8..e02d78999b77 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..e6af63ec59d7 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, sizeof(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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563274; cv=none; d=zohomail.com; s=zohoarc; b=nMAs8Mu33Scrn2Xai878b3SITIc7ih3PkSydWHNMtAE4NHpox6MVBYco7BDITp86bxdr5QECJ3Q/WpI7lmIboAAqgzh758vYun+UEldEKgfTV2p4VvnRNfGpg+c1ymBdc683J7mWUQx7WK5SJdUA4OIHyRjLokxIO8yRYEb/qHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563274; 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=ZoeTmaEjyoYEs4a5u0hn2/Wi0J0r3D+XAH8l4guCWVY=; b=i8qDi1VeyHvyxQnRbAWUNUNuNuRmVSdLV05dJrfatUlnw7GjvMds6FS6m5aSfeviPiVVA46tziMBYNyufDqdYBz+GD80Wc1SFedq/vwLOf64q9IyMrbZyrDL7nX6Wyc7nSFk25NPsTg+bEzzUhhmsPWfQVWrQgxrQV/+HBZn6Wc= 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 1784563274308789.6915440051288; Mon, 20 Jul 2026 09:01:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366999.1616883 (Exim 4.92) (envelope-from ) id 1wlqQD-0000xI-K3; Mon, 20 Jul 2026 16:00:49 +0000 Received: by outflank-mailman (output) from mailman id 1366999.1616883; Mon, 20 Jul 2026 16:00:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQD-0000vT-4x; Mon, 20 Jul 2026 16:00:49 +0000 Received: by outflank-mailman (input) for mailman id 1366999; Mon, 20 Jul 2026 16:00:48 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQB-0000bp-Uj for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQB-00HTZO-7R for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:47 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4626-2eae-0a2a0a5409dd-0a2a450acce8-26 for ; Mon, 20 Jul 2026 18:00:47 +0200 Received: from [209.85.221.52] (helo=mail-wr1-f52.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e462f-f2d2-0a2a450a0019-d155dd34a47b-3 for ; Mon, 20 Jul 2026 18:00:47 +0200 Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-4758bd3731bso3213523f8f.0 for ; Mon, 20 Jul 2026 09:00:47 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:45 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784563246; x=1785168046; 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=ZoeTmaEjyoYEs4a5u0hn2/Wi0J0r3D+XAH8l4guCWVY=; b=rpNHJbl7uiD6gRzRvnsI3dLdUM1FzVSbzMNANZo2td+cPTJkGokGFXlUOu9efhzqVz Bl9KaOScxWcCp1CbAgaoZ6WPvpzop9psr6TH+aVvavO+P5jOv9GP5RLNO+8b04Dyeu7t UMS9QdsixWNZusVvhBmnQyg+VXgQxGfT1i1cKrC/b/w8NOXRdzls4Pr6D+UTleYe7tPd XwIS1WjlhMoosUVCd3aVXuyjCxy40ibezgm8jNHzsEsfmTNGYtJHLiIq4dj/8NM9OsjX oEZr1X5Fdhrupbdx7m2nvi6jtz8sA7YTxfSq9NB/Y5G3GgFfKRMpYFIgAoCjU32B1Vth Z5BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563246; x=1785168046; 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=ZoeTmaEjyoYEs4a5u0hn2/Wi0J0r3D+XAH8l4guCWVY=; b=EpcnH18iffsGsTkWhD3WH7aLCCcK1az960ROY7/VPCYQDXcPUTSDboxdaWYq06rmaa TjNDnGSuJhpUY2E9xohu22Sa1rn5UXFaCkL+oSonWz3xEQkP0C653ee+/oDWauqx8E36 KWx7L9smffZfRCN8G4V2flvrzTrLhGbbXDEDcKaaFKah5vJHDaeI1WAgNR7gTZz2mDz3 8hO5CEHg+g9elVL0Tq15dIkGJqdT4qZM75jU6yK/hTQA1xu5J5nmTL0sAlTLIKXI6IJP 7lGrj6vrCfA17TcB50QjtinPP/j6pa8zIc38QL2JICn1+S5L40H0gWye7U9l+mQmJ8Fp SuHA== X-Gm-Message-State: AOJu0YwAhnqIX2qilbulKvUEbjnVi14uZ0nZpTUhhNq57xzPNzagdYQM S8ABPm3pSslUil0bxBfYSAIT8PPXOczmeqmI55fgZu2ZlNts8tmSU+WZdOSVbw== X-Gm-Gg: AR+sD12Vxac7whPQR6CMetfm9XdRESW/kVZ0NMnQ3SbSWJJbkdHvebyr4yXbgSfa07z El4rnPIJ2EnWVJ1YXadqxF1rzh/S7ch4mELlYZ3RvlORKXYSUEe6s2kAb8lNK9NzKNnWeWFnGyM sqZDklGdN5FgUOhtJkUQzc1B468yenVBU9xPJLOTQ7rH/IsxOY206gHdFIfowhWahXbmMmNikxv RccIPOEEB1MDRMaPFrmHMvnS5pmAoc4D9hFzpyI3HrOtpAYbwbiVPSeQDpz+MnOP8IsTH86YBOh ujFul1DQFlD3OQHitx8nOlVoDzQpJJlWmtyoMFwf2qKsXqW9WxlCWupbZxEd+k1IKs2Lp9+pyhU hbdZFU2KsoysK8E6m8HSMN8oEHy7f8533cfj2rPHgqtwTdEml7t9DYmJZcQujOOSpQ/r4wv9xUA RpF8E/8s2L+Os7U4qhAKVXqwQMW62zpckchZM+X06rdy/Eu7+wqX9feo+PRA== X-Received: by 2002:a05:6000:4712:b0:473:c2ec:7a79 with SMTP id ffacd0b85a97d-47f623bc38bmr16610617f8f.12.1784563246225; Mon, 20 Jul 2026 09:00:46 -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 v6 18/23] xen/riscv: implement IRQ routing for device passthrough Date: Mon, 20 Jul 2026 17:59:59 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1784563247-583CCCFC-56A9073C/10/73395122804 X-purgate-type: spam X-purgate-size: 22639 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563276026158501 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 v6: - size nr_virqs as guest_aplic_num_sources + 1 to reserve APLIC's 1-indexed source 0, so the highest source/irq could be reserved. --- Changes in v5: - add early -EINVAL return in route_irq_to_guest() if domain is dying - use __clear_bit() instead of clear_bit() in release_guest_irq() since desc->lock is already held - remove irq_get_domain() wrapper; inline irq_get_guest_info(desc)->d at its single call site - reword IRQ_GUEST comment in do_IRQ() for clarity - move XVFREE(used_irqs) before the switch so it is freed prior to variant-specific vintc teardown - fix missing space in dt_dprintk() format string split across lines - Drop 'inline' for irq_get_guest_info() and leave it only static. - Drop xfree(info) from release_guest_irq() to avoid a potential dangling-pointer issue with the ->dev_id field. Now that 'struct irqaction action;' is embedded into 'struct irq_guest', 'info' will be freed as part of release_irq() at the end. --- Changes in v4: - Update the commit message. - Mark map_irq_to_domain() and map_device_irqs_to_domain() as __overlay_init (mirroring Arm) and include . - Fix grammar in the controller-skip comment ("IRQ" -> "IRQs"). - Drop the redundant 'base' local in guest_imsic_make_reg_property(); use GUEST_IMSIC_S_BASE directly. - Rename vintc::irq_nums -> nr_virqs and update all users. - Guard domain_vintc_deinit() against a NULL d->arch.vintc. - Use smp_rmb() instead of smp_mb() in release_irq()'s wait loop and document how it pairs with the spin_unlock() in do_IRQ(). - In release_guest_irq(), reject live unrouting from a non-dying domain (-EBUSY) and clear _IRQ_GUEST under desc->lock so a concurrent release for the same IRQ bails out instead of double-freeing 'info'. - Tidy spurious whitespace in release_irq()'s spin_lock/unlock calls. --- Changes in v3: - Drop extraneous "to" from "Unable to permit to %pd" message. - Move res/irq/rirq to loop scope; use nirq as declaration initializer. - Hoist irq_ranges check before the loop (it is loop-invariant). - Remove spurious forward declarations (struct dt_device_node, struct rangeset) from intc.h; remove all three from setup.h. - Use __set_bit() instead of set_bit() in intc_route_irq_to_guest() since desc->lock is always held on every write path for desc->status. - Use XVFREE() instead of xvfree() in domain_vintc_deinit(). - Rename allocated_irqs -> used_irqs in struct vintc. - Fix dangling desc->action in release_irq()'s !IRQ_HAS_MULTIPLE_ACTION path by nulling *action_ptr after saving the action pointer. - Use true (not 1) for free_on_release in route_irq_to_guest(). - Use %pd for domain printing in route_irq_to_guest() error paths. - Introduce release_guest_irq() to pair with route_irq_to_guest() and plug the irq_guest info leak; call it from domain_vintc_deinit() for each vIRQ recorded in used_irqs. --- Changes in v2: - Rework IRQ mapping in more common (similar approach to Arm). --- --- xen/arch/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 | 238 ++++++++++++++++++++++++++++++ xen/arch/riscv/vaplic.c | 9 ++ 8 files changed, 405 insertions(+) create mode 100644 xen/arch/riscv/device.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 9d8d21b65188..fc6b34661111 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.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 e02d78999b77..fe319041cece 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -306,9 +306,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 dad4c5fab08b..2ee5d1533c8e 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; /* Used during domain build only; dropped afterwards. */ 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..6e9972e5059d 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -12,11 +12,29 @@ #include #include #include +#include #include +#include =20 #include #include =20 +/* + * Describe an IRQ assigned to a guest. + * + * The irqaction is embedded here (rather than allocated separately with + * its dev_id pointing at a standalone struct irq_guest) so that freeing + * the action in release_irq() also frees this whole structure in one go. + * That avoids the alternative of release_irq()'s caller having to free + * dev_id itself (something like in Arm release_guest_irq()). + */ +struct irq_guest +{ + struct irqaction action; + struct domain *d; + unsigned int virq; +}; + static irq_desc_t irq_desc[NR_IRQS]; =20 struct irq_desc *irq_to_desc(unsigned int irq) @@ -198,6 +216,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 +253,215 @@ 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); + + 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 irqaction *action; + 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); + + /* + * release_irq() frees this action via xvfree(), relying on action + * being the first member of struct irq_guest so that &info->action + * coincides with info itself. Guard the layout so a future field + * reorder can't silently turn that into a free() of a mid-allocation + * pointer. + */ + BUILD_BUG_ON(offsetof(struct irq_guest, action) !=3D 0); + + info =3D xvmalloc(struct irq_guest); + if ( !info ) + return -ENOMEM; + + info->d =3D d; + info->virq =3D virq; + + action =3D &info->action; + action->dev_id =3D info; + action->name =3D devname; + action->free_on_release =3D true; + + 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, 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); + return retval; + } + + return 0; + + out: + spin_unlock_irqrestore(&desc->lock, flags); + xvfree(info); + + return retval; +} diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index e6af63ec59d7..449240c5cd23 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563274; cv=none; d=zohomail.com; s=zohoarc; b=i9uzQY61IeWg/s4xkLSROn0yX7hgHoD/40gu+8Gg0S3hd3NGMvJDJWB2ub4kGjrg+KvjxeqZ47oIP0FdFQD8Fk7PJPGLxt8e1hPxATdx07U0cTMFZaMjuZCPdTpbqoyk8GS7QOTpxMAqe+lQ90LoHrozJaFv+jRXdEsy+OHuQxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563274; 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=0DFNH29+Q8LihHAoHP3YTwhdjKQRR0o+D4+cY7ApDEY=; b=CpbyElkPbSfN4Sb23TzMo1HC/xSAECviZlqM9iPW3mo+ZQ1HE5uyGbB5K4wfH0JULQNDZq6DM5OLnjXM/u76GedpP7mVmInZ7du0NBmTw+X9ziagNZzYp2Rfnh4FnWuE9vffsEYLscONjd92AJm6asCvjBBMDDHYdnFs0MM82Dc= 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 1784563274792979.2093239653984; Mon, 20 Jul 2026 09:01:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367001.1616892 (Exim 4.92) (envelope-from ) id 1wlqQG-0001eF-Sa; Mon, 20 Jul 2026 16:00:52 +0000 Received: by outflank-mailman (output) from mailman id 1367001.1616892; Mon, 20 Jul 2026 16:00:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQG-0001bb-C0; Mon, 20 Jul 2026 16:00:52 +0000 Received: by outflank-mailman (input) for mailman id 1367001; Mon, 20 Jul 2026 16:00:49 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQD-0000xR-Fk for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:49 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQC-00CGmJ-Sf for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:48 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4626-bab6-0a2a0a5309dd-0a2a4502b098-36 for ; Mon, 20 Jul 2026 18:00:48 +0200 Received: from [209.85.221.41] (helo=mail-wr1-f41.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4630-6ca4-0a2a45020019-d155dd29e52f-3 for ; Mon, 20 Jul 2026 18:00:48 +0200 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47f707e5d75so1000345f8f.1 for ; Mon, 20 Jul 2026 09:00:48 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:47 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784563248; x=1785168048; 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=0DFNH29+Q8LihHAoHP3YTwhdjKQRR0o+D4+cY7ApDEY=; b=Be0cQ4TAVQ1Izfwzt3aooyFPi5lI9mlenYWHb0xToLZN+q8KpzOAQ7sgpNncpo2n2i 6O0paRNDovucsA8DGJX61VkKvPMG5EeN3MlHrX9NBhwmZarG76gBrvirPR8W1YcMDnZ7 OB5ZJjTGBACd56i9JBsK35w/9C36JpNSGsD1Cahe5qQ/Ra/p2qWmbDHyayAHxs5GAc0p toR86hUZoTKKutTX4SFcJxKUna2cDKvH5V8kdVWe6NZ6LllQh6pAirFW0pqIF6vnkFJI dAjFy1knFzXkG9jd/aUOpUpIY+gYY70Z0MUvj/A9MZs6Sff/HdbQB51XDfb6UQWu/11p /0hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563248; x=1785168048; 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=0DFNH29+Q8LihHAoHP3YTwhdjKQRR0o+D4+cY7ApDEY=; b=stJevZ6cbS/YxcJoEubH57p8iWbtbXbNyHPhIlUi5AGrjaNwx+3fA5fPyCOn163JA2 7mXoyj+R2GdUREXjZEMLS7fEF4vbYxlGd8jvcgOQX3DG+cz6jAMka8srTdYud1iO7Kam VuKlg0Zaqxoqd6r/vcWL99pLij0JPZPBYx1WQ+GB6xPG6RDCaZUeEd2Ie4QaSxyDKtEg IuDqkVIPBxFJKQPZuD7C2MC00WlVmGMz0izH8i1Zj6udoK7OwMBflHzfaoJcRy4FnuBQ dZKZeLxMrxaNkEZ45W/8IP2P4HPv960SxV9f7B+7ktM+HU+Gt4PuTK27LD7kxX9l9Fir vf4g== X-Gm-Message-State: AOJu0YzwH52Z96McCItz0YBa9whcZmTOREZddPjxqrLXc30Z2gvHNDbK 3yyuj/ORSExT7MgroZckTCpGpVqFGY6meOY1BTbMaoHO/SaS6jrVTXbhQWY6ig== X-Gm-Gg: AR+sD10n929O/jm8QerItBQjVR2SZCF/xfE4aYGmhZS0/h2H72WOwMS7KPHKNVxjNJA XtSZzIQ/n6NoclDr6ZiJzVZJqNEg1qIZTeR+KgFcxBDU5kudhJQKVb/zpa6gMdtqe9PfqpVwqrh nQbB9eCsgWqdRBHrmKB9EoXA/GFFiunDxew4Z9sMRic01QYRkEoAWq8d/D3qqFjcUCjl51RsMEs zF+JH6mjOKPjTEhL2nFX5D8GPlxrPe3rRRU2A/JgJxAMbitJI/0s3otDa67YpQHi16syV1okOgK cI5kpLtKfflgiotOq3RVMDPYAGElxgsGNDdM9x4jzePL6alpDQd+omJU06D/9PjFw5VPW4Tz2Vl dk7/bGqkrBHUO1ylKyta7MBg15MkY5d30bo9J3bgC11aRu6rsu5FCSyS44yYqWCZWoFUFbXMlSY rYT9BJDU2TTB1JtsrsKQG/PPEKRrx7FKOsRkxZ1Gj95kcehD3HrPmjLkFlOA== X-Received: by 2002:a05:6000:29c3:b0:47f:6fbd:8a23 with SMTP id ffacd0b85a97d-47f6fbd8f53mr6199152f8f.9.1784563248103; Mon, 20 Jul 2026 09:00:48 -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 v6 19/23] xen/riscv: implement init_intc_phandle() Date: Mon, 20 Jul 2026 18:00:00 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1784563248-F26B72AC-9EFBC764/10/73395122804 X-purgate-type: spam X-purgate-size: 1378 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563275885158500 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-6: - 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563274; cv=none; d=zohomail.com; s=zohoarc; b=aMLT/eEmLMGSs1NBR6lFjTlLOFPaig2WYHYz0X0g1T0mgbenGp2B7BFk5KplzBM2r3zJbnYJ9619kdKzhELONWKAuoHKwvhWYo92PF/QgKXt0pyGsUGOaTHuIGNU6Do332UqTJsoQf6/EnVaC+qPnu0t5ZmsYlk3q9AD0DeteYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563274; 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=mI0eMyl2MrsS1GuuBY8meRpdR0WpNCgvj7HrpxOkMfE=; b=ngEoy0A2juuTCTrHMM1boG+37qE6fwZnceWhbA9a+KGKzaJVDTWAuSx6fkZwec4rzjKgRKJ3VfkSnP2WfiWHGHAfrIK4GYvkRlNiUWRIxW4H1j/MXxz04AP4+qHkPsXDYTIEsS0wz3zxclq17UMx9bMW1hq1YETtyeVTfkF0uXY= 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 1784563274667919.2548148078831; Mon, 20 Jul 2026 09:01:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367005.1616903 (Exim 4.92) (envelope-from ) id 1wlqQJ-0002Cd-H4; Mon, 20 Jul 2026 16:00:55 +0000 Received: by outflank-mailman (output) from mailman id 1367005.1616903; Mon, 20 Jul 2026 16:00:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQJ-0002BH-37; Mon, 20 Jul 2026 16:00:55 +0000 Received: by outflank-mailman (input) for mailman id 1367005; Mon, 20 Jul 2026 16:00:51 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQE-0001Jn-Ug for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQE-00CGmJ-Ak for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:50 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4621-bab6-0a2a0a5309dd-0a2a4506c59a-34 for ; Mon, 20 Jul 2026 18:00:50 +0200 Received: from [209.85.221.46] (helo=mail-wr1-f46.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4632-195a-0a2a45060019-d155dd2edc8b-3 for ; Mon, 20 Jul 2026 18:00:50 +0200 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-474560436c3so5222406f8f.0 for ; Mon, 20 Jul 2026 09:00:50 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:49 -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=1784563250; x=1785168050; 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=mI0eMyl2MrsS1GuuBY8meRpdR0WpNCgvj7HrpxOkMfE=; b=WdN/wMiovVW8ObONqG1EywjV5c/ud53OpbbxFPLmd1x5aomV/M49IuAaJBFmYvOOmd U2AebZKxPe1VdLQVsCTbNPIHzvpKFK6rf7+usF4r5qaygk9fCbP/FvGtn8YCrsXVhawM 70pHZEaMrH1vgUrQEZy5RHKkJkjSBulPKkmRS1/mrbKmpnnVKicK9C86D5ZSllt+CJzH N2qzYi9feMOkAYkHAcbUbWYijnHGlxtSJva6DVqR75iN+bxiX+42iaKMqCQCIC7Gl+/X nusbxahSirRdYUMTAbaLPhuF8V4Ezx42HeU38BUWrUuzk+G7Tv9b2Zjh9GBPXCEp0GeB xKWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563250; x=1785168050; 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=mI0eMyl2MrsS1GuuBY8meRpdR0WpNCgvj7HrpxOkMfE=; b=GhyXv1XCw8giy35EdrB7jabJfXVE68jtjGk15gptcn0mVGDF//yJIUw0dDcT1Y24dw L5XRPXKubuj0SI8mtqrzS5EQ8zMwGG3BcZfID0Moqu+gvkkGcvfIS5Wa8NQWIom12C+E APoYgQjSceUf6wnQxihF6R8apB+LCfeuy+X/G922SlD6HWsgpmKi2H+4ObB6QtyK/b7J qIHVyxrBtoYYGxQjNaQCAE/z7tEBWol2vRojGAjYKoDW0Hs7VX0DXAXWGXZ/S8yGc53W AKBDRwkyCAqYCBhsiTOROEJZB9aObFr7CGlDMQQCMNzwstiFB32NkrCVQSz2uJC/B5Il N07Q== X-Gm-Message-State: AOJu0YyAdkmcPRfVtCU31wGvJ6llePTBZX45hT2PLlvSdXei4nWcvbLa lg6mWbz81xmshfAWR7ZSHVLcxyF2FDoCgvPCHV04SUOuOBPTHZMtKqh9+wem2g== X-Gm-Gg: AR+sD13k5oCKsDO038JBoyxhtM1PVIg9G+hQCph5SwVFPMcOxJVE2HtF4cWAEF1W9bd UUbzqxeqT68eSTIERQ3UjPHI8B9Qa90HyDGwyx85vyB3fGhTIy/X0GtgsZ5c9KwNmz5g1KST7Q3 07v6V0XxzmbgIa0RE6iHUNIlG+7WjAFTxe6H91sWNmBjX33hiGTxt4PJr6f1wcWh3fP1dumQDdZ rde1l1ngQuDzv4sqTDrrEI01UJywjGA6jZjK5VxP/I48zCOFFN/jgfLQtIlUqAPIOpQn9sbO3zx LL0SWPZ+JcjsgdQFXnQar7N9GWxcsNYFZpAlxN/JJV00wYLzC46PsHilFJReXGMp4dKnQiW8Fag qBxXZmre0RxpzJqLY2ZGx0SGLezjXO0hL2W1AcW6cF2luF1EpVgdtpv+J4W9q2Q48t34XNnC+pP Ob9PdL4kLOaOlQAZt7FFrm8K9oGO/+Pgg50nv13RCQQYerrtA= X-Received: by 2002:a05:6000:230c:b0:47f:5289:5606 with SMTP id ffacd0b85a97d-47f622f2a76mr18145104f8f.12.1784563249622; Mon, 20 Jul 2026 09:00:49 -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 v6 20/23] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Mon, 20 Jul 2026 18:00:01 +0200 Message-ID: <5f586849014347c550ae1be90ef620a66cec9efd.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1784563250-F4C0777B-05D18F42/10/73395122804 X-purgate-type: spam X-purgate-size: 1560 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563275910158500 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-6: - 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563284; cv=none; d=zohomail.com; s=zohoarc; b=C0flk5DQb7X/xFitGalegge03aN2yeHLUHwCflpz9jilc7N3oMUq/cPTybDa5HLX3ZdevNQTvEx9MnmnM2grpj5oC71CJ4KrpjCOp30sw7XMs3qpUHpCaSQXWLIQpkTYOD/fsJwzdXYyEuvCYo9PTS6iqRW7qlIjTq8sIKva2EI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563284; 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=GnjPdWyeVMMtK/rO246vVnQEYvE09wVm6zsQIO2jAY8=; b=JLd0BlTHu8IzjEXsP8Ak2IfQ6VTyldk19yhvu/hKTupL7OC2e3AFZ+WJoApSQLHICiE8pkZu2ukcf2oUg4GNt7DP9aVHqTm7Z8hnn5iB+r2FCaDcMP05aJwrYr7579oikLxNC7wTTSjaasi0GB82W6uAJNKfyqzHgeoerZyUoqE= 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 1784563284599452.42895766862125; Mon, 20 Jul 2026 09:01:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367016.1616909 (Exim 4.92) (envelope-from ) id 1wlqQK-0002Lw-Nt; Mon, 20 Jul 2026 16:00:56 +0000 Received: by outflank-mailman (output) from mailman id 1367016.1616909; Mon, 20 Jul 2026 16:00:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQJ-0002JK-TN; Mon, 20 Jul 2026 16:00:55 +0000 Received: by outflank-mailman (input) for mailman id 1367016; Mon, 20 Jul 2026 16:00:52 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQG-0001Zm-98 for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQF-00HThX-LH for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:51 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4621-e002-0a2a0a5209dd-0a2a4508cf58-38 for ; Mon, 20 Jul 2026 18:00:51 +0200 Received: from [209.85.221.51] (helo=mail-wr1-f51.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4633-f659-0a2a45080019-d155dd33cd86-3 for ; Mon, 20 Jul 2026 18:00:51 +0200 Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-47c2b362ee2so9040675f8f.1 for ; Mon, 20 Jul 2026 09:00:51 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784563251; x=1785168051; 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=GnjPdWyeVMMtK/rO246vVnQEYvE09wVm6zsQIO2jAY8=; b=FIvzd/Xla4yTAsOLJDKo9+xkG4Nwkey9B3GL05ZY7/6ak4jgEMF+8pxUZPz5mLCW2k fA/CrZuEQyHJcHbgt0tx2czNrT809NAsWwVF1OSiSKqEoyRfq1cC9X8wLP4e69EWAeVh KgRe6df4fvl8ICH+E7gxJifFnEBdftOJcn0PfUdqriKluECnM22vrcS7etCWN34EoWJU +AsQUCIxRl4zqJ0sJntnN5o0KAFE95Rq0gKwtcyTE7K7cRSJowWkqaiaW4xMGdD2bvkY 0jwUXRsenKHb4re0iMN3HFTZpRyN8aRjGL3jXB0lu+fJB3ujkm3wSwg9+Gg1th1Z88sL TGEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563251; x=1785168051; 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=GnjPdWyeVMMtK/rO246vVnQEYvE09wVm6zsQIO2jAY8=; b=EAjpUBeTTHeZeVQHv3WESNflJ1eSKJgEyoc7amWIHMKjb/Pr8BNf5pABe2VSdsc4Hb TpPnvQfIMiIP7t2lWfnYGv3KOsMcOp1y2QD0UwaPOLvKt2Pu/1pfZl+OkKSdbbFpLemM 6qnFBzMUOlLcnTF/pF3axzGsqokyFggYmiR9LTzNAsTNLWmHmf+UxIYoZCbqLijVkcll KOoPFS1pte/aQCnHisOQXTVM9xVTg8XnH/mUminPc4MIvSkPQ+NHMtmKSgjCQT/Ya4Vk +Y/sw0K4O/AzUTntFH64ASYrbg0LsHAlZdsoF8IJR18E85cKWa09UCAgo54fYYzWaPdO A/lQ== X-Gm-Message-State: AOJu0YzwPsrGL1RumJa5pRyFdcYxUOLESMqaVcy3/pSw/ytehMus+sqf lc+L3JXG02938YgUGpvaVcyXZvv4Gk4ZE3GOawcqrDBeoScaNtoro2G8Z2R7ag== X-Gm-Gg: AR+sD11pUVGY/b+1vmcMuiHr0b54bMWjJQ3IvjpSr4bzc6mEKiUDRCf+XP7chJBSHJ5 9JF/P6A2YOse4yEKnimq342xUtxcD8FjqbIwTEV2MGCFWfyU/Z5ndePf4B1T3PGqUum2ISHiql7 KWGAwTM7iMyklx/EhAag63v9Z2igo2ROik25GQAIhOQu60JcVCkUjNBIBlKk1Z4hq8MQy67TTfW wQOSSNCROxjmX+kmt15YT90CmGD0zexUFN0Xzo47wywHmHMG7cYt/jwZpUVIk3asieoSlm1PzZG pZOQ1aUbc92+2IEIv9m+ZxFUKIFyTrfu1XPROcWK4BEyoCNVAmJhJRkFNEcHDT6LxUizeTeF/w9 e6gfwLyendbefJHmh0eDBrbh4VTraXaJ2gCaVU3J/c/DoUUoiWfehK+7bku3tcz+Dj21KAa3HZz oN7uzfvPzkNK3BeWebkaA0OHjSNoG2Gm+rgfBPbh85zIZ685c0xIsgQp6WVA== X-Received: by 2002:a05:6000:1785:b0:47f:7b75:61a with SMTP id ffacd0b85a97d-47f7b75083amr3171928f8f.15.1784563251033; Mon, 20 Jul 2026 09:00:51 -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 v6 21/23] xen/riscv: provide init_vuart() Date: Mon, 20 Jul 2026 18:00:02 +0200 Message-ID: <823515f11f566c54bc060ad68af838c0d3723b9c.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c1860d/1784563251-CE14687B-542FBC1A/10/73395122804 X-purgate-type: spam X-purgate-size: 1391 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563286014158500 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-v6: - 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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563279; cv=none; d=zohomail.com; s=zohoarc; b=EVunI9BTiYwn9OJOWTRLbeb/kZA3leaifq6cf1D/r77UyhgFNqkVoR3GRxxoeNtORdPeMA9raspIrBFa5wGG53Idk2nNJoWOQc4mhf0c0f026Dk3wRJ1ebBYVQVJTkFrxV8MdRjE+nRv1rV9lO+MKRBldz7Rdq25+l56W0UuALw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563279; 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=LNKh9iZCNRF5pxwhL4Q/IsesPS2+IO+kB0heVo/BkTo=; b=m49nD44loVSA6LnKw8ZGAgQnfrMtUjJLW2LBaDq3IN6ebHAfkVaj2Li5slbA+E5xkhf/7Yfod9yfyCFeNfxdHqPxr0IxPO3TlDg5VFnRvsZGqZzzpabOXDjs0f61GPP2sAuQJXnm3C12iBjJrvAvPEFXmWLOyE2KoxByasvZPaE= 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 1784563279622253.56227069283318; Mon, 20 Jul 2026 09:01:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367024.1616916 (Exim 4.92) (envelope-from ) id 1wlqQM-0002aE-3V; Mon, 20 Jul 2026 16:00:58 +0000 Received: by outflank-mailman (output) from mailman id 1367024.1616916; Mon, 20 Jul 2026 16:00:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQL-0002WV-0y; Mon, 20 Jul 2026 16:00:57 +0000 Received: by outflank-mailman (input) for mailman id 1367024; Mon, 20 Jul 2026 16:00:55 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQI-00025f-Qu for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQI-00HThX-7S for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:54 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e4632-e002-0a2a0a5209dd-0a2a4507c57c-10 for ; Mon, 20 Jul 2026 18:00:54 +0200 Received: from [209.85.221.41] (helo=mail-wr1-f41.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4635-b4ea-0a2a45070019-d155dd29d495-3 for ; Mon, 20 Jul 2026 18:00:54 +0200 Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-47f7444576cso1009059f8f.0 for ; Mon, 20 Jul 2026 09:00:54 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:51 -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=1784563253; x=1785168053; 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=LNKh9iZCNRF5pxwhL4Q/IsesPS2+IO+kB0heVo/BkTo=; b=RCesPm+TjmDqTvES5uexlxci/EUjRBK6KaR26z8j3ioMrEmjA5picJJ9fhjtr7iinY jsUxl+eMZPiq11z56fvnSClBnLCQipBRP4Z3ml35Lb0J/Gnq1Z27mXwRBzND063ROXd8 wZOKIiwWxF4bL4ueFf1IDElLpuOtJrSXFeKLmZMm0UiAHP+E4VbL6T9ASgMLolal7bBK 0DgZEvcn4rTEikYH+Dj0ApodtY5M3xkXy2/sFEBuWX3H/SANZiT18sx7tj4fKHabAyuT zJtLXV00WxMFSruVaPnveW5iiqws5BN28iRgQ24Pglc3tUCD7zfxB4eFus5pRw/PUDnR lL3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563253; x=1785168053; 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=LNKh9iZCNRF5pxwhL4Q/IsesPS2+IO+kB0heVo/BkTo=; b=r3H4Y9RSoNraBW4glXYcBwHtXBeq0UjV+RM7DqEq8TeeIJ5tEbvMfb6Zdr69v3oHau dezE9EIUwa6ugJqWItv5vUPtY2QglcXybKp+qgyO4wurjwur5totPWT4MVohu8nDmOp/ K5YxG3lsQWu4Vht/Gw5hRaE82UgAL5066r30+5GHOXXkVsAh8DhnePpHeq+7FG1GYVbg 2mnG+OmFtTxlkqWzu1BDt6Z6G4/5ADhBuwAY0K3OBf3gDfQN1FPijgt5A5+Q2MzOvXlY 6cFVPFT99nM+2buw7fEQ4CpoiZrPA2PjHw5QwAyv/CJEyOGc3om+yd1EZjrTJ7/xTma6 YPlQ== X-Gm-Message-State: AOJu0YzD80+EGqDVQYAiXNUDIjcdhFR/sjHt/agnQPUQIbnUhN8lkLTs RdtJFqwMHFlrbEhMWlBkhBt7eqFyVJ7N4wepplGP74rSvZ9/c6LvLuNJooWpmg== X-Gm-Gg: AR+sD120nlU8LNW/LPj4WBtsKPKFPO05zne7gSXVdIrrKqG1dbNr3mOyCR2+gEoMRmg ihRTSTjAtzRu8l7vKddvi3TYYxqfvpUGSmLMwjWUHveM1NLXQmMHfILu2xLQeilUGWTDjQtQ03h 3njzs1IAnjF5Zo6p3+bVSQHtyvmFz74y48NUUWccg80vPK6J2qwwISv8KHvQrtHhvjr704J4orm zDtpRKaOibve2xNhd9IXtBzIBEFVwmPymctZE+dJUtY32zldroCw6tQahJQZQU0Z1sGJupJ3Nzj ZRB12tQ0cumnK0ltjvW+ISt7svwmr3M79u5/WjyPIEzYqieUXAeJEFZ1VApUgezVoYbH7321zi0 W1VvJ5f39MrWjrEl79tYxKvCAHluubgulZpaZe/00PiYeXnbmKDDaI4Dt809dszfC3gA7akiWy4 tYOLoHcWWUVAi+PXeB3+TIAf6eVZE/2P4lSZ2QZijtXknwNGM= X-Received: by 2002:a05:6000:4a01:b0:474:b860:b7b1 with SMTP id ffacd0b85a97d-47f622feef4mr17043290f8f.9.1784563253056; Mon, 20 Jul 2026 09:00:53 -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 v6 22/23] xen/riscv: add initial dom0less infrastructure support Date: Mon, 20 Jul 2026 18:00:03 +0200 Message-ID: <0b381795a3a7c2d09088c1fae59d3a19099069c2.1784559209.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1784563254-3C212AE4-EE3B00B7/10/73395122804 X-purgate-type: spam X-purgate-size: 7283 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563280068158500 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 --- Changes in v6: - 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 6b14dce9c0a6..04a8d3c244cb 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -175,9 +175,37 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) return res; } =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.54.0 From nobody Thu Jul 23 21:11:30 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=1784563351; cv=none; d=zohomail.com; s=zohoarc; b=m/QIB83+NZiuU3UmgQPwI/cn0LFFKfI4SRi6YZZ6jlhbWoSWYbAdHzt/aACBs2Lm+ru2rOKJhWptpOrKVAjVIovYh1ANNclCiftQt/6RskTITNnkhPFbGDfYmINt2j+GTlZKWyKCR3aS+FnnWxXOdbvAPLScbvlKUHkpxhBVtow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784563351; 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=5RL+fNVvhfSSFDFHK7c1euVp7Huy4szKsBRgrEGEPIw=; b=QxO7s9osHNZW79oO83OnYjg4aLFyWPnV9k/NltDI1m8gAF7vYyQFa28AwXaKBf4HXG3Rxi8UOY9oQIUNH1B5qXscuJ6XGkH8m9kKZRjuj9Qut4qkNeEpuek0G95vXIvwNah3QdrFSc38j8bB6tIhiRxKmhervWJWhlsFQ4gdFB8= 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 1784563351175434.1554515873253; Mon, 20 Jul 2026 09:02:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1367029.1616924 (Exim 4.92) (envelope-from ) id 1wlqQO-0003DX-J2; Mon, 20 Jul 2026 16:01:00 +0000 Received: by outflank-mailman (output) from mailman id 1367029.1616924; Mon, 20 Jul 2026 16:01:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wlqQO-0003B6-41; Mon, 20 Jul 2026 16:01:00 +0000 Received: by outflank-mailman (input) for mailman id 1367029; Mon, 20 Jul 2026 16:00:57 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wlqQL-0002Vb-2P for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 16:00:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wlqQK-00AdLl-Ei for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 18:00:56 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5e462d-5cb7-0a2a0a5109dd-0a2a4505c1fe-26 for ; Mon, 20 Jul 2026 18:00:56 +0200 Received: from [209.85.221.46] (helo=mail-wr1-f46.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5e4638-4cb1-0a2a45050019-d155dd2ed001-3 for ; Mon, 20 Jul 2026 18:00:56 +0200 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-4799b3f7c83so7492535f8f.2 for ; Mon, 20 Jul 2026 09:00:56 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47f63edd7d3sm30084673f8f.25.2026.07.20.09.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2026 09:00:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding: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=1784563256; x=1785168056; 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=5RL+fNVvhfSSFDFHK7c1euVp7Huy4szKsBRgrEGEPIw=; b=bo5HY5+pqP7n/rTSHGkUBzPp+UXR4790XxrLRlsZo9RpjOXeNhYet8BHQT3fslCMy6 qKeLkgHn31EW1Zz/BLxr4xvN5j8RI2xPny7NibKg9Qgvo77FdnRTos52h/hdiJBacLV+ LlMOQZzSwh9Pa1sEzVWFuQxu1znt0jfQ99/35ADRhKLg4b2ytrb/C7AtmTze5Hp9EEjQ oCTr3Lzk/Gc3g2x0wP0G+Qz+vMB5blxiKeglIS9dPWEXz9zGwq1OdUxTD+FgzmSSIMN6 eKlkLbiRfj0emwnle7pMjn5AKAJkl5O9WgUqVlCfcKLZmzZjE2seJWOqtq72SHOwVVYr KFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784563256; x=1785168056; 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=5RL+fNVvhfSSFDFHK7c1euVp7Huy4szKsBRgrEGEPIw=; b=Vp9O07gWILQ6NzhNGhm6jtPJNP3bDEhMkeLFcVNkM31CVUecfxdzZvV7GQIfPgkwMM Zf25oAwRpWw6vCSIxeylkOpUFjK1RzNr3sdeRrqrWMiMxwvsV6e8uMWa2uAtm96+fEhU uaNYmspPntpJ5EoNxo++sbHQ9HTc2UzyzXkdp9u7BawTq9AXLrgTvqMXFDm1OfeuF1Lu 4QDQtCOGKqhRNr4d79DL+IiJwIh1RsfD+uC1XRXzydGnpP3qVq+UvqxrEXMfP0WE0f+B GI17/vpRhEPqRsPMP7lKYVM8giippd6mleO0kO7Hhzfaixw6cMGLYTNcFoJMNx2Dj6yt iRXA== X-Gm-Message-State: AOJu0Yx7asguPJ4YYvR4NeZpZuQusAsQMOPCpBpANXofS8aVgZdUrW4Y rPH/qTz/lMuovFRn7NHRmxNzdBjqeHFetyPriKtovDb/2t4xCly95lmD+IFAyg== X-Gm-Gg: AR+sD13vTDrR99QX3rjTdfQRBANjTJ/wOfx0znv/HwCNCZAl3rkbsH90vdpp2h8TZKY KOEpZxvWC1VjCgZDblhg3wL6I4W3SA8YeLMZzEfBCcceoLM53E8L4ueCmf4AyvbVJ1SYlbW2Blx xPCDHvocstIKeq5YfNUcS9YJ82XpsN3iSGo3G7VbvclNojVyYnwNPVmOk2JgUuzs3Lk5lwJFTZR hAQ3JVVd3puXJ7qJfX0Bjj+1W7C17jjaC+dNXJzBsKV3f+Gc0eJ2jo+sRIXeeuUIgL1ZUPHkdtz opFcWiidfOKqk0xLM3UB+lGlRedYkGu7bW/wtFJdVYp2xGvkiMtnDiNbUOc/BU8lhf5c6Nvl6hR Bdy45SYi4/eZj/uQ8TYhJFUnupJ1x/aNB67WOMPjPD7SNCpkLya7CZ/zUP5IweeENE7DnFWRpTJ np1OSIEmOubgGsXU94I8iMqC29uP+P5pmsy94NvpE/paHP6xs= X-Received: by 2002:a5d:5d0e:0:b0:46e:8226:96ba with SMTP id ffacd0b85a97d-47f623036aamr18227330f8f.13.1784563255708; Mon, 20 Jul 2026 09:00:55 -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 v6 23/23] xen/riscv: do a 4th linking pass if necessary Date: Mon, 20 Jul 2026 18:00:04 +0200 Message-ID: X-Mailer: git-send-email 2.54.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-c201ff/1784563256-247132A1-BF3EEEF7/10/73395122804 X-purgate-type: spam X-purgate-size: 2901 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784563352589158500 Embedding the symbol table can shift sections and flip relaxation decisions, changing code size and thus the set of emitted tools/symbols (e.g. gap end markers). Re-link with a regenerated table when its size differs from the previous pass. This takes the same remedy as commit 35de7285d508 ("Arm: do a 4th linking pass if necessary"), though the underlying cause differs: here no symbol (dis)appears from the ELF symbol table; instead the set of end markers emitted by tools/symbols legitimately changes, because want_symbol_end() depends on code layout, and layout differs between passes due to linker relaxation. Signed-off-by: Oleksii Kurochko --- I faced this issue again in downstream: https://gitlab.com/xen-project/people/olkur/xen/-/jobs/15171254706 Root cause: embedding the symbol table shifts .init.text far enough that 4 JAL call sites from .text into .init.text (e.g. to alloc_boot_pages()) exceed the =C2=B11MB range the linker can relax, so they fall back to auipc+jalr, growing .text by 16 bytes total. That shift moves simple_strtoull() by the same amount, closing a 16-byte alignment gap that used to precede turn_on_mmu(). Since want_symbol_end() no longer sees a gap, tools/symbols stops emitting the synthetic "end of symbol" marker for simple_strtoull(), which is why symbols_addresses/symbols_names differ in size between pass 1 and pass 2. --- Changes in v6: - Update the commit message and footer after it. --- Changes in v5: - New patch. --- --- xen/arch/riscv/Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index fc6b34661111..046f73f4d87c 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -50,9 +50,21 @@ $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(dot-target).2.S $(MAKE) $(build)=3D$(@D) $(dot-target).2.o - $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) + if ! { $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o= ) >/dev/null; }; \ + then \ + set -e; \ + $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ + $(dot-target).2.o -o $(dot-target).2; \ + $(NM) -pa --format=3Dsysv $(dot-target).2 \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + > $(dot-target).3.S; \ + $(MAKE) $(build)=3D$(@D) $(dot-target).3.o; \ + $(call compare-symbol-tables, $(dot-target).2.o, $(dot-target).3.o); \ + else \ + ln -sf $(dot-target).2.o $(dot-target).3.o; \ + fi $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ - $(dot-target).2.o -o $@ + $(dot-target).3.o -o $@ $(NM) -pa --format=3Dsysv $@ \ | $(objtree)/tools/symbols --all-symbols --xensyms --sysv --sort \ > $@.map --=20 2.54.0