From nobody Fri Jun 19 21:21:20 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=1781695128; cv=none; d=zohomail.com; s=zohoarc; b=mCzdjcramsIvfgoFOvkZNXZiL9DgWxktKnkApskqpb1uItm7Brn+QDSzzKfs8xQleQyzPSkorJPjINVa6UGvSYnfE7VwJ843neXnP0Jrq/slVhN0uUVOD0PHgC/54jgUd9VSx4H/rhoKgZf0T5EfwByb0r6wzzbR30hBK0s+smw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695128; 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=LoVAso1S9Fp0u19eDBxf1mv/kzkPYBOYkZMUv8ML4DQ=; b=F57QQ9d9qQA3vXxz9E7Vmjd25m50d5dH2wHQxoqd38CQtmYDYeVM/nSBB8rNBs9jA7jwFwH/vM1yBq8bgOrkI0Tc3GtTU1/8HrzkJETbrNBS1g+uyioMkahAWyLXOw89Ykse0kl3O0Xlg2TY+D91tGU+I9dSe9eIQsFIsXs5VTg= 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 1781695128728896.5871166012913; Wed, 17 Jun 2026 04:18:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340082.1601086 (Exim 4.92) (envelope-from ) id 1wZoHV-0000qn-BA; Wed, 17 Jun 2026 11:18:05 +0000 Received: by outflank-mailman (output) from mailman id 1340082.1601086; Wed, 17 Jun 2026 11:18: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 1wZoHV-0000qD-3f; Wed, 17 Jun 2026 11:18:05 +0000 Received: by outflank-mailman (input) for mailman id 1340082; Wed, 17 Jun 2026 11:18:03 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHT-0000eY-HC for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:03 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHR-000VG3-CG for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:01 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328263-e002-0a2a0a5209dd-0a2a4507bfe6-16 for ; Wed, 17 Jun 2026 13:18:01 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328269-229c-0a2a45070019-d1558030f0cc-3 for ; Wed, 17 Jun 2026 13:18:01 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-491609cdd8fso30076345e9.2 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695081; x=1782299881; 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=LoVAso1S9Fp0u19eDBxf1mv/kzkPYBOYkZMUv8ML4DQ=; b=UBTRuqBd/pG971TKuEdx8dDPCozFxbreGjy74oD8g01quz8RbFpJX/A1AekoBxVJ4n iLm0lmxpXDn+gu2ylqZXAPS08H9TjIUUt7At4/c/VPN2QI05t4xx1QGU41NVid5PAtXF +boFJ/OQ1TkdtUhFitwBh0BdVqZyoqVXgMKnasDHwg8FaDHVWSuTj0MR9cNnqkD+SFBQ 790jtZr+ZeL3eLlQZ7cGo8QHldyTl7J87m/yfpFgEmrCSO84NCmeTnQbQIIWcPLE7+U8 ALZ2lsb2rq5dRa7iCNm94GJu7kIginDwWZ6+EvlZB6lOGtPoK+TbxWGhI3inD0AZQ3rq rTdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695081; x=1782299881; 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=LoVAso1S9Fp0u19eDBxf1mv/kzkPYBOYkZMUv8ML4DQ=; b=cahqoXhGXE9RawMZFFKACSnKTfk2Wa6pAczOf8c4mx4Y1I3vTLaXG17G/rarcW80Ol NXxBOeX0u4g0fd5Xi9p0FKR9tJv5TCBt4wFxAcJ5jAKvG0jV9/6UIzJ7jcZGnpcMBwW9 WT+AcoZDxDppgkB8A6VoygmjFBy34f6P78PzVJjatd3NK/X/1jS2Cm0PMA8d/4h06F0t nY7IW6cinsBtLiI/uu2zgfUMS9L+pquYOeRtVvwHOMNoUE5EfhKGBVbx4932SbWZpJ0I 1OyfsLTtRFh4qDm8f0Cx7H2VoC0E2mZr1f0fHB6KlZDQkVn2IicQX2saePC4ihDEiO4O Uc0A== X-Gm-Message-State: AOJu0YxERNjMlpUTw5UsZq8g7B3rinRSofkbdlwF7b/oHIAsGNT3U4nZ wrviJtxU36U23bBCf1FfJakvUFvqsHakxNbN8U6BrIaBmFqNV9QzU1UJmKBLQw== X-Gm-Gg: Acq92OHYOfCar+h8SBAN5o/X6dbnrLOhek0dzldwW9bmz/XNw1AvICCsQjuH9/jsNZi zk0UjGErrQWQA7ryJwKzW9jrnlSGbNI+XnAR+vxcl6dERcAGmfIb5LCfyrcN9VwBxGxzfW/w5jE vcv232FqJGwMpP4qIKyH6skXZSSH4cOpl3r+tYdQP6Mf2YtMRPSb8f1BATFPbCv99zKuCiSOH8l PX9jEA8TvxkC/E8ufKlN4HVSkkjoduqUWqmCBPWk2HnfdnZnC8bz9NR/NYsUbyfXxz0gj+odhH+ d/7zEChJjDZjAJJ1LGmcL0+mHkDBqS3Zy5vnM1p5s06DLKQd5d70pUCcq9uHBEpr+PmKArshPY9 OGUj9nxl8Vwsc21z9/y4EKimu6RxwxTLVS9yvrYNk3wwgEJAgZ7vXH2OpeTTeqxiyZvFOzxki8M JZgJrcup99eIMTamuW3zpTzfqiQlKRTEv9tXwFvD5zfIhreTSt8aR4beGyTw== X-Received: by 2002:a05:600c:a319:b0:492:1e36:552b with SMTP id 5b1f17b1804b1-492333e0e20mr49333735e9.36.1781695080614; Wed, 17 Jun 2026 04:18:00 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 01/23] xen: arm: move declaration of map_device_irqs_to_domain() to common header Date: Wed, 17 Jun 2026 13:17:29 +0200 Message-ID: <7bbb4d94f6711014f46becfabeb916ceed294833.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1781695081-21B68C48-054D02CF/10/73395122804 X-purgate-type: spam X-purgate-size: 2255 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695130068158500 Content-Type: text/plain; charset="utf-8" As map_device_irqs_to_domain() is used unconditionally by common part of dom0less code it is moved to 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. Signed-off-by: Oleksii Kurochko --- Changes in v3: - Add tag arm and move this patch earlier before RISC-V-related patches. --- Changes in v2: - New patch. --- xen/arch/arm/include/asm/setup.h | 3 --- xen/include/xen/fdt-domain-build.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 0d29b46ea52b..0adfa4993a8f 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -53,9 +53,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 Fri Jun 19 21:21:20 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=1781695102; cv=none; d=zohomail.com; s=zohoarc; b=KHN2lR6ksyGHyusyPdgSTXVTt4zf1rALn1ci3zTkqF4Bas9KzryGo/DQWsP7GLZu5RxsdFyuXSkOkQU4ApR96PY+y8f6rR/2GPq0Bhowghu/xOdSajfQ1Jhvxtijiu8A2uZ6KUXeL9mTHLvjl1x8SO9kv3CIX7Vc7L/Kkyolf8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695102; 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=jhf8qyknDygzxflLcvVL5fdOhndbEUmd5SDjF9WBNsg=; b=iAAh6gZtyaoisAoqldz3yO6rxfUgmwIW0X4t6+gv8uw1L0RX1UYEJyjNFj+U8gv2AmqZId8AUyYSqLOoXv23rXcJh1/Q2YLXMqFdy1Gzf431jnFPmujTnNhWT2Y3z2Q07XcEfYMxRrJQlTKbtznBZkriLX14xchvlXivsJbhMek= 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 1781695102586190.60991243391732; Wed, 17 Jun 2026 04:18:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340083.1601091 (Exim 4.92) (envelope-from ) id 1wZoHV-0000uw-L8; Wed, 17 Jun 2026 11:18:05 +0000 Received: by outflank-mailman (output) from mailman id 1340083.1601091; Wed, 17 Jun 2026 11:18: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 1wZoHV-0000ug-Gg; Wed, 17 Jun 2026 11:18:05 +0000 Received: by outflank-mailman (input) for mailman id 1340083; Wed, 17 Jun 2026 11:18:04 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHT-0000ej-VX for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:04 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHT-008nOJ-BM for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:03 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328261-5cb7-0a2a0a5109dd-0a2a4504e3c0-26 for ; Wed, 17 Jun 2026 13:18:03 +0200 Received: from [209.85.128.51] (helo=mail-wm1-f51.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826b-1dec-0a2a45040019-d1558033b585-3 for ; Wed, 17 Jun 2026 13:18:03 +0200 Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-490cf3000f0so56724935e9.1 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695083; x=1782299883; 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=jhf8qyknDygzxflLcvVL5fdOhndbEUmd5SDjF9WBNsg=; b=h2rMI9lNtRbIprvC/DFOGZPDLVBYvPyrZOw7ibt8cYOewxGzkYaZJw/7ocScAHQ7DZ FFUGbF37KiXc4nvFrniElLVhUOnLcuTS7wHHmA6MpC1nQjkytUxDbxwzQFc2CgNw+42I xWtcnJ+tbYVIcYLfI3eVbbGnH39MsBDCP5deDTZTJ0iEpBD+pt90fsXa7EZ6rwuoYNLO A4pJeWIPF4zW0itewdnEXRRI4v0L8h+X2izpj+vbbVTx01wP4h83T60Mdm2d4+OYt7qj KSxQhBt23U9MsW46/sR6hF1bateGbA6N08IZrlAA2XiQ0e+YOCP0dmA0VIriVEqdCU2M zzHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695083; x=1782299883; 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=jhf8qyknDygzxflLcvVL5fdOhndbEUmd5SDjF9WBNsg=; b=am6eXiT5jGUFm97pKoD6KTMdtPWCo8R27ua24BNietwNcC2iN+350eUiPgwgoCmUyp Xgxay64sVX7jrwwKyKNDgeDWXZSoooXZ6ZlNiX+C4zrUDosikRfrLKcefFRJM38ebL4i uvGOu49oe6IM0/BdNzz2embXgiRZykLxLTjWAFcigGD12WOdWpUfN3IvX5qa+uqLfHfv CR10d6E6GdKJl293i8/5nKt6u8xwY+Adj7jcUZjAcQ97/QUMud2+Ogb8OKpXuhnNrsSN DHEeOHZyuyHt7EcNUqWgTBJNI1TAmv1Dd7H+QuXkKRrLAP0V2dn5A+6Qo3gGllcsuiZg 9cjw== X-Gm-Message-State: AOJu0YwcEvOrt7QimmJRVYO/ldO3+1tCkOt2ybmj0hEkfJix17+sGYv/ 29ymcbmwwyobx3aCaYMj5bIx1BtnJlke6W5/ShZ7kX7yjs7sRIOSwZ3Xckf/dw== X-Gm-Gg: Acq92OHAdjvzswYBZwiQ7J7N46SNyAlfT+i4v8ZoccMeeO6iHkaSc3d7zpuNedVlswq BgTh5+a+gouKsbRb5rUW3GYTT4kNHOnHDgqglqYjKpH4CRfPyANY46RvzTwcGHOnsBYU1LOFK4Q 4qL2xJTVoauBKWdxjPamjA+IAw8b9fArUewT5RUW2tyHItA+fwWxojDLMM1rfOtpUfhi+AF6QI4 LHRSA4+P7YoK3wt1sKd8GHtAnGM22aPWq+ujHkTkj282ANUgkdRQaPdJsxyiLYiwbtpEQviFC2C VcZpjOcjdOvu9a8M96RpKbvfb2X0rtt03e5jUzgpH+7IlO2mgB4r+c0nVoWcATaex+o0Vt7YY6V vQhH4SL2w2M3bJYCQS5hoos/Oxwv6b6JwWy+cOosHoARUl57jAhWPaohp5FC0GWKPE8xYWiXiUs hv1P10l+nY9j0sMOjIYwI6J6OfMODptqJeRCI/lQwksmykpRl0f9MABDLvSQ== X-Received: by 2002:a05:600c:1389:b0:490:d3ef:fa4a with SMTP id 5b1f17b1804b1-49234105541mr41396255e9.14.1781695081844; Wed, 17 Jun 2026 04:18:01 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 02/23] xen: arm: update p2m_set_allocation() prototype Date: Wed, 17 Jun 2026 13:17:30 +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/1781695083-4237F3FF-CA185C7A/10/73395122804 X-purgate-type: spam X-purgate-size: 7929 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695104184158500 Content-Type: text/plain; charset="utf-8" p2m_set_allocation() signals preemption redundantly: via a bool *preempted out-argument (set to true) and via -ERESTART return code, both at the same time. This led to the caller-side ASSERT(preempted =3D=3D (rc =3D=3D -EREST= ART)) added solely to document their agreement. Drop the out-argument entirely. The return code alone is sufficient to distinguish preemption (-ERESTART) from success (0) or other failures. Replace the pointer with a plain bool can_preempt that controls whether the preemption check is performed at all, making the previous NULL-to-suppress-preemption calling convention explicit and type-safe. 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 --- 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 | 22 ++++++++-------------- xen/arch/riscv/include/asm/paging.h | 2 +- xen/arch/riscv/p2m.c | 7 ++++--- xen/arch/riscv/paging.c | 7 ++----- xen/common/device-tree/dom0less-build.c | 2 +- xen/include/xen/p2m-common.h | 2 ++ 7 files changed, 18 insertions(+), 25 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..e5c6be7c0890 100644 --- a/xen/arch/arm/mmu/p2m.c +++ b/xen/arch/arm/mmu/p2m.c @@ -67,10 +67,11 @@ int arch_get_paging_mempool_size(struct domain *d, uint= 64_t *size) =20 /* * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. + * Returns 0 for success, -ERESTART if preempted, or a negative error code= on + * 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 +113,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 +123,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 +130,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, 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, 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..41d6d3d5e699 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -430,15 +430,16 @@ int p2m_init(struct domain *d, const struct xen_domct= l_createdomain *config) =20 /* * Set the pool of pages to the required number of pages. - * Returns 0 for success, non-zero for failure. + * Returns 0 for success, -ERESTART if preempted, or a negative error code= on + * 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..c3818ffed45f 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, 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..1b44ec8ce36c 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -43,5 +43,7 @@ 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 +int p2m_set_allocation(struct domain *d, unsigned long pages, + bool can_preempt); =20 #endif /* _XEN_P2M_COMMON_H */ --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695132; cv=none; d=zohomail.com; s=zohoarc; b=hhqT3N+Yh8ObvHcw0rRdZT0AwNcSp+7vMjc9YH3L0+92v6cW2RFLBtvmjnywNbq5xipEhbDDb4jpYJvZMfx3wmyaoOTRAG6Bk4Ho2tiOpc4EOijWgbk36+Gfvu6axE4cQh06MOjYEAiO21ur172ZrBEQfeaSVelvJiCu07xrd90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695132; 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=lDfvaNHpw1BQg5jjuhW87imUpQEckVBlvr8onRcps9M=; b=W5WSF+LiZAnInHpaViaRtMIGH+ZeZuW5dMpu9bLPtv7QGg4AaSCK4WGqAo2XI5osUS+3nY65HJzmGiCv+1y6xWpxwfkDRcsgahKNnj3KNMP5aAtNuioMuJQvHYgmxhlDZNQjN3op6QuLNUpu7HyCEAimr5+8MLcc57jKJ0zrzW0= 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 1781695132988812.4030221348589; Wed, 17 Jun 2026 04:18:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340084.1601104 (Exim 4.92) (envelope-from ) id 1wZoHX-0001Hm-Ez; Wed, 17 Jun 2026 11:18:07 +0000 Received: by outflank-mailman (output) from mailman id 1340084.1601104; Wed, 17 Jun 2026 11:18: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 1wZoHX-0001GS-7W; Wed, 17 Jun 2026 11:18:07 +0000 Received: by outflank-mailman (input) for mailman id 1340084; Wed, 17 Jun 2026 11:18:04 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHU-0000hV-Bg for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:04 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHT-000VG3-Nu for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:03 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32826a-e002-0a2a0a5209dd-0a2a45019d20-4 for ; Wed, 17 Jun 2026 13:18:03 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826b-c1f2-0a2a45010019-d155802cad85-3 for ; Wed, 17 Jun 2026 13:18:03 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490b1bbcf3aso42557245e9.1 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695083; x=1782299883; 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=lDfvaNHpw1BQg5jjuhW87imUpQEckVBlvr8onRcps9M=; b=bFkz+XexqtDH+3Lr09WlDTqcAn9HYCgX8k+7wVTdAibXe6CTQPnZ8xnrYx+le99oyf lEYrAbVccx+/qv4rhGFaNu2ambX1xoZHnz2ho976d1CVodbSCAiBUcy4W3ypBQMoQCtP Yr1zAiXBdbyjw2MKlfSxvSqxjIxhdcEwYCgVk+BZCj4hu0m9GMVzpGKCZjrZmPLvx+cx XHd4WNs5TlWKRBQ8TFyN1bXgvNdu2gTrIZjnW050HNQ3CMU37LvvxeQn3fm+336wqKDK k+IY2Y+Ck2o6Au1B7wKzb4ysflrKZbwE3BKZTke3I88gr4g0fZ9AA9ga2gz5VNNAtpNj 6szg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695083; x=1782299883; 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=lDfvaNHpw1BQg5jjuhW87imUpQEckVBlvr8onRcps9M=; b=BVtCyhKgwF5HF4Bo4J+UevLKhH/O7FSQN75od0mWC8C7C5juXawB1de1d6If/dJ1H/ b6QBDy1GJvRCGyT6YEU2ZMnjCszmq0RF7qKGqoasBN68yepfMj+MRrQ6or+LYVvqaGnd IU/daM0jZsaGf7DhQ71r8aBxQbZWKLBVdnNXizNvoUHYme7tuz6l+fYzMcHtelTjsQoS Gt0gyzv7Q8WubdTOeG0zcEaqTNITmq+fmydLNwMxpdDvr8gdxnX5E/7KsQYWl7TMmgLH kLDYhGr5ZwzJ1Hk8waYlqcSdI7LztbamMiTZ9z6NOpxI3CGmJ2uuQLEEcv1Hp19Ekh/U AZ0A== X-Gm-Message-State: AOJu0YzrW2h8vp6n4yD0hWt8sW75aX2DzAbyQLJtRT0bbVIahCFv3vke TkwsLx5w7RzBQqAdyk2EUY20/c/P6rZz17po+iMBwikJu756OibqmgNa8oNDVg== X-Gm-Gg: Acq92OFWa6eqheenhO0rLIxWvd/6nirZPtDxPNwToAWnUrBN6dAcc0OtoR8xBVu4TAs LRipbAdOjLdbGGyXCy1EDBxpxgQG/ByGURrrWVu39Wjx5pej+dO36JJ0Eqqoyw2YvS4Muhe/Q8V 8x0kC5/MwoEX3qQT8UzTfanu6A5U7+gSmnqrGBNd89fygNTQYq4H//Rt3h82JAvk0q99SzuTf3M Og1muAKxkt/IuorwZJef0II0uNc4yUZBl3DgGcjs0NeN30iPg0IWIYN4+KuqtzLqxs9lvY+xbo3 rXyZk3KLqNaCntuEe46/hukUh9d6IXlBonRRfXVq9S+l4/uHIVb16fpKW1y64VTb5mtxxmF9olq QReuyzG23hHoGq+vFMzDwoJBruOE0DlDielLVFDFqbAXmYnVAYEL9kV3sgmkXJtECcZeJiUvXv0 91ehHuv93IsXQppe2kt9m22KK8PQNaQQu+xPwgLrBJFTSMNrqLk1LMk8SryOsx7EFCH72b X-Received: by 2002:a05:600c:8189:b0:490:688b:f9f8 with SMTP id 5b1f17b1804b1-492333dd136mr60429345e9.27.1781695082923; Wed, 17 Jun 2026 04:18:02 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 03/23] xen/riscv: Implement ARCH_PAGING_MEMPOOL Date: Wed, 17 Jun 2026 13:17:31 +0200 Message-ID: <6bed3de34d98c47d99235dc062cb9fd4b0e4158f.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1781695083-ACC53FF4-CAD7E588/10/73395122804 X-purgate-type: spam X-purgate-size: 2575 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695134123158500 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 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 41d6d3d5e699..9bf80d38979f 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -1606,3 +1606,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 Fri Jun 19 21:21:20 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=1781695678; cv=none; d=zohomail.com; s=zohoarc; b=UUsCShcxhcQapCGULSQMNMOCdGt1QCL7KN/Q8mpDDxUJO50Y5JbuVUru8bFQJEfYCHtLUJHGAZbXT7F/0scLlvv0gjhT+C4TYYAbUm7oU3Xq9BqSfy2+mvqWaT5emUryAXVHhazyVRp/xAOXUAA+U6ryoKiIPnZIsr7wlHAwO+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695678; 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=FlQi9+uo1dP1MsjK2ZrKEdiUrK2P4TAiiVcer4o8XZQ=; b=RWFDXeBglH3XI7BthFWuZqzzUZFjXQ/yv0G7jwEAKqVqmdYS4BDYY+0DvdlRMrxY4lag5N3gUsN26xl6kTuPKDlj8GktsfwV7hWG6dI4fjjsyoXnLnxMbaW7fzKK0lnoFVg2nMDr6n5DoLCVkzwNZj3qloxuy3SkhoKvXuq+aZ8= 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 1781695678159278.6272761640306; Wed, 17 Jun 2026 04:27:58 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340086.1601119 (Exim 4.92) (envelope-from ) id 1wZoHZ-0001bF-GZ; Wed, 17 Jun 2026 11:18:09 +0000 Received: by outflank-mailman (output) from mailman id 1340086.1601119; Wed, 17 Jun 2026 11:18: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 1wZoHZ-0001aO-2h; Wed, 17 Jun 2026 11:18:09 +0000 Received: by outflank-mailman (input) for mailman id 1340086; Wed, 17 Jun 2026 11:18:07 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHW-00019z-SU for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHV-008nON-8j for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:05 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328267-bab6-0a2a0a5309dd-0a2a450bd29e-12 for ; Wed, 17 Jun 2026 13:18:05 +0200 Received: from [209.85.128.53] (helo=mail-wm1-f53.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826d-212f-0a2a450b0019-d1558035c590-3 for ; Wed, 17 Jun 2026 13:18:05 +0200 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso48529665e9.1 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695085; x=1782299885; 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=FlQi9+uo1dP1MsjK2ZrKEdiUrK2P4TAiiVcer4o8XZQ=; b=AYk1hyJBnP0l6skItus18xG0ykFh9fEH1bK1YeZW5rauQqobxg4/GLHmZUJfa8TapQ EOPtiQD8U1grJ1oYLeNEvC/BVZD2cfEXM1fAc1LzGyW5uuS7OZqgN/gJwe5SOAwBCcWO 4NEGzg/VLntldaykUfBt6d6ZehMLtF26aWelZlRmIljXHN2XCQX5euOmtDLNY1uDLXDA WzqifMLlYgMKZYdUyMJZaoZO1N9P8XviUB7DTCBNDxfleKjCgyu0/h+fwGt4uMdxNvNx yiKW91bvCw6pwJgqnwNDKu2ye+l1ogHKUFfnbge0m7r6+5wfjwjupez/VfcGlzBlmOSn wTqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695085; x=1782299885; 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=FlQi9+uo1dP1MsjK2ZrKEdiUrK2P4TAiiVcer4o8XZQ=; b=REqaTDytu2pQR4krg1J9IgF/5DrXxSiKQgaZyNr8gzjtbZc0u3J8MnfxNVR0b6p2OB 555uDnKp5hTxBjg/EdS0npPrMjxO3KaIikLX2jxheKQ1VJ+aqXZ53d+2Q+6JtaMfk9lq 8UszqU90UPOFrJEvRQQVWyng2qNwUX30EdKCj0nM/obNLB3oFETllNsKgBuO+PPesiju 8v62OkiIBhKaVDjzQhsdkuM6mtqIgtfIjJxEjToWx5eHEkZnpC2+2PybaPb8DNh93HZJ p/J6YJuMql9SN7IAVrVVzml5OgEQw8cd9eZrJsgCc4EBPL32QzrzT9umRnHH8fycRFTT 6I+w== X-Gm-Message-State: AOJu0YwhKAHO/ppmuJC+snmFg8F2wZE34Kj+pm1r6VFXAcm6rNmNWyjw Ty17NOIFGPUA+bpUAOfl6GJ7ALb719yxEq3vDrWkeiv8MhMtv129wwp4WgL8bw== X-Gm-Gg: Acq92OEMaw6tol6faYNPZM2CdBbhkbOY/6b6V9lxKNBsk2xI2Nz0gvORe03cHO1iK/i bWHto+R6IEdeborH1QE250WRc2IP+Wi+7jQHL1O+mQiTS3ZnyvWKpEnvZCoxPhlC4rtzig+HPX0 JDNItUnexEfdlHiO7eaix++0na/2Zhknu/tJRh8aP/dOZgjKNjGrynH3RGGh/Z/gXONU44bqmDJ TeKJqYEbCbOq5IoCZG2XCLzLua71t0Mk+Pu66ObH1tlX/fFmd9usvzpb421ik/zdKPEtaZoPHTg kGrZrOt9McE8FcRRbC/2EWxKgE36md0ccOureWrU85PY0xNcqUwR0e8g+TC1KM1wEIP9WdeBxde Uc/BC/H4pmWwSH+PvSkcNNgFs27hLdD44DZweZWFl/s7J61sw3rymC/nxI0m/hcnf5pNVO7QESh G4PGwuGRbRdsdQvi3hiPSm84bS7CtskZqpXNJpMB6umcWgbPb8ySpW9joQS5cKXlcaVHhH X-Received: by 2002:a05:600c:818f:b0:490:50eb:b777 with SMTP id 5b1f17b1804b1-492333ba2d8mr66182685e9.5.1781695084208; Wed, 17 Jun 2026 04:18:04 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 04/23] xen/riscv: Implement construct_domain() Date: Wed, 17 Jun 2026 13:17: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-42698a/1781695085-13F7EF3B-27D470C4/10/73395122804 X-purgate-type: spam X-purgate-size: 2853 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695679586158500 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 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..72cccb2c5c22 --- /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 %pd v%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 Fri Jun 19 21:21:20 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=1781695109; cv=none; d=zohomail.com; s=zohoarc; b=N6ATbOGG0QQByUA/LMlTJWEaaDP7ywOTJbqTFdasX0q2WAJrU4/uwAJ/P5MYjSHAly7GHZWMp/IiiCSCO8ovAJHfwX4Al6cs2uAh2zgHI5wqKO8IkeST5+PTqSEVk4swv0X0pfmEouyTFhZ272wVLNj1Ed3CVJqtdsz7n40Pp60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695109; 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=4FE9KGCs3R/Kgm74pFNvt+2bRqPcGSPft9+RP3relho=; b=g4Lh67WkqLHk4lcHF9wXJxi07vYk48UMk+t/AcBFKl/mk4IN34cDP+JtKGeWmWzewD8MRcFj2elKVV5mBv+UORZL2W1a5j1dZlZjCI9KiwQmF2x+18SsO58ZW59HsOrUkETB5J5K4wjEVKcSTG6wygACp78FxaDe//0yRUWuOho= 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 1781695109028259.9075418974652; Wed, 17 Jun 2026 04:18:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340085.1601113 (Exim 4.92) (envelope-from ) id 1wZoHY-0001VN-Qn; Wed, 17 Jun 2026 11:18:08 +0000 Received: by outflank-mailman (output) from mailman id 1340085.1601113; Wed, 17 Jun 2026 11:18:08 +0000 Received: from [127.0.0.1] (helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHY-0001U3-Iv; Wed, 17 Jun 2026 11:18:08 +0000 Received: by outflank-mailman (input) for mailman id 1340085; Wed, 17 Jun 2026 11:18:06 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHW-00016v-LV for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHW-008nOJ-1k for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:06 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32826d-5cb7-0a2a0a5109dd-0a2a450abe50-6 for ; Wed, 17 Jun 2026 13:18:06 +0200 Received: from [209.85.128.41] (helo=mail-wm1-f41.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826d-56b3-0a2a450a0019-d1558029c971-3 for ; Wed, 17 Jun 2026 13:18:05 +0200 Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-490ac10e337so38151505e9.3 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695085; x=1782299885; 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=4FE9KGCs3R/Kgm74pFNvt+2bRqPcGSPft9+RP3relho=; b=TIVyiLOPLzU/498kZtSoKncGr3j4Teqmmvs6PklL8TghH6C/iKe6oVbG26KFgG5zFI baCIyK3ZO1Y8QSddwRxdBPr6Ioa7pNoFy4LCe9IFif9h3q/cSQlkVDOk3eaaWiOOmxYK IRc6TTUA0mt+iiLZ9FGgoxXWeoqgdBykLoXJUM+du/QIN8Vm1ZQzxCvms5xlUeFDh1Np fRPabtlCXCls9lMi4KOSjpzbzYaMWqLRmeTH1MsE+qhXvdEZGogWD1MN+CeZ/I6R4Dg/ 8w8Cy+nWHRlHdpbpd5qXC9tTXbZLTXUSSP7Q3H/A1hOSK3cw46GGlXtv6EO3+RAkMpah pIKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695085; x=1782299885; 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=4FE9KGCs3R/Kgm74pFNvt+2bRqPcGSPft9+RP3relho=; b=oEh8rReaj/oBh30bTg7YAgEEHlfYPYExOdFnvqyXpWQKJnmClILQPtcC4dCPo6y1io b2qQNt/iP8hY2UQiHWzAaLKy3xZ3Pps15c3fNfkjt+M23l+wzzxwPxbPac2baAcyQEuw 2idPR/NTeqw60Zig19cSWzq4L5VNiLZ/F9sWWR5Nz9n7YAbVRZXv1K6HL4EvuCt50dLS 1ZY3Ytzv9v6hzK7lHKBcxnUlHdxy7LUMOmcphJx1jNA2h476cXZETUZgOPdH1iuI0193 tMFJCsgGJJ7zFwDQmJMm57/7j0NIgaieckQpaXN8ytvV0X/9BdwdhJf2UP9yN+qb7YQy V3fQ== X-Gm-Message-State: AOJu0Yyd4WtTJyS9ax2UH6mx5Yu+A99vtPv1NiHThYd3PzQH2K/5TWNq HsWJpOCpeOSe6uqXrZlfg5nLaHXpS2/HWz/1yYArBmlSpxSc3RTYDfBYMkvtRA== X-Gm-Gg: Acq92OGCqhry5xwMbTDJBspBRNlwuyyxhERsauqt0Ip9OzXPmSfniVi2IFh8q8xTO98 cNzgLl4Ee0KHfEMrtmN4RdmuWwk8T2/Ru19GzUMYirjjgLm/0xU9PI+FGCL6CjNlrSTqRTPt0KZ USiqpN9D0k1Slb+T4XCUN1qdGmPj005y9lMULfoEp4gyXwDeqf8cVXXb/Z4JGHeKpI6GDEGnzs7 dq+iOd0zaJ9Pqk4fX4ygvB6xwJ9PHOZWnp4K7XRE+GT0Xwah8uCHguETSiz/wGSC2dVUb1U82rQ Bgkudlj7XftZPNKUpyBuhV8oBSspMVWFv2u8Ybpw9AIBaw2UO9l+PHuLpDWndAp9DH3TH5xSfw5 VD2zzqsMU6m8gDGdsOG7LGCq9CVs745DlIDWpLL0GpaBFRICsEeDpIoQgwq/VCEKa6cNtheQMwu jl6mJ56p5YfZQqtjs1OsEbV0XG5ZrIQxEN+VEnjSQ4YZ+TcrHVywPtyDirHw== X-Received: by 2002:a05:600c:c04b:20b0:492:32ec:ca2c with SMTP id 5b1f17b1804b1-492333eb2fdmr49962255e9.26.1781695085307; Wed, 17 Jun 2026 04:18:05 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 05/23] xen/riscv: implement prerequisites for domain_create() Date: Wed, 17 Jun 2026 13:17:33 +0200 Message-ID: <6785b861e192b9812f9a945bce19ff4b725a996d.1781693963.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/1781695086-7F1948B7-6642F979/10/73395122804 X-purgate-type: spam X-purgate-size: 2869 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695109989158500 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 --- 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 Fri Jun 19 21:21:20 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=1781695112; cv=none; d=zohomail.com; s=zohoarc; b=DquQlBMgsnL/cPpsQFtNd+ecDVEOJ27GDzjFJdgQzVHL8QlZsTsdIO8MdZOESZEYmCJ+qxEBlH3W3yGH6Nq7HUAnq+anorSgwFRH/TT3YnIZE/UDcReTM3SjYo2hUPvu6oV7h+Yl1QphxcVJzrAfgbhYvx97/D+Ya2T0IbbbIqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695112; 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=Ch0GvgcfTVIREUJMfYYzdF78jAptI5pBiQNF2XBPBjM=; b=HsWU/BRhegrDUhhKG55BbmHLk/uZqYn8hRLEW7jYblgDmJySqsHQgay4q5GRL1O6N7XNe+9v5lsJo6ii0zZcOK/gqxi9gZnTGj/ZcUmcyzQyrG7/Wp83Zxn2ica1hVNEYKRml4ot3lWHsTP0/3fKCRY6QCnMsg8a/TBD7ssTnm0= 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 1781695112757353.09764053288245; Wed, 17 Jun 2026 04:18:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340087.1601124 (Exim 4.92) (envelope-from ) id 1wZoHa-0001kg-53; Wed, 17 Jun 2026 11:18:10 +0000 Received: by outflank-mailman (output) from mailman id 1340087.1601124; Wed, 17 Jun 2026 11:18:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHZ-0001hT-Mx; Wed, 17 Jun 2026 11:18:09 +0000 Received: by outflank-mailman (input) for mailman id 1340087; Wed, 17 Jun 2026 11:18:08 +0000 Received: from [194.145.224.10] (helo=mx.expurgate.net) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHX-0001Nt-Vw for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHX-008nOJ-Ck for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:07 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32826d-5cb7-0a2a0a5109dd-0a2a450abe50-16 for ; Wed, 17 Jun 2026 13:18:07 +0200 Received: from [209.85.221.53] (helo=mail-wr1-f53.google.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826f-56b3-0a2a450a0019-d155dd35ccb3-3 for ; Wed, 17 Jun 2026 13:18:07 +0200 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-45ef41adbc1so4125840f8f.0 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695087; x=1782299887; 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=Ch0GvgcfTVIREUJMfYYzdF78jAptI5pBiQNF2XBPBjM=; b=hWz6kQeXUSi+6ulbe5Fe2XulHAW5NUCrV0xe009JxBdNgpc0WCm/rjcuxNfgFK9RjA t1ZC02UJTsSSJCkfoFMaBPChqeY6y3WMlgozf8U8iiv40suFSK6COjR9lRwsfEsqkUXD XBzT85CbF0WoYpoda6voeGw84YrFQl6UUZ/nxs2+ynhKR2oCX3HYrIJv2uEZQG0ZzdXu xCD/otYOQ2tYCRToWZqisgHrby6dCXZudnKCVPGCzst4JmO4mPUCTrmYzotUHZXr9R8S YrdKXd4dRQnTkDa/e+XmEUKfudqFQHLJbImWw5hzqiUIg7xDe4hUWmxPFrVpYOrHd4l6 az1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695087; x=1782299887; 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=Ch0GvgcfTVIREUJMfYYzdF78jAptI5pBiQNF2XBPBjM=; b=PDiyQpeDHNLOqvffTSKsXZmVMDhFla5qYC1DFBkI+DpeHUT9nVYY6oWYnfe2ErG/LR 4y6BxBv2cXuNAFR17navQPcDL0qFHn4QOSVeKQkVToEbkOAPiueA26aXkAEu1XfU1TAu vN5/AF7QASejwG+Rt1hx2wfQFTwuby/ZymABTv1ABnZsm9wgNNJbCeAsNn4aLX/eJLbd e3fX7+TJQg+PAWCUpumzEmMXsC3p19HtB7nuW3lrZWdivGDXIDDpA6wpN/1vrK1WcmVh LmU8NUo780xncYQIL4a4of2dQz7lwqkYh82wJCsGXRUZRz31ttcSB3Ct/zSOxM4KmoLt JB/w== X-Gm-Message-State: AOJu0YyddL5RUk4XdOyAXiCDdGAD1dmP3n7JOBCqB7/X14xvz2QGYfkP HfHMO8czQp9Ae0FlMI/3v+vr4j0yb4Oyu3Qvrh/iNyZT1OGyuB+sSFL0kVdp2g== X-Gm-Gg: Acq92OF8bKKB+wocIQO//xnodA0N1Q7SLoS3k683T/98g4LTeo/cphVoV+3kHZL94zC x0RI6pYde8IiuQV0m3aZoyWln8F0Aw+pJb5ACRQwLM42tQncWIkaVvNcRshhjCNmbKGPe0xWumK 3ZibLvMyk03AzFkdSIHpj6qnVHJzp5q+QYcvUkPobTrDCzngWd1lzTWObtG3vqvtkb67xsOMJtV +DSTPrV/3UdOqjqLIci0q6ESmWTZM2WmiziHVFxhYdswkmDdpjV+LlWIDdw4OIZfJB0+VFGr/2z FguF+nZIbSL8C+PS8ZYvjwlF1s9/dlUnCY0kjun/1xJJZZ/LKUKZciZZyUhbSpDejOLRiVyHR0O e1L85u4/WoKdGxfpMfGtPgodsz/hjytRuwBTE8pTedAqOuxYPzVh4XkWlqV+0xHnDidDacNWPVe UnxnZ7LrLPCERECOyeOHnfw6YeAms4fKxp8zSa8viI8Sv2HdylfonyU9m1kw== X-Received: by 2002:a05:600c:3b0f:b0:491:731c:892a with SMTP id 5b1f17b1804b1-492333df11bmr57593815e9.35.1781695086510; Wed, 17 Jun 2026 04:18:06 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 06/23] xen/riscv: introduce guest riscv,isa string Date: Wed, 17 Jun 2026 13:17:34 +0200 Message-ID: <3fb06376e057fa99b0df78e97761b8cff56ca9eb.1781693963.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/1781695087-7C47E8B7-5FA21D51/10/73395122804 X-purgate-type: spam X-purgate-size: 8053 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695113905158500 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. - 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 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 | 85 ++++++++++++++++++++++++- 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, 95 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c index 92235fdfd5ab..a56c28b6c99f 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,78 @@ 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; + + 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 +608,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 Fri Jun 19 21:21:20 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=1781695119; cv=none; d=zohomail.com; s=zohoarc; b=LMwZhEyXLCthnlKENEsEu3P6SCuwO2VqaRjoM9VM+VZku3r/M5+MsKNPlzF1UsJic1oZkqMY4D+Qo64DPIS4orcza0BvX4lJGJo2MVYAh1LI+4CCEd+XyDTB/SQqbgHeKhz53AxYoZ5k1q2RI1wKdGAm7j9RHjO1GFWxKqEcfsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695119; 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=HM+/Kmq9xfOuTPDTM94hm8AgKViPa+UWHR51aZRBeLo=; b=HoX7dMzxCIWZiEQqJooCONFI2NRdltspZQb9bd0PofDHxsvjGvMaQT6gb2vfe5mAZt43pETmXixKM1gFydTqveL99ngFEwc2AfH/NcVlaVglR5iA6XLNwf1bzw+ovgLmsL0SHXyMzKavbStu8H1Fbh9f/ix7puE2AZQSdo3y6Mg= 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 1781695119255726.2945188070455; Wed, 17 Jun 2026 04:18:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340088.1601130 (Exim 4.92) (envelope-from ) id 1wZoHb-0001zw-5k; Wed, 17 Jun 2026 11:18:11 +0000 Received: by outflank-mailman (output) from mailman id 1340088.1601130; Wed, 17 Jun 2026 11:18:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHa-0001we-RD; Wed, 17 Jun 2026 11:18:10 +0000 Received: by outflank-mailman (input) for mailman id 1340088; Wed, 17 Jun 2026 11:18:09 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHY-0001U4-Od for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHY-008nON-5Q for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:08 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328267-bab6-0a2a0a5309dd-0a2a450bd29e-22 for ; Wed, 17 Jun 2026 13:18:08 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32826f-212f-0a2a450b0019-d155802ad5df-3 for ; Wed, 17 Jun 2026 13:18:08 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so39126295e9.1 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695087; x=1782299887; 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=HM+/Kmq9xfOuTPDTM94hm8AgKViPa+UWHR51aZRBeLo=; b=ocgCGgOWNjGQ8BHrDu57ux/+WWUpFczaWZikr6U3+8MB0uSGfjEgsuUnKa6kbi95gB 41fzniF2TZiEleFhWvKEtSbU5itV/erV5enZjRcBNw/v4YlFIBtwcwlCmzt+FQFE0hVu N4WHl6cbcOeB02px2xyVY6DEQf/mDm6mXb6aL+UWbdw0Jc3lbXOKwUOgv1G2cBZI56ZX 1Sl5oZzzWlxAO/9bOdM/3MAx7LMVGB0WnrCqF4w9cE4QyEOAZUvB405hAEVjIxCO3oFb lWV8VVSx9NIpRbx6FyQaNOaUwwdcsk/ea+qMe784BVFsE8KkacG1dp3Ed6sEVEDm/vuE pyhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695087; x=1782299887; 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=HM+/Kmq9xfOuTPDTM94hm8AgKViPa+UWHR51aZRBeLo=; b=d5IU/MpjBd9hCIBw9z0cJmbvWroJssg2Ou5BAhX63hDfN7WADxrnYaVxYYpZCdPqaf DKy8wxRk4YNx3wot04Bo1lsjMm2Tc9lhcWOkM790rAtLruCd3d5n9CvlnEnC60QZQt92 K4HdmI+xU5E7MO0gvVgt1k0nksoAG2gelK2AasL/BUTHM7SC+s42HFSBzBoSukAXhtrR rqOv9c8ZjNtrMU0PZWv8TEl+EGq7K1+NNdKS+yX8IJ7htwFKge4KfoMgthT9PySNCF63 bxTzqNkPYtgpKHy3ESOmfHKzGh9zRuQg6KBeboM9NU8yDgHDb+8dNEPis/Ot26BTYAPW je6w== X-Gm-Message-State: AOJu0YzNMs8AeSifWr1jwU7l4Fc2zzuLheU0BB/655MYTX9L7geEr5wR ijd+v8/rN/yXfPH8GYpgqXpFUcJeCwY+dAWy2Q2jQlgTS0bV2t9hT10/ud012A== X-Gm-Gg: Acq92OEsk8fCOkWZGa3OZFGXU3CXEssEvpiNBw0b6cF4eZd/dZ8Z4B+dlwryzPY95j8 MMCUZsa3VZwPG+LvLumBueZPm1Q0+iLs3JeQGqKh0mG2GZ801961NDb0fnEHG8Ukw3+8MOAvdPl Y8yIRQjyDZiRxlgJpm30rP3WX9lHRDs6W9epJkem/qELuCOIdShcbecUHlTBHPkOScUgJzIoAjT +nmIKv7JDPQYEU0mN1dRaNzSy+Aa2X0MqofkaMLkHm2wwWyblkRG7JtMLx0ik9lo0+ViKpogKiN dGEVTBH/QSkVQaFy4jsVuPBKzr5DhIPz+h2YPCxZLSnLOjmtb7v3kfwk54SQwcU/NqXpcI8E7Jj Mo8POc3gi3Lp3/tYwb6joY+ozxjuO+bs7HsuEYbYmUaw+/W77OsKT+CLiIEzV55fmkCC7hK/qMd E/ieFacYv7deL46LQPNNpVIIUPV4GgbmOFYu1OsRgUvNKpp6xLkhtqwTfJXQ== X-Received: by 2002:a05:600c:a117:b0:492:2e48:81e6 with SMTP id 5b1f17b1804b1-492333a0258mr48820195e9.4.1781695087520; Wed, 17 Jun 2026 04:18:07 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 07/23] xen/riscv: implement make_cpus_node() Date: Wed, 17 Jun 2026 13:17:35 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1781695088-23374F3B-CBC788FF/10/73395122804 X-purgate-type: spam X-purgate-size: 4643 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695119906158500 Content-Type: text/plain; charset="utf-8" Implement make_cpus_node() to create cpus node for a guest domain. This function is going to be use by common dom0less code during construction domain. Signed-off-by: Oleksii Kurochko --- Changes in 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 72cccb2c5c22..c1cbc4386312 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; + + /* 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 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 Fri Jun 19 21:21:20 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=1781695110; cv=none; d=zohomail.com; s=zohoarc; b=Sg8gJpFKlxyPMlaBmJ7RBhz01lu+pYhV6Y5wQ0hsQzrLH+nk/UoLiV3iFTA39ZzWdfly66CAnlPukZjUQbZRbXQQoJQhvGzUUwUsRVlZ7+N/kTzMnaa4XeU+kndptDmVNEvDeFDLMer0ZGzcH0cQ8zbNZmVNOqqFhikCiuNInuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695110; 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=Ua5oAufZEffqM5l46feS+w0Dh95aYTaQPQ9PFyogonw=; b=KyXbYnHopW8eNhFKQhBhQSbPLL3UVwK83T6PBwe3k+Orj/DcgHVEWsOtMX6vd96Z4O9CCjhq4uYFkR813jKZypw9wZWEXI/WRXfR5QW/ZZkqOxXHk0XwHG9K7Nmgngi7LI4xy1Dn1b9QsNCySBB3m+7RDPEhfLWPjdoxfIRsH4M= 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 1781695110344161.525242732405; Wed, 17 Jun 2026 04:18:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340089.1601138 (Exim 4.92) (envelope-from ) id 1wZoHc-00026P-2q; Wed, 17 Jun 2026 11:18:12 +0000 Received: by outflank-mailman (output) from mailman id 1340089.1601138; Wed, 17 Jun 2026 11:18:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHb-00024a-HX; Wed, 17 Jun 2026 11:18:11 +0000 Received: by outflank-mailman (input) for mailman id 1340089; Wed, 17 Jun 2026 11:18:10 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHa-0001l5-3p for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHZ-008nTo-Gn for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:09 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328270-bab6-0a2a0a5309dd-0a2a4504bf4a-10 for ; Wed, 17 Jun 2026 13:18:09 +0200 Received: from [209.85.128.47] (helo=mail-wm1-f47.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328271-1dec-0a2a45040019-d155802fed26-3 for ; Wed, 17 Jun 2026 13:18:09 +0200 Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-490ac357c55so53247215e9.1 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695089; x=1782299889; 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=Ua5oAufZEffqM5l46feS+w0Dh95aYTaQPQ9PFyogonw=; b=IpNC0CkQ67LpilMvPxhag1CSawgSj9v/47D6by18WWvGwyXkGx4SVy1hD9kO2kPU9I 0Eifoq+s5XThiX2qD1FLqga8Uh9F7ScOEFhtlrGuki36hiicE4kN4wVUvRn8bwy99dgD AXqfi1WG+Hn6z3E88Wbbo+fImALMsnipycnLFZHDrb76KMg8XiYWsw0/NfPGWYdswf02 KdR6DS4CeoqVUQT7526kvPgTh8MNXTyoxNmjU0/6iPA47OCLpBd1fd9VMuFTm9CEM2wp YpfVtjfaHEZD0hTEZZ80e+aiRJv9uTr+QtRbNIOWiOsPBwXfD7ZKDnbiHbF1rY6SQ6dT nLmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695089; x=1782299889; 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=Ua5oAufZEffqM5l46feS+w0Dh95aYTaQPQ9PFyogonw=; b=Ru5IecZUN8tXn7e25O8eOWqSWcG3wlTdvwg3mOjMr80MROSpffpqs4K8mEryB+Dzcf oZaI0wd1Qr68vSHjr8zYIt7Y/CSIv2eLdPrB49/Y9kqcDBQQd8sfUU78g+CLzXc+y6iF bIf7Ayi/OQCeNsZ0Q3Y/I/9WYIY1mUdh3Sj2xHScxDpgbeaqZZEx69f7t1Yd7wb62SWH VpYJKYP1Ef9W8igw+3Ptgri2iG33Yopx/ohhLVLAl+fZtaF7CQU8j935414+zJKC0mwA 8Li6fh9TZX5i9fAmxzVTPjFluF/8ipWasTHJSJTLfw61IRvwfjr73AJajGsbCgKt8QS5 y5Fg== X-Gm-Message-State: AOJu0YybRcNnkEqDYLG6SG4T8sUGUNdu1XiuBh3O0KtNWL5mHieZjS1N aYGU1vt0SzHw2HCG6vNdyKCityeUYw8zkfDsOHjtiBrFGICU5Le40/KrwK6DkQ== X-Gm-Gg: Acq92OFfjoLCdpdZh5tF7C6UbE7/2OsKTquqHrlVJ+1/rV87HmLR6lh3+I0ne0tXANx fT+7kRWAgchO2trQxDPl3+2DkuIN6SsCyRjdA1pvJUMSkCVYnlp9nLjYp9VF6X8vvHToyZYDvwJ +M4sBSXLvrTP4spS08h0IQb1U+Z6IO+Y6sdY5ZzSsXbh6DIEL9O0BwemnTZ7P9osAxiIJ+vA7Dn 1bHZb3p4CEaof+coHUcTIBqGeMfVFiZlwIc0qNBdRnUrm+jgdWwQ5BoPFc3bUYaT6qj7ubNRn6R nok6uH0NnpG4KgGYV97vmTxgXCaDGm29juflJpIk3y1MMl/5DZN+h5GqQtP9JHwdr39/6xnh7zg FCWyO78pKP9HwyWvqzmvQY6qUdU7MI7ECnRduT944CGL4rUHcz2I2znjFkw/oKt7gORyOE2VtkB NvFEJLWXhMFwz+nbd+Th4HHH5H7ko8Ttcbv7upfJdXA5TYn1fmCgMqueTmiQ== X-Received: by 2002:a05:600c:a319:b0:490:e170:b80b with SMTP id 5b1f17b1804b1-492333debc8mr52137195e9.32.1781695088580; Wed, 17 Jun 2026 04:18:08 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 08/23] xen/riscv: implement make_timer_node() Date: Wed, 17 Jun 2026 13:17:36 +0200 Message-ID: <85c87a6e2a8116a8fa8a9a0ea03c8084d95728f6.1781693963.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/1781695089-4866B3FF-7533A809/10/73395122804 X-purgate-type: spam X-purgate-size: 1616 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695111786158501 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: - 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 c1cbc4386312..4c21ef37a6e1 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 Fri Jun 19 21:21:20 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=1781695130; cv=none; d=zohomail.com; s=zohoarc; b=nSeLNncpfTMFnGtZm5VrMqipwy4DFw4C11P//v7//XLXpFMPaqd5zQ+Cq3AX/JY4dy8jbDaNca1lsc7P+KbWmfRfZjhzxa79FRrDY8xvmdc3EDSF/wpBidJDA9wbirCZ8w3Bm4ppw7jhY9Ncw5kdxSqcfN8Ow16nn9D8LpV/jkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695130; 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=4QqUVygSKuOYRxT6E8v4W6Rx56YdB/LiXLrQt30w45I=; b=fNPhRB8Bh9yOGtri2kXnkkZ8lKW25PqAbwZFbMQokLQJUMbD7MdRwwHb5YEc94sizMzuc6eRTAWRUBalWSOPznhcl3VARnMAMccC3PpXFvmoVfKTDmAp5200RYAmRs8JSSi2mJmu25jXBOhyeNihUOpHUX2+Ty9NezvdN8BJ2vk= 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 1781695130375665.1564634871438; Wed, 17 Jun 2026 04:18:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340090.1601147 (Exim 4.92) (envelope-from ) id 1wZoHd-0002Tf-UJ; Wed, 17 Jun 2026 11:18:13 +0000 Received: by outflank-mailman (output) from mailman id 1340090.1601147; Wed, 17 Jun 2026 11:18: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 1wZoHd-0002Qu-9O; Wed, 17 Jun 2026 11:18:13 +0000 Received: by outflank-mailman (input) for mailman id 1340090; Wed, 17 Jun 2026 11:18:11 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHb-00020I-7f for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:11 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHa-00CoIJ-JW for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:10 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328270-2eae-0a2a0a5409dd-0a2a4506b2ec-4 for ; Wed, 17 Jun 2026 13:18:10 +0200 Received: from [209.85.128.53] (helo=mail-wm1-f53.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328272-7371-0a2a45060019-d1558035b8fa-3 for ; Wed, 17 Jun 2026 13:18:10 +0200 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-490b7866869so57377375e9.2 for ; Wed, 17 Jun 2026 04:18: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 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18: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=1781695090; x=1782299890; 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=4QqUVygSKuOYRxT6E8v4W6Rx56YdB/LiXLrQt30w45I=; b=IQNUT+ake2+WZNYsyellpUM2s+TkjhM3jQj4/9osbBC0j9+D3jzjVqL8AGEpXLbwku abLzfD5ZRCET6cr/j4W7dlvQ5lOhsDF+5iEEVUCV3Q9XUNMia2aZIXhQLDKArA+syj0M FPgigHJGBMlmCXLUjyOMBRmZXVC1HYcErIlCRt9otGLKTDGTrPR0GJY0B5tFTozEPUfH 3nyUlY4cvVQvd7IoJWOcqTWd3UC8WglhRQIwJ5vvYaKNh7S0b0I5CC/WqYJaFO5AHxL9 5wD+k+8SqP1Cq5mNbVYIkeHF4s96dTAOGA2ZrIGQ04s9IEdarPbztQj0NKKjV1pRO0uN VIPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695090; x=1782299890; 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=4QqUVygSKuOYRxT6E8v4W6Rx56YdB/LiXLrQt30w45I=; b=EKCDLuQPFQRq66K+rJyMqi5hVwNjVCUgCbz0jjRI9MjW63rxHdliNCfJDeCbNNxajc Y6IJ4p9lYKSEyQ4adWGeOR2WhhaphsabisPejVdjWnYQE2cWRRIpH07mwucz/CLfTUfX nOWW21UEZI5nHBvfHtvqTXWejWCBYWvUtyRssIQq3JVXUjsGgpO/ZVqRjHfG2ofz5TDI +uZLtrV5hHzpvlCA240j6y7f/8lnkW+TgMPD6mexiYm2CCnG1ouHEig6OPoLWYPaalZL npGKSbDtqJpUOE4HrZqsk4Gbrjl+z1EM/YnW0FD5tEx8QdNXao3xOEX77XhAGp42O2Ib /JZA== X-Gm-Message-State: AOJu0YyKfnCpUOMSzDySRepNELyYhHyJlhcsd/bC6MYxVHGftSbMSXzH 5ahIXsEEI4Jt2bmtWjDu9Zdm3OG6yMVaZQs0gESTcvKrqvqpLvJsOJlde6664Q== X-Gm-Gg: Acq92OEkviSc2xApF/pHnDhTUTKTDgvGHURGrj/41JkQMijEz8CiNhhCgElY10M2Il7 h1C+8wIXd2rGHozrrtkXJ9aLSRqV1/0peZwskbKReoC1ATmbgzoFm2XOHczGKOOSoSEPQPxoJOm w/BtZrrxs3rVHOoi0ljntQVnm3q4WFYWWi76n81v6DjPKQdJPrUiyp7279z2HuFW6kDHp5SHLRt UxYgL7/oOUK59mJYFjrHZIQsiKJ2dI5jwGyPJAifrZ8daPT8mASMLHER67VLUXgtsLGRoSd3u+g nF3AHA+CL5Jv6m5DWerwdAypVhA/BTOzKyrFZINJPgebcMUUFLhgKlGAdr+4kkLZSZjeMmnn11j 31rU2Y4FQ+e5ERGV5CKaYrE0ajM4lCRHbhbeCVzyfo9V9E4wD0YQ1lx3XnB1W2Lr5hEGBhhIchM URm9tmO6wCSXH0ZSqppHjHOqPPMxTCZu2GMOA9UaJPQeINTI95vkaKm+ri8g== X-Received: by 2002:a05:600c:4644:b0:490:9d1b:f06a with SMTP id 5b1f17b1804b1-4923410388dmr26929715e9.10.1781695089636; Wed, 17 Jun 2026 04:18:09 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 09/23] xen/riscv: implement make_arch_nodes() Date: Wed, 17 Jun 2026 13:17:37 +0200 Message-ID: <738f97f8ea8bb588742c3f03d3cb2d24f399b602.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1781695090-8797CD75-58EC785F/10/73395122804 X-purgate-type: spam X-purgate-size: 1230 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695131896158500 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 --- 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 Fri Jun 19 21:21:20 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=1781695131; cv=none; d=zohomail.com; s=zohoarc; b=icD8/XK2ZUP2ti+xUrygWdp/LOm9IflPdLjOZ4sj61tqPR7h9gctIp0pJU4ZydWXtE+H//BNruW5bUWfbp/6sTUoFRJR19qY41zm8Gsoc8LgMkaWrQA3vzorrCXyiY7Yk5P0S+wdZnQqO6sHzqbrPsAaZp2jYh2LQBf6/9gSQo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695131; 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=JJCEZ0Pvvj10K/+6xn1dWHcG5TZx9e0qejLfuNUUGJ4=; b=GJG6IqPcquDlGfkitTo8hC0Yg0boN8h2aisKBBXL1GZWLhPPnhfpwtKvAz06DxuJ1Qz9ckW29WP+A5cZfXnBDk2piGkTMYD7qm/0n2jurgYnjP9YSCSvQsQPF2rxe/DEMbB7OtLQVtPzGsE+5O+sSIZP7jScEZkCwJKBz9i0+Dk= 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 178169513166948.01479674739903; Wed, 17 Jun 2026 04:18:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340091.1601165 (Exim 4.92) (envelope-from ) id 1wZoHh-0003BX-Rz; Wed, 17 Jun 2026 11:18:17 +0000 Received: by outflank-mailman (output) from mailman id 1340091.1601165; Wed, 17 Jun 2026 11:18: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 1wZoHh-00039Y-Ap; Wed, 17 Jun 2026 11:18:17 +0000 Received: by outflank-mailman (input) for mailman id 1340091; Wed, 17 Jun 2026 11:18:12 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHc-0002DY-Dr for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:12 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHb-00CoIJ-QW for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:11 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32826e-2eae-0a2a0a5409dd-0a2a45089c4c-16 for ; Wed, 17 Jun 2026 13:18:11 +0200 Received: from [209.85.128.43] (helo=mail-wm1-f43.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328273-63b5-0a2a45080019-d155802bd8dc-3 for ; Wed, 17 Jun 2026 13:18:11 +0200 Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-490b9318997so41486405e9.2 for ; Wed, 17 Jun 2026 04:18:11 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:10 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695091; x=1782299891; 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=JJCEZ0Pvvj10K/+6xn1dWHcG5TZx9e0qejLfuNUUGJ4=; b=cwI0Bm3tYklDjwnLnG2UU0k/AOLAMtB0+k//wEKOIw9SNzrutriuzd4Tl03sKAtGDT ACWUhO5gJlkrU2fgtUi9affKSb9GophN84s/l0SAXaxCccVsfDBJYO7iz8OAzmj60ZNz EF6xZ6iuA/cxjoOPiYNqcXkv+v7re9p2Z2rf3YU63WhK+HQWUD09p1Wje9RRNStBtMGG soFBmj5A4galck6xEHqkWS4DciA16pkPTfdiY7tfhIoU1IK1BgtBG2TOsnokOW50c7BR bY254aPs89XczABtHW2/RLANg2g45W9xkGKxVe6qt1SMKo6Y9Djgq2EkzSC7P5gkh/dA pgwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695091; x=1782299891; 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=JJCEZ0Pvvj10K/+6xn1dWHcG5TZx9e0qejLfuNUUGJ4=; b=kXvshx8vX7pNxJP0zts7GqZKOnTWS1miLA4OE8mC3jlcr1lC/xsu+KPj1mcQcI7Hsg D2Dew5JoiZ3FiTqBeewTgp/WEm3pLhFzw5blUtgATbQXv0PC2cPF5TIc97TkuwvBiVso svgovwgKOES1S+SqHUk2UzkAFePQLIW73UKZGcm1gUmsOETFbBByUSZtdU53nDRPY9vA zecE54L0RojQiqkpr/Tv+TMm4d2il3cUU+G6xSsJSeIkpsdcrAmO049bpe2henidr9Bk kT1WweJyqXVZiOriYSsx8TPn8kgXwzDRWbPAUibqLc/X4DKwhMXhSZNePdU6eqqn/yFq lC0Q== X-Gm-Message-State: AOJu0YxoAPDLjd4or9zyg9l+0mxpJBGztpkbtEy+XKl2PrZnx3UftTfa z8wNYhPX+ymRhGDyy8l1BskoNK1v4bKZ+3F+713I+4p4xAqPT/cD8AWxvdZ4zQ== X-Gm-Gg: Acq92OGgZ4a6qGb5w6i/BtTkYYWEiObCOH+GbQoa2kmLgLnOZ8PQ21x8HG/dtb+LPkq No9mZXGktNBAU5v1py+YLB0goiQxzs7nei/EzfEm+k9xb+MeJIQ0noODjZIpFr1C7/flhm58iCu pXaP8s3LxMhl0+Gv6EuxsLUXSdkafsz+F7HLon6+OciwhhLQ8PvYtW8J0n2fPX94p3YF49ZFKYM iEZw7n64DT9YETaDZ+zpQKJG+2qKICZcqAlJgjQfP3oMT1gwOEzgoJajDFyiyIXCiw4uukLidlO DpFj1bBdVMS+2Ov3Vzjjnn/z/GLQaen9SNfncEQp8FqZuoogXxLlb2ycvyVhkrtR3OgjfxTnBv9 gOv9FypVzPYOsYairggvShA0wHZlslixyi+ycKcWZYaqbY+/7/U0N7iwXFbNGtsdu/BXXGHHb0q JQgK0LIw/UuDLzHWF0Gvzah2bgeqTCB24V6hajI4O+c/6hX2cH/gh8nVv+fA== X-Received: by 2002:a05:600c:a148:b0:490:44eb:c1ec with SMTP id 5b1f17b1804b1-492333dafe8mr40448785e9.27.1781695091031; Wed, 17 Jun 2026 04:18:11 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 10/23] xen/riscv: introduce init interrupt controller operations Date: Wed, 17 Jun 2026 13:17:38 +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/1781695091-B7B7CDB1-5EB7834B/10/73395122804 X-purgate-type: spam X-purgate-size: 3769 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695134134158500 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 --- 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..620768fb6164 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 __initconst 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 Fri Jun 19 21:21:20 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=1781695130; cv=none; d=zohomail.com; s=zohoarc; b=FCAmi4i1n6h2CclEruCjGsKnXK/FQjV5A9eQnOXl4VWokvc2Ss2MxDp8P/0d/g0MDWWlOap4Kiln8mrYe2dg9qmMXjwUYdzY3jeYq1fKuX0lZmS5F+Uv3kXEq3tYmr7EqysjuTBHS0jplLxEUrexEaw6RUGx3+iSffF29bgWxQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695130; 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=JTR+5Hn5G7Lu4nePlK2+AFvBwLwdKYyMSMvXluDf1/8=; b=jCoSWxgTV0kRX9lLdS5h82u9ZM4ennWHKpWH1dBAtrl8jQQR6JiymI0REep6mIY57KUrRc/6DBBD5Eu2J3TLF+sCnF8Ygc1DQsYUZSKZzJEdsQKarMEbCKNWIO7Y1JUG4sq97ouMpXeOrzUgs6qmnVXRk97tDCs+O0M5kYAVbzI= 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 1781695130668215.7028860024069; Wed, 17 Jun 2026 04:18:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340094.1601178 (Exim 4.92) (envelope-from ) id 1wZoHo-0003ta-KC; Wed, 17 Jun 2026 11:18:24 +0000 Received: by outflank-mailman (output) from mailman id 1340094.1601178; Wed, 17 Jun 2026 11:18:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHn-0003rD-Oa; Wed, 17 Jun 2026 11:18:23 +0000 Received: by outflank-mailman (input) for mailman id 1340094; Wed, 17 Jun 2026 11:18:15 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHe-0002dE-Nm for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHd-008nTo-3B for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:13 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328270-bab6-0a2a0a5309dd-0a2a4504bf4a-30 for ; Wed, 17 Jun 2026 13:18:13 +0200 Received: from [209.85.128.45] (helo=mail-wm1-f45.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328274-1dec-0a2a45040019-d155802dc8b4-3 for ; Wed, 17 Jun 2026 13:18:13 +0200 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490a76757e5so40645345e9.2 for ; Wed, 17 Jun 2026 04:18:13 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:11 -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=1781695092; x=1782299892; 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=JTR+5Hn5G7Lu4nePlK2+AFvBwLwdKYyMSMvXluDf1/8=; b=bQSaHdgKcrzLKVK0C0VWyEyjZv+I0kRZ1+jrpXCk2UBzFUbIJCUfXaaJbHO8LBJAbV XoMhnZbyKNV0oZ7GB70rn8m96xp7lvHW2BYPg6huZizzpycC3JE1gN04sVl6/YeYYL84 Fs5PaZMg8ZX+pqVh2CWISBtfzStn5xPnNANU21tSxMt0jXUSC1eAY+X9bWQi4PdiLWOM dgEjGcxo7Zf6dkaQWP38bJqB4GXsJRBRes9vqzmH9doxyTIXucd6Bk4b7AGVioptEzNb rLEgcvnJoRZNfRcBYy2BN2onRFswqXOZGC1wUGZ7hmsLOdaXhlSNXAhGicGehs2LSOdR GkFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695092; x=1782299892; 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=JTR+5Hn5G7Lu4nePlK2+AFvBwLwdKYyMSMvXluDf1/8=; b=aG91UmCLZx4p7djk5XOV7JXgDbubWf4N4uPwp0DrUnEKg3Y4F9c0CXSosCdX81uF/+ W0+dkMkKykGpA6cVj2acBpa0GZxL99+KCoscMEWxMaYRKE0oHiSfYmnduIN3nNh0iZMN CFLm9p2kndkKvaql5Wk8BF3sLEDezloMR27ttCaIRRmgWnQS5fvgXuifms9MSUmTd/Xu Gt91m7oJ5+OBliC4OM2SvaZrO9bJO5qm3rmmTRvav74E/HSg/YWLGZOWKNO7V6Sg4nxi Z9QK7so0VBDJskaMl8XQutdfWPCqRdIrEvfin9U2Vv8pNQAOuhoTWph322JFpf0uZG5R tFBA== X-Gm-Message-State: AOJu0Yz5+Lg/o/5wHYqxwcvkytfNBEcMiBq45dFyb3csTpdq6h4expNk 0FOfb11sJ1NdY2/bHj0do6rlgWMMk17ZkmtDvS9uRDPvIz10inAXe0VNmlUyIw== X-Gm-Gg: Acq92OG+Iqt5FZgIhtMN+LwmzqiyWW0luYTOQn16OJ4hrn9S9gb6tBlJD6nXvmR2dPh Pax8dvmEr7kbF1dKrSnIR+GvrDAr0LOYtDHSPrGV8VC6j9scLgSkOmJ7TordiQFROG1ClKxQvVh MVZ2Xf58h6xcsXGajY9OQ60svDfwBQEp/yNNDF5h6sHFnHiYiI1gadhUlid4C8xjgvQjWFeyrEc RXPIYgvKlV8LZXWrxNWCfSfoZu6BtkUEIbmipOW9qO8yuvK0NwMu02vJ2qbtmqGOgWm5az2iQJ+ iD8e1duPq34P5kgTHQ0YErL9J3YAleTREz1NhiFyCzm9s188j5dMOvrmRoZM6rhWaMc2b9Kfhx/ IMUWugYDIICyPLRBt7cosJ/KuNzbg35z2pZ+yAkScyfX3MvRG/rshHYIhoabz4vROACvE6mh0K0 pELlBxncAPocx2dhkZVoSyIWS5fm4NXhmKP9A3Og0VJhKJlpzF9rTRdJYPmA== X-Received: by 2002:a05:600c:828e:b0:490:c024:2ec8 with SMTP id 5b1f17b1804b1-49233356d67mr63644725e9.0.1781695092263; Wed, 17 Jun 2026 04:18:12 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 11/23] xen/riscv: implement make_intc_domU_node() Date: Wed, 17 Jun 2026 13:17:39 +0200 Message-ID: <7b40037c2d0cce84f9e65d7c4a58ec773f7e49d0.1781693963.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/1781695093-2A37F3FF-EF9655EB/10/73395122804 X-purgate-type: spam X-purgate-size: 3376 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695131935158500 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 --- 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..31e08e3a1b65 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) +{ + struct vintc *vintc =3D kinfo->bd.d->arch.vintc; + + return vintc->init_ops->make_domu_dt_node(kinfo); +} --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695135; cv=none; d=zohomail.com; s=zohoarc; b=ifBmWLE5kYC23rK6gEqgixbDJwVZQ2s/OML0zZfVca2U3OnRwt2syPg/TkAyN7c6/g5MPipTjwWtNfCXyDsaEW8UJ1rbpEvq0gLsfRddrBxG9r3G+mPjonNjE4QTqIFcRab4+WBzQE1zaNomFwdHgcJWJdNBOjFOrpf8oeKsbAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695135; 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=bHK0+oJiotjmDU6k0UIB1KR9MCUa+178QTbLj29mVA8=; b=U0YkI82FSHY0CDOpOjo+I22uaoXgVwCe80tShTKsMulSL7naA+oHVgKzkvxeLAprMeb9fmg2QO0QND0iM52tl9NzfaicIjrBGy8WYvNPwgIvLGEdbgz2C2vKvGJRhW/fP9GLHMWFcIypRcxjfT3bRscdVoPYooCrDvp/w9edILs= 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 1781695135584915.5595498670716; Wed, 17 Jun 2026 04:18:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340093.1601170 (Exim 4.92) (envelope-from ) id 1wZoHk-0003Qs-Ip; Wed, 17 Jun 2026 11:18:20 +0000 Received: by outflank-mailman (output) from mailman id 1340093.1601170; Wed, 17 Jun 2026 11:18: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 1wZoHj-0003P1-LF; Wed, 17 Jun 2026 11:18:19 +0000 Received: by outflank-mailman (input) for mailman id 1340093; Wed, 17 Jun 2026 11:18:15 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHe-0002dY-PQ for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:14 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHe-000VKU-5G for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:14 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328263-e002-0a2a0a5209dd-0a2a4507bfe6-48 for ; Wed, 17 Jun 2026 13:18:14 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328275-229c-0a2a45070019-d155802af1d5-3 for ; Wed, 17 Jun 2026 13:18:14 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-490b64c8311so55009965e9.3 for ; Wed, 17 Jun 2026 04:18:14 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:12 -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=1781695093; x=1782299893; 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=bHK0+oJiotjmDU6k0UIB1KR9MCUa+178QTbLj29mVA8=; b=BNMtO/Dhc55Zz8m0U7AOLCwnW65ZVwhw93eQbGx8CR6+NuywQMTRd10KnrN4usPiQM kgbPZHBbF8Psl2E/yjhLl9Wah0TCvXQ/VilvIPXxaMNb0WDRZ5MUtdoDZJ/ByEj/l4oZ 8JSQkV+zsH2ezX5ct+DTgQA7d/CVGY5wRZONiipLGPXL9fVvepW9aYfEfaDJZKt+cr/d 57vbjT6C/+veZpdirHiPjfMw61t9mRd6GL78LAKt8kiXFQewNFz801cYv+Gl9ZMjP0pn /oYS5I7xgUrF0aSydeo22cJ8UkfiteGLysEZ4aM7Z2L+m+BIZEk5QUhBvDJWgUmR71Wn txnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695093; x=1782299893; 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=bHK0+oJiotjmDU6k0UIB1KR9MCUa+178QTbLj29mVA8=; b=dJGkAkCiendlf4NDzFlp4DIQs8wx8pVgnLboLAPmgb+G/pP/1pp4C6YfUtNYoxnr+b IDV25fCXxwFx34LKikosKvNXYWXiy6GDv22vHwLqlhWfsjMzLv3kadVH/8bkp236cnpo hoxmL6QqXlU2eg3vzr1XPirNg8DD5sKvwCM2r5PjelDroCQHtCJJUTd6umlR3HG9lBUV /MHyOzLKJGc1F5Xs7PTp0t1LhcQ4jf/VwL6Utk6hpu70HA8EP/GZvCjcOyZUQT8WVuLx 3C/hx0zP3tLZAWtVwu0H9qV2fYUt1WecYC35IcBgrhnZMk2Zvrn3WmZ4FyaTdYJ1nILI Vrmw== X-Gm-Message-State: AOJu0Yy4A5D9daVJ7z7Vt/6lCp/E4sBosJonDLavdIh1QSgXsof60S36 ypyb1ftst51jArXLEj0tkW9iULMf9TDJOz5sZgU87GsEjI3cNeKjbmobX+gGFQ== X-Gm-Gg: Acq92OHdGopVzA5pKw78A6t5g2d5k6SAnRJTTFnA0qyn3ZOiTbIu+lQNqR+Q50bXCYi HXD10sMeMOVSX3x/jsl+c05x4yKsncYKyBnkNwbzLzKJU6z9SVkxrpBEND1ZS1XWn2xfHxGbSDR IgY2VP2PaiX4XlziZ/Gbxy0vh/XfQvogzkyDDu0tjA7Z8dDvT4t+abv0psJuTsSuhH6pfncpaFL Uuod7pkLYe2w4/SWRutO/HR+5DMRkffS2NBiPNoEMGBuYYcxmdXmasnVRL8spALODK21T7lvTti /kGKD+b2ZT8Z5rPpR+qxW+jemmGqGKubOv6aYTstk+6GBQl+cFi1g4+QSmbb6aG2yfPZYZnYThk FgShiaSK6wLXEkd0EOW126Jh/OOOlnyMsgJWS6J3O2FyAbDoj/qWkmbxDWS5FvForUZjmHyTwTn L+A1oKY7XxCjCGYv9EA9WbK9wi4+POsvy39Y2zX8hJRJwjWi5lFRt+O2TAvw== X-Received: by 2002:a05:600c:19d3:b0:490:b99c:9337 with SMTP id 5b1f17b1804b1-492333a987dmr60965425e9.10.1781695093243; Wed, 17 Jun 2026 04:18:13 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 12/23] xen/riscv: introduce aia_init() and aia_usable() Date: Wed, 17 Jun 2026 13:17:40 +0200 Message-ID: X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1781695094-0A573C48-8B43B7F2/10/73395122804 X-purgate-type: spam X-purgate-size: 2968 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695135940158501 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 --- 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 31e08e3a1b65..f0ce27a96c1d 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 Fri Jun 19 21:21:20 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=1781695144; cv=none; d=zohomail.com; s=zohoarc; b=X/fZlGKes/9GQei3vLTkO/2YM6+eDpKNaUT6ky7R+KhAKCvGaOYijHDDU0HyATBoy2SWXqdYsT1+BDXnpBDEBI4H0oiAJExmIT4kqKkFbUe9yDTPa85bSXT57s7VFG6zATnbju/Gvz6rzbXRJpQJOl4ZZ5fDkU1FezXKCo4aOrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695144; 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=5apYusI3YeOAogzQyvyi2oh99FaaceCirHZlTfuxF20=; b=D0zLyhGY4XXHf596UV66kpPI45xxSvIbMBC4rbOvw1tXKGPfKUIq9X1vhGkSCJo2SP4s5xYK+JepU2VWxgsrNAKfvU41OAPLKQdiTul0Idcsjthy3+eFeNHGhxg5v7NrY7O5Cc6IiWabY1umcLYfZXoafAIZ+SgX+okktYqAcvs= 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 1781695144735937.8754595654624; Wed, 17 Jun 2026 04:19:04 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340097.1601182 (Exim 4.92) (envelope-from ) id 1wZoHr-00043t-2q; Wed, 17 Jun 2026 11:18:27 +0000 Received: by outflank-mailman (output) from mailman id 1340097.1601182; Wed, 17 Jun 2026 11:18:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHp-00041G-FO; Wed, 17 Jun 2026 11:18:25 +0000 Received: by outflank-mailman (input) for mailman id 1340097; Wed, 17 Jun 2026 11:18:16 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHg-00030o-G5 for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:16 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHf-008nUF-Sz for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:15 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328277-5cb7-0a2a0a5109dd-0a2a4505bd80-0 for ; Wed, 17 Jun 2026 13:18:15 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328277-aaa8-0a2a45050019-d1558034b1f6-3 for ; Wed, 17 Jun 2026 13:18:15 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-490b613a17bso51746545e9.3 for ; Wed, 17 Jun 2026 04:18:15 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:14 -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=1781695095; x=1782299895; 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=5apYusI3YeOAogzQyvyi2oh99FaaceCirHZlTfuxF20=; b=a+UyCYNEoEvqx3zxG6nR2UUEZ3INDYjmz3rfbrXj4e4Bi/iRy11S91D4uCq7by1uyS Z+rCnZrTct9mOfJj6WY4ygeJ1qBZ7RiqgIZrSUKbYcnL/8q8GPA94dm8+2rlOoH6pSn3 KTbTd3mrIbO0RDP9LrMtJ2+BzG+TcHkJB7NeKmKQSJ1awol7TWUBu+B0BXQwh0RdT/IM MrHTfhPyXhRIa4yCWBs4EstzhKiu4l6OK5H8OgyBH1Z7WO8RtWYjhE5E/XJs5/j7bCe5 CMqoynzpLEbJEVmLunK0mUk6uYOVAm4iFwb85wTKcdBDB4d71m1FkYXj3eXO17XMiBvX APsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695095; x=1782299895; 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=5apYusI3YeOAogzQyvyi2oh99FaaceCirHZlTfuxF20=; b=SMt5YRsCfBXZdmj0MkmwaqcOulJZ4C8bLcKeqGi8PNsL4X5w6bSE9RuE3uJ4ljqvix JCGZFqeAKw3HmCx4mfDnUc16niB6EwBV8X0btRtcEU6o9LwJ23ZB7ObuyQ6pP5SzXZ5E eIDUcqvRee03PmbuSLxIG8+xhnsH+UnTdNt1f8EwSZZMPMynvsQ1Ge+hIr5h6y1FnvtX K1O5vgTKpVomPLH7SiH5LsZYU/oXg7Qj0itVfpVUFYEvPirMq+KxIsQxxw3PFp2CMQVT oEgz1TBGvGDD4zHib+n7QLqiyZOdEzX3jRMuNvR7HwDRfVdDeLkwiINtOshs79B+vlX4 Ww3A== X-Gm-Message-State: AOJu0YxbTEPcW4U12lAL/e/ANG5+oD/eUNfRaxRAlyj38q4xJZYRJRym swwSi81JBBvT4TphEZvSbfh4uAjNV/kiHweUwU1y7dFkF/Eq5S2rpCCVQrYNZQ== X-Gm-Gg: Acq92OE+mFc+z4CNTxVCyd4qhD7j+xycTPcHBMOnt350k0uX1yEoeIZOLs67tUkYqOF EeQKipz/vzn5HFi5XhLYkTPsrsKzTMePv0kw+ww9/1yD/kstqhnlu9sp9wZn4mM/qW2eR0UIq+2 bxyJOC7mIV8RnKSLkyCP6Nk0KjinMQdgIM1pJEPlVm0M9Qj71NJt/UUJKolSUWjLmnRZR8r9/YZ XufI9dONJP/7Iximpi2Xj+7tt/0952XDMNKW7bVnUpBj7S7T/Y1hRHRSJ8eyusVh6/HaQ7WTg+C Weoq+Ft5L30kGyVnu6AmPIiwsxPwYMVHoQCevrTtpBU0Yvip1tZl/ZgDA3chnhLnzGcQ0ePnu9K 73svgcGLHiCcR3OU6dKB45DIVw5lItB5fUYBMsRCsrkT1KLzfS7fqjMhAio719sVSnhfwWLeLxm zD3lgn7L4M3OOKQpePm5iu12p/oxFfO9/dSajq2cHFRU4Nbuqififln3Ujrw== X-Received: by 2002:a05:600c:c491:b0:48e:5d91:cfe3 with SMTP id 5b1f17b1804b1-492333a5353mr60236275e9.1.1781695094997; Wed, 17 Jun 2026 04:18:14 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 13/23] xen/riscv: introduce per-vCPU IMSIC state Date: Wed, 17 Jun 2026 13:17:41 +0200 Message-ID: <69b84024f185db01d62d6c9ece1b5cee0e20a25b.1781693963.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/1781695095-E1D9D443-68CE1B85/10/73395122804 X-purgate-type: spam X-purgate-size: 5579 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695146045158500 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 --- 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 | 34 +++++++++++++++++++++++++++++ xen/arch/riscv/include/asm/domain.h | 2 ++ xen/arch/riscv/include/asm/imsic.h | 22 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index f7b70a8da09e..59c7556327da 100644 --- a/xen/arch/riscv/imsic.c +++ b/xen/arch/riscv/imsic.c @@ -16,12 +16,15 @@ #include #include #include +#include #include #include #include =20 #include =20 +#define IMPOSSIBLE_GUEST_FILE_ID UINT32_MAX + #define IMSIC_HART_SIZE(guest_bits) (BIT(guest_bits, U) * IMSIC_MMIO_PAGE_= SZ) =20 struct imsic_mmios { @@ -56,6 +59,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 +320,32 @@ 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); + + imsic_state->vsfile_pcpu =3D NR_CPUS; + + imsic_state->guest_file_id =3D IMPOSSIBLE_GUEST_FILE_ID; + + 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..316fe5423c48 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; + /* + * (guest_file_id =3D=3D 0) -> s/w IMSIC VS-file + * (guest_file_id > 0) -> h/w IMSIC VS-file + */ + unsigned int guest_file_id; + /* + * (vsfile_pcpu >=3D 0) =3D> h/w IMSIC VS-file + * (vsfile_pcpu =3D=3D NR_CPUS) =3D> s/w IMSIC VS-file + */ + 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 Fri Jun 19 21:21:20 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=1781695135; cv=none; d=zohomail.com; s=zohoarc; b=Ijz+R+L/JjZYNUb7MyCIo9G+xQQvM8H1rL5L61XXQTI1Maj+fGUfWvid6kRJP99bSKXJidVOcOayWAmWS46B5xpdfZWL1jr2iw3eXf3s8f5dxiwMNvj+1CB0NhP/yDR7sG0msZ7KDmxV9e6hJX/WaN9wqagLdXN3cgdTgvqW8P0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695135; 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=YgS4xncGRmEKcmvBSvgWNruiE6NqAhsldZjnjIta9fI=; b=CB8Z7JYb0W8xrgmFQntFHmLcMQNlu15so0Cm2sZZCOglXBsXfemKBuF/ebFLUEOv2lUZzubYLed226h0fmZOihSj3jqx3cb4qVU36ut73+HpHE62I4hc4pi7RT5GhSk6BuL6glgCYGTnEZ6ZU0sR1VEATrj2imAhN8vAq+FFRP4= 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 1781695135294497.24782293673366; Wed, 17 Jun 2026 04:18:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340100.1601190 (Exim 4.92) (envelope-from ) id 1wZoHt-0004EG-3N; Wed, 17 Jun 2026 11:18:29 +0000 Received: by outflank-mailman (output) from mailman id 1340100.1601190; Wed, 17 Jun 2026 11:18:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHr-00049q-4G; Wed, 17 Jun 2026 11:18:27 +0000 Received: by outflank-mailman (input) for mailman id 1340100; Wed, 17 Jun 2026 11:18:19 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHi-0003Hf-II for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:18 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHg-00CoLo-Uu for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:16 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328270-2eae-0a2a0a5409dd-0a2a4506b2ec-28 for ; Wed, 17 Jun 2026 13:18:16 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328278-7371-0a2a45060019-d1558036f134-3 for ; Wed, 17 Jun 2026 13:18:16 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-490b64c8311so55010275e9.3 for ; Wed, 17 Jun 2026 04:18:16 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695096; x=1782299896; 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=YgS4xncGRmEKcmvBSvgWNruiE6NqAhsldZjnjIta9fI=; b=kunzc0y8voFEyo35ThAd4kc/rp+ec1ZoAVcqsiR2X90I0HOz7PUBIXSBTRx9Bjvbe+ 17axQM4kdDFRR1Sbb1idlMG+6ZfdSqo2YwXCTImzr0P+/JuZxa4PaND8LdKR/de2hygI F+0tklsIHeLnw4LGwNpzt4wGz3/NyGWTiRG47MBOWjDgmWJmEBnAqKsdZdYcx24wpVyr BM8MmKTfR58WjDapSdKN1hhwYC7uS2iuDqJFAEPRBPR9QV8vXGy2FDaUGSGMb77zHH9K 4Ltwvks98CuPhsaTAeKIqetduwviu1XfYCmYZfyThPYmXdluf8d/i7fCbeh320wGvN4j n+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695096; x=1782299896; 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=YgS4xncGRmEKcmvBSvgWNruiE6NqAhsldZjnjIta9fI=; b=tKv1+/8cp9pHfoMqKEAn3XjS3WgwxDzehiQTnZ5C6W96QWlH0pDuUjpKXpWxu/lv9U 1+KOuGAIR/kWIlFksYbwF/qsEaFOdyYYsnVbg3Jmhn/GWX72R9TusO4KwTqNdKLypfJy ytUz4DwE1JB+9fhZpvMspX6DIpy/9b7C9Rqdawas1Wm5XcaepaRj5vS6/pE3Fjji8Z8o SkuvaSo3fbP5gVfXj+TnIRxiEfgi+rmLJ/Uc6l3JCaE+dBp129bjwYqEjVzxeAv4lxfM bULKaWHa3Rcw9Yc9QJ2F+DURXSchhPQF3GtHRX8rHUgrwvJO0H6Y9wjyDHVb9utTfTXb i1Jg== X-Gm-Message-State: AOJu0YwWX3vKjnKFqJFrzvCT+H2PdfmIJnmjdqab89F9oPmoNQoz6QfK esWntH/+oaoe1Vwvauur4PcbAkShwmb40LnLjfuv9NU4mhfUNlEJQmu0YPefew== X-Gm-Gg: Acq92OFJqCt0EPlH8pPDWL25Ohn/+shDz6nxxFQgaWdU95Kxxd37eqaMPgjjLCbL+5J nwLqOo8rePP+TNgFD5QO1cqnpjXP5Jt8sMfgw+WklYjlEDblSXvzeM4CIxvV0hon3/ZyMob4qrY teYgDF2Etb62Vd41yIxrF43Oeb0MrAP7B4IlddZ3QYCT3/WWWJ8BVhrPgrVo3yB4fXawK0EKaoe SOK14TX1FCh7pAXy7pa1wJI9mCQ1+XEqwZK8FpKxBpvRXpeWdN3SuISK5xO1NQ0+BjAeCjKt2mw wxkAIh8/PWRUVHyIO+Gr7dNoJ20u2HTmXkU6M05FHyU9ujPJ3uw9Wq4x2F2IyNDf2pg6Ue+FD2a YvSBsd5ke9vEu+Dvo5DWWGdZFlmreb6Tcd/EJoYHv+k3msDawBfcmFRVAVvp22a+niy/iH7ZoJw fzoqyZRTS6CC+6H3oMzblAe8kEw+uNxtW8SR0FWfvib8woa5hZfgRr8eHgWQ== X-Received: by 2002:a05:600d:117:b0:490:a646:9d77 with SMTP id 5b1f17b1804b1-492333a1c30mr48448225e9.6.1781695096087; Wed, 17 Jun 2026 04:18:16 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 14/23] xen/riscv: add very early virtual APLIC (vAPLIC) initialization support Date: Wed, 17 Jun 2026 13:17:42 +0200 Message-ID: <9dc992009d0c1f9d1c6b6e88c0ea8bceabcb4d72.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1781695096-8556ED75-ABB18FC0/10/73395122804 X-purgate-type: spam X-purgate-size: 8822 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695136027158500 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 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 | 1 + xen/arch/riscv/include/asm/intc.h | 12 ++++++ xen/arch/riscv/include/asm/vaplic.h | 34 ++++++++++++++++ xen/arch/riscv/vaplic.c | 63 +++++++++++++++++++++++++++++ 6 files changed, 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..d443faac57c4 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -15,6 +15,7 @@ =20 #include =20 +#define APLIC_DOMAINCFG_RO80 (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..d3d456afe5f0 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; @@ -38,6 +39,7 @@ struct intc_hw_operations { =20 /* handle external interrupt */ void (*handle_interrupt)(struct cpu_user_regs *regs); + }; =20 struct intc_hw_init_ops { @@ -51,8 +53,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); @@ -65,4 +76,5 @@ 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 + #endif /* ASM__RISCV__INTERRUPT_CONTOLLER_H */ 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..8170e93701ad --- /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_RO80; + + 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 Fri Jun 19 21:21:20 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=1781695139; cv=none; d=zohomail.com; s=zohoarc; b=kXJoqdfUV/IdGhWKd4y689dF7XoFgquor6pxb4lJWHXoYTF0MjKvZvY+QsfzzT9Cr/k9oXYYJ5m0//f2ej20Uq/RFkubc9Gz4/t75gfylTRG1UkN1iJcJlArepv38qRfKYjOJ5A5cgnaJrtS6YCcGDO0rB6bUeFuU7qlbJJE3xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695139; 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=IqJ6MHjr1xcGHKYhTn6WrVMwlfb5wpnVFy95/sHCyxw=; b=EkcAtZnXnDpv1JTL9jjhtofWQ5Ennl6WH7ljbp5hCvTFG3PgFzN4Bvrxd7p0untL6sJeDKmi181jVjbhFBhRZOl724PgLwuzkNF+qGAn/pJgtqz2BA8/xwiQWaQFxYJ3sqzwG3bp2miBc0iGPWGNlcZvRKaVNjkQm/IVanrvmPo= 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 1781695139176132.85944519735722; Wed, 17 Jun 2026 04:18:59 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340102.1601198 (Exim 4.92) (envelope-from ) id 1wZoHw-0004nx-Hl; Wed, 17 Jun 2026 11:18:32 +0000 Received: by outflank-mailman (output) from mailman id 1340102.1601198; Wed, 17 Jun 2026 11:18:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoHu-0004Xw-LX; Wed, 17 Jun 2026 11:18:30 +0000 Received: by outflank-mailman (input) for mailman id 1340102; Wed, 17 Jun 2026 11:18:19 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHi-0003KN-UX for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHi-000VKU-AW for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:18 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32826a-e002-0a2a0a5209dd-0a2a45019d20-46 for ; Wed, 17 Jun 2026 13:18:18 +0200 Received: from [209.85.128.42] (helo=mail-wm1-f42.google.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827a-c1f2-0a2a45010019-d155802add02-3 for ; Wed, 17 Jun 2026 13:18:18 +0200 Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49222fb062bso46603515e9.1 for ; Wed, 17 Jun 2026 04:18:18 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:16 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695098; x=1782299898; 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=IqJ6MHjr1xcGHKYhTn6WrVMwlfb5wpnVFy95/sHCyxw=; b=Qun6agAgKNVx+lqmYNOI6gVGv07BZG6XGG15X3JS5bJDbeO9gCEuQi71MEqfcdqQku I5PumoB/6c9Vyn8KIEDMfaDUbIYS3R3Wot6qsNQmXSaOvJj/bu9jJWJPGJmFF5niKQ6h jw4hyQU+aW/ZiEpsPJ8smU87Maec/HO7MiMVisOh4bOHt3dMDH0g4pmBt/dWOYaA6Zsg HhnvwnfOew58DeoNHDtpTf5m/B5eJFZC0dKVOAlQy5gFZFgYcFns8Uzj4sl4ujRROjFY STuP3xWd37O1qUxFcEbCwsv6PZk5nz7iYX3OozHx4TgrLwBjEkd3x9glwMilyfen10Ej 86vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695098; x=1782299898; 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=IqJ6MHjr1xcGHKYhTn6WrVMwlfb5wpnVFy95/sHCyxw=; b=RrBEFdIqqRjihQhXZw9Qoe3Lnq1+Aupoh12Y82ixw6dL4LqNUOyLyRt5fV9MHPsJRd s/Xw82HmWJ2HSM9E+0z1Vs0Tn3Hcf7iG8xPqQryv75v7FvkNm45mJYmXwd4vXcU3R3Hz aaLQ5TDTOlSUrFP7sjJfsZw1igVArnLvzzZckUBzpc7mswWfbwSDpSsqx5OOAY9VHU2n /MXRc+lsHLbX2bCqLezvPMLapk6tACaaEz66huVOcre63Hj0KDYm0F1V4eLOOU5fRLSF AJ+PPb2Sn6TyZbQCPGIe2WWzBKlo4GrXFlk7mxiBcz6yBkA/aGkixfg86XqK1Um+RJUO a6mw== X-Gm-Message-State: AOJu0YzRvMBUJ7/kX1tehSzge/nuwxZmnvFsuRyLBCa55XmE3FghWkXV eV8GZUNNEUDD2VdDlEnQYRSCzVu2plGwqV+eoEHt61ruWS5vsjl33b72NhAtTw== X-Gm-Gg: Acq92OEto4rObK1DO8IIUFhjWKYk4rPbIGiz+N9cNl4WGN8bMoKLXj14siPvGsy69uP TyaLFspfNc1ut7APeoCfiduDqEqZLngU3umJBbE3VX79JaChRJTAWlAo5JIB7FhZ3YwwX4AD2lc WFYI0+6G8+sQ+RuJAMAZRO40sJplCnKh5XMsY/QKH7E09L/brzUhHjCgoukECqB1Igbn3Q0687l +nhT6AtYU3ONSxBolaGAFQjncis0cVvAJTrcmhWgMvRtKJJAwGkmPXcVyqexw1TZDTV3KKRn3pg f47qsmGQR6iXMPmOyhwV0WpbGkOHIdWarniQQ41wnx+cW5yps7+un5pnRWxWvYBkUS5VskXNMNf w8Kj4PfhOA9vHNSHyFnzFM5IBe7YE9BIA6f1juoz2DLWusyfnAhPNeO3YAvv0+g37fQ+fcYCEBE Kng8tNIaMiSf/N1V5fWkwkE83T3+9rPzs9xfckpy0MwFxIyDFPOMT7gllzUQ== X-Received: by 2002:a05:600c:3f18:b0:490:e1a6:25d with SMTP id 5b1f17b1804b1-492333eb308mr58326275e9.26.1781695097494; Wed, 17 Jun 2026 04:18:17 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 15/23] xen/riscv: introduce (de)initialization helpers for vINTC Date: Wed, 17 Jun 2026 13:17:43 +0200 Message-ID: <8bb11b0d9c905dd3dd9f922a3f1d2e7f2b75c978.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-d62444/1781695098-AFD51FF4-953E5EAB/10/73395122804 X-purgate-type: spam X-purgate-size: 3232 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695140163158500 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 --- 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 | 40 +++++++++++++++++++++++++++++++ 3 files changed, 46 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 d3d456afe5f0..95ca526e1223 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -77,4 +77,7 @@ void intc_route_irq_to_xen(struct irq_desc *desc, unsigne= d int priority); void intc_handle_external_irqs(struct cpu_user_regs *regs); =20 =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 f0ce27a96c1d..ec37b359f323 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,42 @@ int __init make_intc_domU_node(struct kernel_info *kinfo) =20 return vintc->init_ops->make_domu_dt_node(kinfo); } + +/* + * Guests are given a virtual interrupt controller that mirrors the host + * hardware: an AIA-capable host yields a virtual AIA for the guest, and + * so on for any future controller types. + */ +int domain_vintc_init(struct domain *d) +{ + int ret =3D -EOPNOTSUPP; + const enum intc_version ver =3D intc_hw_ops->info->hw_version; + + switch ( ver ) + { + case INTC_APLIC: + ret =3D domain_vaplic_init(d); + break; + + default: + printk("vintc (ver:%d) isn't implemented\n", ver); + break; + } + + return ret; +} + +void domain_vintc_deinit(struct domain *d) +{ + const enum intc_version ver =3D intc_hw_ops->info->hw_version; + + switch ( ver ) + { + case INTC_APLIC: + domain_vaplic_deinit(d); + break; + + default: + break; + } +} --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695165; cv=none; d=zohomail.com; s=zohoarc; b=mpuPQ4EMObEXfWsFeOkMmICPQO00jpMtClv8enomXdppx6iOq+sLOWn6bzQ3k/N/6RD+zme/sTihu2Jg6GmzqukL2PDNa7yWhK+PacfUF47pDYDSFeDf0tNQxmb7tU/5/93ahRLI7DYy5PnSxkiJW2Z6FAM7furT7MI1vBjGdc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695165; 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=hqxW/Z8jTjqVxphsP6AfDNKajwtIhbkCoRayADOZnAc=; b=m9KT31Q1n15gLVq5a21XJwZILMwRyo37lePQkH1quajh21LBtF6rKoDd8YtvygYlhz0pxwQ71aT1Tagt4znngz3P9+wuxnqfBFlsVIDpgyRgdGofMV//KIcdrhBYoQmBBcBaV/OHAg8FNB44iNdvyCoNT0kArF/0q0DOrSQd7Lg= 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 1781695165402216.16738954273012; Wed, 17 Jun 2026 04:19:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340108.1601218 (Exim 4.92) (envelope-from ) id 1wZoI4-0006Ej-Rp; Wed, 17 Jun 2026 11:18:40 +0000 Received: by outflank-mailman (output) from mailman id 1340108.1601218; Wed, 17 Jun 2026 11:18:40 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoI3-0006BH-6b; Wed, 17 Jun 2026 11:18:39 +0000 Received: by outflank-mailman (input) for mailman id 1340108; Wed, 17 Jun 2026 11:18:22 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHm-0003g1-0n for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:22 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHk-008naJ-By for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:20 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328277-5cb7-0a2a0a5109dd-0a2a4505bd80-8 for ; Wed, 17 Jun 2026 13:18:20 +0200 Received: from [209.85.128.48] (helo=mail-wm1-f48.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827c-aaa8-0a2a45050019-d1558030c520-3 for ; Wed, 17 Jun 2026 13:18:20 +0200 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-490ae94a89eso48531455e9.1 for ; Wed, 17 Jun 2026 04:18:20 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:18 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding: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=1781695100; x=1782299900; 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=hqxW/Z8jTjqVxphsP6AfDNKajwtIhbkCoRayADOZnAc=; b=ogsHn7cnOy1VLY/juXNaWHIPnS/A2XbDOvzVv3I1hIR4mDVfiwZlAnX4uBuAOtPPyt 4UebxQ0deLyv1vzVqxFOQtNDCuOkVAgtOsTnDMoQwuG+qUcWX4h6rjvu9KJtFglExx5M fsZNvGS/v+eFM2GTA0jWgvhXv/NIBi+XhuMXTRMtEGyPPRptjR9qJ+ijlcnTGmgQ7206 Nr9Rqk0F1eLU6S9PcBa+PWqThVsSMsioCuH7RvtcaQbtjOQyRHWF9BuW+Za1H3x3wPKd LSc9H+W0Ab9kYfV3UXVS8+1MBgJ/tK/PEso1JaAW0K7BIFaKP1xP42HcKfT+EjKLQuaD yGdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695100; x=1782299900; 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=hqxW/Z8jTjqVxphsP6AfDNKajwtIhbkCoRayADOZnAc=; b=dlcYvGjJ/FAw+6UEBSbr/vR5ArBADrSBR85wwthe0nMeVCxb7yC+TANDDuM9e6y+E8 FkRvuSM7Toy/YVyRSycCBwATg5fyS9/ftD60y2dP7dOf0bTpfDs665/L91qELbzZ0GQ2 bvh4qVWsP2qXa1WXK6Xuko2zq6j/VOV3QcHoPBSMiZEPzAMnX9Dp2Vcf5ubUl67Ky8hk bDN0Bt3A/smh75Meqqv3EXcSy6I5omZx5q3bwbbTwbwB/evdYQxoI8qb9368k1pRH2CI +axJLGK/VmqseLHgb5QXTZiI+kvEp26BxT5qvdLExvEx3sNoB5iXpR/uVz9efZKVoOkd ssxg== X-Gm-Message-State: AOJu0YwR2FZV4Qg+KbrmPzAKVeGb38najEznmX7BWipvhRrK8wRld1hO ++OR/oW9Ja9PiZmEI2dU4qDIUn/z6b2nDSGZACtvquGBjqsvF4rCUwLwJ4+YVw== X-Gm-Gg: Acq92OG8gaeoolAlQa5GGe+iFvZlBe7oGuafXiin3iOeKtb5ubMGkYZLVY+lNW26Z/s Z1llcEjFHTZjfl/vhp9WkBz1zSYqo2QbUgFYQJxW83t1u+hpaB4Ngav5+83HDp2d4kL3Biv9ytL enZyBR9JkJmcyYHE6+2Gsun3pNN6Ey6PMg3x9tT3PYOTyAYhnoF6tbBjGLUdu9kxDkgvrgBZG2M ExloEoGkCjWGOTgEYNPwKdG1/WfCQS7B18Rpza5UCVrBiiWrLCD+846eXhf+w/6RJFlFz8w6OHo yvfm6aBfO4I128O/9FO0ilon1ipGhglvsVmvp+/+xWjo0bsywcDXkkDZF9xWsj2Ke2ChtgsprUa Q/msm5yx64hDLuqy2Wy1DafzobGB7eoJctKVRdgt+Me68cY959nMifRg9grZpmzj0c+7iKakZ6E f4rWqQI/iI5HOUmd7x761TntpSikOtemJsBNz+vnrOhw85NyCXiWredpTh/Q== X-Received: by 2002:a05:600c:a143:b0:490:4b89:5362 with SMTP id 5b1f17b1804b1-492333e2f05mr43103235e9.24.1781695098793; Wed, 17 Jun 2026 04:18:18 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Alistair Francis , Connor Davis Subject: [PATCH v3 16/23] xen/riscv: generate IMSIC DT node for guest domains Date: Wed, 17 Jun 2026 13:17:44 +0200 Message-ID: <18938bb8845fa91315e320f88d17147592aba51c.1781693963.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/1781695100-E338A443-05B5E7A9/10/73395122804 X-purgate-type: spam X-purgate-size: 17200 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695166215158500 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 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. --- --- ...asic-VGEIN-management-for-AIA-guests.patch | 273 ++++++++++++++++++ xen/arch/riscv/imsic.c | 132 +++++++++ xen/arch/riscv/include/asm/guest-layout.h | 2 + 3 files changed, 407 insertions(+) create mode 100644 0001-xen-riscv-add-basic-VGEIN-management-for-AIA-guest= s.patch diff --git a/0001-xen-riscv-add-basic-VGEIN-management-for-AIA-guests.patch= b/0001-xen-riscv-add-basic-VGEIN-management-for-AIA-guests.patch new file mode 100644 index 000000000000..ae8c3425507f --- /dev/null +++ b/0001-xen-riscv-add-basic-VGEIN-management-for-AIA-guests.patch @@ -0,0 +1,273 @@ +From e423a993b2ccb28f59a2d941c503d7bb5b29e683 Mon Sep 17 00:00:00 2001 +From: Oleksii Kurochko +Date: Thu, 1 Jan 2026 12:53:07 +0100 +Subject: [PATCH] xen/riscv: add basic VGEIN management for AIA guests + +It was decided to add support for IMSIC from the start instead of having A= PLIC +operate in direct delivery mode, as it requires a trap-and-emulation appro= ach, +which is not optimal from a performance standpoint. + +AIA provides a hardware-accelerated mechanism for delivering external +interrupts to domains via "guest interrupt files" located in IMSIC. +A single physical hart can implement multiple such files (up to GEILEN), +allowing several virtual harts to receive interrupts directly from hardwar= e. + +Introduce per-CPU tracking of guest interrupt file identifiers (VGEIN) +for systems implementing AIA specification. Each CPU maintains +a bitmap describing which guest interrupt files are currently in use. + +Add helpers to initialize the bitmap based on the number of available +guest interrupt files (GEILEN), assign a VGEIN to a vCPU, and release it +when no longer needed. When assigning a VGEIN, the corresponding value +is written to the VGEIN field of the guest hstatus register so that +VS-level external interrupts are delivered from the selected interrupt +file. + +Signed-off-by: Oleksii Kurochko +--- +Changes in v3: + - Rephrase per-CPU comment from "Bitmap for each physical cpus..." to + "VGEIN control structure for each physical CPU...". + - Use %u for cpu in printk("cpu%u.geilen=3D%u\n"). + - Fix missing \n in "AIA: failed to init vgein for CPU%u\n". + - Shorten dprintk message to "vgein_init() failed: %d\n". + - Use %u instead of %d for v->processor in gprintk() calls. + - Drop redundant hstatus &=3D ~HSTATUS_VGEIN in vgein_assign() as + hstatus is already cleared before the assignment. + - Add check that vgein_id isn't 0 as we don't support s/w interrupt files + for the momemnt. +--- +Changes in v2: + - add static for defintion of vgein_bmp; + - Drop declarartion of vgein_bmp from aia.h. + - Move declaration of 'struct vgein_bmp' from aia.h to aia.c as all the + management is inside aia.c. + - Instead of decrement of vgein->geilen just update the wait how it is + initialized. + - Return -EOPNOTSUPP in vgein_init() instead of BUG_ON(). + - Use %u to print unsigned int. + - make bmp field in vgein_bmp not a pointer. + - allocate owners dynamically. + - Drop unnessary blank lines. + - use find_first_zero_bit() instead of bitmap_weight() to find a free slot + for vgein number. + - Drop the section number for the comment. + - Start to search from bitnum 1 for free vgein_id, as bitnum 0 is reserve= d to + tell that no guest extrenal interrupt number is used. Thereby drop vgei= n_id++ + at the end of vgein_assign(). + - s/bitmap_set/__set_bit. + - s/bitmap_clear/__clear_bit. + - as vgein_init() is needed to be invoked once per CPU being brought up, = drop + __init for it. + - Return vgein_id =3D=3D 0 if vgein_id is higher then maximun supported b= y h/w + VGEIN. + - Add check in vgein_relase() that vgein is 0 and if it is there is nothi= ng + is needed to do. + - Use gdprintk instead of printk() in vgein_{assign,release}. + - Add the claryfing comment above geilen field. + - Drop ASSERT in vgein_assign() and return just vgein_id =3D 0 in the cas= e when + there is no aviablable h/w VGEINs. + - Make vgein_init() static. +--- +--- + xen/arch/riscv/aia.c | 146 +++++++++++++++++++++++++++++++ + xen/arch/riscv/include/asm/aia.h | 8 ++ + 2 files changed, 154 insertions(+) + +diff --git a/xen/arch/riscv/aia.c b/xen/arch/riscv/aia.c +index e31c9c2d24b6..5afecde81d3a 100644 +--- a/xen/arch/riscv/aia.c ++++ b/xen/arch/riscv/aia.c +@@ -1,11 +1,33 @@ + /* SPDX-License-Identifier: GPL-2.0-only */ +=20 ++#include ++#include + #include + #include + #include ++#include ++#include + #include ++#include +=20 ++#include + #include ++#include ++#include ++ ++struct vgein_ctrl { ++ unsigned long bmp; ++ spinlock_t lock; ++ struct vcpu **owners; ++ /* The least-significant bits are implemented first, apart from bit 0= */ ++ unsigned int geilen; ++}; ++ ++/* ++ * VGEIN control structure for each physical CPU to track which VS (guest) ++ * interrupt file IDs are in use. ++ */ ++static DEFINE_PER_CPU(struct vgein_ctrl, vgein); +=20 + static bool __ro_after_init _aia_usable; +=20 +@@ -14,10 +36,134 @@ bool aia_usable(void) + return _aia_usable; + } +=20 ++static int vgein_init(unsigned int cpu) ++{ ++ struct vgein_ctrl *vgein =3D &per_cpu(vgein, cpu); ++ ++ csr_write(CSR_HGEIE, -1UL); ++ vgein->geilen =3D flsl(csr_read(CSR_HGEIE) >> 1); ++ csr_write(CSR_HGEIE, 0); ++ ++ printk("cpu%u.geilen=3D%u\n", cpu, vgein->geilen); ++ ++ if ( !vgein->geilen ) ++ return -EOPNOTSUPP; ++ ++ vgein->owners =3D xvzalloc_array(struct vcpu *, vgein->geilen); ++ if ( !vgein->owners ) ++ return -ENOMEM; ++ ++ spin_lock_init(&vgein->lock); ++ ++ return 0; ++} ++ ++static int cf_check cpu_callback(struct notifier_block *nfb, unsigned lon= g action, ++ void *hcpu) ++{ ++ unsigned int cpu =3D (unsigned long)hcpu; ++ int rc =3D 0; ++ ++ switch ( action ) ++ { ++ case CPU_STARTING: ++ rc =3D vgein_init(cpu); ++ if ( rc ) ++ printk("AIA: failed to init vgein for CPU%u\n", cpu); ++ break; ++ } ++ ++ return notifier_from_errno(rc); ++} ++ ++static struct notifier_block cpu_nfb =3D { ++ .notifier_call =3D cpu_callback, ++}; ++ + void __init aia_init(void) + { ++ int rc; ++ + if ( !riscv_isa_extension_available(NULL, RISCV_ISA_EXT_ssaia) ) ++ { ++ dprintk(XENLOG_WARNING, "SSAIA isn't present in riscv,isa\n"); ++ return; ++ } ++ ++ if ( (rc =3D vgein_init(0)) ) ++ { ++ dprintk(XENLOG_ERR, "vgein_init() failed: %d\n", rc); + return; ++ } +=20 + _aia_usable =3D true; ++ ++ register_cpu_notifier(&cpu_nfb); ++} ++ ++unsigned int vgein_assign(struct vcpu *v) ++{ ++ unsigned int vgein_id; ++ struct vgein_ctrl *vgein =3D &per_cpu(vgein, v->processor); ++ unsigned long *bmp =3D &vgein->bmp; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&vgein->lock, flags); ++ /* ++ * The vgein_id shouldn't be zero, as it will indicate that no guest ++ * external interrupt source is selected for VS-level external interr= upts ++ * according to RISC-V priviliged spec: ++ * Hypervisor Status Register (hstatus) in RISC-V priviliged spec: ++ * ++ * The VGEIN (Virtual Guest External Interrupt Number) field selects ++ * a guest external interrupt source for VS-level external interrup= ts. ++ * VGEIN is a WLRL field that must be able to hold values between z= ero ++ * and the maximum guest external interrupt number (known as GEILEN= ), ++ * inclusive. ++ * When VGEIN=3D0, no guest external interrupt source is selected f= or ++ * VS-level external interrupts. ++ * ++ * So start to search from bit number 1. ++ */ ++ vgein_id =3D find_next_zero_bit(bmp, vgein->geilen + 1, 1); ++ ++ if ( vgein_id > vgein->geilen ) ++ vgein_id =3D 0; ++ else ++ __set_bit(vgein_id, bmp); ++ ++ spin_unlock_irqrestore(&vgein->lock, flags); ++ ++#ifdef VGEIN_DEBUG ++ gprintk(XENLOG_DEBUG, "%s: %pv: vgein_id(%u), xen_cpu%u_bmp=3D%#lx\n", ++ __func__, v, vgein_id, v->processor, *bmp); ++#endif ++ ++ vcpu_guest_cpu_user_regs(v)->hstatus |=3D ++ MASK_INSR(vgein_id, HSTATUS_VGEIN); ++ ++ if ( !vgein_id ) ++ domain_crash(v->domain, "s/w interrupt file isn't supported yet\n= "); ++ ++ return vgein_id; ++} ++ ++void vgein_release(struct vcpu *v, unsigned int vgen_id) ++{ ++ unsigned long flags; ++ struct vgein_ctrl *vgein =3D &per_cpu(vgein, v->processor); ++ ++ if ( !vgen_id ) ++ return; ++ ++ spin_lock_irqsave(&vgein->lock, flags); ++ __clear_bit(vgen_id, &vgein->bmp); ++ spin_unlock_irqrestore(&vgein->lock, flags); ++ ++#ifdef VGEIN_DEBUG ++ gprintk(XENLOG_DEBUG, "%s: vgein_id(%u), xen_cpu%u_bmp=3D%#lx\n", ++ __func__, vgen_id, v->processor, vgein->bmp); ++#endif ++ ++ vcpu_guest_cpu_user_regs(v)->hstatus &=3D ~HSTATUS_VGEIN; + } +diff --git a/xen/arch/riscv/include/asm/aia.h b/xen/arch/riscv/include/asm= /aia.h +index ca42c3086126..6073c89774bb 100644 +--- a/xen/arch/riscv/include/asm/aia.h ++++ b/xen/arch/riscv/include/asm/aia.h +@@ -3,8 +3,16 @@ + #ifndef ASM__RISCV__AIA_H + #define ASM__RISCV__AIA_H +=20 ++#include ++#include ++ ++struct vcpu; ++ + bool aia_usable(void); +=20 + void aia_init(void); +=20 ++unsigned int vgein_assign(struct vcpu *v); ++void vgein_release(struct vcpu *v, unsigned int vgen_id); ++ + #endif /* ASM__RISCV__ACPI_H */ +--=20 +2.54.0 + diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c index 59c7556327da..de8c54cb33fd 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 @@ -36,6 +40,11 @@ static struct imsic_config imsic_cfg =3D { .lock =3D SPIN_LOCK_UNLOCKED, }; =20 +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 @@ -287,6 +296,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) ) { @@ -521,3 +535,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[128]; + 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..d757bb9219ff 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -3,6 +3,8 @@ =20 #include =20 +#define GUEST_IMSIC_S_BASE __ULL(0x28000000) + #define GUEST_RAM_BANKS 2 =20 /* --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695145; cv=none; d=zohomail.com; s=zohoarc; b=UhLoX9/6Tw0JoSESLGQIzOGTDeo4BVBeQHUopUNDwlm33bW2o0ofE5M+E0LqBcBLpDnfVyoJyrzmwg/omaS7xueAn9xI2mH+mPIqwvB/cuwPupwa6x67WJBIRH7Idgm2BCkLl82OTzNiid3CppoVoXSpwF2yi+FlTsCXV6EW0eA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695145; 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=XwCDX+bjauFbF5BAFy5k5d2Hdce0oX7JFJAMNfRxcjY=; b=H7CQjohTjRXajEKY88Q/tWQCM0+2DJDZJzL2pskkQTYJxu/PLCcVs3GBasWcLhkPsn8kZo+KW/n/ZJgVr9n6uyj+L6maiXRpxc4RGMlWeDxbViFmG8SE81k3sXlxaBrUR0/nNehcOoemn6KF1OfoWeVv8sXUFUMuMK6gSgKqpus= 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 1781695145196368.7440847803931; Wed, 17 Jun 2026 04:19:05 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340105.1601212 (Exim 4.92) (envelope-from ) id 1wZoI3-00061X-Al; Wed, 17 Jun 2026 11:18:39 +0000 Received: by outflank-mailman (output) from mailman id 1340105.1601212; Wed, 17 Jun 2026 11:18:38 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoI1-0005vb-MK; Wed, 17 Jun 2026 11:18:37 +0000 Received: by outflank-mailman (input) for mailman id 1340105; Wed, 17 Jun 2026 11:18:22 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHl-0003Ya-9Q for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:21 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHk-008naJ-JK for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:20 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328277-5cb7-0a2a0a5109dd-0a2a4505bd80-12 for ; Wed, 17 Jun 2026 13:18:20 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827c-aaa8-0a2a45050019-d1558036dd53-3 for ; Wed, 17 Jun 2026 13:18:20 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-49222fb062bso46603855e9.1 for ; Wed, 17 Jun 2026 04:18:20 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695100; x=1782299900; 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=XwCDX+bjauFbF5BAFy5k5d2Hdce0oX7JFJAMNfRxcjY=; b=EnkvCRWlB0T28MW5dklAjxjFG2u4H2WlyQ43FX2yqKQ2z9sT8lQFOpZxt6tRKa5nWK fgI+1XeFwnnycN4b0RsPKKBa4Dyhl27gxq5lVyoRe0NS/MOFZ9PliPZvDQeCfgtM5gIl VaNnoXG+J7wjPSXi0zP3zKGg9o7rfzLCKH/vFWwH3Gx4amlN0np9n9TQgjvFEbKFl+Vw AZaAZtMeVOop3lqVSMIZFtx+YSokVAR47Q8CWlIgKkVqL7XMuak0D1AFox53t/kBZhUJ BBOnyuGyVIsgwtToW74j4PJKXVkOYjCv5no47tXodFyOH6FEAkqjIyGSkn1sNkd/buJM 7Z4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695100; x=1782299900; 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=XwCDX+bjauFbF5BAFy5k5d2Hdce0oX7JFJAMNfRxcjY=; b=YQ7ofs0eDntt2/Z4gK8Cgc/PUqPSon6lhvpsI74n6OhrgHZoBOD60VRN78eGtHXaD9 aG3GyoB4raYVZn1OJBFhfrR7OFo3bAhDy39VnmBsrjHtzynjGbAlLlgAlQix/xNPh43V dlXKWSSSvQ2IQ9kh1u3J3LTnsAszP0nWEb0WAHjH6AlrzbZc5YrIlSAO1bFq/zTsxIB1 xAs6Gborfzqjtfv9qgRUfle47mk8vzjABrJTkb83jGTrqBGqm9qeS1Dp8q1+X+31mhTW 7wqdbH32lVlNm870lwaj3HMowc80+uNp2+854nJSUkCZkpJYiIHdrlmqVnwIagEOTsWp r1Zg== X-Gm-Message-State: AOJu0YwtZdsh5jPqOKIg5Xamq6KERzMdVDV38LGMttupsKs5bd70hUFS z1ktHU90DkYoQhcnAyxMgpH3XdPCFJLjzKxAfbCsoJP6C+MiYwfvvTkTg2meBg== X-Gm-Gg: Acq92OESN2oxF0e0NaewsrVeQa5yvYzGpIVwG3zwz6XjTQlXilisY97MfSwbbqSFi3U u2ZRC77sKDO+c5SRAiptGFokxPrXY/YdKMrXwaBCkQs21RbiQszo8olypHoF9dFC+GWWF2ghBQJ r/GL4AAUNXR7F19EqcZNkGPZCVzUN50MOP+oraRJWk5pU7ZyOyOp1RYSwB5Udrfncz/CGLA1z4g B9FFAnAQH4jIJd6LpZXq0Epr3QIV/71tO4/dMD8REZAMIRcXs6FdOOk905BpKC5PDZAWpJ75oRk ZkQsnfgp2Y23PT8MQbTyNY7YrIIaF4RSvbNEF3t5PpZiblfE/vinXB6L0/tvkAJvfml+Gfi0o/X bF3rJD0W6RHiNP4CEnm7p6t5cqBA533KOJoc2myEiaTuu4G3uRKsax7TxQsHCB9Gw+zCkyGFwGJ S8ybXnj2wZK9VJaSFkKsOjS1MeX2HXLaXdrWF82y+DG61qv/+oN1gZcH1xLg== X-Received: by 2002:a05:600c:c09a:b0:490:e196:6574 with SMTP id 5b1f17b1804b1-492333bf89bmr50542825e9.13.1781695099770; Wed, 17 Jun 2026 04:18:19 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 17/23] xen/riscv: create APLIC DT node for guest domains Date: Wed, 17 Jun 2026 13:17:45 +0200 Message-ID: <0b034d584b7aaec54b70e9e575c727b07930d2ed.1781693963.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/1781695100-DAB68443-C494604C/10/73395122804 X-purgate-type: spam X-purgate-size: 7553 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695146082158500 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 v3: - Fix rebase conflicts becuase of this patch is reordered after IMSIC DT node creation is intoduced. - Update the commit message. - Move initialization of domaincfg with APLIC_DOMAINCFG_RO80 from this patch to earlier. - Change paddr_t aplic_size to unsigned int in vaplic_make_domu_dt_node() and replace the UB (after it started to be uint) aplic_size >> 32 with an explicit 0 in the DT reg property. - Add BUILD_BUG_ON() to be sure that aplic size isn't bigger then UINT32_MAX. --- Changes in v2: - Avoid as max as possible of host properties inheritance. Only number of APLIC's irqs are checked what leads to an introduction of get_aplic_irqs_num(). - Move this patch earlier what leads to an introduction of vimsic_make_domu_dt_node() stub. - s/vimsic_make_domu_dt_node/imsic_make_domu_dt_node. - Refactor vimsic_make_domu_dt_node() to avoid re-usage of APLIC host properties. - Drop next_phandle as it is now in common code. - Drop const for kinfo argument of vimsic_make_domu_dt_node() is is going to be updated inside vimsic_make_domu_dt_node(). - Use introduced before vintc->num_irqs. --- --- xen/arch/riscv/aplic.c | 2 + xen/arch/riscv/include/asm/aplic.h | 8 +++ xen/arch/riscv/include/asm/guest-layout.h | 2 + xen/arch/riscv/include/asm/imsic.h | 3 + xen/arch/riscv/vaplic.c | 76 +++++++++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/xen/arch/riscv/aplic.c b/xen/arch/riscv/aplic.c index 620768fb6164..0abe32c2e446 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include #include diff --git a/xen/arch/riscv/include/asm/aplic.h b/xen/arch/riscv/include/as= m/aplic.h index d443faac57c4..b42b159496b8 100644 --- a/xen/arch/riscv/include/asm/aplic.h +++ b/xen/arch/riscv/include/asm/aplic.h @@ -28,6 +28,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 d757bb9219ff..2e5762af863f 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -3,6 +3,8 @@ =20 #include =20 +#define GUEST_APLIC_S_BASE __ULL(0xd000000) + #define GUEST_IMSIC_S_BASE __ULL(0x28000000) =20 #define GUEST_RAM_BANKS 2 diff --git a/xen/arch/riscv/include/asm/imsic.h b/xen/arch/riscv/include/as= m/imsic.h index 316fe5423c48..9c7fe0d469d1 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 8170e93701ad..683e8aaec2f3 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[128]; + 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 __initdata 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_RO80; --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695148; cv=none; d=zohomail.com; s=zohoarc; b=KWpC7HNR8a0oZuvd/2dnu/LaA8XVv6kKSMBl405XoIrcf0y3qPrHsQXv0he9PRcxVCvTqDiHHOZO9KGXS5d9Ydl93IDsJGxuKD0BBl7NNEj7XvCKH3sKvPW2Oc99oBAAnA+xpQfj7Qe8qvAasrFQpChWbwOpDotZDawvdL2nTXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695148; 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=4xSEG9bIjafLGrwzdvC04MxmFA+4dsnLVgng9C+J+7w=; b=ALDUnW1ImRRWHBkJ0k2XcBCQqh4R/F8Sw8bHlY6+F+GeCuFiQU6QvYdGssf6s2Us4tqi++Hl1vEWup07gx62oo4NMmtacpKM1Se0fo0ZOV+cJOKHzafS6hnyv/dH6yBId2KsXv9DPtUch4Wytgt0lyCLvxsjEWHxj4ph/loEU2A= 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 1781695148362780.7905107887342; Wed, 17 Jun 2026 04:19:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340110.1601224 (Exim 4.92) (envelope-from ) id 1wZoI7-0006c5-4e; Wed, 17 Jun 2026 11:18:43 +0000 Received: by outflank-mailman (output) from mailman id 1340110.1601224; Wed, 17 Jun 2026 11:18:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoI5-0006Xe-QR; Wed, 17 Jun 2026 11:18:41 +0000 Received: by outflank-mailman (input) for mailman id 1340110; Wed, 17 Jun 2026 11:18:23 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHm-0003mG-VD for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:23 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHm-00CoLo-AB for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:22 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328278-2eae-0a2a0a5409dd-0a2a4508ac62-26 for ; Wed, 17 Jun 2026 13:18:22 +0200 Received: from [209.85.128.46] (helo=mail-wm1-f46.google.com) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827e-63b5-0a2a45080019-d155802eed73-3 for ; Wed, 17 Jun 2026 13:18:22 +0200 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-490ac357c55so53249155e9.1 for ; Wed, 17 Jun 2026 04:18:22 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:20 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695102; x=1782299902; 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=4xSEG9bIjafLGrwzdvC04MxmFA+4dsnLVgng9C+J+7w=; b=ggfAcCYgm2saDY4pyoHIaCMMuWgHugUuPQcDlqcHYLlyVVsigvX7o2XL2oY28sGNB5 2/NL83/qKVWJkuDIbkK998Qg/sDUwKB3ST0RrwqkYcVgD2gX4Wsj8WDHYpwQhWd4MgRp TGCYcQVBPs7WYUWHURKxRVbovxrJ04W8ZarMbN/gS4ZrNKzr4sqhA8yyYaBu77awcw2H TMO7za9jtafwftfkVU1iNYgzSAjHdqW2f2NnKJWCg6yWqW7RjxlV0sSe7WSoK41mKTfY v6NQ6yWtbHN2Ycaj4SSB6LFtpue0uRI8H8B5XZkLJhPuKRKZdNWOk17yE6ehMjSJtTEB zBXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695102; x=1782299902; 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=4xSEG9bIjafLGrwzdvC04MxmFA+4dsnLVgng9C+J+7w=; b=YWMuPAbNybxRagTZBTib0zzKR/ny3TgJEDrXvCg9397byLderEq/V84xKE8vypN8nS 7N2T5q7OmbGZA2wXrIwp0Auv4vvbpUo2MoAVui7/xVxiDkysJAaFqf8LPkzQGC660y85 +51KkXhatxgWTkGOht9BUPLtlDyPK1/HAkSRQFbvqKBBZ1NHpTTPk6pD3V1AcG6tUVQM oMspruGOB0lc2gx1PcCmmge0xTn5Ebh/xtSVWb8QURLH69CnmI1YP9GjFID5q8unVpqE xcQPNK8DCvUd7liV0i02yGNTWvYHdGXCxtALsc4qSGOZML2Imb86AOFVz038mQKyFG/2 Z3PQ== X-Gm-Message-State: AOJu0YyNj3LCggosta1aH65E9aGF43NqgywMUOhufY9PbaH1X57volW5 834CqmCdIz8UEuJZsyN+N7dmCYVorVJ9tKwCRQe//J26P7dkcSEdOstVtWiURQ== X-Gm-Gg: Acq92OGTPtjn7zZ54voS/1Q7dSJhMw6HqQ4bTMZcNrejX+ILISbX67Ec0guGCIcjfp+ LoUv5QCeNAZ3Lutr8Q/4Uksi38HlZaOr1zblcIiBbRp9vvT7XgJ9ITZRpJaWCxGG91NQFKEG9Uh PIlR24bxRFjh0QYl9cERT0GBMw0zxIbinIjGKYjCg7AzQ2g5BaETabR7DUb+f6CwejBeH6H6Rbn 4jNsfCens2UirYJ0WS4iVnor2WTLfuMP8GVzyUM8vOqApg7iWyu8P06jRazUDwKUZ1TW7eqwqb0 1d8IfO/1aXOK0p5nhlnojUlw/n0hCl7UuVJ1Q2qornXLwFhSg6KfZeh/gz2/C0+nY8eAL1OWPxK BxKoi32kcDlFCIsbKe/94tYip7PIEMJd9FC3IM6B17f9ZVFjjhocJgbsFd5Pz9Ht2IwYGKtZD5N LcfCJrDScEhzzcdu3wRK5phSkmuHxiQbCk92aGRLnoaECvlkccj/tF6z55Ouq6Wv30x75B X-Received: by 2002:a05:600c:c08a:b0:490:acb8:1490 with SMTP id 5b1f17b1804b1-492333a1716mr50603575e9.4.1781695101242; Wed, 17 Jun 2026 04:18:21 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 18/23] xen/riscv: implement IRQ routing for device passthrough Date: Wed, 17 Jun 2026 13:17:46 +0200 Message-ID: <0458468cc5a6db911a9acc64f4c8cf17ceebe4c6.1781693963.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/1781695102-BD96DDB1-392DB2D2/10/73395122804 X-purgate-type: spam X-purgate-size: 18538 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695150302158500 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. 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 (allocated_irqs in struct vintc), managed by vintc_reserve_virq(), prevents the same vIRQ being claimed twice. 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 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 | 102 +++++++++++++++ xen/arch/riscv/imsic.c | 5 +- xen/arch/riscv/include/asm/intc.h | 9 ++ xen/arch/riscv/include/asm/irq.h | 5 + xen/arch/riscv/intc.c | 41 ++++++ xen/arch/riscv/irq.c | 203 ++++++++++++++++++++++++++++++ xen/arch/riscv/vaplic.c | 2 + 9 files changed, 370 insertions(+), 2 deletions(-) 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 0abe32c2e446..a559c81c6d16 100644 --- a/xen/arch/riscv/aplic.c +++ b/xen/arch/riscv/aplic.c @@ -306,9 +306,13 @@ static const hw_irq_controller aplic_xen_irq_type =3D { .set_affinity =3D aplic_set_irq_affinity, }; =20 +/* At the moment there is no difference between guest and Xen ops */ +#define aplic_guest_irq_type aplic_xen_irq_type + static const struct intc_hw_operations aplic_ops =3D { .info =3D &aplic_info, .host_irq_type =3D &aplic_xen_irq_type, + .guest_irq_type =3D &aplic_guest_irq_type, .handle_interrupt =3D aplic_handle_interrupt, .set_irq_type =3D aplic_set_irq_type, }; diff --git a/xen/arch/riscv/device.c b/xen/arch/riscv/device.c new file mode 100644 index 000000000000..95bd3b46f538 --- /dev/null +++ b/xen/arch/riscv/device.c @@ -0,0 +1,102 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include + +#include + +int map_irq_to_domain(struct domain *d, unsigned int irq, + bool need_mapping, const char *devname) +{ + 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; +} + +/* + * 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 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 IRQ that have no physical meaning + * ie: IRQ 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/imsic.c b/xen/arch/riscv/imsic.c index de8c54cb33fd..bd565aa6af08 100644 --- a/xen/arch/riscv/imsic.c +++ b/xen/arch/riscv/imsic.c @@ -538,10 +538,11 @@ int __init imsic_init(const struct dt_device_node *no= de) =20 static int __init guest_imsic_make_reg_property(struct domain *d, void *fd= t) { + paddr_t base =3D GUEST_IMSIC_S_BASE; 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(base >> 32), + cpu_to_be32(base), cpu_to_be32(size >> 32), cpu_to_be32(size), }; diff --git a/xen/arch/riscv/include/asm/intc.h b/xen/arch/riscv/include/asm= /intc.h index 95ca526e1223..f257e6a47b2b 100644 --- a/xen/arch/riscv/include/asm/intc.h +++ b/xen/arch/riscv/include/asm/intc.h @@ -13,6 +13,7 @@ enum intc_version { }; =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 */ @@ -62,6 +66,8 @@ struct vintc_ops { }; =20 struct vintc { + unsigned int irq_nums; + unsigned long *used_irqs; const struct vintc_init_ops *init_ops; const struct vintc_ops *ops; }; @@ -73,6 +79,7 @@ void register_intc_ops(const struct intc_hw_init_ops *ini= t_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 @@ -80,4 +87,6 @@ void intc_handle_external_irqs(struct cpu_user_regs *regs= ); 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 ec37b359f323..a38740778d23 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) { struct vintc *vintc =3D kinfo->bd.d->arch.vintc; @@ -106,12 +124,25 @@ 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->irq= _nums)); + if ( !d->arch.vintc->used_irqs ) + ret =3D -ENOMEM; + } + return ret; } =20 void domain_vintc_deinit(struct domain *d) { const enum intc_version ver =3D intc_hw_ops->info->hw_version; + unsigned int virq; + + for ( virq =3D 0; virq < d->arch.vintc->irq_nums; virq++ ) + if ( test_bit(virq, d->arch.vintc->used_irqs) ) + release_guest_irq(d, virq); =20 switch ( ver ) { @@ -122,4 +153,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->irq_nums ) + 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..3b90ab013e74 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,188 @@ 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 */ + do { smp_mb(); } 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; + + 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 683e8aaec2f3..b418cbedd9b3 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_RO80; =20 + d->arch.vintc->irq_nums =3D VAPLIC_NUM_SOURCES; + return 0; } =20 --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695155; cv=none; d=zohomail.com; s=zohoarc; b=F4Br8lgt+AVZXAMQ+NeHt8pKfGSoNDZH6c83Whf7UjgS3wzCjyYcsf1q7Yo/KSyHopvc3oLSGsJhKdPKl9rmEuxwQOmit+gKB6FcMZdH7vcLc2bdpPDqTB5tJPTZvoQH4pf3z+4YjdPn9oeJ86lcevzg9TZPjSFVgUoyBnvw3zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695155; 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=2I+oddooa9AtYM/3fWA2kwT7rhEB1jpQvIHH/BXdEDw=; b=aKJA2dej0LAlwsEcXQp3ugwpbGYccka18ZncptnyjPa6fS2AMIlqiDg7qVXoMYtSndU7eVlvhxtDFhqrTS/6vQhBaNJIgPQ72u70W0qG0j2jiuc4BdtT7eHtIIjgidEHF1qapjePRWo0NFH0xtCzrJsyabN2J4jKmOuk2CKF+U0= 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 1781695155692689.4717517219517; Wed, 17 Jun 2026 04:19:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340111.1601231 (Exim 4.92) (envelope-from ) id 1wZoI9-0006sk-3p; Wed, 17 Jun 2026 11:18:45 +0000 Received: by outflank-mailman (output) from mailman id 1340111.1601231; Wed, 17 Jun 2026 11:18:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoI7-0006ng-OK; Wed, 17 Jun 2026 11:18:43 +0000 Received: by outflank-mailman (input) for mailman id 1340111; Wed, 17 Jun 2026 11:18:24 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHn-0003r8-NC for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:23 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHn-008naJ-2v for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:23 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32827c-5cb7-0a2a0a5109dd-0a2a4509b80c-12 for ; Wed, 17 Jun 2026 13:18:23 +0200 Received: from [209.85.128.44] (helo=mail-wm1-f44.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827e-2497-0a2a45090019-d155802ce5bf-3 for ; Wed, 17 Jun 2026 13:18:23 +0200 Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-490b4a8e28bso42351645e9.1 for ; Wed, 17 Jun 2026 04:18:23 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:21 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695102; x=1782299902; 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=2I+oddooa9AtYM/3fWA2kwT7rhEB1jpQvIHH/BXdEDw=; b=Z8jAQSfqx+rDwBrBxxfj1AyWctodXM6vqIGdZRNRUhaQC0Go8bSZerxDTDHlG9ZCG0 yRrW9ctqRvhmpBAg7NnurJftHoakboSGYtwVNF1Ms4TpcEzpktJ/Y956Kbmgne0hpgur bFiICGu8p5WlQje6/w8SAJU5OsvxYzuTwxNV03IDApsPXqiT+7F1TnKTa71vBRKpDg4l uTz/xsRiBPZcFK42l9mc2c/bylb8Bb455rH2xqNe1ECCHZalrPYElUmJ2XSXmHWcrkRo XGPPzeEheSqn8kCgxCU311xKpaUDvxHBdP4ocYPFJvuTCIM90JAWUAp0v3g74CqGpaaQ d0Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695102; x=1782299902; 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=2I+oddooa9AtYM/3fWA2kwT7rhEB1jpQvIHH/BXdEDw=; b=NQIeL6REhCY830fbRWPD2vr8th9XJZplXNKytJFNFjZ3RxsQVaY63DvPx/ErCkkWu3 W5Jiqr4skdNrLkwBkLxavv5Y0S1QpIoXydk0B1fBBh5y6cMDydpKeyzaXqrYyywCYDvG Of7zF8FtDYjBAJhUmw9V10BTjANQpa+Ofo2MCXLEcCO/lX15whK7o4yhwAlwd9SPH4M1 pZIHihCMU//R9Cgd2v+i/lDp2ozPFcyMrn4gsErGdEr9xQukY3en9s/So59njXXgHTo5 A7CMgMkYVr5AvCJxYdOudbfs3z0HzMi3+W2Tprb3Dzdy9PCwMDaoupRY6NS4Syb6LeB1 8lVA== X-Gm-Message-State: AOJu0YzNQLz807TW6dxTxz7XYDrNqltPOkaU8vL5bCbmtu9x6YB/WLUG w4BDRolJkcU6z50Mu2GXXPzwXRZxrCpgMxjZWwr09O0oB/rQf2CNVJlgPx2z4w== X-Gm-Gg: Acq92OFeSApRc1ZgBOIHJG32zutgdM7O0el5GlCOXvAnV9j02pBV5oPGIZ4TD5Qj6cv fkGjUkFzhP67wLsKoIUAhSJCiwXD7M03WPviryK7r4sehSK5TU3rhWNJqeV4N6kq/ms32h0vk1y NQYaD1CXrZHi8G9yMlfgqWaQ7DuFA6fVBncfzYDWx/AYMJn8yMJ8UR3xn6KSMBJgKI/3tgPUStC YbHeHUCLGFlvomOCAA76GGMJBaxtaBG5bS6G1SJe5h4VtP2J133RwKN/dI2oLcgBMbMF61o4WP6 EXv1hHEiG+uLKtVvQH2X+cDjA1b7ShS3XCqyjT1suZmCmJ0OtoLK/yTzKnYufeEWcbOv8H7O7pJ VqcFcQDgkOlv1GTy/9LXOuztyq7lKofh1cTJYcT2WoqpATilZ4bE0ZSgqVUirdgQ1SjwjXY4Ln6 iqZRcTaF6wR88Dbc71lap1MfUhsEDHg9kK2Gd/57jahHi7xxVjoTNY0HJxb/QjaT/x6ygt X-Received: by 2002:a05:600c:1554:b0:492:3237:ddf with SMTP id 5b1f17b1804b1-492334282c2mr56391445e9.28.1781695102287; Wed, 17 Jun 2026 04:18:22 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 19/23] xen/riscv: implement init_intc_phandle() Date: Wed, 17 Jun 2026 13:17:47 +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/1781695103-8B392A53-2CEE405E/10/73395122804 X-purgate-type: spam X-purgate-size: 1316 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695156020158500 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 --- 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 Fri Jun 19 21:21:20 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=1781695151; cv=none; d=zohomail.com; s=zohoarc; b=hqYWiyDcfqNQL52tlStUvdlw29HExS7pwnOmgBpRmBUib7WFcFIblyhKL/1uoecxMhlxTcqIrRiVo0IoGF0Mr1FEnOs7rIVeCjcmhwyZx3GTLryrdwYD6hmAMKd6J9LJMpuMuikYaOFq7Sq2FOaIcOFoVHgdaxYno9+ztsTgD/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695151; 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=2FIk6pMeqEKkA+0YYHQME+TSQ8sYaHR2h365DGY4sbA=; b=P6WgYtl64Arzrt5NULiWHgb4MGUCLu7IxYLBDx2X2/tkuCWTDbhT+WZ74io5gm/ejh9E8iKGm9Zz41uwm+kz9X05Djl8xRoreSmMegyKPT2pU66RqQGoMWlzYJQw++SpNdbym7Ge5eqYSe3vu6upIZkJlnAixQw/FmbmSqbL2Y0= 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 1781695151899497.10076806455436; Wed, 17 Jun 2026 04:19:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340112.1601236 (Exim 4.92) (envelope-from ) id 1wZoIB-0007BS-4r; Wed, 17 Jun 2026 11:18:47 +0000 Received: by outflank-mailman (output) from mailman id 1340112.1601236; Wed, 17 Jun 2026 11:18:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wZoI9-00077F-RQ; Wed, 17 Jun 2026 11:18:45 +0000 Received: by outflank-mailman (input) for mailman id 1340112; Wed, 17 Jun 2026 11:18:25 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHo-0003wP-Ng for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:24 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHo-003J0D-36 for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:24 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328276-bab6-0a2a0a5309dd-0a2a4507dd54-20 for ; Wed, 17 Jun 2026 13:18:24 +0200 Received: from [209.85.128.54] (helo=mail-wm1-f54.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a32827f-229c-0a2a45070019-d1558036a586-3 for ; Wed, 17 Jun 2026 13:18:24 +0200 Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-492329c5514so3895045e9.1 for ; Wed, 17 Jun 2026 04:18:24 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:23 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695103; x=1782299903; 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=2FIk6pMeqEKkA+0YYHQME+TSQ8sYaHR2h365DGY4sbA=; b=mXNqIleSA6uri73ySrWuyZsjgeNjpklY8r9Oi7WP9JvZJwTohJg9cASSX6fgAGZLZq 4yGsHN/QbDlyCafcWn5C3pMJricaYQj8kbjdZEk/4P0Hjnz3QlMCtxTa2KXA3A/dUVVw yG1DxoKEFs5vFSfv9VCy6t30zNA3HPN6H1tbP0By96PHyRlM+gSX+YwKnmkpoQxQjkk3 uOubLvBzR9Ya24XGmuDJu3Vs3CvFbg2izE4lql+mvU3190lKBoBtDTz38BRh7Pl0gu+9 ZeMLd3Ec4PfWnPsOJvJRWLB5A8QD/oNPQmr2iy15r/TRdD9aB8l2m7AlTTmynW5XjpZ3 UI6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695103; x=1782299903; 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=2FIk6pMeqEKkA+0YYHQME+TSQ8sYaHR2h365DGY4sbA=; b=sjQzB52X2wtSitjHhy6lkufYqq/DEZWDogwYCxNB0kfWMKlZy8+TMRBpBV0rPmjeVz 8tC+PyNsxH57bU6Ds+BFC7oiM6iCrcqnMGOCrcyfHhlKf7DgwZmnXHf7edT/GshyBRh3 SWDal1vUjrjWomDVYcURJpPPedF4Ps00Kim3UbOCoKianifT/9ujOuN0E1p7Ryan5kt/ YQQOHhdz5QEV9jHmb0865oUT5CUa5wauYUohscibSWdEKiDewv3fUgwvih+103BAIy61 WewVXgrAlwQKKYtfGufjROHD+VBjv0+EAR3dxAK7L+Fwwd1JgfxZti2ApBCTkbqHWGPY QOLQ== X-Gm-Message-State: AOJu0YzIQHc/Zr5CzvTQ7W3aBOuX+CbN242joTrpZ4lAatmqwX7c6Org LOvr3veGnd5i7VXNrotzLnR6JGHntA4oXs/1uONHHnBe3VranZc6kHmc+a/mnw== X-Gm-Gg: Acq92OEhSG5xmRf4Y9XyAmCRs68ohKdUYlruLD0TxuBWza8syit/A2K3h47utFJZh6Z YBefk/hQCVqT7dWrJkkWl1Lu2WBmcq0yvu9YQaupI0X79tlmdSS2tm5OAokmbZsPpxqrE58MINd Ir3ozrYAYxrK/tsudxwTvnIPj4UqwXt6MG0JV35ib+7UyyCpxm29hc3rJPON9Dr5XtkWUYaN356 pNQUaHWelysd4kVc3+B0g+eiHH8Tr+fzuKeb1eO69H35eol5I9HkhR81ep4Hz2cYoodYgqm0OYh Sb6wh4e1TG9tUfhPzZDxKIgT2y+6Uwk+p54sMKAJo3D0uCRI1BGQSxPxU2/IkdMKyapuVIdrzdc lV/KrpCV2p6WNqXoCo/V4TW41tMn3Qt+8G/6I7z2x4ULRx6nninQviokqdO6dQzh95gI6DlMoq8 hjA1Wdhbni/mjjGyd/V3vsoHrr8THvZYz25TT4qyYZhBqR7tZr+yQe+QiKHQ== X-Received: by 2002:a05:600c:8285:b0:490:4b89:5372 with SMTP id 5b1f17b1804b1-492357da8b7mr16402825e9.11.1781695103242; Wed, 17 Jun 2026 04:18:23 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 20/23] xen/riscv: initialize RCU, scheduler, and system domains in start_xen() Date: Wed, 17 Jun 2026 13:17:48 +0200 Message-ID: <7a236aae14c6685f8104f0d4f80a1b34c9be19b0.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1781695104-0A772C48-D67FB8A8/10/73395122804 X-purgate-type: spam X-purgate-size: 1503 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695152162158500 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 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 Fri Jun 19 21:21:20 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=1781695155; cv=none; d=zohomail.com; s=zohoarc; b=LAsvQnnVqfiCj+RblkQPl5ck3P/qSj5pN1i59u0PqOG2Av6EU7e3ki4VfelbtABWo3oYBjkhY6qeyvprIimUX7fx21zVHEk+ySdP2SI0LZ6u8q95YVUxSVtjXDrFEoGjopr4et2tQd67nSAUqQ+CDOZDi7LDJof9b4U9cnH0fAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695155; 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=swvk0YgzHz2ARgtgQlFZIpC4f1vcSxqdtw9lrbDzreY=; b=FMmVcZF9DbVUbsgLhfzIAYDZJBMyPDHU180LGbYyrcQK47F+X8Cfi4dxAF6jmZz/xQvB72Oadazxb1yDIhkcu2nLLh59ceyWkPycA2jkYmVclOgKBeW++ZrzmNX9++wzs+ppQiF8shpCYZ5/AhgRirlpCpvRLqxMA0iT/9Dn+9A= 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 1781695155541439.5593193164673; Wed, 17 Jun 2026 04:19:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340113.1601245 (Exim 4.92) (envelope-from ) id 1wZoIC-0007PB-VV; Wed, 17 Jun 2026 11:18:48 +0000 Received: by outflank-mailman (output) from mailman id 1340113.1601245; Wed, 17 Jun 2026 11:18: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 1wZoIB-0007Lz-9z; Wed, 17 Jun 2026 11:18:47 +0000 Received: by outflank-mailman (input) for mailman id 1340113; Wed, 17 Jun 2026 11:18:27 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHq-00043m-4g for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHp-000VOC-E1 for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:25 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a32827e-e002-0a2a0a5209dd-0a2a4506cf32-18 for ; Wed, 17 Jun 2026 13:18:25 +0200 Received: from [209.85.221.50] (helo=mail-wr1-f50.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328281-7371-0a2a45060019-d155dd32f128-3 for ; Wed, 17 Jun 2026 13:18:25 +0200 Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-4629d80fa08so589791f8f.3 for ; Wed, 17 Jun 2026 04:18:25 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:24 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695105; x=1782299905; 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=swvk0YgzHz2ARgtgQlFZIpC4f1vcSxqdtw9lrbDzreY=; b=GV2RUKWy1Iv6qTRnIEKQbQvnykh2HniTK9uiiBJYPGUkKgvEUI8eqWAV/g7Es/3GCk yqk8+IhvdmfxwINOw9ydEXXJgHt3SjDC6v61ZtvtiztJMBaTWw8x5nkOFhaJYwT7RDIJ nYZSd2191G+7i2cAm1HbiNo46jiKl6ipSGcNHVjSjbgL1KSbx2+G9BozphGJf9AUjfOc 3H3ShzQNpQ3zypgS3PXIEf795ITGetLdJ1NHVPdZl8YGOhEsSMIGSnhvAVq7EWz/gq9M gTYfm3cQ6PrdNrfspj7dzMZIgx7ZjN+mJr8fR1jEiaDr+eZQSfGcUiDS9hWNH1LPOFPM Ptfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695105; x=1782299905; 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=swvk0YgzHz2ARgtgQlFZIpC4f1vcSxqdtw9lrbDzreY=; b=Ibci7jCi+zdq9cIJafdQZWEEXFv46qYVlCzMcu+DJghjzQ2XZEdcSCTteU2BJ/Hob3 qxMPOp6+LWnGJVTMzBPIxAhLKHWkyNro+Z2i1atRLtJnh3KZsOS88BbGLi3HsYux1Gml bevAqtSAZwazbl9GePYar8e/qgkUKTkHqLAq+CXcAUIilrcAmBFniLjHt5IuH6e73RZY WYn7oqcxOQQS9Y0tOYJJelVVBQWK2eepdssf/5FRUn1M/Ze9WprACioz+NnhLBgX7yQs DYKKwzhOy6T2TbAPChDa6IZxC1VnBFYbXOzbuaPGoDm/jiSzYEWnxox3290ihMG2WMrz lvbQ== X-Gm-Message-State: AOJu0YzsIao9G1TptQg92vpkFKqxpqkTcsPQDip1jmJ/Zcym0OH4I3CW hwuoStumLQ1x5WtZMgwHmgUgSPm7/nwa3TL/+eDgv4Q2bUl/HojQfc3BCrZAug== X-Gm-Gg: Acq92OGXy/XXFZiLDnfCo5MUdtZp7AzhHJa30NsHHUEkJscEM043E9WHOAj5sgRt8Pg llZFFh3mMC7aYcsXcNJJ0nEjC1RAxWEB9eRfZhimtSi7g8AGhJQAJcBX2qC7uDQqvSTNVGFPZE0 KcwJTbFaVIkSD0GM8Ls1e5x1fXxg1lAmAPTPTZR3P+PD5nV2KsktkS6VEFWwRNn+Dkr7QlHTNq/ 6I44bj87fCe9mkghn9vl8pyUGNKfquQrdAe0oMjLEsIireuRPl/Yvf+TezbGoXPWlnp4abpyZ0M s875CzNITBnV3QuPmfdNO+zxda5nX5zo4Q58ZijgvB1Bq0NhYsxcDyQi7gAHp55YYKIqmnvT5Hr br/lp4Kfm77KUeuqkTr9a2bNDHJo2yN4ML5fTMrbJGPVLFCu05uemJRBVEO7a2bU5dlIGa3nAtN bwczJ459rZS1CduuTO0VNmtTWdrIS6k+88SfnzrTX6Ef5aGtBkpLDUKzmSDcoUYGnSk5WH X-Received: by 2002:a05:600d:84ca:20b0:492:3071:1db7 with SMTP id 5b1f17b1804b1-492333d8b49mr43245255e9.28.1781695104510; Wed, 17 Jun 2026 04:18:24 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 21/23] xen/riscv: provide init_vuart() Date: Wed, 17 Jun 2026 13:17:49 +0200 Message-ID: <401b93509df2e9f8682c1de13de32114279ad3de.1781693963.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1781695105-8D982D75-C449A61C/10/73395122804 X-purgate-type: spam X-purgate-size: 1333 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695156041158500 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 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 Fri Jun 19 21:21:20 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=1781695153; cv=none; d=zohomail.com; s=zohoarc; b=cEEFqR97QfKK2DDrqJA2/56mrXAR4wzfqbCrl8wag0nwNVqnBQOkWqlzpiHEpzaAmNKVtVXU8j8kJyGHF0z6nz63ca/Dmt8DS129dLI/FM0lhFppee87VeGtz2YwJpQz3tPBBop0kfq+zsBLqENBh/iCKT2uJ0R21SqXkTXPGHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695153; 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=LAKichfwvXiqlJdvvQBNjiMjpG5MCqx/29voflyMUog=; b=XZPmzApleZO7B/D1q10m3F8IfpfMKAG2xej1GXcyqVZ0oJ6AwIV/7hO73LcdaXT88hJIOHSs/UzEjcNajEtv1Lnmwn+20xj5gxhpITxA6uT4fHzLafdEYGMFY4NiVDv3YHWikrk9VHs5AOLbYu7m7YJbaZzd+7IRUUWvDZym21U= 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 1781695153430131.68392572924859; Wed, 17 Jun 2026 04:19:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340116.1601251 (Exim 4.92) (envelope-from ) id 1wZoIF-0007lb-HK; Wed, 17 Jun 2026 11:18:51 +0000 Received: by outflank-mailman (output) from mailman id 1340116.1601251; Wed, 17 Jun 2026 11:18: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 1wZoIE-0007hM-1l; Wed, 17 Jun 2026 11:18:50 +0000 Received: by outflank-mailman (input) for mailman id 1340116; Wed, 17 Jun 2026 11:18:28 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHr-00049U-89 for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHq-003J0D-FR for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:26 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328279-bab6-0a2a0a5309dd-0a2a4504a088-26 for ; Wed, 17 Jun 2026 13:18:26 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328282-1dec-0a2a45040019-d1558031bc18-3 for ; Wed, 17 Jun 2026 13:18:26 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so38395805e9.0 for ; Wed, 17 Jun 2026 04:18:26 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695106; x=1782299906; 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=LAKichfwvXiqlJdvvQBNjiMjpG5MCqx/29voflyMUog=; b=hA9PlVgck2nFu7OaJPeTnpRkkPvmKjxL2s1G1npZYM9/mmXozPu/31CLB2+rJalhIU paQIVaehNqEBWoNT3cp04iIznPQShXWHN4uR3cpym5YnQQunudBnQgnoxt6YmcYeh3MR cLFmfHXxhi+8/M/ysE67Yn8puByNjcGaxTPKyu50mu3VN1N2h4ep++OEmwIS40YReEc4 CH7L2O85IhKplFnS8S5o2sSLrjUX7EBWHqX41Q64oCcItHtRNpb6qu8QhZpUUMoa2Iz5 fWEqew1/mJhLwQ4bNICrBFyN4xDQnNk7wZFGRSc/YdU7bjCXVgI5MQoUFKq3zXO9DBk4 sTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695106; x=1782299906; 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=LAKichfwvXiqlJdvvQBNjiMjpG5MCqx/29voflyMUog=; b=n8hf5vWYIjMD4dm8VABQ/sHbynLRA1XzaEro/+KZST0eq2jmOH4gHX1BNsav6ZK90V 95LIPaU0qPnq7InLUZxwhoxNvWzTnny+5RPaHBFTuwLcGjljTFAY7IsrI1ClBrCPU9rc Za9YMhacNRwO/1yjJVcXsH4SosIZXpuPy2y0nvxVVRxMmjR9abR4YJMKr2nTRFHDeEW+ wXde3BHU3epkboUD6UE+PCHvxB3IqXdQFObBHGNCVZ/fV2qTcDKvv+5U11ta+SJm6+4H fGJ3IH0jGHTYEMbK5X2GmydHeVT6+MwLNnPd0hz/KiIwo8Ia+vY4S3I5p3GkZw5CwR/V Vl7Q== X-Gm-Message-State: AOJu0YzgMGWnzlrV6SHp1NgaHUwWdJhHJ1sow0einnRxDMWypFc4DP6Z AK7QQfS9PRbEDJG5Czx6woSehzMy/k+wQqdIqwYMORKsyyx+J4CJv+GjMnHq9Q== X-Gm-Gg: Acq92OFhNjptczDFGOxrtem7NZ89Q1s8t9GCI+BYA6LMHpIvtiYFSyxhM3z9/ZZBQ8k jXWHyyczRP7R6aHG5N2LWDS6p99GcZW2QyHeadrD7UeD+HyOHaTodAJErdhAzw86LxoBUcJ2VnL kvCI8h0ti0YxlsQpVDb11IX0sKD/5mptOXfmzfu2Nr/1HSwwWMAuhgMRoSZQ+ly2m5A+7rLO95d iCVRPAyZIHtYprsk5y/Eb1T+/urdppFV83IbLoxBRfCFtKZoNiiviYYYLwBqSHNgTXoJaIxuE8j M3fF/zdQ8JDgphht9BlIl0tqwHj3Pje3/juZwLy6uCs8MVv5N6iS0JvP56ZfuB3qGNK1Jjy6HoC BC7ROA1Pe06RPbJWc9iyW6QgBWHKgtRt51D25NvVRqTIxHk+vXwJrqru85oYTghU23gy09nagWR hCqRnp6OOjkc4BlYggS3c9rAN8Y3Lkf+pwWW47xpU1rWD2bWs4OKpW77oa7w== X-Received: by 2002:a05:600c:590c:b0:490:b58a:dcc1 with SMTP id 5b1f17b1804b1-49234139cdamr30781995e9.29.1781695105673; Wed, 17 Jun 2026 04:18:25 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 22/23] xen/Kconfig: introduce HAS_STATIC_MEMORY Date: Wed, 17 Jun 2026 13:17:50 +0200 Message-ID: <22c02e188a0b38806f08b7a87f00f03c14aad742.1781693963.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/1781695106-411763FF-9ED0E3E4/10/73395122804 X-purgate-type: spam X-purgate-size: 1677 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695154033158500 Content-Type: text/plain; charset="utf-8" Architectures that implement guest_physmap_add_pages() select HAS_STATIC_MEMORY; STATIC_MEMORY then depends on it. ARM selects the new flag; RISC-V does not, so CONFIG_STATIC_MEMORY is unavailable there 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 --- Changes in v3: - New patch. --- --- xen/arch/arm/Kconfig | 1 + xen/common/Kconfig | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) 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..6e24f7f4e43b 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,7 +199,7 @@ config NUMA =20 config STATIC_MEMORY bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED - depends on DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY + depends on HAS_STATIC_MEMORY && DOM0LESS_BOOT && HAS_DEVICE_TREE_DISCOVERY help Static Allocation refers to system or sub-system(domains) for which memory areas are pre-defined by configuration using physical --=20 2.54.0 From nobody Fri Jun 19 21:21:20 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=1781695171; cv=none; d=zohomail.com; s=zohoarc; b=TgsEN5suzK6pPRfMUANft5CxQP8bBjgeme9pNCSnmdIiFv/gUszShYU2V+9S08+lqOqYbgXwl9LpmS4ae+SeVWR+bxAQ82ISfP3bcww9jgdZ5cbbUU7zuJbUAfEK2txD5wXfrZEelNd49LjBKZtTY0UJ+c1WfliuF+cSCKexqME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781695171; 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=wd109uo54h7Ht2m/jvWZ4if8ySED0SAOqrqE/7gjCJk=; b=gPF4YRoDtyUyaeniQqqNkoztWyz+PA2K4KkRbBtHU/5O9jD0BwI/Vf/7cvKB9gB1jt+0WpanS6u6U67d7S+YQrFslyhnhW9kh3KdgnGN8AxAh7u7ixowAAf6Za2Gi4s4tcipeNY3OfGLYsdIFxDw/Gq4vJ8QdNyuVBXAPSa4j60= 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 1781695171873241.39459890873547; Wed, 17 Jun 2026 04:19:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1340118.1601259 (Exim 4.92) (envelope-from ) id 1wZoII-00084a-0L; Wed, 17 Jun 2026 11:18:54 +0000 Received: by outflank-mailman (output) from mailman id 1340118.1601259; Wed, 17 Jun 2026 11:18: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 1wZoIG-000800-5C; Wed, 17 Jun 2026 11:18:52 +0000 Received: by outflank-mailman (input) for mailman id 1340118; Wed, 17 Jun 2026 11:18:29 +0000 Received: from mx.expurgate.net ([195.190.135.20]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wZoHs-0004JY-Gk for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 11:18:28 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wZoHr-000VRI-NL for xen-devel@lists.xenproject.org; Wed, 17 Jun 2026 13:18:27 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a328270-e002-0a2a0a5209dd-0a2a4503b370-34 for ; Wed, 17 Jun 2026 13:18:27 +0200 Received: from [209.85.128.52] (helo=mail-wm1-f52.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a328283-672d-0a2a45030019-d1558034dd73-3 for ; Wed, 17 Jun 2026 13:18:27 +0200 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-49222fb062bso46605175e9.1 for ; Wed, 17 Jun 2026 04:18:27 -0700 (PDT) Received: from fedora (user-109-243-148-111.play-internet.pl. [109.243.148.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4922fa3a8efsm151319985e9.2.2026.06.17.04.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 04:18:26 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781695107; x=1782299907; 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=wd109uo54h7Ht2m/jvWZ4if8ySED0SAOqrqE/7gjCJk=; b=Sr7rbD5BKLnI5zn+CvFCzD8u7GJAVIUadKPTMrRmSU1chjm8VSWtKPNwgre109ZCjs wBdTXpRXudiFJdt+sZZfdTdKfkmF+pXkkxRFF7+jHS341Q7lYyXn2bupN6b+xKNbuj3l gul8yepIB0g7BWIMJ2qp6nEbzKTVGQKFqcJpb0QxZ+YtfjPnSF8n0oF+x0A5VpqlvCBA IGOKFxO8i50CtnN9vnDjwF0CUMTthEb9Rs+L1/SuvXw0sTeBkh05kqK9cifXut+zNeGa i6ryKZUPSLp5Yk506wiaCybMHqnzxdeMc4KEU2uAsirStPDX42f/xIKJVWDdk8u0jZpH JAOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781695107; x=1782299907; 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=wd109uo54h7Ht2m/jvWZ4if8ySED0SAOqrqE/7gjCJk=; b=dAGQ+mSBPRRASWEz89+3b49OGdD+wREgmt5QTP8AziiaS8sSlCCSsfdOMhn6PMYf/1 vuxNzkBkNCFjwxK2SGcp8Nk8Xfkm2BpKXAt5UVgRWKCrN6h41mi0pSS9cRLjae9OPqE2 0WJEmbLQDie69QbhZCeQHwfApA8DDXzz+4s3ONnpzDAqZagM0xNgnZswaewNUGmg9+PN +P3hzkLqGHrVS6HbDDhdfdREtXy+jrGtLOQ6DSgoTlkEhruz7orwGgqPci/HH3pn127n 24+oGvBJ0PIlEujebh9bmZwvBL33dIMDcmxw4vtZAxl4dRQnrrtIg64/D9g7Xb8MQWob Q6Pg== X-Gm-Message-State: AOJu0Yzuf5GzZ7N/z/svE9wrEwZStei5C05wigaNDtlUYfqvD5JVmO1v nV37O8mNJXzWTLs7PYMzrc9ujK7M7BQxdipVZGqT8PxC/DBHuoxeOs+JSzxzNw== X-Gm-Gg: Acq92OHuzz7O3AcOrhdNVKS2/7wLwNwn2LbE9qjDSbenoH5DQsxCAZHHWZfCG3rXCSh WsFe4zBvyoBRbpmGi6kdwtdK8IKVtcx6xN2AP8jVvXz6w884AtrCU2mEzcw6KKv0LNsmC6SWLG4 avL0dAb9dcyxGXa1HDhRpyticjJxk5h1NaulEoUUDjXRzBTH1+BQRuv49Fb7CJktKnfGWFpEN9w CeRt0J7+lTeI8b0fSLwDDi3pcVBxWk+vR39q3dMsdPlHraDSnOv5OCFj62QtVpsqGcP6j/Tfbvk 5gko35ooneyESQnij90nvE3zaW/6XKxRDrFZx/cR/wG8LNdpit6VkP0AVtdgBX3AE7Z7bhnzNmy /6c/F+UqKvG1WX8Rb0PjRLrMkDYoeekFVr9pNtJim2v24jvkqGrxjhOKfm5OIMsU76D4Z/JysVf aaRYPF3hwOyfPW5D2tN5YLeOiF3mrIYmktr36X5udA+sTVhJ/7g3k24CnkHg== X-Received: by 2002:a05:600c:608a:b0:490:b65f:8b1 with SMTP id 5b1f17b1804b1-492333ba1d1mr71065675e9.5.1781695106912; Wed, 17 Jun 2026 04:18:26 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , 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 v3 23/23] xen/riscv: add initial dom0less infrastructure support Date: Wed, 17 Jun 2026 13:17:51 +0200 Message-ID: <781214e3cb87a0fe38e210e9b0cefed49d623d52.1781693963.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/1781695107-39B7C938-C3D29834/10/73395122804 X-purgate-type: spam X-purgate-size: 5246 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1781695172200158500 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 currently perform no additional work but allow the generic dom0less code to build and run on RISC-V. Introduce max_init_domid as a runtime variable rather than a constant so that it can be updated during dom0less domain creation. 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 in the public RISC-V interface. GUEST_MAGIC_BASE is placed at 0x79000000 to avoid overlapping with the QEMU RISC-V virt machine address space. Signed-off-by: Oleksii Kurochko --- 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 | 13 +++++++++++++ xen/arch/riscv/include/asm/guest-layout.h | 3 +++ xen/arch/riscv/include/asm/setup.h | 4 +++- xen/arch/riscv/setup.c | 2 ++ 6 files changed, 30 insertions(+), 1 deletion(-) 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 4c21ef37a6e1..df4d90e1410a 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -156,9 +156,22 @@ 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) +{ + 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) +{ + return -EOPNOTSUPP; +} diff --git a/xen/arch/riscv/include/asm/guest-layout.h b/xen/arch/riscv/inc= lude/asm/guest-layout.h index 2e5762af863f..757285392d46 100644 --- a/xen/arch/riscv/include/asm/guest-layout.h +++ b/xen/arch/riscv/include/asm/guest-layout.h @@ -24,4 +24,7 @@ #define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE, GUEST_RAM1_BASE } #define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE } =20 +#define GUEST_MAGIC_BASE _ULL(0x79000000) +#define GUEST_MAGIC_SIZE _ULL(0x01000000) + #endif /* ASM_RISCV_GUEST_LAYOUT_H */ diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/as= m/setup.h index 2215894cfbb1..678b65ac1e54 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -5,7 +5,9 @@ =20 #include =20 -#define max_init_domid (0) +#include + +extern domid_t max_init_domid; =20 void setup_mm(void); =20 diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index c3e98733ebc3..b8fa004cbf25 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -33,6 +33,8 @@ #include #include =20 +domid_t __initdata max_init_domid; + /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); --=20 2.54.0