From nobody Thu Jul 23 21:52:48 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=1783353523; cv=none; d=zohomail.com; s=zohoarc; b=Bpfaf0nfHui8ltDEQPUV1zNzW0xcNswFscfN6AhmZhQIoWAUOAwab5Nwc6e499vrbYSI1bSKrwnXBzb6xV1uUwRfiFG9QsyrfNs03XpbHTKKPmsKA9EvQjksW9AjPVpyrDqTducXx666Lw4k9B4vN/bYKqMyo5u9PFiiB1M3Rys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353523; 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=pkd0v8Xp/yZj78/ox1+RnfdTHP8Nmjo3Xh1oO+t56kw=; b=WmyhJx29rOgZGyMx7InknwBwpRQ4ooTE9iDwKxWB4bMvAKWVq5eCNFG/BGzhu+1iSt2BVnq2Mp5MN9i+yJ6dSF2cRONTlcKqpPC6aiy+rr/VNvnzpbcTipjXTXAOcsdPs1M/on+5phWyORQQw0rA2dCChmUmB7LH1lfTpeohSSc= 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 1783353523906314.5381884016788; Mon, 6 Jul 2026 08:58:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355484.1610274 (Exim 4.92) (envelope-from ) id 1wgliB-0006dZ-7y; Mon, 06 Jul 2026 15:58:23 +0000 Received: by outflank-mailman (output) from mailman id 1355484.1610274; Mon, 06 Jul 2026 15:58:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliB-0006dQ-4v; Mon, 06 Jul 2026 15:58:23 +0000 Received: by outflank-mailman (input) for mailman id 1355484; Mon, 06 Jul 2026 15:58:21 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgli9-0006UQ-HS for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:21 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgli8-00AcTL-RM for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:20 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd070-5cb7-0a2a0a5109dd-0a2a4508e958-40 for ; Mon, 06 Jul 2026 17:58:20 +0200 Received: from [209.85.221.49] (helo=mail-wr1-f49.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd09c-edec-0a2a45080019-d155dd31f13a-3 for ; Mon, 06 Jul 2026 17:58:20 +0200 Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-475881b9a4bso2780970f8f.3 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353500; x=1783958300; 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=pkd0v8Xp/yZj78/ox1+RnfdTHP8Nmjo3Xh1oO+t56kw=; b=WIOzPhMw5ynVQbkmJm7fEDb29hMVDpigmlRBSyGdh2YsCLuXkAYFaRMyFHMe+HqfFF seSELFyBsPvdt1GqEBsaPSEj0O/6GqziQUS7d54JBUAwLriaxWHjDgJYjaq08zRtT86U RNPlaJAC4fSd2FrWWZ4u0MAIznlnFvuA5LhWa6mzLqnmy2Vd2Nt1dqfhatSz6lFnAeTf QaQw4mpKzzpL52uVMwIjXxdkLNZObbZhLxcykkT2IuCDdwWazQmSXCvYqgFCUCK7fALX sIRQFURA1XmBXfJqqcD2vYRNA9svvpPHQ/RhrVVQQr4Zc2uQhSXxz4zxFmPNGOD2s5sq NBwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353500; x=1783958300; 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=pkd0v8Xp/yZj78/ox1+RnfdTHP8Nmjo3Xh1oO+t56kw=; b=mcp0FDtzZlJIiJmwfEFAngof5TJjqxxnpx0iCTZZi2fNs2GKb1DmC/1pcUDz3C6jBc dExRK8pXLo9rTXrvR9sFvK8lRaph+bwwdEp9vxSVUp+qqQjLmhNTjaHT27WFGAtYpruF q/QP0kKC0IYFrnLWjw4LTavqK1aLoSCv+tjhUrds67Q1h4IOyfGL9l7b67B3jbOGb5fF VLyrjleVNp5RWPs1uI/EhJFOnrDTk2/hiQIehMQQ3EugVbw/lcty0xVp4H1fSk1iP+LX uiDDS1C2L+kEKA27/t4HFZXcAuPzl5EOkxDMeKSIjdq3V1YQBEEyIMAOX3d1Kza6B0U4 6AbA== X-Gm-Message-State: AOJu0YyVEZ7uho/3wEgukzS7i9p2u+OUckd6AuHIbO5rnvjenkNV5vtz KlAm/Mwtgu+kti3bSyc6F2NLbtQ8sfpNb4Et/6rcLxWh3EOJWj68NPhgWrCKnQ== X-Gm-Gg: AfdE7cnErzZvbchNPiage6n8qnVbwhCHJ0KCswf9bnmMgLVLjm5VZ3THnhFtnyf1Khj 3RM6nm4DKL+wIXbXcrDbtAeE2wnBYog+LjgX4GD0isXVabRTInec6r2jn5yi0gcOfYEn8UtBJg2 zXcMbPoVKTaOG24hOQ/Xw6LOQ46S/tD2Rqnuld2sxGMsGi0JWBM/9khU6kvgBvZ+8udUP6md7dJ o6fZ13N1Ozvg2d6Kz8kg5G2cQV+JmJsqDGeMcoTW8TrrvBrtOcTUG6IlR67cPWM2NaaXnb6S2lf 40kHDFlI4j/bOQkJ32MU8r2VEXhSDRQJjaX9f46cPsrOxdcr9iu+66haruB1C9pnSu+te0RQb2a JsOgQrtzCR4GfqC1bsErTpIy56UiEf+vCbw3RiaXsuXUaM8FpVt9z1Fy6IXJGBPxnjW/FjI3SqI NzwrUYCuqUM+9JqNKjeQtdXlYv7by7EkiuxOuWXNa8rbTZEM8Xxm7oi9tA+7M2j3E8+9oL X-Received: by 2002:a05:600c:530c:b0:490:9782:3eb8 with SMTP id 5b1f17b1804b1-493df087129mr11946045e9.25.1783353499906; Mon, 06 Jul 2026 08:58: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?= , Timothy Pearson , Alistair Francis , Connor Davis , Teddy Astie Subject: [PATCH v5 01/26] xen/dom0less: turn max_init_domid into a common variable Date: Mon, 6 Jul 2026 17:57:42 +0200 Message-ID: <36325cfc8ad82a85d9039965222e278058a18a60.1783331040.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/1783353500-A2D3B3FC-209DFCE5/10/73395122804 X-purgate-type: spam X-purgate-size: 5768 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353524659158500 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 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 0d29b46ea52b..14fa92d5c1db 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 bcd6d261491b..4c09f4c7a984 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:52:48 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=1783353525; cv=none; d=zohomail.com; s=zohoarc; b=PaCCcF2Qdn7a7GhOT8R4ze5gNTicGqbbvdoLqG5EvsY8WXXNQvNzK+o9HM/EPELjiHAbAHBZLxbsneKpnNY8VtzJmz8uEkaLZH2g6/Au6e6kC9/bb+utyHoLd/I4rs/piT7hbvLhHdPPnRYI+X8GAF3YkCVXLaSzEqkJVvszKJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353525; 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=TyI+cJHXlQ/CsV0qqhbFZd2j4tvOANbiay87gjrrueY=; b=lJVYT6uNs892KLxHJEnP8QO+JdG9D3JjrGGhCGLJ6AVVy1zAL8hNo6dqkWw/bZCC//ZzzjBYB99lQINy/Bu0pgIzDQ7OXwX+keJqdv19lloEG505s06cVqzInh1RyzUDxHxZygOK5K/OObkvOxdJ7uOBebvrSeASSHHgR1I/Tsc= 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 1783353525653247.9662216859681; Mon, 6 Jul 2026 08:58:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355485.1610279 (Exim 4.92) (envelope-from ) id 1wgliB-0006gV-IJ; Mon, 06 Jul 2026 15:58:23 +0000 Received: by outflank-mailman (output) from mailman id 1355485.1610279; Mon, 06 Jul 2026 15:58:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliB-0006fo-CV; Mon, 06 Jul 2026 15:58:23 +0000 Received: by outflank-mailman (input) for mailman id 1355485; Mon, 06 Jul 2026 15:58:22 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliA-0006be-8s for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgli9-009ym5-Lu for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:21 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd091-e002-0a2a0a5209dd-0a2a4504c49a-12 for ; Mon, 06 Jul 2026 17:58:21 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd09d-a01d-0a2a45040019-d155802cd40f-3 for ; Mon, 06 Jul 2026 17:58:21 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493b691cb44so22993425e9.0 for ; Mon, 06 Jul 2026 08:58:21 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353501; x=1783958301; 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=TyI+cJHXlQ/CsV0qqhbFZd2j4tvOANbiay87gjrrueY=; b=qDnciBfZtJRbTNFwbjMTYiwA/WrvW2KfssSKc+9+A9/3wXG0U4LpQuLfeCKnOBJB/n XIOzWS/ACanUqcdP9f9XFznoiraAyFWdJB/C8d8H0VNEt/oPD9b6WdEJ2tq6JDOfRIgr V6nUsFeKYB9KfZ7NRG8ZQtLwa5afX/IqNU+y7gXIsj3iWOJDCKqRiSyi26+AIRALceZx BXwzk1JLzbc93vp3Xz6Ee4640HqzyevpK4i2pnvfnWJGy+EfUA5f6EvYVcQKaQ9rFGqL rXEAEEw9+6Vgyi0Op1x9DxMJyLFZvwfE4KgWq00ZtkIOCyyJv+0QF/PLThe7SS7N5RKQ PQPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353501; x=1783958301; 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=TyI+cJHXlQ/CsV0qqhbFZd2j4tvOANbiay87gjrrueY=; b=MWyhNOYCiCjmIES/NqcvMxj5c4BKFqXROGsIxbe9GGY4C5zmskkdEIGma4Ggfja/FO NhHFmyg7QWuNsfIBwC7qFcLMixSACZHYzE7GwRxjTNOgkKofB+aXhuKt8PiM+GSVMASF vjc66TrVUQsaHYrM6EQx7BWtlJkAQPpYWRdFlI9amuE/8eweSlqej24HyV08uRTEm73x 4t8Ed0+d+/Wz/hrFygKYdYV1ZRpP0LgJE/FfBTp4KYKUseIbBHaV6tTEoTcsN/wZCK7W tKmB9qnr6LON+jAUslW1TEGJI3pcsL+915khuupxt9udKdyKx72crpCF58fAWbnpqkk8 1xYg== X-Gm-Message-State: AOJu0Yz2SW9hePh/Rz2SAwYf+bjifSJWWx+BGGtktfiCH8+3XSqeR5tZ pOAL7T/dS0FQKV6F6lil1euU9chJT9OzBP3fjc83nXf9fIsq2G45N/iT44qqwA== X-Gm-Gg: AfdE7cnMl7cs9iuMF08ec+u/4llN67hTgo9pJjRFKxmAP1Ga4CJiuRywN6rRjT3mV9M wZUU93Lt+/haMQYxv44ojc7mnL6vDzfAz22WQU4pCt0gcZAhtcJbbLzZBZQSbXHzywEZMm1NBGX /8o8q4SZ8MjlV3pAtZ1BZOn7YovpYLlZYNAHPqVwW5brfhZldI/RIt0usKQnvy//10qSTiZ+fWv 2CiIyu88NfBAmEoUTTktmqRQNApetBzvroS84EMAdnsw5BbyTa89/Z/uFEW7QDaoEIt94GOS4Dr OwzhpCiZCSkezELHRffZj8mHdaG2sZCB7albf5d5Tt8/wH2uhnA8CYHZ2uYpK3Hi1PPKNyUjYie BaQAUAtWo21XTBxJCnUg/8+AgjnA/Zsk3K3vDbJMNUb+uQWlzPN4novdHSog/pUW/Rwtw8NA6IT hJhl2miJTrTVuG/6nqIQh3Ej4BrZM8/DtFN8TFmir0frJEwz/fBeapHIL1bw== X-Received: by 2002:a05:600c:3acd:b0:493:a5f9:d33d with SMTP id 5b1f17b1804b1-493df08feb3mr11711955e9.18.1783353501067; Mon, 06 Jul 2026 08:58:21 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , Andrew Cooper , Anthony PERARD , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 02/26] xen: arm: move declaration of map_device_irqs_to_domain() to common header Date: Mon, 6 Jul 2026 17:57:43 +0200 Message-ID: <0854d614acf81c6d237a280349bd75832889ab91.1783331040.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/1783353501-2F15F1CC-2C95EE76/10/73395122804 X-purgate-type: spam X-purgate-size: 3776 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353526634158500 Content-Type: text/plain; charset="utf-8" As map_device_irqs_to_domain() is used unconditionally by common part of dom0less code, move the prototype to a common header. fdt-domain-build.h is chosen as map_device_irqs_to_domain() could be also called indirectly in Arm's DOM0-related code and DT overlay feature. Signed-off-by: Oleksii Kurochko Reviewed-by: Michal Orzel --- Changes in v5: - Add Reviewed-by: Michal Orzel --- Changes in v4: - Reword commit message: use imperative mood ("move the prototype") and mention the DT overlay feature alongside Arm's DOM0-related code. - Add #include to Arm's device.c so the definition site sees the prototype. - Drop the duplicated function description above the definition in device.c (it now lives only on the prototype in fdt-domain-build.h). --- Changes in v3: - Add tag arm and move this patch earlier before RISC-V-related patches. --- Changes in v2: - New patch. --- --- xen/arch/arm/device.c | 9 +-------- xen/arch/arm/include/asm/setup.h | 3 --- xen/include/xen/fdt-domain-build.h | 13 +++++++++++++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 7d9644fd8b6d..b11366d722ef 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include =20 @@ -117,14 +118,6 @@ int __overlay_init map_range_to_domain(const struct dt= _device_node *dev, return 0; } =20 -/* - * map_device_irqs_to_domain retrieves the interrupts configuration from - * a device tree node and maps those interrupts to the target domain. - * - * Returns: - * < 0 error - * 0 success - */ int __overlay_init map_device_irqs_to_domain(struct domain *d, struct dt_device_node *dev, bool need_mapping, diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 14fa92d5c1db..2af780512540 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -51,9 +51,6 @@ void init_traps(void); int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t= p2mt, struct rangeset *iomem_ranges, struct rangeset *irq_rang= es); =20 -int map_device_irqs_to_domain(struct domain *d, struct dt_device_node *dev, - bool need_mapping, struct rangeset *irq_rang= es); - int map_irq_to_domain(struct domain *d, unsigned int irq, bool need_mapping, const char *devname); =20 diff --git a/xen/include/xen/fdt-domain-build.h b/xen/include/xen/fdt-domai= n-build.h index 671486c1c837..8612e98dfda5 100644 --- a/xen/include/xen/fdt-domain-build.h +++ b/xen/include/xen/fdt-domain-build.h @@ -12,6 +12,7 @@ =20 struct domain; struct page_info; +struct rangeset; struct membanks; =20 typedef bool (*alloc_domheap_mem_cb)(struct domain *d, struct page_info *p= g, @@ -79,6 +80,18 @@ static inline void set_domain_type(struct domain *d, con= st struct kernel_info *k #endif } =20 +/* + * Retrieves the interrupts configuration from a device tree node and maps + * those interrupts to the target domain. + * + * Returns: + * < 0 error + * 0 success + */ +int map_device_irqs_to_domain(struct domain *d, struct dt_device_node *dev, + bool need_mapping, + struct rangeset *irq_ranges); + #endif /* __XEN_FDT_DOMAIN_BUILD_H__ */ =20 /* --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353528; cv=none; d=zohomail.com; s=zohoarc; b=lpcACQegNXregeBe+y8N7GXvgZuOS9BchKc2Mtnw4k3MHM3xsfT6lET0rPSeY4VF/JPTxt31kJcWdXwQlRlaDXc3cCgZvw5jZ0KYrAgw2Eb6yYDnPE1epFnGMI06GtEz47nDj16FNsFJzGtQ2R3y58cWweRLuMYm4VS7agaGDnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353528; 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=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=l0+SzijsWf1/oZv5cyKtQzNUMzKS/wM7rete2Gkzc4RFCYQu/yLhfJEBlcyLDN8BYajAFHKIoeRkWxE+3XHN1cI5BAwsYSZtppPciyphLzds/XWOLXFSUBjVAv++dFmkmjfZK9wEYQFcLxp9yy64YW57VnPOM6Oc+M1XNdSrKT8= 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 1783353528594492.84406215122067; Mon, 6 Jul 2026 08:58:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355487.1610293 (Exim 4.92) (envelope-from ) id 1wgliD-00078G-Ty; Mon, 06 Jul 2026 15:58:25 +0000 Received: by outflank-mailman (output) from mailman id 1355487.1610293; Mon, 06 Jul 2026 15:58:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliD-000784-Ph; Mon, 06 Jul 2026 15:58:25 +0000 Received: by outflank-mailman (input) for mailman id 1355487; Mon, 06 Jul 2026 15:58:24 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliC-0006vR-9K for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliB-003COz-Mc for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:23 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09f-2eae-0a2a0a5409dd-0a2a450ce8e8-6 for ; Mon, 06 Jul 2026 17:58:23 +0200 Received: from [209.85.128.50] (helo=mail-wm1-f50.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd09f-f399-0a2a450c0019-d1558032d4fe-3 for ; Mon, 06 Jul 2026 17:58:23 +0200 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-493b691cb44so22993935e9.0 for ; Mon, 06 Jul 2026 08:58:23 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:21 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding: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=1783353503; x=1783958303; 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=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=DrFd63rQ9QYGteiEvhbKFjs6rya25oGiGWy8KWNoaxtxSSmOxWvu/0UuqKKg50xw5A F42z75iNwCRLIm4g3Z0DKXz+8fC/ZYT8H921z4TBWyO+bWRIFmwQTM7AK9u3Tjc7j7h8 3YHBJ/aySiMjb5jZ+iB1/ezryHV5uXBWcbb4Bf63WdUo8ujD2P+atGFFu3p67eidp6bc /X6nZ4E4HpjUD0sJz3MVO2l8cDrHxcbI08Pce3VzKjHIAYlh4Y5060/tV/7nlAhpjcac i8FQhFyjy1jRsDfga76cqMfccRJcUZStunRF+jJz2VAOCx+onnYKs2IMmcrkgbmoPJBq q31Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353503; x=1783958303; 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=sS+W4tqZwutZWWwcjeWai30+FMlUlIOZS6B2+B7csNw=; b=QWWBANkkKoYBvIP6nshf+NmeLqZV4jNZFa2Bf2cviY9TOsAk4NA3nLLrkhOui5lUwi zMtZDsYimzL3/lwJj0i419nUzEwkefmpH0ySHGu5/ODlF6/MwMrvryEMO2qLRsVRnE/G LePp2gKgqrppqQk1VCnRQyn5Jr/UZZzSFdGmAdOrZ3b+RrzelZ5s3p6CXEnDbM3uN2/o s19IFSlgQTlJXKaIi+GSJBGJp46jx4CEsidFraURIZIIiQEbfzCKRU1BLEi5KT6PjosK N2APDP9iAm9VqlrsS+oieAiqaFf38+LSLqjUCGEwEUHskqYMaezKslw6SAK/+kTy7x8e FSvg== X-Gm-Message-State: AOJu0YypCgH/BOIZOFO7HYc2AmlA4PvtbaL7TTA8wPHSyal3I6PYm9ib OHa08sQIbvQw2oBd/0hHkg/YWnge1QfBYJ+7pkLXdNaCx85yn9ENBnLjJ0XqYA== X-Gm-Gg: AfdE7ckyA6YVJPXzDiS1hXIkJGj8yW2b+RU+djN92xcKMwxhWQ90ZGCMkBxB7iuymEG fLkJkGgjVzhvzRcJVnVYsJbeDMvJat5XUfwgyXaUS6uVop/uGwlEvCLcO67YyOmtejj85BdPTzA Z9pCEL6K+ko45qy5MY8kdmzmHTQkl7VNRF5bD1xBnDxXzpoZXqCbNa7SbS6TK2aBYL3T4tVoYQ8 707VlQzikoTZRtWdK5GBKa0jlErUSavUDJY5LtXc2BeHbGHzOZmljf5SDOPJPgLGha/oT3/XWxf VbeMIi8t8pHnToJQOP1QcrOqymcQMvLQq1EcfJld4LGBGPUeCgNdJbhb4R4kYyIF9y6TT/GiiSC l6XsSGzgWRP+BCBqGC/pa7DN6JMiQ2dlWRgiYIz+Is9wDFP+ZfIrIJiphCMbbL4v2XGN61giui1 PelqMLvsDXcFr0yDd0Ca4Elz3cGJ+xarOUZZPgvmTvn7Zo6jdpPEqhf4kKLe8/L/Tu21lw X-Received: by 2002:a05:600c:3b05:b0:493:bb45:d54d with SMTP id 5b1f17b1804b1-493df09e3a9mr13736335e9.37.1783353502372; Mon, 06 Jul 2026 08:58:22 -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 v5 03/26] xen: arm: update p2m_set_allocation() prototype Date: Mon, 6 Jul 2026 17:57:44 +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-d25034/1783353503-91924D51-EF473D15/10/73395122804 X-purgate-type: spam X-purgate-size: 8891 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353530733158500 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 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 eacfd93087ae..6f0b574755c5 100644 --- a/xen/common/device-tree/dom0less-build.c +++ b/xen/common/device-tree/dom0less-build.c @@ -747,7 +747,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:52:48 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=1783353535; cv=none; d=zohomail.com; s=zohoarc; b=KEmRUJM+SPjCBskATC5pbLpZ5UA2SVr5NuVnZWzOMQtwkFPh+9bvYFkgUUEgoCB+6Ll8nirA8YKVPgfJPgQn20kWiA3/fvwAOIwM8nifMpMCxRbtDfzshNGrTANG3Wz0M5jYKIaoOOCkX0pqQ/YL5riC5sC4Fi3rVeKT16Ry7lo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353535; 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=UaNFNH9DRDfcOheNP7RGDgs9zgSwZrJZXL9nPPgLQm0=; b=f7Gju9cQQWPfbTRekWZBAG3tlJhdFofH13yB/LfdqSOw1LEMdOihVVprLb1rQ6uOFlhHtkZ8w7XEKmIxtIcLmGG7LZqNEDEnYs2T9S1J/jqJxCCqazKAu2q060o/BZoL/CD4m6XPCChSqxJwLAP6YPx1Q/x1t8+ub4U2PFQste8= 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 1783353535564206.30453479367065; Mon, 6 Jul 2026 08:58:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355489.1610297 (Exim 4.92) (envelope-from ) id 1wgliE-0007Bm-BH; Mon, 06 Jul 2026 15:58:26 +0000 Received: by outflank-mailman (output) from mailman id 1355489.1610297; Mon, 06 Jul 2026 15:58: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 1wgliE-0007As-2M; Mon, 06 Jul 2026 15:58:26 +0000 Received: by outflank-mailman (input) for mailman id 1355489; Mon, 06 Jul 2026 15:58:25 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliD-00075S-07 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliC-003COz-DE for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:24 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-22 for ; Mon, 06 Jul 2026 17:58:24 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a0-5a27-0a2a45020019-d1558029cd01-3 for ; Mon, 06 Jul 2026 17:58:24 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-493c55d5c7aso31169935e9.1 for ; Mon, 06 Jul 2026 08:58:24 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:23 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353504; x=1783958304; 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; bh=UaNFNH9DRDfcOheNP7RGDgs9zgSwZrJZXL9nPPgLQm0=; b=kOSVRxzUlbhWSMCWuFpo0O9m7oqOtFASB7zb9f/fa/HNKSm373R3nvZ7etVgqZhsaA YwoVNVW4+EZ9p1GhvkngzQH4CdE8xG4w4KmAi1vnrlBLf1Jkm8GA9xx+kIQRid+CC9jj 5q8sc3tccSy/dabsDuSMYwUKB2VevXsHJPvDXzjVO1vhpyIuzi9jGE4Lr/ziwDvHOSQ2 MXgTAUi66kkFszTi1jhLVUjzN9iMc4SooFmbRk4IokQn864g0b6rxIk13O7lHio5u1ah hQYen24ZylC7OfMVdzghDmvp4JXDL04L9eDg9rohD141JaRX8KcIPJJLLlme/o72MJuL /nOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353504; x=1783958304; 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; bh=UaNFNH9DRDfcOheNP7RGDgs9zgSwZrJZXL9nPPgLQm0=; b=mWX17722e3dcMcvchVSW1OUxyXXe9fWyV0ZbSP96D9niIh+y/pbe2Zt4bXZeAcNpaD OW2WwNSC+9J+pb05GaU8Fj5Vf3obdHvz+dMr6oCmL7p2rq5II5fJvz+pKWhfMkvWoE1S zOyW1HV8fKlPu/7GZvCO9Iz/CHfhrMmWKMy4NMyqjZfOS23qh66OiGdP1gC/yd6RBNxk GAY+4LdpWcpu3hDBsNheUo6jfcPzmlsAFSamOU4elmVUr6CYCbfbMfPngOB4eG2FsHQE 2ENO8qPpdiOnhZ1e4kwVkc7p5bSAAAonuuCdO9QdYG8Rljg5GAfS/ro5Axln05nyB3V1 ZfDg== X-Gm-Message-State: AOJu0YxqiefhKsNbPbyZuBAszWy2qyOHQmlm+VowDxwhErkOyZMU6zKX oCmwdbuqH8HFTrWGtQ7/l82fi+oLxojG8h2nw3+0DykeByhj1IuxmV3pCsmPUA== X-Gm-Gg: AfdE7cneY3fsBfWJegmFYPKhJUse72/GeJMbfnrRr1PuaQOmmHZsYWTkNU16AjdE+Aq cJbY+dVqFKz7gfObo3jSSi4zPn65wAw9MnFBL9jBtc7RjhJp4F9XIRPJJxMjfDJtVv4ubyGovc3 YIh4J/xG6TjaDeDnSWth34TrsHi1I/on08ChWxB5Wf4YABbq0X1Ms67VjV6KByyvXaauNBF0cKv vWnh09ZpleMK+LLtnqIFm2Oh4KJffgGgqorlC0naxSCpOJtc9KNN/i3UO6+KfcEbIVtZHpMFSLQ 9UMFtJQL+W45of99g/Iy3ot/YF3Hp0mP4tOnxZjImzMfwesWYRbAqF3xklG6klt9CIL0tsfL+cU PkOf4Sx4MVsfCVHZXh1UJweLkzC4f7ITh+iqDyihyqGjOpIpT4wvNo+yfzVtbEf5Of3V1hUIjfG QAvILQUAusueKpkzGeUFJHh+RfVJ0TUSt32F4WJf7FqWHddZSxYLAkezm7Fg== X-Received: by 2002:a05:600c:5309:b0:490:d38c:7836 with SMTP id 5b1f17b1804b1-493df082feemr14569175e9.3.1783353503768; Mon, 06 Jul 2026 08:58:23 -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?= Subject: [PATCH v5 04/26] xen/Kconfig: introduce HAS_STATIC_MEMORY Date: Mon, 6 Jul 2026 17:57:45 +0200 Message-ID: <39f6e7414696acad4a1257afaf067a832b165cc4.1783331040.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-720697/1783353504-4D90E7C5-5340CAF2/10/73395122804 X-purgate-type: spam X-purgate-size: 1962 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353536673158500 Content-Type: text/plain; charset="utf-8" Introduce HAS_STATIC_MEMORY so that STATIC_MEMORY can be enabled or disabled on a per-architecture basis. ARM selects the new flag; RISC-V does not, so CONFIG_STATIC_MEMORY is unavailable on RISC-V and randconfig builds no longer require an explicit STATIC_MEMORY=3Dn override to avoid a compilation error. Suggested-by: Jan Beulich Signed-off-by: Oleksii Kurochko Reviewed-by: Jan Beulich Reviewed-by: Michal Orzel --- Changes in v5: - Add R-by: Jan and Michal. --- Changes in v4: - Reword the commit message to explain that HAS_STATIC_MEMORY allows STATIC_MEMORY to be {en,dis}abled per-arch, dropping the reference to guest_physmap_add_pages(). - Split the STATIC_MEMORY dependency into two separate "depends on" lines. --- Changes in v3: - New patch. --- --- xen/arch/arm/Kconfig | 1 + xen/common/Kconfig | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index 683ab7d25a1e..d748404e82da 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -22,6 +22,7 @@ config ARM select HAS_GRANT_CACHE_FLUSH if GRANT_TABLE select HAS_SHARED_INFO select HAS_STACK_PROTECTOR + select HAS_STATIC_MEMORY select HAS_UBSAN =20 config ARCH_DEFCONFIG diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 8b48d84c79e8..5b289e444fa5 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -161,6 +161,9 @@ config HAS_SCHED_GRANULARITY config HAS_SHARED_INFO bool =20 +config HAS_STATIC_MEMORY + bool + config HAS_SOFT_RESET bool =20 @@ -196,6 +199,7 @@ config NUMA =20 config STATIC_MEMORY bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED + depends on HAS_STATIC_MEMORY depends on DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY help Static Allocation refers to system or sub-system(domains) for --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353528; cv=none; d=zohomail.com; s=zohoarc; b=WoKByr5UphDuDfk7r0Wo8tuIznexSob75xRuMfkIXqK07R0W1zMD5mTEGjLxw9oxqB5xtNCrmWNlVNxcIAkWxp7NgNFH8M707tMouDn6djBZaTR8Bmmr/3f6UmMxwbTeBvwtd7fKGaAQOwkCF58XTK2Tg3cNBJNwcqm3yQlg7IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353528; 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=9q2co12X66hZII96yfXyVBuNaa4Dm4OQ/7bOcOdJkmg=; b=a+RRFebyWikpCrB3QUyDaZVClvxWj0vkpM0/Qh+ALwO4gd/kpkgYt+eHjf5AMushsDUy5BnjZAkphxmBv0k4YOoR3mF5vVLKSn14HP5GrgWP0UIIsImO0YquDrUzwcW2i3cQqXwpo6HLmRSNC2M0Df1yKZOyxXQU4zD1QsFqn8Y= 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 1783353528043558.3134966361163; Mon, 6 Jul 2026 08:58:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355490.1610309 (Exim 4.92) (envelope-from ) id 1wgliF-0007Yu-HT; Mon, 06 Jul 2026 15:58:27 +0000 Received: by outflank-mailman (output) from mailman id 1355490.1610309; Mon, 06 Jul 2026 15:58:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliF-0007Y4-D0; Mon, 06 Jul 2026 15:58:27 +0000 Received: by outflank-mailman (input) for mailman id 1355490; Mon, 06 Jul 2026 15:58:26 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliE-00079r-6x for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliD-00AcWu-Jw for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:25 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd08f-bab6-0a2a0a5309dd-0a2a4506e170-26 for ; Mon, 06 Jul 2026 17:58:25 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a1-08de-0a2a45060019-d155802ad59b-3 for ; Mon, 06 Jul 2026 17:58:25 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so20514595e9.1 for ; Mon, 06 Jul 2026 08:58:25 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353505; x=1783958305; 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=9q2co12X66hZII96yfXyVBuNaa4Dm4OQ/7bOcOdJkmg=; b=pkKJY2ZNLOC1OP1CxWM6pdNT/UswtOEbgfw5N/fnvRsNQnrslXJ98+n2uWbF7vO0m5 MVnrL0wjWHK93fmGPobkdyohAxShzhuVwIbayZp1iNjT4NdND3CTReXMsQNvWlHD0P5F JnXfKKCNue0x4lMqhX2NGB9RjA0W5q6FrlivGTiPJ0JuDFWsbM6C5jVkazwwohm8tagY RakP005c/yBtZC1r09sN1LAea32O/9bT/9oo/v+LWus1RcbvYMV6kJEidPZKj7AKINgX nqxvwWQ8j5oZ62c6ef181lHeDhG8H3WWMeLWt89x4DJGwmI/IP8X+LyYBghYy+P4vs40 cKiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353505; x=1783958305; 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=9q2co12X66hZII96yfXyVBuNaa4Dm4OQ/7bOcOdJkmg=; b=rNEQh488YTBwfJuB98f521NJIvKfNWxJ9N2ShdXVsfQcrCRqHTard3oXN3WT5+2HmD PgzkNJdT0/MRbHQdpzmmBG+f6izVm6e3CSABmC9ve76rJ4HyPpv+zVRMHFdK5T8+WmuH UTVwDtLZ4c8fvVsfAUwqD5acj5qFylrZiApd+k+vJx/vlAsJEGYCJTtu5dmgw+F239aE U+hXblbbBkNl+EITQ2u1BKiMBHdlGu0GmCchtxKvoBtoZS4wqK7ZDiEtDl8+ALDYq0JG jx7DsM1njZj3qLTUXr17IhJdOqi2BNz3Ps1Rebe9p5R3JlSKf0bz1T8qwHgOdjAJpyWA k6BA== X-Gm-Message-State: AOJu0YyIgnvkxSMxBJB98t8rK40B2CSaQv9+2oxK03Ki+nb4F6bfXQHK trALtg/hCYYPsNryUHHYN0cHBpijXIpKjvjlRbJwEBCIYXOIpoZshkXKllU/Jw== X-Gm-Gg: AfdE7cnjue2Hj46PsFK7LF++I1oAC787WsVDiopi7Odjr8McbqTdvCaEfnaOTCOV30C Ag9FTsLlsA/k+AE7S9VLoadfWHK7+KhtURZNftDFrzkcHv06dsezm0mQdirtbDyJmzyM1DryPj0 u7MiePNtfYvgwifkf53Uc15pCMQFcOGKztp1PVdgx6r8LKEuLLlOPZvg1FYU8HD+74d8gwp9X40 6VbNb6h/YvMA1qq4jmZ6RJLEdEkdU7tRQsa+2TTjeR6EsOUPCBzH4+fWZlYDYKWA1WnRJunRDV7 yO1DRomUlF8KmtV8yOVtL2DYQhK5t8o+q18OcHivhlEzIaf5qyyrxTqUrw7atcBSzUlbwvflwGB gyDXJZduzzgg4LiQvDD19s/5zc+BKPLsYbbZ7soJ6Bq16mTA0/rGfpav1XQbL1Hi6idKoOPQKEh j4hFh0DUXD9Rr7VleBVVuPhBs8K7izeqP8yZL3b4DiXxkVcZEQBPBJOOX5sg== X-Received: by 2002:a05:600c:4585:b0:493:bc4a:fb55 with SMTP id 5b1f17b1804b1-493df09e3cbmr14351095e9.38.1783353505030; Mon, 06 Jul 2026 08:58:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v5 05/26] xen/riscv: rename enum intc_version to intc_variant Date: Mon, 6 Jul 2026 17:57: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-16d1c6/1783353505-4272068D-547A0081/10/73395122804 X-purgate-type: spam X-purgate-size: 1633 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353528683158500 Content-Type: text/plain; charset="utf-8" Rename the enum to intc_variant and the structure member from hw_version to hw_variant to better reflect that these values select between different controller variants, not versions of the same one. Suggested-by: Jan Beulich Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5: - Add Suggested-by and Acked-by: Jan Beulich --- Changes in v4: - New patch. Prereq for the next patch. --- --- xen/arch/riscv/aplic.c | 2 +- xen/arch/riscv/include/asm/intc.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 739e8dab3498..6a1255c5f403 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -35,7 +35,7 @@ static struct aplic_priv aplic =3D { }; =20 static struct intc_info __ro_after_init aplic_info =3D { - .hw_version =3D INTC_APLIC, + .hw_variant =3D INTC_APLIC, }; =20 static void __init aplic_init_hw_interrupts(void) diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index ecdc8a5e6577..675f703ec97f 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -10,7 +10,7 @@ =20 struct dt_device_node; =20 -enum intc_version { +enum intc_variant { INTC_APLIC, }; =20 @@ -18,7 +18,7 @@ struct cpu_user_regs; struct irq_desc; =20 struct intc_info { - enum intc_version hw_version; + enum intc_variant hw_variant; const struct dt_device_node *node; =20 /* number of irqs */ --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353539; cv=none; d=zohomail.com; s=zohoarc; b=LzusVvgo4jneJc7xzlhLdGMXa0B/c7uTzkLC8NbO7WEsI7Le3OUCCYG91j7dtZ4ILBn5IXMZ2YhOcQG3YLLMlRhio5chNtwwDsQtbZs19yBiGKFU7cwrShFyZFh1aeZhZjsJx8vj2xPNJxsEvSvT7Hs6jX25JduL/PC925plKOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353539; 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=5zepiqiigHvqnD5vmRfX34e8SW56sHhvkSvrCXNFv4E=; b=n2ArjByousJ2gZwm5cg6quaRYOwqNVPuvNqxP3n3O6it8aSXaO1IZRGQ/h7aKER5ws68uyoNe2jKhmwGwpuFU9n2si5nEE7UEHMNWHHNPzeqcc5gbuutuOMJubKa3j0RSvv2Qo3NPa4ZW3oYFnmwu6Ys2UD9RiukYJBc/uV8ouI= 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 1783353539388417.0488726583627; Mon, 6 Jul 2026 08:58:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355492.1610318 (Exim 4.92) (envelope-from ) id 1wgliG-0007rA-UD; Mon, 06 Jul 2026 15:58:28 +0000 Received: by outflank-mailman (output) from mailman id 1355492.1610318; Mon, 06 Jul 2026 15:58: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 1wgliG-0007qA-Pa; Mon, 06 Jul 2026 15:58:28 +0000 Received: by outflank-mailman (input) for mailman id 1355492; Mon, 06 Jul 2026 15:58:27 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliF-0007Zt-NN for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliF-003COz-3r for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:27 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-26 for ; Mon, 06 Jul 2026 17:58:27 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a2-5a27-0a2a45020019-d1558036d0a9-3 for ; Mon, 06 Jul 2026 17:58:27 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-493bf73ec2aso20502945e9.2 for ; Mon, 06 Jul 2026 08:58:27 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353506; x=1783958306; 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; bh=5zepiqiigHvqnD5vmRfX34e8SW56sHhvkSvrCXNFv4E=; b=LFW2WjF2POOi8jJKr7fZeZFd5rPclj6txlkeQWpV/dBgDiaB830mLPyfi7++yD3r0C PR39wjH15RsDblBRjEFMGyS7myzgU6z2FlXUZxGTnYJmU9AyNa4yON6v3zbMcsg60Dft 1mj3/De9vBzygsGRiI6DbhuFY/Kad2rla6J6B39++vYdeXd9czTMRw+Zyx1BiNgTM5A7 I4ZI29spYH3XT0v+fqCvx6IDMsUEzZVQw0uDBnbMxFZ1Ub7kKzwR7LS+nRfjA8Z7Ex4/ sc+PrV3Gph/+SSLLbUSALVOW5IGsGqyk3sx1/3Pw4YkjNMV4Lnj4mfsWyTfcnlQg5h7b Qtug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353506; x=1783958306; 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; bh=5zepiqiigHvqnD5vmRfX34e8SW56sHhvkSvrCXNFv4E=; b=fkRHHWXkwRvfA2O4aQ/DllJKwyig6BvUbq8XGkFuihVbQF+d0DeaATv/z8DV+0h+rM OWQbeort8fiCNw/R6/IwWgvBypgVrYver945qAvjNCx8Zgnwy5UpiL77h8j8jo0RsaIe x+JV67va3IgGhqHJG7SrnQ6nIec9gLOUMLkQm2c7lxbFAfqjLX3Q4eJGRmyHGwJ2vmyv hc85RTRlHQRO2MtoBUD1edaRWmvZBhPsJJTe9Vk/CQtqI1Q2aAIo70DkaU+PWZTbbXTI jERG8GymeMg7RcZcW4d2x0n66KKHPgooryTSTgBOjwI8mZZAZmyFQQth3eeB1+xVY9CC 2v4Q== X-Gm-Message-State: AOJu0YxSBSWHDNOhi6ck8EshOPCbN+vcnbfXCdYxS39sAXZ+wnZoLHaw +YgbL2ATFh1yBQdksp7mAEG+RmLszEE7Q/4Ll9FzTQxulRyVif944xLfRQW+AA== X-Gm-Gg: AfdE7clBoGDZa1AW3hfawNffKgAjRXsPtLAcqJaUhmOcXnKbY7mNrGM5U4V1leOls4K 5Yo9J9uBZtm+hvdc0V6by0LfPBTnMHcnetWsPideYiGTN3vCE8vsvdlzbpFqjLzl4VAxzmXoS/B qp5IJvWw9gW9EA9Gn8CCy1lUZjRfFvQGsyevzOel3k053gHp6QlVGnkyAhlQhad4pt4HTUVAYOb xcNYmzENpFC94plLYtyBxSuou7ZExZMLGh+qDizmPYXFd7JXogjBkE9yMp2sirATSuiCCsAlaUe 5Y1cxclLb0rYVr+lR14zOdxFsuQQdmOXTHKlE9whveAHJ1vkNKSNyHzKR8wFkLWnDW/ehZlmMRQ CnOqWczbUEGsHdYsiDZuKK8rdwZPk046RA6tbJc/rarYu7xitkhsSht7g56eIDNQQYvSOUApE5e em7q24QRWzJJ2UuMF10bkaS6tqDs9ooAckMTCX0oV670WysUj9GzlqhFhlIQ== X-Received: by 2002:a05:600c:474a:b0:493:b499:3ef2 with SMTP id 5b1f17b1804b1-493df0b5b14mr13478395e9.37.1783353506490; Mon, 06 Jul 2026 08:58: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 v5 06/26] xen/riscv: Implement ARCH_PAGING_MEMPOOL Date: Mon, 6 Jul 2026 17:57:47 +0200 Message-ID: <8e82427407ad321ef8d992d2d4e0a6370e7b92c1.1783331040.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-720697/1783353507-4E5147C5-DD3A2495/10/73395122804 X-purgate-type: spam X-purgate-size: 2633 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353540753158500 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-v5: - 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:52:48 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=1783353541; cv=none; d=zohomail.com; s=zohoarc; b=oL0z+O3LkS+N4nPkjGaUfkROOyuzYEQ2O5r1e7X+QqWZ9AHk9xiyH5NLgWXFoGxvOT6++88WC1ovOo2+rsV25AvjXXpwvue4lSeqtHB8utIzo7MEdlbdCY5fcP9LcxCt1dqZ5IXf3GBcQ6AfM/W06/0nsobAWSKTDt9yDdW12CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353541; 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=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=DuvpVJ8H0OYvoodO31gd5gRgdWgUp5KGkYSzJQgqynrEG+vHBaUYSxq+AMSoqlCh9PnAnKeMNWznrj1MEMX88ZsXSNpq8unkpaxQldK0ZssrbyGMirczBDq4aj04ngaeyFof87Q4XblJ7khJW6MsRv7j2RFajzTutwpvq2/jarg= 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 1783353541688263.9417194695135; Mon, 6 Jul 2026 08:59:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355493.1610328 (Exim 4.92) (envelope-from ) id 1wgliI-00088j-Ee; Mon, 06 Jul 2026 15:58:30 +0000 Received: by outflank-mailman (output) from mailman id 1355493.1610328; Mon, 06 Jul 2026 15:58:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliI-00088S-9c; Mon, 06 Jul 2026 15:58:30 +0000 Received: by outflank-mailman (input) for mailman id 1355493; Mon, 06 Jul 2026 15:58:29 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliH-0007ta-9J for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:29 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliG-003COz-MK for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:28 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-30 for ; Mon, 06 Jul 2026 17:58:28 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a4-5a27-0a2a45020019-d1558031d16c-3 for ; Mon, 06 Jul 2026 17:58:28 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493c59f740cso22407835e9.3 for ; Mon, 06 Jul 2026 08:58:28 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353508; x=1783958308; 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; bh=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=Ik/sDORWAvy5pbB9ArKmqNnPtyhxbWROlpS5mG2HXJyjVbtKUkhL+0cJwp8sLOoLic d8MldxFUAaB9D+1EGcLgY+ltTcnnA1kdcrkjhHqzuy0Xnpqcqz5dvAGclFUP/TNxCC2l zNydx4khxzHpOIVddCBWXZaOwIK6S7B5C8C2TJz8yacIyuwxORPep2fbm8wLtacuAwi8 oUYEbARg1BJNrA6zNHV074n+S8dGzUaDafjjUBvnQ/jPRzVVHx4KBnt2rl/4vC6u/l+D FVJtYNGXFhxyu9gTcYBh4H7aepnAZ6CyaqBlT9VLxm5C44/Q3aKoDd53VbxJFzrW1yj0 KTYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353508; x=1783958308; 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; bh=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=IMMUC6Llfz9nOdb2ecqFeWIZellKZA97XLJofIvtjFN93JswAwCjtlO+rs2EX6We00 NuiL18W9re1ftblltBD2fLPsrrxYAPtLEDKpziaova8hBlI/nftoCVIJMLap0ALTEOQM ZvrgPiXK3JI9e+qx8tumyjYroxPRb6StC25hQsl6TURdHP2jVoU9u31Lovmnmrh+z2BG SymOSd56R6Iq4H+2ONSfU7UpDRUN1wVtQiwTc5RC4U+/cAtSHe98Ht7FcJM7HT2r3Ue4 QeVFmmesOkvBvXkwVVpWAqY925gd4e9rbsA1XYODl83Q4stTqwYhUczVUPZahx6qAAdo 08AA== X-Gm-Message-State: AOJu0YydBSPyF4hxh6MuWzBJRfFvzcIsDKTXN/4LgUbBK9l6QdB0IChN EZV1LZVhQKdhbS8HhClQhP66auzmHJ7+n5SiN8Qv7P9iYLFkN7c2Miea8DGqHw== X-Gm-Gg: AfdE7cnvjloGxuwySAa4ZMFfH25ayOm41yeu6wujypVsTPiVzsW2UnHsI1M+dDPIGWQ Jc5PGjdVxeka8LX8MDXVXrzXCFl2UFHxZH8L+yGGt3QX7XFx6xDabnaN1rh80i5pXeuRu2TKQaf 9Xve2I+IuqcdeXmz0Rc8zSFRWBpvbq2EEjpsuSW8ume0ci8ad7hixiRepz+aJ1S0dR5ia0C0FA4 7dVjrhx7b7ZiWaYzusO9YkwWn7946M73xyntOBJOEbZxDiak+oOZN6rkp4iC3nghfhpbMYEVefR fWFcb9OC7oGPPdxhmgmZJBWCT/v+F1UdaXgpBB4WQAXAH89HO/uFd546UdaXFyxOoH963mOriAh P+iUzUucsBE0RWlf4bP3eDbmj1b3sDk96HFOdIsW7Tt449Up4AORxae1TyuQ83jXf+lgXt4Mdf3 W2cB2SxCCIusVJSKzd5Nvwk3IV+J4Cq/nzA0BlPMUII9mQd/FNXOUtQPlf9A== X-Received: by 2002:a05:600c:3143:b0:493:d800:204f with SMTP id 5b1f17b1804b1-493df0a7521mr14274605e9.21.1783353507784; Mon, 06 Jul 2026 08:58: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 v5 07/26] xen/riscv: Implement construct_domain() Date: Mon, 6 Jul 2026 17:57:48 +0200 Message-ID: <77cfcb52b46c96d68e1fe4032b238bf40f77e3f1.1783331040.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-720697/1783353508-547197C5-2B2108C2/10/73395122804 X-purgate-type: spam X-purgate-size: 3114 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353542864158500 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: - 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:52:48 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=1783353544; cv=none; d=zohomail.com; s=zohoarc; b=DWCxAZbmag1ZnqSBUV66zMnMsuvM6PFNLmKlElOhTHvH7hoa9cWAsa/kaXWPw7GNU+02ogBfjfVPwhzN35E8xhIm9ivEO8lIgo0wy3igzz6z6i92JvbL/z5sg9xaaiJkrD8nriWyqLo62tS7v+5Obc9Ua6YBbhUuSmcFM51gEb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353544; 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=2wM02Rzxvcnp+4y/YzfnnOgBpcuqxKShTB/HzBg0suo=; b=LC692dQRNFjxO0hggWq6K1cBKv9xxV4xkEOQSi8hIN2wze/Mr9aEXReAyv6dBG7PUxmPy0S49A71WnuOltZapxGzyNQl1hwgj4TAiVG10qB5FIbRB33azgvGnQS/s3MXSh4Bpz0HAPJ7za9FbROYELb2It3ubJGb7NW9uanPpYE= 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 1783353543997194.52684441065276; Mon, 6 Jul 2026 08:59:03 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355495.1610338 (Exim 4.92) (envelope-from ) id 1wgliJ-0008PO-SK; Mon, 06 Jul 2026 15:58:31 +0000 Received: by outflank-mailman (output) from mailman id 1355495.1610338; Mon, 06 Jul 2026 15:58:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliJ-0008P9-J0; Mon, 06 Jul 2026 15:58:31 +0000 Received: by outflank-mailman (input) for mailman id 1355495; Mon, 06 Jul 2026 15:58:30 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliI-0008Cm-Sz for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:30 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliI-003COz-9x for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:30 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-36 for ; Mon, 06 Jul 2026 17:58:30 +0200 Received: from [209.85.128.45] (helo=mail-wm1-f45.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a5-5a27-0a2a45020019-d155802da869-3 for ; Mon, 06 Jul 2026 17:58:30 +0200 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-493b27c7451so38128505e9.0 for ; Mon, 06 Jul 2026 08:58:30 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353509; x=1783958309; 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; bh=2wM02Rzxvcnp+4y/YzfnnOgBpcuqxKShTB/HzBg0suo=; b=Kxif4d4ZbgeE+LO3yz9Jf6TvFIlb8nYwn6Ca67uTQi5JT+MBH6sMr8RwLVHOyX91Al o+V+90YG3bP3cX/Tzk6A/bgqeChP6QC+VLCPI4Ivg9KQy640XFUMVzSY6lCJeU7i3MqG GV5Edlw2NChMfjp3hWbZroB7gfr63MaZhojrT9dk0GUdVfLkE6GkLP128Fi+4lhVQ8vV gh5cR56LpwkGzLfaE6Zxw44YEjjM65V75eiwXIH8hu8ML5r7HO41FzXTh12CMAguJfQh 2O/w6MmgvC66ma3lmKYnGt7LCHBBqRXJy3mEKeUOnq9sea915bITNMwE5dpMgcCjE1ZC TrEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353509; x=1783958309; 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; bh=2wM02Rzxvcnp+4y/YzfnnOgBpcuqxKShTB/HzBg0suo=; b=eqnFq+qv/xbk7jslJpc/6ARwktns1aHbJC4q+S3fyuLlAuKBIqbTdWGNFX3G9N3D6j vZaC625TI9/kam1k3xcmmAFNkSmSvsVaNm7Ec5RqObBQamQo8+ADMp/9jomybBaaz4tH ucYAU/v2cbCb8tQ5gUNkzSD1uo6GEDDx6RDAecmAyJJoXJ/cjUJW6Rj1WHJ0nKLUzHWn rvZsLqbkXrtRGGBRDp0eBCH3uoLrrpjH0hczAwYNY88spv9sqUgDRSAafjfDPi9PEwWM KjO/HXnvgBYZObZVxXl7bmCF/WKeNW/gSE+5QZv9LD+D4+47jzOMZyXUxYWz8d1gwLKG s+PQ== X-Gm-Message-State: AOJu0YzWunerHAOVh/jxMIopaDJ5W5cKe0zBTaDz+j3A9phr5KEvqN4t nDug6tWag0ebFiUhnDekO4l8MPbGXpKtxMOa5dcsJ0faV9z4ztjR5Z43pdWC7Q== X-Gm-Gg: AfdE7cmvrGIPKjcU+Db6CHBb8JUYSBbE6ChAV6GSOfl6LazJv9I7X+XqVkHdN6QHe81 /KsJP2rLQvBnboSLpGuIrpitf1g7fdMCuopfEBpvfl7Zscv2GbO1M9hUw5cYWRmXVnBLkEvUPbc i9WNrcHFpriHjTyJL9nRvlhTvRdUgLsE+46DLT1GCuqYpGgQXQOPbizKcWRLHRuGiPGC/JzaFhr 3Oo45WyUK9hnbU8pF1BQCklGVnXtfyMPXI1RYx7evdR8Y6AmBMW4JNj0RhHXuRn444BRArdx9x0 Y8cde9T0NMH3nVqE/yILnevR0KJFc/FJxbjVb0BZ7U0sM5NWgKdY1+n7F54mLNKN8776cuA/lmC 5L0UKy7yr0ger0ZdmKipQ8j2UuWebJCeqNzeWMhC9mt7YEZn6fiKwJ1KXkwT1OsA4B6bol8qbVh 9Gl9PfrbT39Wdqr6d99cLSl8LiY7Ty/+aJ0X+Kpc7j9DRBGJa2XJJ/BsoYaw== X-Received: by 2002:a05:600c:811b:b0:490:af63:2cb1 with SMTP id 5b1f17b1804b1-493decbf15dmr15755415e9.7.1783353509335; Mon, 06 Jul 2026 08:58: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 v5 08/26] xen/riscv: implement prerequisites for domain_create() Date: Mon, 6 Jul 2026 17:57:49 +0200 Message-ID: <2e6d9e0283bf401ca698e72ddeb7c7f4feaa118e.1783331040.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-720697/1783353510-7791E7C5-04EB336F/10/73395122804 X-purgate-type: spam X-purgate-size: 3039 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353548768158502 Content-Type: text/plain; charset="utf-8" arch_domain_create() and arch_sanitise_domain_config() are prerequisites for domain_create(). arch_sanitise_domain_config() currently returns 0, as there is no specific work required at this stage. arch_domain_create() performs basic initialization, such as setting up the = P2M and initializing of next unused phandle. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5: - Only review. Nothing changed. --- Changes in v4: - Add Acked-by: Jan Beulich . --- Changes in v3: - Move arch_domain_destroy() from stubs.c to domain.c next to arch_domain_= create(). - Drop d->is_dying =3D DOMDYING_dead from arch_domain_create()'s fail labe= l as domain_create() already does it. - Replace BUG_ON("unimplemented") with printk() in arch_domain_destroy(). --- Changes in v2: - update the commit message. - Drop vcpu_switch_to_aarch64_mode() from riscv/stubs. It shouldn't be und= er riscv/ at all. - Drop next_phandle as it is now in common code. --- --- xen/arch/riscv/domain.c | 29 +++++++++++++++++++++++++++++ xen/arch/riscv/stubs.c | 17 ----------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index c77be3b827eb..2819ff4e7c92 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -289,6 +289,35 @@ void sync_vcpu_execstate(struct vcpu *v) /* Nothing to do -- no lazy switching */ } =20 +int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) +{ + return 0; +} + +void arch_domain_destroy(struct domain *d) +{ + printk(XENLOG_WARNING "%s: unimplemented\n", __func__); +} + +int arch_domain_create(struct domain *d, + struct xen_domctl_createdomain *config, + unsigned int flags) +{ + int rc =3D 0; + + if ( is_idle_domain(d) ) + return 0; + + if ( (rc =3D p2m_init(d, config)) !=3D 0) + goto fail; + + return rc; + + fail: + arch_domain_destroy(d); + return rc; +} + static void __init __maybe_unused build_assertions(void) { /* diff --git a/xen/arch/riscv/stubs.c b/xen/arch/riscv/stubs.c index acbb5b9123ea..3a7953593d93 100644 --- a/xen/arch/riscv/stubs.c +++ b/xen/arch/riscv/stubs.c @@ -101,28 +101,11 @@ void dump_pageframe_info(struct domain *d) BUG_ON("unimplemented"); } =20 -int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) -{ - BUG_ON("unimplemented"); -} - -int arch_domain_create(struct domain *d, - struct xen_domctl_createdomain *config, - unsigned int flags) -{ - BUG_ON("unimplemented"); -} - int arch_domain_teardown(struct domain *d) { BUG_ON("unimplemented"); } =20 -void arch_domain_destroy(struct domain *d) -{ - BUG_ON("unimplemented"); -} - void arch_domain_shutdown(struct domain *d) { BUG_ON("unimplemented"); --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353545; cv=none; d=zohomail.com; s=zohoarc; b=HYRRT3+uyM/IwldETNeZmzjxGPGR6w/Ikq+s9PfSraRptaXVskWOgF9lHyx0cnHPYz/iOnwj6P84b7+OcA8sz9KP62ipHl3mBbl+3OuArQPg360vgj1GHBEqMLs+PyZclWk8RUaB1f9+Q4uOyAtFbAOduakVsFo83scLfwXwB14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353545; 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=PMUxY16+EjQiunTHmrdOH7xzPAM+NcHF5gtkkVq7+74=; b=Y+/HhwNUb+B7HQLbdlSiNW0Khcsc2UbWtYB7bSZwPCKClfACR+0+ugbPsjfJhNPajky3snYLVwGQHKIlwzSnJL7sYjw62s5vzZnYzfeITk0gvhjyT4nDvdfxHq38pd44C+nHFBRqDpxu0m30CaDdMBOjIAG2Yv8Ay8Q9AMT3jPM= 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 1783353545232333.7752046752703; Mon, 6 Jul 2026 08:59:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355497.1610346 (Exim 4.92) (envelope-from ) id 1wgliM-0000Lu-5j; Mon, 06 Jul 2026 15:58:34 +0000 Received: by outflank-mailman (output) from mailman id 1355497.1610346; Mon, 06 Jul 2026 15:58: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 1wgliM-0000Ld-0v; Mon, 06 Jul 2026 15:58:34 +0000 Received: by outflank-mailman (input) for mailman id 1355497; Mon, 06 Jul 2026 15:58:32 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliK-0008TC-5a for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:32 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliJ-00AcWu-HN for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:31 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09b-bab6-0a2a0a5309dd-0a2a450b8a36-10 for ; Mon, 06 Jul 2026 17:58:31 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a7-ac48-0a2a450b0019-d155802ab062-3 for ; Mon, 06 Jul 2026 17:58:31 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493b1710405so19850345e9.2 for ; Mon, 06 Jul 2026 08:58:31 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353511; x=1783958311; 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; bh=PMUxY16+EjQiunTHmrdOH7xzPAM+NcHF5gtkkVq7+74=; b=Ycbog57HnGLQpKPY0FJBgCPUJkIfFFDS9NQlxihMMiGuqvKj3c8CHzJW9YhQ+ZOhSG O7sKQyPzHOlT6FI8vTyZowSpve/NhUK1CcYCDBIes0qhZ4oYutBvTAWAr/iQ5i0Xhkfp z7qwHT4DyKNrU3LSAXaNmYud3I6RNEVmSe0QH10XZb+5V1qToGvtdvj2daAtC5VfU26/ sGlXchqPU9Bpet9md938u/C6xAJRUHljFHd3mXIQBu2l49TF2DDFuj5bVcZwZ/T8xQoe tD50KM9FyQHBLaRDEFl+q2saxl/2C/xruhVM/vHy8w9pxAFfLLZ69ojFq2GJjkIrccOM jzGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353511; x=1783958311; 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; bh=PMUxY16+EjQiunTHmrdOH7xzPAM+NcHF5gtkkVq7+74=; b=iM2cd1gLtdrrc0AiGB49xWFGcRMMJoX5tD4eLrabSSnqwrbNpN7uR2seUr/AKXGgNQ 0vGCPDbt9SQS8i5hyjvRUkf6GUaCAAzjtxfLcz4ryUGeXQQvTQu98YlVHpUW9y9oXC8b hzBFc26gKic5NP6QMBNIJg51Rnhncnq/ocbIvaz5O7QR131vMW+Slg672h6gzR/YY3m+ TYdTpPcQpLEwArCGq2hny+V+Ic7mS2+pTZ3SrDPPsBxjnaueGUTUanEZOdrnA4Y7YA6T 7zqGXMphqEjAGlRtRTLfef0+aKjG5F4XpFHd6bhKGGRyQ/W1fH3AGKzVTrgvA2oDpf0i Eudw== X-Gm-Message-State: AOJu0YxyKjcDVg8Vedyqf33fjy0puzYvrJnKOnlt/BkR4zKOe00pov58 knlI3R48As0yZ2FVe+sIEZIGmcWy5Vqsw7/Gn7EiIyEk0Q5VBAc8z+15EAWh9w== X-Gm-Gg: AfdE7cmpgWKX8h7LPkwvvkbaebVjruvYdJUVhDz0RLMfDDnJOvvI81LnSUnUkxweRTu SxDao/9z2YBzUTbUk9E7TtaqvXIiy1sqLA5ZWIZnAN8eAYbhopU1QJxmbiCobiX7mtBbxv7Zca9 QzxIfyKIVodV1lQ9gg77RAURAYnlCJxq6dedAIGgJqxj5lmIiZ7l8Weh3HXpIsiRJQ/UqhjeAMg Dhr6zWKxO+EgAi1apSj4nhLt2t27ix8J+v/UaMQ4U3tDbXfvNlbC3XJ4UEjisv6ZTZW91yF+nbQ /GHf4BVqKwGdvx3LWTFCb6mblD/O5HJi3BbZc1Y1fD3KiAjOOOLEiegQG1CBKRiSjQXR/lZjrBD 6yCncCyUUs9WCqfPlpHI89/TFArV/rU8Zq7nnncqU9He+BeTw7D7gXArUjstKbaPf7Sadgg37T3 gOST7CLVQEX+9Uk69CoIz+XYKbU5LhW69K91fcYZKSqaKMVROCbwDgqvq0bg== X-Received: by 2002:a7b:cc81:0:b0:493:cc01:807b with SMTP id 5b1f17b1804b1-493df0a0861mr10499455e9.38.1783353510795; Mon, 06 Jul 2026 08:58: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 v5 09/26] xen/riscv: introduce guest riscv,isa string Date: Mon, 6 Jul 2026 17:57:50 +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-42698a/1783353511-A5523220-BF0D7000/10/73395122804 X-purgate-type: spam X-purgate-size: 11522 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353546858158500 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. Drop __initconst for riscv_isa_ext[] as it can be used after init stage by init_guest_isa(). Signed-off-by: Oleksii Kurochko --- 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 | 132 +++++++++++++++++++----- xen/arch/riscv/domain.c | 2 + xen/arch/riscv/include/asm/cpufeature.h | 6 ++ xen/arch/riscv/include/asm/domain.h | 3 + 4 files changed, 119 insertions(+), 24 deletions(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..5002ddc92a22 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,6 +35,19 @@ 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 @@ -120,29 +134,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), +const struct riscv_isa_ext_entry 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 +196,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 +495,74 @@ bool riscv_isa_extension_available(const unsigned long= *isa_bitmap, return test_bit(id, isa_bitmap); } =20 +int build_guest_isa_str(char *buf, size_t size, + const unsigned long *isa_bitmap) +{ + 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; +} + +void init_guest_isa(struct domain *d) +{ + 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, d->arch.isa); + } +} + void __init riscv_fill_hwcap(void) { unsigned int i; @@ -527,4 +610,5 @@ 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"); + } 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..e26f5f0b66fb 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,12 @@ 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 unsigned long *isa_bitmap); =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..235b20f8a6ba 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; + + DECLARE_BITMAP(isa, RISCV_ISA_EXT_MAX); }; =20 #include --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353548; cv=none; d=zohomail.com; s=zohoarc; b=KZtrevhODCzI5mmWa7SdetLEo6rUDOWcThuURvYNmoO04EA846z3bherhZU3RNu2XAo5siK/PapvX+P9A9L65/EDgPCFdVDiDUXxF7aDUirzJitGJz9EjImEg2rADU0k3WtVyqdARutc0dMCX5pbIW2650gka7YKR9vv4EfTEx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353548; 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=KUaoD57i3eG5vrKrWLrvtGucvmcW9ojWQ9m6U5XgH3E=; b=SPKHCZ6aIsvbqMu69fDHZdm66VoO2YNUq2Y8NSL66F5GNSzEckRk2gN1knTxZ4aMtq7PgmVPC8aG0dFb3KiCRMSBhF627hkkkSY9JWHQfWNKNcIEKJu+Fu4BvzYT2jkgQupzXgWEx4qb8bGrqmimmjEnnF+nc88K59xdVJevnMk= 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 1783353548158582.3550855735594; Mon, 6 Jul 2026 08:59:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355500.1610351 (Exim 4.92) (envelope-from ) id 1wgliM-0000UF-RI; Mon, 06 Jul 2026 15:58:34 +0000 Received: by outflank-mailman (output) from mailman id 1355500.1610351; Mon, 06 Jul 2026 15:58: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 1wgliM-0000Ry-M2; Mon, 06 Jul 2026 15:58:34 +0000 Received: by outflank-mailman (input) for mailman id 1355500; Mon, 06 Jul 2026 15:58:33 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliL-0000JL-JR for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:33 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliL-00AcTL-0K for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:33 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09e-5cb7-0a2a0a5109dd-0a2a4509a9ae-10 for ; Mon, 06 Jul 2026 17:58:32 +0200 Received: from [209.85.128.46] (helo=mail-wm1-f46.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a8-97e6-0a2a45090019-d155802ed9ea-3 for ; Mon, 06 Jul 2026 17:58:32 +0200 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-493c486f012so13701865e9.3 for ; Mon, 06 Jul 2026 08:58:32 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353512; x=1783958312; 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=KUaoD57i3eG5vrKrWLrvtGucvmcW9ojWQ9m6U5XgH3E=; b=BfGfYPuGjF9KV41z8atdAB3O+2og8t0CuOcNymD/zHoq1BHKJDcSmUNb/eAh97ZR6C BkwUxL+tisCmEql568JMe3wTbfpUgsNwy8DqVEUKr0ys6LMbg2vH0/nDMVZupWQ5Qe4L wzgtsgl1M1TqO84qrJGg4c7ciKXU75Ra0I/S1dT98WW7TGFucAviOFkPRVr8DnqBbXfe sk0EO3K9KOkt0JEFt6vlSGQ4Fjqh4fu5xOCZLyvjs8Fr8erFDc7vZuiz88muhF+kIGsr 6XYX4zVxjJJmVC3Tu7JAwbS+WxaioiIyByLpSVGHBdhzjU4gtj6mwz85jxr1w1xkMVA/ +6tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353512; x=1783958312; 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=KUaoD57i3eG5vrKrWLrvtGucvmcW9ojWQ9m6U5XgH3E=; b=BMXtFheM3fpiy/BWoUnE/iYdVMwm7Amna8tq6DM47YPiFIuFW3f/KbeWaoPiCC/iAu yjkEMR/MZWXlAtNs+4nZtQdSuoNFtOeDBWWF/ie6OXUFd5KcsSHwUuA8TedNKiAI0DT2 Dgp5Kk/f0Tx0UK1wRm9jxBukeX748RNflMq0C6VUANPDsxC9uR5eyzvRUQxJmExdbvJF Ho1yi+5mji3i6ISZtyxXi/ZIegcmLAsPuH5zgQACRa+CmfgKTBiRiY8b55vWnCpKHMSZ jGMi++8c7F73hdKQLimHtb2TSxd0ZHYhwIUyBtWDjnTCYvALXs+ylV3R9zTqVC54QS83 x9fA== X-Gm-Message-State: AOJu0YzXMdxoHM3yZjFpO8ACQKIGd7VCD1i0+aamKZmptFY2dcYrC2cw UkRdcDXsXYJ8b1LZ3JKMpGIq9QacSkVilsHsiDi9S7JX/vLxcxF/0ONAe2m7DQ== X-Gm-Gg: AfdE7ckyp3fKQU16R9nDC8DIMPBYff6OxdnfjQSHrv1Umww/SV9txQdX+AhGwtYh+Sj Cx6aN1YaLbNg9jfOdy9Ye49hAjPVcLKjt/VYgjhyFltUntIpUzfD981ELxiK1xflN6X9r8TFS0S wdsIGVHqqkjKdytU2ffFc14FTA5b21pZw0EHKSe7NTrO/TlIJ/AAe3jch6W6yRq/m+4y88Hzyt9 8RsAhofFBC4aY2DaXGRd6SKNGwPAJdw98tUvOekq8mmifEa3xtHgkJPMcOszaCJ/m6IBxGT+MP9 xnZAh1ApyE8pk8YewBH7k+Qiq60BeRseONpeDK2WfN5WTUmlI6LpL7nphxdcPypa/AjifPrVbY8 l9c6B5PeWl9kqC7/KwdcdFPDj0BpEPey2k2a9axFqTiHSbYxTScVXsYdM94vPplbnN+lfOvEsWF F1Ii92w3tbEl+KDDs9x2zYI/Smd+ZxfDvlEKWK+6/jxMwmy21YsUcE6s+d+w== X-Received: by 2002:a05:600c:6995:b0:493:bcef:5646 with SMTP id 5b1f17b1804b1-493df06ec87mr13987345e9.12.1783353512181; Mon, 06 Jul 2026 08:58:32 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis Subject: [PATCH v5 10/26] xen/riscv: implement make_cpus_node() Date: Mon, 6 Jul 2026 17:57:51 +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-bad1c0/1783353512-46F3D986-F00E2489/10/73395122804 X-purgate-type: spam X-purgate-size: 12770 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353548723158500 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 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. --- --- build/tools/fixdep | Bin 0 -> 13632 bytes xen/arch/riscv/domain-build.c | 125 ++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 build/tools/fixdep diff --git a/build/tools/fixdep b/build/tools/fixdep new file mode 100755 index 0000000000000000000000000000000000000000..42233e2669e9cdaf1c31723ad22= c00f6c9291f7c GIT binary patch literal 13632 zcmeG@ZE#!Fl}ECj2q)1~fCPuHyoG0K(?piyBsfk0$&uq{R{0=3DtLY4+zWa-(_t}Gep z32b1fQ`;#IVHVf(QYI$M@*mnpNQ8OYLDkguk+I{{|9p>!KhH*_TuNVcINU*ztb z`|got#iBd?vC|(pndrQ8?m73Ickai#_uT6*w+2_(Z8jjV!ySOs$!Z^GS-$|j`6L10 zgC>{(K9FH9OaXvO&a=3DQLGzcHITYSO}Ay*;vz$F+iVM*ZY1)DH=3Dh`36WSy1qhllRTA zxP+;G)I&dsCOd>TUSa7GCOOo@cRX{0Reol^Wry&S;{9^fRypY*8}%GFT6~Aw(j$CG zybxiE3;KxvYcN0@TY5DDD;B$e`8x?6d_GfS37n}BehO?+*mf3_+H0C)@tfvY5`<+T zPnhhj`@o3&DfZR~J>NA}#lCASdxSfLJ;G$~?hlLz#`FIQ)UDQ%pJm$5A=3D;0yXclhw zY5?9(+g7cIAH2A(XVCkty6*R0I`HGJpY{(z&;6&Q8_%hO#~o^>>e+b!>TuSuvqS3O zUdNt-n{3e&^8i@wlk)(ixjtaENN>UN{1{`5)qVwOG@C!f>4%X({A+$2ShLN@@73RRC({ewUhwJ4SP}eBjNhnGH3n`I~n0i1+>6_oo1; z=3D84?hQvnVHlpxlun)}+#ebQWzcDBMYS$gKpWt*gD-f;X(8vZ96z_My-=3D({$6p{z8t zv=3DYU0$EHbh0|5Sk3)RN;?dJY~v~#mf9n9MNr}rL_hJIeb%QmHdGtkGHrJ=3Dv%T5qcL z9}b?o?y-B-*P`)oEFIAs{N^Ebv|Eqs$&jJnHDXj9RU4gZ<6{o>inG$tjgmjG95~A_#J7;&uyQ`ZRRf? zP#mgxfa16N?=3Daq{KVwWa_o>5KY3QyBfLzr@#)2d3r>YrG(EJZ|NlbC1T&lEtJv&{w z!I3^Va85J!B0ZJURRia=3D^eaL0T^^IJ@n-s?kE;2eD(zlwQwR6hRP#+~XXT1)u3~V^ zHgHapo_W)8DE*(Rc{o^qXzXkcLbfPWjc$Rj%c%ymWZjB!N zTN~KaB`4D#`lX$3sAfR%shP@sV;&zM(Zs{^JOH$tSvCAd;PHr3qneu(d8N5GV7?VJ zV@lmh^WRl7rg&8I7pUVpc8xT*I0`E>in4O}sBx!%$tGob`lNqpOmU?1YNkVRwU0ci zxPs=3D#xdZ1J8_uTR4M;oDL}rsB2Qx9HE55FBWJCr(g z{KNrTh24gIbetkC17`Z_^K>mB5QM~ym9&WzC*uUaj)jD+4Skyie zx98tFk9`f)!Tgl1eHDTA!B%Ow>odmk5!BtTW*$`>-uH8R&ob6JbTs`|CZGgym`$+( z1kH0n^Wy09mc^NNFoM$W_L`n1G(Y2PT7i<9eJcePHP&U-Y zyJx7o6MvKH?@6Kd1G8{S8GZ@1om~4v^mTz%fzG|ZI2y3X4K@IClM>87d!8|Cgymno zz}RSRwhwlF5dd~$)YQz3>9+vny3f*-zY?EnuJOUHTZ)AKyA~kVQV^;;iy^kY0Qk-J ze$;NheZOk{RvkQga!p68H|ss99ykD1K47!~Pe3TYXPn&r>f<)O5tCxxQ^vzyCr{g@;3r259kcdBoksZeeE)weGiGYd6L6*ZLVqy2%~ zZ>R-;^i}Is^Ml;OjIsSy(`o^1_wBjF9?BnkV%%YM>+!>UwBQgmJ8)tNDosJ0n}TLg zQHQd|ZBl(eStHd4mCaIphtez6e_O%1Ppbb1Wjn|JtnA?U73F1)UstkN=3Dg5#U#_PVQ zW^P}nAg2RA4mk8j0*ZVfpg3@$aUh^f_i(|0Qj>e)Q=3DFWn$L(hrQ@8F#?}`HK@9>`X zX4k9cXY16h$I*Ol30LU5Up0Sc9x(Uh`YrmAU?!q?aL%*krhGd7{dwn8#)9T=3DRdc_2 zB=3D^#3#?++&#Ul;B@F`>a162U#k=3D!<9Z{3U4t7Z#+vc`%>cOz zC~2O^?LAGakzbu=3DY!|NTE#WMm-ewp#0~~uBc>MXAaKb9^GF*l~PiTlmI~Ol(h(+ed zqVaU!{Jy5e^A|64rxNZ3++kdRUjE_pP_B~C4d`)D=3D*;! z1j_LH%J6XloUEP)%JA`XF`4|Y0SbHBV)$wq`P<9zo67KU<29Mx$I9?gb~5>=3D%J82p z!@so*|GqMO+1|&X=3Dpv6XdH#~WU^3; zk%%Q8(v!Td9=3D#{r(+lBPBBjHFUA@U@-00%m-hSwMC>b?$=3Dt>zO1F%x;$cv#Z*xs^S zTi|XSe;R-EE*$5MKQ3@D0!{1gNyLR;8uk`DRDfOl!yExUBd!8FOo1u<8HY&~e5)wk zbX7Du12aP36TBZi{f#M@$@-z7pW$>R>=3DN`VoUVXy#nnY5}o#NgVjFR-$V+7 z!&ng?H~j?Eo|q`Wu}eVhiF_Q-1rY6wb>LVca1`-Hii(4)h)+2igqk9Lao$cY;uq(2 z>WcW(_Ygcqe37c-&{V{y6dZ!Dh>yt&0=3D0;bNeqHDMSPJ$0r zhH;{~nrasT;RF8*MIkA``c$Y}ZY9cUZlM zg4Y{LrgW?JrE)wWTjD9XE0K;zssU`*RV>9^CH6`AIAhOY-}{I${LXZI#F%0Oc=3DRL2 zw%Y)*A2H^$0la*Qv0eZeJH;68N_Kq07%r&S{DHBP!ebhXwuje(thwJN(Q;g9V!#pv5V+W2g=3DE4E&bggjK+$BwW$T0wSUc2QF01lsG>;+`BImc}Fzjxx;!+IYFfKA64 zts>x*2P@m0FWc-|wNnl_Yy3`Ei__tshBk2CsyohD9qKq=3DwhdNptH9hjX3vh}I5^H& z4xMjty1r&_an?Ll(c+XxDqEa&PgePzo^4b7&Zfbs0q1sG#jh)?olVP~9>24$#VNNq zYg&XM5u0T;fTPFA)^^+A)NNCqtQx6&s^V*fsS@WXd>1r{`Ca<}WRXX6oegZ9rn$y0 zXevipj1SVNkAU-G!N6s>442_D{F%a`Y1aC2hrl$i;hGhJ)<(<3xg)KK*37W<#BpKa z9P~P&M{Blg1r6fdlQxJ{{)dY!fg-Xv@1^gS@5=3DFYErKe_X>E5*)JtnRaoh>B1fPJ` zra7@5rg?clyeNHNX^kw7BcbMM%Rcd6y~?7=3D@6EyheHY07MP|LvMj_7xO>sRb=3Dy{_2 z{~PGsxfC80?Ym9jZwUN?z&i!rFYqq~{++<51)frA#c8&{w+Osg;1vRI5V%WVgtq0& zo8`K;RqN|z?_#&t?UfgJ7A*EG@_6OCwR%KWLxw1r@2xK@?Ok+<^n!ZuZ)jfF>uvNj z!P*VY$#k5rm%GE^QcKXXp*a+fCpx3?NsHU=3DY4-Hp7Fq0Bw0ME+b~mK@Q@A8;=3DxbWs z5bBK1k0%V>9foylnj2x=3D@@6kAU(ww3If5&K&7RLGZu2*LVNHAULRi<@?1AXIX3sV~IN~74E?h+{ERtDSXEWnrxHj@7l}oyKIx^_3#iwh8h^4b`;Rh z_nI{@RKmya=3Dau%V!Z;+@R>tmgW%%DO!+%}aE%oPM8Tnsv|1X6+zOUU0J7$UgDd2RO zdhq_wOmM<;LY{J1*VreI^R0H=3D|ILB1rit}8puD{jWYKSFUGpZlTUnSZ`Q9DBeWD)9 z&k?NSb}Io7B@y`E828;}{E3#~KU#+WbQ%74%kY1U@v+wco?{ln8)f9*LB8Eyn9~XH z9$;~vi{Mxp{uLFI%l}1%)t@PUDW)HQaMJL)6QF6K&ZuUDx;#&koExIL3gXkF2GR0}1Op?*z|8_9m?N``uLEt2l(=3D?6_K zqBQ)vPY?|!4Lu&=3D@4I5He`TxIx+&RmQi%ugZF!4BK0>e6^n84Ds zj+M(r)A1B$p|r6Pc%zHclLFsrA?u8#=3Dyaq|-dH$0;U_RfeCueXz`%;Yo$BwwzV1#L zNegeGC%&%jj;Gz7>1Zr6KN{-@2Qz>wV6Foh8+yJ-O4scs3%WED4cgQf3(ayA? zr)c*2(*f6MxYwlpDc$p>`@eMGmw>)Y1a7|muDJ~*Z|YMoS;;Hq(pzSSjTP_ z`aE}B1bpo;a-RqbOY~`7IUo%ETVZ0hVB*)qT3_PQht7a#eZNK|94PNVQ0hO{hx!yh zy3b9HQr>}p)`bKr0GwtlLHd-Bkj0DAdY4{=3DUN<$MXf$ZxIzz{-s82OekN2dYGdr)&F`)`_uaEIgt?h$C7}N zKEXFj^ywZt-A|``=3Dme$x@5K`R=3Dfr*X=3DR`tj(;u<_FD2uj?(5S%{?hSM>OYC?IR;klMUk|Q8}!e>kLDPNcq`gopK45UZc&i7~I{?oo? zKm@)t-X+}u95$;@lmE027!vwEG9;k1J!c5}xPLDO(%)3f6z^J$XP40*6NXloI7}qr zTAS7X2*x&AJ=3DVid7Xbn!C}6U9(A-fBeVC}g{f^i`VRynggTg`c2lfk!T`?RI6ZgWB X!V-7*S$v5Ihst>tURt71Lc;$7AAVAt literal 0 HcmV?d00001 diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index 5f6f4b6248a5..33cd1ea80f39 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->arch.isa)) < 0 ) + return len; + + if ( !(isa_str =3D xvmalloc_array(char, len + 1)) ) + return -ENOMEM; + + if ( build_guest_isa_str(isa_str, len + 1, d->arch.isa) !=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:52:48 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=1783353546; cv=none; d=zohomail.com; s=zohoarc; b=OspqhvH0gZ9op5Pf+8bs15HyHsNJ6kWPzqitko8Mj+rv6zooJrbUOT6hoqtbE2suT7WusDXuIAVLavmJhls/pTRA2srWGmUYJKrNYSI/DH9Ebq+6Y4mhyeOB8hCSMDLyxJ1iKPiYRkhI88dBpJK8Wdx1n1tjYJH+MlwUrxcWZQs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353546; 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=7lv2O45XMhPXIdRz4+cb8L4pJQyLhC4GuzwrLqLgLnk=; b=lH2akjMmAhVQDPjLQTI2Qoy6+SyIbgb7z2G7QZ5HmzabU9OBdL0ncE7H2yTduAyuuM2xqyf0HLBe9KlMUSMGgh0OPb0VDZ0gUhTVIG2xac2HtJriUuta1FUpYkc3ym1ZAGhAh/OuSlMtJeqshFc1tWGXhxCzbycFoZuIw/5hDIY= 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 1783353546075115.82533650332357; Mon, 6 Jul 2026 08:59:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355503.1610364 (Exim 4.92) (envelope-from ) id 1wgliP-0000zw-9f; Mon, 06 Jul 2026 15:58:37 +0000 Received: by outflank-mailman (output) from mailman id 1355503.1610364; Mon, 06 Jul 2026 15:58:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliP-0000y1-3U; Mon, 06 Jul 2026 15:58:37 +0000 Received: by outflank-mailman (input) for mailman id 1355503; Mon, 06 Jul 2026 15:58:35 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliN-0000Wb-7I for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:35 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliM-009ym5-Jf for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:34 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd091-e002-0a2a0a5209dd-0a2a4504c49a-30 for ; Mon, 06 Jul 2026 17:58:34 +0200 Received: from [209.85.128.47] (helo=mail-wm1-f47.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0aa-a01d-0a2a45040019-d155802fd0f7-3 for ; Mon, 06 Jul 2026 17:58:34 +0200 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-493bf73ec2aso20503805e9.2 for ; Mon, 06 Jul 2026 08:58:34 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:32 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353514; x=1783958314; 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; bh=7lv2O45XMhPXIdRz4+cb8L4pJQyLhC4GuzwrLqLgLnk=; b=Vj2GiPTeZk+VrXHiWbA+gvOxWDDeQ73icEK2h3yAM2T0aJrtcGQtD7NqN8xEjoX2le cBiI8NxclOyoYpJ2/P6vmqU/aWEsRbYmbDDmrv2Z/ZbBX3TSTCs9pX0i429iSb0MZAfJ gt4TkznqR9GqBotqNgExNmG3bqnF3a0qUoLSOliS6EBWXD77F5qxN+1chftwnLdmHxya LFCPd9Vkn9/O8NZWSCRon+tfPKUl3PyeG5xty3kxjv9jw92oy/CXY6Mw29Cc9195D/9j SFpaLIVL4nW2aROcsQeVZpDFVtZGrK964qoolj7JyJlQafh6nTdbQtP/DAtH4if2RdEL FXlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353514; x=1783958314; 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; bh=7lv2O45XMhPXIdRz4+cb8L4pJQyLhC4GuzwrLqLgLnk=; b=cd8a50B7/hF4aURFpT0bKgV/27T1n+kJ12pY5jdjOpGJq9j+SFlfl6e4XoSL4n6Fvq Ln6bttiIdN/hOlzSg8CQayLD87b6HuWIblAbH2Lgh2v+GhPbCupjCW4MfbEN62mQ4oiR Kjn3pAQwHdyikfwAlpB9E7RxVRJmrFUC1GMy142dRTviI2Dyf0jxIQy3TEV34khc+kSi nKosjWy5j4Po+JBQMS0W03zvT3uaZY/xraIiPWjpP+PVKpxUdjyW+HZr0/xyRPgs+PgD UyHW1lIrdZT+CY4ee+56ylUR/TEtr8tX1p9nsDXezTbytkQVprbPwqtWleW08WxcFriK pCPQ== X-Gm-Message-State: AOJu0Yz3vLuHubX8Aw9sEpNPi0xqkdICg7DBzstxOXeuPiAkVS/o81rA xCgTZgH2FiOuJD74S849oNyQMDCAV1gOHhWzRRzZvY5VTNWcppqBlbwr59v5vQ== X-Gm-Gg: AfdE7clHbuTMHn6WD56cl7V9/eBH9vRXtjTf1bYy38KJE0Q+5p5K04H/TucdYALtQR3 v+OVN5LxEbN/YqtuDuwabTa+48RoYBdgr6Vib7rXkG4zbkNtewIkurzG8ifshOLZaAicmO7TwwO OXWVGXL8uy5vi3o1uEFovqBlzJmBH9gDfpwvDEE7EN8yFozlK8jOoBcbYt2/kY2fBLM05ZCDqAj nEyV7huQVGEIeYzy7nVzO2VfyebuYe3S56sE02hMaZ46oZQCh2k7vpiQ/1nIgs4hXMuycwmIjF7 uAiOlNNlUe47aMd8RhFB6bedPmHujYtxQPoyl0f/fLF1HVLVVkGfBKPNRFTR45ycc2MITm4rtVJ UE7IDWKvhIcp6MygBD9QjikgJUjMv49hAT+X+x3/jaRtsMG56kfYgW172Blhldm/56ienShSCBE e3+ogLIaA6P9vliCdQ9BmIPl07ED4JJTflrOHvHlFPSk1jmTNSHWJZ6ezLKg== X-Received: by 2002:a05:600c:8486:b0:493:df1d:7488 with SMTP id 5b1f17b1804b1-493df1d7cafmr12020075e9.16.1783353513724; Mon, 06 Jul 2026 08:58: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 v5 11/26] xen/riscv: implement make_timer_node() Date: Mon, 6 Jul 2026 17:57:52 +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-ebf023/1783353514-77D241CC-0A1C3198/10/73395122804 X-purgate-type: spam X-purgate-size: 1649 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353546740158500 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 33cd1ea80f39..089e5ce0e0a4 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:52:48 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=1783353548; cv=none; d=zohomail.com; s=zohoarc; b=fqFdU1UpSnrbvqvTS1R9RXnArnCbXqIaqV3wUPAsaFCJOHvf0X3S53lTImTbbk36rUFo4JVinaAOVACMJ3g7hD+4tKQ5hESBwS32gxxHYsiXH/i0GGSGD5XDjeUxtAUTkSYEGqANBBGvo40e57MaRPTRhWryUs7CecxOG2BTlGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353548; 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=P8vet58ruSNPYddp5eYFi5gnVJ3f1awjtUgtwQdL9z39KdMMXbA3glK1ceEGecyBEu5QM1LVQYc+VRYY/PiimXU7f1bHkuu5rSxB2MFrBZvg4HK8aVTx7hxvGyZAOzNgsRgD7wYQNvFB2FdGox7+pGEcWM5++mRt/tnsMoUq8oA= 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 1783353548681621.8026623559145; Mon, 6 Jul 2026 08:59:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355504.1610370 (Exim 4.92) (envelope-from ) id 1wgliQ-0001Hw-Q3; Mon, 06 Jul 2026 15:58:38 +0000 Received: by outflank-mailman (output) from mailman id 1355504.1610370; Mon, 06 Jul 2026 15:58: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 1wgliQ-0001H0-II; Mon, 06 Jul 2026 15:58:38 +0000 Received: by outflank-mailman (input) for mailman id 1355504; Mon, 06 Jul 2026 15:58:36 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliO-0000ra-JW for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:36 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliN-00AcZM-TF for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:35 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd081-5cb7-0a2a0a5109dd-0a2a450a953e-32 for ; Mon, 06 Jul 2026 17:58:35 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0ab-e40e-0a2a450a0019-d155802be9ef-3 for ; Mon, 06 Jul 2026 17:58:35 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-493c5220cb7so24616975e9.3 for ; Mon, 06 Jul 2026 08:58:35 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353515; x=1783958315; 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=Al+T4YoEWiQ/7CIdwwh3JcAjYPAxbsYvOrxOZmOwOdsWbqoMRPtz2eZDn3fSnpDT0v dXLzZNkhrXG2ko1leutgpH8YQWJuvC1Yj8MeV0NcLBO0T0mfhelF8XyMdy3sN2Z4/vk6 bSGeWGQK580v351KREkD2cWI14Z8T9qU3scueoh5clzIaXG3cUGi+AgoNmh8gergCzUL 9SBUh592BtGwM04Nd6LNhcT6Hj3jlbJdxC+sKff8dlX8g5c9ZoqJY69mbm/dGR0C/l11 qEL90idaVBxo+yLLFWy4l8P8kVvh0lxzbtEWGKwrMq3epVZbeBZb0x6wAjXKrCbZ+V0g 4fQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353515; x=1783958315; 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=kt6lctsszAhjl/3GSB4iPtN/PQ+NNTnSeMDYAVMNiM+HyVE5SJ7r/ingM1dkstSpih J2BkGyySskp1LC2al49asnEfUDWLKwu9MPXri9tWe9wrZdKBbnDR6HhrmUbulTLd/IM6 SBPF7A8KDjLpWzLoq3uRfh3ww1AQgF46tqqk0qPEk38qVbfVHQbhFUharfKOXFxPOIJb v7mjnoLIipjqPubPOwGcULtNwjiZouGlcSsbs4E30Ib2z0qCxqPaUia0crVIMmVNOl9m p7dWtv32flN7vkdaiG+0EypTtdRaj0gnFEmPhohjUdqepWyUjcOPB4fj1VWrLwCIIvhN A4cA== X-Gm-Message-State: AOJu0YzTj1pIqsEl68rCSIZjeItUSqS3WOEvtvlKHplHvNYMAyYQ9jYG LY/Xsng4Zc1mcal08EMJsOdIkpBn8YANyDFajOGfqBYBYYuqIHk7aQVn2cqSiA== X-Gm-Gg: AfdE7cmYjEWsiQIWXoXSXV7Ckjx7z9IVVMyuxO+oMaQfM9lto/gXTlwsdSk006ivtTh qg2+D8Kt5tOXSpTRxSQ9/CsoMjN0uPfdoe6hMvrFviq9a4XvbAedrnoEukkprAgF+khiAGlV2eL 5N7Col0F6z42QZyxcfG11qlezLsz+rYaz5nX44nAF1r3MUKzvjY6enLwbiqLglCyCmhIYCg6SxI pPXe1+hU1cpkXTySXokHU1rwZqbO6S4xRrFk4afZmU6XCpRkI0GQkLSr0HLJlnRqF3Xcgw5r0+F 6x+UQ3yQ8wxgszqvF1mtfdDCqddhmpm39lctC08AMl5X+OQSpM2eJVDgCApcCcOoT+ng+Yk47nD 1sNniPrFT8S761FM5Osp23Uxy4tMB6xNOKBTrLivf7TDxi84lkt9c89jace4K9Yf+b0H8rTIyVG jsXBqCTUl8uH9NoMVpgUAiYCAl66JVAgFiy3TSWmz/mzASmiAVm+0H1Ykuyg== X-Received: by 2002:a05:600c:818f:b0:493:b750:bd20 with SMTP id 5b1f17b1804b1-493df041d26mr14237625e9.15.1783353515285; Mon, 06 Jul 2026 08:58: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 v5 12/26] xen/riscv: implement make_arch_nodes() Date: Mon, 6 Jul 2026 17:57:53 +0200 Message-ID: <982cafc2caaa2977d0a51dece7c6e92b9001a745.1783331040.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/1783353515-D4B2CDDE-E068D889/10/73395122804 X-purgate-type: spam X-purgate-size: 1386 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353550763158500 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:52:48 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=1783353547; cv=none; d=zohomail.com; s=zohoarc; b=HRsovlaqt3yGV8CwZVWXXATbBrr8VekgvObY10x+8IgLQXRzCfIvONxii9ikjV4/4/DSaRjD3tMMWLwyzHwI4JuCaVg8F/lv/krsKqazM0zxZmoNuq6XdTIe0TALNK1HfujcswXX3fG6jGF1Joartg7AJd66SOvTgp6t9W5OGCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353547; 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=DeYhmbs4p9nhGatscZwNVXsYAwui5pFBrqBaWuo9GENZDRMEXiEEkqzeLlshRXMv4rFGo6yoH9wGt/oRZLL5sBR6Zpsrw5ZTO7Te7+M7Yxq4dBJAEEsI/nkX1djLtQ4xzOKgrHfSfYQyeBzntxjjT3tbDeCLjovhmHDPx1/KDz8= 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 1783353547166976.9285518846181; Mon, 6 Jul 2026 08:59:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355508.1610375 (Exim 4.92) (envelope-from ) id 1wgliR-0001Se-Rn; Mon, 06 Jul 2026 15:58:39 +0000 Received: by outflank-mailman (output) from mailman id 1355508.1610375; Mon, 06 Jul 2026 15:58:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliR-0001Ri-Dw; Mon, 06 Jul 2026 15:58:39 +0000 Received: by outflank-mailman (input) for mailman id 1355508; Mon, 06 Jul 2026 15:58:38 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliP-000153-Qv for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:37 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliP-009ym5-7d for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:37 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd091-e002-0a2a0a5209dd-0a2a4504c49a-32 for ; Mon, 06 Jul 2026 17:58:37 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0ad-a01d-0a2a45040019-d155802ac59b-3 for ; Mon, 06 Jul 2026 17:58:37 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493c7902f47so19401775e9.1 for ; Mon, 06 Jul 2026 08:58:37 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:36 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353517; x=1783958317; 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; bh=kj+Ys9sE4vz8rN4cl1XewN5jOlLycBUmGkH75Llh0pg=; b=HHO5pSUDR8XRC3uNaXFFgnpkOp5unJL2/AUlFMiJkNs7QHQjZIk+dXMF74XvufTNQJ vMTgABIE13epbo/xgsyPypJidOYGY2fqk+3WFPdclHDdMxZGyWd885+KmC85j91x3Ljy hqVcIDkWFF0TVuz7PoMmxO+RIw38Q5t587DakIU5rcPkXoRIwFEF3WIUgHmcoOK9Y4K5 g0xggvau4v7X0eeQSxj9O8Xy6F1yfgOzr7NTJWWpnF1s8tyjOYsSA602vVEG/LY1mrJf 6UTOjV1iTyRstoEDfvqbo/Xjm1LqSX00SnSXfkKa7NeCqc0oRYIM0xWG3BzeoSG25yW1 HsUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353517; x=1783958317; 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; bh=kj+Ys9sE4vz8rN4cl1XewN5jOlLycBUmGkH75Llh0pg=; b=kAxchOgmM0C88qKRaNnttzGPMOQrtfXrVISZarMujvtBEBvMLv0Y18btXNUvY08Chs CFE/9xYheMUuJiWdPOfaZobmA07Ne0DkrBAlUKgzENn84Mt+Uat5138FUY6mul2Xyu5a TnrBGIlllPuz3in7F2fKyJk7esZv7Lwhl9fpbR9AgmQDJXKRWqY4eHzLPGEQLwLYuv9Z jgGgTBO7Xg18AlAMOvm050JeNgAmnMRD7Hg4rtQf4PTsD+8ZgBWlfLQW7fiBRlJHgFfi GeWDvv7GvHQLUUBxprBMqasixn17OD6OPmz8DONoWOkPM4m2zLBw6Er70D0tPFpdnqlL xb+g== X-Gm-Message-State: AOJu0YzNwTZeNHrvV6rEb8LC+tUr8nXg8GPJZf8R4/hbxUgHwsD0JAP2 N6UmG689kqn/QFIzMESjQW1zRP6rkl5G2VPNP2Zu/RSzC+ZSv8rZdy9z+rrmUw== X-Gm-Gg: AfdE7ckad8bajmWOWbJuWrFm4yuxucsiAM1FVZ9LDk5trsHErHoEvKgl4IbuUklXYeo NWpGHrj0e7czBhbOtzQV+TAzJ527RFoEKPG09ixqdSEPK+rkVEQENCbtyRZugS0G01MnxSq+L+U zITPGpxoviQnmmzRNfjKm8c4BMrXz5ra5oQ136g+Fa/MpV64yQBakyHamiglGC01WadKb0WQcRx R/UbJLhiDnBe+k5ddIAyAtCqT6xWAxM1luhBBMIrhtYi2I9QEomK4wo+udIgcbdvmMkzMN6mOIe 3aFTU0fK0ejVf90CnWPZEPAY3X4r0jdTY8/B2NSznXea3wZA0qW1v6C+cKMBnOeFPt0FcyOCijL nXIqwgg59HyF3nRStKDtuiguLX8cLM6N040c2YL/OMpH3dj+5ii6tIdgtK7LJiBWllMtNLn4BAU y/81WItINHuiOFeUWiMmrBSsg5atbkzYqJ+gf0u7if7YxMgg1JLXgQlTwW4Q== X-Received: by 2002:a05:600c:19d1:b0:493:cc25:85c4 with SMTP id 5b1f17b1804b1-493df1c98fbmr9609605e9.8.1783353516591; Mon, 06 Jul 2026 08:58:36 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v5 13/26] xen/riscv: introduce init interrupt controller operations Date: Mon, 6 Jul 2026 17:57:54 +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-ebf023/1783353517-AEF2D1CC-0B056E72/10/73395122804 X-purgate-type: spam X-purgate-size: 4030 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353548767158501 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:52:48 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=1783353560; cv=none; d=zohomail.com; s=zohoarc; b=cDYhxdFyjWZkjKIWoAiYqOzSrm+IGfjak1uPWcz1onsk+C5ivrddxCXkeeOXeI7xoRdoCb00/8teTrjBhdSBNKezsXcfOkzs6SPu88GS7OTESCLpIt4JyzOsgNp9GYTRSHC7MzBaerz/9pKVUYDAZGwfnNV3AZzuR84X2FSrdH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353560; 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=A/ZtxrvuTd4UkEQ4i2TfmlJT/OYOaHL0n4xPwr38eXk=; b=BcVDGvIjPT8zIgjSGMhQ78LdYpIy84PTarcFGHMH+GKjGkCU+csS8Cg8QPY73LcpDIDua7OcKvdfNvilWn6g17kIzc5+Nz6Cs1pzV5WE3n1Gx952N7VuDo1tP9YNjHk8cz2bY11K6/k7A74rqXzlYpP9bFMLTDgukflvMRJy3TE= 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 1783353560455406.51399958262914; Mon, 6 Jul 2026 08:59:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355511.1610383 (Exim 4.92) (envelope-from ) id 1wgliT-0001mN-FC; Mon, 06 Jul 2026 15:58:41 +0000 Received: by outflank-mailman (output) from mailman id 1355511.1610383; Mon, 06 Jul 2026 15:58: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 1wgliS-0001kD-VJ; Mon, 06 Jul 2026 15:58:40 +0000 Received: by outflank-mailman (input) for mailman id 1355511; Mon, 06 Jul 2026 15:58:39 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliR-0001Kf-50 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:39 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliQ-003COz-IH for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:38 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-2eae-0a2a0a5409dd-0a2a4501d5ae-0 for ; Mon, 06 Jul 2026 17:58:38 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0ae-400f-0a2a45010019-d1558031ace5-3 for ; Mon, 06 Jul 2026 17:58:38 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493b6f1b14bso12910525e9.0 for ; Mon, 06 Jul 2026 08:58:38 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353518; x=1783958318; 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; bh=A/ZtxrvuTd4UkEQ4i2TfmlJT/OYOaHL0n4xPwr38eXk=; b=O7xUXLmdEFb2iG0NZzUNX/7tcnd9rBHg3OfF3uS2ah1HiMMUZJk5adcWywRlYQRxpl /YNcEhj/+U3cd6LpLt4GOfA7NpHq1HHVrtRTJYZI7GEDcnExh3G8eQ6hOfy99x1FiBGT Gq+0XVG4u2DBYiOxCcmb0Qk3RrZVjXJJugMfrlhD4lRGYmyitSullRh9enY38pX3xPXf IMs8+qLA5cYauqpjub4q6ieVaUy7qCApwC0R9faHEaG1M5tktCZ1sAHLq/0BqgtfA+MB CJueG2a2XSDiPC/j3/WxJqIr+BkBBqCLIttSOVb0y26mkNyjvaKNCGNLeZVpgxEGSBbf Z8jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353518; x=1783958318; 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; bh=A/ZtxrvuTd4UkEQ4i2TfmlJT/OYOaHL0n4xPwr38eXk=; b=kUpkabMgxHYp3UPZJeggzWire7uZoXJmTS5BW7mE4/1l3WF+k2FbsLY23r1jvp+Z3Q SV8bbpavhmIDWZCPHJUvtmQgkq9hl1XBQADhySb5CNyf9bN26kXNCGUIF+ydv7rBzHpn QnLh+a932BoHA/n9kDrG6T5YPSZ2eHgc8gQBzT+bZxms0CA5yeH7o60yuqt6fx5btaDJ ujItJeM1Ws/zD8RWqhDpkq6fJQwjFUz+AnosdJtv3SQalJJXjalQmDj7e7ztbpOMzBmA 2MFdtAoVtIyVAXngCGMj08P5ultmlbP/169EgI+ypfjl+Njw9taZ80MwUnuYykGdrh/1 ewAg== X-Gm-Message-State: AOJu0Yx+KTtavx4mQQU4SEWlkyKFeW57U9aodgo/5zRQdj4EQcdSZ57l zxbP+YA2Zgw8HdwvoyG62Hn1G/MOk7NoWsr2N37X9mvPPT/52/bBWA0x62wE+w== X-Gm-Gg: AfdE7cl3tEeCrde5gK9jVGmAtZVF2U5Ip0K3plgZCOuEwtJOMN0FXKilLUeX56W0xUJ vg31B7Ea5AxUAS9xrFrGLTM83HaPDB1Oo/VZMn516i8Q+Pxfd0F+BLUrFx/QISeQUFgJLu1/caR QRSCTp110nhxFAqAjEs3pADJCwMumw0VXPffUKH2+rUNgziQ0jHZnKQozalMEMY89eNm5dOOd12 9z9cQXlns7W6EZqN+NbStd+3812Ngt/ZwdpA/nJoabCpCk5psj5/SUgfkHA+lF+yF2MA1sxJNEf vFUJ4IelERluUBz7RqVTGYc/21nucreQFKTlzhTps9r8uXKVzehFwoi3fcypbJ33MDiKCUY7L/1 2qhnrcCupgj5xN68h8RBkk0U7sibuRKNtu9NvmM0UjUoZXu0OnxT8twvG5E7idqHOcPuZr7tSuN ubnO9ARfVS578L1ju/gnnscswJUY59dtFoD+3AFgWZvK/wUZ1sUfbPAplgYzryjhzh90lO X-Received: by 2002:a05:600c:820f:b0:493:aa28:38ad with SMTP id 5b1f17b1804b1-493df06a2d2mr13017205e9.10.1783353517711; Mon, 06 Jul 2026 08:58: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 v5 14/26] xen/riscv: implement make_intc_domU_node() Date: Mon, 6 Jul 2026 17:57:55 +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-d62444/1783353518-822DD1E0-05FB12CC/10/73395122804 X-purgate-type: spam X-purgate-size: 3451 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353560853158500 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 235b20f8a6ba..bdc6086a1752 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 DECLARE_BITMAP(isa, RISCV_ISA_EXT_MAX); + + 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:52:48 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=1783353552; cv=none; d=zohomail.com; s=zohoarc; b=S/WT3mpqgxDCfY1FRtCsmfQvjojDDhV9pLaalaEQELqtxeLkh4jWOTpux/lxyTvJrs9m49N8kuJU5fkvFy9szasAZgsUQs6k6zivdaQFBCDe0uy0VUiKlAk4b3HF7NhLB4pYNBQU30Ffbku2uoF489pQv3Sf8X9LGF4wh7w68ME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353552; 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=n5/+d5dRVjAs6O6GMxUktSNMn+4DCvyTRvObcIZIpZ0rPLSe97XobpGZBGCauaS1on/4tQhysSvfuUNBtXoq8G2FSED+pCMNSAJ41qd8pku+487VNUDm8cnQIBD2HRsGZKw3AsBSnvP+giBUYJ7fsDkZHoMW9cj8ahYlYovd3oM= 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 1783353552280369.8060927204052; Mon, 6 Jul 2026 08:59:12 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355515.1610392 (Exim 4.92) (envelope-from ) id 1wgliU-0001xu-Iw; Mon, 06 Jul 2026 15:58:42 +0000 Received: by outflank-mailman (output) from mailman id 1355515.1610392; Mon, 06 Jul 2026 15:58:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliT-0001uu-N8; Mon, 06 Jul 2026 15:58:41 +0000 Received: by outflank-mailman (input) for mailman id 1355515; Mon, 06 Jul 2026 15:58:40 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliS-0001WN-6d for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:40 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliR-003COz-JC for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:39 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09f-2eae-0a2a0a5409dd-0a2a450ce8e8-28 for ; Mon, 06 Jul 2026 17:58:39 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0af-f399-0a2a450c0019-d1558030bcbc-3 for ; Mon, 06 Jul 2026 17:58:39 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so22318155e9.0 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353519; x=1783958319; 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; bh=bw1hrTkQ2ATB1SLL0iu4tNbNK40JrBmaLHXXypeFp0c=; b=G5BuSYH2B8KrqFyPfTYjy63tfVs3pGADWoimSOdjh3AevIvD8e6lhtuBZYuCloIqrf uDHIQDacN9OXPSxwZvC1N3v5UrjE+wAPY7uIQBcCS3jm4+KKAZ9sB9Qhn9X4GaqTI97t TaDAOnkC5aPU6k7+5lzOCfypPFjui0fSx8Ch4HpRAFFNY9rRUBduxmETzFN9/6fBIzhI P/ojgGXwdZIYvDBbOHSZbQuGHgAKbwRUzq24/WxRpP1EAHTNdHnnJ/CCfMNlKcYAEQGN C7lxK9hPQ6nghICaQwebfmFcExA4/5vLxLKnpt+lVC64w3E5XPlUwh2uAhn9AkUUA/aU CPdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353519; x=1783958319; 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; bh=bw1hrTkQ2ATB1SLL0iu4tNbNK40JrBmaLHXXypeFp0c=; b=cdfI12epNHLYRusUlle/NU+vzMU4NG+3btMwkqsFIrTA3Tm+sToPFikcHbRlYNhmJb CHH3jBshvcRhhEMNXErJvIs2AnUYUdpMKuaQRymB5OKOIErqaGpXYdDWCtZ406bVS5JE uv1wXkQ7ciFwAeZjnyCdASo4GJdMBZog3xP31mtfda1cVW/B6OS9ecp8nzDCF2surNsv QB6MKoRKnPAbfJSrYpUuRvc3bL/KMS+kpmAV92rpZ1krCQ/dJ/y4VEk/7OO7++qQD/tH RDNtiV6bDApyDioAu+Hp+VjRuedTXG340yfFOsrETQUZNOs+27OnaQrr7guFzhFIRooH FCLQ== X-Gm-Message-State: AOJu0Yx9Tzs1jJ8ptDXuILADxBTeNpaXTiBQbjFS/NpHNHM/C1UF9wJf 0kjJyDwflFPUvvTwIzGrLgP3dXxABhWsfWWt0Yzw0agI0IXiy0vn2bp05il79A== X-Gm-Gg: AfdE7cmp2x6UgYnfG7R7ECb5+a1cOIsiEPkqE3HgsS2Xmnp2F/5/dq5m8793YB/mm84 WMFEEm2AnBFDzu2/nvvdX0qdVP0jqZ6MLJsnLDdxvCpFhuyNwgikXHB7CQOS+eWYKnft9CuG96P LqWpnoRcowIO5/O/FSZfsXTHMLrHtTrBboJD1yhW2ds9kGAgGXQHyb1PWOjFRnVx3TETqxDjNGo o/IBSUSxSjDd334wtktbqyi4jPMsRteDJWioTR0Xg/443EEIfypwjLw4ZC9cXxguC/giOFjZUv5 vnH59P7fJiNZm9KndxeO5couzAvokf7UngbSs3q7ekTW1AJsMhpp0mZcwyxArczAw650NEdcLs3 T9NZRzPR7bF+TgjTBE/ripR4M+JMua1xTUPHILV74QlPOG2O0an1gKiLE8U6XLf4lrzKpLufRbR YlBZu7HyoP4ncItwom6F1UuoVL3KpXGzheuFWsS2buvU66b9w/TTlwOSyiG2ZNP9egfvTF X-Received: by 2002:a05:600c:6385:b0:493:bfea:2780 with SMTP id 5b1f17b1804b1-493df4af8d1mr4920195e9.9.1783353518979; Mon, 06 Jul 2026 08:58:38 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v5 15/26] xen/riscv: introduce aia_init() and aia_usable() Date: Mon, 6 Jul 2026 17:57:56 +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-d25034/1783353519-0D727D51-0199B8CA/10/73395122804 X-purgate-type: spam X-purgate-size: 3183 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353552947158500 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:52:48 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=1783353561; cv=none; d=zohomail.com; s=zohoarc; b=j4dZn3x5WA/uP7J377mKsgPa9iVGr+LcbzrMSQnPxIyxLf8er6HMFrBkj4c8f/iMx65sBnfVvIvjzvd8HrnjNbUL55bli0tcnhW5l3rBkemqhwfCucuSudpMg8g6dRL/9Wmo8/1wqYPxsIsIZn1hRQ4vpSJaKCFl+N2Meooyd6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353561; 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=FHkgIPf46HKPOxJxqgCmDuDrFwFnSVGNxj+iOnJ7uQ0=; b=TSaK9GnF5pOO4MFcMhfMpaGWK93XnMvrvYp5HjiLC4szJI6WBasrm32FnfOuc4bEVc2+c/TZBFey7e8dc6uvXtSGMfDuT7ZbQPX1dKuXYPH2BMnpDBG0RnhLrPOfpvE39SfPbHqzTtjIndOZg/NuF7ePDZ52NurgqROp/Jc4fEo= 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 1783353561335656.5348024005225; Mon, 6 Jul 2026 08:59:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355519.1610399 (Exim 4.92) (envelope-from ) id 1wgliW-0002Qz-F6; Mon, 06 Jul 2026 15:58:44 +0000 Received: by outflank-mailman (output) from mailman id 1355519.1610399; Mon, 06 Jul 2026 15:58:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliV-0002OI-ML; Mon, 06 Jul 2026 15:58:43 +0000 Received: by outflank-mailman (input) for mailman id 1355519; Mon, 06 Jul 2026 15:58:41 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliT-0001mr-AA for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:41 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliS-003COz-NC for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:40 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-46 for ; Mon, 06 Jul 2026 17:58:40 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b0-5a27-0a2a45020019-d1558029e442-3 for ; Mon, 06 Jul 2026 17:58:40 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-493bc8fda98so35469985e9.0 for ; Mon, 06 Jul 2026 08:58:40 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353520; x=1783958320; 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=FHkgIPf46HKPOxJxqgCmDuDrFwFnSVGNxj+iOnJ7uQ0=; b=CCh6zxhC3iUas9wAlCoEZ9Q4JbJWYVcmSEunx7SjDLGNwxQ594Jz7o/FV7cYPdIZVL h5bVYyYgAmS2ADNl9a0Eb3fn+My+L+mktap4MPDy4l/BBXZIvSn+Q5PzGXKO7K8jMbj9 kUEpEILaZaTpctWWCNEs1e1wn1wp5qG9Fc8gZK7jReg8Gn6NXULVyp4asw7zIaNiqco2 fMguOjSwZkXn0+FekZomsDi80MMY70Lq8/yCk7BDNgJlnK/An4BD8zXaSfDx/wkqNjWC 2lixyBrLEgEtJ6h8ryDaegP6mVeScTZ8eOFwboPg9jbmrwSxyo8Xp6n/sVDJx3I8jnJQ p9bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353520; x=1783958320; 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=FHkgIPf46HKPOxJxqgCmDuDrFwFnSVGNxj+iOnJ7uQ0=; b=IIIXWwjkOecRtqlDOSF0QeREPTyF0IFJanwDl7cWrOlkhq4Bj01xZ3pY1wPBxpUVcj NossPFXtAuwySvc4YMn5rxMSUWnKXjomhZdZo5ovJ7z/oiaF1kSWxoNGiV0XjHL+RM1N 15R6QlMWQ9IOD84OJWRNerLxS811HaNO8umR9Fbh/Nmbn3HexF7yr+VbXWYSg5dKAg9w N1BD+ceXP8xpkFrn5saQGBUTf3rFu4PGMS1uUNclwjpboi1ps0Bha1zf5lrty5oWlOLH t2oUVqgqZ7DqlbzT7AWCPC6UXYc/CksJavLjeZVYoC/z5H81LjE9QDqeaGZ44MMMExkd mzow== X-Gm-Message-State: AOJu0Yz5Wo9xc1/U/ZZXPbHFLQYlm+aB5B10TrRU1KqzndekQdSLzVZ2 BRfHv/m95BHA6XBC53MPcyzGsjJaM1M7T85D8DfVOZD+5s2IwA1PQhexwoZr1Q== X-Gm-Gg: AfdE7cnU4TN59wiKpRIpjRePMfjLSYvEjWmKFpz3e7OrK0m1TSW7lO6XlJ2SYYJ6jHP hd6uD3sEksrtTr+zkLbmp1rVoM41kc3Xp261/GIbajLp08FbnSuPXfMhnW8fieTRzA5gMd22G9U 2U+auv8u9Zmigj/c8JPer+1yUzJDhWR88VwGW4q3c5Rbl7k3luZD2ODozrY2hy09ja3j34Uzz8Y ajsQW06TpWoB53tDZw7KrHm4kdk3F7/oSXOaMJyGyWF2MKq1f0e1mU0nvb3vCUxqSMmhAw7tqx2 YP1bsD5hV00yokCvpR0XLOR+ozPUCYgg/HfWksytEPcKJ8uIzfeMmNizY3VelIPxb+bnjtYvxNA HdO7EGhuWMjruLj2nvt9ZbWbGKlm61WgTTyXFxfc2JUsOfQvtjBI4aDBTxzR4qGWC9IABuJTUFn enOIwINZb5WqqwytTtmRs9BOq2y+bn4sjOCcouZ9RAjgPjVxpCIE1IhGWbNw== X-Received: by 2002:a05:600c:8b82:b0:493:bd2a:93bb with SMTP id 5b1f17b1804b1-493df038790mr14690605e9.3.1783353520093; Mon, 06 Jul 2026 08:58:40 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v5 16/26] xen/riscv: introduce per-vCPU IMSIC state Date: Mon, 6 Jul 2026 17:57:57 +0200 Message-ID: <5d7e0342ac4eeb65defd58a923267c4b0f8029b7.1783331040.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-720697/1783353520-4D50C7C5-F6A1770B/10/73395122804 X-purgate-type: spam X-purgate-size: 6433 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353562924158500 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 bdc6086a1752..a0f681e25c33 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:52:48 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=1783353558; cv=none; d=zohomail.com; s=zohoarc; b=WBEq5Pv5/u+OW5+Cpa6d37vhOyww1O53KUFPst13FcIJ3ONMZzGQebSazJtOes/+Lrjo92Z/LhvfZDX7D0e1leEYG+s2DbiNpc1Hk5tk7gM01RDDtVW/+5C+0U7LRi0fvbLRbHcDgfSJ9mrNPua2Bv5VoG5OI2e0rIgcwxou2Os= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353558; 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=517+1oBC/3etFT89VUu919j8ILu9fgNtL2l2e+ESqVQ=; b=DCR0UbZwmKRyFuvFqmHdYhVA5Jd+LMwZPzHDHyX2SRBKZTXnW4i6u4X+lqYHGcwdlTnTF0aKZN7ZydbB8jmBzdrXJUbDXtzKy03G6vRkVfHenH/wVVvsI8K+MTtxWDymqdN1ov2xFIfDKsWByOyshnmppPTw09zRZMDfCSkncrE= 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 178335355891475.98644920074094; Mon, 6 Jul 2026 08:59:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355525.1610405 (Exim 4.92) (envelope-from ) id 1wgliY-0002kA-E8; Mon, 06 Jul 2026 15:58:46 +0000 Received: by outflank-mailman (output) from mailman id 1355525.1610405; Mon, 06 Jul 2026 15:58: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 1wgliX-0002dK-DJ; Mon, 06 Jul 2026 15:58:45 +0000 Received: by outflank-mailman (input) for mailman id 1355525; Mon, 06 Jul 2026 15:58:43 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliU-000257-Tl for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:43 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliU-00AcZM-9N for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:42 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-5cb7-0a2a0a5109dd-0a2a4506c18e-6 for ; Mon, 06 Jul 2026 17:58:42 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b1-08de-0a2a45060019-d155802bbc26-3 for ; Mon, 06 Jul 2026 17:58:42 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so22318595e9.0 for ; Mon, 06 Jul 2026 08:58:42 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:40 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353521; x=1783958321; 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; bh=517+1oBC/3etFT89VUu919j8ILu9fgNtL2l2e+ESqVQ=; b=tBAP5QKybvsIqzKJV8677XyaOpBVvExAEK4ebMYQHiAMvOnF7d0qsjv2E9rZtEju6m h2ag7a+5+8QGaRWaGhk660kkK8/pvrLDfOMjeKldM2ls63kt3ZUnUMruSbvv6VhREcB9 /LNYGD7idtO4TvVGt2yV8Yn29t20xIn/UpTZrosNbgu6laKVkeiWGuOBqeN+el65Ivca Q3DCq6MYEBMb7Zzu/If+29+RD+n6f3V4GQToSPnZKW7YA1+aQPOZu1cj6BYeWcKOKXq3 k1soeIG54Zf9VHQFiPAqAwmJGix/pB4U6qwRNN7jbpiD/UxphiLIn/Asf7LjWrLVEGOQ QnKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353521; x=1783958321; 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; bh=517+1oBC/3etFT89VUu919j8ILu9fgNtL2l2e+ESqVQ=; b=SMG1yRSgGAHl9VmzUcWEJ/2UaTBIK/wT5B5gDoWh/wJwFXOpTSQSdI4baAhk9blkM7 +hdJU6PPwdNlFdGz3u+qiIG9qg8cgeM1Hdf4bCG7igWTOhGFw1eyQ7HOycJ/3excSk08 CP4O7UbRZX0n3dHAIAR5TBl4g0M4bs+WzM0Dlf5Tl1BwUE70RHSnsad9VDkRlxK1Gd8R t4up2uXiayEq2T4CEFA0CpCqA3w5SLA9/AVqimIvZVw2t+f3Xle05srPjFSAtj4RcplN ZnRG2cVSGIKDvqMjrauPTBnuZ8b/aXbnovRkVATYIfJx4Nl1SGebEzLEB90+FKMmJwlx 5zuQ== X-Gm-Message-State: AOJu0YzlMsTIz+ON3hYPn/p8RM2wW7D19JQCKDDDAx4etKAj/FhKHPB4 X/wIQxBEEv2yKJEiwBNPUQD3f+Y4+uy813INAyZAdzdqfYmCeTn5nicVoTqGYg== X-Gm-Gg: AfdE7cnmOdYRPkqKWjXG6Dy9JtCuaIu8TcHMQwdhN7wifV8O4GN2Arj6uzAbms9uF/5 +iuidMdJvlXf4VLc9LG49ErgG4e2U3FcGFWR1xchNSNPtsqwghUHlP+pjR8v0vqZfCItaPNhY/k lYzjtTAz3EooR82HHC0jJNdzvSR7vC1x+/l0hDPKxQb82PPhl+bUwRHxwDVNB/Q7lF4IOtR3Qlm NDd1QTP9Un7uHhCbtLqC6brwsJQvUxDYMEhiuvQCm64g4E3zu7OXV3fqnyQGr/c3MLqUkL1CHX/ iyaZqY2TZmxhu5nOSJrJhidS2j2+3lrPJSPiMi59dtQh4m3aIGxVklJFaUL1KvPpbIpONOseiKT NomXjEHiOpiXZenb1b6lDLpkPu2eVx99EFBq1UNltvQ6bc4jWB2BKpHlCUlZswBhxztSdid/l5W Q6miwx9v3fVFbDv4LXgbV4KAkcxPpxU1SuvhKPx8YJeacK4s4pjMVjdawz/g== X-Received: by 2002:a05:600c:83c9:b0:493:bc31:b2ae with SMTP id 5b1f17b1804b1-493df040597mr14466295e9.10.1783353521386; Mon, 06 Jul 2026 08:58: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 v5 17/26] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Date: Mon, 6 Jul 2026 17:57:58 +0200 Message-ID: <1f51410c080599a5c80173398d9db837b8718356.1783331040.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/1783353522-C7B2A68D-F0370B61/10/73395122804 X-purgate-type: spam X-purgate-size: 9099 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353560935158500 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. --- 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 | 2 + xen/arch/riscv/include/asm/intc.h | 12 ++++++ xen/arch/riscv/include/asm/vaplic.h | 34 ++++++++++++++++ xen/arch/riscv/vaplic.c | 63 +++++++++++++++++++++++++++++ 6 files changed, 115 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..31264e2e683a 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -15,6 +15,8 @@ =20 #include =20 +/* domaincfg bits 31:24 are read-only 0x80 */ +#define APLIC_DOMAINCFG_RO (0x80U << 24) #define APLIC_DOMAINCFG_IE BIT(8, U) #define APLIC_DOMAINCFG_DM BIT(2, U) =20 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..6562b25f0abb --- /dev/null +++ b/xen/arch/riscv/vaplic.c @@ -0,0 +1,63 @@ +/* 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_IE | APLIC_DOMAINCFG_DM | + 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:52:48 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=1783353564; cv=none; d=zohomail.com; s=zohoarc; b=BQnPdhBS8WrYj++vPDrllU5uIcfxAavzOB37lCiNRuo0tYpPwDY7JWmbBsNEIqeWGDJCmwUcgtqtOL2aSsExdtbVFeq2saBm9kxz9OfTfkZoznyV4aDq8reYm+F+hWcODfj1q2esrzg0JeZyRgDz/P6JvMjauVi/jh3k5TNN13k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353564; 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=IjcS/Avaf1GsgDFyaOfVm5ygdYGJU0669pyToitaIko=; b=cs5LAwWUjAYFgmYb2IHJd/OyohmLX1Y5FA4ri7upupKtdlAYUhgUkknD0+9rAvduvfT8E+kA9pGJfKhD1SSNkDXEJ2ZvVHgh0OnzGfy51u6kccN7cUV45JHnBDCvxQuUZXIXc6KJ51ERquy0T4yeWyrnYSIav2VcSAvF7XEE7Z4= 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 1783353564046652.9282087299498; Mon, 6 Jul 2026 08:59:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355531.1610412 (Exim 4.92) (envelope-from ) id 1wgliZ-00031G-Rv; Mon, 06 Jul 2026 15:58:47 +0000 Received: by outflank-mailman (output) from mailman id 1355531.1610412; Mon, 06 Jul 2026 15:58:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliY-0002vw-NZ; Mon, 06 Jul 2026 15:58:46 +0000 Received: by outflank-mailman (input) for mailman id 1355531; Mon, 06 Jul 2026 15:58:44 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliV-0002PW-V9 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliV-003COz-B3 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:43 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-2eae-0a2a0a5409dd-0a2a4501d5ae-16 for ; Mon, 06 Jul 2026 17:58:43 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b3-400f-0a2a45010019-d1558034c806-3 for ; Mon, 06 Jul 2026 17:58:43 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493c19bad03so29975475e9.2 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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: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=1783353523; x=1783958323; 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; bh=IjcS/Avaf1GsgDFyaOfVm5ygdYGJU0669pyToitaIko=; b=qYYE/0NXEhGTHJef9K/oCbSB7UBOEnIQI1JM/Rg3sCOE/Wl2fpk0zR38OWBarXa7v4 Nq1mPCukH6f2EbyPAQg/w7AHrIWpFLtLvlnpX+icARgfYcw/rc1R96/NGw+m1gIoeEvW AgQ3GZRKQ4e93AwRUbjINcVI1EtKeU7vECNw39Y4NidAGsV5/zwDIkyUE0CYottXyvaz 7V98jlRsQhKGVNwo599nVYmYYACFvz8tl8k6rfWQry5uNtqcQNrVrmJBoVThIxzcBmiR TWm+kwyKKSueEjJiZ7KZryLHT1/PrDoESKcTgQFM8pQbV11t+sqtl8YwK+35vETnVUUx Lf9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353523; x=1783958323; 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; bh=IjcS/Avaf1GsgDFyaOfVm5ygdYGJU0669pyToitaIko=; b=H6iW9DE1u8wi1Qcb5jJi8ZZPlbybM3rUUTu55WCjypiqCxDpRBBn0/cdKh9Qa9DFsk K/2ylsDYcDcDQXDdEvZfWRw/Dkqa0A4nGPSWFVhR/Xsw1S63XtnSkp3oLzwWZ+sVZ7Ly ZAvpAGfzUuWS9YjkNToC+aGW9eErgV52IU746FZeUKyePy16CpcgJfr65T5RCoOvWVgV RWa6NHKWqCND5f86QuP7rCT8eSXQFiuv+Af2sYwEk+DGQw8aD612dkr1UxLz81+Hbt0+ w/mVyHcs5QwSrezV0HG/8176t/wqpNFGn/nRdzOSh1EtL+0bbm2l57DLvMgIAPpPCQi5 bICw== X-Gm-Message-State: AOJu0Ywt0oRmJUM5cNsS/l1aWUT5cuJMNH3cHkiE3G8Kv1Y+S/GDz/nr lrvU/zkMzG5upn2eboB5Y7tbsW4bEIVXJiJ+9TpUb1gjCiV1I+3qUhx8xolgjA== X-Gm-Gg: AfdE7clPt/SYjzR/Ax8SVGVSQtq5dsqAGt5LvAx6Qnz/s7kW8d0Kdby45FarqJZjzC2 GV6SmXsVYGrGKNiunzc2hQZycSrvJi/2h+vXPHy46DwwFvxENeXfzBaAHNuPhFXMwRa0PT+cncR finMOAU8TDb61sYJOmF5VmaELAnIxrYx4FU9D3t+f5UG0rViOm+gn4o7u+rkhKfX86yn3dQcdsf XfJhvH9O1jjGhL0tXXSisO3GLR12b4aT//N2fp1kkUDO7DJzFa9RQFP3zdDqvyy0Tw/rue4wjiY /oOre0rkvZ6EYBbbQ7WpaLjf/2FX+XlE1xGKojp1duY3f/ejsSrVYEZN7Ab0y7ZgOUIvjG1Y7jT spzQx8Lq/ijsrLMTMYEiQxY/BhhOPtSboT3SLgcSA1xHyUtNgRRxJa3v1+n8jTkBDYv9SMTy8ar b4Lm53OtAk18ocDYGERpZ88lU98lXYjHAT8Yfvp8R3YCNtuZQcj+wKNImbNg== X-Received: by 2002:a05:600c:6d86:b0:492:2f3c:d0ed with SMTP id 5b1f17b1804b1-493df0786f2mr10598305e9.30.1783353522751; Mon, 06 Jul 2026 08:58: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 v5 18/26] xen/riscv: introduce (de)initialization helpers for vINTC Date: Mon, 6 Jul 2026 17:57:59 +0200 Message-ID: <547003a0b3489190e1709575798606b5104daa85.1783331040.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/1783353523-820DC1E0-1708A3FA/10/73395122804 X-purgate-type: spam X-purgate-size: 3578 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353564872158500 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 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:52:48 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=1783353557; cv=none; d=zohomail.com; s=zohoarc; b=REQFadaRvu4TiHGLaP+sA/z1V4D+Bed75Z41+NcZna2WBcOUIprEXxL2MZubf7NT1KfYkEBEMDgds5qusCWaSTqm+JjPr6fPT9Um8lUavXu9/VciemAXR7J7RKe/RVFrVcMfeFsvzralX5BsSDAiNuCHeSmn8v9qisI9kHjU0G8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353557; 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=2hkhMYTJKPM49ZEEfJBa6VK+y/dGsOiFIcDLfi+stU0=; b=aRq9/x2dUtHQZwld0JtD8oO7CjKxLMavS3kN4/BALtbUd+6dRdo/VDNMXqMltPAXVUZC0C5qq9bz988N8WstgfOHtPhyEwi8tR36FPWXUUUzeNffdKZjpOF7fuBuSbBsUS0vryx2D9CgxcBjLBNesBmEUI8CGT5+34RBGfFn5lU= 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 1783353557081595.9351084185494; Mon, 6 Jul 2026 08:59:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355536.1610420 (Exim 4.92) (envelope-from ) id 1wglid-0003iS-8B; Mon, 06 Jul 2026 15:58:51 +0000 Received: by outflank-mailman (output) from mailman id 1355536.1610420; Mon, 06 Jul 2026 15:58:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglic-0003di-7f; Mon, 06 Jul 2026 15:58:50 +0000 Received: by outflank-mailman (input) for mailman id 1355536; Mon, 06 Jul 2026 15:58:46 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliX-0002cM-By for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:45 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliW-00AcWu-Lk for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:44 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0b2-bab6-0a2a0a5309dd-0a2a45029ce2-12 for ; Mon, 06 Jul 2026 17:58:44 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b4-5a27-0a2a45020019-d155802ac031-3 for ; Mon, 06 Jul 2026 17:58:44 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-493d3135f62so11376875e9.2 for ; Mon, 06 Jul 2026 08:58:44 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353524; x=1783958324; 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; bh=2hkhMYTJKPM49ZEEfJBa6VK+y/dGsOiFIcDLfi+stU0=; b=R96QsvSAZOs9WHEYW2wjikor/ZoVVidqEoWaHjWBzWSFZeR5bIqBrAHn5albQsjvrW WTO7eKuARi3KBdWRUsaXvn/bPSajIhgiJE9PkS4a+cfjz/G+NxHxuT1vQvoGutLxixt1 BkibH5mQ37KBZjZODnSQ0z7fcxXZnjK9W0yuP0iiTjEexUlPgF50vrbUB8pg+UDevyFY WYQuZ62yyiNb074Jo5FO/rVNs40gYRjtYtn9u85pHLrgrGpsiwDe61wZKuQeCG+V3lv8 y4voyQFlnI1JKEnDH9A363uYJ3PTVc4SBC6b5Wi0QoFG+l5DTLWO3rgNzPE5YoR1Umk5 X13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353524; x=1783958324; 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; bh=2hkhMYTJKPM49ZEEfJBa6VK+y/dGsOiFIcDLfi+stU0=; b=G3peeIxPSk175/+SK6KowJglpHoLRIbhB7tDaTFD10qBQiQrU1KW/uNAOOFnWvsgzW FJxGHf8rKdwX9PScWR9WDM2Ezb0SyL0oSGlpUGyYBC70NfFarkerlQyxsOFgGBfTDkkF aFayab0uLnZANHYvg4TKMaJSIzuD5OC+zjMQQIg3yyKzHS+lnDbvOPq2lBvFjPvynvhj tKCjFPfgyP+o7xCD6LyhPIy/Ja3210Jj0zziWb1l4GT4U4g3RWZsAxAoOHSGaT7jBGud JnVKCtvA+ZoV8tWUAapzeWRSE1jv19XYtfQm3ee1NwJ1DSxe5Ol7io5gBKuR3ZBm7WOm O6Og== X-Gm-Message-State: AOJu0YxZAj/OKavNi3Y+xwJkHf+zRcvgMue0N6bENY+s9c2fnsaOVb+Z uStsdyL9OQYbphFGLs100yXcJkig3q28icTSZFBGdjk7Gi2LN0tuo7GDcxaATw== X-Gm-Gg: AfdE7cnu5m0E+pWdjIyHx2bk4yZnu1WPakat+owGC/YQCbdfPHH2CoD813PWwRS4Ujt GTApQ5fvTLDH4ENp/Z+ebr0jQtjnUmKvyb2aIFiDfZjtJv3dFOYbHFTii3pbqLvlsgRkXMQ+0Cf UK/jN/P9JEfJfmSUQ5u4tYPw1HNDOaBtlXwJPFXKuU2QckjTu0jodZXSHNTAlQlVSioWnnMUZ17 Uv+7crd8nlZ3K72AsV3PTdKm6s0Zn5LZAu2Y3hUKQSUWHHgzmvim1JHDv9Yqx9t+E280Zy2pAwJ f34HPUyZPmqAPBzRhlqIU+OOB+PpvTAuEU6gH6G/JPZuaIAmsN3Ck5NqCXqAMzTpnzxvTqGauGQ 7RVKPWD6UMNX83C4jXShPlhfxdwJR+Eg3HO5QsqHwe01MFLQC6qxOooaTQS3b8wQs6g+BzWa6Wt BDOyyoIz36wYarDZ7WVssjQ/3QcQrn4MebhCwRxVCLZjqATqWeQj7p0wl09g== X-Received: by 2002:a05:600c:584c:b0:493:df11:eab4 with SMTP id 5b1f17b1804b1-493df11ebcdmr9153605e9.8.1783353523915; Mon, 06 Jul 2026 08:58:43 -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 v5 19/26] xen/riscv: generate IMSIC DT node for guest domains Date: Mon, 6 Jul 2026 17:58:00 +0200 Message-ID: <7af5bcc9ef818926f02244f5d566541da06a0a16.1783331040.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-720697/1783353524-5491A7C5-89C5769C/10/73395122804 X-purgate-type: spam X-purgate-size: 10372 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353558928158500 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 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 | 144 +++++++++++++++++++++- xen/arch/riscv/include/asm/guest-layout.h | 6 + xen/arch/riscv/include/asm/imsic.h | 3 + 3 files changed, 152 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 5a5758e45dc2..8966362fb149 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 255 + #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,13 @@ 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 tmp; + else + guest_num_msis =3D IMSIC_MAX_ID; + + guest_num_msis =3D min(GUEST_IMSIC_MAX_MSIS + 0U, guest_num_msis); + if ( (imsic_cfg.nr_ids < IMSIC_MIN_ID) || (imsic_cfg.nr_ids > IMSIC_MAX_ID) ) { @@ -522,3 +548,119 @@ 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, sizeof(vimsic_name), "/soc/imsic@%lx", + GUEST_IMSIC_S_BASE); + if ( res >=3D sizeof(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:52:48 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=1783353571; cv=none; d=zohomail.com; s=zohoarc; b=UfKKzAVRR9/45J0TfZVrGqUZGOy5j2a7FmGqu2kCIkNhFtfJoVD+aQvoHzgwVVlJ4HA4uQOiRrKtR3JNJMlLmFmU/DKnvR6pjYB0FfiIflJez4a3K9ddULOIOvuowVL8HztrXNAnZbkGfMRtnXU1Iq79x4XqDoTVG7pSI7oBnlY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353571; 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=VOtrWkaPQqlfPd6Df6usWjHZMbCEmGeH2VRC7YlQb7M=; b=e4Sq1WXnjt7PhMQtaWPaGWC8HX/b+W+PplHxmfnTjHZhn8qmMnLHrpQqh8pY0IcCHR2OW3Z7KMR4wojZJySCqgjVNgAxogUA6J1hh+7p+qaWf5c3Xz6RxTSokgJuKdlTPSlAzYPOMEiyecNEwjjDOEvxJmWTrg4LRiYf5jaK9OM= 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 1783353571002622.590945976329; Mon, 6 Jul 2026 08:59:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355539.1610431 (Exim 4.92) (envelope-from ) id 1wglif-0004G2-Nf; Mon, 06 Jul 2026 15:58:53 +0000 Received: by outflank-mailman (output) from mailman id 1355539.1610431; Mon, 06 Jul 2026 15:58:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglie-0004B7-Rv; Mon, 06 Jul 2026 15:58:52 +0000 Received: by outflank-mailman (input) for mailman id 1355539; Mon, 06 Jul 2026 15:58:47 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliY-0002t5-LK for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:46 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliY-00AcZM-0V for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:46 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd081-5cb7-0a2a0a5109dd-0a2a450a953e-44 for ; Mon, 06 Jul 2026 17:58:45 +0200 Received: from [209.85.128.53] (helo=mail-wm1-f53.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b5-e40e-0a2a450a0019-d1558035e498-3 for ; Mon, 06 Jul 2026 17:58:45 +0200 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-493bc8fda98so35471125e9.0 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:44 -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=1783353525; x=1783958325; 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=VOtrWkaPQqlfPd6Df6usWjHZMbCEmGeH2VRC7YlQb7M=; b=bOE7Vr3TTWY/vqIt2ENCpd/P1jLCX8jCOt5vwl0XaQjxkyWgXZHWS4DaphEeTY4IWr WH0/ZAjMECpmyySFadbEBonqdMNRv4a68smFV7d7U813W9mY6t9aOAJk2BEtrnzrijCO R3cSzrZZ1yMPBTMBlyhWinDnDnqYrEmNX4J0sRSK3CG076qfyqh66lQFHjIRaQVGAmBB Chzcz+eXWKBA39NFnD0MZd/yG/UbioeLRLdgDjS5rbmHq1rVBmCi8ueM5CJkS3ills5z IafVQxHCr9M2eDDyTXEs1/LsHToTM9StBZfkjGM6HD/8iIe+leX3DuWM8bKjF2PY14Hq uclw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353525; x=1783958325; 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=VOtrWkaPQqlfPd6Df6usWjHZMbCEmGeH2VRC7YlQb7M=; b=GlMxcgNHGtn8PP95VtsfzLRjjIjoCOZjZ5+Y9K+0A/tVjTTJMdnCaeoUmNLGhBqDq8 7YQqWMOZ4fCBAGZGuAsAQBqX8ndNIvP2C4ItHtSlY4MiC80qQ09w3hVYInUY1nxRG1O7 zlW+tMRfek51FmOTGT62Ti65gXYsg+0cyX9oNN5Rvgy+ZccQepsmdMe+CDcIEbNH5O4E Lsv+STwpAQPi7AD/wrMcDdaBQkOO/QJxJCt4+amCwMhjHMzFyVjNTfGiKHgm0pd8WVX6 Bt/UM9J2ZCQnVVW7W7O8Gc7XfbfaAqQTn2ykOwzAw4as6+S3MEuXH8+Mq+LfUDSJf4aU 8mUw== X-Gm-Message-State: AOJu0YyIjiun6UzFg5jcNBhGOka2Q+0zUaRXjTitwKSN+xxyyhc8E38I cxBqWjUGNNlRoHEECLlo/G5vjRDoXtR+PZIXFnlN6kIkS3j43AKjJwSKJWfvOg== X-Gm-Gg: AfdE7cnjo1kPvPNc/2IMcUwk1kBPmraP0nn+OtLkBEV/J0jPnCpF+eLnXDE1UcnyWkp dN4mSPp/Y0R0QgmsdfGLTmQp2RoLl/aozlvtzMJSjFAGbbjPlvRv6Y9wa4xEC+MHOY0JhQsgWIG GvdBEw18mvkf5CquVZqFGEJCWTEKc95bG/RVK8aqkN+DdvQA02cwMtb0g7pppeyiwmsCUxK7Dqv 4x16gndsbQU3vNeYBhZDLvQa6ppyKoJUDEzVSJbyHtBFszde0AGylcrhDixcCDt7JHAm0rDkheD AUFzWP+1ETT589hPHx8zkKctDMcEKCxLqSa0jK/UjT/W+FS8ECRh91AkRJei3WPytZjGF6Tr844 zh+c2tEzEFf5zJrWzw3depQK+8mTmmgsTsLxpUuwxD8L7Qv7WcuDIoqNA0yU8DbSpJxUbB7+Y/v vmtCjghzoUKxtdSfz3rnFn/t/44THUVITFzGwhp+BVg13Xz7H6CMkpNhl+eA== X-Received: by 2002:a05:600c:3d8b:b0:493:bba7:e9f4 with SMTP id 5b1f17b1804b1-493df065f50mr14196265e9.18.1783353525265; Mon, 06 Jul 2026 08:58:45 -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 v5 20/26] xen/riscv: create APLIC DT node for guest domains Date: Mon, 6 Jul 2026 17:58:01 +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/1783353525-3D470DDE-DB34833C/10/73395122804 X-purgate-type: spam X-purgate-size: 8543 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353573045158500 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 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..ac971f34add3 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 96 + +/* + * 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_num_sources; + #endif /* ASM_RISCV_APLIC_PRIV_H */ diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 126d56fb7ea8..5f8ae4d97b87 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_num_sources =3D min(GUEST_APLIC_MAX_SOURCES + 0U, aplic_info.num= _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 31264e2e683a..5a1ab85353e1 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -29,6 +29,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 6562b25f0abb..719c439e48d9 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_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_num_sources); + 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_IE | APLIC_DOMAINCFG_DM | APLIC_DOMAINCFG_RO; --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353565; cv=none; d=zohomail.com; s=zohoarc; b=byeeHqJsX3CuU1AUB1wq28AhEZnmBq21Ee0D3fo1uBiCuWlQs8stqgKp2FJx6EhXnXlh0rrzfkf/+Gnrp7wfV1vm973Fob5prCa2o8RbYuBTmfAX7rluXeuLyGi988VAkcs13mAYYaldsYo5k4z7PrsusHoezuCFi2ez3p85kOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353565; 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=qhDSRqZCa8FiBzhpxge5NcsdKHKmZpIkmXlsTE8qD7o=; b=kBNc57LFIXjLrcxyycfr66vVNhyse9Tm21WMjf1Q+DdhSMdsEiC4C0f5wXOY3fHkTQherFuIUElkrfgLtC1gEOHKfjC4HBujgb1wcWs1LH+NHkSp5DVh/Wu0KnwCW54nYHV3Z+n4BdyglOIqgtfyaBisxBRkCZGByugLBGtgtec= 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 1783353565540969.8116671990264; Mon, 6 Jul 2026 08:59:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355542.1610438 (Exim 4.92) (envelope-from ) id 1wglih-0004Yn-31; Mon, 06 Jul 2026 15:58:55 +0000 Received: by outflank-mailman (output) from mailman id 1355542.1610438; Mon, 06 Jul 2026 15:58:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglig-0004Tv-2C; Mon, 06 Jul 2026 15:58:54 +0000 Received: by outflank-mailman (input) for mailman id 1355542; Mon, 06 Jul 2026 15:58:49 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliZ-00038y-QU for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliZ-00AcZM-2B for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:47 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd09e-5cb7-0a2a0a5109dd-0a2a4509a9ae-26 for ; Mon, 06 Jul 2026 17:58:47 +0200 Received: from [209.85.221.47] (helo=mail-wr1-f47.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b6-97e6-0a2a45090019-d155dd2fc94c-3 for ; Mon, 06 Jul 2026 17:58:47 +0200 Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-4703bc0a99aso1762405f8f.3 for ; Mon, 06 Jul 2026 08:58:46 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353526; x=1783958326; 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; bh=qhDSRqZCa8FiBzhpxge5NcsdKHKmZpIkmXlsTE8qD7o=; b=nMXQ+opT4rriqH71Vu7lhQenbFWxJffsFH8qVLBn7+KFi7A1oPmzEzLzOcYURbCHbm fgLhPG5YgRNMtpgr1cURPug3GifN/MSCOwxvoZW30KNBJ4+DXUhv/Y4RX39vK/GbcENN nMrF1a8KJFUAqeZdzmhYvQfBHEA+rtfll+8t2MRmsJVy3z1MdmZFr8gLDvIyWQZfBtpv 8CXRgXns1xyLOLmTgxe54zNzoyr9ur0UMFfUVC13KXAP2YgwV4hK1ABGQx0fGQwZTIMt PvmN6sR5b5/7hDkf1FlA5aA6stVAP246+r2tPIx1x2PY3h73qFj6kI7+LzSGQRhrDIlK br6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353526; x=1783958326; 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; bh=qhDSRqZCa8FiBzhpxge5NcsdKHKmZpIkmXlsTE8qD7o=; b=hAJ5UuJV3OIn1KcRx0afXseYOyV56886NLDpKtw2azkbXQVaWG8EpuLq5+BVvaHwOG CABbsamzRzNuLJdqYYxiU8kXevhAKztGcL9lLEaiOnDSD1gyEiQqrww281C1olGsbkLD h2cLN3XqfOWLorSXUVdjIJVDBAD+14R4m/gKiopXrkVfUmk2yL9+Cm4WmW5HB5VOArdF hixFD2uBm0rV32etGnCWAUZBU0a89aZtAG5Qk6C2Qrkg/Z4244+udcQ5xr5wMussePOX CEXJkCGowrbqcwwStYESfYh+sqnQVfnOHFpKeu2XLpF0L0w1WETwaAGJkpQQPXi/Xaeq A2ug== X-Gm-Message-State: AOJu0YwCM7mg5vZlnn0NxZmZT1B9JS5Aw9PyUA57pbBpTCDgIhOAR4UE Z5TFM9Lvef2Z0uVyuxD156p+v7hZuerpBU9hP84tDJdnARGZu1Y6LtjbwfhIZw== X-Gm-Gg: AfdE7cmmlNd6Ge7zbOJbwuMsZwkx/z+d/sqaASK8FvDzv9NKExJJjsJcoYKYqHyqC9q DxqX0mL5gikXbwNQxI0F/zClbUhdhK88OKmkXm+4GAgKJhOqMzvHh+GjPpSXIIrqyjuHv9hFngM fHc2iAJ31F1l4lqrz7XRo6D0Dj8ZERY2i7QgYRZk8WlNnu9WnAS/HA53Pz8Y15iJj9Ib8Jv4Mzk dIJP+D1w+hKHb2JLfIWGaAnvWv6hrOn02I3AsIBynZwHKxqFyPqJYJffcJgHemuO+CCU63XFU2S 3UWZ8Qu1gsYRmfmjaa0+uqQHpj0yzsD3QT5b7JgiEGsYUwLyJ4J2wKYwY0djBkz3m+IMfaJB0N1 4gTfpcuc6ag94JMGIHnP2FEWx0ksKKmpENmRTR2pTzrc9RUWdHINVSPWePu5YjJPKB7/PIDsmP3 aiaW+GI3gJFlbcncyno13RDPwNL4MRPdKwugOphxRbn04kXvtKoRO0qNg2kg== X-Received: by 2002:a05:600c:5897:b0:492:4cce:53e2 with SMTP id 5b1f17b1804b1-493df0412f5mr11029555e9.3.1783353526179; Mon, 06 Jul 2026 08:58: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 v5 21/26] xen/riscv: implement IRQ routing for device passthrough Date: Mon, 6 Jul 2026 17:58:02 +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-bad1c0/1783353527-46D3C986-51781026/10/73395122804 X-purgate-type: spam X-purgate-size: 22158 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353566989158500 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 Acked-by: Jan Beulich --- 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 | 2 + 8 files changed, 398 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 5f8ae4d97b87..9b9a0929a89b 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 f633636dc308..2b95f8226be2 100644 --- a/xen/arch/riscv/include/asm/irq.h +++ b/xen/arch/riscv/include/asm/irq.h @@ -49,6 +49,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 25d329500212..ee75e0e88d85 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 static bool irq_validate_new_type(unsigned int curr, unsigned int new) @@ -192,6 +210,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 @@ -221,3 +247,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 719c439e48d9..2d0b31e08252 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -124,6 +124,8 @@ int domain_vaplic_init(struct domain *d) vaplic->regs.domaincfg =3D APLIC_DOMAINCFG_IE | APLIC_DOMAINCFG_DM | APLIC_DOMAINCFG_RO; =20 + d->arch.vintc->nr_virqs =3D guest_num_sources; + return 0; } =20 --=20 2.54.0 From nobody Thu Jul 23 21:52:48 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=1783353571; cv=none; d=zohomail.com; s=zohoarc; b=npNYqKpuOwrSUBbNOrfYqFXvJosVqPZGKg8y4o2n29hysgzjn5yE6Uw6ef60u67N8/d+P2snDYE80FdCT1sqN5tucmh124BjrqBOzIrPiZzCdoaajZl40SREkAQgD2qnOnoMGGb8kwMJncxLxasRna0e751GsRXgB8z4/N/VE8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353571; 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=2Ic0zHniYCoxw7zx7ppkCijfRbsYL+qDQtIqh4IRQM0=; b=DRXA/TuiaZRKiBU/GJdsna7wBD/XcC3BcU+5ur1CkOZqhsxq/jSWWmOeMmL0XAiMf4aMotI9cuoO7kDaDN9sg4SxnU6k2T4ln6G87roKZB60pX+aTISt+kriYrVqOar5BFdzZaRI03tN/ESA1jDRYoCgqoZHLum/0uc4JAhqRZY= 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 1783353571657859.0042411379352; Mon, 6 Jul 2026 08:59:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355551.1610445 (Exim 4.92) (envelope-from ) id 1wglii-0004sQ-Hk; Mon, 06 Jul 2026 15:58:56 +0000 Received: by outflank-mailman (output) from mailman id 1355551.1610445; Mon, 06 Jul 2026 15:58: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 1wglih-0004m2-FP; Mon, 06 Jul 2026 15:58:55 +0000 Received: by outflank-mailman (input) for mailman id 1355551; Mon, 06 Jul 2026 15:58:49 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wglia-0003MT-N7 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglia-00AcZM-2Y for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:48 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-5cb7-0a2a0a5109dd-0a2a4506c18e-16 for ; Mon, 06 Jul 2026 17:58:48 +0200 Received: from [209.85.221.50] (helo=mail-wr1-f50.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0b7-08de-0a2a45060019-d155dd32ed34-3 for ; Mon, 06 Jul 2026 17:58:48 +0200 Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-47ddf7b09e5so1296415f8f.1 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353527; x=1783958327; 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=2Ic0zHniYCoxw7zx7ppkCijfRbsYL+qDQtIqh4IRQM0=; b=KxzKMkqIgwLHRhdy8jeNA9ssd5rUT7CW6v22OfHGjl6C/UTrakGwspxjZYUSoD4fot dqSDL9oBrlawDv0anJXa0DcNPt1uGwOP5j0lJHAUXcSRP4OIUEUwKC8V12/Kc1VC9pC3 3EO9k3PjAjV7D71Uo9wI7aq9q9NyTUx8ghth3cEoTqFtiC8yYpKqOpqMr3O7IkfbB+m/ Z0n6U/MhQOSJTB1Y4R2Z1TOv2DyDTlSAcj8sRsjPzBZkK6iQSy1kTc6YbgnenAc13KcI SDFx9jXX59hTmPrsaEDSN0kDnAozG1EKwBJIEcMOB9Qs28jyr/p2D8nOCGO+FPUwz7ju uT5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353527; x=1783958327; 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=2Ic0zHniYCoxw7zx7ppkCijfRbsYL+qDQtIqh4IRQM0=; b=GK79lLaGpXBO/wJVIN+gnrX7qF0wWVY8d33yC/iLlvczGJxO9zZHjMl97EpqlnaIOT sVU8x/Myc2MUKJbBWpTIJnw11DZM7P5CPR8kblA5hbbAVavNsj/3ZEfB+EHRCJnHaL5f E+YQO2Ys2ZuieCNLGP38vpnHxMuTZz3wrGQSiGLIZWzg52RDo+nZRE63VTwkcazlGvcm mKmnAnTd5mJBaaJw6o6QNkxGeVrjvOSQ/N61LOvpSiVtpXZDAqbLYVKI1IFsNFRGW6Es sNtdZXL37PQAeOuFOCUHJe35va5y0oRHli90Vd8YRbHMsJ0HlXJMgX//njJkYVOPQxI/ OWig== X-Gm-Message-State: AOJu0YxZflmP9BLlIFbNaQeBVu7zVlVPqR2hA2S9nbsuGJaLCdhky6wJ zjsq7eQ5BrvE1w+xzZZ1Pyq0TGEQnL6K+RefKsmdYjuXqFW4ruuvkjsnCU+R5g== X-Gm-Gg: AfdE7cm0a3QqHkHK1grxVNHP2GFyS0lC5qY2geWd/g2Y37qNSgovYEeqQVKPI0TWnAO Su153qUm0PZkpZXX9bV4b2Jdn4N2/ZcUn8jY5u/1eSen9phLhC9OpcN1nLW573GtDNKcVoR46vO 9xDTH/Orda0d+5/tDnUIllyr0yGO11bCccO0sVKmqeoz1R6ni217FLECl8M6mUCWJPoQtbvC+rd Bb+wRuyV2+qAYul0UFyrP7sYwyW/C+STb02nJS06IR5sJ1FjWZtT/H+0H6F9wETnhRQLkcq0BZJ JozqwA9tlVZbFkCUNU1VCqFthlr7AFh160KQwXwTUBIv4phGDK9eO96L+xuUTlgqHqK7TcgGYtD NEGxe1pYCS3enWwDJyqCiMXUQRWLryX+A/yITmlLpehZoRs2N2r6o46OIhAzFABBzSX/dQWCB8O oUl4nrKkiMcluc5bMozGjGZWRlT8LcJLqmpKp6Sm6bZDgUbXhWfvAWGiqlDGoDLCLgmEza X-Received: by 2002:a05:600c:218d:b0:492:465c:56f6 with SMTP id 5b1f17b1804b1-493df05f8c2mr9276095e9.10.1783353527496; Mon, 06 Jul 2026 08:58:47 -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 v5 22/26] xen/riscv: implement init_intc_phandle() Date: Mon, 6 Jul 2026 17:58:03 +0200 Message-ID: <3a8dfc37dddf0737ac830149ac78ab0bb1677739.1783331040.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/1783353528-C712768D-1103B545/10/73395122804 X-purgate-type: spam X-purgate-size: 1378 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353572899158500 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-5: - 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:52:48 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=1783353575; cv=none; d=zohomail.com; s=zohoarc; b=VKy06Vu6Lkj1dyWnhhq0xQNRAqO45xlIu82NZ5qHI7iKM5kvbn1Esnu1X9B8JHpZjIoxYXTAICcQQ41zZnVWaQlPUfv3LNQhv8f5BcZR+yaeIT7Qq/nBu/DtugU96xsHTGTTF2rWeF/Uh5/dJJFMt33fz49LcTFXFh4LepO8/sA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353575; 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=1HewRHJTZRQ+nFOINwAOu6Y1DjcWg4/eeN41dA4C7d8=; b=Rukvm0LYZvnJJjrT1YoKW1mlPepH2fjCMiIexxWIfZSmvxJOFsipxxTiLInJyY/WmqWCEd/lPw94p/RvrZ4mr10+w0LCAKUODAAbCOHJEQtR3C42AUCC/72rThAyXwP0SSR1dJ0Kfm/jxxKlGShpEkxgTOJiokRpW5VTPSD+A44= 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 1783353575746288.69574981735036; Mon, 6 Jul 2026 08:59:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355560.1610462 (Exim 4.92) (envelope-from ) id 1wglim-0005fP-Fc; Mon, 06 Jul 2026 15:59:00 +0000 Received: by outflank-mailman (output) from mailman id 1355560.1610462; Mon, 06 Jul 2026 15:59: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 1wglik-0005Wk-Vw; Mon, 06 Jul 2026 15:58:58 +0000 Received: by outflank-mailman (input) for mailman id 1355560; Mon, 06 Jul 2026 15:58:52 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wglid-0003vU-N6 for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglid-00AcZM-2N for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:51 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-5cb7-0a2a0a5109dd-0a2a4506c18e-26 for ; Mon, 06 Jul 2026 17:58:51 +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 6a4bd0b9-08de-0a2a45060019-d1558034ddb3-3 for ; Mon, 06 Jul 2026 17:58:49 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-493c2c0b9a8so28898005e9.1 for ; Mon, 06 Jul 2026 08:58:49 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:48 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353529; x=1783958329; 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=1HewRHJTZRQ+nFOINwAOu6Y1DjcWg4/eeN41dA4C7d8=; b=Idf7NBF2lXqiSqVXI0YGxX06/k8w2L90hEi9wa4UHBgBPvSBrhrZQ+JCNWOKjLv6R4 ETIk4LzOBRKCdw2dBNRX4WowqGPrvKgeU53gUli/vXJSd3lCCXCl9w6PQUgM0EIz0e8I ppw56QuSk3x/+65jZHLg8RXjLgM2ijTpYw5xh6o2WNnXXImDOPXMi4iUQN87a3+ubSKr uNTu0JRstJVMgctezpA5en2U4JHV02xRZxRmz4pAMjSovLgAhQNgio2I/GavzogzgynJ dSowT9gBBDfgU0aWF8g0ass7feeWIH/YPp28VN47xUnELHAPM6ziY47s8u5BeHWhSh7A 1uJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353529; x=1783958329; 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=1HewRHJTZRQ+nFOINwAOu6Y1DjcWg4/eeN41dA4C7d8=; b=juZTujgOkSeepRflR4PgiGc2sxnT0hISXaw7GAnaGSR1FgUOg0is36LVU02fjWzR1t JxHWgWfZgicWXtLOIdezRUW23YR1/CmP1WN4vHJ0LbVY9vNCQlWbp9hze3prV3Ohql/w amiVhCenT88lJyOmwfNAGbVdbRG38xplDsjr5AYMwqxUzQ4guWYtyllUQPh1JEdom7jY 2UKJHH30LFgFliN45hrVfqUCNvPocXfO+bswRjFhiz6vxfKaJOWYrVg+OpFwvWC3Jpv3 k+CJmAFcvDmXcAFaQroahlA0MnwJUzT7Q4UycwCZsvbOkAw3OBU370z5WUceNHOlq9EX yQpQ== X-Gm-Message-State: AOJu0YwbeMQwZR4IHkQSLF+2vY7T6BHp6rJyRVk3AoSwUG7HgQsgVAPX rgR6yLI/1NH4PlyPLbOuCga38wOqgC8vgw/z+9J6dPb+v+AaF4mZhcDINFHsMw== X-Gm-Gg: AfdE7cnAMj31o14Z0t9X4V8V3Np2uzE/bMMYSk+WkKuR6Cag88e1oZ9o4uz3L7KHCZp 9e7OkMOcHFaIsAVnivkTejvgL19YaW/CvI4woA4xS0FHK5Ms8A6+j+8QGZb5ASeLHciEdUFirrC tHXOYKt7DseCycJlQMIidwwZ75Rro0fQqbkkkhurGWUlx1HHpvzqKpX20aNIsaRdJJxLCNPIOaI 3K8IyMSBiRyulMpvlAjgnjE6V4JW2/Yd29rFRBEF62wTcNEYUoUpXxZg4/FjHJS8KOqcmSah9l6 OxQFDrGrICFTQLCOHpskfcMh8I1riORQXxF0raXYdHyB8fW9Q9p738fcAR3ylsDUR/jDjwatESa L5sqLa/ngc40QoJeR/Fb4rUnGQKGzGhQ5x9gm/roLlUpn0uplpbY4LdDF/saiFgOmcIbvbGDQ3a Sg+af+iT2+vrbtgMmGinqKprsLODNAtGi7t70RBoXN76XbLUlzI97IzTlaLxC60ABKOAUI X-Received: by 2002:a05:600c:37cd:b0:493:9661:f55d with SMTP id 5b1f17b1804b1-493df09a412mr13882195e9.30.1783353528691; Mon, 06 Jul 2026 08:58: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 v5 23/26] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Mon, 6 Jul 2026 17:58:04 +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-16d1c6/1783353529-C5F3C68D-59DF2D02/10/73395122804 X-purgate-type: spam X-purgate-size: 1560 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353576938158500 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-5: - 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:52:48 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=1783353566; cv=none; d=zohomail.com; s=zohoarc; b=LIhuiUZoRjLihcJfGZbZPywlRyHhFBEq3LZuI6GDDjKFJzMwST6gOWeRZ07wMRNUES8wlXpVdNBdm3Avmbcu+xvGDG4hHw5Y0W9gDFkqiZhZBcY7yqUgPmewdYMh5kLsaF9ZSIb4By7RxggM6vUwZcVyy/ibzEjbVewCfbJPbl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353566; 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=U1yyxCfvyoBfYw/uEmsf9oSi+vYcj07VTIqsiRnbV5I=; b=ARxF6yMFkioZKzAgsiVlEvVcl74s3YHNSY1QkbOXezMhYL8v7/tsIo9MS+NxM4n2INYRFlUUmScIJdJ0w7CST62hHuZqPKmwtn3nYWo4lMJ3zVmVHn/gNACfSklQwdKdgHSxYE+uI6nV/PjDVIvpc8Im6UU62jY34B8QwI0IqCM= 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 1783353566208906.8681380505093; Mon, 6 Jul 2026 08:59:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355558.1610450 (Exim 4.92) (envelope-from ) id 1wglij-00057i-Qh; Mon, 06 Jul 2026 15:58:57 +0000 Received: by outflank-mailman (output) from mailman id 1355558.1610450; Mon, 06 Jul 2026 15:58: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 1wglii-000505-L4; Mon, 06 Jul 2026 15:58:56 +0000 Received: by outflank-mailman (input) for mailman id 1355558; Mon, 06 Jul 2026 15:58:51 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wglid-0003ox-7s for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:51 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglic-009yrN-KZ for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:50 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0b6-e002-0a2a0a5209dd-0a2a450a8e8e-8 for ; Mon, 06 Jul 2026 17:58:50 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0ba-e40e-0a2a450a0019-d1558031b063-3 for ; Mon, 06 Jul 2026 17:58:50 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493b1710405so19852425e9.2 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353530; x=1783958330; 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; bh=U1yyxCfvyoBfYw/uEmsf9oSi+vYcj07VTIqsiRnbV5I=; b=rgFyynczNwyTgnpBfT7DX5sHfPvN9aUX4tdcvdGI/QLwgB9nCR+Bn5grd89Owcf0Gk PaqOJTYmjMebSoAyX1pDNhi8PNf3WWIpNt4oeMpKFyJJR4XVhYwwFWfx9V0maGdnCYNB MINewd3oehJH9eH+qtqiSKr99JtLgpaS0znMsOiVbP01m1QekaOhugTCUJxVw+oC4kT5 qAb8jFygqN4JsgG0bgS5EFEtanV/Uyfodw/g5XBaWzkV1NcjnRyntVcihqwmDaENC64v 2O2LeFA3i48TimXzGpF36HY2q3PJ8mK8N6Gr+VjNWgTCER7yN7cjCc8XJg74jUwCW9gc ZoyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353530; x=1783958330; 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; bh=U1yyxCfvyoBfYw/uEmsf9oSi+vYcj07VTIqsiRnbV5I=; b=HMm17Iw3gR8oByf5GT53A2KYur/3+eE6JJaCjOrx0L+KDk27Ub1+DXK4dW5VYOUk+g G4oMR7O35m2MludRDC5tV1/FM/xtHLHZ+cl+ngk8/Oe6+oK220fmX+nbKR4ECo5wCV9k 7o4dLCWsn05l2y5CSCubpeOofiLp652LFP8qEHV9ZgZ6hP9xJThwKLYuW9JQx086NLKQ LW+XfRwTzPiT1cWoG4OvTty6EY52QnU4YejG91dK50mcL73p0enrXbZ/eGj1TsjK53o+ UUairC1z7/bolxDDqWkCGG+ERTEYKilPoKbKIe4G7IR03zrJzPpRo+1UYljYW6vRnA6u 3haQ== X-Gm-Message-State: AOJu0YyS5wuKh/G3CpndESH3gwdsTrcbVIxlEU8O7XmlP1BGfPFWrrVz bYfRyknEuhAGMJBE5qI9jXHun6R315FBTlsyDkpK6ZUErwb/lS2Cowge0PMxQg== X-Gm-Gg: AfdE7cmtdxTBlrtJrdnBmw+Fz7gHgcJF7q4p2+9lypGl5n07GZZL7qUKAhT2e8y/x+D M1QRWRHXTEzjajbkA3XWHW8lMzhkOLXu06yDj4VwFJmhXR/jUg6l7rWQ3alSJ9MGITgvmp6Y49f w6aWzYj55j9N/g7LMFD+eELDH+LKIS+4sNykEd2b7YdkJkAMyflPvlzSSnLDwEt2e0ZYqVHRbI9 jzjM9NKwKbovxUF8oAa+GzmQqX2Q0Ra2bFl9JngcZa8dLlmMxMFrPb+xBOFMBkpz7p5wQygKItR adBHH3r6qZJRB+M1uOTJAZkm8s4DgHpFEZ/4n6cS0CZqBaoWWacQoE+Z4lAhomKdCwt4/2QmYff AQuANyC2j23Cx8y2dBTVuLmlkEJWyo2w8kd5doHHVZGwhB5vzWHe2PCUf6AlV4MYH4809qBM4Fq ITgBbpbfJRo6ihjlsa4oJ9L8eUh60hnuLsSICm4V8sZPuDoCtoHk34Ig75lQ== X-Received: by 2002:a05:600c:4e04:b0:493:c389:d434 with SMTP id 5b1f17b1804b1-493df07398bmr13932665e9.15.1783353529794; Mon, 06 Jul 2026 08:58: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 v5 24/26] xen/riscv: provide init_vuart() Date: Mon, 6 Jul 2026 17:58:05 +0200 Message-ID: <0754278839160c0bdb922254d66f56b0e25206a9.1783331040.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/1783353530-CFD33DDE-9F180D37/10/73395122804 X-purgate-type: spam X-purgate-size: 1391 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353566874158500 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-v5: - 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:52:48 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=1783353576; cv=none; d=zohomail.com; s=zohoarc; b=nYBE8HwCIXAjyd/OsixiFEGHY2wR2VccNKjuTWaN6KEuqrkSNvah+43aREt1H1RgYhfpngdkU2KcEOsLtmbNpAPgAClBY85w5bby7JMAmIKFO4C0Ate3hrVD+bxQ0c/b6Hy8nobLUqgxQ3Y+5Km6T5bSL8UaFhpVboDI52A+CKg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353576; 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=geHCSDaLoyJK0T4JaX0vw42LUcqQXsZkwutnK3Lm7Fo=; b=YXNmGr/SJLpKx0ImICFbzkUtwNAtpRDgUQqmnn1fO35fRuplrRSdGnFUNpXNy2gunzCKnmEy+1IQa6M8VoroUWh1VPC42kgv/K1NKp5c+MmS1clLlzOw163Lx0WeIRgW47jW0XG8q4xX1nEIkNUU91unsA2aL+Y8+GbgG6Ctxro= 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 1783353576578127.9642300292403; Mon, 6 Jul 2026 08:59:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355565.1610469 (Exim 4.92) (envelope-from ) id 1wglin-00061R-Tn; Mon, 06 Jul 2026 15:59:01 +0000 Received: by outflank-mailman (output) from mailman id 1355565.1610469; Mon, 06 Jul 2026 15:59:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglim-0005uk-Mq; Mon, 06 Jul 2026 15:59:00 +0000 Received: by outflank-mailman (input) for mailman id 1355565; Mon, 06 Jul 2026 15:58:53 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wglie-000460-EU for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglid-00AcZM-Qf for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:51 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd0ae-5cb7-0a2a0a5109dd-0a2a4506c18e-30 for ; Mon, 06 Jul 2026 17:58:51 +0200 Received: from [209.85.128.51] (helo=mail-wm1-f51.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0bb-08de-0a2a45060019-d1558033e1a9-3 for ; Mon, 06 Jul 2026 17:58:51 +0200 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-493c83474ddso29313405e9.3 for ; Mon, 06 Jul 2026 08:58: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 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58: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=1783353531; x=1783958331; 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=geHCSDaLoyJK0T4JaX0vw42LUcqQXsZkwutnK3Lm7Fo=; b=Ttifz6pCIj12NeSMJLMk1jeMGtlVC2aP1o7atKbJ0LILzLLPwO6EF1jf2GCXUip+d0 PXmoeOWfitSb9sIWAaVg0pSK4TaaHPghe2yc4Q8cmgoAsAHSvsM5BXrBJd22jwgPHyiJ qzf36OKJEijaUit0wGZh7G+OlrJtz+tQ5dWURssDv4m5WY0Wk/TMZFwYl4CQx+xkRVMd TnWB3vMVvwJ81uc4CxRLeejvgGuLvbOaCFpqdeeEBqinN5G7FaMUZBi+6On4NdfwHvRY D/9Oi8R7RhmRcZwvLOI0M2xgAeE+wrc+nz98UPk1+xKnZP17FyMitBe/AmIR7D3CIyJm 6UKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353531; x=1783958331; 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=geHCSDaLoyJK0T4JaX0vw42LUcqQXsZkwutnK3Lm7Fo=; b=JAVvaMUBXeCGBHtNIpsW0iKj6jslj2Nv357hWU5xQdB2YEA3BbiReQjoif/FlojqjG U6BMQ6XVO6xpxi7S9p6yFaP49lWC5Fm89XvJQdRJIGEND36xPs1KIxsajOx/yA+vV3b/ 0aKVKCM58UxfAb1psPzlzpl0l2F53hHB9XJoaekDdFAcg7YGLEZBJmozSgRBkqFQ4TZ8 tEYzSllOXNfO7lKojcqNN/fbxAvHPgA+74gUrHtgVY9pu4s+AQfdzzBwaTwehgKqfJO8 j8sXCQJzc1wfy9MgX0isU8dFct7pI2h+SQUn6jE2p5MOjzxxRwyYbuL8gAEwNqhl7Ej5 VCpA== X-Gm-Message-State: AOJu0Yy9vj7vcxQo/h/XjbQzFyposBHWHdHOIon6LOX+zcF3HMSrIQF7 uS3+Pw+7v3+0+F4a+7zu9xtv45XBYDFFYEKf79xkupltb0Wnavhq0aXwIAOfCA== X-Gm-Gg: AfdE7cmYVrVhzkos77GbQ8Vpdzgzccb2VvMorZTKa6hNvKnhzfzeuQPdkYdPkhNJmrW hAgX/oDradi+imx9RSLqrZfABPCzOVshmGJau+eJNTrC/NN+5Q2ImdjaQOdweidTpyqsQ6/enlV aiY2bK3BTXPNaxkE/JnWclJJJ2LopRiQ2wqqJEhQQWXzbHV/SwZdpxd7GKSi++twrKyvqIilgxF cJ+NsmVE7XrXHOEy26CHb4eydt9zhz1j4+LK0ixBEbcgg51sKLipZ8RQ+CBg3JPFtcGLg5MRuLH 4KUeTZV7Ut5vweDrr90Tbnj+6pyVSgt0NUZl/Dw6trKWVgu5s5tDmVgJDD7ZXo3aQSeALfG2sRW 93lxLaclroGuju7fZnK7PmrCtHki5oG/q/m6eKK3/D7ajiMlhXyKzQU8EWn7p8JbrCViM/nNte5 OofrL8MZKjL/YPcaK8OT37esTZGzHS1zUAuRTGfWmlKwfhveKz2qmrDLSJeQ== X-Received: by 2002:a7b:c38e:0:b0:492:6f6f:fa42 with SMTP id 5b1f17b1804b1-493df0a1b84mr9512065e9.37.1783353531170; Mon, 06 Jul 2026 08:58: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 v5 25/26] xen/riscv: add initial dom0less infrastructure support Date: Mon, 6 Jul 2026 17:58:06 +0200 Message-ID: <8fdb9cb4579e20dec10a9919fa966bc00394c6e7.1783331040.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/1783353531-C593B68D-D4475562/10/73395122804 X-purgate-type: spam X-purgate-size: 7215 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353577049158500 Content-Type: text/plain; charset="utf-8" Enable dom0less support for RISC-V by selecting HAS_DOM0LESS and providing the minimal architecture hooks required by the common dom0less infrastructure. Add stub implementations for architecture-specific helpers used when building domains from the device tree. These allow the generic dom0less code to build and let a basic DomU be constructed on RISC-V. construct_hwdom() and make_hypervisor_node() are still stubs returning an error: Dom0/hwdom construction isn't supported yet, and the hypervisor node generation (needed by domains with DOM0LESS_ENHANCED_NO_XS set) is not implemented. Both are marked with a TODO and are not reached by the currently supported configurations. Provide missing helpers and definitions required by the domain construction code, including domain bitness helpers and the p2m_set_allocation() prototype. Additionally define the guest magic memory region (GUEST_MAGIC_BASE / GUEST_MAGIC_SIZE) in asm/guest-layout.h. The base is arbitrary; the only constraint is that the region must not overlap guest RAM or the emulated device regions. It is placed in the unused gap below GUEST_RAM0_BASE (0x80000000); the constraints are documented next to the #define-s. A separate region for grant tables will be introduced at the same time as the introduction of the grant table for RISC-V. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in 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 089e5ce0e0a4..7f24bd1023bb 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:52:48 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=1783353572; cv=none; d=zohomail.com; s=zohoarc; b=CmvktqeC0rpkNE9uyJN9xdUCqvtMwxW7CZzFW2FNtMvyoIbFvAygm2Ru1TOzqiM6139G68D7im2IbmXIljFJEY68KTcq57G8aVZOSF+9QdKPlQPl8YGxNoV1TD5fe1hm5LufKP9JrZvHl3p9eO0d+vXx5pHrM8f5ROlX1ACG5Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353572; 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=IxRXEnbnwcKwLoBQXvU2u8JCcaQ998O7uU3S4PznH3Q=; b=IeWulYvzUug7g6G2m/ajM6DFIhY1h540zyiC9Caq/KfT7OOUT9BJ87Knb8hJudH1o7HjmskWGct76rkOc9fmyL4VvFHXeIxn+13uFauslYYySQEuyLVI719ZFzg80WAxnl9l5YSftPKtXJ79Fb7y6s6uhWQ+FhdtVEMgqTu6MV4= 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 1783353572175908.9171254805111; Mon, 6 Jul 2026 08:59:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355572.1610477 (Exim 4.92) (envelope-from ) id 1wglip-0006Kb-EO; Mon, 06 Jul 2026 15:59:03 +0000 Received: by outflank-mailman (output) from mailman id 1355572.1610477; Mon, 06 Jul 2026 15:59:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wglio-0006Ee-6N; Mon, 06 Jul 2026 15:59:02 +0000 Received: by outflank-mailman (input) for mailman id 1355572; Mon, 06 Jul 2026 15:58:54 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wglif-0004OB-Ov for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wglif-009yrN-5A for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:53 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd074-e002-0a2a0a5209dd-0a2a450cca90-44 for ; Mon, 06 Jul 2026 17:58:53 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0bc-f399-0a2a450c0019-d155802cada0-3 for ; Mon, 06 Jul 2026 17:58:53 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-493ce08a75bso13625345e9.1 for ; Mon, 06 Jul 2026 08:58:53 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding: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=1783353532; x=1783958332; 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; bh=IxRXEnbnwcKwLoBQXvU2u8JCcaQ998O7uU3S4PznH3Q=; b=E8cmFWT97x4lrt1ZPiQ+amgj+VkUa+G++KeSAiYqHDuaWMkdWiCFzqNE8UgjWG+f4O iJC/qLVdxJk5KvP4gE4HoyO0L3gUn+UOv/l7decVRabxp65FHZvLe/uVVvwt4X/EBAy8 B4SiHpGg2J+564XRMtZVflCXKq/FYlN1Yvsbi86udHNd7ZQ6lTYxzEX9B41MG5HL12fL Bs0kum6nu2OEYHvjZ3wC8OrFcC0DCfGlfbOB/IbHWzsjkHyArXaT3hQGDIClKfL9JJfy U2ExOzlBltSNeUfcy7IPJzmn6hi7JLsDuN0LdPsNBtxrgkw0ruiFrPx4mKoVdPSRe8XD CIrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353532; x=1783958332; 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; bh=IxRXEnbnwcKwLoBQXvU2u8JCcaQ998O7uU3S4PznH3Q=; b=LR4ph/7195WOJfg/c5bGDWrg1FD0U/VkittpKrhARa0M6QC1KEdDOT4ioBew+dg6MG h4lKztJu8hPzYrCamvYxiC3tIJNs0fBgm909spl4pz/aX/XdTOORmyXusHiLQqVurF+A WqrWcI/3IUd2EJgHRztM/yB7ifmC9VT07gXDgadplCGpMJfRDPIUasqAt2ATzFtcE5zy Per+V1/xkvnYeWRQp/5xHBmmme9Ip7oajCzbBgt+LNbpUo4+/xXvchyNDoCy4liLo0RM dqW8qcJ17K6HQpOkctAl0SxDrGULbkvK3pNsrWELuDeHlwZLt0x+yhaW1ViSuCTwvVL3 /Lsw== X-Gm-Message-State: AOJu0Yyj+b3xxGqAZNUmk/3p6u/kIjpG6YsIbthYrDxPL7fxhoXKWEBq bdBoF/FE9s/Grm2rn36ZH2veHlmGad601K4pD3O+YOlnW6qc1DxYqRR3AnBM2A== X-Gm-Gg: AfdE7ckZAK8R1BCDds72LcuB5GIwW7XZX7ZxX1MTJVHRm5SKrIFUwY75TYresYfRRA4 ezZf08dGi7N+/WnVN0cO3LcjvBg8f3SUU74DA2JnHhwrCR3IO9NtQl51lhcw8PjKpwwd+Wsfpxq rJuGrzx+CFkEvZV6X9mxqdk8s3A24BL4Hp8Ub6/id0IHsvVTHV3NPn9d/YrpoAyLVAhwZLnc4kV ULAgpDm3yzlUZSYaGjj4/4cJQ+fvTfn7bo7HbDEVasc8w8j5oUL3BAWYg4oxn3ZW6Iu2iprKei6 E3uAwuRxZdtb2zkBPI73iAW25LORrYd5kjp1X8Owe1HlaTVKzsROkfoPmWThutHH+0w2VqrZhIa Ds6X9k/VcVtMaxDfJT8pGh0VJiALSyUYcOCzbjzyHg88HypPSc39jcPGsEsf8y6a7eIMePSBZWG Y6oWQaY2Yb9qebmI2EiIRFytbqTQpDkSG4GRfxB0bpOmOlr3nj55+dzzm/4w== X-Received: by 2002:a7b:cc81:0:b0:493:cc01:807b with SMTP id 5b1f17b1804b1-493df0a0861mr10510525e9.38.1783353532508; Mon, 06 Jul 2026 08:58:52 -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 v5 26/26] xen/riscv: do a 4th linking pass if necessary Date: Mon, 6 Jul 2026 17:58:07 +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-d25034/1783353533-93934D51-2DB467E5/10/73395122804 X-purgate-type: spam X-purgate-size: 5835 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353572968158500 Content-Type: text/plain; charset="utf-8" Embedding the symbol table can shift sections and flip relaxation decisions, changing code size and thus the set of emitted symbols (e.g. gap end markers). Re-link with a regenerated table when its size differs from the previous pass. This mirrors commit 35de7285d508 ("Arm: do a 4th linking pass if necessary"), which riscv didn't receive when the underlying pass-2-vs-pass-3 check was extended to it in commit aa786d6e3467 ("non-x86/symbols: check table sizes don't change between linking passes 2 and 3"). Signed-off-by: Oleksii Kurochko --- I faced this issue again in downstream: https://gitlab.com/xen-project/people/olkur/xen/-/jobs/15171254706 It was found that the difference between .xen-syms.0 and .xen-syms.1 is in alignment(?) gap between turn_on_mmu() and the end of simple_strtoull. Specifically 0xffffffffc00c05b0 is present in pass 1 but not present in pass 2 (where end of simple_strtoull() is just equal to ffffffffc00c05c0) because code was shifted: ``` .xen-syms.0: file format elf64-littleriscv ... ffffffffc00c0534: f2e794e3 bne a5,a4,ffffffffc00c0= 45c ffffffffc00c0538: 00280813 addi a6,a6,2 ffffffffc00c053c: f21ff06f j ffffffffc00c045c ffffffffc00c0540: 00068813 mv a6,a3 ffffffffc00c0544: 00800613 li a2,8 ffffffffc00c0548: f15ff06f j ffffffffc00c045c ffffffffc00c054c: 00277713 andi a4,a4,2 ffffffffc00c0550: 04070463 beqz a4,ffffffffc00c0598= ffffffffc00c0554: fe06869b addiw a3,a3,-32 ffffffffc00c0558: 0ff6f693 zext.b a3,a3 ffffffffc00c055c: fc96879b addiw a5,a3,-55 ffffffffc00c0560: 04c7f263 bgeu a5,a2,ffffffffc00c0= 5a4 ffffffffc00c0564: 02a60533 mul a0,a2,a0 ffffffffc00c0568: 00f50533 add a0,a0,a5 ffffffffc00c056c: 00180813 addi a6,a6,1 ffffffffc00c0570: 00084683 lbu a3,0(a6) ffffffffc00c0574: 0006879b sext.w a5,a3 ffffffffc00c0578: 00d30733 add a4,t1,a3 ffffffffc00c057c: 00074703 lbu a4,0(a4) ffffffffc00c0580: 04477893 andi a7,a4,68 ffffffffc00c0584: 02088063 beqz a7,ffffffffc00c05a4= ffffffffc00c0588: 00477893 andi a7,a4,4 ffffffffc00c058c: fc0880e3 beqz a7,ffffffffc00c054c= ffffffffc00c0590: fd07879b addiw a5,a5,-48 ffffffffc00c0594: fcdff06f j ffffffffc00c0560 ffffffffc00c0598: fc97879b addiw a5,a5,-55 ffffffffc00c059c: fc5ff06f j ffffffffc00c0560 ffffffffc00c05a0: 00000513 li a0,0 ffffffffc00c05a4: 00058463 beqz a1,ffffffffc00c05ac= ffffffffc00c05a8: 0105b023 sd a6,0(a1) ffffffffc00c05ac: 00008067 ret ... ffffffffc00c05c0 : ffffffffc00c05c0: 12000073 sfence.vma ffffffffc00c05c4: 00800293 li t0,8 ffffffffc00c05c8: 03c29293 slli t0,t0,0x3c ffffffffc00c05cc: 000fc317 auipc t1,0xfc ffffffffc00c05d0: a3430313 addi t1,t1,-1484 # fffff= fffc01bc000 ffffffffc00c05d4: 00c35313 srli t1,t1,0xc ffffffffc00c05d8: 00536333 or t1,t1,t0 ffffffffc00c05dc: 18031073 csrw satp,t1 ffffffffc00c05e0: 00050067 jr a0 ffffffffc00c05e4 <_ident_end>: ffffffffc00c05e4: 0000 .insn 2, 0x0000 ... ``` So the tool (symbols.c) emits an entry at start+size only when a gap follows; the gap closed in pass 2. (look at the code of want_symbol_end() in symbols.c) what leads to difference in one entry in symbols table between passes. --- 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