From nobody Mon Aug 24 19:01:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1783353541; cv=none; d=zohomail.com; s=zohoarc; b=oL0z+O3LkS+N4nPkjGaUfkROOyuzYEQ2O5r1e7X+QqWZ9AHk9xiyH5NLgWXFoGxvOT6++88WC1ovOo2+rsV25AvjXXpwvue4lSeqtHB8utIzo7MEdlbdCY5fcP9LcxCt1dqZ5IXf3GBcQ6AfM/W06/0nsobAWSKTDt9yDdW12CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783353541; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=DuvpVJ8H0OYvoodO31gd5gRgdWgUp5KGkYSzJQgqynrEG+vHBaUYSxq+AMSoqlCh9PnAnKeMNWznrj1MEMX88ZsXSNpq8unkpaxQldK0ZssrbyGMirczBDq4aj04ngaeyFof87Q4XblJ7khJW6MsRv7j2RFajzTutwpvq2/jarg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1783353541688263.9417194695135; Mon, 6 Jul 2026 08:59:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1355493.1610328 (Exim 4.92) (envelope-from ) id 1wgliI-00088j-Ee; Mon, 06 Jul 2026 15:58:30 +0000 Received: by outflank-mailman (output) from mailman id 1355493.1610328; Mon, 06 Jul 2026 15:58:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wgliI-00088S-9c; Mon, 06 Jul 2026 15:58:30 +0000 Received: by outflank-mailman (input) for mailman id 1355493; Mon, 06 Jul 2026 15:58:29 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) id 1wgliH-0007ta-9J for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 15:58:29 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wgliG-003COz-MK for xen-devel@lists.xenproject.org; Mon, 06 Jul 2026 17:58:28 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a4bd092-2eae-0a2a0a5409dd-0a2a4502b80a-30 for ; Mon, 06 Jul 2026 17:58:28 +0200 Received: from [209.85.128.49] (helo=mail-wm1-f49.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a4bd0a4-5a27-0a2a45020019-d1558031d16c-3 for ; Mon, 06 Jul 2026 17:58:28 +0200 Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493c59f740cso22407835e9.3 for ; Mon, 06 Jul 2026 08:58:28 -0700 (PDT) Received: from fedora (user-109-243-144-234.play-internet.pl. [109.243.144.234]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493cce03fa1sm284910325e9.11.2026.07.06.08.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2026 08:58:27 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783353508; x=1783958308; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=Ik/sDORWAvy5pbB9ArKmqNnPtyhxbWROlpS5mG2HXJyjVbtKUkhL+0cJwp8sLOoLic d8MldxFUAaB9D+1EGcLgY+ltTcnnA1kdcrkjhHqzuy0Xnpqcqz5dvAGclFUP/TNxCC2l zNydx4khxzHpOIVddCBWXZaOwIK6S7B5C8C2TJz8yacIyuwxORPep2fbm8wLtacuAwi8 oUYEbARg1BJNrA6zNHV074n+S8dGzUaDafjjUBvnQ/jPRzVVHx4KBnt2rl/4vC6u/l+D FVJtYNGXFhxyu9gTcYBh4H7aepnAZ6CyaqBlT9VLxm5C44/Q3aKoDd53VbxJFzrW1yj0 KTYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783353508; x=1783958308; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hLy3qyx924BwMCcddx6KluNT1kSq6alsUk5vcF9j5ys=; b=IMMUC6Llfz9nOdb2ecqFeWIZellKZA97XLJofIvtjFN93JswAwCjtlO+rs2EX6We00 NuiL18W9re1ftblltBD2fLPsrrxYAPtLEDKpziaova8hBlI/nftoCVIJMLap0ALTEOQM ZvrgPiXK3JI9e+qx8tumyjYroxPRb6StC25hQsl6TURdHP2jVoU9u31Lovmnmrh+z2BG SymOSd56R6Iq4H+2ONSfU7UpDRUN1wVtQiwTc5RC4U+/cAtSHe98Ht7FcJM7HT2r3Ue4 QeVFmmesOkvBvXkwVVpWAqY925gd4e9rbsA1XYODl83Q4stTqwYhUczVUPZahx6qAAdo 08AA== X-Gm-Message-State: AOJu0YydBSPyF4hxh6MuWzBJRfFvzcIsDKTXN/4LgUbBK9l6QdB0IChN EZV1LZVhQKdhbS8HhClQhP66auzmHJ7+n5SiN8Qv7P9iYLFkN7c2Miea8DGqHw== X-Gm-Gg: AfdE7cnvjloGxuwySAa4ZMFfH25ayOm41yeu6wujypVsTPiVzsW2UnHsI1M+dDPIGWQ Jc5PGjdVxeka8LX8MDXVXrzXCFl2UFHxZH8L+yGGt3QX7XFx6xDabnaN1rh80i5pXeuRu2TKQaf 9Xve2I+IuqcdeXmz0Rc8zSFRWBpvbq2EEjpsuSW8ume0ci8ad7hixiRepz+aJ1S0dR5ia0C0FA4 7dVjrhx7b7ZiWaYzusO9YkwWn7946M73xyntOBJOEbZxDiak+oOZN6rkp4iC3nghfhpbMYEVefR fWFcb9OC7oGPPdxhmgmZJBWCT/v+F1UdaXgpBB4WQAXAH89HO/uFd546UdaXFyxOoH963mOriAh P+iUzUucsBE0RWlf4bP3eDbmj1b3sDk96HFOdIsW7Tt449Up4AORxae1TyuQ83jXf+lgXt4Mdf3 W2cB2SxCCIusVJSKzd5Nvwk3IV+J4Cq/nzA0BlPMUII9mQd/FNXOUtQPlf9A== X-Received: by 2002:a05:600c:3143:b0:493:d800:204f with SMTP id 5b1f17b1804b1-493df0a7521mr14274605e9.21.1783353507784; Mon, 06 Jul 2026 08:58:27 -0700 (PDT) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Baptiste Le Duc , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v5 07/26] xen/riscv: Implement construct_domain() Date: Mon, 6 Jul 2026 17:57:48 +0200 Message-ID: <77cfcb52b46c96d68e1fe4032b238bf40f77e3f1.1783331040.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1783353508-547197C5-2B2108C2/10/73395122804 X-purgate-type: spam X-purgate-size: 3114 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1783353542864158500 Content-Type: text/plain; charset="utf-8" Implement construct_domain() function for RISC-V, which performs initial se= tup for the domain's first vCPU, loads the kernel, initrd, and device tree, and sets up guest CPU registers for boot. It also creates additional vCPUs up to max_vcpus and assigns the device tree address and boot cpuid in registers. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v5: - Only rebase. Nothing changed. --- Changes in v4: - Drop the blank before v%u in the printk() failure message so the output matches that of %pv. - Restore Acked-by that was lost in v3. --- Changes in v3: - s/%d/%u for printing vCPU index in the failure message. - Drop dprintk() for successful vCPU creation. --- Changes in v2: - Rework construct_domain() to print that vCPU1...n are created using %pv. - Use true instead of 1 for initialization of v->is_initialised. - Drop unnessary BUG_ON() in construct_domain(). - Add TODO comment above *_load() functions. --- --- xen/arch/riscv/Makefile | 1 + xen/arch/riscv/domain-build.c | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 xen/arch/riscv/domain-build.c diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index 8f7fd625dddd..fd5e499eb4b9 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,6 +1,7 @@ obj-y +=3D aplic.o obj-y +=3D cpufeature.o obj-y +=3D domain.o +obj-y +=3D domain-build.init.o obj-$(CONFIG_DOM0LESS_BOOT) +=3D dom0less-build.init.o obj-$(CONFIG_EARLY_PRINTK) +=3D early_printk.o obj-y +=3D entry.o diff --git a/xen/arch/riscv/domain-build.c b/xen/arch/riscv/domain-build.c new file mode 100644 index 000000000000..5f6f4b6248a5 --- /dev/null +++ b/xen/arch/riscv/domain-build.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include +#include +#include +#include + +#include +#include + +int __init construct_domain(struct domain *d, struct kernel_info *kinfo) +{ + struct vcpu *v =3D d->vcpu[0]; + struct cpu_user_regs *regs =3D vcpu_guest_cpu_user_regs(v); + + BUG_ON(v->is_initialised); + + /* + * At the moment *_load() don't return value and will just panic() + * inside. + * TODO: it will be good to change that. + */ + kernel_load(kinfo); + initrd_load(kinfo, copy_to_guest_phys); + dtb_load(kinfo, copy_to_guest_phys); + + regs->sepc =3D kinfo->entry; + + /* Guest boot cpuid =3D 0 */ + regs->a0 =3D 0; + regs->a1 =3D kinfo->dtb_paddr; + + for ( unsigned int i =3D 1; i < d->max_vcpus; i++ ) + { + const struct vcpu *tmp_v =3D vcpu_create(d, i); + + if ( !tmp_v ) + { + printk("Failed to allocate %pdv%u\n", d, i); + break; + } + } + + domain_update_node_affinity(d); + + v->is_initialised =3D true; + clear_bit(_VPF_down, &v->pause_flags); + + return 0; +} --=20 2.54.0