From nobody Sat Jul 4 20:59:50 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=1782488859; cv=none; d=zohomail.com; s=zohoarc; b=MBKD9rmu8IrElf3vJJhkxtM95LUN16Xi189HNWhwS95gizFKa/AIehgWBu9F4VouQbl5WAApCLqljpA1Fq8Pkbj0ACuIYuaHsfkQbLDm+ANVjealcfRxkalcmug0iM7gi6X9fJUC5HR72Hk8LMfNjYuytIIMb/94jiLY/dBNNsY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488859; 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=E1ntZTjXuPMc3S9pVqmhNEY95hHRXNFcsq1srHmQDd0=; b=ZiHOljuKQQ5M64KcmXdFlUIBg44zGrRAePl3zKWKSAtnaTAORTlNG6gUm4G5ZaKvpQZMA1hnbeeOrvre9YHM/pQ6c4JsEoKyV75DW0Zc3QpnluroKKGGkyne5rylfLSsR1g3bFlKZ8BozVJwltVDYRwffc2tTaWplwbVMMhZy/w= 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 1782488859209713.9151014818822; Fri, 26 Jun 2026 08:47:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346272.1604745 (Exim 4.92) (envelope-from ) id 1wd8lY-0000u4-Cd; Fri, 26 Jun 2026 15:46:52 +0000 Received: by outflank-mailman (output) from mailman id 1346272.1604745; Fri, 26 Jun 2026 15:46:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lY-0000to-8Z; Fri, 26 Jun 2026 15:46:52 +0000 Received: by outflank-mailman (input) for mailman id 1346272; Fri, 26 Jun 2026 15:46:50 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lW-0000f0-I9 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:50 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lV-008hQp-VB for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:49 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ebb-2eae-0a2a0a5409dd-0a2a450a98aa-36 for ; Fri, 26 Jun 2026 17:46:45 +0200 Received: from [209.85.167.50] (helo=mail-lf1-f50.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ee4-e40e-0a2a450a0019-d155a732cd05-3 for ; Fri, 26 Jun 2026 17:46:45 +0200 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5ad583dc41eso936682e87.1 for ; Fri, 26 Jun 2026 08:46:44 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488804; x=1783093604; 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=E1ntZTjXuPMc3S9pVqmhNEY95hHRXNFcsq1srHmQDd0=; b=S0MPT4Jk6uuwFXfsQc2fvbhV9+gfNJS0GFv0cb1VyNtiVBIZSw6gs2sTg9EUrBgh4O N9LIaFkz30GJe1NqSM7kbpcu7sN8PoYzlskYTSIrdQbUeaCvniTAoROZba1ujk7FBG8j 04bzi2+WweoZHQco7dAZ+l/DArcETmcpUjRyXv4F9xgHWsukgOzFNxUbm6M9+2MxIsvM 6ivt5U/QAP44vExlRYi0HbzvZ7sI29J9GC2sCxwAV//lIX0L3hsmD3ivUvV12g8UkS79 oiSAQjnXy2FtZGsneuN6LkOHDgeTGiubd+fAkJRipucVSvVQAN96HdgbSAdBFwlED6tk +5TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488804; x=1783093604; 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=E1ntZTjXuPMc3S9pVqmhNEY95hHRXNFcsq1srHmQDd0=; b=IBjdb/cgPIreqfFF7KFYDYgYTOk5Aqcmed2zRvfULLtf/UR92hP98yf71ebDaJJ1jY FSivloE/y9qDXZqNg8wLlC+chy8SMafdr1/RXOq6ZkUNBCKwzhH28uYvN66ka4RjoZOY aksfQ7ovcq6G4XwuPgzNbSSIYcHUHUBU2DJUXz7G0HtO7GtAuBe0Arcr64qPlDna6M6a fySlTFIqSrV8fHxxA/Vrnje3Zpzn2F5TPgphXVLOf+laPX6GXaocrTl18bb8bevJrDER IR3w51GcAeJ4aTfG12Ql0Jmsa5R+Tvs1q8oSXpSjbB6jedbIk9ZWakaOTxi01H+D59EO g6jg== X-Gm-Message-State: AOJu0Yzcqpb3+7WGm1sUDkF3rc+sGwkizTD7GZLHkfOEVIhtOVotOqYH ZPGC0i3Q9mRcUk3WdBp5659OQi88yC+w6JH2uUAonUp3Giwb9ht13hRLffMeGA== X-Gm-Gg: AfdE7ckaXM7iR9U8GEdH7OR17jm/tN7WziUn86b+BI4GirSG63ly5DevvjRG/En608e AoM4NhTpn/d1aKfmuxjTWtfvj2eSoXPzG36MhiqbZ8lGkMcOt2TAVVkijGeFCUE43S/vxTKfLVP pOuy6IJETYn4C4GPr9bH26stMo5/jdZ/GWgA38xmcZxKthdd0eT4J4cf2oqLkklyGu5F37Z00Kj UvNP2LBVnRZgOjHNUj9l710fvgtMO/+ufKacTLrUUXHT6PhIz3POQrqQNxFVF1qEcH2APCNw5up q3H4C5nkLOzHaWaCPUdf/j00OpG93LrjaW/4kqC+RTT6djvT4pMRJ1/9lAugfRF2bVMnH0Q1QFY Df5eC2rxwGCUHviHXkf7BlsMKwv080HoY8snXzeLUU3pg1MnhcCOLwwc0iiaQ7I0gh/f/Hpj/23 wxrzRwr2Jy0lkaGUybMm8xact3Rw/2aWTKvvkCwjl8frPpaKNFyS0C8vxxBQ== X-Received: by 2002:a05:6512:1515:20b0:5aa:8824:156a with SMTP id 2adb3069b0e04-5aea1f57886mr1584108e87.46.1782488804127; Fri, 26 Jun 2026 08:46:44 -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 v4 01/25] xen/dom0less: turn max_init_domid into a common variable Date: Fri, 26 Jun 2026 17:46:10 +0200 Message-ID: <2c60cbed167fda0f90ce3aa4324ea4c4b076c43d.1782487661.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/1782488805-D7139DDE-CB210E16/10/73395122804 X-purgate-type: spam X-purgate-size: 5746 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488860160158500 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 --- Regarding last paragraph it is also alternative option just make dom0less-build.init.o no-init. --- 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 Sat Jul 4 20:59:50 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=1782488849; cv=none; d=zohomail.com; s=zohoarc; b=NGvzyO2QAugtjmuptpx1CCXS250nSol7ISesa4VMq36LvHV/uMSGssu4BdI9QiTf2C1h/k7KdR/yRE12C3+2rt+6xtQa5IFBY5v5IMP84l0+kCvA0Y/7MKBJMl+AML+06WcxwpoqxoA9Sg0QLL0NkXkrKQVEKB5J+SrRb5jAqBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488849; 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=mvT5LR8MKVSYyunuWtIqsb5iTgSnZW7RCbzYGmmoDZQ=; b=QZR6h4DUpnNhzRD68hE21yC8fbcPz2wlOXoTguxh2kyX9QY0ajY8eZbfLuLHWmc1qSk4i/dRaWECDoAGs8zWUEXsiLoroOPxQEwSNKmGuzRIfqTBA+rE4bED1eKW0Pw0HGQhzrfQ93DWFBFOSMQJLRY10KQIN1Q3HG2WH0VhZdM= 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 1782488848993409.98469844982515; Fri, 26 Jun 2026 08:47:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346269.1604718 (Exim 4.92) (envelope-from ) id 1wd8lU-0000EZ-Kz; Fri, 26 Jun 2026 15:46:48 +0000 Received: by outflank-mailman (output) from mailman id 1346269.1604718; Fri, 26 Jun 2026 15:46:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lU-0000ES-IH; Fri, 26 Jun 2026 15:46:48 +0000 Received: by outflank-mailman (input) for mailman id 1346269; Fri, 26 Jun 2026 15:46:46 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lS-0008Sh-Kw for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:46 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lS-004aNQ-1l for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:46 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9edc-bab6-0a2a0a5309dd-0a2a4501e980-12 for ; Fri, 26 Jun 2026 17:46:46 +0200 Received: from [209.85.208.182] (helo=mail-lj1-f182.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ee5-400f-0a2a45010019-d155d0b6dcda-3 for ; Fri, 26 Jun 2026 17:46:45 +0200 Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-3997a448ecbso12136791fa.0 for ; Fri, 26 Jun 2026 08:46:45 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488805; x=1783093605; 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=mvT5LR8MKVSYyunuWtIqsb5iTgSnZW7RCbzYGmmoDZQ=; b=HsC0S4PLS0FnpYT5EW0BY1QrEnYyxulEBJr68rUDZKTZn8lsjuO0X0bzZYSmHUzym9 nbbKp126LvsASyoW7QuPXoCjCZN21t2t083h2VP8GDT4xg7zO5QmHpR8bvQctli3ABcy ZP5he/UXWVwqB9cTRcO3ZqSfHKnhd+MLCCFBP4e49iZIfpF9IAzrJ5r/tTzV+S/rnfWo M25aZ6llxtQgU8Kjilkmzcp+Puy91jkgxtB0OtMpjq0QNr4M5igkqwv30x6W8BbM3dW7 jGx3DHLmgsLazSQ4GY6iXj4P1mbJxjmQgV8ZZ1KRr0TKjL8eTTzs3q2dCeOsXb4hTGiN fOXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488805; x=1783093605; 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=mvT5LR8MKVSYyunuWtIqsb5iTgSnZW7RCbzYGmmoDZQ=; b=ZBPsacfKQHCwLI/OmAJ32dAUNFlwcip8YYVKxRyiyWdupDg/m/0D5agUgLrpPa91Lt 661KJXsRnr9RvQA1KzOlWUQIF7IjiPsYNgsUxOp3tD6b2WAkdVTKxEDsJjwhe45CSonX vi3eksoNgWYT2zGoZ8BBaBuh1ACgYyuScK76+Yt+1rjoCRE3QwnXd2FDeC81qdY6IIwO Za0d/LKpA2W2tvBpDxXeuVZsMxqp/J/V++YO1+Q7sWiWBR249vcCNDRAwf0DfE7wCkee 7m3rZMiLuUqiGjTE/CWIi6UtrLQqJVL0SZ2nBJ/Apka96jV1N9SlTexbjShXm7IbQbsH 6wrA== X-Gm-Message-State: AOJu0Yzc33FbDh6bHcOw4fcBLcWA92Snpx1XrAfvJBLdaaRl/SwJw8mr TAzIwmV+NXvzUMMQCOZRzs32SqJkBhz0KL48BvgqgAEhkZEv/+DWEpk57znP0w== X-Gm-Gg: AfdE7ckAgV3rxE2F7JA4SKzhcfpdpRd2QjEXzlQfgfz6lhPgZBTf3UI+ea9PDe2ZHQ3 47i5oFT3wbcwse6V2DHUlT3cHizC4/QcXc49uumOV2dvmKzWb7MZJ8bdEPLuT5s2Q7ojPYmdZsF ZVzcaqVm0ifVUEY8GHz0sUqLwCW3z61eh0olY/8tmylPLsxhS5gJDeknbssxrklyh0tHw0bkKMu UXPnVuKgwUz5K8lRhFIhRjCUeaCN8GbnlbZDk6XtwUanEIWsZm99QsYUs7rq8hPIvhEgC1bjNLZ zin+JE3FbAIXIj1PR2qejYgUmuU3fMyJiVqCYlFqbHcb610edPSmcH6U85s0bRNLPoSlaYi2cSr TdcQkqQVQUwFzmOWgiLIP1Aim5z+Jbsx6z8elsADYQHmSZvYarMY5F07qJX8Pq/z2kW3N7TyIDL 6xQ6dY4KQLqk3uEr6doqtwCEIw4QFMo/hk2RK7rAw1mDUYd2pkttoxtP/X3GQpmEabDv99 X-Received: by 2002:ac2:4f15:0:b0:5ae:a9ec:9fc1 with SMTP id 2adb3069b0e04-5aea9eca36cmr128297e87.60.1782488805066; Fri, 26 Jun 2026 08:46:45 -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 v4 02/25] xen: arm: move declaration of map_device_irqs_to_domain() to common header Date: Fri, 26 Jun 2026 17:46:11 +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/1782488806-D1EC21E0-6A192B89/10/73395122804 X-purgate-type: spam X-purgate-size: 3643 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488850284158500 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 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 Sat Jul 4 20:59:50 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=1782488847; cv=none; d=zohomail.com; s=zohoarc; b=nHrwbz8fOvjWRxhOATz0mCozgCP6fV8Yl1B6I7xZ8co8fqCF9kmeTiW/aW7k0pHzyuDHZwLBBmC5Am8G/9QTLrpcaHaCWuEjpySWUdiD7DnH6Giqxbu//uXLgxyANHJyMMMwipC1MdNfLy28Fqhv94roQkYOjmayxhgHmkM0a6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488847; 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=4TtdpsKQe2Ojlx7r4TwViI4rHIRjvzW7vDmBaVjvSro=; b=n2b3fZ7ZKswbcG+VHyrImko6cXOjvxeDbYEHBS6zo6NSvJEAueIq0XpTZ/ixYdOLnc57p5XglSGOA9npKK1Fy3ZgAowXBssJbhCS98HNJXnK4nc7TDgn3MixD3BFUZxbT74vmBdL5EaiCMqUexo2HwxQFD3zmzF+QTW2qnR1I0A= 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 1782488847934680.6115767898984; Fri, 26 Jun 2026 08:47:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346270.1604722 (Exim 4.92) (envelope-from ) id 1wd8lU-0000HV-S7; Fri, 26 Jun 2026 15:46:48 +0000 Received: by outflank-mailman (output) from mailman id 1346270.1604722; Fri, 26 Jun 2026 15:46:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lU-0000Gl-OT; Fri, 26 Jun 2026 15:46:48 +0000 Received: by outflank-mailman (input) for mailman id 1346270; Fri, 26 Jun 2026 15:46:48 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lU-0000EB-2N for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lT-004aNQ-FP for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:47 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9edc-bab6-0a2a0a5309dd-0a2a4501e980-18 for ; Fri, 26 Jun 2026 17:46:47 +0200 Received: from [209.85.167.48] (helo=mail-lf1-f48.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ee7-400f-0a2a45010019-d155a730a4e8-3 for ; Fri, 26 Jun 2026 17:46:47 +0200 Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5aea1f4dc7fso1077104e87.0 for ; Fri, 26 Jun 2026 08:46:47 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488807; x=1783093607; 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=4TtdpsKQe2Ojlx7r4TwViI4rHIRjvzW7vDmBaVjvSro=; b=XRP+jsKKJG4haAX2XYx/jWM6JWcKGpAyNq3R6TiQZneGqTuXvpwHrFb/Tunz7XsK0s feDjWJQSxHQT3ZPZI2l/y63+qZ4NA+Vp2xDQe5OY+5LMelUCLn6gAXLYa5k+Mu8ChBUe HTJJdRPcfvA2VEVi+y7HKWjHMpo6KLm/lBao8Ni/aXNU4dO/NWI10U9BZQbsMzQRcXHf UBGDU2T7Zr1dB93ZhUlO+uNDEnm6OqBNzzC6zSI2/m+Ei45Uh8YrkkyUVm/ZyDbJy/PE ngSp0qxoygjgF+/nsuy5S6ZAbR+GYrQ9cfdbp8pR5DCoUR9VfGjQ45eQpuf46hQmlxSm r9nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488807; x=1783093607; 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=4TtdpsKQe2Ojlx7r4TwViI4rHIRjvzW7vDmBaVjvSro=; b=hQ2N7PT3kIOlo5sDRdXfptz4SMU+k8wCN72V7Hpiwz8/G7RHs6598lr6zNRdKpJLHS x1KDLXRFPlhN6VOPL+lrctoGyVxI5RYvYBsB1iZeuSLpUV3gxjZ2OiTWv1sbkt9piTOA zZ/utLcaNaXbPw3ZHEpgz+wAxok0CXm1sS8P0clPmmIKKKd+6acqZSYH8OkM4c/V5EtP YM51lLH9fCzHuR2ipeDwLWvpELCLB+ICrpdSZxoJSOrkfZDeyft2j9kQdTXv0G/2ZNeK EK5D5dB8obDiG25nnsD+EsjyRfVNGvote3/Hrt2IgSYBuhpDHznJFHNqRsL54Gh5aXZu NWjA== X-Gm-Message-State: AOJu0Yxsj48WakdC4n0NEd8TdF2cOIewSayYlslDUaxxoPFH3foF5xhk CjKGXOq47Mfwxee9ltRmXsTetLc8OqGbadbwkfDLAxVxD5XuAZ6iKfMlmI3PuQ== X-Gm-Gg: AfdE7cnh6myxl5UYnPS6zH97Ex9zh/Bi9NwTmFHYXOSyIQ6NXS+8Z8w7VlmISsRuPhp pVJ10bBNS5nBdt8xQnFZAWD6H0kGLCutMPQ1SGDyhuSlYgoA8qa5P5AdoV6SgbupxqcohvlIcy7 WzZOkNyf6NS6QAS5PTWRBXkngN22RTeSOmLbKrFVRvILlO5CCxouVkBV8zaw381/YDCBPbgUi2w xNiHDkxlCmu3x17E/uVC8PvqfovZgiIGf+CzSOrBzeeC7C3tUgbFUPFn7lNmmceaywVKWDY99F9 sFKONHchTlh5XVc3RR2KRRM5+5qhCYjpBWKdBEpFo+lNznfGw6FAQxTzoh8Yx+nJ5LrzJGKPFM2 eU8N8XsyGYZLXFFSQw0V/DyC7iw4SG2KRHCafSag/qJ1zXD7LAfW9cndImhiSyOyrcU4+ZlqTPX 5oowWf+7nLpRxkDwhzrrpYbx4BJpLU+Fb8eh4XyEfYfYM/lUar9YMN/m+5Vw== X-Received: by 2002:a05:6512:2c96:b0:5ae:a9ed:35a6 with SMTP id 2adb3069b0e04-5aea9ed3758mr104764e87.31.1782488806557; Fri, 26 Jun 2026 08:46:46 -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 v4 03/25] xen: arm: update p2m_set_allocation() prototype Date: Fri, 26 Jun 2026 17:46:12 +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-d62444/1782488807-81AD91E0-1DC5DD87/10/73395122804 X-purgate-type: spam X-purgate-size: 8763 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488850341158500 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 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 Sat Jul 4 20:59:50 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=1782488855; cv=none; d=zohomail.com; s=zohoarc; b=GgMn+36rs3zv4O3E4VZz0OhBjtgKHSJr4pPkcAING1l5lWVAgKxju/d+PQdJgHPuzBTHRHnotXMoImTIVZI7rQomYF3EKVkgwT9RHnMisxMJnmcLPstjdlh9Ic1HDsRSpWRh7PeIAAu8oisP7fVcptPdWCN9Yz75pNTAxlJs5Do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488855; 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=N/JdhyxbZhpV2hEcQ308jQnWzAFQCSs6VvGpVq3IvD0=; b=jP//KEDrByoesmJNJT3cYE7zoyVuQpbk/5SFcM7ejITT47VJzarucZUI7CDucYr3l5gsAtNaiK1k2KCFPIFoHi+0Zl97/s1R2u3poYeLCsU1skXgoNbbteuDsaChJFhE/qLsXM9FHQrjcL/B5OszQeqQmC+QsdCQWulMYSGUD8E= 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 1782488855112776.7008116886772; Fri, 26 Jun 2026 08:47:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346271.1604736 (Exim 4.92) (envelope-from ) id 1wd8lX-0000g2-5z; Fri, 26 Jun 2026 15:46:51 +0000 Received: by outflank-mailman (output) from mailman id 1346271.1604736; Fri, 26 Jun 2026 15:46: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 1wd8lX-0000ft-2e; Fri, 26 Jun 2026 15:46:51 +0000 Received: by outflank-mailman (input) for mailman id 1346271; Fri, 26 Jun 2026 15:46:49 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lV-0000Ux-H6 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:49 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lU-00Ad3u-Qv for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:48 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ebb-e002-0a2a0a5209dd-0a2a4508984a-42 for ; Fri, 26 Jun 2026 17:46:48 +0200 Received: from [209.85.208.175] (helo=mail-lj1-f175.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ee8-edec-0a2a45080019-d155d0afb018-3 for ; Fri, 26 Jun 2026 17:46:48 +0200 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-39979f72d0cso6178671fa.2 for ; Fri, 26 Jun 2026 08:46:48 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488808; x=1783093608; 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=N/JdhyxbZhpV2hEcQ308jQnWzAFQCSs6VvGpVq3IvD0=; b=h5DM2rO0ENQXZg12l0R9PLcLh8Pc0QuOOSdX61FQ8GvHPikgJK/rDNkgQ3q0tVCXK2 1FR3ITl6CwSOrSCpMHL23RdGIwDBjyXrFnFYeJzeby3tSwLTyoXPnJonv9dkB4qxH76s i4c0yJhOjJIp/B7/eikbpkWHuh2QNozaQdRSXDfIBPnygCU79HKDEz5ecIMIkURIhez2 YiXMkja+MBixiH7uJZPmN5cNegr/+raTOkM6KhXXFdE4Yo5b+3h6gK1ATixNYhpmSNlp JUcuvAAk6BWeEJSUi654YD1Cufvmi7+zmzawvrwbQ0LW6XQs0oVqTHimy51bG6qKD6ne 6Y+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488808; x=1783093608; 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=N/JdhyxbZhpV2hEcQ308jQnWzAFQCSs6VvGpVq3IvD0=; b=GGjM672dFYoFJmxF7W77VTHZVSUjgD13JrtoIr6drHw+xBvi85pawLKTGT740WlV1g 6hxBh86LuUcgTgtXJwa/LbU9g/8aGVMpox0h2m3x5IyXvKvBjRyaf+bgd3f7BFMOKwUF k/ydUKL4ZglEr2jlKda6rhBsiSzWVnSwa3357VPSMhsDE7Wr+6bqG8RNqSfV4EsKXv1n IWWRSn5yxlb+6SINEV/DnLBetXOVzKSuvOp9iQT0Fc0yvMADCMYXQ0DYyulhSem+6Wv+ Q14EXK50tnyWr+zZ/3gVBe5o1JqnOVtpz3VY/W0Cozh4mGAGuNgZ5EvGplA95CsTMcMP O7Fw== X-Gm-Message-State: AOJu0YxiDcM5V8VC9Vj491XLSHCbugz3TegvouYzAAq1A95ZYXRkwWS6 CLV3caej4//FHEvxXhzkjrSlxpkiHKexJZH1mFjQi7ooCr0clKF9qUdLe4ivng== X-Gm-Gg: AfdE7cncKnWbAUMmBnB65EVKbyUsFAWMSvEzDk83H9wt2YA813zWJK5bMeiXTUX0qso au7k4tbzDnQaQGDPNtoowZZnvk9+RGQ0LJghTi8tiweYlgvGarokTNfVzrUlLuK1/A4sI61xbhw 7iY+EFfFNv9b6sPYOUDlY4Ymu5p5lG4rVQj1gdaLtZwSZ3nMLyfUfe6lyq3oXlwbrVJUjYrgDev sLFhYL9k0yEp2FKGSQYHeNULblv2+3etWXug9BWZAmMmo5NrOHIUNlPE3MlaoWAEINGzBOjI336 SBr3pgndK/0s8rWHAOCblMqef18fIMIgDowYEt6TWekBPxe9Rp4/2O0WGkfDFZfcDGYv5IH4fkB QpAaKfCpsbC79aHx7vTtN3jWl1otiXUimXhIv4FZi9eGrSEKCdHKdlGf65bh1CoZ86/j1dRB8E+ Fw3IC7XN33CjUUzJprxL3Pr0RqF4AcKZ3ANRN3JpiKGcRJ4ris6/A/gFVoAq7+FyYW9hvx X-Received: by 2002:a05:6512:2285:b0:5aa:6d11:187c with SMTP id 2adb3069b0e04-5aea9450128mr305171e87.8.1782488808000; Fri, 26 Jun 2026 08:46:48 -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 v4 04/25] xen/Kconfig: introduce HAS_STATIC_MEMORY Date: Fri, 26 Jun 2026 17:46:13 +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-c1860d/1782488808-A0D2B3FC-71C9598F/10/73395122804 X-purgate-type: spam X-purgate-size: 1815 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488856292158500 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 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 Sat Jul 4 20:59:50 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=1782488858; cv=none; d=zohomail.com; s=zohoarc; b=VlxLMrKfafrzjcPJsAFJmvqnht+3pLF9bQtpp+Mc3AjIokLOU80ZkbzitsYlZ4/bJqdugtb6RhhBG6DhXfCRCs8WRl0SQFvLeb1KmL6nljIbxIvjXp8mVf8aOf0EyerDTUaiief/cSS+GBq0AzKC8gZGC91seXDbPMrexJCXBBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488858; 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=vafZ9uu7Ib7QiNOrz7YTpkLsKCJIlHqsiKN2O4f/BLQ=; b=nHUP4p5EeKWYo61Z/owPKWETTOl3A2JjIo2YkawPjgRfU8N1idgqtFzw47MN2WOx+UOG92RXYsaWEkHG6z745nDzIgciIz6z6HxoMElq2xhr9GYnY+HAwpv68lbWBB4INR8bSPqgIbFp25LM/RZ2SMiIDZymRQbd+YrkoQ7WJss= 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 1782488858639912.5547819917695; Fri, 26 Jun 2026 08:47:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346283.1604814 (Exim 4.92) (envelope-from ) id 1wd8lh-0002tL-Im; Fri, 26 Jun 2026 15:47:01 +0000 Received: by outflank-mailman (output) from mailman id 1346283.1604814; Fri, 26 Jun 2026 15:47: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 1wd8lh-0002st-9M; Fri, 26 Jun 2026 15:47:01 +0000 Received: by outflank-mailman (input) for mailman id 1346283; Fri, 26 Jun 2026 15:46:59 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lf-0002OG-CH for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:59 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8le-004aSr-Ol for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:58 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ef2-bab6-0a2a0a5309dd-0a2a450adae0-4 for ; Fri, 26 Jun 2026 17:46:58 +0200 Received: from [209.85.208.178] (helo=mail-lj1-f178.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ee9-e40e-0a2a450a0019-d155d0b2c5b3-3 for ; Fri, 26 Jun 2026 17:46:50 +0200 Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-399f5e574b0so11917671fa.1 for ; Fri, 26 Jun 2026 08:46:50 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488809; x=1783093609; 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=vafZ9uu7Ib7QiNOrz7YTpkLsKCJIlHqsiKN2O4f/BLQ=; b=calD2OC8OdHT11rJ9Cx/qNGPR/AGUhNU+AHcsgtvuRpuBKlO/F4FKWq0yOXgcSoTeb v9/lDantYYVeyEFPnuzJtY8KfCC+Otr/GT4fRhHXqpzCoFYhlDTIbdeg5uvatowevYpm Ay1SewrW7qmy9hvhTSisEZVo/P9uOissTv1dVzjtE5KuvY/wpT+P4fzKxvmYUkXeRlDq gD8A+MjK0RfzOAaNOEyBrjC5mJPQ++/B43QyR6DHlNWUtnSnygturbaZA2Ab8Crq/Kme 6zsHPfU0acpxjPqT63TH4jsZshUH4kSXpWczd3XNB487sjFKtGE6bvUsPGYosHSrmzfq I/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488809; x=1783093609; 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=vafZ9uu7Ib7QiNOrz7YTpkLsKCJIlHqsiKN2O4f/BLQ=; b=VRpUSGesWhIwCaeUd5SVHRnE6r//glppk28wPGl7853iIv0kqaRX6JihEOJHW8lGOf Jm1kDzuZt2b7TNlJ80UWF2SrKL9np+riX7gVkyuXW4gvwJNQnsDTZe4/JfesH46OmIG/ 9tLEOwOPHj89JlJaFhyOAgON2LWnI1jcwh6bYDrsRZYuGtUUmBBoVacXhuXOKmoDeX99 7szvfCnVRnbVWObTXUq2Xhl5z2+M0qr+Xpzfm8nwpwVFW0TRd1eF0i5xrNcOlArG121u ybJ4Hm9qrGg7dVBvdQd3GQPh946+ncVSSkpRM8YR/XJ7cFkSOtWsncLORDTfnvU3Tv5k P7Ug== X-Gm-Message-State: AOJu0YwRw7LAX88Sqxw83mwOCPI+8whc2bRTnS9JTNEhEdT+6PwfZew5 VBLBsbLUzt2Psz5M5BNruo23j6zX++W//E/S3TULUoowsMsYzZbgnxnPOC6aLg== X-Gm-Gg: AfdE7ckVYjiNtw9D5na8zPUM6I6l1ZAj5sV94j4dbAyJbj1mxdEkHNaLDBNmTqCsI43 11LzPu221lOjaTjywzaVDGwI7xYn1ri+TDX4HM0YRdzR6drl5z7j0NsFUXl+fnco1I1g0hSTdx0 /kO8wDSSqPDlg45sBCU85gr1yrDX751m3IPdkFzpQbZSSFBcvuZKYpqpIcHWvDtkdjlDHCKiP8d fpfSnt5pa2KGkvmFuRld+UgCmZgKMmKuAxvGy98FH+k+RXY3ep/4iRNuQsOI8hvRpeau7G5MqmP goqdSxrqf6WdvkYW0d+K8LE4YQgqEMOsWfMpFmh6ynpiKPtDySI3/ZTFH4Dp5N1HwTJ/OEYN6ZA vkMNEk2dj6olZ28UmCV6udN5ErBvOgvqNVCWNIF7H9wX94AdCG+T6Z2j9zyH1zowKg5vjnKdS7j O85DZlrCBi1L2oOaUeviglsloDyOZmpDJOnq4CIVi/oYmo15P/6yf3eJeqgxEpvn+BXWt7 X-Received: by 2002:a05:6512:1410:b0:5ad:5620:ba65 with SMTP id 2adb3069b0e04-5aea2066328mr2280843e87.50.1782488809430; Fri, 26 Jun 2026 08:46: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 v4 05/25] xen/riscv: Implement ARCH_PAGING_MEMPOOL Date: Fri, 26 Jun 2026 17:46:14 +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/1782488810-3D470DDE-BAD961D0/10/73395122804 X-purgate-type: spam X-purgate-size: 2630 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488860130158500 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: - 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 Sat Jul 4 20:59:50 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=1782488844; cv=none; d=zohomail.com; s=zohoarc; b=JUTQ8y5vBRK3DqqlQ9a29HIeK8rDYIFiglT2wJCS3HEMXnp3nwdtGzSH/D5uxw4Kdj5RitNUidloX+8bjRmlsYdHa++dP7OOf24G7o8h7YiZ1jMB+1TYAI2dHW9KLCCAPMkjrCbWeWcamp2zEt4kx1I2X5lcllEwBYTrEosDJgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488844; 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=j9voWSp+JkoD/VpXapknL1AYvuXz0NiQDfxoMWyQ7FY=; b=nI6YebdAIOUB2pjDgXck5UoP4CbGpbDtNoYiSgXNWw7p5kH9zenvEShQkN9httsXJyt14ezln3fTkVzdYhaAqz7HUhrp0DMH0YCKEg1eQOZsf6X3TysrNHlqpLu/8krwkVWTYbxA2fEShNvsSwIiYEhDvSm1ucuNePNBf3ol0CU= 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 1782488844517827.8118136184245; Fri, 26 Jun 2026 08:47:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346273.1604754 (Exim 4.92) (envelope-from ) id 1wd8lZ-000189-Kj; Fri, 26 Jun 2026 15:46:53 +0000 Received: by outflank-mailman (output) from mailman id 1346273.1604754; Fri, 26 Jun 2026 15:46: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 1wd8lZ-000180-GQ; Fri, 26 Jun 2026 15:46:53 +0000 Received: by outflank-mailman (input) for mailman id 1346273; Fri, 26 Jun 2026 15:46:52 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lY-0000sw-8S for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:52 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lX-00D1eP-LW for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:51 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed4-5cb7-0a2a0a5109dd-0a2a4505c00c-30 for ; Fri, 26 Jun 2026 17:46:51 +0200 Received: from [209.85.167.47] (helo=mail-lf1-f47.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9eeb-3cb2-0a2a45050019-d155a72ff08e-3 for ; Fri, 26 Jun 2026 17:46:51 +0200 Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5ad536cd0c6so1012847e87.2 for ; Fri, 26 Jun 2026 08:46:51 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488811; x=1783093611; 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=j9voWSp+JkoD/VpXapknL1AYvuXz0NiQDfxoMWyQ7FY=; b=m17amcVQ5X7z1jvCpNm4XhrfKc1B9HiTXS6AWzEj//0+0ww2dZjSX/jJlZfuAcTQeh sirC6wUkWP8rSKwsRqzLI7K9gfHVjvC89Q2Q6JrClLKJfxmwUhdWY/2/YjVA0FmUJNX7 O8qADnqqOC4eykwalIgRaj0udk9t1RTL4BF9yP6RPROIhgTiJtSWTmSQtNSJVba4aJ6K OYEQD7iQ4rIV9/RMOyGmsEn7UHalFHDQcW1y9d0kZKDARgozG3m9GM9R1MJ4voDIXPys d6epQ5MZ/l0qUKFq9NFLIGFD6lkv5OIde2aluRh9XzXZjacqrJ69HK/MhJnnghsTTr6d c/ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488811; x=1783093611; 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=j9voWSp+JkoD/VpXapknL1AYvuXz0NiQDfxoMWyQ7FY=; b=HXkbRr/OQaBPEAWWdsYaSorAYbu2uI0YI7Zn8CwvMnZ2QQVS4d/Z4123iiFnA7IwWq lm7nlRCDmZRAvd/TMf38dWgMKq5ON7o2bqP2PbnWureE22A0bZ2x1Mya/0u7EnjzlQV1 dRQfJBGlFqlPLu8CtTZu8sU4ADtfaJkrHj+absgxABc/9PqaEqw3LKh2+9BVjhwkgMmC qwsFqMUi8EdHJe+WKsjJvlWjIgsBNKZg4UZsCWhxdBCs0oJ9TkkK12bScA8iyl/qJkpc XEeV9lSKuJISRB8k8e4O2D7gy2QrI7Jt6tOz75uXYCViK1J38eWmOPlSgBe0/AI5nm2s 9OUA== X-Gm-Message-State: AOJu0YwJ6zL3Lx8HTKoffsIz1HnGwHt7eaqYnc0VqaSRH9GVcgoL3F7s WLykVWtFtOzS/oCBvDTOhAuwUIbleDchjxyBZ60t0paua3kCds4ybcxxgajAGA== X-Gm-Gg: AfdE7ckOhf0iB4BwLdFEYwSSh4IZzpHW+7rdOcaEDfG2jvG2SDNIsBI+mGdVe5oNe2u XOxK+lSQirxWU6Ee8qvDznZfNYGScZHmH26hfpos+7uLyi5TYtNjNq+0vzp6v2yWyq2/oArf1um mwIhjEkz8FS1JwnvpsANBpflrRZMJVfTyzq1y1iN0QWMbW1O/d6dsWGKfDilOEvm+Stm5hxCPNk 1YW1+8hSdopVFLjGDHtLrHscxQg6pRkpxEf8NHmFYndz7XkBY8/ZGR5nc2x8JvTC7DPJEGj7Gkl J2PFEcmttv+5uboT6fVqoqDrShxzEvI+WX5PiHJfanotAHyygRxLF47BcSBTn2anCh8K2Wa0j5+ 9G5dQrDbQOAwjPW+5fCfyG8pgUbpJY7r9lIvz4M3nIsd2d4GQzcJ1p9cvicwKs7WmLWuxzOz9Qt 8HY9NILHsCfYle9yLe8qw5Qyo5iygOhtxWGSfL2u1lUGAD6Tr3u18hyVq/tQ== X-Received: by 2002:a05:6512:12c5:b0:5ad:4d1c:9361 with SMTP id 2adb3069b0e04-5aea1f6596bmr2385426e87.50.1782488810731; Fri, 26 Jun 2026 08:46:50 -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 v4 06/25] xen/riscv: Implement construct_domain() Date: Fri, 26 Jun 2026 17:46:15 +0200 Message-ID: <91001b3be672a35077be8acb86d7151fcd6e9f67.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1782488811-159082B8-D735517D/10/73395122804 X-purgate-type: spam X-purgate-size: 3059 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488846265158500 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 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 Sat Jul 4 20:59:50 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=1782488855; cv=none; d=zohomail.com; s=zohoarc; b=QM0cYCXTV0ADJtpnstTd9YdgN5XbE3eVO9WJJnBUet20nZdsXLJ/rExjOk8izaJXETHK8Hj+h6iQVM9NHxcW7lXAgjSUPyoHDfudGSVs+z5VJfwvmURdV0gKOO9uotbRP4HfvPzC9XUi103S7Mb3TCbmdba9s7/RD8h3lZiBlAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488855; 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=1J8DhFfVno1XP9itvPHGglKJyQAoP1V4ZHqNNB/X7RA=; b=Gz6CdHQm+YN+PeUdGF1p5MROytPPJNOgdmXThVc75d7l/rI1m718oYd6xlZ7SlGxwddZmZS+aCJuKgN/azpJ+xanHGZzJaCJbWkSCqpxoh8W2XiFS+6ZnGBevhoGjtWJUJm4Igl3+IJHFt/2vQLOvhtW8V6jis7e7ZJxddPPpCM= 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 178248885558073.20627198630086; Fri, 26 Jun 2026 08:47:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346274.1604763 (Exim 4.92) (envelope-from ) id 1wd8la-0001NX-Sx; Fri, 26 Jun 2026 15:46:54 +0000 Received: by outflank-mailman (output) from mailman id 1346274.1604763; Fri, 26 Jun 2026 15:46: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 1wd8la-0001NM-PH; Fri, 26 Jun 2026 15:46:54 +0000 Received: by outflank-mailman (input) for mailman id 1346274; Fri, 26 Jun 2026 15:46:53 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lZ-00012B-2b for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lY-008hQp-Fj for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:52 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ee5-2eae-0a2a0a5409dd-0a2a450ba306-14 for ; Fri, 26 Jun 2026 17:46:52 +0200 Received: from [209.85.208.169] (helo=mail-lj1-f169.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9eec-ac48-0a2a450b0019-d155d0a9b49f-3 for ; Fri, 26 Jun 2026 17:46:52 +0200 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-396771119c4so10048591fa.0 for ; Fri, 26 Jun 2026 08:46:52 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:51 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782488812; x=1783093612; 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=1J8DhFfVno1XP9itvPHGglKJyQAoP1V4ZHqNNB/X7RA=; b=IM3KPjIDxTSIgxlLDu+SU4AB+jzFx2YN5ImKALJl/Lp44iA+7NAbA0y6Wt5P70GnuW 5R9d02NBpamESvuwCIK2UsEdNgFfiNLwD/I1/HlqZG+SMiFkMB+h5HwFYCPM2bvYksJz AdaCOxaMR6Av662r1f1eqXbbJ4xVp4yWaH2VoPC57zc5jrMGo79t0Yn1rNSTZ8MAnG3I lMV0fiFIGVJQQ/6bjxqehl2s3JseXrOeKmnNYjO5UX6VMbB1KJRUvn//Y1g09fOHT7E/ Iaw1xVDRNxu2aVyDv0YV2ltm38/NI9c6zXP2uks/JHvSbkyYUkuwQTokbVYLB1m14jsy +2qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488812; x=1783093612; 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=1J8DhFfVno1XP9itvPHGglKJyQAoP1V4ZHqNNB/X7RA=; b=NXUamx/6e6lIDrMCWH05P+nfq9kLdYmupCm95OamnWl1yX77Abd3izhB3Gt0n7ODBm 5mE1ikfQdbu8DRZHiCbPm8haaN0bH2oCQiHUH6AmKzxSICecVJ6hrCAaozrV8kQCUuYn bFn0keHxQ8NtosD8fbMKlJHGXHNNc+UkyIMYSqkdC7cBpSqKoohON1ltj4kVOJGQQ63V 4zR2cU0b/3mnfsOPr7c9YjClvxj+HCvagRUXa2VQWfDBBU5anrXAH4Hy8JAr4r+tqZ9b LbNhZJCMbz0DrV+lTvCvhYs9VBIihg8XJbujofMHQfW5gpewkr5jeBD34CRF5vIHtcOy uwfA== X-Gm-Message-State: AOJu0Yw3HhV0bpQLNHSWvpNlWmXaAYmprQIsgw2mol9IvBpB9AhpyUT9 7xdqItaxCYdsJU5S19i44+jzkmAgqdIE5vRK/CBkokW91nTqqsjgjk30/qeNlg== X-Gm-Gg: AfdE7cn0KhlfOd6hJA0aU9A8et8f5Mcb+V3WRFDCSu9RXZ7vDGeji1si95Mux77qB+2 gleizDIn33ZZrQxLCkYWqfnHjClSeKbR0UlClDXEAC7MbpWlciEpuhUsQ2uFUutQZtTYumkUxO5 cTH1aebzY6RzFnNNfef5bc4shF/5MXRb330lrJKIZTLd/SzJnOPzuLEKNWyBYb/juuh/ZJKAuc5 c5uxSg6tQmeNRax/FA2cR5juBTSP3uW/HJ1DYt0efbuIe7aeF9QG1q+UKjtqDl5A/CST+Z1j+Gn uPJ6n8CbbKtQ4TKVrphhZxFb8EO8Mwf0OhPJb+q+Mx0K9p7QZ4NyvunLCLtgpuC3W+6/08jsvKO aC755Ai7XbiDODnPCkybAYj3fj+IaCA/ufejZJCMOD9W85qI9Syl2DXKDE9KiMzXl+V+kSZKOpS zlO6dCkkLk9ETF5OMDRagKuazz7uWwjeQ4B6HvctQkzGCnXHhglxXYVBFbOw== X-Received: by 2002:a05:6512:484b:b0:5ae:a9ed:2499 with SMTP id 2adb3069b0e04-5aea9ed2520mr97120e87.58.1782488811630; Fri, 26 Jun 2026 08:46: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 v4 07/25] xen/riscv: implement prerequisites for domain_create() Date: Fri, 26 Jun 2026 17:46:16 +0200 Message-ID: <5ddc512315e870100dc6fcc97a8f6d4fbdaaac05.1782487661.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-42698a/1782488812-A5921220-811BBC9F/10/73395122804 X-purgate-type: spam X-purgate-size: 2984 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488856302158500 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 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 Sat Jul 4 20:59:50 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=1782488853; cv=none; d=zohomail.com; s=zohoarc; b=T1eWiT06lzcvwE0HByBfBJn2S9WDUpXmrLKYQdOWgqCzbDc7FoUd6ubDDJGv7fmg/MKe6LhmItCJTrU2uqPCTTIpwwY1hfX0v+A/jf2OfUsARcIJk+Paqb88+AF0LFwsFF26b1KjCtCy6CJh4kKf4WfVPHWYMvdU5ivhmVD4pOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488853; 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=lAgm/yYwskXxJGXI22S3gUIllEquJX3wAHQbVFNRFl0=; b=YCZtGJLn923fkfEccuxz3RRiSVTmGlRV2tdCO5Jrx9Ii+NnhkCq+w5CbQdWBukjGvQOYJOK3bveBqkjtz/0mbQC+B53KW6TGV8mKJtFgRMuLTkbZBCun6++b4124AcO0v2VBHFrwcmuL1EwGdP0GimFX8X1DjyO92+OaojGZPf4= 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 1782488853338320.23702612267687; Fri, 26 Jun 2026 08:47:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346276.1604769 (Exim 4.92) (envelope-from ) id 1wd8lb-0001U3-Do; Fri, 26 Jun 2026 15:46:55 +0000 Received: by outflank-mailman (output) from mailman id 1346276.1604769; Fri, 26 Jun 2026 15:46:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lb-0001RD-6g; Fri, 26 Jun 2026 15:46:55 +0000 Received: by outflank-mailman (input) for mailman id 1346276; Fri, 26 Jun 2026 15:46:54 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8la-0001Eq-5t for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lZ-008hQp-Iu for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:53 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed7-2eae-0a2a0a5409dd-0a2a4509c3ce-18 for ; Fri, 26 Jun 2026 17:46:53 +0200 Received: from [209.85.167.42] (helo=mail-lf1-f42.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9eed-97e6-0a2a45090019-d155a72ab4fb-3 for ; Fri, 26 Jun 2026 17:46:53 +0200 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5aea96d09ddso196152e87.0 for ; Fri, 26 Jun 2026 08:46:53 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46: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=1782488813; x=1783093613; 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=lAgm/yYwskXxJGXI22S3gUIllEquJX3wAHQbVFNRFl0=; b=iJlMpiPFcGmq6JyDYPsln8dabcQ0fnKmxN7nJJXTpo69voqr8THS8eoar5X2Uj/MPX OOJqloTSImmu+TOabuXPoH17NSwMDT0R+43OjqKdG7/wzNEFBLSTwf3fHAa4GR/cKeSb RF5LV+xfCopNBuRr9Z/iqdCbYjM55G/HrfkuIe6ehqrpYudvYtcCNmghVtVt+c18DxE2 UwlRva19KNAcgT0v+F9XVC1DgLJl9y0VEs68OPVmkAsHYXZkQkr9qTzwB/5Vt7wXlt22 3gtZACt90PSX4CoPvyN1tp8rO1tndxQvyiw4frc4GgiHoVq9wmpSUFFQB1go62UMqQnj obEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488813; x=1783093613; 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=lAgm/yYwskXxJGXI22S3gUIllEquJX3wAHQbVFNRFl0=; b=qntZmobKGh7HH+4/tbWvhimmSyKkVlBD8pnt/lxTZjbxwvBfqA1T7beHLqLzV+dPay Vpub42Bt5xGOy0sKuSkE0fcEDtQtFPJrqoi8d14YTm4vnjCS6WcD39//kRTMStlM9ARf k/ZjQ1vKv8+jpjC84ni77w8TCWX+AP1DnpyqSM9ETxn2Aqp9Sodlc74uE3BosY6jCeBA t2XyYLtcNz8FbqZNv6CxE8F7JKl0qCZ8ZRXVl7BQjzVRq0Ymm1R7Qq9Y6GuJhvpoWrAq XONpnFrs6vUUTvQnNnAtsCKuC4QLlLAszlENpUKtVKZzez+ZSNCcNfHy2uoYAZ0AVyrj Xjeg== X-Gm-Message-State: AOJu0Yw+fNO1gRAmYSuC7b96o3KwcKbCpTsmATLm1edesmqdkp/SIMZw fS48CfGbrxpGhZK1nihL2WdhnbYZZfhggpQePWlzEG3GgLJdh9CWqy7u/gXUxQ== X-Gm-Gg: AfdE7cn1H2C2Oh5rvOK7KO9hsw4RMYHYPZjDkWNfftz6ZPr1LzxWn+ENkIfPrhamP0t x1nYMa0k1nBflAF3sX2yzNhU6+21l6j2EpNGbzyKWTZxAHzZWKmXXyupJUCHHAEpaxLJFEl9asD HMhlMcV5yeIBGSnC/y8g8KTAxhDcUomhn1iEdhFugnV3yTqu5J+VykNrdDr8i3O2w+Nc8bvpNIX QgiYJ6d96hknUZneZJABmvXy6U3GYpqZV/RNRIwYxrsmFn6P5Wk7dZVmLETZJafCIqk+b5pA0Xe lzPmC2ops++Dxiq2mCh41nG5KX376Xf6GB8eA89hl/0rgAb9SwmFpWbQhlGEuajQpUFUbouvPx9 DFBPrYkpEg0asD4NJ3fSamoKAHU+d1IUfhI3/nQYB9k7hnWDDyV1qlA0JB9han5yeequNOo2dFd tl72f/uz7+BD2kOOJeJtTj19thPfC8TLC+KpLvI5BYSYAyZsRISZKRTtcrxZX1t6nq2lni X-Received: by 2002:a05:6512:130e:b0:5ae:9d13:e610 with SMTP id 2adb3069b0e04-5aea1f6958dmr1970457e87.37.1782488812647; Fri, 26 Jun 2026 08:46: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 v4 08/25] xen/riscv: introduce guest riscv,isa string Date: Fri, 26 Jun 2026 17:46:17 +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/1782488813-54785986-483B4FAF/10/73395122804 X-purgate-type: spam X-purgate-size: 8878 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488854212158500 Content-Type: text/plain; charset="utf-8" Introduce generation of the riscv,isa string passed to the guest via the Device Tree riscv,isa property. Introduce the per-domain isa string and guest isa bitmap, populated during domain creation by calling init_guest_isa(). Introduce guest_unsupp 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 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 | 88 ++++++++++++++++++++++++- xen/arch/riscv/domain.c | 3 + xen/arch/riscv/include/asm/cpufeature.h | 4 ++ xen/arch/riscv/include/asm/domain.h | 4 ++ 4 files changed, 98 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..b85af09d65c9 100644 --- a/xen/arch/riscv/cpufeature.c +++ b/xen/arch/riscv/cpufeature.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include =20 #include #include @@ -120,7 +122,7 @@ static int __init dt_get_cpuid_from_node(const struct d= t_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 { +const struct riscv_isa_ext_data riscv_isa_ext[] =3D { RISCV_ISA_EXT_DATA(i), RISCV_ISA_EXT_DATA(m), RISCV_ISA_EXT_DATA(a), @@ -128,6 +130,7 @@ const struct riscv_isa_ext_data __initconst riscv_isa_e= xt[] =3D { RISCV_ISA_EXT_DATA(d), RISCV_ISA_EXT_DATA(q), RISCV_ISA_EXT_DATA(c), + RISCV_ISA_EXT_DATA(v), RISCV_ISA_EXT_DATA(h), RISCV_ISA_EXT_DATA(zicntr), RISCV_ISA_EXT_DATA(zicsr), @@ -160,6 +163,12 @@ static const struct riscv_isa_ext_data __initconst req= uired_extensions[] =3D { RISCV_ISA_EXT_DATA(svpbmt), }; =20 +/* + * Everything in riscv_isa_ext[] which shouldn't be exposed to guests shou= ld + * appear here. + */ +static __ro_after_init DECLARE_BITMAP(guest_unsupp, RISCV_ISA_EXT_MAX); + static bool __init is_lowercase_extension_name(const char *str) { /* @@ -480,6 +489,81 @@ bool riscv_isa_extension_available(const unsigned long= *isa_bitmap, return test_bit(id, isa_bitmap); } =20 +static int build_guest_isa_str(char *buf, size_t size, + const unsigned long *isa_bitmap) +{ + int total; + +#if defined(CONFIG_RISCV_32) + total =3D snprintf(buf, size, "rv32"); +#elif defined(CONFIG_RISCV_64) + total =3D snprintf(buf, size, "rv64"); +#else +# error "Unsupported RISC-V bitness" +#endif + + if ( total < 0 ) + return total; + + if ( buf && ((size_t)total >=3D size) ) + return -ENOSPC; + + for ( unsigned int i =3D 0; i < ARRAY_SIZE(riscv_isa_ext); i++ ) + { + const struct riscv_isa_ext_data *ext =3D &riscv_isa_ext[i]; + int ret; + + if ( !riscv_isa_extension_available(isa_bitmap, ext->id) ) + continue; + + ret =3D snprintf(buf ? buf + total : NULL, + buf ? size - total : 0, "%s%s", + ext->id >=3D RISCV_ISA_EXT_BASE ? "_" : "", + ext->name); + if ( ret < 0 ) + return ret; + total +=3D ret; + } + + return total; +} + +int init_guest_isa(struct domain *d) +{ + int len; + + bitmap_andnot(d->arch.isa, riscv_isa, guest_unsupp, + RISCV_ISA_EXT_MAX); + + len =3D build_guest_isa_str(NULL, 0, d->arch.isa); + if ( len < 0 ) + return len; + + d->arch.isa_str =3D xvmalloc_array(char, len + 1); + if ( !d->arch.isa_str ) + return -ENOMEM; + + if ( build_guest_isa_str(d->arch.isa_str, len + 1, d->arch.isa) !=3D l= en ) + { + XVFREE(d->arch.isa_str); + return -EINVAL; + } + + return 0; +} + +static void __init init_guest_unsupp(void) +{ + __set_bit(RISCV_ISA_EXT_f, guest_unsupp); + __set_bit(RISCV_ISA_EXT_d, guest_unsupp); + __set_bit(RISCV_ISA_EXT_q, guest_unsupp); + __set_bit(RISCV_ISA_EXT_v, guest_unsupp); + __set_bit(RISCV_ISA_EXT_h, guest_unsupp); + __set_bit(RISCV_ISA_EXT_sstc, guest_unsupp); + __set_bit(RISCV_ISA_EXT_svade, guest_unsupp); + __set_bit(RISCV_ISA_EXT_svpbmt, guest_unsupp); +} + void __init riscv_fill_hwcap(void) { unsigned int i; @@ -527,4 +611,6 @@ void __init riscv_fill_hwcap(void) if ( !all_extns_available ) panic("Look why the extensions above are needed in " "https://xenbits.xenproject.org/docs/unstable/misc/riscv/boo= ting.txt\n"); + + init_guest_unsupp(); } diff --git a/xen/arch/riscv/domain.c b/xen/arch/riscv/domain.c index 2819ff4e7c92..e4a8c27ea9cb 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 ( is_idle_domain(d) ) return 0; =20 + if ( (rc =3D init_guest_isa(d)) !=3D 0 ) + goto fail; + 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..866e0f6e7bb7 100644 --- a/xen/arch/riscv/include/asm/cpufeature.h +++ b/xen/arch/riscv/include/asm/cpufeature.h @@ -17,6 +17,7 @@ */ #define RISCV_ISA_EXT_BASE 26 =20 + enum riscv_isa_ext_id { RISCV_ISA_EXT_a, RISCV_ISA_EXT_c, @@ -44,7 +45,10 @@ enum riscv_isa_ext_id { RISCV_ISA_EXT_MAX }; =20 +struct domain; + void riscv_fill_hwcap(void); +int init_guest_isa(struct domain *d); =20 bool riscv_isa_extension_available(const unsigned long *isa_bitmap, enum riscv_isa_ext_id id); diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index 6044ce0feee0..459896c04b41 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,9 @@ struct arch_domain { struct p2m_domain p2m; =20 struct paging_domain paging; + + DECLARE_BITMAP(isa, RISCV_ISA_EXT_MAX); + char *isa_str; }; =20 #include --=20 2.54.0 From nobody Sat Jul 4 20:59:50 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=1782488856; cv=none; d=zohomail.com; s=zohoarc; b=FUyzqkTCxy/KOzDNpMybsqRKiXPqflJQla+jcVI/xDRt7r48WHMsn2k8LKT6ArDuK39DSlXxKy7IuYbx6Ex8SB3CIygGszJkxHO1XbNEaGPY01WoPEhizwKt/IJlE/YkaUccbcnHkMhMsWvL4LueOuPszJkxOQv/R3agyTkoxdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488856; 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=0+TCKMUSTuyvYICiXP6HL6dmH/uLiRs4XxAzoc6J/CE=; b=hrEtgIRph0Ged/DeRDiBA6HLkPVRvP/12ziCizf2AZhlwm2Rms/kyS1fXy5ALVRUEFEs93jC/1rBgHrxkk66T/8xuRK8ZldKYuv8j6uI5AnKl3sOZ5SJui17FEYuKJTP5n3tWJCFQ6kiBBSS/8BEjQiYK5bqjOXWCAp6FAkvL2g= 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 1782488856179823.7347926016031; Fri, 26 Jun 2026 08:47:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346277.1604782 (Exim 4.92) (envelope-from ) id 1wd8lc-0001pf-Pq; Fri, 26 Jun 2026 15:46:56 +0000 Received: by outflank-mailman (output) from mailman id 1346277.1604782; Fri, 26 Jun 2026 15:46: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 1wd8lc-0001oH-Gt; Fri, 26 Jun 2026 15:46:56 +0000 Received: by outflank-mailman (input) for mailman id 1346277; Fri, 26 Jun 2026 15:46:55 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lb-0001V4-Ih for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:55 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8la-00D1eP-VG for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:54 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ee5-5cb7-0a2a0a5109dd-0a2a45028256-18 for ; Fri, 26 Jun 2026 17:46:54 +0200 Received: from [209.85.167.43] (helo=mail-lf1-f43.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9eee-5a27-0a2a45020019-d155a72bc5fd-3 for ; Fri, 26 Jun 2026 17:46:54 +0200 Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-5aea367c965so1125147e87.1 for ; Fri, 26 Jun 2026 08:46:54 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:53 -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=1782488814; x=1783093614; 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=0+TCKMUSTuyvYICiXP6HL6dmH/uLiRs4XxAzoc6J/CE=; b=aFmNTRkeF13lSg79F+24Vw/T0BoRFYokJtbfv017PPU/0/NoFqwMvOE/cwyQqe6v2d MC2RYjB5H9Dh3YJC46rGv5WXiVfrSYYl6hu7m3qPf4A9DwDsoYlQWnok2wKJ38Ghp73v 0I0Zw0M2S6b+VEia1wHeSPLjzQUzFlMC7d/R7Hu9t6ZEjFpx/W9kY5jREfamNGra1DNO WrIcQWvFK4uPF1iMJgrdMeaemJj9LD54TZzyAFbKW0GAdlThmwsOuLPahemwskjmfkVU 63yFj7d1VekI4ZpN8a1NJ7ZufnL/MT5xjdFROVIZ/sWK3Z+4xMNjD1IPAcjcttnjdBK+ ZXOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488814; x=1783093614; 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=0+TCKMUSTuyvYICiXP6HL6dmH/uLiRs4XxAzoc6J/CE=; b=l67ECE/NWASE2Jqhs2yEF62r0PoHJy/N3rM98wL+287WdxDc5pmIrtzpn/kWkC16/1 Y0nFbRHTKUJfo+RHokRIPLS3zdzlr2w+Rq2glRkJZHpFldGl3jlbBW3abeb1E3IlAb5D /GhxQxxBkZyGLP69FRtPB+VHdgbHo5JPkIxsvrFhRBIb77t4yM9VgMJV3Om7H3m63OCa FIWTkaLaqWBlHGCfVCMrdH5MVOuHrpR3Sd+0qnhyOoRn4/q9aZyydw9O2YSXsgcP2qxT Fo+klLaHRDaMiF9ZAHzjFbCOq4x+aoIwlto8c77nav2D0u2oxXfIQu/cTDzW80xkuE0l qrsQ== X-Gm-Message-State: AOJu0YzN5wbv0Z7PTwpL/6jxsp/c3E32Hdcbe2HWAt2xmeeyYS/PjIWk PF1TxpWLF96ApMfVlQQRwyGqIGRlJLkLVcFhDgtyoK8TEWZDuV6C+Zh5PlqKaQ== X-Gm-Gg: AfdE7ckcL0Idn4P3Q4H/I1P5GUlsTJUI7cSxw1FugfLna5C8vezha0W2b6B4CBX4ocO 8WlJOFOnG7OXWC523fyu3O/M6OUOpw5jQF9ctCQU4KNJZ7sa6mWNzvRpjmE2qpaJvRiw9/adV9B nZCnqA/scXRnTfxG0MoH8xWVsg/jeYTJKbFmXh/+O5+XdrrpmWzWE9i7gn4xvBK3IvVWBhQhNeh xa2nhKMLdw1Q4bKvSckfEgngb/dEA9eWozEOI/TFaZ/Pats0pZpF7zuzXgV4gUT5Ljb5PRXBHP6 x+Ml0M3B3krfbnDttfps0raic4dFXe7s9pkhp/ByGHnCQnmH/VVL56wYmaK6oRY9tyBI8yb9ayk MlNRU//uqoiIRnFXSSnC3vHnVxemI2nMOm1xILbKMUDqTAUK560j0er5NoIBqy6ZZ3T5spJ2Co9 r66t5ZsVT2RqB9itXKpWcDn+BU0mzgJMfmCtgchN5b8HrSn78TcT2iKYDErA== X-Received: by 2002:a05:6512:651c:b0:5ad:317f:a9a6 with SMTP id 2adb3069b0e04-5aea1f3f8demr1909934e87.8.1782488814088; Fri, 26 Jun 2026 08:46:54 -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 v4 09/25] xen/riscv: implement make_cpus_node() Date: Fri, 26 Jun 2026 17:46:18 +0200 Message-ID: <56211b75a05c8738d23caac9273ce40e39e8663f.1782487661.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/1782488814-4F1127C5-113466B4/10/73395122804 X-purgate-type: spam X-purgate-size: 4834 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488858139158500 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 v4: - Update the comment in make_cpus_node() to match code style. - Add Acked-by: Jan Beulich . --- Changes in v3: - Add blank line above make_cpus_node() function definition. - Move 'unsigned int cpu' from function-level declarations into the for lo= op. - Drop 'uint32_t reg =3D cpu_to_fdt32(cpu)'; use fdt_property_cell(fdt, "r= eg", cpu) instead of fdt_property(fdt, "reg", ®, sizeof(reg)) so byte-order adj= ustment is handled internally. - Add matching /* interrupt-controller */ start comment; fix end comment to /* end interrupt-controller */. - Update d->arch.guest_isa_str to ->isa_str in make_cpus_node() function. --- Changes in v2: - s/u32/uint32_t for timebase_frequency local variable. - Drop +1 from BUILD_BUG_ON(). - return fdt_end_node(fdt); instead of res at the end of the function. --- --- xen/arch/riscv/domain-build.c | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index 5f6f4b6248a5..198a420f55a7 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -3,8 +3,10 @@ #include #include #include +#include #include =20 +#include #include #include =20 @@ -48,3 +50,107 @@ int __init construct_domain(struct domain *d, struct ke= rnel_info *kinfo) =20 return 0; } + +int __init make_cpus_node(const struct domain *d, struct kernel_info *kinf= o) +{ + int res; + const struct dt_device_node *cpus =3D dt_find_node_by_path("/cpus"); + uint32_t timebase_frequency; + bool frequency_valid; + void *fdt =3D kinfo->fdt; + + dt_dprintk("Create cpus node\n"); + + if ( !cpus ) + { + dprintk(XENLOG_ERR, "Missing /cpus node in the device tree?\n"); + return -ENOENT; + } + + frequency_valid =3D dt_property_read_u32(cpus, "timebase-frequency", + &timebase_frequency); + + res =3D fdt_begin_node(fdt, "cpus"); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#address-cells", 1); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#size-cells", 0); + if ( res ) + return res; + + if ( frequency_valid ) + res =3D fdt_property_cell(fdt, "timebase-frequency", timebase_freq= uency); + + for ( unsigned int cpu =3D 0; cpu < d->max_vcpus; cpu++ ) + { + char buf[64]; + + snprintf(buf, sizeof(buf), "cpu@%u", cpu); + res =3D fdt_begin_node(fdt, buf); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "reg", cpu); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "status", "okay"); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "riscv"); + if ( res ) + return res; + + BUILD_BUG_ON((sizeof("riscv,") + + sizeof_field(struct gstage_mode_desc, name)) >=3D si= zeof(buf)); + snprintf(buf, sizeof(buf), "riscv,%s", max_gstage_mode->name); + res =3D fdt_property_string(fdt, "mmu-type", buf); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "riscv,isa", d->arch.isa_str); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "device_type", "cpu"); + if ( res ) + return res; + + /* Start of interrupt-controller */ + res =3D fdt_begin_node(fdt, "interrupt-controller"); + if ( res ) + return res; + + res =3D fdt_property_string(fdt, "compatible", "riscv,cpu-intc"); + if ( res ) + return res; + + res =3D fdt_property_cell(fdt, "#interrupt-cells", 1); + if ( res ) + return res; + + res =3D fdt_property(fdt, "interrupt-controller", NULL, 0); + if ( res ) + return res; + + res =3D fdt_property_u32(fdt, "phandle", alloc_phandle(kinfo)); + if ( res ) + return res; + + /* End of interrupt-controller */ + res =3D fdt_end_node(fdt); + if ( res ) + return res; + + res =3D fdt_end_node(fdt); + if ( res ) + return res; + } + + return fdt_end_node(fdt); +} --=20 2.54.0 From nobody Sat Jul 4 20:59:50 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=1782488857; cv=none; d=zohomail.com; s=zohoarc; b=AtBvcJkCKEOOH8qnIB44gABTZpLuMN/CRCbMfp88zQjvp9TMV/p1baOsF+uVKDatu0m0/l8ed7gLqcuy6eaDl9I3q9SBg9cvJWmz0v8G4fsIPxlqqN08j6OovHWaH/8G5gEKtR8+yIEfaXkv23Jc9xdAqCgu7wrI+vAxzSw64Zs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488857; 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=qB2c1Qc5sQgY4mzQM5bvoIPB8oNENMm9Ls9IP71fSNs=; b=SMirytzUW2STcoyDN91xp0Ut7BN5Y/UYRTc4V4RG0ayd3K4Dyp8DPuf2nmZ/eoczHkLeIYDXo9WOvwAFJT6S2kSpgBFug7fWYiMXoadap1nziS8OZYOavOvy4vrKC9iNh9yPGYDcDSGJtxd511trwEY/gGtmgmOdW1fzUVf/67k= 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 1782488857228942.6535882721971; Fri, 26 Jun 2026 08:47:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346279.1604790 (Exim 4.92) (envelope-from ) id 1wd8le-00027J-32; Fri, 26 Jun 2026 15:46:58 +0000 Received: by outflank-mailman (output) from mailman id 1346279.1604790; Fri, 26 Jun 2026 15:46:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8ld-00026a-Tv; Fri, 26 Jun 2026 15:46:57 +0000 Received: by outflank-mailman (input) for mailman id 1346279; Fri, 26 Jun 2026 15:46:56 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lc-0001nt-Lm for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:56 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lc-00D1eP-2U for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:56 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed4-5cb7-0a2a0a5109dd-0a2a4505c00c-36 for ; Fri, 26 Jun 2026 17:46:56 +0200 Received: from [209.85.167.51] (helo=mail-lf1-f51.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9eef-3cb2-0a2a45050019-d155a733e845-3 for ; Fri, 26 Jun 2026 17:46:56 +0200 Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5ad5e719157so1023729e87.2 for ; Fri, 26 Jun 2026 08:46:55 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782488815; x=1783093615; 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=qB2c1Qc5sQgY4mzQM5bvoIPB8oNENMm9Ls9IP71fSNs=; b=bfzfneABRezBGUbQkRz7USViUt6+d0tlpPpsJVhMSlma06lUiXLzYgDPq9aoE46d9g V70hm2k2oUlQMQGQLmO/js0yNCOWolQfQRBIbfRYSG9ayXEQGzXVvE5KVOf9prT4rDc8 zuQhsxS9saizxqXwGXy4Ax3cZRbLiw8GUCNS0FZpQGw4oBuv7daOSnd//yfMQSXrMRBn XpG+pgZ0tUvkQ80Qi9BBDU2iFJxZnvF7QbN9JYsAsLjTBHr/3nBx4QmX0WVw5NCqTeuy j0ej81QfFIgutOQ/apE00B+Ux13DzJXVEDeB+rLIIU49vc9gfPhlnOl4mKJdOOcz9eDy 1Azg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488815; x=1783093615; 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=qB2c1Qc5sQgY4mzQM5bvoIPB8oNENMm9Ls9IP71fSNs=; b=lUdDoljaeHswf9LfxuhdCLzZEDs0RC4exwQsbNXoL0ZIZ40xo/al1FcHJnrojROwN0 w6CmBJhEdcvT1oUtcswbjmlkXpDFDG/0M9a6rBwYBbqbY3y0Vp/RSfweJbV8bNK+UNXS EYmZUnSwe+lW+jg6nMuBSVQFmKzgjFOAZapVYtcqw239KZ0Ze4j/k7Yfu4tHYLh3sPb+ GklieQB1axrde15HbQtvWw0BVvo5PrjPH64d2BxKbeFzlI3WHEx2UtpyvrKsAeiSptq2 0K/D2rfUdyJ4qYaDEUwsXJIyEGkswMfJuQMxjL9R6GB3TvCEtd09Qu0s4PmxpwTKN0ni V3iA== X-Gm-Message-State: AOJu0YxcPXBhlUJOmz7CVBkrlncLcsMWiSz4iX2WoX7HCc64td4A1wkZ P8QkHIWBDT3ITHqjg1IWsdiEucaaR9iBR/WTvXa0C+OKXFLBr/3OKufFMu8cYw== X-Gm-Gg: AfdE7ckywEnERiQl7a+38OCpT+VnT04byWmtHK57aI432ymdHwLVP6DlKVdZTIRsK4b BW5HVkr3lxC7NbHas6IvJi//SEtM9BhZXMdr5TQG2mOMJ7uYq2tKPfzoiI35ImVvBoTGKENWLxA mn3JAhfkyDHcLaGAj9M9qWWIGVZF/QY1jhqeawAFEYvq2SohWQON/YFDfpTi3ljYgZCGJL6oBOg LvEffpRKriaM9WmKz4Qs6zCOcCTYjV1cUFplPH0plYV+68cdm65mRKNaCSPpcQBgedgjPqsjWRH iYtz1fgC5Ub9tNd+CIDFzDVXBjz30ZZURQHcDgDnKKkoKg8rCzAEWAW6j8BZrJyx2SnG5jQNjKO 57KxYlUAGxYiC3SqzbT5BQDDQmysB+4VwrkzgbmjXrmVWEo6OujrngSJr205S+F3qxiqHl60lUy F+GCziVpqJk1+lm0FFw+eXiKky8mpcKzCSYBeUSYQpxNm8zn2QfqZyNgd/fQ== X-Received: by 2002:a05:6512:3e13:b0:5ae:9dcd:d071 with SMTP id 2adb3069b0e04-5aea1f4b410mr2461758e87.25.1782488815091; Fri, 26 Jun 2026 08:46:55 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v4 10/25] xen/riscv: implement make_timer_node() Date: Fri, 26 Jun 2026 17:46:19 +0200 Message-ID: <02032a8d2fc06025ee8863617be71f3873ca1e26.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1782488816-1771B2B8-5D8B6865/10/73395122804 X-purgate-type: spam X-purgate-size: 1618 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488858098158500 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-4: - 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 198a420f55a7..54ecd301c49c 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include =20 @@ -154,3 +155,10 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) =20 return fdt_end_node(fdt); } + +int __init make_timer_node(const struct kernel_info *kinfo) +{ + /* There is no need for timer node for RISC-V. */ + + return 0; +} --=20 2.54.0 From nobody Sat Jul 4 20:59:50 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=1782488855; cv=none; d=zohomail.com; s=zohoarc; b=c8o2X9CFrboRM1K24Axdp8Ns13s3Rhje7ta71F5ikZUEyK2U/+IgEJmkqxBJbDV4zCrftiBe7BU3q0zZG88vE5unGXc5XpA+SeIwWg6OZISUfICkDnc1/EnHtJ1B9ELSFzChmfjSYnm82zmbrvVwHRhK34hTRouv3IAOhBUyd+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488855; 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=L0ZctfsZi9AKtr1AUJuUtLW7iH2a6UK3bDqcVMsemmU=; b=HYC20eCALsxWRYWJObvp3T691OLdAzgGkDRxg1rBvxzI1yZnbbaas2QDaQjaCsUxDZu5LelgcgRByFPxQ0hePL/3okpOAtC+xWgkue8bkhqa+AmT+bI6G0YfTVZNwyuQItAEyLQ8xaToXEPEJOcQtgr51L1UKAtvzLLTrBCzpzw= 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 1782488855005581.1888832573849; Fri, 26 Jun 2026 08:47:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346280.1604797 (Exim 4.92) (envelope-from ) id 1wd8le-0002Fz-R3; Fri, 26 Jun 2026 15:46:58 +0000 Received: by outflank-mailman (output) from mailman id 1346280.1604797; Fri, 26 Jun 2026 15:46:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8le-0002Dr-GV; Fri, 26 Jun 2026 15:46:58 +0000 Received: by outflank-mailman (input) for mailman id 1346280; Fri, 26 Jun 2026 15:46:57 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8ld-0001zo-FZ for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lc-008hQp-SR for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:56 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed7-2eae-0a2a0a5409dd-0a2a4509c3ce-32 for ; Fri, 26 Jun 2026 17:46:56 +0200 Received: from [209.85.167.50] (helo=mail-lf1-f50.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef0-97e6-0a2a45090019-d155a732e4d0-3 for ; Fri, 26 Jun 2026 17:46:56 +0200 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5aea8d5a777so343255e87.0 for ; Fri, 26 Jun 2026 08:46:56 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:55 -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=1782488816; x=1783093616; 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=L0ZctfsZi9AKtr1AUJuUtLW7iH2a6UK3bDqcVMsemmU=; b=ol2gHnyl2AIXjb10OnTRa88sSCLMrahCV4gUqUxWFSxUPrEg9hn6qfHv2awCvTzvkn qJW/w8rluxDGrBSCDSXc9HHiNqE/lLqP/QijrlfD/gWtD2hLZrKTCeCjxn8SPYsif9uu wHhBlfzyVV/TylXCKgR+c6FgoPpDIm0joa+EDaRDUjOUa63EMEf3ApdowohfkEhQS9Gu AzXH6j4vYv5DgXxw+J6/t5fYvsJFS0+EXDrphw/BNuGBAN+TlIKN5v4QhuBcBTslQDIB lIiRPy9U9a2XPpPblu5HlrCJCcFZ6NlXVONhiNwMertBiCZTTME5RbCkKOTPUnErk03e 1ijg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488816; x=1783093616; 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=L0ZctfsZi9AKtr1AUJuUtLW7iH2a6UK3bDqcVMsemmU=; b=aVHxPOTK9YI+m99WO6QhKORz79NnTZhORenNNmBcUF3Q6KP2aEgK6ekZpN9QwRmBpb hA9QkAasroPaxFZSgAbztRG74NIzwLULClaln9gQRfrWMH34IdIuLvOKry9t7TpBHhRh JMMInOfGfEFqwxuvp0HUEcQK58QI0WiY6BdsiYCqr3DwEmLVffQuzYpPQr+qoHCNr4n5 J+cR+ZHC/xSWpoiFHqiOfGJKwSGcTV7UXOhAWRSOiXGKxVHPyJLZwKH7/Gql7Jg+wCGJ OclAIx7HxvZ95tisJXC/gchYZUHpXSILqG7fUe5mCDeWr5KYUfyT9b4E2DVhgU/eSvqS 7+tg== X-Gm-Message-State: AOJu0Yx5KIBfdsK7mOEkBo82IqW3VqIMwCRy4gbKkaggL7rRaApjXYWE AB17lLGX7eZJ8ki4YtHj+LAjRY8HrI0aZn+M9/of/PrZMZuHKoxWUoAGhZ7rEw== X-Gm-Gg: AfdE7clfcOJsVuHuL2f0+HOelpSZZBqzpZM4BBGC5uK8b0jVQimM+zbalki/W5yMFGW d1NXFaqJH+5c81aIMJXB5xjna3IayCPv5EU36kifpOALoyw1nPoBj3Yv5g//B3TvjZof1x781LR s+KR/swOAcn6IrjmelajCnVtlCMd0ibSGph4Pr0Jg1R9q1nqAyG8x0keBKvo6x4qdilLrgxk8NI l775Q94uQCEufze+USWgCAf4AyN3p3g/lkTCbQ7ocDfkS82PGRlHz5nvctPOa830F2psR5blEkm pWcw4GcJNzm/UvPITzeJpuKtBEyBK3GMSdwsVw5UGVCYLMe7TFgMnuLu7T3ed2U9hsFZ3ar1ocr JA8gjV5BYJ5xWRBcr93zeuctpAC86lxm94YzwQL05h40QRansoqRsptrqmKEE+a49m/S3M2lW/f Q2V+ToRzjXB233oMw/MCB3F+HyMlPqIWEf6/RCLhiBSnwD0BzYeTf61yCkBw== X-Received: by 2002:a05:6512:618a:b0:5ae:a9ec:bb35 with SMTP id 2adb3069b0e04-5aea9ecbc7fmr129687e87.61.1782488816000; Fri, 26 Jun 2026 08:46:56 -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 v4 11/25] xen/riscv: implement make_arch_nodes() Date: Fri, 26 Jun 2026 17:46:20 +0200 Message-ID: <7b35f8da6b35920c012c56d5790584e237b2fe4b.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1782488816-54B87986-6B9BB6B3/10/73395122804 X-purgate-type: spam X-purgate-size: 1320 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488856278158500 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 Add Acked-by: Jan Beulich --- 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 Sat Jul 4 20:59:50 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=1782488851; cv=none; d=zohomail.com; s=zohoarc; b=CjcotLVJJfAtEH8wVk65aRfi4M/3mez1TQ+/2n92gdMBur3YzTxUzhPFcXPHLKSCjHyFzu0UWUapzCh/srG0j8jg0cXEgilcP1Dq1i//FOOzFbSg19gStfe3rCpMUl067IvzQGd0CBnq4RmYUp/wsHUDumPC7lWIQatMBC8neD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488851; 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=FzYOAPlpVwUcUak5H++ik2H8pEqHXcF+MNINDhmTTZ8=; b=Zk5e4Og58PeP+9CMqdIMtFSHkI9XP6HU6CKJGKo/dTQjSeXeSo5xzRraN+1FojQ0ErMSs/AsUQd+b3DASU9727+aBo+RrbplWANrA3logOXFohR1GQiN8Fwb7UBo1vY/X1+B4rfOxv87YKlYJi7hllnrpQyoz5ybGQVYuilKxZA= 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 1782488851564693.3887195951094; Fri, 26 Jun 2026 08:47:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346281.1604808 (Exim 4.92) (envelope-from ) id 1wd8lg-0002c7-94; Fri, 26 Jun 2026 15:47:00 +0000 Received: by outflank-mailman (output) from mailman id 1346281.1604808; Fri, 26 Jun 2026 15:47: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 1wd8lf-0002a7-WA; Fri, 26 Jun 2026 15:46:59 +0000 Received: by outflank-mailman (input) for mailman id 1346281; Fri, 26 Jun 2026 15:46:58 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8le-0002Ap-DR for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8ld-00D1eP-QD for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:57 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed4-5cb7-0a2a0a5109dd-0a2a4505c00c-42 for ; Fri, 26 Jun 2026 17:46:57 +0200 Received: from [209.85.167.41] (helo=mail-lf1-f41.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef1-3cb2-0a2a45050019-d155a729f031-3 for ; Fri, 26 Jun 2026 17:46:57 +0200 Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5ad536cd0c6so1012879e87.2 for ; Fri, 26 Jun 2026 08:46:57 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:56 -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=1782488817; x=1783093617; 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=FzYOAPlpVwUcUak5H++ik2H8pEqHXcF+MNINDhmTTZ8=; b=bqRzeLr92fsmX9wc1dW6sjw7CqV+uJFJZGrAaHV8ykSH2ESbK6ZJ3dL0xuiUHi4xxj eiqYciX0/bxwhdMQRYQeHmAQU1vNYRm7VyGTuZJrOSQettDSPB8JLaaxk5hnN31McOBl PlxHAhPLvlTl8H47mIRRimwCjueC/pAAuYQlUJonG8puqCCyjT4iNwqaEcs3eaaWWDRu r1yCbQCVAzhMyUb+XGLgqrsepgOZo7MYZAHUcUy/Z8vvqSiNJCD5xbS39DcJ3XCvm29b QdqRoMSlMot1QjVs0a7bFOA7Xo1bY9KfOeG4LF4fDZRx5dJ/ZEM/TZ0L93McsFy0+mrx KxjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488817; x=1783093617; 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=FzYOAPlpVwUcUak5H++ik2H8pEqHXcF+MNINDhmTTZ8=; b=h1fMeqsUvtvQSvlg+Z5T5QUyofAYRk47dUUQl/mvEGbwI1gNBpZE0XpcxF+2RW+uxF eANvQ0P5BWmX64wwDe4QGiH+zfMCSHDkfyNIhshdsqJeKqJITyfFGm7fYQCgN7bXz5N/ fmVho5K6FuO+pEirOSPNBskRKrB/trA2D3vzNqhD89kNw9QdnKHGFOSIUSyFTnptHVhA dWzH233488QvnS5QldgHeTzm/tdMJOs7ep2Ro4QsRLZdKXpzG3J4zLjb//84C/dbz5Vt uyvu3e2lP0GIV8WnKCyMW+qMTPuTIvnIO0nYajFgNSTIUqCXKHVOuxtUANyNNnK1cKiV VEaQ== X-Gm-Message-State: AOJu0Yyg9/Ug0xaVmH28rmc62QEI4E4LNhGMr6rdjMgPtthujzWpwJfS zrQjka5/ChDBLkSqIoln5tdG9/b3BH7TWnMH4cd6OhrA2bTdMLmlDGObjDSWfQ== X-Gm-Gg: AfdE7ck7Rd400QbNX7rrl6IdKKScRsCLDKVx/EK0lISKRCbzy14zQpHJOerDnhHzLKk 94+opJYo2JCJXZ8xVPPut9fyEnWrY4PwCZiSIP/TvVl6TdAKoRgUj9YV51dq54+qszKfi6jbmxV 9WOGBL482ItrKLlhdI0P0t4wUTrKs0uilO24UU4lmh+cezTZlrrDzvVzAJL4P+rLBiEio8qfzCr t+xRtsLSbViVzEfa07Ygmg8ZYc5gqsOg3pogE3L/cCcR6dR86O5K+5GWJkqnAxaAVopWkNyCzVK yO9gapusszTPDE1rNEq6rYsnuRq9mAltVNtHFQCnjJ2HuIQrmYzKXb3DMQhdKJfzmJIbA+eUBiI 3stBwf3rROXT2sSStiR50uJXb/tmpbtoHjn10NZWC3mn02whI7LU+ne8m5wENerabgWzWkI0iNX M4THGMAYMqAj9I/Sp7Y6aF2Fx7vbZS5CKNmg8l4udTwcxz6shm5ciB9advneo3aMBKD8il X-Received: by 2002:a05:6512:39c8:b0:5ad:abf:1e1d with SMTP id 2adb3069b0e04-5aea1f3464emr2403998e87.8.1782488816947; Fri, 26 Jun 2026 08:46:56 -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 v4 12/25] xen/riscv: introduce init interrupt controller operations Date: Fri, 26 Jun 2026 17:46:21 +0200 Message-ID: <6b57fa27f8f4c8a90a1237c1880ecf476b9fe222.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1782488817-0DB092B8-6C7299E4/10/73395122804 X-purgate-type: spam X-purgate-size: 3976 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488852095158500 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 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 739e8dab3498..def15f792d62 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 ecdc8a5e6577..3d84fcc51d1a 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 Sat Jul 4 20:59:50 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=1782488853; cv=none; d=zohomail.com; s=zohoarc; b=IAIEqUZkFAb8v8uwq8zeTtXEuYvzCr3oisEm1Ozpicpdz1L7JVd3PPTykaF4y2qKxpn7dNdfwlUrfSD2/vtBDS7kcZUTBPL7cI8gn5T8hDBZUvAxPqDy/yFrqsRzO5FykLx4KAqsUkiMDYYETWjuYOwnwzpSpK4I0vzYIiPpdJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488853; 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=z9apWbvB3Q7fbjd5yUWMyhIhyy9eFY+Tl+j7eQxlTNk=; b=frEQUVaHWn5rxSMsaY6I35Yq0tlmR/t+ks27y/xxUh6T76t76eWKDGZvWmgHsVg0L/M2JHnEo1tyWWsIMtwonjVyno6Zveii+Il9BpOMZ8M6CJ7Vgi0ZLmLobqd+appY6fvawTBvm3t1HOdaVwq9YmBR2Xx8ugyFVTR+K/+7Yck= 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 1782488853399613.7554073561081; Fri, 26 Jun 2026 08:47:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346284.1604820 (Exim 4.92) (envelope-from ) id 1wd8li-0002wr-6T; Fri, 26 Jun 2026 15:47:02 +0000 Received: by outflank-mailman (output) from mailman id 1346284.1604820; Fri, 26 Jun 2026 15:47:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lh-0002w9-OQ; Fri, 26 Jun 2026 15:47:01 +0000 Received: by outflank-mailman (input) for mailman id 1346284; Fri, 26 Jun 2026 15:46:59 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lf-0002RQ-HT for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:46:59 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8le-004aSr-Uc for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:58 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ef2-bab6-0a2a0a5309dd-0a2a450adae0-12 for ; Fri, 26 Jun 2026 17:46:58 +0200 Received: from [209.85.208.171] (helo=mail-lj1-f171.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef2-e40e-0a2a450a0019-d155d0abe5e6-3 for ; Fri, 26 Jun 2026 17:46:58 +0200 Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-3965adfd75fso9039471fa.1 for ; Fri, 26 Jun 2026 08:46:58 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:57 -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=1782488818; x=1783093618; 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=z9apWbvB3Q7fbjd5yUWMyhIhyy9eFY+Tl+j7eQxlTNk=; b=cJESfHsfPsCCQAizqLl4+wEFgVkI+S//dHKrg7zK70cRiDh2dn9JmWd8QRr0fmSy1j iX9mvhwqx9MneU7pnnjvNc6/BgSK2yaFrddiU56FfXcjlHic1hywbRhdTehA/fa1D0fs DgOSqo0sxEU9HecLqHNIU7I31gfDNnBtp2fHHLX1Um0HaQFjZdKxK5C92+SFJ0+xKv0K GMoy9rj4uPmUVAwqSO0AnqFYMVbCCP3TeTiN6Dm1FzdkIOyXnLIHCdhCvqjiY0x1Mkho aus5n0tbEt06FhD+ma19Acu4TTAcCeULiYLBPcnl1S0I0s+Yml+y9CoZV0CZU4TuGNWd IyZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488818; x=1783093618; 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=z9apWbvB3Q7fbjd5yUWMyhIhyy9eFY+Tl+j7eQxlTNk=; b=mScfDZDsPOWC6OhsoQMvDJ978fdXQ1sjTrvfyXSJKmjNUII6vlpeCPBvR6af6/OK+2 /Dfg3ioMP8Odp+scMqiS1C4hxFWVVEXfUvlqHWMKEY/O2MqfUnU9a81EIXwFFDI+tAL/ T0GJIedpOPFPY3mMeFHi+CFDqiZxxfe4D3CSqYMjcdOYPu8fyvm4kMu75muPWIbW8AQO pb9369Zd9SWvYH45bGz/SQv8PT9p3c8U61Q0wJ/gvyA5Y0SQhqJHocvoYvk261ivim9e LS56wggWwd8X6+7+Q8L88Tk8LMhydWUWztNAAteHqokEs5Q0r8LCkQ+rP1JRHxv0VqqI gMJw== X-Gm-Message-State: AOJu0Yzjw1rUT2rhbpMDo1ciiqrpaUHYFz+TnTsGMh/w6MHoANgTeSi3 Ty299vpSPF2oZASVPZrmSRBeC4fPNJXfR0ojVHWKU4k6jF8RimBykkWAYRaWyQ== X-Gm-Gg: AfdE7clhferVHCuQudgPxygIfslKK+ynKKSpvOrqLKUUaW26I13/gFzqGcR9lj27Jl7 mF3Sz+MRJPrmd7eDe0kL5foUQqdc9oPbIwS4Hd3RKZUIkUyWmjhkdRztUgS9lJIP2J11ZkaiTRD wKyg6ym9w9oW6xrcerw5g9yD8/gjRxE70Pooj4+SmuPWZIE/aVmwLzX5L94TCROoC8oRlltuFZs 4a8Xh543O9BQw14vFSprggwtnQqsMCevzqy/xVpl++5gnrb9b9yxc/bhg5h+4HOV06jXG2ObLRe hOLEtw+ZRvAJUa9aUbesY/+UaiRdNoXrk+jg9FxLww7ZN0wwsLtml80HejK0g5ghau6YNnkXacF LrQ7zzcgVPxjY8qCU7ko4L9xB7x33mKv7IvTqUjrP3hMNwlgV51Sv9qxZ5mUXPuL4uLAUjh6lgn nsHTwhOIBgvesVKo/YoFe4En6Fgwrmy6HSibZG4hiYLFQoCLu0YCPei95GJw== X-Received: by 2002:a05:6512:461a:b0:5aa:655b:ac29 with SMTP id 2adb3069b0e04-5aea1f2d5d2mr2181855e87.13.1782488817809; Fri, 26 Jun 2026 08:46:57 -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 v4 13/25] xen/riscv: implement make_intc_domU_node() Date: Fri, 26 Jun 2026 17:46:22 +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/1782488818-D6F3ADDE-8808133E/10/73395122804 X-purgate-type: spam X-purgate-size: 3543 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488854133158500 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 --- 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 | 12 ++++++++++-- xen/arch/riscv/intc.c | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/a= sm/domain.h index 459896c04b41..8e597e231ee7 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -98,6 +98,8 @@ struct arch_domain { =20 DECLARE_BITMAP(isa, RISCV_ISA_EXT_MAX); char *isa_str; + + struct vintc *vintc; }; =20 #include diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 3d84fcc51d1a..9b701445179f 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -8,14 +8,13 @@ #ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H #define ASM__RISCV__INTERRUPT_CONTOLLER_H =20 -struct dt_device_node; - enum intc_version { INTC_APLIC, }; =20 struct cpu_user_regs; struct irq_desc; +struct kernel_info; =20 struct intc_info { enum intc_version hw_version; @@ -47,6 +46,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 Sat Jul 4 20:59:50 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=1782488851; cv=none; d=zohomail.com; s=zohoarc; b=X+xtr5fmCqARz95fsBveGFijgc74eyWSqMr+ZP9TZEq4eJ4yo2tD478epfAGvi8PN5/CW4f99m2f/1qGefADrH7NVC0QIxBOUcIXEYazVhB+0bx/Ybgrbe3dfBKAoY+uWDMLYWH9XJuWCWlHw35cmFTFP3R2LD4OKcWdV7Zp1yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488851; 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=gmaOim7BZjYCiN1zoPRNC/AZ0NqzABJMaudwwqKrFuA=; b=L4KTh6wSo0XDNwrhpMgAiz+BuEV379WHnvGrLMSnPEUjfOTr5uXczoOG12h8hD0ngG1B1EMoKmF/l8dET2UqiYzqRD08PWnIR8FWLPwdR9C9oiFbv4Fa1LeNvLoA4UfD16gHCx4gfn4Hconw0wqLPon1u+mJozA97peFPANt+Fg= 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 1782488851576686.8707608528779; Fri, 26 Jun 2026 08:47:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346285.1604825 (Exim 4.92) (envelope-from ) id 1wd8li-00031z-RA; Fri, 26 Jun 2026 15:47:02 +0000 Received: by outflank-mailman (output) from mailman id 1346285.1604825; Fri, 26 Jun 2026 15:47:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8li-00030L-A8; Fri, 26 Jun 2026 15:47:02 +0000 Received: by outflank-mailman (input) for mailman id 1346285; Fri, 26 Jun 2026 15:47:00 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lg-0002aG-5E for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lf-004aSr-IV for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:46:59 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ef2-bab6-0a2a0a5309dd-0a2a450adae0-16 for ; Fri, 26 Jun 2026 17:46:59 +0200 Received: from [209.85.208.180] (helo=mail-lj1-f180.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef3-e40e-0a2a450a0019-d155d0b4edad-3 for ; Fri, 26 Jun 2026 17:46:59 +0200 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-3996c9eeebeso9996361fa.1 for ; Fri, 26 Jun 2026 08:46:59 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:58 -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=1782488819; x=1783093619; 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=gmaOim7BZjYCiN1zoPRNC/AZ0NqzABJMaudwwqKrFuA=; b=ALaYxdSd6SwoGzdXZr3j6TCxhDRwLnoqTpScFeE6I08CRDNS4mLWfySBMuukmd4qEq JuNIFBVDmHpDk1IQ4Rpuc4WlO1QptfPpIe7jb2e0xBr9jYCchWASp+iD16bPjMuxIf99 zG2QzilsEoMM1uFVt7wBu+b05HKkDKM67blCm71UEI2oRVlwA0TL6gb5XN7W4lpA9nUd 85aBGedR2unY5llaKxamb/L36IGu5Uc+3/a40Gt0yK3mxMfGivFCwOmxrm6Ny2jyZbTT 2zct+wEIrtySjKwSRxWZtoEkYDNzXyExyJIySFpDudanjgIftGrXH4Ur5hJ20Lzi4qVw I2Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488819; x=1783093619; 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=gmaOim7BZjYCiN1zoPRNC/AZ0NqzABJMaudwwqKrFuA=; b=SGoV1xkm/yi3LEm/W3o1C9q8paigdtc8+X8TafdsdGU6SfJY1FOe37QEVSMM1uzJRP XhcqhhZz4OB8Sb5xEtEK7ujDuamw2RVA0btpN0hg7TY7Fv+kcuwPtIwPOKMEtLfwp9S3 LTTEGRiAeiZ9ONBS2DisUv0hav6AAP3SkKw4BUzG48RYZJZsuvtzX2hIM9OPYv85kV/v 1bihsoRX14aFyAzvOUScUKiSuBUT7jaeiviElE0D8/b65QLkngGYGN8QqlMiOLcqcOwI NEsYyxhonM+CYVNKCrwq3x4vuhwjWPSUg4LywvfG96peFJr0No2nz3yJTkJZHshy+hAx IVqA== X-Gm-Message-State: AOJu0YyUDnsCZPydr94NOfK1HwNjZTX6OULJymiDZ+mjj84K8FR89QDh ypS6n41BI4P9YD5L2hKpSEgZodFn7AmtMyfwP8+4q+oVkjz+PgmIaqiH9/O2Ow== X-Gm-Gg: AfdE7ck3nkkYUdibqnGM9Kf91qegNtaRUVExbLK2M3Jpt0vH94VYgH4dHjHxxy8zuQC k5ynjcXE3qPMAiNkf9sbOmvO19Y22qGqnD3jviRkBX1+QcT0YmVyzmb/CWxAzYfN0u+JE2pcpF4 MGZX5jVbjgFNDwmPfXeP2S8Rnv2o8hhM0sBzCdndHc43RJPpq5ru59zzuGXmg/RMxWgz9NkDrJF kN/7oqgXhHOTVfQcTiv0tsf3rvA3cRjUEn2c/oK7Snj2c82LhX4ZNd1C0PZngRuXpEGdQwSDYyb +9TJx6tUaMjUcF0p9kNXSHJw5NXr4v1BdvlpF3KPCI/DE+U5+nFjLHVFrw0djc+3oDhWtbug88r /GTsltUkk7BeNuiMXxybgcBfPQzC41zfc1LYtK/ckXOBrpU6F1gu1UoE0Hf0bdPbhImmm/QFwgP J/rQJ7mMLSJ91j6AhwprpfpYNzJhCqGdBhF91wbL1xW3/4dFVvppsAsciJbA== X-Received: by 2002:a05:6512:64ed:b0:5ad:5b38:2690 with SMTP id 2adb3069b0e04-5aea1f60e9cmr2054615e87.42.1782488818729; Fri, 26 Jun 2026 08:46:58 -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 v4 14/25] xen/riscv: introduce aia_init() and aia_usable() Date: Fri, 26 Jun 2026 17:46:23 +0200 Message-ID: <709f4f1d9d593501819fa3d579b2cef0a108b48e.1782487661.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/1782488819-D5B24DDE-689BC773/10/73395122804 X-purgate-type: spam X-purgate-size: 3082 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488852105158500 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 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..ca42c3086126 --- /dev/null +++ b/xen/arch/riscv/include/asm/aia.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef ASM__RISCV__AIA_H +#define ASM__RISCV__AIA_H + +bool aia_usable(void); + +void aia_init(void); + +#endif /* ASM__RISCV__ACPI_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 Sat Jul 4 20:59:50 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=1782488861; cv=none; d=zohomail.com; s=zohoarc; b=EZzqqwigL47Pd9UcO5HMS16SaWjH7+v1SaStHU5+gasNHMMFE1JFYmmoGkZqmmkkVW2FQBcI5pfpnEQkFosisdloSJFN3ogYf9GVZyogKdal0EyZ6ZnjGXDZAWLkKeACxutskSa0pGDYTWRiFVrlVHL8zqD7hS9xNoiv4JMBwW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488861; 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=doELmlZY6voWxsScgdyib31c6ViG28sXkot44w2GTgw=; b=MQob7ZnXU+hxFIUpL973FFK0QnumvLL2LqolJ4Mo0kQyS103AmoBh/F8dyqMBrL5s/TFMGv8ZEVYG94ZoLAj7rUBjnspy5fuHlWldSrv0TA9BXi0+J7jcEAhvdRuS8OHNEW2TL/M0xS3Dq5SeAbnlHM1AOnxgpB2EmfpS5hVus8= 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 17824888612611019.8211096842656; Fri, 26 Jun 2026 08:47:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346286.1604832 (Exim 4.92) (envelope-from ) id 1wd8lj-0003H7-Tw; Fri, 26 Jun 2026 15:47:03 +0000 Received: by outflank-mailman (output) from mailman id 1346286.1604832; Fri, 26 Jun 2026 15:47: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 1wd8lj-0003DT-9V; Fri, 26 Jun 2026 15:47:03 +0000 Received: by outflank-mailman (input) for mailman id 1346286; Fri, 26 Jun 2026 15:47:01 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lh-0002oK-4T for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lg-00D1eP-HX for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:00 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eeb-5cb7-0a2a0a5109dd-0a2a4508b62c-6 for ; Fri, 26 Jun 2026 17:47:00 +0200 Received: from [209.85.167.48] (helo=mail-lf1-f48.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef4-edec-0a2a45080019-d155a730d911-3 for ; Fri, 26 Jun 2026 17:47:00 +0200 Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-5aea915df15so438523e87.3 for ; Fri, 26 Jun 2026 08:47:00 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:46:59 -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=1782488820; x=1783093620; 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=doELmlZY6voWxsScgdyib31c6ViG28sXkot44w2GTgw=; b=fyNePBOG9uC6F7smYz1/yH3U7wm/jf5DX6o3J58yPiYobeVDJn3pgLyZBNey/ZK+1s ReQuDLXLyPvdALb50TyIqWeDuYhkdW4n2eULGcFijXX0yUZbdtzEsB4qfzeBEgSxJETb 2SIv1Nu/3drAl8CPWl8/pXj3oKClUWNI/Xxev+dKm94LsIZecyAZzgKE1Glqee8fEkbY ueOBhmuTGCvRiROqfM72M6pnGV1fe3yb4CxqW/qU3Nqo9JcW7/Wnib5l4dUZs/9QEZ0j 9Tv9tBI9YK3hivK2LL03CJfRDWQrLKR6q3GRNljJAkQk43nd38tCibP7yK1SouHg76lS 6a8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488820; x=1783093620; 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=doELmlZY6voWxsScgdyib31c6ViG28sXkot44w2GTgw=; b=sPxDo78bFX0+QKKUNc2nZQZ8gUKtsr7RCARuJSMk2HBk3OyYT2z8BK2RyhDb3J5bhv xTymWgC1CGRszK6/GaYMuPti/SAJ74bPEJtexAJwOeNDLYVyAm1zVZwOkNrgr+zj00Wn QQ5CkOW3d1BZwlmvO7ijK92EkHafnBWXJ7kk19zCOYBaR4VnHNEHi6hBsqM5wlWqDmTY q0338Iy8z0XmQhvaWFAA33jURC3MrZa0xQJ1+bH8jVN5kLbHsErhlILNTBn190+80fFK Sm7nShK+MKQvfI/7sXVCOKDm9UvUw8l1ZOMKjsW3y7ZJbNBhe3x7PNEw+PWorXB4zB/J hxfQ== X-Gm-Message-State: AOJu0YyUGbOA6628v6v2C7AplZoiJmDg1uTJwZiM5AqSNAuOrGre/Dd4 czWc1QTQNYPY7eNWt0V6H0L1lwKelBNGmQql4zQNuShw/FnnuS/mglVXCQzhzA== X-Gm-Gg: AfdE7clsbC7+jVlv6hNyUDwARBGg5t/ksC4iwAknHwGtWka+DzxLgLtX4T2AjIaSOwc ffpPFR9xOCE/D2NOl6DrReunnfc2XROyz9pCOHa9LmKL8/8HSa/WM5vYjFMgXSgndZpROEHB1mq pTpnI4ipjDkicCxeEckef/OjN0GicJ8aKStAM8Fv6m3+s13hF8/+2qlEioGOMt7dGJdbF7JcxxV tjkhgiRo7JjsBrKH5d1CbpTsjpj6Ozyo2b5jKEaam9S8eWKIrby9epI7nrKOOEqNXsxB+fVgkJR aBtv49hCNCeRvGScZHdMNQPxy+599qtSXM8heSPkcaaH80xrMumOH/J0w76PEKpmi9sV2FwXhp8 xBVlv+Rn9Og4shFnSuL6ap/9lZB3TWN3CvPhOTNj7f1kAnevtniMoSeNyXnjRjBUFe26UGjYdl0 +M21xQSNbRFormY71DkTAbZCQfxb7ycOB/OECBoeczGeRmNYQten7LaOFyQg== X-Received: by 2002:a05:6512:8053:b0:5aa:6b0b:1f34 with SMTP id 2adb3069b0e04-5aea1f29155mr1571422e87.8.1782488819683; Fri, 26 Jun 2026 08:46:59 -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 v4 15/25] xen/riscv: introduce per-vCPU IMSIC state Date: Fri, 26 Jun 2026 17:46:24 +0200 Message-ID: <98936eb92e39aae0b56049d6c94cfd468f559397.1782487661.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/1782488820-4253F3FC-A181279A/10/73395122804 X-purgate-type: spam X-purgate-size: 6151 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488862374158500 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 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..7068d6a7fef1 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; + + v->arch.vimsic_state =3D imsic_state; + + /* 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; + + 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 8e597e231ee7..bbeac7518a85 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 Sat Jul 4 20:59:50 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=1782488857; cv=none; d=zohomail.com; s=zohoarc; b=NjUUL9aamt57OIErQxZcpmGw9EG3//Swsl2hVaE0KGZWsX6d/LMVeUCTokGOx0tYXw9jStFlmExWt5BAHTly+XKl3IlqSe/3xCG8H69AFqVlAXQNEE0Nh4cqbBjTMdfLIu56nnSQT4HRJJiCfBx3VskegMsOD1YZ9HsOPQ8/UKc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488857; 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=AchFHgJ16zmh1UmcP9J522LiWGX/SFON840u47F4Ksk=; b=bkCJg/fsNDkhQBThmJLpZ+WYLJDjRK4FPYF4VMm+/qkO/WFimz0upNo0ryE3psMb2IZa7FOQIfPjgQGq2fTvFPpFwK1uayFGpUmq8l0Hz/W6YzVfVI8FUFfwaYJDOhJXkoX8b2jtzPPWxruODMOvyPsGDZCEdJqAH27MrzoxGzY= 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 1782488857794290.9053649184075; Fri, 26 Jun 2026 08:47:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346289.1604842 (Exim 4.92) (envelope-from ) id 1wd8ll-0003gT-EH; Fri, 26 Jun 2026 15:47:05 +0000 Received: by outflank-mailman (output) from mailman id 1346289.1604842; Fri, 26 Jun 2026 15:47:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8ll-0003eR-18; Fri, 26 Jun 2026 15:47:05 +0000 Received: by outflank-mailman (input) for mailman id 1346289; Fri, 26 Jun 2026 15:47:02 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8li-0002xD-3b for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lh-008hTo-Fi for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:01 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ed7-2eae-0a2a0a5409dd-0a2a4509c3ce-44 for ; Fri, 26 Jun 2026 17:47:01 +0200 Received: from [209.85.167.54] (helo=mail-lf1-f54.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef5-97e6-0a2a45090019-d155a736bc1d-3 for ; Fri, 26 Jun 2026 17:47:01 +0200 Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5aea7e6220aso809434e87.0 for ; Fri, 26 Jun 2026 08:47:01 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:00 -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=1782488821; x=1783093621; 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=AchFHgJ16zmh1UmcP9J522LiWGX/SFON840u47F4Ksk=; b=JiFyoE88hmDxrKTGkldVJOfGKf/fN5KaRmq0B0nThqGG0iE1yM3Bei5uGT7/9BPduC rY0TBY3LYLUB3PNOhGoXuOSGEGk9BmBBxzhyAvnNQtjmsT9lxVlyhV6nunu+XEVH7vnn DgVyi2a8czr/IQkj8xOgywrmAbQU9jyPEfO25TUKMbO5pQ3ZH0EugbzP2S3+cQaDQQnI jlNORpahAmcDZ+O6lcwd+YbFaBwhvpEcH9KLLg4shyJ9Unl6HmzN4I2juBZqMcDHNfGe rZYmoAqztlX81dnDvXVUMeJFfjYaHQcQJXJQ+iz4Cdoq7cZ3HAV81IKitn76vygZoECa w7XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488821; x=1783093621; 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=AchFHgJ16zmh1UmcP9J522LiWGX/SFON840u47F4Ksk=; b=hSZOmRtDEG5f3qGUOrRQelz2EOW8KGIUZASa1ljAuztMfmZRgo3ZksdkvALyw7fQC6 a3WpBFQK0QUJEvN5JHZPO6ad/ikz1c7pBXu7erAJ86uhe/s1r7d22V00SVHyiDiRoJGf FT1PVTo6NJSy53Gjoq8nmcJTUfGPtf4t+7rZm3P0JtJXAsUOkjCgaQx3QfjqWjUP83QL 1lwFbGFbELPXcVKKUg9dk7L9mKfhRVFIwy3+Yu+9RfapA6UBCSZzz1gn+tYnnLQIqHNr RqGocn1mFbmZsBPQ/4mcUMnuNxFlmdSBZ/tp1vn6t2QJ+ce/s5dCDjrtRPxYTJzfSCxm nfNA== X-Gm-Message-State: AOJu0Yx9PlE7h+gG+AFy5e5wWhexWYGuUcRv0wIRa2i7x//Ymqz67O5a x2LTJ3EBQaE6o7/5nawfSqbTB6lLzz+TKmrHsOznn9N+N7jNZ4wVF+LeDui/Bg== X-Gm-Gg: AfdE7cmCNi6XW9NFnrRgF+/SrN3HKNETaQ9sU4TY0E4xi1pLyA35cFxXU5FtTbGJCWs ta9qoF2IMH/OlBsEFd3MMZ+2adDdQoc18e1dDOyE1+U6dvJ/z9hsUV9IwAciS+pNyyWgtDEU5g+ +S1QvqNPAXYpB28fKvHUYMvx+rqmtpaG63qiyGTbc+Vh4DhFfcz0aFbhaZx4TVFUfc+Vhg66M4p eXvOl0n7nQW6dYTnzJA4d4FvgT4rMbcsM5M42rlz5Nbxm17ZzD3zerioaySmpp52WRGYwf8O5gB UvfycwAbKythEZRQykI9OeGY1x/HEgaD1rH74btnjF7B6jQ0YdH9VJegYE/zYRaxpS2a5Out904 BILJxU+Cnz7sOX4tPRZO4ddeGVDuQ31wXra/GY4JPzsjI4YOtFKXMP0n0tUcm+BkKFoB3TnwWpN iUG9LN6EfjFkh/kTkGzyluVctl9D26rsbgyhUlhu5rQnQpZgNqhpO9+ZaCSg== X-Received: by 2002:a05:6512:3c92:b0:5aa:6fff:c3e3 with SMTP id 2adb3069b0e04-5aea1f4cdf3mr2573519e87.33.1782488820619; Fri, 26 Jun 2026 08:47:00 -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 v4 16/25] xen/riscv: introduce minimal virtual APLIC (vAPLIC) infrastructure Date: Fri, 26 Jun 2026 17:46:25 +0200 Message-ID: <61603c1548b7c685fb92e1b687445fc1b6a95c35.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1782488821-46B3B986-AEAF6148/10/73395122804 X-purgate-type: spam X-purgate-size: 8640 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488858230158500 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. 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 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 | 3 ++ xen/arch/riscv/include/asm/intc.h | 10 +++++ xen/arch/riscv/include/asm/vaplic.h | 34 ++++++++++++++++ xen/arch/riscv/vaplic.c | 63 +++++++++++++++++++++++++++++ 6 files changed, 114 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 e4a8c27ea9cb..129e775c52cb 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..2e606b8cd947 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -15,6 +15,9 @@ =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 9b701445179f..46a0073c2d59 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -15,6 +15,7 @@ enum intc_version { struct cpu_user_regs; struct irq_desc; struct kernel_info; +struct vcpu; =20 struct intc_info { enum intc_version hw_version; @@ -51,8 +52,17 @@ 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 { const struct vintc_init_ops *init_ops; + 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 Sat Jul 4 20:59:50 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=1782488854; cv=none; d=zohomail.com; s=zohoarc; b=eeVnySWOZ4j5zvyknAUjlGkUJn3YNb1tuu/y/bJu1QQIE5AaClKJBzbkiAJCVoV11NgV37YfxoP1qWJfldGAUGlp178FeM4zLOCLne0ZHLS4F3f/tB9G8yxh313g4yiDHMkPLkPK54JewTuGm5z7C7L2RDXkk2rNMd8XvMuLITE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488854; 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=zWZ84aMqxsVJocBQ/1piJw1YHKrWxdOI1LLzqv702F8=; b=G67hLNCqXsPgAQUplKZQlpvVGnQWOgkoNEaLCeHA8SXynNUMbDOjsJu8iGuCQvGB+Wz6q2NAzeAjDqLjx20PIvdDqf7eznmnin5QYDTFD1ycB33Oq10FicO3AcXkI5WKeFgQXZfaW425I1ig2KJ0ALd+j6MeYXtDR2xhbvpHMpQ= 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 1782488854889337.32407772243346; Fri, 26 Jun 2026 08:47:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346291.1604851 (Exim 4.92) (envelope-from ) id 1wd8lm-0003qn-J1; Fri, 26 Jun 2026 15:47:06 +0000 Received: by outflank-mailman (output) from mailman id 1346291.1604851; Fri, 26 Jun 2026 15:47:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8ll-0003mp-RC; Fri, 26 Jun 2026 15:47:05 +0000 Received: by outflank-mailman (input) for mailman id 1346291; Fri, 26 Jun 2026 15:47:03 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lj-00036u-2Z for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:03 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8li-008hTo-Ep for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:02 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eed-2eae-0a2a0a5409dd-0a2a4504e35c-26 for ; Fri, 26 Jun 2026 17:47:02 +0200 Received: from [209.85.167.51] (helo=mail-lf1-f51.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef6-a01d-0a2a45040019-d155a733c95f-3 for ; Fri, 26 Jun 2026 17:47:02 +0200 Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5ad58584037so851614e87.3 for ; Fri, 26 Jun 2026 08:47:02 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:01 -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=1782488822; x=1783093622; 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=zWZ84aMqxsVJocBQ/1piJw1YHKrWxdOI1LLzqv702F8=; b=HA03ZnS8vvxdBJFay1S2Z0w97hjvEaudZ37JQWy11+J/lafHUD64oNb2OFUrUntr1O 1EPUl7FSskOaYLwDRcsfFV46B2y7ukaSLOQeBzkwn8m0f3b9Qm906mGXwpcJR1Upd0Z6 Bym81WKLgRRKQXJcLuhY6UetCMsg927lC9aS/lHLuoFQnDM2V9NoFg0l5Wov/q6CVIUB ZUFwy1aRkGPolWYdiIZVOWoNXCTDrHRBMUrJUwfIZqMVVxq9NwzpSaeuBeyt1sJNNJZF zikx0r0nlyLGij53Qy+F3F4umrZFpSTGURoh8zNU4dG+D2hAUpg0I5UtrB0g0hGNymyx 2+HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488822; x=1783093622; 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=zWZ84aMqxsVJocBQ/1piJw1YHKrWxdOI1LLzqv702F8=; b=BrpuGxOsbIl7Jb9vMJ2/7eO9wHGzfqbQY9ob3fdbPODEWhE82PlD61W7lq6X8hkyU+ LWTZG2Kn013+K1rheBQT2WIlWPzckj78yy/O21uS3MUa0r7bgsJTBbChhI6nCJJKB52I oRJKN8vf2wRtq8vl1Iqqh0IfOed9XOSz+AO5LNfh3cJ2HTdLE3nYtkb/nWOawYK/IU77 kJwN9GRMvglXhnRDz+Bf2UjWfbLio51iL1NF25hrHioDVlIgLtk+V9//NvFG5+c9z7og 9mL4Gsd0q6km+HPAOL/avVIe2RB6RMMKjLLU4/PcaJobWX+KRUeuMEdkrtMZWFTlvAed YtFQ== X-Gm-Message-State: AOJu0YzwIxR2QCZf1H2TjaGbBNQWMLjspjXgmv2cBLQgEW8LLM5qODOJ XCOLCj93qLeNadNGYF25ZO3Al+5V7wCiJXSAk737NGW7eFUyltKphqIOjjWkLw== X-Gm-Gg: AfdE7ckUzhnya3gEOvxRhXWp0FG/iPPzne/O7CuU6DAsWxhDsoJfkg2yj8M5GpXzRfd fbCsxeUxKMzoN9808ZMYpq3RYh0dWDZckKujPx9DLDDhpfYHxPKlQPzfF0j3qTpYak3pLIlpY8K caqOurqc0X7UOf/NCqTt5birus6xIlEM6a76+206p0ohaYpA5Yz/nUKIltklW9+9dGr15s1NVDI Qu98hj6uxpqlch4i9LIR6BNXjDKP5T9yLg9MiTyfdlQng30rPt/jA4kFx7wnPY7FrGefMWGeWBU BqN2emUNWmyd/a76lFET+y8E7q8wqZUqYLGsO1ZsVqNCGzz6+Y619rcjixXf/QVKavjEXmlmeSN i0zkqPJwb/gUw2bUKL1Hbh/THS7q25XSD5Hs6zkZXbjBlBXYFpOq/iPaDeJoP7rhb5PVnPGGVOf 16KQHJIal2qqeAjRGzWMPUYhM0uimJkGynNZxl9nHi62ouEts9IXuchYIhvQ== X-Received: by 2002:a05:6512:220d:b0:5aa:b6b:f6ec with SMTP id 2adb3069b0e04-5aea1f68d40mr2321858e87.42.1782488821629; Fri, 26 Jun 2026 08:47:01 -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 v4 17/25] xen/riscv: rename enum intc_version to intc_variant Date: Fri, 26 Jun 2026 17:46:26 +0200 Message-ID: <542b22adf7bfb2a60baba201ef89df260d9bfd1c.1782487661.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/1782488822-AC93A1CC-3BB7C0C2/10/73395122804 X-purgate-type: spam X-purgate-size: 1507 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488856285158500 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. Signed-off-by: Oleksii Kurochko 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 def15f792d62..126d56fb7ea8 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 46a0073c2d59..f7d42aa9fc40 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -8,7 +8,7 @@ #ifndef ASM__RISCV__INTERRUPT_CONTOLLER_H #define ASM__RISCV__INTERRUPT_CONTOLLER_H =20 -enum intc_version { +enum intc_variant { INTC_APLIC, }; =20 @@ -18,7 +18,7 @@ struct kernel_info; struct vcpu; =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 Sat Jul 4 20:59:50 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=1782488858; cv=none; d=zohomail.com; s=zohoarc; b=gnmUZTBJ/FeWe0ugs6CVKkTsmbBaBlnrk2urBWjRBxfIi738iTvY1+LL/Ew6n3+/A3v5TmBEOHf2uqaFIurnzpntX4XkgZfpfJwa5X68q2fCX3qVB4hC4qezlGbPqkRYMXpV16TWsy+wau+pA13s9tYnE+BmZL+X/NdDNDjG4B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488858; 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=ayLS/4Tj1pdUVipiDBa+IiAffN+x6DQ9eb41/7qATdY=; b=Tyi3VyFC88WAspsQvi66XZixR3IbdP4727N6+fWO0bSTqi7KoVHX/NY9X9WtzMoYBILfXt5/sRTfRDXItWt5xGa/CwpehsIU/+bTRqfRRcrA8BiJaGzzKN4dmmd9llsgIejrqWYNGFLc30md/vmMw6OSe3sbCuBizGcPmyaSAlg= 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 1782488858313121.5435636236; Fri, 26 Jun 2026 08:47:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346294.1604856 (Exim 4.92) (envelope-from ) id 1wd8lo-000492-54; Fri, 26 Jun 2026 15:47:08 +0000 Received: by outflank-mailman (output) from mailman id 1346294.1604856; Fri, 26 Jun 2026 15:47:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8ln-0003yp-2j; Fri, 26 Jun 2026 15:47:07 +0000 Received: by outflank-mailman (input) for mailman id 1346294; Fri, 26 Jun 2026 15:47:04 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lk-0003SW-Gj for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:04 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lj-00D1eP-T7 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:03 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ef7-5cb7-0a2a0a5109dd-0a2a4505e2d0-6 for ; Fri, 26 Jun 2026 17:47:03 +0200 Received: from [209.85.167.41] (helo=mail-lf1-f41.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef7-3cb2-0a2a45050019-d155a729b04d-3 for ; Fri, 26 Jun 2026 17:47:03 +0200 Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5ad58f31846so1048619e87.2 for ; Fri, 26 Jun 2026 08:47:03 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:02 -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=1782488823; x=1783093623; 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=ayLS/4Tj1pdUVipiDBa+IiAffN+x6DQ9eb41/7qATdY=; b=HEvLfG4D39IkI0Eb3HpoIhrttyISSxWWWkdiIO/N6ReJJ+6kyq0lFcTUtI5Wbt9zoU sZqgqD8aFI+LsvosqqA2jMDcSmUg9Ik5x19YiQyHhGHsafTTDchDUV+9yUckk/kG4JUS jRd91Fk1vv/I6kvke145Eki1j3+TNaoNICvINsOaxlROYivtw/FFKPrw5P2AyRUkyune lx9HpAhiIkQ+fiARJX4MoGH0tsh+9PysWC8jj17VXMq9HRtxbwlxNEA1Osa0MYa2lUIM YER0Qpkck8FrQU6EX3AM5K8bVadsQgj2nKvRLmDKgTtlzLjjeDoKSF5gScL2x9idN7oT 9Blw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488823; x=1783093623; 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=ayLS/4Tj1pdUVipiDBa+IiAffN+x6DQ9eb41/7qATdY=; b=qIgpNVnzbQGKEsHu5IQJqn6Wgs7BjOTlIXaDFUHxIMw/kCowvbfLOQyi2e/bcjddrk /Pyq2YTFWwPO4Bmh0QRXSXPZLdQNI9KEeljSwS4QGGe45x8UgLCeccuCYXhaVCo9/mmv OjK6uQ2fcfl3dkkXouKW+9mk1jHnvPPKrFPlvjb3DRuyPm3dewmKBWyo8nc3Vyk8nNQ9 Z+yTem38z5JCP0WPFJ8lsZIgGwRRma/mWF7mOmtbPy+Xina1FPRep9tQoTC/9GfeHT2O p83oFpD3LTNp5FAjAWYdMq+HbbVY3V0xyuKgMcyGPd9ZjFoQk2NBs1EbquohWhX7C+PC mKBQ== X-Gm-Message-State: AOJu0Yz1xby/z2hx8TTV1RPjDB652zYt0Yp3QcnHwZA7r4rW+uZTRH66 ZEj8NKo8wRTn+WmV8hN5rMd6RAw+6iXwL/xse3J5GDsrz0T8tbonox1T1h3Jcw== X-Gm-Gg: AfdE7cllAcXOXwRmtfoVRP8RXDGslNTGMViIuSSs1qCh6zDVmNNLj+E8E3ZQ2SqJI9j Q8b2rX0xRzKdOqm1t0Gede0CN4xmhraoORzLOh+9VcwdpUFg34rQ/vZASG7/PUueSFmfYUSbn3q nJhLfI3sBfLh5okNeIP5oAkpW9tTh3MrySulFaaOaVbiVMuxlvjmPzhBnjH8X4BbS1fW7DKZVAD M2ZhknUFYKZcRAfClyM3ALkIHNDje6nG0h/Diwr2hwppJi47mbPtdoWtPBArNqB3R1Aw+Gj84iZ E4rLGeM31Va2u8cBOYuyKac8TmazHc99tv0j++aQBs41auMl8xZnRAoObhABX05KfHv+IPnA1wN X/z03FGjvLBzEDdTEecYwE3Q+H2TWum6MJkIR1PbeNLqSEFHA4sey0KLpx+vGXqhDBglpSuiKfb Me5DHM5583dTdYdksF0Kc3oIXHbBBXKkDfjbAZF36cZgLUIMt9DSAG+peeAA== X-Received: by 2002:a05:6512:3983:b0:5aa:6e86:55e5 with SMTP id 2adb3069b0e04-5aea945b98emr249770e87.13.1782488822877; Fri, 26 Jun 2026 08:47:02 -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 v4 18/25] xen/riscv: introduce (de)initialization helpers for vINTC Date: Fri, 26 Jun 2026 17:46:27 +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-c201ff/1782488823-17B192B8-1FB907BE/10/73395122804 X-purgate-type: spam X-purgate-size: 3430 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488860131158500 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 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 129e775c52cb..3499c25dcfe0 100644 --- a/xen/arch/riscv/domain.c +++ b/xen/arch/riscv/domain.c @@ -309,6 +309,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 f7d42aa9fc40..62260155dc6b 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -75,4 +75,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..0eb7eb924e9c 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("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 Sat Jul 4 20:59:50 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=1782488852; cv=none; d=zohomail.com; s=zohoarc; b=KvUlBdUOrpUXckBoaAvZQECNShSegPJHtM2TiNmkn8UAcblleZQ2ErGIe/zftrqsM3VbDAQiueLfHQ6CxhZS91JAVYBM9sPJJSI56wloHyA36RTPqQuKT7b9Z+lh4PXoqHYNV0i60N/Z+lM2X/CYoJw/UtTqjMLWHqsgdyLguiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488852; 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=d+KWRQx/XjRfjBiOa3Y3HELI1/yEcgsVLINlQEFSIzQ=; b=MNssftUeWnmoRN2UdC8WJd/qejLCUiUOjyipYjcRQpWGzzrImOSGidbf6FJdnzcNA+BepQjO2CpLheJEirOwFkjFzXEQRGA8pJvbxd8zII41R+Kgf6G+d9l/yE0BbfP2ZzM6OJiPmZKy9oLsTqRy+vza735tMlR4vAHki3t14yk= 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 1782488852951477.4051157510529; Fri, 26 Jun 2026 08:47:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346296.1604863 (Exim 4.92) (envelope-from ) id 1wd8lq-0004QW-0X; Fri, 26 Jun 2026 15:47:10 +0000 Received: by outflank-mailman (output) from mailman id 1346296.1604863; Fri, 26 Jun 2026 15:47:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lo-0004Ky-LD; Fri, 26 Jun 2026 15:47:08 +0000 Received: by outflank-mailman (input) for mailman id 1346296; Fri, 26 Jun 2026 15:47:06 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8ll-0003hC-E8 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lk-008hTo-Pz for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:04 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eed-2eae-0a2a0a5409dd-0a2a4504e35c-30 for ; Fri, 26 Jun 2026 17:47:04 +0200 Received: from [209.85.208.180] (helo=mail-lj1-f180.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef8-a01d-0a2a45040019-d155d0b4b4c1-3 for ; Fri, 26 Jun 2026 17:47:04 +0200 Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-396771119c4so10049121fa.0 for ; Fri, 26 Jun 2026 08:47:04 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782488824; x=1783093624; 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=d+KWRQx/XjRfjBiOa3Y3HELI1/yEcgsVLINlQEFSIzQ=; b=lK1vTxfhFSjr5/5Ru+Ya5TifHS83nMCNC08nEBifgK3uHYgVDNAHBe4leqyvC3J/zO h7d08hUS5rjrsfpohRKNwfS5hFGr3kfp7zyBqQYLysYCONw3Dgsd4B3+1YvQSbhp/GV2 LnmMLMWjNsjTzWXdqYSZF9f6cMy3a2f2SEN8nHv7MhRetd1+aaCGYtW8VpzYSOWCknrK GiQnMk1Ze0PqKFAH7rDBk6alKhbs9NZ6djuvRD+kEmzrVKJlTVvI/p8d9SIneNXJcRJO JJMhgcnLrlcnhqz96qMaRhwWvrgvlGd09cDNkVn0+VTLnd70gg/bp3MQouERepUxZRSI 7YvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488824; x=1783093624; 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=d+KWRQx/XjRfjBiOa3Y3HELI1/yEcgsVLINlQEFSIzQ=; b=HhalDUbl4zDAY/VaTIAdEQwUUaxYqFnDsuNVnim3rD06YRHC1EDeALEwjT03CO6njl BNaDbI8GJdYAHZWZ7x9RguiIwl9aq60dKvxYD2KK6tbTOXcFfnkxuhlDYkrhBhT40PGO rInZCAfseh8P7ieQqMj0uqidzfkTNnUwjiBJq7+JidEaUBcgsCpU4k9kPzv6SlZTQOzB mBb6OtfJVhA5OOp/8NS83JQjwzdnL5+lof8iaYRgLKlE3Ywh1Q8yDUw0cs1eXlxFyBwq dNm16axtZKu8VLjsqA3eHeYZyHu+XgKENIV/9n4TPrrcDJHJDvjKjvCRuiWbsmk/zmDI t8xg== X-Gm-Message-State: AOJu0Yz9XdiJPthIpdwVV8zc7vLNhEGUkjBc+hCnJRNe5/TsbudWV4qS l4e/UpUp8a5nFJF33BC0C8i9imPb2Sn0NMAUxkE7BN2JfgUtFwRGHWGK4J2Wbw== X-Gm-Gg: AfdE7cmBRzOVkfd5gX4hK0auqMEc3uRt+k/WiOEJ3X9gMN0xf/iSZ4fHuw37XagTC2r tncmSmCVF2t9ijZh++2kBZdi9A60hGpKw9qi58XZyFv7rG7RC/g9yxBX5essoW7ALKbtS+ClNy1 iLAtj2MRRIkh4z79dDdnVpm2DV4zqOUrxDztqi5HKfyp4saYHkNP01F4cwsDZBJ+d9k7Qll/PqW 27B/zPUR5gNO1970t2orWqMqFk1tixPTkoPkMNSKrjqKI+KhQa+qyGcIgGkxnb5iFtsNueq6gtU MlJtRH8FbbsACa3mNud5ckhI6am6NoVU/VrKdHJpg74oyPxpRif78ubZg2234bOI+JOKlGX53M6 uLYckNYXSuP7hqxcy4rcirDT6V/O1Z6WkRP18NKtYZYc/IBvJMwXZ+DgJ6micLebo4x1piIrS7f 20YMXPPsQmkbSqHPHh7zs1SIihTr2hkatOaHZXsZoAXjvhHLwxLVAdpYg2vQ== X-Received: by 2002:a05:6512:258c:b0:5ad:3a58:1bd2 with SMTP id 2adb3069b0e04-5aea1f40f8dmr2325136e87.3.1782488823833; Fri, 26 Jun 2026 08:47:03 -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 v4 19/25] xen/riscv: generate IMSIC DT node for guest domains Date: Fri, 26 Jun 2026 17:46:28 +0200 Message-ID: <424c223b97e9d27aa4ef4e05e2d5c8d0c426324c.1782487661.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/1782488824-2C5A91CC-13AE7A8C/10/73395122804 X-purgate-type: spam X-purgate-size: 8276 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488854166158500 Content-Type: text/plain; charset="utf-8" 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 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 | 137 ++++++++++++++++++++++ xen/arch/riscv/include/asm/guest-layout.h | 6 + 2 files changed, 143 insertions(+) diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 7068d6a7fef1..e6919f491193 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,16 @@ 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 __read_mostly guest_num_msis; + +#define GUEST_IMSIC_COMPATIBLE "riscv,imsics" +#define GUEST_IMSIC_NUM_MSIS 255 + #define IMSIC_DISABLE_EIDELIVERY 0 #define IMSIC_ENABLE_EIDELIVERY 1 #define IMSIC_DISABLE_EITHRESHOLD 1 @@ -285,6 +299,11 @@ static int imsic_parse_node(const struct dt_device_nod= e *node, return -ENOENT; } =20 + if ( dt_property_read_u32(node, "riscv,num-guest-ids", &tmp) ) + guest_num_msis =3D tmp; + else + guest_num_msis =3D IMSIC_MAX_ID; + if ( (imsic_cfg.nr_ids < IMSIC_MIN_ID) || (imsic_cfg.nr_ids > IMSIC_MAX_ID) ) { @@ -522,3 +541,121 @@ 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, sizeof(buf), "/cpus/cpu@%u/interrupt-controller", cp= u); + 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; + unsigned int num_msis =3D min(GUEST_IMSIC_NUM_MSIS + 0U, guest_num_msi= s); + + 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", 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 /* --=20 2.54.0 From nobody Sat Jul 4 20:59:50 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=1782488860; cv=none; d=zohomail.com; s=zohoarc; b=ElWj5nMGdABxWHg02Vj1HMkB1RN8suso4sT7hGrr+Pcrpdd/Xr7n7gav2A5x9wRgYnKScBAhoxQDpGPJtvM9604TgGbpHyanI9nQX4Vxjk+2LuXAy8j1SqxGoKaX/FG002G9wEdVyxhCGt2yAS78eFb3caOt/h0oedfwYNp+aWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488860; 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=ys49SiCuwqKT2WlVxYaggJAPMz33LKatvfN3jVmdVs4=; b=MlWpqop3zqRaGOADPgolCF5LHr5C5Hp7sRZT1dzp1msev+EsUzOTLKvdFre487Ed4/PdO3f39WmJuPEkHMH3kiRfJGrqK6CIOj1I22Vh62v2CFaIOab1R+MYi/XuT6zQV0ghQePc/SoC6uGJyFlWhB0WUWRJm8y55ZwvngEXqzs= 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 1782488860629936.7425085385283; Fri, 26 Jun 2026 08:47:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346297.1604873 (Exim 4.92) (envelope-from ) id 1wd8lt-00052O-SJ; Fri, 26 Jun 2026 15:47:13 +0000 Received: by outflank-mailman (output) from mailman id 1346297.1604873; Fri, 26 Jun 2026 15:47:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8ls-0004w8-2T; Fri, 26 Jun 2026 15:47:12 +0000 Received: by outflank-mailman (input) for mailman id 1346297; Fri, 26 Jun 2026 15:47:07 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lm-0003uT-OC for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lm-00D1eP-3W for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:06 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eeb-5cb7-0a2a0a5109dd-0a2a4508b62c-12 for ; Fri, 26 Jun 2026 17:47:06 +0200 Received: from [209.85.208.169] (helo=mail-lj1-f169.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9ef9-edec-0a2a45080019-d155d0a9dce3-3 for ; Fri, 26 Jun 2026 17:47:05 +0200 Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-3997a448ecbso12138071fa.0 for ; Fri, 26 Jun 2026 08:47:05 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:04 -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=1782488825; x=1783093625; 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=ys49SiCuwqKT2WlVxYaggJAPMz33LKatvfN3jVmdVs4=; b=lYWtz1rQ/+MA3NKJJi6GZk8A1qQsITtXfPNrrDvQbHk9dQUqh5iMpUzOtsgFsJQL9u F/q/7Briv7jpKuPUEA4BQxwxPdd8XL1zf3bEkX4+QYvuFdKzGQP9ze4wpOG4afxixu9L QyyA4VoU+dCzXj7sMKm3o3XbK7YIBDm0tq8zwz0SfYls3FLm1CCPwRqLQU9SBq/A/tr3 fnrWhUfKtjBdoT5zUiENQdxrYQ7ISurxvul3tVy4V8MiMyXGnFq36p1o+JGEnahxKlv+ f7URirX0JM/URJgKoEyXuJ+eyUW9mdUQppYi4eFIyxpSYRACvg3XXm5sqje+2TEDZqm8 QBEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488825; x=1783093625; 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=ys49SiCuwqKT2WlVxYaggJAPMz33LKatvfN3jVmdVs4=; b=fptCSNVquGQaHCJXbkw6vWAMV6wWA08av5g5kfO7WVkRLYpyTAIKabEVQ+Z0EkAcfJ owejmU+jdW1ywpZJ9y/bV+rgUQINc69pC8Ov6jyAxtoL4OBePmZyeTwD4mtOChfDxCF1 rPh8sTdFpyM3AjYazN0YZ59vLsaSa64Qf5DcBNDwY7fiKFIB5biXI1J8QP5KzXts/3Kw j2/943Efc6cEdNPWRB34G6kUz9usaIBnDwiGYNq5cokkODAVONh+igOpIhcvjXd4MDqE 1LzdR3KLebAclM/WSF3z/5+ebbAinejZVkgHgAVlUNodyOs4uNx7ef7vbRv9RZH1Sh/j RYww== X-Gm-Message-State: AOJu0Yy7h2Rlc8Z6fRtnhGAb/KWotp6Tv99r1/NDcPSnXDCNaSOBr+Mo TmPtrV/O6Fr6r9TS1pbKpKjV71w6aZ+Kuhwcsqm36CNQ/pxRReFRRMJ7wAYYsw== X-Gm-Gg: AfdE7cmUIRQZr/0z44kUgRTYAmdhPNRCN853uXnFIhzvWjADI3IGrG850S/VfV6OxuI 9WDfz+U30Fq4Ycx7MxQ7z8x9Po27pbUgvimWP7ixnNPNnsdc9VdLOMIc9cOA+dKLqtSeYBMgn6o sgAvlXNFTJw5gwghFZRSKhYA5vqfhAafzodVFGrbBXATGr3q+z+OhAWH0BAOg1dEA3EQzv952Ab gewLQWicbXK5UW0IdguZEA72cMEgbJ6IMr/cJ0t72GOKNrmaxdjas9rY963JtTewsZpr4Pv4Z5L fSzxII1kp2kTShjQaw1ufrB5prnGie+6AnyxUjj3DRXzPTeg8J4zF7J7YjEu14cMxaEwvmESNPx u04sTOUolBXsSDah8s22+wLaQ14rZ3gVjzE1rOmkopVIKDapL92QZQn7V1mzRcCKF+szT9I6djR UIpUk4hT0eu4jP81R8ollfPXFgXObInbOz5PQWOU/2WY8a2W2tva+qoKyzazWue7jygVTm X-Received: by 2002:ac2:5695:0:b0:5ae:a9ec:9fc2 with SMTP id 2adb3069b0e04-5aea9eca34bmr132674e87.61.1782488824963; Fri, 26 Jun 2026 08:47:04 -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 v4 20/25] xen/riscv: create APLIC DT node for guest domains Date: Fri, 26 Jun 2026 17:46:29 +0200 Message-ID: <2bab716741ae436c7b92989d7613dac620166b89.1782487661.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/1782488825-431393FC-1AC0C4EF/10/73395122804 X-purgate-type: spam X-purgate-size: 7584 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488862387158501 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 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/include/asm/aplic.h | 8 +++ xen/arch/riscv/include/asm/guest-layout.h | 6 ++ xen/arch/riscv/include/asm/imsic.h | 3 + xen/arch/riscv/vaplic.c | 76 +++++++++++++++++++++++ 4 files changed, 93 insertions(+) diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/as= m/aplic.h index 2e606b8cd947..3d870fbfb387 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -30,6 +30,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/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 */ diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index 6562b25f0abb..6e409d9b732b 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,11 @@ =20 #include "aplic-priv.h" =20 +#define VAPLIC_COMPATIBLE "riscv,aplic" +#define VAPLIC_NUM_SOURCES 96 + +#define FDT_VAPLIC_INT_CELLS 2 + static int cf_check vaplic_init(struct vcpu *v) { return vcpu_imsic_init(v); @@ -29,6 +36,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 =3D 0; + 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", VAPLIC_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 +118,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 Sat Jul 4 20:59:50 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=1782488857; cv=none; d=zohomail.com; s=zohoarc; b=b2TUfuZAa0iDOxU6braN8mL7Znef8e88MykuABizPHejKVaZIQbl6oE0kDlN8hNbhB3lCa11rYEdUCamJFgceso8ZExH5pmwgiPBLca7PJeZj0TbCLw103DEDUDNJ463swpGyAM5kbo4N+fM/W5JM2iDshbFgXmmiWIfHP4Ohiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488857; 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=tE18Q/Zu8AIcss7x9lzMh64k+xShMcKC9jAdFBx8PaU=; b=VUxcSuiNV3kr4UQeWQSN6V9QKColW83kJFnez4o38bUENnIp/nrTX12A+S6jX3EEL+TYcB/kmeB905EdwI8urpIrQeIKFY778Y9nRjH57ZR6nwRm2y5QC6XPlItaNtgnlpXLTVfkxp4nMERFi1gCnZ78lu2eslpINtrSLwHvBw4= 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 1782488857534175.1519349338921; Fri, 26 Jun 2026 08:47:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346301.1604879 (Exim 4.92) (envelope-from ) id 1wd8lv-0005Pu-9N; Fri, 26 Jun 2026 15:47:15 +0000 Received: by outflank-mailman (output) from mailman id 1346301.1604879; Fri, 26 Jun 2026 15:47:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lt-0005KK-Rf; Fri, 26 Jun 2026 15:47:13 +0000 Received: by outflank-mailman (input) for mailman id 1346301; Fri, 26 Jun 2026 15:47:08 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8ln-00048G-PT for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8ln-004aSr-41 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:07 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ef9-bab6-0a2a0a5309dd-0a2a450cac98-12 for ; Fri, 26 Jun 2026 17:47:07 +0200 Received: from [209.85.167.51] (helo=mail-lf1-f51.google.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9efa-f399-0a2a450c0019-d155a733b057-3 for ; Fri, 26 Jun 2026 17:47:07 +0200 Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5ad58f31846so1048635e87.2 for ; Fri, 26 Jun 2026 08:47:06 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:05 -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=1782488826; x=1783093626; 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=tE18Q/Zu8AIcss7x9lzMh64k+xShMcKC9jAdFBx8PaU=; b=Mr5J6mPXzFDsrgwQOcnRv5t/Ptz4QeKITTMsy2Wd/gJz12KBxBdXVz3SV4ZS1oImZe 4tqIZCnGMr6VBCF6Bi39JnWoB4p0pbr2lGdwjrdh5Zb6PhHuUTUU5yB0Q9tebRAxGszW /02rF4gwqwFw2ug/+sVhPiykwJxaLqwE+PsjsW0ox9qpcVNbWGYcN8qEFUZF2Ics4Qrx V15Imutauoc/LJykYcVDjEnGwbzo1vdPK0kbbu/m11AtU7MYWRm1cQetEswOazv4Syuq QX2sGbuZA2L+whPIMSh6jKkR4iU/c2dWfIqvkkMIZ6IwvAKDCDSGkibl10dYLYbe+3Gg V5kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488826; x=1783093626; 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=tE18Q/Zu8AIcss7x9lzMh64k+xShMcKC9jAdFBx8PaU=; b=aQCR7z0R6RBbW+Kjdf3iV2nEf/LkPEUYLmtN8NBVlyZULJMI76WNXdtjusTNq3ejnm SsEydevdzqTIWZEC4iWA+/73FOlL647bwMnQIgwwl4aCXOoqKHl7riu8SSZQcUW65Rxr hLVYEiygbCAy1zUOPA9xDNtX2xUj2avTQ7redFMbwwGvjrGDjVGVvW4NufaQLzijGt7o RNhoULM6jzHfDhMVjhoa1OMnfTwe8QDdImDjgBsvd9el8/O5UNsmW1L5k5ibVx6MKFzH 1iLQ6f3YuKHCqjaSh3acXnBKD5KYbGgQbM0QjBzcBDQWmW6I6pjsUj+BHIjZ3E+MNLWm mQHQ== X-Gm-Message-State: AOJu0YxOCY2KZmLX9Xiq0ZC0AoYYcpDnfv6TUcJvbQbG7894fCmTuZNz dBBdi8BkHYCL9Fnwk9BHbvZ1ckNfZNilAR03lrJvWJmS++BSXeRTdcj2S5DhAA== X-Gm-Gg: AfdE7cmk3N1/yVT0krZc5utbZTiKr2GpLXmO3uL6VSL0CU+ftrKT0cEHm0ZoWyPOTav HGu2IxuJS0UpGEcUptA9vnFiJHRoN9W/ekDwgytlcpH5FKCAzKnpkH/LA+DxVG+5whKQ7vZA4kL Es5a9w/u1XnowUQKoTK/5sBTdze1vCbRCIdGlxUnOO6kjjlT3SDNlMX7xal8G8oToIXZv/652fZ p4g0h3osg2Crzsvpd5Fo5OP3q2mA0vw7ORK3cWm7Nw42Hh8x4/5LFHTTfvZLXLpnPJ5sGYegRFF xKIw9APezN6gxc6us++R8Bv6D72SKfOD691SzmnjqbPqWJGKECe4vKhxlmckP7BLniBUh2iezMZ 7i3LOHDNdV8g9hthSg88cN7KCB7LUTxkfXrbtpU8ob12IKJdn9XMSBZDLHDggq5c+W8rFT1qkSR +mSy4geDtvc+2NhYCHKfsMk6ZFLzY7Vq339ws/X2zIHNQ5OOcrkidkTfo8sw== X-Received: by 2002:a05:6512:68f:b0:5ad:4f88:30ec with SMTP id 2adb3069b0e04-5aea944ffe5mr386809e87.2.1782488826185; Fri, 26 Jun 2026 08:47:06 -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 v4 21/25] xen/riscv: implement IRQ routing for device passthrough Date: Fri, 26 Jun 2026 17:46:30 +0200 Message-ID: <472a77604d35a0bc2a75b71f250fd67b63afde4c.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d25034/1782488827-0FF33D51-45140EBE/10/73395122804 X-purgate-type: spam X-purgate-size: 20699 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488858190158500 Content-Type: text/plain; charset="utf-8" dom0less device passthrough requires granting guest domains access to device interrupts. Introduce map_device_irqs_to_domain() to enumerate a DT node's interrupt properties, skipping those not owned by the primary interrupt controller (as at the moment I haven't seen usages of it), and map_irq_to_domain() to grant domain access and configure Xen's interrupt descriptor accordingly. Sharing IRQ between domains is rejected. Both map_irq_to_domain() and map_device_irqs_to_domain() are marked __overlay_init, mirroring Arm: without CONFIG_OVERLAY_DTB this expands to __init, so the functions are init-only and need no XSM check; with CONFIG_OVERLAY_DTB they become runtime-callable, but the only runtime entry point is dt_overlay_domctl(), which performs the XSM checks at the domctl layer. RISC-V does not wire up DT overlay yet, so today these are strictly __init; if/when overlay support is added, the domctl-level XSM gating must be added together with it, as on Arm. route_irq_to_guest() and release_irq() manage irq_desc ownership for guest-assigned interrupts. Each assignment carries a small irq_guest structure as irqaction::dev_id, recording the owning domain and virtual IRQ number which is 1:1 mapped to physical IRQ number. A per-domain vIRQ allocation bitmap (used_irqs in struct vintc), managed by vintc_reserve_virq(), prevents the same vIRQ being claimed twice. Host and guest interrupts may differ in some operations (EOI timing in particular, possibly others): a host IRQ is completed once Xen's handler runs, whereas a passthrough IRQ must defer the physical completion until the guest issues its own EOI, otherwise a still-asserted level line would immediately retrigger and storm. This affects only the .end callback; the rest of hw_interrupt_type is shared, hence the separate host and guest hw_interrupt_type instances. With APLIC+IMSIC, guest interrupts are delivered directly by hardware through the IMSIC, bypassing do_IRQ(). The _IRQ_GUEST branch in do_IRQ() is therefore left as BUG() until a platform without direct IMSIC delivery is encountered. Signed-off-by: Oleksii Kurochko --- Changes in 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 | 95 ++++++++++++ xen/arch/riscv/include/asm/intc.h | 9 ++ xen/arch/riscv/include/asm/irq.h | 5 + xen/arch/riscv/intc.c | 44 ++++++ xen/arch/riscv/irq.c | 230 ++++++++++++++++++++++++++++++ xen/arch/riscv/vaplic.c | 2 + 8 files changed, 390 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 126d56fb7ea8..96ea475e914b 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -304,9 +304,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..8bfb9926e8ef --- /dev/null +++ b/xen/arch/riscv/device.c @@ -0,0 +1,95 @@ +/* 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." + "Connected 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 62260155dc6b..f16dc4384e2c 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -13,6 +13,7 @@ enum intc_variant { }; =20 struct cpu_user_regs; +struct domain; struct irq_desc; struct kernel_info; struct vcpu; @@ -32,6 +33,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 */ @@ -61,6 +65,8 @@ struct vintc_ops { }; =20 struct vintc { + unsigned int nr_virqs; + unsigned long *used_irqs; const struct vintc_init_ops *init_ops; const struct vintc_ops *ops; }; @@ -72,10 +78,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 0eb7eb924e9c..447b21db452b 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,28 @@ 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); =20 switch ( variant ) { @@ -117,4 +151,14 @@ void domain_vintc_deinit(struct domain *d) default: break; } + + XVFREE(d->arch.vintc->used_irqs); +} + +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..a308a6978752 100644 --- a/xen/arch/riscv/irq.c +++ b/xen/arch/riscv/irq.c @@ -12,11 +12,20 @@ #include #include #include +#include #include +#include =20 #include #include =20 +/* Describe an IRQ assigned to a guest */ +struct irq_guest +{ + struct domain *d; + unsigned int virq; +}; + static irq_desc_t irq_desc[NR_IRQS]; =20 static bool irq_validate_new_type(unsigned int curr, unsigned int new) @@ -192,6 +201,15 @@ 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 ) + /* + * As at the moment APLIC + IMSIC is used for guest interrupts will + * be directly passed to guest. But if/when IMSIC won't be availab= le + * all interrupts will go through Xenand here an irq injection + * will be necessary to do. + */ + panic("unimplemented"); + if ( desc->status & IRQ_DISABLED ) goto out; =20 @@ -221,3 +239,215 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int = irq) spin_unlock(&desc->lock); irq_exit(); } + +static inline struct irq_guest *irq_get_guest_info(struct irq_desc *desc) +{ + ASSERT(spin_is_locked(&desc->lock)); + ASSERT(test_bit(_IRQ_GUEST, &desc->status)); + ASSERT(desc->action !=3D NULL); + + return desc->action->dev_id; +} + +static inline struct domain *irq_get_domain(struct irq_desc *desc) +{ + return irq_get_guest_info(desc)->d; +} + +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; + + 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 ) + { + spin_unlock_irqrestore(&desc->lock, flags); + return -EBUSY; + } + + /* + * Clear _IRQ_GUEST while still holding the lock so that a concurrent + * release_guest_irq() for the same IRQ observes it and bails out, rat= her + * than capturing the same 'info' and double-freeing it below. + */ + clear_bit(_IRQ_GUEST, &desc->status); + + spin_unlock_irqrestore(&desc->lock, flags); + + release_irq(desc->irq, info); + xvfree(info); + + return 0; + + unlock_err: + spin_unlock_irqrestore(&desc->lock, flags); + return -EINVAL; +} + +/* 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; + + desc =3D irq_to_desc(irq); + + action =3D xvmalloc(struct irqaction); + if ( !action ) + return -ENOMEM; + + info =3D xvmalloc(struct irq_guest); + if ( !info ) + { + xvfree(action); + return -ENOMEM; + } + + info->d =3D d; + info->virq =3D virq; + + 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_domain(desc); + + 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); + goto free_info; + } + + return 0; + + out: + spin_unlock_irqrestore(&desc->lock, flags); + xvfree(action); + free_info: + xvfree(info); + + return retval; +} diff --git a/xen/arch/riscv/vaplic.c b/xen/arch/riscv/vaplic.c index 6e409d9b732b..6256d75091b2 100644 --- a/xen/arch/riscv/vaplic.c +++ b/xen/arch/riscv/vaplic.c @@ -123,6 +123,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 VAPLIC_NUM_SOURCES; + return 0; } =20 --=20 2.54.0 From nobody Sat Jul 4 20:59:50 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=1782488875; cv=none; d=zohomail.com; s=zohoarc; b=djxlw5GJIOeoVs3pIR9Gp3yJAGJz53rjGUiY1tCEe4GoIQNeSc6U2MJdIk5tQroZm5MeBXkXl+UXtmraY2spKZP7b0DsNa3rcG0tYiAOuHjJ6uBJBMe4+v9BSUT7QNNs8/RQ0FGI8hQFHHJHknBp+0ChH4GH1qXDG9L0bpr6UOU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488875; 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=tGVs0W5yuF//qwARTLwYow22/uS7Po5fojk55jJOeWQ=; b=BjdEakwAJ17b3SDKrDBHDM7KCLFwZzJe3owB07AcMkt1yuMYVB9lQXv0tAHpT0NOZkj2OACSjaUC/SuH7NDg0uaP1R3ZXV29hudFwen6D2Hn7NkwkfM4cZdQyYMz7+fCziffSvNrWUB+TxHkO8oVISQAagp42vTyj2uZsT45Z54= 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 1782488875956453.93031709072284; Fri, 26 Jun 2026 08:47:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346303.1604887 (Exim 4.92) (envelope-from ) id 1wd8lx-00062z-TK; Fri, 26 Jun 2026 15:47:17 +0000 Received: by outflank-mailman (output) from mailman id 1346303.1604887; Fri, 26 Jun 2026 15:47:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lw-0005xC-Ek; Fri, 26 Jun 2026 15:47:16 +0000 Received: by outflank-mailman (input) for mailman id 1346303; Fri, 26 Jun 2026 15:47:09 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lo-0004HM-Hd for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8ln-008hTo-UF for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:07 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9ec9-2eae-0a2a0a5409dd-0a2a45038a38-48 for ; Fri, 26 Jun 2026 17:47:07 +0200 Received: from [209.85.167.50] (helo=mail-lf1-f50.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9efb-ec1a-0a2a45030019-d155a732d90d-3 for ; Fri, 26 Jun 2026 17:47:07 +0200 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5aea915df15so438567e87.3 for ; Fri, 26 Jun 2026 08:47:07 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:06 -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=1782488827; x=1783093627; 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=tGVs0W5yuF//qwARTLwYow22/uS7Po5fojk55jJOeWQ=; b=ZRHLVDGLanKzMM7ZWMUVg9kgeNY3HQmQRt86jnFNrit/+NUC2f4fEXrABOqwYyLAKc 229BR7nB+OgXNPu225bpcP694JKcJOHxIDmq12SDHJ5lewAY3w5caPjTpLdFNaOiS6vK XeaE8szFGlF0psM/VGT4x4Xs6rTAm/cJCm6jzNrInwuiVSyOa9+s6IHZUx6ysHv/dzMt QFttU9Y0CmZG0k6LUoIqUBbkwPxwMGaYq3N5ei06Dv10QsIJsmIhxc5uMlXLLDYahdAY R2u4x1d1ABloub+P0kSW/b+2GxQaWPy4F1/b9ivwozHsLYslheC1j1R2BIjc6FdWk39J mBEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488827; x=1783093627; 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=tGVs0W5yuF//qwARTLwYow22/uS7Po5fojk55jJOeWQ=; b=JVwlKGK1EZ4khCgD20q7tRJ9Cn6wdJdf81hAT9LLSOQNUkdzV6J2FwPphWtUnoYPfs sfeNl3omxIsg8L//XCR0BhHRraDMrR/dUPk3gRa1IgEK4hCfbJj03VLv4FOoO2QiavgO TwPpfUW0mU3zQKTYWvKJXqC5JxFYU4M14SM6YX5yrRYmngbzFMqEUYQomEJqgVRLHSjY PfluhCTWT84ddwrH1hFslX7mvfhLczIsywHpgyRYguVSLVfUYI7T5WqknbQc0zE4jMll 6ATN8pY4C/qmvcOCAgd14wssKb6RkaR2ZgTQWEVsWEnlLu/ts6UBdoKSt0bah19Dmboe J7sA== X-Gm-Message-State: AOJu0YzDIgow/AvlzRBNJlP3q8JLI75TApWxvbkcDphjwdKIE0DmGYnn IJSvgch7DjGjI1kyerkJyn8u/hU8Ygv2FG+aw+sEDoegmQ34KmQ3Uv+/e/tZSQ== X-Gm-Gg: AfdE7cmcIUqSTBsQsPpGuN3/WU6h1dvIo8FQe185o4z4XU7i1gd92II4z+qKMPRum9g kXoBNWLyLIzGnAfSuoXhfGEwvshl9CiPvidjk0yeUpyOlfW7lrdM4/IqqJgqEdeYRoxrIEaKm2W F/vY1sc+ZdU+W4SQktguhGPjzAB6By6SyRbDXIiha2890fu3H3uXki0JwfHJoPeBrUCqH2UEMVg EYuuqcEQrDv7capbHZPwhTbVDz/1cM2bnL+fW8RSk+yp0Lox5k2I69kYoM3I0F2bJuqrLEHK9Wz Hnvtp2ZBGg5l7yKGdBRFh5t6jGbYNAn8w317K3CN5FhNPdPIAE7O92BhELAy+Eu9UFTUMw0Kt6z g+FDDWrbbDY9r7RvA5vE6yBp3+IZMaf7vES0zJ4WqHVQh98jnakRU/iSpbXyu1mGo5plPAsdlRR 4i4jmL/1SKCnHBR7ocvWYmW4YpBoZ4Hj574psZJl5jXx+NjRJj21zk+u+VAg== X-Received: by 2002:a05:6512:6085:b0:5ae:a488:cda8 with SMTP id 2adb3069b0e04-5aea488ce07mr1932782e87.42.1782488827120; Fri, 26 Jun 2026 08:47:07 -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 v4 22/25] xen/riscv: implement init_intc_phandle() Date: Fri, 26 Jun 2026 17:46:31 +0200 Message-ID: <3d06d182ab718707ddce2445f317bfd6e661fb5b.1782487661.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1782488827-BC7875D1-CF050ACD/10/73395122804 X-purgate-type: spam X-purgate-size: 1376 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488876181158500 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: - 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 Sat Jul 4 20:59:50 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=1782488872; cv=none; d=zohomail.com; s=zohoarc; b=YkqTye35Ud8hjC61VskMNbbdY6hpxhyLwCSINIqgornQmoz6ArWWiLgUxtH3ef/v7i8NfgAjEeYxWWwR3ByvV+yE4pKcKfzie1YQIFnDf9FB8EYvCbiGquoqOPWcPstaC939DiuRGVsHKbpnm+flyPPbsSKsIOzNPW45cBPkVIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488872; 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=q+nhDaDUJkCW0waY+Zvj1Fm8pm8i//taC/XFR+qPzKk=; b=l9qGFdOtbW9GvgEDvGETnr6srENxW/+/mEynpxOZF55t/3UGXnlmslVFEDAQPrfIyVgDO2udxeWscMpnWZptbspJG1tkVsGWpJMxkrQ4R9fpVyC2/v5Zl1G0ZfjW58mojphNq45BULfHijqk1+k7PJ46BfBPsgYiPIbrkkbY2u8= 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 1782488872510605.1351596789942; Fri, 26 Jun 2026 08:47:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346315.1604903 (Exim 4.92) (envelope-from ) id 1wd8m2-00070w-H4; Fri, 26 Jun 2026 15:47:22 +0000 Received: by outflank-mailman (output) from mailman id 1346315.1604903; Fri, 26 Jun 2026 15:47:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8m1-0006vH-34; Fri, 26 Jun 2026 15:47:21 +0000 Received: by outflank-mailman (input) for mailman id 1346315; Fri, 26 Jun 2026 15:47:13 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lr-0004ra-Hc for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:11 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lq-008hTo-SI for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:10 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eed-2eae-0a2a0a5409dd-0a2a4504e35c-38 for ; Fri, 26 Jun 2026 17:47:10 +0200 Received: from [209.85.167.52] (helo=mail-lf1-f52.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9efc-a01d-0a2a45040019-d155a734a43b-3 for ; Fri, 26 Jun 2026 17:47:08 +0200 Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5aea1f4dc7fso1077205e87.0 for ; Fri, 26 Jun 2026 08:47:08 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:07 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782488828; x=1783093628; 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=q+nhDaDUJkCW0waY+Zvj1Fm8pm8i//taC/XFR+qPzKk=; b=Tljjas2u/Tw+NXK7EKfGLuDIVxm2fBdJSTXze1DwjP0nHErpof1Moy4IvOw6vd6SiN QWGoQ9ilD+yn1jg16fdxCiWr7AeR90f2WFjcO90URuPKpaBVALO+b7gx4ZijP2baxrGf 3ktycjDVUTlJfV20xQv7aLBwQ8k6Z3R5CU1/mfByuUX/g7P+JnQBJRq84tueQa9brQ/5 InHdOqTATkvjaNWMLFryNfF5uRn0kaLvRWPw/cKc8dSyqjxUauM0DsvnfxV6UQYXfYV4 VEROcOhCSES70V2hPdMtbh9jK5JZs0hO88E++o5OL/zkvgv6wZTSkB9cRorLh7TnUI7m lICQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488828; x=1783093628; 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=q+nhDaDUJkCW0waY+Zvj1Fm8pm8i//taC/XFR+qPzKk=; b=CuFksLNGor2KCvfoX4/beHh15Z+rW3vtY8pUzl3Ps+mUFQKzpCIHnBlC2RLJb4Dy82 Dh1Rt299ITO324Zo5MyQoLXxMrf7cd0zx8MJRw+wBqW3YgcXBpo+ZGidbmDyWuB7oesw jI03RBXVDvYkYwc08WmbmzOn/dM29cQefO62Fisy+nRCkzSvEX69Yg7eVAfnLgH+wa24 OwD0KdzC8hSZvLYKSy+GXevuUEPo9QOQHKpiPXVkhNPsTrzmXJDeOw0yw2pyU4RFTWBG jY7mVZ8pw3+do6NpqHpuL1NNDc8kKNXNvb4yTU+oB07F5J18xMZbs7FjEVNo6W0pgtQx vSGQ== X-Gm-Message-State: AOJu0Ywwo5qg9n2Ga2BhjPcfOe0BMjqN/5xAgzuIw/FkCAs+8epncVjR k5pDnCL3JfXTITwiQ6jwAtxFPJqjKyZ0TILDK62k/B7Fr6iheyjycfKyDZ7nuQ== X-Gm-Gg: AfdE7cka8PO6vhq+mlaMcAMFfQgXNEAznimQZRNRBPrSUVrbmwfP/Vem48a/UUMlFvC VGd1l67izE2Dso5mG5tyy1js5X+C4kTam0EIICMwepkmd/D9MAztgFOq82p0pzOwG3Fh0QnHfgQ 57yXGqLbJyA6L+kHIc3V+6eDznWQseTQWhnlWOZuD1eVd8D81hnINBhjrBVRaJHF1Dy/Hm8/2D4 ZFysI2/+nQrzGX345vF6yB0wDh3BBTbSw5tLn4MzrnJH6a5i6ayfKoc5ofEYz9AT1afDoM4/rYJ A0ZFncnPXkrPv7esKx4Ri9yJlC9WkQg+z7IOA0S7yvTkYDPaAQUWMWwYz9cu8RzwLGhsWLaE2dR p7hZcNUyS4fx9DDrk9BYUvwgICD2ylq1MZoNO1ybH8AcGEyTPTeHz49Akt4C3tJSO1n6+QtxthS USSkLT1j6pT2KZke0ix1Z6nBGj1g76MeWz+Fqv2yWSr/fzZkGZClAyZuJqODPe4lnME2SV X-Received: by 2002:a05:6512:2251:b0:5aa:65a3:468c with SMTP id 2adb3069b0e04-5aea1e246f6mr2021690e87.7.1782488828078; Fri, 26 Jun 2026 08:47:08 -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 v4 23/25] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Fri, 26 Jun 2026 17:46:32 +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/1782488828-AF32F1CC-AC15FB50/10/73395122804 X-purgate-type: spam X-purgate-size: 1558 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488874193158500 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: - 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 Sat Jul 4 20:59:50 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=1782488875; cv=none; d=zohomail.com; s=zohoarc; b=eCQnTZoKIa9nsZGVmA5Reo2b79EemAOMiPyzI1/FclYdGora+UaXopBlfG5x1xzr5KhEL7rZDwsVpftYeXGwwwzbdGXdRpn9qGZ3CuG/iadk337/CN7nbQnOwPjoR3I2XyJG5Og7MEH6rCH+icNfvXpezRMdZKgR4MlHe+gXYFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488875; 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=oLh8fGIE1A466qmTuKBcUXl7JYmNxJHzlMuXubpIZxQ=; b=Qj+x4WBzuJMip8zr6DjHfgklxa1Yht81+/heyxSZcpBUVX+mML/jCdlytAH9LfusT5gJVqfklx+U2l32Tqna9ZiC4i5evGeuih4uxLFJFn1rXcCcl+ojI+rOm3pzt1SXCGJXaQ9g0ZNf9Dzhd/cUNt1QV+3wSuuV+RAFlzsrgKY= 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 1782488875890818.4843203933847; Fri, 26 Jun 2026 08:47:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346312.1604895 (Exim 4.92) (envelope-from ) id 1wd8m1-0006iu-6i; Fri, 26 Jun 2026 15:47:21 +0000 Received: by outflank-mailman (output) from mailman id 1346312.1604895; Fri, 26 Jun 2026 15:47:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wd8lz-0006ch-Hg; Fri, 26 Jun 2026 15:47:19 +0000 Received: by outflank-mailman (input) for mailman id 1346312; Fri, 26 Jun 2026 15:47:11 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8lq-0004h7-HV for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lp-00Ad7h-S1 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:09 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9efb-e002-0a2a0a5209dd-0a2a450bedca-2 for ; Fri, 26 Jun 2026 17:47:09 +0200 Received: from [209.85.208.175] (helo=mail-lj1-f175.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9efd-ac48-0a2a450b0019-d155d0afedc1-3 for ; Fri, 26 Jun 2026 17:47:09 +0200 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-3996c9eeebeso9996901fa.1 for ; Fri, 26 Jun 2026 08:47:09 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782488829; x=1783093629; 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=oLh8fGIE1A466qmTuKBcUXl7JYmNxJHzlMuXubpIZxQ=; b=ZFTUDu8+gU0m2A+bykZlaw6AHRzL4bOB/+9lXEU2zkB2fhzGqSoW1u3qh8PBT8wtfN aDaSZisKP6PsBtVcNwGinrCeY18uKvTM1nKU9kxN6hxF1XoZ9txxm3PXtJesX2zVyuB9 W7+2cHgPCoqi37VKDkogpsPXyxAw3liQYfit84b+PyVwumYII0lonZ4uJClDMPeLuUNm IzcFyc9ASPE4h8Cs2FucLCvQHkJuFTIMRBOHWjkWnLIoIT3H6cKe70/L7X7GRlaKfd1w 7PTxLbe6eHXYalB822KhqUBfxfhsclQOjO+vSXFVGNm4FxtXSudE/JRbD09vaEc0uDpc pQHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488829; x=1783093629; 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=oLh8fGIE1A466qmTuKBcUXl7JYmNxJHzlMuXubpIZxQ=; b=hm5B2waShXN/XPc4qoId/2dvIAXZ8q3X88aqJqvgci4kuHjYvmSaCKP7FoVIM1PP/Z CrNljyvatXYZibi25vabUxLumnelFmq8b+RRU4klKR120+zMFoC1eLKddmhT/nC7mTFa nTo7TAZ2B74zD6x13LWppOb4BuuMJ4TCsHVHUKQI5m/9meq0avHMRu9M8gEjBu/SrgDt 5wvsFPcAvqUtHwqMsL6IK1fVaWjvKwoDtpcEaRVwTOmV6LJ9G2yvJNvu7D6TGBgvWmVb KjhR6nlni0NntP/D8HOFBAB/Ui+PXLaYilWpXuZ/MloYpp/ax14OTy0tek6EXcXosJXf mOBw== X-Gm-Message-State: AOJu0YzJDEwIqWPrxn/D8hv7wVohOUUmniDNuIIK1Rsfzrv88Q9NUjNU 8d8fayb8MjgkkUtkNQihZNgOqUkM/gf0l0sbwo0WgpVROv9DYWGOVwEjBx+IqA== X-Gm-Gg: AfdE7clzLG8oKxZj+fGQQkRVOteWb3DGcYC6WCNLWSl9JT+CVifkZYnFavBri3M4p2+ qz9t/5z+d8SAkmSLtXV3trrS8PwVKK9OsBRs+Sy0XOK5otGYDvRLOAzNppukmE7mYaXHRtasGWj XiT3KZcqQxXqw10RWpqKLbf7Ezbwx6TPIls6mQQYgwGthXJqCAiMStvNLfOrE+nb2xU9o3sHV6E L+gdtgNFTd/PYlCF3v2QdkdczIwyZhGqLlZBai0iyEKFGfsFU/bmYr29A+1VKWOqJ8t/EWhL8C7 Js7iDQmBdqh7rafpKsxE5cxj700bXdDpFI7mxAoSJMBJclsBHhk+0tW22ejt5hmD0ysjiu7w4mh 3v+rQeoJDEblQN72ry1zClNz12TzIqAtwlyVlPtifZgM1uATYi/yAV5SvmAJoRYu+11ga7ZjcKt 5GhPg83n/cjguoDwVk1m6dAqOwNvPztcKknhKjyRrd3NPQgHZ4qE0ojnd97JqFiqKTOHws X-Received: by 2002:ac2:4ec5:0:b0:5aa:6d0e:9d4c with SMTP id 2adb3069b0e04-5aea1f5945amr1360383e87.25.1782488829050; Fri, 26 Jun 2026 08:47:09 -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 v4 24/25] xen/riscv: provide init_vuart() Date: Fri, 26 Jun 2026 17:46:33 +0200 Message-ID: <0d7964b75db0d5d42fe1788fc1bd77962301c927.1782487661.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-42698a/1782488829-3BB30220-FB46DC91/10/73395122804 X-purgate-type: spam X-purgate-size: 1391 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488876209158500 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-v4: - 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 Sat Jul 4 20:59:50 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=1782488881; cv=none; d=zohomail.com; s=zohoarc; b=m4yoMSzpueEQqDctDr6Bsl0OhZzAsiCEetjHp405jeGJ+8QmvrS0V+BIObHTJtZe7wdYGUA6kw/qBnOUoRU9hdK02gvRNH3fs+YGoypSWrpgz+aTNAznjOIOesG9Qb1VvDEMn2IOpWdRm5J85PW3gF8XHnvHkZjYz6a1cZ2Vklk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1782488881; 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=+DdSrh6NSU2s4GU9Tmsol8kJnh0oRP/iPMlkqVlxmWs=; b=CXHDQV868NRq9NTGrpPifc4nqEaLwfMzlgYhAJ3BE4om+HahicwOCixL/ZLZWeArlan8z3E/GfBBCSAIlKZzRnS6VWmV1fDVkovqILbygMc7RbZhcRrhi3GMk2xK++8nCSDA7eS+n7cxazecQlQdTokJntYt6ZoImKBhBg+L+xU= 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 1782488881895155.11485476565224; Fri, 26 Jun 2026 08:48:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1346314.1604910 (Exim 4.92) (envelope-from ) id 1wd8m4-0007Jz-1c; Fri, 26 Jun 2026 15:47:24 +0000 Received: by outflank-mailman (output) from mailman id 1346314.1604910; Fri, 26 Jun 2026 15:47: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 1wd8m2-0007Df-Gx; Fri, 26 Jun 2026 15:47:22 +0000 Received: by outflank-mailman (input) for mailman id 1346314; Fri, 26 Jun 2026 15:47:13 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wd8ls-0004vD-11 for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 15:47:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wd8lr-007b8F-5W for xen-devel@lists.xenproject.org; Fri, 26 Jun 2026 17:47:11 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a3e9eeb-5cb7-0a2a0a5109dd-0a2a4508b62c-32 for ; Fri, 26 Jun 2026 17:47:11 +0200 Received: from [209.85.208.175] (helo=mail-lj1-f175.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a3e9efe-edec-0a2a45080019-d155d0afe02f-3 for ; Fri, 26 Jun 2026 17:47:10 +0200 Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-39ad9c80fa8so7349521fa.2 for ; Fri, 26 Jun 2026 08:47:10 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5ae9cd5b232sm2612888e87.29.2026.06.26.08.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 08:47:09 -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=1782488830; x=1783093630; 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=+DdSrh6NSU2s4GU9Tmsol8kJnh0oRP/iPMlkqVlxmWs=; b=j8Tjne1L93srtK5EsZnblNH1KAz1t2e0qDjfe5z4QGrEh5HotFOHFtOvuC1wOO3GOi aJBWQ3sVG47gPYG1r/E6ivQjdJHRtUYcJF1PwFH4B4V6ZYBU+AjpqN+zBedU7U19x87s +GEVHc4f+JlB6o3rKURJ3eNaiz8odo19Aq7+DPHBHp155O3bhaNHRObygWtbE+aVAa/6 M9JU1e6LkK4Sen3ksKl2le/jbFlbug2e+2CElocXZWmFC0Di2QqXxolbYB/kNiqmPv2K HmVQQOzOZo89o1Yo3xdpdT/vLRkjW4V5VkWyMgAp+JAL9oXAgrwaCMV8WQStoBY494Ap pKsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782488830; x=1783093630; 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=+DdSrh6NSU2s4GU9Tmsol8kJnh0oRP/iPMlkqVlxmWs=; b=cwHfoV9SsW4t361qqFVplEHfKy6aByct+AtQiiSrI8kPEvA9rw8OGQgffsO/v5nJko Tn44lW0aEMEoFSH6qZ7/nMiGuQSNFuNBo46QfcGZn1JleICQUnpz/FZdlhD9UeGtGAB4 FT0YYOlWKNzvs84zSOW3/WHo7kDre85hl+KSrUrXsDoHEfjStpjuwr4v9tlNjcMZnjBP p/SM73ZOe8pPDzCX9KGNXp2WzifzGED+yx8puC5pz7p6u8lpFWAygq29w5B3zcBQbQPl JaH/E4yycuYUw6oSc7ZE1vdp+9eRgwFHZ9gDHCVe+0UTLgNFqpXZsZyw8d1n+7f57sHb NpxA== X-Gm-Message-State: AOJu0Yy/WCxvQRJB8yMrg7wuURFqeYJ8SjxZQ1STKUCWyhQn2haigjEA gePYxTUJ/rXphN6uYnSzxHLcLe0aBeWG5pH4Tpc9WazfWhOikGb3fkDmg1nnsA== X-Gm-Gg: AfdE7clQ+939/y0wbMDh4J6d0Mj4Twqa00QjPsaZgLRYJ5AQAn44Ry+SNb56ZoC2UoC TLjbJGNO+BVoVmlSJNE/HesivByzdh+fGfog8xcVIFYe8sYI5ht42nv4oFYDOO+tGb8E3dcqDqr anPGDe/Sx5IvboT+tv9Eglpr180DmV9pE7bD5C6pz4n/XOpeciCKieiD7Z/yiDl62RmsSfdRaM6 T+KJNsvUixO1jhp4BzptTBsXXei02ymDdlshAwSolZW36LANtioMeqW8BCMrABl33RxhjcLucDm D4wT5KERKXJQ2sWre9n4RNMHxIXN3kVrGDiGUFLdDCFUp74ETUWxOy0pUw+fhJqIUvrQPqXF4kw D4nmIl6jKjEkSrqYy04PSyC+fsgq0Fc/uP3kcIeurtm0x8plaqyWgKbqdhq1TnO6Mvgu54Ks/Dl Rf8JYmBcguFRmk5Hp84iT+ThRtcj9pjJsZO5g3CpCdNUINMHv3r93CZfrKgg== X-Received: by 2002:a05:6512:6285:b0:5ad:68c8:191b with SMTP id 2adb3069b0e04-5aea1f3d4c1mr2281084e87.2.1782488830038; Fri, 26 Jun 2026 08:47:10 -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 v4 25/25] xen/riscv: add initial dom0less infrastructure support Date: Fri, 26 Jun 2026 17:46:34 +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-c1860d/1782488830-4092D3FC-F713A814/10/73395122804 X-purgate-type: spam X-purgate-size: 6637 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1782488882518158500 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. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- 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 54ecd301c49c..84923b8f7b10 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -156,9 +156,37 @@ int __init make_cpus_node(const struct domain *d, stru= ct kernel_info *kinfo) return fdt_end_node(fdt); } =20 +int __init construct_hwdom(struct kernel_info *kinfo, + const struct dt_device_node *node) +{ + /* + * TODO: Dom0/hwdom construction isn't supported on RISC-V yet, so this + * is a stub returning an error. It must be implemented before a hardw= are + * domain can be built from the device tree. + */ + + return -EOPNOTSUPP; +} + int __init make_timer_node(const struct kernel_info *kinfo) { /* There is no need for timer node for RISC-V. */ =20 return 0; } + +int __init make_hypervisor_node(struct domain *d, + const struct kernel_info *kinfo, + int addrcells, int sizecells) +{ + /* + * TODO: Generating the hypervisor node isn't implemented yet. Returni= ng + * an error here breaks building of any domain (DomU included) whose + * dom0less_feature has DOM0LESS_ENHANCED_NO_XS set. This is harmless = for + * now because Dom0/hwdom construction isn't supported on RISC-V yet + * either, and no RISC-V DomU sets that flag, so this path is never ta= ken. + * It must be implemented before DOM0LESS_ENHANCED_NO_XS is used. + */ + + return -EOPNOTSUPP; +} diff --git a/xen/arch/riscv/include/asm/guest-layout.h b/xen/arch/riscv/inc= lude/asm/guest-layout.h index 90603f06bb91..add42d566597 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 Xen-reserved pages mapped into the guest's + * physical address space (shared info, grant table, etc.). The only real + * constraint is that the GUEST_MAGIC_SIZE-byte 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 work equally well. + */ +#define GUEST_MAGIC_BASE _UL(0x79000000) +#define GUEST_MAGIC_SIZE _UL(0x01000000) + #endif /* ASM_RISCV_GUEST_LAYOUT_H */ --=20 2.54.0