From nobody Wed Apr 8 04:36:26 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=1773163128; cv=none; d=zohomail.com; s=zohoarc; b=DCEfT8h9JcU9WXlhDW2dKhCAWturhRc6UqLK+QAvwmQsPKJveLW611CJZdkB75bBvZzPrSGqejrwwWlQl0914/0jZAhrVbnEBEtzq0X60K6mUBWDkVo4FqytdDu1bAK6CknWhRn22vi5gEjqeOtSRcghe4Od/iBDnv0npGH5UJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773163128; 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=eS5sSCMJ+IJ1M5ORzLuoNMwjp7zPxai25z8WoDewGMs=; b=SbDRLd3Pz0OgTYpqrfKjuuG7AFvXLuCzJX6koaNRNaAC0RHWavF9x0CzbE6DGVmNTGLtC4DRfs2pV4VeXwiIyYUFizKEzcS4X5krX9hlepHv8mJlyDoKtUT1ctCfOlczUdh06UfwKUVtrHRZ8JMGG67P2PQceQux3jk9j5LT4WY= 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 177316312863252.871802893069; Tue, 10 Mar 2026 10:18:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1250565.1548053 (Exim 4.92) (envelope-from ) id 1w00j6-0005Nz-Os; Tue, 10 Mar 2026 17:18:36 +0000 Received: by outflank-mailman (output) from mailman id 1250565.1548053; Tue, 10 Mar 2026 17:18:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w00j6-0005Nm-M2; Tue, 10 Mar 2026 17:18:36 +0000 Received: by outflank-mailman (input) for mailman id 1250565; Tue, 10 Mar 2026 17:18:34 +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 1w00aW-0001Q4-J5 for xen-devel@lists.xenproject.org; Tue, 10 Mar 2026 17:09:44 +0000 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [2a00:1450:4864:20::330]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ede70159-1ca3-11f1-b164-2bf370ae4941; Tue, 10 Mar 2026 18:09:42 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4853510b4f3so41192225e9.0 for ; Tue, 10 Mar 2026 10:09:42 -0700 (PDT) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-485359bf807sm119619845e9.2.2026.03.10.10.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 10:09:41 -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" X-Inumbo-ID: ede70159-1ca3-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773162581; x=1773767381; 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=eS5sSCMJ+IJ1M5ORzLuoNMwjp7zPxai25z8WoDewGMs=; b=V6yZRalt6hfTpxVuBCuArsS79iZpCjhdoZ/pdpi3ir4s30PmTg4uVDZIb3Bdz0SKmK zQ0bPZCAb5S0UnZ8riWtkO6Lm9rEB5jzFI5R3L5EJxuvWaEvlUmsBpJmragGPpyKU8WZ m2MXTahbvFKhSeT6OOhkFaJAtz7LYuEmLN+61st8nbeXKI8iItQ/7ndN9EO3q/qf5Ysn jzl9f/jNc0MuRdtaU5NpIvYK8ypE93OIgz0Lg7hAhQn+gPFhO78t2qyzIvfWUFaejzWx sY0/LpZeASF9UO56c3tnMlZFp83qnk7TZlQjz8w0cuwyxjFUYDBx7v15c0MrveGUDRR+ JSiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773162581; x=1773767381; 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=eS5sSCMJ+IJ1M5ORzLuoNMwjp7zPxai25z8WoDewGMs=; b=s6ypZ+rYGTliRaIJQywBJCpnFK1NaBmTpRN3jwRVuTbaO8E2dhJMPOMxA+QDNPljMy 5wiNpISxtQrshket458J3WwBbzqONP7IGIN6i1yTAut+sHL5DkVGwaHqm3nxc59e+ndc zCTlN1OS5PyvTaVuCGjCWDTvjmjeTXJ3C6gRFphjg0QdMOieyr6b2c7+UWNp+ubFHn8r 7du7pu7r7vRFgXyZygmOftWn7Bf5RvQ7SckGeXBCOaBegr85+SwuwxnyzWzKQJb5r54h /B3N/mDavKdPiATAwMAfeYAtkxgVoq4Mo6JrignLvM9YXsSyKBDdSW8MdgAI7amEykM2 DNGw== X-Gm-Message-State: AOJu0YwjVfrb6rnYvzki2Rw1pSfSmYKOoKdGoP6AEg4DpaqFvJPszUfQ WgP+mZ4sdnX3J2r1BkkwNv/wzDfDbSYDVlT3R7EvTwLRzKwdSj08+/u9rStKeqE/ X-Gm-Gg: ATEYQzwMo8kkiGOq1YIoWwv1Qi7XhNmu6sDVSpr8Gb6B32rV56VJu3g590ObJcWkaJ7 QPpDowvUT9eDPdrzP5Yd3G/X0qnQ/F1noZ6dCZ1Zb6BY0gIKdKO0LfHKIXvMhAU11yHmYjZ8y0W HWD4uUf4RMWVwsQG6FljNBqpcJeVnuu4pR0wGXSy5Z/oJ2nBxNroqL37NocBKpp9IR0cz7lwf/T eX5baAMOxQXu+SUHFez9ioEUA1RbCr2JD7HIavV8krBRoM1bCajfSgfPqWFErvl/vM+pFOkuzu2 ToN65cMA1fcnmWMjQgjgGY7TkEzMGQ9L6maBQiD7yjZ32tjPiKcKhGQ+vTuN8KwCl6L4aK9d4KC nrKO+2ct272+G5PMidGPGGRVQDQs1t1F1uGBMwcaHu/eUuqLTVZqXO6UhRihcgi0dI3Q0GlEgHf bmdMm3vB2AeB4tdXS3TSM8w5QuCeAGvLEfRcTrZFT0tlOFL+oFumzgHhFAEVS67ANtwbcvag== X-Received: by 2002:a05:600c:19ca:b0:485:3d43:7c9a with SMTP id 5b1f17b1804b1-4853d437d40mr110653125e9.25.1773162581377; Tue, 10 Mar 2026 10:09:41 -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 v1 27/27] xen/riscv: add initial dom0less infrastructure support Date: Tue, 10 Mar 2026 18:09:00 +0100 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1773163129766158500 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. Signed-off-by: Oleksii Kurochko --- Open questions: - Move declaration of p2m_set_allocation() to xen/fdt-domain-build.h or xen/dom0less-build.h as it is used in common code of Dom0less and there is not too much sense in declaration of it for each arch which supports Dom0less. It could be ifdef-ed in common header as, at the momemnt, it is used only for Dom0less. - Shouldn't declaration/defintion of max_init_domid move to common code instead of having it for each architecture separately? If yes, then what would be the best place. --- --- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/dom0less-build.c | 18 ++++++++++++++++++ xen/arch/riscv/domain-build.c | 13 +++++++++++++ xen/arch/riscv/include/asm/domain.h | 8 ++++++++ xen/arch/riscv/include/asm/p2m.h | 2 ++ xen/arch/riscv/include/asm/setup.h | 4 +++- xen/arch/riscv/setup.c | 2 ++ xen/include/public/arch-riscv.h | 3 +++ 8 files changed, 50 insertions(+), 1 deletion(-) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 091510380949..abd579aa6a54 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -6,6 +6,7 @@ config RISCV select GENERIC_BUG_FRAME select GENERIC_UART_INIT select HAS_DEVICE_TREE_DISCOVERY + select HAS_DOM0LESS select HAS_PMAP select HAS_UBSAN select HAS_VMAP diff --git a/xen/arch/riscv/dom0less-build.c b/xen/arch/riscv/dom0less-buil= d.c index 43c8bdc52300..865311ec7037 100644 --- a/xen/arch/riscv/dom0less-build.c +++ b/xen/arch/riscv/dom0less-build.c @@ -43,3 +43,21 @@ int __init make_arch_nodes(struct kernel_info *kinfo) =20 return 0; } + +void __init set_domain_type(struct domain *d, struct kernel_info *kinfo) +{ + /* Nothing to do */ +} + +int __init arch_parse_dom0less_node(struct dt_device_node *node, + struct boot_domain *bd) +{ + /* Nothing to do */ + return 0; +} + +int __init arch_handle_passthrough_prop(struct kernel_info *kinfo, + struct dt_device_node *node) +{ + return 0; +} diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c index ae26faed09ed..20735f41d646 100644 --- a/xen/arch/riscv/domain-build.c +++ b/xen/arch/riscv/domain-build.c @@ -154,9 +154,22 @@ int __init make_cpus_node(const struct domain *d, void= *fdt) return res; } =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/domain.h b/xen/arch/riscv/include/a= sm/domain.h index 21a3e6876f36..a8342ca7c5bf 100644 --- a/xen/arch/riscv/include/asm/domain.h +++ b/xen/arch/riscv/include/asm/domain.h @@ -20,6 +20,14 @@ struct hvm_domain uint64_t params[HVM_NR_PARAMS]; }; =20 +#ifdef CONFIG_RISCV_64 +#define is_32bit_domain(d) (0) +#define is_64bit_domain(d) (1) +#else +#define is_32bit_domain(d) (1) +#define is_64bit_domain(d) (0) +#endif + struct arch_vcpu_io { }; =20 diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/= p2m.h index 4441c0400b83..d97c8d13ef6b 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -259,6 +259,8 @@ void p2m_ctxt_switch_from(struct vcpu *p); void p2m_ctxt_switch_to(struct vcpu *n); void p2m_handle_vmenter(void); =20 +int p2m_set_allocation(struct domain *d, unsigned long pages, bool *preemp= ted); + #endif /* ASM__RISCV__P2M_H */ =20 /* diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/as= m/setup.h index 1c23043f409f..2e3f8931d01b 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -5,11 +5,13 @@ =20 #include =20 +#include + struct domain; struct dt_device_node; struct rangeset; =20 -#define max_init_domid (0) +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 5bc34e41fe55..513f94777f38 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -32,6 +32,8 @@ #include #include =20 +domid_t max_init_domid =3D 0; + /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); diff --git a/xen/include/public/arch-riscv.h b/xen/include/public/arch-risc= v.h index 91cee3096041..3c0c786c57ac 100644 --- a/xen/include/public/arch-riscv.h +++ b/xen/include/public/arch-riscv.h @@ -58,6 +58,9 @@ typedef uint64_t xen_ulong_t; #define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE } #define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE } =20 +#define GUEST_MAGIC_BASE xen_mk_ullong(0x39000000) +#define GUEST_MAGIC_SIZE xen_mk_ullong(0x01000000) + struct vcpu_guest_context { }; typedef struct vcpu_guest_context vcpu_guest_context_t; --=20 2.53.0