From nobody Mon Apr 13 03:40:41 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=1770913300; cv=none; d=zohomail.com; s=zohoarc; b=LLOqdX55wIHx+3tv2O9DCoEEXV4IBDLb7C4eMGScgSSMv1CUQLSJ/qcPTaskdbPh4GZ3xGDB8NELBaXJ1QNIEBspMjAxCMX91yaMek4T/IUGVERqLuGN5l4aflTi3JP0v5sDONgLBJat+xUTpsCClDrB/BcBE3axr5/4jXOJQNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913300; 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=756p0sgqElUf/O7m5v8k7wVt+/PfhKAVifuQ4bDjN4Q=; b=ZWf+amQq3ijaq+05ECUkLB4TvqTTZPrQc/A0oUgqg7SgRQUfywa3s9xFetVk06iMQG7X5k5/iljoMYo6+f7/zLOx32gKWzldzAYgSlWjTrlR+w2NuQYhTSO8Lq5Ld8Udw5Qs8y4R67DCRss0qSKxI8snIZtZdVVpamvE/dbw0NI= 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 1770913300301764.9176060968747; Thu, 12 Feb 2026 08:21:40 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229474.1535427 (Exim 4.92) (envelope-from ) id 1vqZRR-0006ID-4V; Thu, 12 Feb 2026 16:21:21 +0000 Received: by outflank-mailman (output) from mailman id 1229474.1535427; Thu, 12 Feb 2026 16:21:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRQ-0006Gx-Vf; Thu, 12 Feb 2026 16:21:20 +0000 Received: by outflank-mailman (input) for mailman id 1229474; Thu, 12 Feb 2026 16:21:19 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRP-0006Fi-Dy for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:19 +0000 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [2a00:1450:4864:20::429]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dbe61651-082e-11f1-9ccf-f158ae23cfc8; Thu, 12 Feb 2026 17:21:17 +0100 (CET) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-4359108fd24so27355f8f.2 for ; Thu, 12 Feb 2026 08:21:17 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:16 -0800 (PST) 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" X-Inumbo-ID: dbe61651-082e-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913277; x=1771518077; 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=756p0sgqElUf/O7m5v8k7wVt+/PfhKAVifuQ4bDjN4Q=; b=kyw34+E7slAVZfUbtJhcKV+vlYckGky3hgXGk2+r+fa15vnfFxxoUl6VdeUNGqrii7 XVmVl/nWvrjEkObDUjimkpaawuEBtrMSyEVuln09OGMH8ENlBMsny/DRIr4UOejFmC8U +Mnn6GAppPExM4RAZXZbE3/6kiGvPGIQ9DaeJcuzslRarpvqFUY25MeCd1qPc6s9dmva L6nGXctZqNZxTLyxfqfU+/3GL8VTcaTIjbnyJgeIB8QNz+292PfW2rWeqwHceY/zj9Iq OYsMORPKiD4+vTBqjf+qWkEJE17D+tpj62AB2FE/M+1COnIIY9T4dKsOICDOefyHmu7J +bOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913277; x=1771518077; 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=756p0sgqElUf/O7m5v8k7wVt+/PfhKAVifuQ4bDjN4Q=; b=cJPcuKFBnEqtZnKLmr8R2v2G8d/4AG6De4twy7uL29w3Clg9Xefl/ZWMSULJ6IyVZc VXEDSQoiEZ4dSN5Ot6WVVwRCofwSNTnY92R4DVgLdmApSyEkCBXLAv4zhz7bghpXeFY3 6J0bnvGrkkV63M2FO7HblZqMmvqU4YCJF5Mq8fWA7OUa7xjKbANn6Xdzm4MZ3UjWxwtW zF/rsVmJDGELOjW445w4aH6/R1yDrx4pU0HYC/m7NEMMc/oSM7fcURq+j8B4n13J/JB8 TixyqUzqsgmTrs6a1Y6jJB5TH/P/kXvrJT8WFYp1cKRFQr0A/frZadPvehT/vd96uR0Q AwMQ== X-Gm-Message-State: AOJu0YyWUsIZTcroBztzcIrbuXABGp8+gWMZwWt9ISd9W6U1C2uCvnj+ oeb5V1kQtQAnsogVx5OmHkd07TcW4aa1YtnagkZe/wOZT+mFwh64P9E9P6nACDWW X-Gm-Gg: AZuq6aKMkIlVn1fLdHrq9ZLmUXZC2u1lCktekrkchfrXd0ddE+s3YHE6KSIZDIBoq14 g8KavzYmEuGGGk3uLpg9vg0wblmsLLkel3E/JcW0UUMSxXLy4N9jmZhhFeJw2f4CF93c8BHnUyV a4ZHV6nNtY7fIGB9pG3aYJfgXxPSJnF3Li5cHgJrl2CHVzaDMKzbpAyS7SF3L/RumAb2V0VzqdM tHwIZSWZFoOJl78HQJNFTZX0sRicyuAVxiUzMfDwx5aMz7zMW4Z5rkqGJccocjgiAudJQFzF42p uXFdmb4AGhGAPDHhbBP471lsFAK/3HbvIPVBC2FgKrk9aerYlWM9bs4HxfM0OYg0/RSS/w39Ndi oqFyIhTBs+lb8bx06QZKg6a6FYV1f+f2L5WpbRuulsQS+RZlhDtjFrMcNnSbRxbJdw+aMScgFgI zgPuA/mKhVWpBoB3lt5lSEWvaS+i5d9krfpMm6d5bKYvM7CsOTDppUofhqYsO1xvYnAiBHfTWrH J6hKE3b X-Received: by 2002:a5d:5f55:0:b0:437:712a:fac9 with SMTP id ffacd0b85a97d-4378aa04146mr6020186f8f.23.1770913276791; Thu, 12 Feb 2026 08:21:16 -0800 (PST) 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 v1 1/6] xen/riscv: implement get_page_from_gfn() Date: Thu, 12 Feb 2026 17:21:02 +0100 Message-ID: <04eee3ae5e8aadf8c7f0b873ba24ce38220e8fa2.1770821989.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913301439158502 Content-Type: text/plain; charset="utf-8" Provide a RISC-V implementation of get_page_from_gfn(), matching the semantics used by other architectures. For translated guests, this is implemented as a wrapper around p2m_get_page_from_gfn(). For DOMID_XEN, which is not auto-translated, provide a 1:1 RAM/MMIO mapping and perform the required validation and reference counting. The function is implemented out-of-line rather than as a static inline, to avoid header ordering issues where struct domain is incomplete when asm/p2m.h is included, leading to build failures: In file included from ./arch/riscv/include/asm/domain.h:10, from ./include/xen/domain.h:16, from ./include/xen/sched.h:11, from ./include/xen/event.h:12, from common/cpu.c:3: ./arch/riscv/include/asm/p2m.h: In function 'get_page_from_gfn': ./arch/riscv/include/asm/p2m.h:50:33: error: invalid use of undefined typ= e 'struct domain' 50 | #define p2m_get_hostp2m(d) (&(d)->arch.p2m) | ^~ ./arch/riscv/include/asm/p2m.h:180:38: note: in expansion of macro 'p2m_g= et_hostp2m' 180 | return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn= ), t); | ^~~~~~~~~~~~~~~ make[2]: *** [Rules.mk:253: common/cpu.o] Error 1 make[1]: *** [build.mk:72: common] Error 2 make: *** [Makefile:623: xen] Error 2 Signed-off-by: Oleksii Kurochko --- Does it make sense to make this function almost fully generic? It looks like most of the logic here is architecture-independent and identi= cal across architectures, except for the following points: 1. ``` if ( likely(d !=3D dom_xen) ) ``` This could be made generic by introducing paging_mode_translate() for ARM and defining it as `(d !=3D dom_xen)` there. 2. ``` if ( t ) *t =3D likely(d !=3D dom_io) ? p2m_ram_rw : p2m_mmio_direct_io; ``` Here, only `p2m_mmio_direct_io` appears to be architecture-specific. This could be abstracted via a helper such as `dom_io_p2m_type()` and used he= re instead. --- --- xen/arch/riscv/include/asm/p2m.h | 8 ++------ xen/arch/riscv/p2m.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index 0cdd3dc44683..c68494593fd9 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -171,12 +171,8 @@ typedef unsigned int p2m_query_t; #define P2M_ALLOC (1u<<0) /* Populate PoD and paged-out entries */ #define P2M_UNSHARE (1u<<1) /* Break CoW sharing */ =20 -static inline struct page_info *get_page_from_gfn( - struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q) -{ - BUG_ON("unimplemented"); - return NULL; -} +struct page_info *get_page_from_gfn(struct domain *d, unsigned long gfn, + p2m_type_t *t, p2m_query_t q); =20 static inline void memory_type_changed(struct domain *d) { diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index 275c38020ae2..f5b03e1e3264 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -1557,3 +1557,31 @@ void p2m_handle_vmenter(void) flush_tlb_guest_local(); } } + +struct page_info *get_page_from_gfn(struct domain *d, unsigned long gfn, + p2m_type_t *t, p2m_query_t q) +{ + struct page_info *page; + + /* + * Special case for DOMID_XEN as it is the only domain so far that is + * not auto-translated. + */ + if ( likely(d !=3D dom_xen) ) + return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn), t); + + /* Non-translated guests see 1-1 RAM / MMIO mappings everywhere */ + + if ( t ) + *t =3D p2m_invalid; + + page =3D mfn_to_page(_mfn(gfn)); + + if ( !mfn_valid(_mfn(gfn)) || !get_page(page, d) ) + return NULL; + + if ( t ) + *t =3D likely(d !=3D dom_io) ? p2m_ram_rw : p2m_mmio_direct_io; + + return page; +} --=20 2.52.0 From nobody Mon Apr 13 03:40:41 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=1770913294; cv=none; d=zohomail.com; s=zohoarc; b=DZWoZpWxvRf5RKpHK89koZWyW8kwEyLgXyR0bInIBTRDyI+DZeGBZPd9502iu85KySW0iigfYN/bHS4VnGnfsamzFF081R4EONJ6RfJyHkb8qM/rvITfyZmlEdr+L+KfpzRjtyVlezX2kW3eImojOW6xFDPjeTc3bplslUDU5us= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913294; 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=PELzgBrkYoFU28QGxSaV7T34+uk+b3op31q7VDuVJfM=; b=i7o6ni9Pl5WxdUkAlDIhA6Pjuft8qkuL4gyPx09BesP4ySlavRP9ppktSb3rKMFgI6sQMM1YCr95s18gZZXpoxox3pd5vMEVRe14knv4uFOR3QVuXUWTgbqvOggOHiwtG0dNQ1dpFBaS9tWtt8wm5D3pKCIAmPo/wRlEMvSsAjQ= 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 1770913294514731.1644681873737; Thu, 12 Feb 2026 08:21:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229475.1535433 (Exim 4.92) (envelope-from ) id 1vqZRR-0006MV-EP; Thu, 12 Feb 2026 16:21:21 +0000 Received: by outflank-mailman (output) from mailman id 1229475.1535433; Thu, 12 Feb 2026 16:21:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRR-0006Ku-60; Thu, 12 Feb 2026 16:21:21 +0000 Received: by outflank-mailman (input) for mailman id 1229475; Thu, 12 Feb 2026 16:21:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRQ-0006Fi-Kf for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:20 +0000 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [2a00:1450:4864:20::32d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id dc8a1bbe-082e-11f1-9ccf-f158ae23cfc8; Thu, 12 Feb 2026 17:21:18 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4834826e5a0so32425e9.2 for ; Thu, 12 Feb 2026 08:21:18 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:17 -0800 (PST) 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" X-Inumbo-ID: dc8a1bbe-082e-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913278; x=1771518078; 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=PELzgBrkYoFU28QGxSaV7T34+uk+b3op31q7VDuVJfM=; b=N4TqEt1QE/B8pYIP+hQ+7eFD2X+6KEctSsdPp4P8HWs9uKANviylSh3QnWZDkBUFfm afd2WRuCFtrCcqsvvB2n6tE7PbKWuTjxWnk6EnfKWQIMlY/5OpAUIAnU+FydfGCZWGII hmN3fHWqWey4cvex2Wubsea/fog+ol6bNGaIk/PfgEYfhbiFrbONdMOZ1D4PJ8ICv14Y lOyK1a8ifrEZu3ZDqwmlDZAgP5a9ewIptJSKBaroFAvji2j4Kv5YdwPcHpePJxYRXlWT wUtK7r3JQfHw/30+9WdeT7E9adgXS+UZrAoa6GtaAWs6M6/5aHM7E9XIOQe2klKfe8/d PSnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913278; x=1771518078; 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=PELzgBrkYoFU28QGxSaV7T34+uk+b3op31q7VDuVJfM=; b=CIGbO3TRJmSlurtGHefyM8a5rdM2TGgbN3taVDDm/LQjfq59k/fDJmVzljtikWfXRu 8CuChyWVZudA+MJ7ETjWKndhnHkIHWtGxEoF2p+AJrShLrm/uF2Z2uzNHe6nH87Hp2xV 0oJo14A4t6WreIIFBghGa9W1SclSeDeLD0MWetY/eHQ0KLlditiskUzAItOeB7eIv0lL HK2V9cPYl5awAWcjSpMa02NMTbMrt4wTQJm7H1NEGqGz//Y+NNiA3CJftj7zG3I16GyD GV1f93GvMLB+bZl7V+8w65Zv7Z0ED0TDhzwAWXE7cSIvZfDuT29q2gnSGsiqmYuzRvx0 IUVQ== X-Gm-Message-State: AOJu0Yya6P0ZF14serfLv2+UOZlz56avLDldAV4mKd7ipseQynNmo6qt k2LJrj6G/0tQsYvcb5pHZLhAfeoykiXw130GjZ7wr6FrWkVsFlsqovODcH/oOfqZ X-Gm-Gg: AZuq6aJ7ueKKyTx+ng3EdeawZgbtqANs6uC3sw0z9+QMNe+q3Hlacau/GKpwjPEbrBz 1kgKHtThonjWnftSNy2gVsh/ISvJgpAmIX0PMyoskjj7/QgJYNtTki/E2Dn251nNcAfJ+gZN8tb mGjk69m2KTLw/dXWeu/qTgtvtaSuBgmcPEhPRRl1k+xQE901loBl+ZflMcVTQsZLLbfJUoGA0X0 8I+BzskUO40f4QbFzYQ59RDUn55cGLFpjqqljSCLuBygAiUJOKVio6uxJhX2059c8J81t5JW9Vu GIXC/+ZtPMTOd+sSZGQyCPzHY/kNDeDmA9X3kgfLN/iBCLYiDNqiV2lwxAnB990OHIxeRUbZt0d 8Qq3aq0ntPduqNc3jMmPBZbIlGXdnucIBAjmGbi9xQvlC5gdDct2s7dJEHnJ6YurM9+e+0xkJtc g5cOyPrKkeWBQ93K8+c+94NGtRq+umuMJRYjY7gTqE3qG1boYD5plPCG1fAWE057bDtA== X-Received: by 2002:a05:600c:6285:b0:482:eec4:76d with SMTP id 5b1f17b1804b1-4836715979emr46166525e9.17.1770913277874; Thu, 12 Feb 2026 08:21:17 -0800 (PST) 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 v1 2/6] xen/riscv: implement copy_to_guest_phys() Date: Thu, 12 Feb 2026 17:21:03 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913296190154100 Content-Type: text/plain; charset="utf-8" Introduce copy_to_guest_phys() for RISC-V, based on the Arm implementation. Add a generic copy_guest() helper for copying to and from guest physical (and potentially virtual addresses in the future), and implement translate_get_page() to translate a guest physical address into a struct page_info via the domain p2m. Compared to the Arm code: - Drop COPY_flush_dcache(), as no such use cases exist on RISC-V. - Do not implement the linear mapping case, which is currently unused. - Use PAGE_OFFSET() to initialize the local offset variable in copy_guest(). Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/guestcopy.c | 112 ++++++++++++++++++++++ xen/arch/riscv/include/asm/guest_access.h | 7 ++ 3 files changed, 120 insertions(+) create mode 100644 xen/arch/riscv/guestcopy.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 7439d029cc45..90210799e038 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -3,6 +3,7 @@ obj-y +=3D cpufeature.o obj-y +=3D domain.o obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-y +=3D entry.o +obj-y +=3D guestcopy.o obj-y +=3D imsic.o obj-y +=3D intc.o obj-y +=3D irq.o diff --git a/xen/arch/riscv/guestcopy.c b/xen/arch/riscv/guestcopy.c new file mode 100644 index 000000000000..19b681c30b1b --- /dev/null +++ b/xen/arch/riscv/guestcopy.c @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include + +#include + +#define COPY_from_guest (0U << 0) +#define COPY_to_guest (1U << 0) +#define COPY_ipa (0U << 1) +#define COPY_linear (1U << 1) + +typedef union +{ + struct + { + struct vcpu *v; + } gva; + + struct + { + struct domain *d; + } gpa; +} copy_info_t; + +#define GVA_INFO(vcpu) ((copy_info_t) { .gva =3D { vcpu } }) +#define GPA_INFO(domain) ((copy_info_t) { .gpa =3D { domain } }) + +static struct page_info *translate_get_page(copy_info_t info, uint64_t add= r, + bool linear, bool write) +{ + p2m_type_t p2mt; + struct page_info *page; + + if ( linear ) + BUG_ON("unimplemeted\n"); + + page =3D get_page_from_gfn(info.gpa.d, paddr_to_pfn(addr), &p2mt, P2M_= ALLOC); + + if ( !page ) + return NULL; + + if ( !p2m_is_ram(p2mt) ) + { + put_page(page); + return NULL; + } + + return page; +} + +static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, + copy_info_t info, unsigned int flags) +{ + unsigned int offset =3D PAGE_OFFSET(addr); + + BUILD_BUG_ON((sizeof(addr)) < sizeof(vaddr_t)); + BUILD_BUG_ON((sizeof(addr)) < sizeof(paddr_t)); + + while ( len ) + { + void *p; + unsigned int size =3D min(len, (unsigned int)PAGE_SIZE - offset); + struct page_info *page; + + page =3D translate_get_page(info, addr, flags & COPY_linear, + flags & COPY_to_guest); + if ( page =3D=3D NULL ) + return len; + + p =3D __map_domain_page(page); + p +=3D offset; + if ( flags & COPY_to_guest ) + { + /* + * buf will be NULL when the caller request to zero the + * guest memory. + */ + if ( buf ) + memcpy(p, buf, size); + else + memset(p, 0, size); + } + else + memcpy(buf, p, size); + + unmap_domain_page(p - offset); + put_page(page); + len -=3D size; + buf +=3D size; + addr +=3D size; + + /* + * After the first iteration, guest virtual address is correctly + * aligned to PAGE_SIZE. + */ + offset =3D 0; + } + + return 0; +} + +unsigned long copy_to_guest_phys(struct domain *d, + paddr_t gpa, + void *buf, + unsigned int len) +{ + return copy_guest(buf, gpa, len, GPA_INFO(d), + COPY_to_guest | COPY_ipa); +} diff --git a/xen/arch/riscv/include/asm/guest_access.h b/xen/arch/riscv/inc= lude/asm/guest_access.h index 7cd51fbbdead..024e29b4c9f9 100644 --- a/xen/arch/riscv/include/asm/guest_access.h +++ b/xen/arch/riscv/include/asm/guest_access.h @@ -2,6 +2,10 @@ #ifndef ASM__RISCV__GUEST_ACCESS_H #define ASM__RISCV__GUEST_ACCESS_H =20 +#include + +struct domain; + unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len); unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len= ); unsigned long raw_clear_guest(void *to, unsigned int len); @@ -18,6 +22,9 @@ unsigned long raw_clear_guest(void *to, unsigned int len); #define guest_handle_okay(hnd, nr) (1) #define guest_handle_subrange_okay(hnd, first, last) (1) =20 +unsigned long copy_to_guest_phys(struct domain *d, paddr_t gpa, void *buf, + unsigned int len); + #endif /* ASM__RISCV__GUEST_ACCESS_H */ /* * Local variables: --=20 2.52.0 From nobody Mon Apr 13 03:40:41 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=1770913302; cv=none; d=zohomail.com; s=zohoarc; b=H0z5bi5yO7BGczj17LHuTUPiV4eDLHTLR1Zya+cepGj8k+j9ykkrbLwcFjVcLGj1ZzueEhrEX7PAO3oA0ghZLZ/qJdZnXoYSPPiTfdh9TfRTs9eKNzkK7wtL6CsnP5JAtuuclaOjmp+SePWF63zOrvnKYLERa6weDS/zngS8Dz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913302; 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=uZVTmyjQ+cfxWV4H5phu2iSv8MlikEWciPmm+cING7w=; b=GNjkKg3eNUPMv0PwJzOapQmRb4BGDOf+hKdnfiE7rBJm2oQ7RAhSJbCA9YRroqk0IephIxuMOEuw3bUQ93C9lUd2MgdVXvw6el6HrCAqAdxh4PjSj5rGN7rzxOt9FcKlZI+nibqjx4CzJZI4+FOnWYISdcgAe047K3Huy9mNme0= 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 1770913302405128.15756412949997; Thu, 12 Feb 2026 08:21:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229476.1535450 (Exim 4.92) (envelope-from ) id 1vqZRS-0006rv-In; Thu, 12 Feb 2026 16:21:22 +0000 Received: by outflank-mailman (output) from mailman id 1229476.1535450; Thu, 12 Feb 2026 16:21:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRS-0006pv-FD; Thu, 12 Feb 2026 16:21:22 +0000 Received: by outflank-mailman (input) for mailman id 1229476; Thu, 12 Feb 2026 16:21:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRQ-0005jV-PO for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:20 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dd4090f0-082e-11f1-b162-2bf370ae4941; Thu, 12 Feb 2026 17:21:20 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-483337aa225so23765e9.2 for ; Thu, 12 Feb 2026 08:21:20 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:18 -0800 (PST) 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" X-Inumbo-ID: dd4090f0-082e-11f1-b162-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913279; x=1771518079; 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=uZVTmyjQ+cfxWV4H5phu2iSv8MlikEWciPmm+cING7w=; b=mGB4J1ukpJXKn/SE8tfC/OH2RlYPGzz3CgXzDysajvgU7PFByVsBppUYMmvbydeHRE QUtU0tRlSLqo3r8mdmeA+o2qmfHChj06KZLy5mgP8cFTEs8J77PiWb8H5iipFC/5HyG6 OfZp4nGbd6nRRaWTH9wie7cBaBhzIrXrhjEIbaEftHmWZYIBo+wJSLOaOC8gnNXZsbQU 5afFTUqyGPSgGYJ0Oj5FxP0ky9v3xbEiadf4ygbi64fBoSaUOhZ3V16P9JwMo872wy9P IUKLM6sO59JuQ73BUYVMIucP0bXgYnGUSQZHqvboYWoPLOOSIaGfiebUnaYh21AzfYL7 CFIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913279; x=1771518079; 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=uZVTmyjQ+cfxWV4H5phu2iSv8MlikEWciPmm+cING7w=; b=jawL4XaYggIpdgV4D6NGdVQU4H+lcjkbXA7zrfQUNfp5tpyAZnM2VFrExc3e3QeQx1 UJto1/42m6odPQo+2L8NGfopL3QgvBRCYLlC0ijiwGj7QFza/OmNHmgX/1fr5wVm8gVU IfKFgg3AD9MxpZIypsrB+pC5HK2Wy7Z+4qYM3D1y+ZixaEgoh+D4bBKFC/f3/zC/pMQ8 VwF1VW60oX1W3kQrdezu69F+Xr71tfOkRzZZc/7wt8Lyuz+2KTVcjTgWVk7jEI4jvJy1 g//lwuMEQVKVjPAxosJVBpZee7Bk3CbNwv+RcCJeDTPL3UsDsWtJvCipNwEA3sav1/X9 7ciA== X-Gm-Message-State: AOJu0YwsrVtfL+OTIzeXfoJjayExBR8pvLF3SWL1ZUhP4CEOwN6IVX5Q iSCSkrxxtKzlzFkxhxvTIMjRdKvb+CUqkbWqa9VNoVuOFLqS0KUsvWZqDRlNpQar X-Gm-Gg: AZuq6aILfi1pU5GfgQPqhYe7ivUxDdKMewDnW3rT4PzKBbjbcPtmCZyDvAFbpPZ2UxJ d6tQAlxfmWbiLsHh7YQyVEZyAZyNlulLm2lThOHUqhCxq91Qx5kbGBwOkDbRgQnuZqSuEXLh9Y6 cpwDw5f4Zmfg0+Muxn1Dizwv5N7pHG0wguvvJcpSyPBWuT/0awzuS0ZfJy+z25rUIpuAOwg9jiP aA7kCQAisI9WY/i4bb2FzUJCMscGDN19K+tGK1kBuIoTbQdkZrsH3n/INdoE1feFjHKFAcCiCGS D4mPquzmSd6P2D5dQarOyEB2xqideO69elpXAPIgOahDMcyhgKvWp7j6u7EErbk9P2Ss3op5HIt 892zxT6iil8BnwnKGdOl0JXkPAW5loKdwKBhVB3BCJN99c5yfBasVjjKGxfKiiHLD542mDO6U4N qa3ESSk7FTzp2sc9hCIys/eanR0mOYnnk0fAjVWPuMKUW/WvGH1In0t0EebFH7oGNwVA== X-Received: by 2002:a05:600c:83c8:b0:46e:4a13:e6c6 with SMTP id 5b1f17b1804b1-4836570ec0cmr40317005e9.19.1770913278999; Thu, 12 Feb 2026 08:21:18 -0800 (PST) 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 v1 3/6] xen/riscv: add zImage kernel loading support Date: Thu, 12 Feb 2026 17:21:04 +0100 Message-ID: <308c5bc1de15b23c643d48f975799739f44dde8d.1770821989.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913304244154101 Content-Type: text/plain; charset="utf-8" Introduce support for loading a Linux zImage kernel on RISC-V. Note that if panic() is used instead of returning an error as common code doesn't expect to have return code and it is something that should be done separately. This prepares the RISC-V port for booting Linux guests using the common domain build infrastructure. The code is based on Xen Arm code. Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/include/asm/config.h | 13 +++ xen/arch/riscv/kernel.c | 156 ++++++++++++++++++++++++++++ 3 files changed, 170 insertions(+) create mode 100644 xen/arch/riscv/kernel.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 90210799e038..2e15f894fdd4 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -7,6 +7,7 @@ obj-y +=3D guestcopy.o obj-y +=3D imsic.o obj-y +=3D intc.o obj-y +=3D irq.o +obj-y +=3D kernel.o obj-y +=3D mm.o obj-y +=3D p2m.o obj-y +=3D paging.o diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/a= sm/config.h index 86a95df018b5..d24b54d656b8 100644 --- a/xen/arch/riscv/include/asm/config.h +++ b/xen/arch/riscv/include/asm/config.h @@ -152,6 +152,19 @@ extern unsigned long phys_offset; /* =3D load_start - XEN_VIRT_START */ #endif =20 +/* + * KERNEL_LOAD_ADDR_ALIGNMENT is defined based on paragraph of + * "Kernel location" of boot.rst: + * https://docs.kernel.org/arch/riscv/boot.html#kernel-location + */ +#if defined(CONFIG_RISCV_32) +#define KERNEL_LOAD_ADDR_ALIGNMENT MB(4) +#elif defined(CONFIG_RISCV_64) +#define KERNEL_LOAD_ADDR_ALIGNMENT MB(2) +#else +#error "Define KERNEL_LOAD_ADDR_ALIGNMENT" +#endif + #endif /* ASM__RISCV__CONFIG_H */ /* * Local variables: diff --git a/xen/arch/riscv/kernel.c b/xen/arch/riscv/kernel.c new file mode 100644 index 000000000000..f91e9ada8a9c --- /dev/null +++ b/xen/arch/riscv/kernel.c @@ -0,0 +1,156 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define ZIMAGE64_MAGIC_V2 0x05435352 /* Magic number 2, le, "RSC\x05" */ + +static void __init place_modules(struct kernel_info *info, paddr_t kernbas= e, + paddr_t kernend) +{ + const struct boot_module *mod =3D info->bd.initrd; + + const paddr_t initrd_len =3D ROUNDUP(mod ? mod->size : 0, MB(2)); + const paddr_t dtb_len =3D ROUNDUP(fdt_totalsize(info->fdt), MB(2)); + const paddr_t modsize =3D initrd_len + dtb_len; + + const paddr_t ramsize =3D info->mem.bank[0].size; + const paddr_t kernsize =3D ROUNDUP(kernend, MB(2)) - kernbase; + + if ( modsize + kernsize > ramsize ) + panic("Not enough memory in the first bank for the kernel+dtb+init= rd\n"); + + info->dtb_paddr =3D ROUNDUP(kernend, MB(2)); + + info->initrd_paddr =3D info->dtb_paddr + dtb_len; +} + +static paddr_t __init kernel_zimage_place(struct kernel_info *info) +{ + paddr_t load_addr; + + /* + * At the moment, RISC-V's Linux kernel should be always position + * independent based on "Per-MMU execution" of boot.rst: + * https://docs.kernel.org/arch/riscv/boot.html#pre-mmu-execution + * + * But just for the case when RISC-V's Linux kernel isn't position + * indepenet it is needed to take load address from + * info->zimage.start. + * + * If `start` is zero, the zImage is position independent. */ + if ( likely(!info->zimage.start) ) + /* + * According to boot.rst kernel load address should be properly + * aligned: + * https://docs.kernel.org/arch/riscv/boot.html#kernel-location + */ + load_addr =3D ROUNDUP(info->mem.bank[0].start, KERNEL_LOAD_ADDR_AL= IGNMENT); + else + load_addr =3D info->zimage.start; + + return load_addr; +} + +static void __init kernel_zimage_load(struct kernel_info *info) +{ + int rc; + paddr_t load_addr =3D kernel_zimage_place(info); + paddr_t paddr =3D info->zimage.kernel_addr; + paddr_t len =3D info->zimage.len; + void *kernel; + + info->entry =3D load_addr; + + place_modules(info, load_addr, load_addr + len); + + printk("Loading zImage from %"PRIpaddr" to %"PRIpaddr"-%"PRIpaddr"\n", + paddr, load_addr, load_addr + len); + + kernel =3D ioremap_wc(paddr, len); + + if ( !kernel ) + panic("Unable to map kernel\n"); + + /* Move kernel to proper location in guest phys map */ + rc =3D copy_to_guest_phys(info->bd.d, load_addr, kernel, len); + + if ( rc ) + panic("Unable to copy kernel to proper guest location\n"); + + iounmap(kernel); +} + +/* Check if the image is a 64-bit Image */ +static int __init kernel_zimage64_probe(struct kernel_info *info, + paddr_t addr, paddr_t size) +{ + /* riscv/boot-image-header.rst */ + struct { + u32 code0; /* Executable code */ + u32 code1; /* Executable code */ + u64 text_offset; /* Image load offset, little endian */ + u64 image_size; /* Effective Image size, little endian */ + u64 flags; /* kernel flags, little endian */ + u32 version; /* Version of this header */ + u32 res1; /* Reserved */ + u64 res2; /* Reserved */ + u64 magic; /* Deprecated: Magic number, little endian, "RIS= CV" */ + u32 magic2; /* Magic number 2, little endian, "RSC\x05" */ + u32 res3; /* Reserved for PE COFF offset */ + } zimage; + uint64_t start, end; + + if ( size < sizeof(zimage) ) + return -EINVAL; + + copy_from_paddr(&zimage, addr, sizeof(zimage)); + + /* Magic v1 is deprecated and may be removed. Only use v2 */ + if ( zimage.magic2 !=3D ZIMAGE64_MAGIC_V2 ) + return -EINVAL; + + /* Currently there is no length in the header, so just use the size */ + start =3D 0; + end =3D size; + + /* + * Given the above this check is a bit pointless, but leave it + * here in case someone adds a length field in the future. + */ + if ( (end - start) > size ) + return -EINVAL; + + info->zimage.kernel_addr =3D addr; + info->zimage.len =3D end - start; + info->zimage.text_offset =3D zimage.text_offset; + info->zimage.start =3D 0; + + info->load =3D kernel_zimage_load; + + return 0; +} + +int __init kernel_zimage_probe(struct kernel_info *info, paddr_t addr, + paddr_t size) +{ + int rc; + +#ifdef CONFIG_RISCV_64 + rc =3D kernel_zimage64_probe(info, addr, size); + if (rc < 0) +#endif + panic("only RISC-V 64 is supported\n"); + + return rc; +} --=20 2.52.0 From nobody Mon Apr 13 03:40:41 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=1770913308; cv=none; d=zohomail.com; s=zohoarc; b=lN01x+lVoA+eWOr1rM77VVz3IyZH+eHtXdDMPuewn3SGjxNr4PjI/NIDGMtL/73k1jNWUxlorYHhrJ4x5BAgpiR0EzA8hkv18cRHOacJx9KY7s++3S3eqH+aQ44h6abfhNbPTaKS42izjKVwKfda7uBu7OAUPfkxdzloH2T662g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913308; 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=CRkNJBibaLYU3bMR9lUWo949I9MQDI6fqJ8QTLnRMOI=; b=Q5ZCoeVV7FTOB6ouG/lhmDRzpw3mOyxxxk7mTCZz3+JmhTPHq1gk9bl7MpZgxxgzSIuBCKkutL5aecQdY6pASlx/S5fRox6gADGBkTKXtk4X+qpSEMHLlW1bqo3/J3NGcKDL83Pjg+GTEy2cWQKdGYDPn399mMUvWIJNcNWkWT8= 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 1770913308241293.1465203776663; Thu, 12 Feb 2026 08:21:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229477.1535462 (Exim 4.92) (envelope-from ) id 1vqZRU-0007DA-8q; Thu, 12 Feb 2026 16:21:24 +0000 Received: by outflank-mailman (output) from mailman id 1229477.1535462; Thu, 12 Feb 2026 16:21: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 1vqZRU-0007D3-3K; Thu, 12 Feb 2026 16:21:24 +0000 Received: by outflank-mailman (input) for mailman id 1229477; Thu, 12 Feb 2026 16:21:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRR-0005jV-QO for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:21 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id dded50a9-082e-11f1-b162-2bf370ae4941; Thu, 12 Feb 2026 17:21:21 +0100 (CET) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-4376de3f128so41886f8f.0 for ; Thu, 12 Feb 2026 08:21:21 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:20 -0800 (PST) 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" X-Inumbo-ID: dded50a9-082e-11f1-b162-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913280; x=1771518080; 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=CRkNJBibaLYU3bMR9lUWo949I9MQDI6fqJ8QTLnRMOI=; b=S9rG2hX1diD8RiAFb4TVsRd/ECXYFtnsrWHKlTPZOfkcz2QXMIx70WwlLFKz8PNw7a Fs4+sYYT/qKvC3QPxDLYbTPNyNNjlulrmz+YLxP7iZ2V2jdsDlBH3ljWxEqDDq05+IZf Jv9TLzM8cr5eFid15PzzifW03olMo0lMkLIljGEELXmiK6/Gj3GtyqZGMptQzIx5wz+f iVQqI0K0CETuCPssekfDp7reblKtdrhummCrBOeZ7aFP6fc2V0uLJKRi1wcJkl954JX0 CxN52jWBDkdMGhX6IB+C7S/Nki7FmVlEVK1rtyee5mA3Rqgs8C14ydh0QaVDJ8+PT6A8 P6dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913280; x=1771518080; 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=CRkNJBibaLYU3bMR9lUWo949I9MQDI6fqJ8QTLnRMOI=; b=THcZ9rXfS/RiFrAT0wqjxU8IY5s/YJDulKJYeya8xHI25zft0uaQzg1OIVOv7WqRj9 CoCdtcx2akhTUo3Ah2zpC7PzLs3C6vhFwh66wInmpdAvmKhltWarVsrt9yeWraPi1I/N 4kcmJZhoKT0YJ6+IQp52Yu2Ldg3dCIkotdbiXtncOTyE06O4BIOS8FN2LLtbzRNdU43t Avfh/U1M853wzxR176syBK76PpPvTIoFBT2g+y/ydQzR6Wr3uCjQEwYiHHPR6Krm8RXh idQBjFdmxEVihWWo6s4kt+ZUFnt8CGqBELlWp8JM1/N8zSckmiS9On8U8UHAEmsF/ZUH ESPA== X-Gm-Message-State: AOJu0YzGYtNTYUuiCzJHsv/tdJ/osyczivxJdeJeQV/EQdM5Nj/JJJvG Q+vh+XEagOSjzyWODnm29qurgxvRBLKhhrLG4p/BmD+V9qRSrDdblYobxdBKm3Qp X-Gm-Gg: AZuq6aJPOT2Dbdkr8t45E3gma04b+HJacSOtnc4uHQA4wEf0lISapcvUyCTPJmINY6L +A4lMzgNZnr353GpOiz5yCM525m54vevBmVXJ+8sARehum5OYC9AwpTP3wKQc0Sw9ZHcxhxvnmr bvz1bEWB3sKczZ0JH5MYuAnkJXN8Tm/QuIMMV7/s4xzPWj9TSGg3AoV9QjbaT4DCF+G/JX4HW9z Am+0VVwHThBrK8kyn/33ADIU6FuzX/EWZNED5r5MiXkgnH9LFZVdO8uvAweA8gT/VZ+rfXTJ//o 4m74N4MggyIh5SE52mrB0NSILGb7iAI4IiI2VuPeLo3n4G3dSAA2+8bAqFdzbjrqgGd2HR41RbI 6ZOriJlJtNOYs2ysSd8HiQD4raHVjnCThyFP3h1oNhAd8CNZXw4VxuBmdrc3CuJ30jWduunuzx6 ThHxA9J/zNE7hgIoibjCZjkRKhm+fBsd06ZHMHdec+ItoDj7wsroXdynCKGSW++qA7WQ== X-Received: by 2002:a05:6000:1acb:b0:437:681e:cbc3 with SMTP id ffacd0b85a97d-4378ac92470mr6296018f8f.13.1770913280269; Thu, 12 Feb 2026 08:21:20 -0800 (PST) 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 v1 4/6] xen: move declaration of fw_unreserved_regions() to common header Date: Thu, 12 Feb 2026 17:21:05 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913310220154100 Content-Type: text/plain; charset="utf-8" Since the implementation of fw_unreserved_regions() is in common code, move its declaration to xen/bootinfo.h. Signed-off-by: Oleksii Kurochko --- xen/arch/arm/include/asm/setup.h | 3 --- xen/include/xen/bootinfo.h | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/se= tup.h index 899e33925ca4..0d29b46ea52b 100644 --- a/xen/arch/arm/include/asm/setup.h +++ b/xen/arch/arm/include/asm/setup.h @@ -43,9 +43,6 @@ int acpi_make_efi_nodes(void *fdt, struct membank tbl_add= []); void create_dom0(void); =20 void discard_initial_modules(void); -void fw_unreserved_regions(paddr_t s, paddr_t e, - void (*cb)(paddr_t ps, paddr_t pe), - unsigned int first); =20 void init_pdx(void); void setup_mm(void); diff --git a/xen/include/xen/bootinfo.h b/xen/include/xen/bootinfo.h index f834f1957155..dbf492c2e36e 100644 --- a/xen/include/xen/bootinfo.h +++ b/xen/include/xen/bootinfo.h @@ -210,4 +210,8 @@ static inline struct membanks *membanks_xzalloc(unsigne= d int nr, return banks; } =20 +void fw_unreserved_regions(paddr_t s, paddr_t e, + void (*cb)(paddr_t ps, paddr_t pe), + unsigned int first); + #endif /* XEN_BOOTINFO_H */ --=20 2.52.0 From nobody Mon Apr 13 03:40:41 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=1770913304; cv=none; d=zohomail.com; s=zohoarc; b=k17D0M9j+LyKj3A4ru+eBeozh66dN68QUJmgXT0IKM+5KwB+agO3mAlripKj4CVDBhwUhUaxqrtwK4E5BMyQ480kTOUGGZ+dzHscdttkZKB8ruBL+MGorj5hvRJWDbSAixqBH+9jHF27EplcTNKIGmUv1EmVP04xjhhHg6ShUmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913304; 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=iqkKpGyCtGDJtDlBv21kLuTz5YLX6vjY9zkGw/p3/7Q=; b=QJX/phTchj9DaQfCTA8ctqnmTePdPg6w8zw6ACTufi/mFCKGCzWLEh2m3YCjmCDWEXtozD+AQlsseh8QMSDkKOr1+LMGWC4mr7sm4zxD6oRR3iLhV71jhZjfyzjsCoIq1wDkygmmjCv7RFtfhOyQtDzzGVUViWGtlOcjRJ/Ix60= 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 1770913304051139.55900914977508; Thu, 12 Feb 2026 08:21:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229478.1535466 (Exim 4.92) (envelope-from ) id 1vqZRU-0007Ef-HJ; Thu, 12 Feb 2026 16:21:24 +0000 Received: by outflank-mailman (output) from mailman id 1229478.1535466; Thu, 12 Feb 2026 16:21: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 1vqZRU-0007E5-Bf; Thu, 12 Feb 2026 16:21:24 +0000 Received: by outflank-mailman (input) for mailman id 1229478; Thu, 12 Feb 2026 16:21:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRT-0006Fi-Su for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:23 +0000 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [2a00:1450:4864:20::32b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id de98d959-082e-11f1-9ccf-f158ae23cfc8; Thu, 12 Feb 2026 17:21:22 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4834826e555so63095e9.2 for ; Thu, 12 Feb 2026 08:21:22 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:21 -0800 (PST) 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" X-Inumbo-ID: de98d959-082e-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913281; x=1771518081; 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=iqkKpGyCtGDJtDlBv21kLuTz5YLX6vjY9zkGw/p3/7Q=; b=i25PJeX/McznYKr9yMEgnKbH1u+cqRNWLOkqGkPsceVqbIQgPa4o46zjQSPLWFX43F WkpgpYM+vFHzapHp8mRdbNNpSTXWfjs7V/3SFHkiS+67kkFU5tWrVPE1tNO+yc+awaPv cCb6kVzz8DvWX+b3fNLaoZ+2H7Ca+fffaD2RVEBgaECgtxwaXmJUzohvN/AQv+cBLLgb mwkN3aJOKgAf0k18p07JWRjsNHzGdduqrbJbEgyjDcHT2/xD20AZSBct+rZDiv7EvvDY WZuyMWFHsnvcEgPE61A4/tyZm4pgYDWiZ8AhrLVJzWPUo/k7CYT/kHeT2zmmcOegJvKK UBQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913281; x=1771518081; 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=iqkKpGyCtGDJtDlBv21kLuTz5YLX6vjY9zkGw/p3/7Q=; b=HwLyu9iPaT71gfKRGjUwAfk+qfgzDeO8Tr2MExis3cLHdTbpYV3YfY8q7DgJe5K4JI UouN7lDylYRzEdL4y10PWVaUJVFNeacuIJRhcvm9A/wKS6cn91Ox//AcXJZGGRKitUZ2 PLHYgCYgUohXv5hghautU3eVnFzVbiexBzEYA/nLPvqujSknS/gmf8ANOC+ivUJzsrnI VLICQCeYuXWsIfpEOF+TbC3+F12Uc0IS2mNzSMVPOq200d6n4tgnns4gwiEf14MOMILL +qihmNAwnPrEUhkVKSoWdKwaZ0uGVnPRiVrHuCxK8bf61auOhHfQEnMmQyixoCH429sT zmaQ== X-Gm-Message-State: AOJu0YzZCqiLjUzpJD2jUOWM3Lbu2kkwJuUVk0/kFTewcLUMzMLFsL2f LIKd5FISyAAoduZFaGs8VXSb5f0NR9BamVdBxDp47zbKLlChwL13+sT8F9U48ilw X-Gm-Gg: AZuq6aJQ8edQSgwM4LJfKb/q/I7SM02W+tadraHigiUoDZMBQThUEXUwmKGEDl+mdiF IfXFLaSjgwqLDnO7rWtPNE+pF8U4K0gIkkvD7CU/f8Hdm0xGaEAbzum4VIg41rg5FH9efxAiReU R++PoPo5RuWD/h4oPgw+I+LeM1Vy2XAF58nmBJB8j0ySAmokdLYAqJXST4BOMdMKmrGiNhAXpjd mq6OtEc7FsqGqHQXjeCSCbUkDsu3eO8iZvPMDOOccc+Dq3gjT78Xkzg1QCXTKr4dNlC/Aau3AW4 RQNEfM3mpPtqgzFh4mgQuKh3wALkb/RWdUpN950+MOORz3VW7InklmK7o5M6U2MT8cpL8vZsAhY A70DDikhaPSHRfJPHbuSJKCZsS8Xi2yzJD0RMUxatvVG1dBrTt1fjvxKVSuHyUXmkjDYAjOPkbz EMikPwadcr1nU5QmKg9QezVHRowASoBQwuVG+ig2lLRWbyGlrpbF8exSHY0lb9zrohiw== X-Received: by 2002:a05:600c:35c9:b0:483:43da:6c87 with SMTP id 5b1f17b1804b1-4836571fd5emr54435805e9.33.1770913281356; Thu, 12 Feb 2026 08:21:21 -0800 (PST) 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 v1 5/6] xen: move domain_use_host_layout() to common header Date: Thu, 12 Feb 2026 17:21:06 +0100 Message-ID: <678eb53c56bc4f6147feb0bbb6c1319197d0f0df.1770821989.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913305202158500 Content-Type: text/plain; charset="utf-8" domain_use_host_layout() is generic enough to be moved to the common header xen/domain.h. Wrap domain_use_host_layout() with "#ifndef domain_use_host_layout" to allow architectures to override it if needed. No functional change. Signed-off-by: Oleksii Kurochko --- xen/arch/arm/include/asm/domain.h | 14 -------------- xen/include/xen/domain.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/d= omain.h index 758ad807e461..1a04fe658c97 100644 --- a/xen/arch/arm/include/asm/domain.h +++ b/xen/arch/arm/include/asm/domain.h @@ -29,20 +29,6 @@ enum domain_type { #define is_64bit_domain(d) (0) #endif =20 -/* - * Is the domain using the host memory layout? - * - * Direct-mapped domain will always have the RAM mapped with GFN =3D=3D MF= N. - * To avoid any trouble finding space, it is easier to force using the - * host memory layout. - * - * The hardware domain will use the host layout regardless of - * direct-mapped because some OS may rely on a specific address ranges - * for the devices. - */ -#define domain_use_host_layout(d) (is_domain_direct_mapped(d) || \ - is_hardware_domain(d)) - struct vtimer { struct vcpu *v; int irq; diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index 93c0fd00c1d7..40487825ad91 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -62,6 +62,22 @@ void domid_free(domid_t domid); #define is_domain_direct_mapped(d) ((d)->cdf & CDF_directmap) #define is_domain_using_staticmem(d) ((d)->cdf & CDF_staticmem) =20 +/* + * Is the domain using the host memory layout? + * + * Direct-mapped domain will always have the RAM mapped with GFN =3D=3D MF= N. + * To avoid any trouble finding space, it is easier to force using the + * host memory layout. + * + * The hardware domain will use the host layout regardless of + * direct-mapped because some OS may rely on a specific address ranges + * for the devices. + */ +#ifndef domain_use_host_layout +# define domain_use_host_layout(d) (is_domain_direct_mapped(d) || \ + is_hardware_domain(d)) +#endif + /* * Arch-specifics. */ --=20 2.52.0 From nobody Mon Apr 13 03:40:41 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=1770913302; cv=none; d=zohomail.com; s=zohoarc; b=Ff3qQtI4A/p+PFPlfkHidEn37Yi9WyrBk6HqGZdTsvzJxVAJNgsh0/CpaVkTED5q94GCo0U6ces2FRI7ddyo61IsNCnRjpfx+vadnLER4607zygwhF404ssmpjRP8fCvUBPQ6mkuOpPkM5YP96Q4Ljbu7Xmzb5UliZVPLS25Iiw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770913302; 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=boVLzqeW8TB014ODFlHRq6lW2fSrAobM0ZB96ecUZjQ=; b=UB9DrBAV2zLOJku3ycOdDb/znFglumLaYotAPbXGkfx5NoJQc6iq0/8pH16/GRwzOdq8ZcteBvtmRzNwTMJqfraBYC5bKujxVQHHI0I3tZvvMWvSO1xY9vnVwcXwrjdto6AmVYOF1MpAVTEQ6IBbfleOoaM5yqk1SkqsjroQV/g= 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 1770913302826659.6526933776734; Thu, 12 Feb 2026 08:21:42 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1229479.1535481 (Exim 4.92) (envelope-from ) id 1vqZRV-0007dM-QV; Thu, 12 Feb 2026 16:21:25 +0000 Received: by outflank-mailman (output) from mailman id 1229479.1535481; Thu, 12 Feb 2026 16:21:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRV-0007ce-Lh; Thu, 12 Feb 2026 16:21:25 +0000 Received: by outflank-mailman (input) for mailman id 1229479; Thu, 12 Feb 2026 16:21:24 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqZRU-0005jV-1g for xen-devel@lists.xenproject.org; Thu, 12 Feb 2026 16:21:24 +0000 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [2a00:1450:4864:20::431]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id df39c846-082e-11f1-b162-2bf370ae4941; Thu, 12 Feb 2026 17:21:23 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-4359a16a400so40458f8f.1 for ; Thu, 12 Feb 2026 08:21:23 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43783e5c635sm13938426f8f.37.2026.02.12.08.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Feb 2026 08:21:22 -0800 (PST) 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" X-Inumbo-ID: df39c846-082e-11f1-b162-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770913282; x=1771518082; 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=boVLzqeW8TB014ODFlHRq6lW2fSrAobM0ZB96ecUZjQ=; b=YhKYtxRHG6R5fVNwC1+ZSp1sWgFvijRu81Nvhx3JxTN6mC3olsA4TK2uwBJC3btsOp vSqTySyl9A9cajYipCRYQS+FlBPkYQdvI8KaNXtAcd/+5xxs0uAx6nTc19i/Z1Sd5dLB xzwnLBhFqdLgKuH48oLHxJzRSWnWWn7WZRL1Z2h6rdPF/ZD863dyqTVCCku6vaMVE/Ad BD4Oa09xgmoE/Or8TYiwrE0YEy+MggzXdi8cPl39I5+bEk1FORw3pndAdqLZ/Yukons7 CggRiFEdCVqpF1KxrQsINUBlmQyqIURpZxHjhPXDArZpOHWQJn6O4F9pwdotjtUgEAkR kzjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770913282; x=1771518082; 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=boVLzqeW8TB014ODFlHRq6lW2fSrAobM0ZB96ecUZjQ=; b=gxPlZBDVsvL67LBff53g9AvO1Qzxhi2RnbUubvqKqGCgL16b1DAxXeNfYqUYkx4/zf w8PtRF5FsRUkPiw7XB6/9OxrgbDSkx1VvRKyFyxnr+lGlTuLuxhMEjvycZzA983dh6q6 kOnwW022brsAvQaOtxriIOBPgLd1KGfj5Se3Jw+kmMGHeVI2F3UG29TmxImZAJ1dbYoP lfDrT2TG8L+M/UU1oVchhBTQINAWQO3kclHfknz7HW9pLk4neAUWEjEyBRWpSO1Q+Qvt 7UAc+YH8mqm5f93UASFSBXFxKzLZwdY4agSmbEQ1fTq+TqoEAVTWLkzGnmXeVU/tbHjx Z9bw== X-Gm-Message-State: AOJu0YxHaF3TYkuO6smXdj6DoQtzrvjbU+IyRa26auFfXoUcCi1hJTHU K+qtL+chfSId9G4QQcMcMHm5f/snslOBOC73hOFStSYwGZxC97Dyqt7XmZEGzklR X-Gm-Gg: AZuq6aKMjh8m0hcXrpX0i5UL/fFjlykWpPX2wIYVfd8DTryMejky9g+OF2klZrXgs0S q7bPcS9ztiILJvOKueMhc/4QhrUDJuwmtc6Lhn6KfyATyoRjAtcJktb48ZYEsGxpQQTkbIjcu8T SdVSHs6cPb2nLIHEpi1oF2ctSZD1lRF2P3msx8RX8PuagZbgU9cWff0q6UTGuM0yKTkIZhENKCD vJw/xlJAzhu9ZbpXWV3FHmidqR8nZIyeumAS26/SfyQU4LKz6WmdYRF91shVabha/z4tiSqGGiB DaA18GDYIx/Tu8YpqqW5C/xd36ix63okGIUvJNZxPG63PPBK5c1sgW4+BtAEgm2p85je3wVoqKg nWQrQWQtcU7oMWZ5ilW/vJUxVYR9CXpphggzvqPHtfP5Xy3wmLigZ/teGCfxZK/gHU4odSsBOfw f0mECVVi7cv2ZfJ3B5+XljxlVQJxw1OJ2FmJXEHApulefolKeFiPsUygOtzgsjze95j3Mx3mIeo e8I X-Received: by 2002:a5d:5d8a:0:b0:436:3732:cfa6 with SMTP id ffacd0b85a97d-4378f16d7ffmr5166470f8f.53.1770913282360; Thu, 12 Feb 2026 08:21:22 -0800 (PST) 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 v1 6/6] xen/riscv: enable DOMAIN_BUILD_HELPERS Date: Thu, 12 Feb 2026 17:21:07 +0100 Message-ID: <6ab04f3584e45795dc82c25f62a6c950913f5c7d.1770821989.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1770913304180154100 Content-Type: text/plain; charset="utf-8" To enable DOMAIN_BUILD_HELPERS for RISC-V the following is introduced: - Add a global p2m_ipa_bits variable, initialized to PADDR_BITS, to represent the maximum supported IPA size as find_unallocated_memory() requires it. - Define default guest RAM layout parameters in the public RISC-V header as it is required by allocate_memory(). Signed-off-by: Oleksii Kurochko --- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/include/asm/p2m.h | 3 +++ xen/arch/riscv/p2m.c | 6 ++++++ xen/include/public/arch-riscv.h | 8 ++++++++ 4 files changed, 18 insertions(+) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 89876b32175d..12b337365f1f 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -1,5 +1,6 @@ config RISCV def_bool y + select DOMAIN_BUILD_HELPERS select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME select GENERIC_UART_INIT diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index c68494593fd9..083549ef9640 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -44,6 +44,9 @@ #define P2M_LEVEL_MASK(p2m, lvl) \ (P2M_TABLE_OFFSET(p2m, lvl) << P2M_GFN_LEVEL_SHIFT(lvl)) =20 +/* Holds the bit size of IPAs in p2m tables */ +extern unsigned int p2m_ipa_bits; + #define paddr_bits PADDR_BITS =20 /* Get host p2m table */ diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index f5b03e1e3264..62bd8a2f602f 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -51,6 +51,12 @@ static struct gstage_mode_desc __ro_after_init max_gstag= e_mode =3D { .name =3D "Bare", }; =20 +/* + * Set to the maximum configured support for IPA bits, so the number of IP= A bits can be + * restricted by external entity (e.g. IOMMU). + */ +unsigned int __read_mostly p2m_ipa_bits =3D PADDR_BITS; + static void p2m_free_page(struct p2m_domain *p2m, struct page_info *pg); =20 static inline void p2m_free_metadata_page(struct p2m_domain *p2m, diff --git a/xen/include/public/arch-riscv.h b/xen/include/public/arch-risc= v.h index 360d8e6871ba..91cee3096041 100644 --- a/xen/include/public/arch-riscv.h +++ b/xen/include/public/arch-riscv.h @@ -50,6 +50,14 @@ typedef uint64_t xen_ulong_t; =20 #if defined(__XEN__) || defined(__XEN_TOOLS__) =20 +#define GUEST_RAM_BANKS 1 + +#define GUEST_RAM0_BASE xen_mk_ullong(0x80000000) /* 2GB of low RAM @ 2G= B */ +#define GUEST_RAM0_SIZE xen_mk_ullong(0x80000000) + +#define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE } +#define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE } + struct vcpu_guest_context { }; typedef struct vcpu_guest_context vcpu_guest_context_t; --=20 2.52.0