From nobody Sat May 30 16:35:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128836; cv=none; d=zohomail.com; s=zohoarc; b=cv/PZJmyoXlJ3MobmxInytjGY8rUmd/IXTemnYVrdV+uKyQmYN/VEdw2DZjbY7U40a4/x92z9ZqR41dzNLan0erkU8/f8BXnDJnLvimNJXw9gXB/1aaWKRQAqiOMikMEG89K7V1y4JAapJrOVpBufAm9Bg56nx1mVY/cNaoXUew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128836; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r58xAilyz0m62aKrNY5JMXEmTJub2NBNqjXn8vtcN8c=; b=hemsTs6+9DlQSJuc4keblU8gk53bH/XCwPmA1MEcHqVtfcFxWV1mPY8THKCXC7jKd+7biXXImgf1Cv+v1P5CD7VXeZ4YTkOAE1Il5CKFpPqCAj2OQ44Y7pvhQB/ZSR/LebXygxKAqoRmTVVnHYVb/7vsmwPXEomFrR/E0ATN1Ho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128836490946.9501587183846; Wed, 6 May 2026 21:40:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqWc-0000PU-PK; Thu, 07 May 2026 00:39:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWb-0000PF-P8 for qemu-devel@nongnu.org; Thu, 07 May 2026 00:39:49 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWa-0003rW-6J for qemu-devel@nongnu.org; Thu, 07 May 2026 00:39:49 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2b9705613ddso2584665ad.1 for ; Wed, 06 May 2026 21:39:47 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babaaf38d2sm8899235ad.32.2026.05.06.21.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128787; x=1778733587; darn=nongnu.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=r58xAilyz0m62aKrNY5JMXEmTJub2NBNqjXn8vtcN8c=; b=BGJ929fXmNw4hZdWQIHQRDsGuW1nJRVFJYA3TXJtOdafEdsqcolVUl1T05YTPepH28 E0d7bhRquiH1DLUcmz+IcnLa7uyUxIzsHyodNgpkPgJneTNMnSk8ciWgnRJwIRfltkvc AwMAy4cCWqQDMBUixeR0ZLHGTTbRPMXlPqnIhU2b373t3M8SUJWpfxSP41EnXMvd5pi9 7NdXMk3YMdOLV60zS5jGfgbu0UgvB9Joxc/NqSC0Tc/rF1JZRPR2/qxlsgR5e9lI0yV8 oWhCPKj+GrmLNZjRoIcjR8UgFGwn9Ezel+Gstm9+3ehcpsMtNZ6VrfCslW2z8Nuop4gV 9udg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128787; x=1778733587; 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=r58xAilyz0m62aKrNY5JMXEmTJub2NBNqjXn8vtcN8c=; b=LajadLJfgC80Ipa12WF7zN4ubUulUUoLmW1dIVqm539ai2IfD8LGlZjHh416PliG5i iecJGDWfjTPmEbrkZarEmZT+c+aZGjUIIgScNsjsCUWUoyPqy8IWMsV+U3SRYPQQ6Z0w TVcTGidYiNLTgDrIxKevoXsTIVyEWTFm/BdK3qSa8AB0119MSyzAsvwzuupQqTFHbSA6 X4zL/j0xhXrD38LH6cx+B1NOEMnb+im1GoDIENdMUm40RGy3oKgjspbVojzEKzG+RRwe xU1JpVAqzW/jjwixUtxtq1E4h/VzyEicm8t0eUz9KdJJFIC+F2dRm6izsT/lrokAw2eL kIyQ== X-Forwarded-Encrypted: i=1; AFNElJ/MP41DT5m3q04HlUza1A+VOONmW8ZdKPOchGe15u52bX2bS2vpNg27x6A3DCJbougqUI4IshyCh5VF@nongnu.org X-Gm-Message-State: AOJu0YyCim8T+kQleh7ymjCtN6jeNYsYOvVZDQBqGanuWc3b4UHblE4Y +peYggOj83Wj9Q6QE9CQQBCsR1ki94nev3p3xiS2H+sEA+sVrG7kyUkl X-Gm-Gg: AeBDievev5oLacuqhui44v7yLbB5c8VscQHsDPWMlGkcTQ5552CNSiBIRF6b/ozsz2C y6gsGNFcJklz2R6PSr0BlemR6j36c/Bw11RWBOLDuSV3fIgkYRRHxdr3ysEhkBB4+Mik28sos8Y cl8wvFZ3ILfCWrIQOcNOfcvJK8pe2sjF//7jqSSD5Z6xnnR3FEd/L+T0aBISqJT5P8TfkXGv7gl PSx1NRdiY/Vk6lSilDbeIwyfYS5NNjt2/v3p0m3vGqqWBUaIiwXpjx4NuaU+DWEazd8kjslCheZ 8HeY4Qn4fpapRFmNk1e++naqQ+ek5qRZhNe1jzWI3GBwTHQUA8TyiXsMvFLnVgSKM/OXvyiyLWg xhnSataeEjFhp/SSDyHaESK7JYNWp/fC45VeVR+lb2ZtC/KI7qptqS9FLqlMtH4C5jcI/8s0oMq UzpRhnJmrTlfjK1mz290olnYhRacBQxKdTolMD6zULHUwsJNEUOXrq5fCU472i9g/Mhhk3FG3JO yE1Ucj7 X-Received: by 2002:a17:903:f8b:b0:2aa:d5e5:b136 with SMTP id d9443c01a7336-2ba79f192e0mr72101335ad.38.1778128786737; Wed, 06 May 2026 21:39:46 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v5 1/9] hw/riscv/boot: Describe discontiguous memory in boot_info Date: Thu, 7 May 2026 14:38:29 +1000 Message-ID: <20260507043838.45652-2-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128837901158500 Content-Type: text/plain; charset="utf-8" Machines that have discontiguous memory may need to adjust where firmware and images are loaded at boot. Provide an interface for machines to describe a discontiguous low/high RAM scheme for this purpose. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin --- hw/riscv/boot.c | 16 ++++++++++++++++ include/hw/riscv/boot.h | 7 +++++++ roms/seabios-hppa | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 9086793b7a..6e0c6c2d17 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -69,11 +69,27 @@ char *riscv_plic_hart_config_string(int hart_count) =20 void riscv_boot_info_init(RISCVBootInfo *info, RISCVHartArrayState *harts) { + info->ram_low_start =3D 0; + info->ram_low_size =3D 0; info->kernel_size =3D 0; info->initrd_size =3D 0; info->is_32bit =3D riscv_is_32bit(harts); } =20 +/* + * This can be used instead of riscv_boot_info_init() if the machine has + * discontiguous physical memory. The low memory range specified will be + * used to place firmware images. + */ +void riscv_boot_info_init_discontig_mem(RISCVBootInfo *info, + RISCVHartArrayState *harts, + hwaddr low_start, hwaddr low_size) +{ + riscv_boot_info_init(info, harts); + info->ram_low_start =3D low_start; + info->ram_low_size =3D low_size; +} + vaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, hwaddr firmware_end_addr) { if (info->is_32bit) { diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h index f00b3ca122..69c99a1496 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -28,6 +28,10 @@ #define RISCV64_BIOS_BIN "opensbi-riscv64-generic-fw_dynamic.bin" =20 typedef struct RISCVBootInfo { + /* First contiguous RAM region. If size is zero then assume entire RAM= */ + hwaddr ram_low_start; + hwaddr ram_low_size; + ssize_t kernel_size; hwaddr image_low_addr; hwaddr image_high_addr; @@ -43,6 +47,9 @@ bool riscv_is_32bit(RISCVHartArrayState *harts); char *riscv_plic_hart_config_string(int hart_count); =20 void riscv_boot_info_init(RISCVBootInfo *info, RISCVHartArrayState *harts); +void riscv_boot_info_init_discontig_mem(RISCVBootInfo *info, + RISCVHartArrayState *harts, + hwaddr low_start, hwaddr low_size); vaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, hwaddr firmware_end_addr); hwaddr riscv_find_and_load_firmware(MachineState *machine, diff --git a/roms/seabios-hppa b/roms/seabios-hppa index d9560852a3..1a8ada1fb7 160000 --- a/roms/seabios-hppa +++ b/roms/seabios-hppa @@ -1 +1 @@ -Subproject commit d9560852a34f156155b3777745baa0d96d553f22 +Subproject commit 1a8ada1fb70643172e251aacbac673c9ecda99e9 --=20 2.53.0 From nobody Sat May 30 16:35:20 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128872; cv=none; d=zohomail.com; s=zohoarc; b=VZEHkG+V40RmcMo7Vh2hnn/zzuOz6hRauuln8AqPuKbqp0IYYE3wbFido5LD3h3Q/vG6YDl+ABMQW0OKFDIyambL82ht9E3AJoaNkBSfrKjWivfsoU0G7Z/eQrW4Hfl+uZjdTFjusneKzTSQ8UrxglaL2ym/yS9gNPECsfOfmfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128872; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aFqRmy2NnHUogWk2zuIaqAwu+8N7/skfs0tq/duJUVQ=; b=Ci2UhIwpFxtjeKwRi2gnp+IG09ecZEdhVbMZpRbeiviMC0yzg9EOGM6mGmPSyPKFQDjGD1aUtQuNEAxuLTvQKCVVF0iMh7L4gUD62q/DAVfe2L/P32ZDhzGinIHGwKJ2e8RGDPkYNkHgL1Kk0DRAZml5pg8gjQ2PF3jAmz48XgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128872596974.9840530584344; Wed, 6 May 2026 21:41:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqWj-0000QY-5c; Thu, 07 May 2026 00:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWh-0000QH-Lc for qemu-devel@nongnu.org; Thu, 07 May 2026 00:39:55 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWf-0003sA-Cf for qemu-devel@nongnu.org; Thu, 07 May 2026 00:39:55 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2babfd18435so1131785ad.1 for ; Wed, 06 May 2026 21:39:53 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babadef853sm8972825ad.64.2026.05.06.21.39.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128792; x=1778733592; darn=nongnu.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=aFqRmy2NnHUogWk2zuIaqAwu+8N7/skfs0tq/duJUVQ=; b=nZ9hRaB0Sa4JfqqV+MZwbFhg1qbCIOS4RDZhsy/++tmdlEHcVT64zuUmiHfB1cROIF FOlpux+efcRJxt1JuD8zI7KYiJy94uytMT6mAJIWACAWdbD1RxlSTAyBogdKoHvUVCDO m0YhblGzogys/CBC3Hjw8162eHaIFeejI0IYM3KRejfh+etVb/FZYxRHvPtPrB4ntLU0 1Qj1bsxps5PhygzKG6DsWNM3mW6j1PeP9JcNfC1k1tsZs3v2sSf70ncuATgROE/FOi3E pI+5NOX7GnSubCQMGHEM02SNuIxlM+1fVIv1PzZqWFg0puHphKeoXkTXohPljrnwLAiu QjmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128792; x=1778733592; 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=aFqRmy2NnHUogWk2zuIaqAwu+8N7/skfs0tq/duJUVQ=; b=PwJsjOZAFq3M6l7nFMBwiF99if4IGEED5xS5KaQUvix9EEKB9IR+IMiyQ8zUFYJ6kb 0yYZEIVC1+B4xq5saaiyT46Inm5iPe30qO/DKbPIcUAdvHfxfkhCK/SvYzNQII+rCJEV RGfdkcEOJf2hw1dVC8nKsnM+piVCrOHECUNQ5Q7sQZqQFkAzdNR7FHyOqgciFe+taRQp t7tleHVSDRZrYn0tUR2UigcDBqddCzDvuXJ5Rt8s2jN+PCC0aokpPZcdUUOI+w04cCV6 kgyULOlGFCgYSIKnsYHjggWDLagLl8qhopZlAGwy243pdzWmmpbUOjBalzsB319btec5 wOBg== X-Forwarded-Encrypted: i=1; AFNElJ8LdnJ38QB41uPvncv+KMyZwXv0R+InM4iIMur9Rg3H5yzUUCK5/JthgOM3CuVQQxSFkgs7hrVAH9mw@nongnu.org X-Gm-Message-State: AOJu0YzdxHrrREAow5Sqlz+CVQFmybA6jtxbHmYGRuylh72SxuBe9oMI DQzELtZvLUoivZTsiw1wc5iUZnyPZrvKycU9vvUfn0eNQGYzbDh3xvFa X-Gm-Gg: AeBDieurKMhLHD903ILXCr1OSCBssQP1nLvnc+655tOjdtkYeeKtp/NcHmmc6xvCCpP e3Adu9QM1x7OPMlBeSC9spKonX2x3jzHFXU8Rvqa5UopcP48UTzXSyN8rrVE8/mjecUUQOwmw1/ TdO4q54Wb0zmQZB3+MqSDau/t+HipqeQIqL0b7Q9UvVy2PD0bBzS4SGWzBaaFytsx4funu/OnFD 9F/L2Wua7YbtPWTkNVuIotP7meswqGRnjzjYuSw0p2mcBhFeeFVoJ9BDATND9vcpmt3MBD5G/8/ E3J3dSWP9A8G7aMW1OXgK8OLG1uIACLDtJkvppLXBMyYOsUKWcVgcnz2FdaYUFbyMUArM4NAqHD TdGnSMFb/ixzaCmflc+TTneh+2T8Cu3A/Y/zTsqt58nYJgn0JfacRYEXQ7DL8+PzSe3Bq0U3Tvv +C4UIe4NnEw+9xP10BqI8cAS/oY5dYHTLwviqyBra166By3ZhvU281yTxR/01YpKPD3aRwFQiK7 zAsTxx1 X-Received: by 2002:a17:902:7447:b0:2ae:ba5f:3ac3 with SMTP id d9443c01a7336-2ba78b30c4dmr44598685ad.2.1778128791720; Wed, 06 May 2026 21:39:51 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v5 2/9] hw/riscv/boot: Account for discontiguous memory when loading firmware Date: Thu, 7 May 2026 14:38:30 +1000 Message-ID: <20260507043838.45652-3-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=npiggin@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128875513154100 Content-Type: text/plain; charset="utf-8" This loads firmware into the first (low) memory range, accounting for machines having discontiguous memory regions. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin --- hw/riscv/boot.c | 18 ++++++++++++------ hw/riscv/microchip_pfsoc.c | 8 ++++++-- hw/riscv/opentitan.c | 6 ++++-- hw/riscv/shakti_c.c | 6 +++++- hw/riscv/sifive_u.c | 6 ++++-- hw/riscv/spike.c | 6 ++++-- hw/riscv/virt.c | 7 ++++--- hw/riscv/xiangshan_kmh.c | 6 +++++- include/hw/riscv/boot.h | 5 ++++- 9 files changed, 48 insertions(+), 20 deletions(-) diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 6e0c6c2d17..2b1f11ea15 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -150,6 +150,7 @@ char *riscv_find_firmware(const char *firmware_filename, } =20 hwaddr riscv_find_and_load_firmware(MachineState *machine, + RISCVBootInfo *info, const char *default_machine_firmware, hwaddr *firmware_load_addr, symbol_fn_t sym_cb) @@ -162,7 +163,8 @@ hwaddr riscv_find_and_load_firmware(MachineState *machi= ne, =20 if (firmware_filename) { /* If not "none" load the firmware */ - firmware_end_addr =3D riscv_load_firmware(firmware_filename, + firmware_end_addr =3D riscv_load_firmware(machine, info, + firmware_filename, firmware_load_addr, sym_cb= ); g_free(firmware_filename); } @@ -170,10 +172,13 @@ hwaddr riscv_find_and_load_firmware(MachineState *mac= hine, return firmware_end_addr; } =20 -hwaddr riscv_load_firmware(const char *firmware_filename, +hwaddr riscv_load_firmware(MachineState *machine, + const RISCVBootInfo *info, + const char *firmware_filename, hwaddr *firmware_load_addr, symbol_fn_t sym_cb) { + uint64_t mem_size =3D info->ram_low_size ?: machine->ram_size; uint64_t firmware_entry, firmware_end; ssize_t firmware_size; =20 @@ -202,7 +207,7 @@ hwaddr riscv_load_firmware(const char *firmware_filenam= e, =20 firmware_size =3D load_image_targphys_as(firmware_filename, *firmware_load_addr, - current_machine->ram_size, NULL, + mem_size, NULL, NULL); =20 if (firmware_size > 0) { @@ -217,7 +222,7 @@ hwaddr riscv_load_firmware(const char *firmware_filenam= e, static void riscv_load_initrd(MachineState *machine, RISCVBootInfo *info) { const char *filename =3D machine->initrd_filename; - uint64_t mem_size =3D machine->ram_size; + uint64_t mem_size =3D info->ram_low_size ?: machine->ram_size; void *fdt =3D machine->fdt; hwaddr start, end; ssize_t size; @@ -263,6 +268,7 @@ void riscv_load_kernel(MachineState *machine, bool load_initrd, symbol_fn_t sym_cb) { + uint64_t mem_size =3D info->ram_low_size ?: machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; ssize_t kernel_size; void *fdt =3D machine->fdt; @@ -294,7 +300,7 @@ void riscv_load_kernel(MachineState *machine, } =20 kernel_size =3D load_image_targphys_as(kernel_filename, kernel_start_a= ddr, - current_machine->ram_size, NULL, = NULL); + mem_size, NULL, NULL); if (kernel_size > 0) { info->kernel_size =3D kernel_size; info->image_low_addr =3D kernel_start_addr; @@ -390,7 +396,7 @@ uint64_t riscv_compute_fdt_addr(hwaddr dram_base, hwadd= r dram_size, dtb_start =3D QEMU_ALIGN_DOWN(temp - fdtsize, 2 * MiB); =20 if (dtb_start_limit && (dtb_start < dtb_start_limit)) { - error_report("No enough memory to place DTB after kernel/initrd"); + error_report("Not enough memory to place DTB after kernel/initrd"); exit(1); } =20 diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index 743f31f005..60bb96da01 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -618,18 +618,22 @@ static void microchip_icicle_kit_machine_init(Machine= State *machine) firmware_load_addr =3D RESET_VECTOR; } =20 + riscv_boot_info_init_discontig_mem(&boot_info, &s->soc.u_cpus, + memmap[MICROCHIP_PFSOC_DRAM_LO].bas= e, + mem_low_size); + /* Load the firmware if necessary */ firmware_end_addr =3D firmware_load_addr; if (firmware_name) { char *filename =3D riscv_find_firmware(firmware_name, NULL); if (filename) { - firmware_end_addr =3D riscv_load_firmware(filename, + firmware_end_addr =3D riscv_load_firmware(machine, &boot_info, + filename, &firmware_load_addr, N= ULL); g_free(filename); } } =20 - riscv_boot_info_init(&boot_info, &s->soc.u_cpus); if (machine->kernel_filename) { kernel_start_addr =3D riscv_calc_kernel_start_addr(&boot_info, firmware_end_addr= ); diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 309125e854..8cd660dd41 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -99,12 +99,14 @@ static void opentitan_machine_init(MachineState *machin= e) memory_region_add_subregion(sys_mem, memmap[IBEX_DEV_RAM].base, machine->ram); =20 + riscv_boot_info_init(&boot_info, &s->soc.cpus); + if (machine->firmware) { hwaddr firmware_load_addr =3D memmap[IBEX_DEV_RAM].base; - riscv_load_firmware(machine->firmware, &firmware_load_addr, NULL); + riscv_load_firmware(machine, &boot_info, machine->firmware, + &firmware_load_addr, NULL); } =20 - riscv_boot_info_init(&boot_info, &s->soc.cpus); if (machine->kernel_filename) { riscv_load_kernel(machine, &boot_info, memmap[IBEX_DEV_RAM].base, diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c index 49a39b3021..eb720d9cdf 100644 --- a/hw/riscv/shakti_c.c +++ b/hw/riscv/shakti_c.c @@ -45,6 +45,7 @@ static void shakti_c_machine_state_init(MachineState *mst= ate) { ShaktiCMachineState *sms =3D RISCV_SHAKTI_MACHINE(mstate); MemoryRegion *system_memory =3D get_system_memory(); + RISCVBootInfo boot_info; hwaddr firmware_load_addr =3D shakti_c_memmap[SHAKTI_C_RAM].base; =20 /* Initialize SoC */ @@ -57,8 +58,11 @@ static void shakti_c_machine_state_init(MachineState *ms= tate) shakti_c_memmap[SHAKTI_C_RAM].base, mstate->ram); =20 + riscv_boot_info_init(&boot_info, &sms->soc.cpus); + if (mstate->firmware) { - riscv_load_firmware(mstate->firmware, &firmware_load_addr, NULL); + riscv_load_firmware(mstate, &boot_info, mstate->firmware, + &firmware_load_addr, NULL); } =20 /* ROM reset vector */ diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 7ec67b2565..dda8687bfd 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -589,11 +589,13 @@ static void sifive_u_machine_init(MachineState *machi= ne) break; } =20 + riscv_boot_info_init(&boot_info, &s->soc.u_cpus); + firmware_name =3D riscv_default_firmware_name(&s->soc.u_cpus); - firmware_end_addr =3D riscv_find_and_load_firmware(machine, firmware_n= ame, + firmware_end_addr =3D riscv_find_and_load_firmware(machine, &boot_info, + firmware_name, &start_addr, NULL); =20 - riscv_boot_info_init(&boot_info, &s->soc.u_cpus); if (machine->kernel_filename) { kernel_start_addr =3D riscv_calc_kernel_start_addr(&boot_info, firmware_end_addr= ); diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 35c696f891..6ee915a8ba 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -281,9 +281,12 @@ static void spike_board_init(MachineState *machine) } } =20 + riscv_boot_info_init(&boot_info, &s->soc[0]); + /* Load firmware */ if (firmware_name) { - firmware_end_addr =3D riscv_load_firmware(firmware_name, + firmware_end_addr =3D riscv_load_firmware(machine, &boot_info, + firmware_name, &firmware_load_addr, htif_symbol_callback); g_free(firmware_name); @@ -293,7 +296,6 @@ static void spike_board_init(MachineState *machine) create_fdt(s, memmap, riscv_is_32bit(&s->soc[0]), htif_custom_base); =20 /* Load kernel */ - riscv_boot_info_init(&boot_info, &s->soc[0]); if (machine->kernel_filename) { kernel_start_addr =3D riscv_calc_kernel_start_addr(&boot_info, firmware_end_addr= ); diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a1c323e66d..4501d5581b 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1457,7 +1457,10 @@ static void virt_machine_done(Notifier *notifier, vo= id *data) } } =20 - firmware_end_addr =3D riscv_find_and_load_firmware(machine, firmware_n= ame, + riscv_boot_info_init(&boot_info, &s->soc[0]); + + firmware_end_addr =3D riscv_find_and_load_firmware(machine, &boot_info, + firmware_name, &start_addr, NULL); =20 pflash_blk0 =3D pflash_cfi01_get_blk(s->flash[0]); @@ -1480,8 +1483,6 @@ static void virt_machine_done(Notifier *notifier, voi= d *data) } } =20 - riscv_boot_info_init(&boot_info, &s->soc[0]); - if (machine->kernel_filename && !kernel_entry) { kernel_start_addr =3D riscv_calc_kernel_start_addr(&boot_info, firmware_end_addr= ); diff --git a/hw/riscv/xiangshan_kmh.c b/hw/riscv/xiangshan_kmh.c index 436e51c1c5..247a0b5d1f 100644 --- a/hw/riscv/xiangshan_kmh.c +++ b/hw/riscv/xiangshan_kmh.c @@ -166,6 +166,7 @@ static void xiangshan_kmh_machine_init(MachineState *ma= chine) const MemMapEntry *memmap =3D xiangshan_kmh_memmap; MemoryRegion *system_memory =3D get_system_memory(); hwaddr start_addr =3D memmap[XIANGSHAN_KMH_DRAM].base; + RISCVBootInfo boot_info; =20 /* Initialize SoC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, @@ -177,13 +178,16 @@ static void xiangshan_kmh_machine_init(MachineState *= machine) memmap[XIANGSHAN_KMH_DRAM].base, machine->ram); =20 + riscv_boot_info_init(&boot_info, &s->soc.cpus); + /* ROM reset vector */ riscv_setup_rom_reset_vec(machine, &s->soc.cpus, start_addr, memmap[XIANGSHAN_KMH_ROM].base, memmap[XIANGSHAN_KMH_ROM].size, 0, 0); if (machine->firmware) { - riscv_load_firmware(machine->firmware, &start_addr, NULL); + riscv_load_firmware(machine, &boot_info, machine->firmware, + &start_addr, NULL); } =20 /* Note: dtb has been integrated into firmware(OpenSBI) when compiling= */ diff --git a/include/hw/riscv/boot.h b/include/hw/riscv/boot.h index 69c99a1496..4e7bd9a225 100644 --- a/include/hw/riscv/boot.h +++ b/include/hw/riscv/boot.h @@ -53,13 +53,16 @@ void riscv_boot_info_init_discontig_mem(RISCVBootInfo *= info, vaddr riscv_calc_kernel_start_addr(RISCVBootInfo *info, hwaddr firmware_end_addr); hwaddr riscv_find_and_load_firmware(MachineState *machine, + RISCVBootInfo *info, const char *default_machine_firmware, hwaddr *firmware_load_addr, symbol_fn_t sym_cb); const char *riscv_default_firmware_name(RISCVHartArrayState *harts); char *riscv_find_firmware(const char *firmware_filename, const char *default_machine_firmware); -hwaddr riscv_load_firmware(const char *firmware_filename, +hwaddr riscv_load_firmware(MachineState *machine, + const RISCVBootInfo *info, + const char *firmware_filename, hwaddr *firmware_load_addr, symbol_fn_t sym_cb); void riscv_load_kernel(MachineState *machine, --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128902; cv=none; d=zohomail.com; s=zohoarc; b=Lc++DD0bLz2Cgf5yh4kMM7VEZxbjmjy0/USKPkjB8WIgj91B6uv2OU6REAycwSUjqsqvaq+AMYxlNAwZyjyOq0b+VZgDtcUObaxEsc70b/KtS5Ae+EfTgORtnQod4BRZnxaSCSeT18M2mx4csE0z0LM5SIVznUHJkTMObtE4POY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128902; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OcAtlEZ69UD1ecjEQMV6rCsQw+NL0cPCttHRoeHGkic=; b=UDpGDtWH3yw0NLJ+XXwSzqdNdwQipw0LdQ0CGcA0uzHrvafFsWAdeHbYFdaygVXxjeFkiVw6FiG9Ydpj3BEYLN+Nub/QF7nrEsaIESAooL1SPOxJx0k2T6KXomHfQvdvX8KXplXOWaDS5jI7cY9RUWHr+SdFpRml1kyx/lszDhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128902830234.61574630613245; Wed, 6 May 2026 21:41:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqWn-0000RT-QG; Thu, 07 May 2026 00:40:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWm-0000RC-3F for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:00 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWj-0003tH-RH for qemu-devel@nongnu.org; Thu, 07 May 2026 00:39:59 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-c7980c060cfso136441a12.2 for ; Wed, 06 May 2026 21:39:57 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c8253582a6bsm742181a12.5.2026.05.06.21.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128796; x=1778733596; darn=nongnu.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=OcAtlEZ69UD1ecjEQMV6rCsQw+NL0cPCttHRoeHGkic=; b=GIsfzM7bzhbDqKY4C/MjhCcyNRodRcl6ddDPg2t7h6kG3MPVA6MhlDCw2wsFZGHFze 5tgWfYwQ5TAkazG4NLj2IEU4K3oIO4oOv3ludJ5ZwF9gIwTmep3N7EnWPNPfIQmMvru7 5giaXbhp2ELm4DKAdft754bcDheqLBDLISk0O3a7Rf7qlLeUVUQJRSd735ZLMOE6WQEZ E7k58ocDRIuDQCiq81uFRU34429BUN2G0KOwcR9Vb83fF5/TEDSXw7bjSdhzl+K+yF+z BLX/Dm+IncucL2LnRvgi8v3MFbljOhHqFHHSN2aieS7x+cXUd54IF3LcmmiLb73dlhDb O05w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128796; x=1778733596; 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=OcAtlEZ69UD1ecjEQMV6rCsQw+NL0cPCttHRoeHGkic=; b=nkewfWHU3+sY+esIqBxHjISiN//evWsqGP3ydlYKrgKtG4Ax+rd2u+LFga1S6narf+ abM29N7JvowL4P/qqDFbx+2rWfEfPrnmbdj058NnaBzexCaX2ALsQaf/YGnPUx3tqsVj zp+AtoqPXhc5mKXBWFZkjBdqOF1fPe933Z0Uc0XAwPC+vlkioAIPjVlihcP0uilCiPBY MXSrF0omUdM16cQr9FHepf+9TFfsJLJczGJ0fP/hg2huW4990ikvSpzbm8JgD136+NBk p6ZeZ9lQTqDbWn2f05bhNKv699arMUqGpi1z2YLxSZHEk1QkND4yOXYwcdWUIajjbpt+ JibQ== X-Forwarded-Encrypted: i=1; AFNElJ9Hju9bwnlmNHdiv7RbQ/S3BokOWu2h8keY82M/opD7TLRd2cJlUng0wSpCcKsWPG2WCJYunNzoFZ4B@nongnu.org X-Gm-Message-State: AOJu0YyHZPqcZDExJctx1/b+7vlh8aiTjMygrbqSB+gvfp/KtLBNCl5+ sDEs5DCiBsD9jPCCDUyuZnKcc6pHapK0QvOlGmHWtl1EIhvtjqLACyFn X-Gm-Gg: AeBDieu1/V9IoGgCnSSHzm0olWWAcCxrhhsh8Y55zkyUE7bDrpT4Ak324brw24V93kM sv2yKLSHAptjFrhmjaebcwiYmiK4suOFdVRKfK8kfwqIfp1TKrKc7+NPPbZWZTZBFPosppeTHY9 b+36/6MMDCsVJn87jJq51vgS4875EeGPSdwYLiWCRKmmK0i7KVyvKjrd1U3UnSsFC+dEICXcoqO Nmp1eOtkPmXIm5lIhb2LShNhcfCO5nfPGIMKkszYS7cuLsg9GsmgxB/Jx8U6TBUJSdClwS8elYy 7bgV/UQbTowi0Qws1uvIQfhqYFToqF8DwYa9LfiDPG816Kgbx5rDYlN2JveNB70aHm5tqVyoZcv SXyI1zNMnan8PUh36G2vt6yK8LFsib8OD9KHiGiX0L9+Nwe3uoYJq/ig/TcWxb0f1DLidNsGXNa fpZ/nPJNrGE4PAZz69+pX0uljLZm9932itBL6KvDnuKhW+SDn74KpEvE8xWMhhyX/8rcwc1gQTa QwvnrifscVTD0ENQDM= X-Received: by 2002:a05:6a20:94ca:b0:3a2:f14a:4277 with SMTP id adf61e73a8af0-3aa5aac8801mr6731774637.32.1778128796337; Wed, 06 May 2026 21:39:56 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley , Nutty Liu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 3/9] hw/riscv/virt: Move AIA initialisation to helper file Date: Thu, 7 May 2026 14:38:31 +1000 Message-ID: <20260507043838.45652-4-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=npiggin@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128903863154100 From: Joel Stanley The AIA init will be used by any server class riscv machine. Separate it out in order to share code with such systems. The virt machine keeps machine specific #defines such as VIRT_IRQCHIP_NUM_MSIS, VIRT_IRQCHIP_NUM_PRIO_BITS. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Nutty Liu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin --- hw/riscv/aia.c | 89 ++++++++++++++++++++++++++++++++++++++ hw/riscv/aia.h | 26 +++++++++++ hw/riscv/meson.build | 2 +- hw/riscv/virt-acpi-build.c | 2 + hw/riscv/virt.c | 87 +++++-------------------------------- include/hw/riscv/virt.h | 1 - 6 files changed, 129 insertions(+), 78 deletions(-) create mode 100644 hw/riscv/aia.c create mode 100644 hw/riscv/aia.h diff --git a/hw/riscv/aia.c b/hw/riscv/aia.c new file mode 100644 index 0000000000..c724612a50 --- /dev/null +++ b/hw/riscv/aia.c @@ -0,0 +1,89 @@ +/* + * QEMU RISC-V Advanced Interrupt Architecture (AIA) + * + * Copyright (C) 2019 Western Digital Corporation or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "system/kvm.h" +#include "hw/intc/riscv_aplic.h" +#include "hw/intc/riscv_imsic.h" + +#include "aia.h" + +uint32_t imsic_num_bits(uint32_t count) +{ + uint32_t ret =3D 0; + + while (BIT(ret) < count) { + ret++; + } + + return ret; +} + +DeviceState *riscv_create_aia(bool msimode, int aia_guests, + const MemMapEntry *aplic_m, + const MemMapEntry *aplic_s, + const MemMapEntry *imsic_m, + const MemMapEntry *imsic_s, + int socket, int base_hartid, int hart_count, + uint32_t num_msis, uint32_t num_prio_bits) +{ + int i; + hwaddr addr =3D 0; + uint32_t guest_bits; + DeviceState *aplic_s_dev =3D NULL; + DeviceState *aplic_m_dev =3D NULL; + + if (msimode) { + if (!kvm_enabled()) { + /* Per-socket M-level IMSICs */ + addr =3D imsic_m->base + socket * (1U << IMSIC_MMIO_GROUP_MIN_= SHIFT); + for (i =3D 0; i < hart_count; i++) { + riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0), + base_hartid + i, true, 1, + num_msis); + } + } + + /* Per-socket S-level IMSICs */ + guest_bits =3D imsic_num_bits(aia_guests + 1); + addr =3D imsic_s->base + socket * (1U << IMSIC_MMIO_GROUP_MIN_SHIF= T); + for (i =3D 0; i < hart_count; i++) { + riscv_imsic_create(addr + i * IMSIC_HART_SIZE(guest_bits), + base_hartid + i, false, 1 + aia_guests, + num_msis); + } + } + + if (!kvm_enabled()) { + /* Per-socket M-level APLIC */ + aplic_m_dev =3D riscv_aplic_create(aplic_m->base + + socket * aplic_m->size, + aplic_m->size, + (msimode) ? 0 : base_hartid, + (msimode) ? 0 : hart_count, + VIRT_IRQCHIP_NUM_SOURCES, + num_prio_bits, + msimode, true, NULL); + } + + /* Per-socket S-level APLIC */ + aplic_s_dev =3D riscv_aplic_create(aplic_s->base + + socket * aplic_s->size, + aplic_s->size, + (msimode) ? 0 : base_hartid, + (msimode) ? 0 : hart_count, + VIRT_IRQCHIP_NUM_SOURCES, + num_prio_bits, + msimode, false, aplic_m_dev); + + if (kvm_enabled() && msimode) { + riscv_aplic_set_kvm_msicfgaddr(RISCV_APLIC(aplic_s_dev), addr); + } + + return kvm_enabled() ? aplic_s_dev : aplic_m_dev; +} diff --git a/hw/riscv/aia.h b/hw/riscv/aia.h new file mode 100644 index 0000000000..dbb8333402 --- /dev/null +++ b/hw/riscv/aia.h @@ -0,0 +1,26 @@ +/* + * QEMU RISC-V Advanced Interrupt Architecture (AIA) + * + * Copyright (C) 2019 Western Digital Corporation or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HW_RISCV_AIA_H +#define HW_RISCV_AIA_H + +#include "exec/hwaddr.h" + +#define VIRT_IRQCHIP_NUM_SOURCES 96 + +uint32_t imsic_num_bits(uint32_t count); + +DeviceState *riscv_create_aia(bool msimode, int aia_guests, + const MemMapEntry *aplic_m, + const MemMapEntry *aplic_s, + const MemMapEntry *imsic_m, + const MemMapEntry *imsic_s, + int socket, int base_hartid, int hart_count, + uint32_t num_msis, uint32_t num_prio_bits); + +#endif diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build index 533472e22a..e53c180d0d 100644 --- a/hw/riscv/meson.build +++ b/hw/riscv/meson.build @@ -1,5 +1,5 @@ riscv_ss =3D ss.source_set() -riscv_ss.add(files('boot.c')) +riscv_ss.add(files('boot.c', 'aia.c')) riscv_ss.add(when: 'CONFIG_RISCV_NUMA', if_true: files('numa.c')) riscv_ss.add(files('riscv_hart.c')) riscv_ss.add(when: 'CONFIG_OPENTITAN', if_true: files('opentitan.c')) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index fd6ca5dbc4..145f8d92ad 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -42,6 +42,8 @@ #include "system/kvm.h" #include "system/reset.h" =20 +#include "aia.h" + #define ACPI_BUILD_TABLE_SIZE 0x20000 #define ACPI_BUILD_INTC_ID(socket, index) ((socket << 24) | (index)) =20 diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 4501d5581b..ce0fd6f50c 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -59,6 +59,8 @@ #include "hw/virtio/virtio-iommu.h" #include "hw/uefi/var-service-api.h" =20 +#include "aia.h" + /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU= . */ static bool virt_use_kvm_aia_aplic_imsic(RISCVVirtAIAType aia_type) { @@ -509,17 +511,6 @@ static void create_fdt_socket_plic(RISCVVirtState *s, } } =20 -uint32_t imsic_num_bits(uint32_t count) -{ - uint32_t ret =3D 0; - - while (BIT(ret) < count) { - ret++; - } - - return ret; -} - static void create_fdt_one_imsic(RISCVVirtState *s, hwaddr base_addr, uint32_t *intc_phandles, uint32_t msi_pha= ndle, bool m_mode, uint32_t imsic_guest_bits) @@ -1293,68 +1284,6 @@ static DeviceState *virt_create_plic(const MemMapEnt= ry *memmap, int socket, memmap[VIRT_PLIC].size); } =20 -static DeviceState *virt_create_aia(RISCVVirtAIAType aia_type, int aia_gue= sts, - const MemMapEntry *memmap, int socket, - int base_hartid, int hart_count) -{ - int i; - hwaddr addr =3D 0; - uint32_t guest_bits; - DeviceState *aplic_s =3D NULL; - DeviceState *aplic_m =3D NULL; - bool msimode =3D aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC; - - if (msimode) { - if (!kvm_enabled()) { - /* Per-socket M-level IMSICs */ - addr =3D memmap[VIRT_IMSIC_M].base + - socket * VIRT_IMSIC_GROUP_MAX_SIZE; - for (i =3D 0; i < hart_count; i++) { - riscv_imsic_create(addr + i * IMSIC_HART_SIZE(0), - base_hartid + i, true, 1, - VIRT_IRQCHIP_NUM_MSIS); - } - } - - /* Per-socket S-level IMSICs */ - guest_bits =3D imsic_num_bits(aia_guests + 1); - addr =3D memmap[VIRT_IMSIC_S].base + socket * VIRT_IMSIC_GROUP_MAX= _SIZE; - for (i =3D 0; i < hart_count; i++) { - riscv_imsic_create(addr + i * IMSIC_HART_SIZE(guest_bits), - base_hartid + i, false, 1 + aia_guests, - VIRT_IRQCHIP_NUM_MSIS); - } - } - - if (!kvm_enabled()) { - /* Per-socket M-level APLIC */ - aplic_m =3D riscv_aplic_create(memmap[VIRT_APLIC_M].base + - socket * memmap[VIRT_APLIC_M].size, - memmap[VIRT_APLIC_M].size, - (msimode) ? 0 : base_hartid, - (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, - VIRT_IRQCHIP_NUM_PRIO_BITS, - msimode, true, NULL); - } - - /* Per-socket S-level APLIC */ - aplic_s =3D riscv_aplic_create(memmap[VIRT_APLIC_S].base + - socket * memmap[VIRT_APLIC_S].size, - memmap[VIRT_APLIC_S].size, - (msimode) ? 0 : base_hartid, - (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, - VIRT_IRQCHIP_NUM_PRIO_BITS, - msimode, false, aplic_m); - - if (kvm_enabled() && msimode) { - riscv_aplic_set_kvm_msicfgaddr(RISCV_APLIC(aplic_s), addr); - } - - return kvm_enabled() ? aplic_s : aplic_m; -} - static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip) { DeviceState *dev; @@ -1617,9 +1546,15 @@ static void virt_machine_init(MachineState *machine) s->irqchip[i] =3D virt_create_plic(s->memmap, i, base_hartid, hart_count); } else { - s->irqchip[i] =3D virt_create_aia(s->aia_type, s->aia_guests, - s->memmap, i, base_hartid, - hart_count); + s->irqchip[i] =3D riscv_create_aia(s->aia_type =3D=3D VIRT_AIA= _TYPE_APLIC_IMSIC, + s->aia_guests, + &s->memmap[VIRT_APLIC_M], + &s->memmap[VIRT_APLIC_S], + &s->memmap[VIRT_IMSIC_M], + &s->memmap[VIRT_IMSIC_S], + i, base_hartid, hart_count, + VIRT_IRQCHIP_NUM_MSIS, + VIRT_IRQCHIP_NUM_PRIO_BITS); } =20 /* Try to use different IRQCHIP instance based device type */ diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 18a2a323a3..ad858deb76 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -135,7 +135,6 @@ enum { bool virt_is_acpi_enabled(RISCVVirtState *s); bool virt_is_iommu_sys_enabled(RISCVVirtState *s); void virt_acpi_setup(RISCVVirtState *vms); -uint32_t imsic_num_bits(uint32_t count); =20 /* * The virt machine physical address space used by some of the devices --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128859; cv=none; d=zohomail.com; s=zohoarc; b=gv48JquuC13jwle42MbXo6ycJftt9wQUZUzWVd3y15xfVQQaOUBs2MirvFX8E111ZdrgDoer38XZqLR2bjdNmm8gDUhAgdwzl74nY1lEShYDpfIoNo1oeg2/TpvqBa7gIdWXP/pUdJj5he+PiiHiyWw7P/f4ILlO77yMQkh++Ro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128859; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=13lu9MkgMDO/GCkyMxzJaolOgnQJRxha13QXdWrCjBw=; b=PpjqtZyPgsQ/Je8XH6f+tRuZVG1aHOBX09Ev/79VXUB3mj6c6imEQ2Rn5PT3F3hIrNU3VJt3zyQ+atwCDUe7UXODMevTYkGyM92ROXypuQ/O1djL7Cz18B7e2LbQqmoas4iJ2KmlHUPDO3+wlwVfP3YLiiCGmw6RZ222erRrRXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128859727142.31818847649004; Wed, 6 May 2026 21:40:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqWs-0000ZJ-M3; Thu, 07 May 2026 00:40:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWq-0000UV-Ml for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:04 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWo-0003tu-Jy for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:04 -0400 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2ba0fc8b1f0so2605695ad.3 for ; Wed, 06 May 2026 21:40:02 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babadef254sm9006215ad.61.2026.05.06.21.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128801; x=1778733601; darn=nongnu.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=13lu9MkgMDO/GCkyMxzJaolOgnQJRxha13QXdWrCjBw=; b=CXXcit8qUDgaAnyTvbut5ekvJCLCMK9mIjEQSAMmtKj1EiVFH5j2Lz1U9rg1eAwrmG 6aYWcuhxUb6lCwY/dzfPeQeZiUuN0xPI4nW16XlAlRFQty2Kc00xQg1cie5QjMPpoamB Wn14/GnnIe52r/u8Kl6bj6ZKpZF1OAqJaspWoYyXkhgbpKnymASH4gOuNn05ikZrT1K/ DclacsnOp8k1Ibh5SxPg0hAtdw/6ZI42xVaNBhkuNGPuvzrrgsrCwVxCof92vF9C0P2V 0J6ZnmBuQe/fqiHHeDWKOBDgd2mRz02rTMXMKaBLa7poTfjtwy6xuctiaWfP0JHAqIxz 5dDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128801; x=1778733601; 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=13lu9MkgMDO/GCkyMxzJaolOgnQJRxha13QXdWrCjBw=; b=hjjGVtmpIrqpu35lP5nZDZY+N+3EV0PEwDjZSZAqdeREi3Rud/H+rWuc0/JymIHJzq eKauJd/3vQMS82v+cY+7oTEkGM/iwWjQSOnsIgozCes8CNLimnGVKIRP1nAkmW9c7lvX 0Cvpyy0DbM0UcvuJ1G16Peubn7u0+JohXDzjXfZoqik0+ZTxJ+/XzsY6s2yzS/CULp2g b/H2YOkUq0KFl0THlAbFVzPCW4SuVUN6/Qa97OTFzjwvZ1Ll7MaBPGjc6Pa6ueoVuFRf oqVsUKwVNjVPFn6kWWX50x9W1VOcbij/sgKXNO4tcgr45by75zYL8XfvkvMhu3Jp3510 OiFw== X-Forwarded-Encrypted: i=1; AFNElJ9Te4RHAv4jLPgC4NrEUoh9bK854KYZJNV2Wx7UHcYuJ2EheOUjzkFL9pegN3zBHj2esAihsY0otr5D@nongnu.org X-Gm-Message-State: AOJu0YztEL/FcPh23FUZfVwGE9rIMH4B6AZZFCmfag7KV5z01vJGbEoL Bpj6QintTCIY3+mVXMKS8BOCQiov2eueQIJ6sUg9tmVetABQ/29Iq/Lw X-Gm-Gg: AeBDieu6X37SRivTq21M62ylfQkHZ13hup5POg3ZglwzRxnCJXSFXmatwWFZrDW2D9c ASB8RBMBdsvfElBaYM0QS+jjYngOM60p58FUgP1+mJGOgI41xq08XkvlB5q7oLoZQVx/Fuax4oq Dmg39mmRraTctC8XOKn9/cedTpWxp8MkM2V+oKyxkHScpuU0uvTBBchBPo0BKAkXbOY0OGtTbtn AVI8fERNzV8L34YyFd2yqxOS61d29afyn8E59q1sL0l8HT4q4wOfIqXo0o5bTLGCzsRcfdxCPJu 9Ml5KwhIKNJ+bm7dqBVgoycRva/KbsanUhR3EYr76fbpnjmI994odiBPQeviqbyQ6I8b+lA/yTN +VxdXaVTR7lGL54OoQ+OnaL2uhyheXPmZYZiH2toSkRh56E6G/lXVm40QLlaNwf6Wk2vkEt85s5 gwmvDs0yFnxtXG76d10/pc89/CYV7a4HVv/GOibdhYRMv5zgrx4VJJSiAKrYaE1wLQb3eFhqQLJ kj7c21x X-Received: by 2002:a17:903:1a2c:b0:2b4:6470:760d with SMTP id d9443c01a7336-2ba78f473a2mr71631285ad.14.1778128800909; Wed, 06 May 2026 21:40:00 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley , Nutty Liu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 4/9] hw/riscv/aia: Provide number of irq sources Date: Thu, 7 May 2026 14:38:32 +1000 Message-ID: <20260507043838.45652-5-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128861467158500 From: Joel Stanley Instead of hard coding the number of IRQ sources used by the APLIC pass it in as a parameter. This allows other machines to configure this as required. The maximum number of sources is 1023. Reviewed-by: Nutty Liu Reviewed-by: Daniel Henrique Barboza Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin --- hw/riscv/aia.c | 8 ++++++-- hw/riscv/aia.h | 3 +-- hw/riscv/virt-acpi-build.c | 25 ++++++++++++++++--------- hw/riscv/virt.c | 2 ++ include/hw/riscv/virt.h | 1 + 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/hw/riscv/aia.c b/hw/riscv/aia.c index c724612a50..82ea9d48ea 100644 --- a/hw/riscv/aia.c +++ b/hw/riscv/aia.c @@ -25,6 +25,7 @@ uint32_t imsic_num_bits(uint32_t count) } =20 DeviceState *riscv_create_aia(bool msimode, int aia_guests, + uint16_t num_sources, const MemMapEntry *aplic_m, const MemMapEntry *aplic_s, const MemMapEntry *imsic_m, @@ -38,6 +39,9 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guest= s, DeviceState *aplic_s_dev =3D NULL; DeviceState *aplic_m_dev =3D NULL; =20 + /* The RISC-V Advanced Interrupt Architecture, Chapter 1.2. Limits */ + g_assert(num_sources <=3D 1023); + if (msimode) { if (!kvm_enabled()) { /* Per-socket M-level IMSICs */ @@ -66,7 +70,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guest= s, aplic_m->size, (msimode) ? 0 : base_hartid, (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, + num_sources, num_prio_bits, msimode, true, NULL); } @@ -77,7 +81,7 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guest= s, aplic_s->size, (msimode) ? 0 : base_hartid, (msimode) ? 0 : hart_count, - VIRT_IRQCHIP_NUM_SOURCES, + num_sources, num_prio_bits, msimode, false, aplic_m_dev); =20 diff --git a/hw/riscv/aia.h b/hw/riscv/aia.h index dbb8333402..5ad0a902be 100644 --- a/hw/riscv/aia.h +++ b/hw/riscv/aia.h @@ -11,11 +11,10 @@ =20 #include "exec/hwaddr.h" =20 -#define VIRT_IRQCHIP_NUM_SOURCES 96 - uint32_t imsic_num_bits(uint32_t count); =20 DeviceState *riscv_create_aia(bool msimode, int aia_guests, + uint16_t num_sources, const MemMapEntry *aplic_m, const MemMapEntry *aplic_s, const MemMapEntry *imsic_m, diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 145f8d92ad..9ef3ef842a 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -146,6 +146,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtSta= te *s) } =20 static void acpi_dsdt_add_plic_aplic(Aml *scope, uint8_t socket_count, + uint16_t num_sources, uint64_t mmio_base, uint64_t mmio_siz= e, const char *hid) { @@ -153,9 +154,12 @@ static void acpi_dsdt_add_plic_aplic(Aml *scope, uint8= _t socket_count, uint32_t gsi_base; uint8_t socket; =20 + /* The RISC-V Advanced Interrupt Architecture, Chapter 1.2. Limits */ + g_assert(num_sources <=3D 1023); + for (socket =3D 0; socket < socket_count; socket++) { plic_aplic_addr =3D mmio_base + mmio_size * socket; - gsi_base =3D VIRT_IRQCHIP_NUM_SOURCES * socket; + gsi_base =3D num_sources * socket; Aml *dev =3D aml_device("IC%.02X", socket); aml_append(dev, aml_name_decl("_HID", aml_string("%s", hid))); aml_append(dev, aml_name_decl("_UID", aml_int(socket))); @@ -474,10 +478,13 @@ static void build_dsdt(GArray *table_data, socket_count =3D riscv_socket_count(ms); =20 if (s->aia_type =3D=3D VIRT_AIA_TYPE_NONE) { - acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_PLIC].ba= se, - memmap[VIRT_PLIC].size, "RSCV0001"); + acpi_dsdt_add_plic_aplic(scope, socket_count, s->num_sources, + memmap[VIRT_PLIC].base, + memmap[VIRT_PLIC].size, + "RSCV0001"); } else { - acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_APLIC_S]= .base, + acpi_dsdt_add_plic_aplic(scope, socket_count, s->num_sources, + memmap[VIRT_APLIC_S].base, memmap[VIRT_APLIC_S].size, "RSCV0002"); } =20 @@ -494,15 +501,15 @@ static void build_dsdt(GArray *table_data, } else if (socket_count =3D=3D 2) { virtio_acpi_dsdt_add(scope, memmap[VIRT_VIRTIO].base, memmap[VIRT_VIRTIO].size, - VIRTIO_IRQ + VIRT_IRQCHIP_NUM_SOURCES, 0, + VIRTIO_IRQ + s->num_sources, 0, VIRTIO_COUNT); - acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + VIRT_IRQCHIP_NUM_SOURCES= ); + acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + s->num_sources); } else { virtio_acpi_dsdt_add(scope, memmap[VIRT_VIRTIO].base, memmap[VIRT_VIRTIO].size, - VIRTIO_IRQ + VIRT_IRQCHIP_NUM_SOURCES, 0, + VIRTIO_IRQ + s->num_sources, 0, VIRTIO_COUNT); - acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + VIRT_IRQCHIP_NUM_SOURCES= * 2); + acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + s->num_sources * 2); } =20 aml_append(dsdt, scope); @@ -581,7 +588,7 @@ static void build_madt(GArray *table_data, for (socket =3D 0; socket < riscv_socket_count(ms); socket++) { aplic_addr =3D s->memmap[VIRT_APLIC_S].base + s->memmap[VIRT_APLIC_S].size * socket; - gsi_base =3D VIRT_IRQCHIP_NUM_SOURCES * socket; + gsi_base =3D s->num_sources * socket; build_append_int_noprefix(table_data, 0x1A, 1); /* Type */ build_append_int_noprefix(table_data, 36, 1); /* Length */ build_append_int_noprefix(table_data, 1, 1); /* Version = */ diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index ce0fd6f50c..6c5bcd43dc 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1548,6 +1548,7 @@ static void virt_machine_init(MachineState *machine) } else { s->irqchip[i] =3D riscv_create_aia(s->aia_type =3D=3D VIRT_AIA= _TYPE_APLIC_IMSIC, s->aia_guests, + s->num_sources, &s->memmap[VIRT_APLIC_M], &s->memmap[VIRT_APLIC_S], &s->memmap[VIRT_IMSIC_M], @@ -1691,6 +1692,7 @@ static void virt_machine_instance_init(Object *obj) s->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); s->acpi =3D ON_OFF_AUTO_AUTO; s->iommu_sys =3D ON_OFF_AUTO_AUTO; + s->num_sources =3D VIRT_IRQCHIP_NUM_SOURCES; } =20 static char *virt_get_aia_guests(Object *obj, Error **errp) diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index ad858deb76..36a2def410 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -64,6 +64,7 @@ struct RISCVVirtState { struct GPEXHost *gpex_host; OnOffAuto iommu_sys; uint16_t pci_iommu_bdf; + uint16_t num_sources; }; =20 enum { --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128884; cv=none; d=zohomail.com; s=zohoarc; b=FRR9bjTuVltgz0h0WOE0QiZ0QD18z05KGYeYyoRwF/Hzx/p61NLhNunhvKqCZRsWXJnw+NnNd6hoPwkC0bGIcqykm3CKJz3WSz8RypUij8y99sWSdU8mYkVrAKwBab3tyD2Ix4KWNLItunySnyC25xIgQeE1EW/kdQ5RRO7PZV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128884; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bHeLtodOnv6pG12WXEAqX2AcLxs6QHtw3TrspFKRS0A=; b=GmSSa8tJc0yaNRUnIX//Mo/YlsARpAc3IaLtFc8Q9xSRJYpLAM9pXWHsjtZPl+zrlgnU66xhUYcq0gdXNxz8eZhyYmmcgOnZFflIxFmg1Q8lhrctntynE/XOQ9d/WO17Mb3R0+j9uyFrtWVpoecTOcCknot2XK6GmYgDPzUfF8s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128884845663.5348166702455; Wed, 6 May 2026 21:41:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqWw-0000cY-3f; Thu, 07 May 2026 00:40:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWu-0000b8-GN for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:08 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWt-00046C-4y for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:08 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2ba17c8cfacso5056155ad.2 for ; Wed, 06 May 2026 21:40:06 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babaac3111sm9291785ad.12.2026.05.06.21.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128806; x=1778733606; darn=nongnu.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=bHeLtodOnv6pG12WXEAqX2AcLxs6QHtw3TrspFKRS0A=; b=sswKK3vYQMkU8qiNW/Hwnu0OvhbvLvbk6FskfMOyIb5SPnvylc29wKt+j2/SDECBsz t/hM6Bp47egw9uoekvYASvyWoR/Or5gJ4oqf2glUQcuZisajU/svoou+0LY9HJTxzXTy pOUfN3q+hnnOTXLAWE29KuqotaMaq8gELKlxYhRa3F4LgWdwSVlsq+gQ0pn8PgQabURV GuLLLB0HOxiJGF7sDxFEW3qfxpsxOH4DWRl4Q7sznlCtJK1lniwL+dPNpy4PhEx9ReeA Chqj8GVec9zVVtc99cKrnK2yUcXJ4DKPKBNChtEv64icnOFCBXgIGKMYmmvn9nSfvnIh bC2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128806; x=1778733606; 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=bHeLtodOnv6pG12WXEAqX2AcLxs6QHtw3TrspFKRS0A=; b=HQVmoUfr8FBVED7yeXa78BJ/G/YLHyy7MEKV47r4Tqz69yfamEjT2YMg60CWXQj9cj J75489BsApWR6uJA7G7HctWC2JjMO8XFoQkduTZ2tndyNxm//x2AtY2/Z3RJ4t3MDxUd /MRIbFjUfXIdjwvW0tuWUdRGv3rRD3fk1TP8aTcv43AVEDhtrqxF0nDWfWOpdjg917Ug 8YOkTTSTstsK0I+lSfnvwWFObebb2aIl667Q20kC/jcYhden1whay4hAj1l9iGSxdAn6 POoH+pp1KU6uYcHsNpjo0S2ZeZYmxOhX122nTkvBO3ia6dm71at2GBkbJnVgRhuPQhI+ 42pg== X-Forwarded-Encrypted: i=1; AFNElJ/dL3vvL1u85AYO8dmUE5AHVumjAJt2f0IZpZ+kuqilgMZZazdJ4s6bsNDzCGuXbG3GvlYo8luMfCVD@nongnu.org X-Gm-Message-State: AOJu0YzmXXMSTX6+VVHh24DvRsca0thJj77pzY0suQVgh1OBYuzR0+/g D2aQRk2YyGJi/8gcoZz/7DFPE7hWaUEeCHQ5/yt5VYZQnM70oLgToTGP X-Gm-Gg: AeBDieviHTTBOeCF2T98RDwUDmOQu2hQolVaBuZWf9w6rVsp1nsp97dXpcNZdm0W0Y+ eSnL6A7rMU5cGdyqCk6wkYtyarq9WxOpcSbnGx2jfpwe5JTJkx07EYr+idnQ7ELpMLDTmBVH4C8 eTte2eUouAYPpEqlmaJ4E/UgH4aC4BoGh2SPrySrxLhvE8NAwJ4dTyyYpFWcP4Dj6nM+kVW4hqn B1QFkc7XuaM35xIo7bGRT1QEsBRRQ3TwH8enYjqVdN3jfyKiCWEHkTwVJiZ7JLVuO2hEbkiotr8 5CnlSJkr69bfQcH0vqLN2GuqZZS3gKjAMpvQeZG8AjApkSaKif952Td2FK0ZWkhrDhpvmivun6q Bn+nl1QWwKqL2frpXLGXscSGKcwAUrKBMbJgs7sYU2D6pNpAu2o3+XBkET5GPYBWQ81HBi6k3eC xebd134TsvQxqd6Pze14xUq7B5wa/w1z2gUVS99bJvGwO2BMgVzr0WAhCRIDNIYM0n5cuV5MTaP b42aZjYLxZTZi6a5pw= X-Received: by 2002:a17:902:e74b:b0:2ba:5f24:caf8 with SMTP id d9443c01a7336-2ba7908c80cmr65596485ad.12.1778128805818; Wed, 06 May 2026 21:40:05 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v5 5/9] target/riscv: tt-ascalon: Enable Zkr extension Date: Thu, 7 May 2026 14:38:33 +1000 Message-ID: <20260507043838.45652-6-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=npiggin@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128885535158500 Content-Type: text/plain; charset="utf-8" Ascalon supports Zkr and the SEED CSR. Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin Reviewed-by: Chao Liu Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index ce15a17c37..69649462dd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3190,6 +3190,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .cfg.ext_zba =3D true, .cfg.ext_zbb =3D true, .cfg.ext_zbs =3D true, + .cfg.ext_zkr =3D true, .cfg.ext_zkt =3D true, .cfg.ext_zvbb =3D true, .cfg.ext_zvbc =3D true, --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128835; cv=none; d=zohomail.com; s=zohoarc; b=FGSM0z0K1GF56QxEegHMdeA3jV19/+cOdBnbXOhCwYKp0L8xNbPy21Fkx2RfFx6z6Hn2PfHy7zHFj8JZ/+Cig+JhP2ae5dv/dxLjzmKG/5bTE2dea8rFo/HGudIqVCv2XxBqBfzOUdR8HT3Fl1s1sC0cWuYQbTGyLzoWmIRS3/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128835; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=My2S6d1QZcXh6qabXNMTSl35HL9fJpY/xbsHbQJU1s8=; b=aQB8Qck55tS/p/W3U6vj0vCThH+aBQgshvX9w8+pDiKdo17UB4syqoUnbxqWttLR7WkL6QQ1d1Pmou3Xt2B2wRcHTNIzuzS8luimSrGRYneeBZYmBr7aNb0fx/2SUAeNE0LF7NZVbo5Suy4HW4IKmoufnXPJJ3EXb7uiW+KsUGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128835536798.5250849837873; Wed, 6 May 2026 21:40:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqX0-0000e5-TJ; Thu, 07 May 2026 00:40:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqWz-0000db-JI for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:13 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqWx-00047V-Tz for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:13 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-36535998b71so207598a91.0 for ; Wed, 06 May 2026 21:40:11 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-365b4c87678sm6018505a91.12.2026.05.06.21.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128810; x=1778733610; darn=nongnu.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=My2S6d1QZcXh6qabXNMTSl35HL9fJpY/xbsHbQJU1s8=; b=i6W/lzTY77KRTQL6FNPnhLPRU+CXFAYGnTfgekFggQQ1EPuLH6GsY7RmgcKQZbl4Ok yp3A6xmAPVRKHQIna5jAJwwaQkqtUrEQiFN0bW9Ji4Fuc+uv7cZw/CJqotpT01ijiyex zETHFGyJs/eRu7JvgCk4fnScga3B4XVdyxkbSy7/qodMGYtkhTmrDXIDy8c1ZE/550bu 2zNuBod4QYBzVpxhxpQZfhlJlVDv9LxVD9f7cyhAk0ajWay7ic9SJhP9qqfQWFrlymkz g6OqOEsigYgt7Acluh1gq2nzLTY1jjP4j3PDR8fCLm+mMC3T7nnHY6xDqfjPX83KTdxw WrGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128810; x=1778733610; 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=My2S6d1QZcXh6qabXNMTSl35HL9fJpY/xbsHbQJU1s8=; b=pl6mDbTNqcFJPB21fswYlNFfoTXl4GR5cnjh8bmqaMuEs03jaaiRsfVxmwnRYQ3sJ3 3lcOwvf6ogXc/iLSXZYcwGoqzbJlFuSiAwFRC5zQymfPh2G8A+hwkygSfuzzBkSEbeay OiHYn4DiYtlaTZ0EBvhCKMhtaUMhj9FXXIWQrt2Fob31MnHDly9wl5lC4IuqQwD+NMxd ZqIfb2EUivFKHPxQch1bxxSc4SiHD9LQzyerOZXdRmH5B1v0w8I0UxAUJOSkmxUZ6Wcc 9ODNc7rCTAiLRkFw6FdhxfA9red846FmSx8lIFFwiEdRdC0he28BMvLXuNk/RMoyzce+ 7R5g== X-Forwarded-Encrypted: i=1; AFNElJ89MsVzEe1xtXXDTgP5nQH8jBK1AVy3R7auRx/lDpYKys4RJZNiuv2L1RDQzwbL3WvGK4Kw9ymctSA5@nongnu.org X-Gm-Message-State: AOJu0Yy/o9F6T8FHvCMf8Hk2uD5gZ4H21swRbtr8sVa9oEWqOqGGCOUR kii7DH2r7oTtVdWPqFglHEoqfUh1J0WUlwcxYFk/AuKwex7gNCQC+rQS X-Gm-Gg: AeBDies/MqR140f1cVu/XfApLEC2tQ0n8kzKlZzOFhyXS9HhNgMmfJ7JK22n9dIitsv fRUvM8n7XpmvKQXGvhrWmbuAAh+UtbpfzJOTcT3b1h2XuWiLh9FQFIckMinvRMWSLfKhw7N6EB6 tYX6iX6MxmvZKc6MS6YoS7VvkqISnDvc1rMwHzj378w2YVuDqbAGQnAzlJ9kmmT2N3gCUNuhK3U SJna0C4tRC3XfzqKXbm3mH60XHJ5Rv8wZmG3Psygb7KHmoijTWPzSBQlb+Dv4KdBAlchcWNQwHA Dlw8J2N2kmF+LqAtR2UnLt9FuEbAp+6gA9cI5wsJnu12gSRZgRn1Bi30ea3Srzy0QdhQShED8gq Ldp8Q++Ioi2tpVyMjDHnXVlvQ/4dKVJqXx0vfug7elltTsfv349LJN0tMHyoI/mjh6kLZ94Op08 x3F3DuQuCTs/ZwBbHrgUfNkIhBo0q1qZ3RkN1rts0botica9tmTGg+LsliedJwcKnFogliWOjQP g5Zwv4a X-Received: by 2002:a17:90b:5486:b0:35f:b230:5889 with SMTP id 98e67ed59e1d1-366053e90a9mr1128822a91.6.1778128810475; Wed, 06 May 2026 21:40:10 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v5 6/9] target/riscv: tt-ascalon: Enable Svadu by removing Svade Date: Thu, 7 May 2026 14:38:34 +1000 Message-ID: <20260507043838.45652-7-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=npiggin@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128839151154100 Content-Type: text/plain; charset="utf-8" Ascalon supports Svadu (hardware A/D bit updates). QEMU makes Svadu and Svade mutually exclusive, remove Svade so Ascalon comes up with Svadu working. Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 69649462dd..97e3567264 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -3204,7 +3204,6 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .cfg.ext_ssaia =3D true, .cfg.ext_sscofpmf =3D true, .cfg.ext_sstc =3D true, - .cfg.ext_svade =3D true, .cfg.ext_svinval =3D true, .cfg.ext_svnapot =3D true, .cfg.ext_svpbmt =3D true, --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128850; cv=none; d=zohomail.com; s=zohoarc; b=Ip3xm8uat/kIFUsBkInyktrJjtxVySK/tghXlifD4aFAq+SD7Q9cUBvLYVN5lFUoweGC1sSTnf1dFS17tm/qe8W4wFxefAmRUFyczXN63REoqzqiBiwcgB+xH3iw04O7aNoIlTpPH/i1Bady463uTHc7r+LWmlN7cLREGdpt0/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128850; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yITtISNMFjnVppWG9b5+Yyw3EVYoyuwfUK+wQjCeHZg=; b=SOLelTMWbi9nDjuD94/uXXGpLBxXSA9lZBJ3T90MnKxsFh8Z0n8hB1EdO6PaEtSWQxoZgfrlLw83rPHGfIXZeYfxPr76htjELabiauj6ez90dXlorpJoyv0C8oHr849kLu8QaNUOP8pNLe6o3LpnduR5r8pAqT5JJsLyWqfQffk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128850231640.1099898986241; Wed, 6 May 2026 21:40:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqX8-0000mW-Rn; Thu, 07 May 2026 00:40:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqX7-0000kq-0M for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:21 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqX2-00048B-UN for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:20 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-2a7a9b8ed69so3661065ad.2 for ; Wed, 06 May 2026 21:40:16 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babb1f0148sm9255885ad.82.2026.05.06.21.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128815; x=1778733615; darn=nongnu.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=yITtISNMFjnVppWG9b5+Yyw3EVYoyuwfUK+wQjCeHZg=; b=DT9DuKRRqobuTzNgSHQPRkOrvX/uV0OPFzVLp5k6oDsMItChmaM7iZWalgcnwE/NbX 1akCHfVeKmzwUooJsUrK+y/GqTyZYKvdLvvutcBNos1dV62xTp06C68Jr42gKEC08WJy tWSSbgG8RIFCNG+M/6lWXWhHJYiBA/NICxfuBMzsni6etUWhZ2lcpvBEGQ5a9lT2ZmgQ /YuuFYfkQMmRbuGLvt4C9DpSh2A96hNtq4K/pu9a709hjVzMAdg5nigQnlP/72+7bi8R py4n29vCwFd5zXx8tJS/PfKFh2a8FYNsUHyfLKzJiNzHr4FmoOA+sl7QRnlGxRigY9+I P3ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128815; x=1778733615; 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=yITtISNMFjnVppWG9b5+Yyw3EVYoyuwfUK+wQjCeHZg=; b=ocAoBvdf3PGMu/ek1j57X2tcNz8KbQ6E8aNKTJ4l9M1Y+xcXX55oJFOjNb1ittxQ+N tMEJVy+aaTYEjbBI4lySqgtQlV4gG5ennQS13aNUzO3usLWh3+iWSZEBELBV39oAvf6W Wv0uJtxaOTn0pzlzHj5S1bma59gY3ITsIQFtWzjP6pDKFh9yXKpb0qIn3dv5bAEKxkKm ZnfkwBWHtrEHi9yV2/yuGq2SI+quaQLsBMJiBJszqqNR1zmEkbohASwDYZuzWjSVCoHr pYmyLzBEXLm21WkyF1tTZLTYbq1aBvbpnp/dcuR7byaZG37Y4BjTI75Nw4v5jdzeOL77 yRSA== X-Forwarded-Encrypted: i=1; AFNElJ/yo+7gXyTkzw/uVCYtbaKmgqGN5jhy8iiNdL6FeOpQazSqNHY4pDJiy2/fH+s1PI9WoE/Pxu2ZkjjY@nongnu.org X-Gm-Message-State: AOJu0Yz/sYDbwfi4u+q+Y3IkjuKhiaQnzmKj7tLyURtLhnLKZ67ey9ar pU2qIi9nVXPN1KNMNJzb9T7k4iPG5mUI655Ls/7tEbj8ldBVHDQ4q+pV X-Gm-Gg: AeBDiesYQnTWumy4Mc6Na36Ol2i24G39mPuIz4m0XK7AYTzldGB+uNVlG2uBKlzbqXg gOzDs+RoIwFPAXviT2R6c79B/o6tNXzQq9m0pakd6vBoRAN4+R6zCqVHKg4Zrfo3ypI7KFS/Tgi 8Z6iLN8S+hW7BmqYD8+xOlBqfkDlrBVnTS8ye0kGA0Xrqz0L4V0UFJRYqFcqLGbaamIFTZyM00l 8FF5X3Kx3TgkCvtum24zCuEq13Nu4kEyam+SlQSFdTP854BX/mNqUYI/00G4czhvt83RXAtl3C+ 72H8G62XVJu7qm1Gjh0hQQ3mbEEontP5Z2VgjPY307rriS/doboofTF1+MuKJiiCCz42WiEclbl 6BuT+kWgx/xxUelhPmfP1AVActp8K+lUnbuJ9E1MJsvj+V11Uu+CQCwaIcPoCte1P88kwU5XQGS bDlafEYj+bn6Awzic23Up+cOIx+TUwucYoJyW5leB+9VSUQAS9FOt2wU4cwXVbdWXUbQ+YFT8hT +HHwWwf X-Received: by 2002:a17:903:4b03:b0:2b4:5dff:30fd with SMTP id d9443c01a7336-2ba79291d16mr68160165ad.4.1778128815318; Wed, 06 May 2026 21:40:15 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 7/9] hw/riscv: Add Tenstorrent Atlantis machine Date: Thu, 7 May 2026 14:38:35 +1000 Message-ID: <20260507043838.45652-8-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=npiggin@gmail.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128851691158500 From: Joel Stanley The Tenstorrent Atlantis platform is a collaboration between Tenstorrent and CoreLab Technology. It is based on the Atlantis SoC, which includes the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology. The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant RISC-V CPU. Add the tt-atlantis machine containing serial console, interrupt controllers, and device tree support. The Atlantis boot images loaded from include OpenSBI and an initial DTB that is passed to OpenSBI. This is approximated in the model by having QEMU build the device tree rather than load a DTB image directly. Subsequent stages may use the modified DTB provided by OpenSBI or opt to supply their own. qemu-system-riscv64 -M tt-atlantis -m 512M \ -kernel Image -initrd rootfs.cpio -nographic Co-Developed-by: Nicholas Piggin Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Chao Liu --- MAINTAINERS | 10 + docs/system/riscv/tt_atlantis.rst | 32 ++ docs/system/target-riscv.rst | 1 + hw/riscv/Kconfig | 10 + hw/riscv/meson.build | 1 + hw/riscv/tt_atlantis.c | 556 ++++++++++++++++++++++++++++++ include/hw/riscv/tt_atlantis.h | 51 +++ 7 files changed, 661 insertions(+) create mode 100644 docs/system/riscv/tt_atlantis.rst create mode 100644 hw/riscv/tt_atlantis.c create mode 100644 include/hw/riscv/tt_atlantis.h diff --git a/MAINTAINERS b/MAINTAINERS index afa178c5cc..1ab5f3e45b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1767,6 +1767,16 @@ F: hw/*/*sifive*.c F: include/hw/*/*sifive*.h F: tests/functional/test_riscv64_sifive_u.py =20 +Tenstorrent Machines +M: Joel Stanley +R: Nicholas Piggin +R: Michael Ellerman +L: qemu-riscv@nongnu.org +S: Supported +F: docs/system/riscv/tt_*.rst +F: hw/riscv/tt_*.c +F: include/hw/riscv/tt_*.h + AMD Microblaze-V Generic Board M: Sai Pavan Boddu S: Maintained diff --git a/docs/system/riscv/tt_atlantis.rst b/docs/system/riscv/tt_atlan= tis.rst new file mode 100644 index 0000000000..e8bc625677 --- /dev/null +++ b/docs/system/riscv/tt_atlantis.rst @@ -0,0 +1,32 @@ +Tenstorrent Atlantis (``tt-atlantis``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The Tenstorrent Atlantis platform is a collaboration between Tenstorrent +and CoreLab Technology. It is based on the Atlantis SoC, which includes +the Ascalon-X CPU and other IP from Tenstorrent and CoreLab Technology. + +The Tenstorrent Ascalon-X is a high performance 64-bit RVA23 compliant +RISC-V CPU. + +tt-atlantis QEMU model features +------------------------------- + +* 8-core Ascalon-X CPU Cluster +* RISC-V compliant Advanced Interrupt Architecture +* 16550A compatible UART + + +Note: the QEMU tt-atlantis machine does not model the platform +exactly or all devices, but it is undergoing improvement. + +Supported software +------------------ + +The Tenstorrent Ascalon CPUs avoid proprietary or non-standard +extensions, so compatibility with existing software is generally +good. The QEMU tt-atlantis machine works with upstream OpenSBI +and Linux with default configurations. + +The development board hardware will require some implementation +specific setup in firmware which is being developed and may +become a requirement or option for the tt-atlantis machine. diff --git a/docs/system/target-riscv.rst b/docs/system/target-riscv.rst index 3ad5d1ddaf..a8e6b33421 100644 --- a/docs/system/target-riscv.rst +++ b/docs/system/target-riscv.rst @@ -71,6 +71,7 @@ undocumented; you can get a complete list by running riscv/mips riscv/shakti-c riscv/sifive_u + riscv/tt_atlantis riscv/virt riscv/xiangshan-kunminghu =20 diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 2518b04175..aaf029c9ed 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -120,6 +120,16 @@ config SPIKE select RISCV_ACLINT select SIFIVE_PLIC =20 +config TENSTORRENT + bool + default y + depends on RISCV64 + select RISCV_ACLINT + select RISCV_APLIC + select RISCV_IMSIC + select SERIAL_MM + select DEVICE_TREE + config XIANGSHAN_KUNMINGHU bool default y diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build index e53c180d0d..026e79591f 100644 --- a/hw/riscv/meson.build +++ b/hw/riscv/meson.build @@ -9,6 +9,7 @@ riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifiv= e_e.c')) riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c')) riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c')) riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfs= oc.c')) +riscv_ss.add(when: 'CONFIG_TENSTORRENT', if_true: files('tt_atlantis.c')) riscv_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c')) riscv_ss.add(when: 'CONFIG_RISCV_IOMMU', if_true: files( 'riscv-iommu.c', 'riscv-iommu-pci.c', 'riscv-iommu-sys.c', 'riscv-iommu-h= pm.c')) diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c new file mode 100644 index 0000000000..43f47fbd75 --- /dev/null +++ b/hw/riscv/tt_atlantis.c @@ -0,0 +1,556 @@ +/* + * Tenstorrent Atlantis RISC-V System on Chip + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright 2025 Tenstorrent, Joel Stanley + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/error-report.h" +#include "qemu/guest-random.h" +#include "qemu/units.h" + +#include "hw/core/boards.h" +#include "hw/core/loader.h" +#include "hw/core/sysbus.h" + +#include "target/riscv/cpu.h" +#include "target/riscv/pmu.h" + +#include "hw/riscv/boot.h" +#include "hw/riscv/riscv_hart.h" + +#include "hw/char/serial-mm.h" +#include "hw/intc/riscv_aclint.h" +#include "hw/intc/riscv_aplic.h" + +#include "system/system.h" +#include "system/device_tree.h" + +#include "hw/riscv/tt_atlantis.h" + +#include "aia.h" + +#define TT_IRQCHIP_NUM_MSIS 255 +#define TT_IRQCHIP_NUM_SOURCES 128 +#define TT_IRQCHIP_NUM_PRIO_BITS 3 +#define TT_IRQCHIP_GUESTS 7 /* aia_guests */ + +#define FDT_PCI_ADDR_CELLS 3 +#define FDT_PCI_INT_CELLS 1 +#define FDT_MAX_INT_CELLS 2 +#define FDT_MAX_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \ + 1 + FDT_MAX_INT_CELLS) + +#define TT_ACLINT_MTIME_SIZE 0x8050 +#define TT_ACLINT_MTIME 0x0 +#define TT_ACLINT_MTIMECMP 0x8000 +#define TT_ACLINT_TIMEBASE_FREQ 1000000000 + +static const MemMapEntry tt_atlantis_memmap[] =3D { + /* Keep sorted with :'<,'>!sort -g -k 4 */ + [TT_ATL_DDR_LO] =3D { 0x00000000, 0x80000000 }, + [TT_ATL_BOOTROM] =3D { 0x80000000, 0x2000 }, + [TT_ATL_MIMSIC] =3D { 0xa0000000, 0x200000 }, + [TT_ATL_ACLINT] =3D { 0xa2180000, 0x10000 }, + [TT_ATL_SIMSIC] =3D { 0xa4000000, 0x200000 }, + [TT_ATL_TIMER] =3D { 0xa8020000, 0x10000 }, + [TT_ATL_UART0] =3D { 0xb0100000, 0x10000 }, + [TT_ATL_MAPLIC] =3D { 0xcc000000, 0x4000000 }, + [TT_ATL_SAPLIC] =3D { 0xe8000000, 0x4000000 }, + [TT_ATL_DDR_HI] =3D { 0x100000000, 0x1000000000 }, +}; + +static uint32_t next_phandle(void) +{ + static uint32_t phandle =3D 1; + return phandle++; +} + +static void create_fdt_cpus(TTAtlantisState *s, uint32_t *intc_phandles) +{ + uint32_t cpu_phandle; + void *fdt =3D MACHINE(s)->fdt; + + for (int cpu =3D s->soc.num_harts - 1; cpu >=3D 0; cpu--) { + RISCVCPU *cpu_ptr =3D &s->soc.harts[cpu]; + g_autofree char *cpu_name =3D NULL; + g_autofree char *intc_name =3D NULL; + + cpu_phandle =3D next_phandle(); + + cpu_name =3D g_strdup_printf("/cpus/cpu@%d", s->soc.hartid_base + = cpu); + qemu_fdt_add_subnode(fdt, cpu_name); + + qemu_fdt_setprop_string(fdt, cpu_name, "mmu-type", "riscv,sv57"); + + riscv_isa_write_fdt(cpu_ptr, fdt, cpu_name); + + qemu_fdt_setprop_cell(fdt, cpu_name, "riscv,cbom-block-size", + cpu_ptr->cfg.cbom_blocksize); + + qemu_fdt_setprop_cell(fdt, cpu_name, "riscv,cboz-block-size", + cpu_ptr->cfg.cboz_blocksize); + + qemu_fdt_setprop_cell(fdt, cpu_name, "riscv,cbop-block-size", + cpu_ptr->cfg.cbop_blocksize); + + qemu_fdt_setprop_string(fdt, cpu_name, "compatible", "riscv"); + qemu_fdt_setprop_string(fdt, cpu_name, "status", "okay"); + qemu_fdt_setprop_cell(fdt, cpu_name, "reg", s->soc.hartid_base + c= pu); + qemu_fdt_setprop_string(fdt, cpu_name, "device_type", "cpu"); + qemu_fdt_setprop_cell(fdt, cpu_name, "phandle", cpu_phandle); + + intc_phandles[cpu] =3D next_phandle(); + + intc_name =3D g_strdup_printf("%s/interrupt-controller", cpu_name); + qemu_fdt_add_subnode(fdt, intc_name); + qemu_fdt_setprop_cell(fdt, intc_name, "phandle", + intc_phandles[cpu]); + qemu_fdt_setprop_string(fdt, intc_name, "compatible", + "riscv,cpu-intc"); + qemu_fdt_setprop(fdt, intc_name, "interrupt-controller", NULL, 0); + qemu_fdt_setprop_cell(fdt, intc_name, "#interrupt-cells", 1); + } +} + +static void create_fdt_memory_node(TTAtlantisState *s, + hwaddr addr, hwaddr size) +{ + void *fdt =3D MACHINE(s)->fdt; + g_autofree char *name =3D g_strdup_printf("/memory@%"HWADDR_PRIX, addr= ); + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, addr, 2, size); + qemu_fdt_setprop_string(fdt, name, "device_type", "memory"); +} + +static void create_fdt_memory(TTAtlantisState *s) +{ + hwaddr size_lo =3D MACHINE(s)->ram_size; + hwaddr size_hi =3D 0; + + if (size_lo > s->memmap[TT_ATL_DDR_LO].size) { + size_lo =3D s->memmap[TT_ATL_DDR_LO].size; + size_hi =3D MACHINE(s)->ram_size - size_lo; + } + + create_fdt_memory_node(s, s->memmap[TT_ATL_DDR_LO].base, size_lo); + if (size_hi) { + /* + * The first part of the HI address is aliased at the LO address + * so do not include that as usable memory. Is there any way + * (or good reason) to describe that aliasing 2GB with DT? + */ + create_fdt_memory_node(s, s->memmap[TT_ATL_DDR_HI].base + size_lo, + size_hi); + } +} + +static void create_fdt_aclint(TTAtlantisState *s, uint32_t *intc_phandles) +{ + void *fdt =3D MACHINE(s)->fdt; + g_autofree char *name =3D NULL; + g_autofree uint32_t *aclint_mtimer_cells =3D NULL; + uint32_t aclint_cells_size; + hwaddr addr; + + aclint_mtimer_cells =3D g_new0(uint32_t, s->soc.num_harts * 2); + + for (int cpu =3D 0; cpu < s->soc.num_harts; cpu++) { + aclint_mtimer_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu= ]); + aclint_mtimer_cells[cpu * 2 + 1] =3D cpu_to_be32(IRQ_M_TIMER); + } + aclint_cells_size =3D s->soc.num_harts * sizeof(uint32_t) * 2; + + addr =3D s->memmap[TT_ATL_ACLINT].base; + + name =3D g_strdup_printf("/soc/mtimer@%"HWADDR_PRIX, addr); + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_string(fdt, name, "compatible", "riscv,aclint-mtimer"= ); + qemu_fdt_setprop_sized_cells(fdt, name, "reg", + 2, addr + TT_ACLINT_MTIME, + 2, 0x1000, + 2, addr + TT_ACLINT_MTIMECMP, + 2, 0x1000); + qemu_fdt_setprop(fdt, name, "interrupts-extended", + aclint_mtimer_cells, aclint_cells_size); +} + +static void create_fdt_one_imsic(void *fdt, const MemMapEntry *mem, int cp= us, + uint32_t *intc_phandles, uint32_t msi_pha= ndle, + int irq_line, uint32_t imsic_guest_bits) +{ + g_autofree char *name =3D NULL; + g_autofree uint32_t *imsic_cells =3D g_new0(uint32_t, cpus * 2); + + for (int cpu =3D 0; cpu < cpus; cpu++) { + imsic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); + imsic_cells[cpu * 2 + 1] =3D cpu_to_be32(irq_line); + } + + name =3D g_strdup_printf("/soc/interrupt-controller@%"HWADDR_PRIX, mem= ->base); + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_string(fdt, name, "compatible", "riscv,imsics"); + + qemu_fdt_setprop_cell(fdt, name, "#interrupt-cells", 0); + qemu_fdt_setprop(fdt, name, "interrupt-controller", NULL, 0); + qemu_fdt_setprop(fdt, name, "msi-controller", NULL, 0); + qemu_fdt_setprop(fdt, name, "interrupts-extended", + imsic_cells, sizeof(uint32_t) * cpus * 2); + qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, mem->base, 2, mem->s= ize); + qemu_fdt_setprop_cell(fdt, name, "riscv,num-ids", TT_IRQCHIP_NUM_MSIS); + + if (imsic_guest_bits) { + qemu_fdt_setprop_cell(fdt, name, "riscv,guest-index-bits", + imsic_guest_bits); + } + qemu_fdt_setprop_cell(fdt, name, "phandle", msi_phandle); +} + +static void create_fdt_one_aplic(void *fdt, + const MemMapEntry *mem, + uint32_t msi_phandle, + uint32_t *intc_phandles, + uint32_t aplic_phandle, + uint32_t aplic_child_phandle, + int irq_line, int num_harts) +{ + g_autofree char *name =3D + g_strdup_printf("/soc/interrupt-controller@%"HWADDR_PRIX, mem->bas= e); + g_autofree uint32_t *aplic_cells =3D g_new0(uint32_t, num_harts * 2); + + for (int cpu =3D 0; cpu < num_harts; cpu++) { + aplic_cells[cpu * 2 + 0] =3D cpu_to_be32(intc_phandles[cpu]); + aplic_cells[cpu * 2 + 1] =3D cpu_to_be32(irq_line); + } + + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_string(fdt, name, "compatible", "riscv,aplic"); + qemu_fdt_setprop_cell(fdt, name, "#address-cells", 0); + qemu_fdt_setprop_cell(fdt, name, "#interrupt-cells", 2); + qemu_fdt_setprop(fdt, name, "interrupt-controller", NULL, 0); + + qemu_fdt_setprop(fdt, name, "interrupts-extended", + aplic_cells, num_harts * sizeof(uint32_t) * 2); + qemu_fdt_setprop_cell(fdt, name, "msi-parent", msi_phandle); + + qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, mem->base, 2, mem->s= ize); + qemu_fdt_setprop_cell(fdt, name, "riscv,num-sources", + TT_IRQCHIP_NUM_SOURCES); + + if (aplic_child_phandle) { + qemu_fdt_setprop_cell(fdt, name, "riscv,children", + aplic_child_phandle); + qemu_fdt_setprop_cells(fdt, name, "riscv,delegation", + aplic_child_phandle, 1, TT_IRQCHIP_NUM_SOUR= CES); + } + + qemu_fdt_setprop_cell(fdt, name, "phandle", aplic_phandle); +} + +static void create_fdt_pmu(TTAtlantisState *s) +{ + g_autofree char *pmu_name =3D g_strdup_printf("/pmu"); + void *fdt =3D MACHINE(s)->fdt; + RISCVCPU *hart =3D &s->soc.harts[0]; + + qemu_fdt_add_subnode(fdt, pmu_name); + qemu_fdt_setprop_string(fdt, pmu_name, "compatible", "riscv,pmu"); + riscv_pmu_generate_fdt_node(fdt, hart->pmu_avail_ctrs, pmu_name); +} + +static void create_fdt_cpu(TTAtlantisState *s, const MemMapEntry *memmap, + uint32_t aplic_s_phandle, + uint32_t imsic_s_phandle) +{ + MachineState *ms =3D MACHINE(s); + void *fdt =3D MACHINE(s)->fdt; + g_autofree uint32_t *intc_phandles =3D NULL; + + qemu_fdt_add_subnode(fdt, "/cpus"); + qemu_fdt_setprop_cell(fdt, "/cpus", "timebase-frequency", + TT_ACLINT_TIMEBASE_FREQ); + qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0x0); + qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 0x1); + + intc_phandles =3D g_new0(uint32_t, ms->smp.cpus); + + create_fdt_cpus(s, intc_phandles); + + create_fdt_memory(s); + + create_fdt_aclint(s, intc_phandles); + + /* M-level IMSIC node */ + uint32_t msi_m_phandle =3D next_phandle(); + create_fdt_one_imsic(fdt, &s->memmap[TT_ATL_MIMSIC], ms->smp.cpus, + intc_phandles, msi_m_phandle, + IRQ_M_EXT, 0); + + /* S-level IMSIC node */ + create_fdt_one_imsic(fdt, &s->memmap[TT_ATL_SIMSIC], ms->smp.cpus, + intc_phandles, imsic_s_phandle, + IRQ_S_EXT, imsic_num_bits(TT_IRQCHIP_GUESTS + 1)); + + uint32_t aplic_m_phandle =3D next_phandle(); + + /* M-level APLIC node */ + create_fdt_one_aplic(fdt, &s->memmap[TT_ATL_MAPLIC], + msi_m_phandle, intc_phandles, + aplic_m_phandle, aplic_s_phandle, + IRQ_M_EXT, s->soc.num_harts); + + /* S-level APLIC node */ + create_fdt_one_aplic(fdt, &s->memmap[TT_ATL_SAPLIC], + imsic_s_phandle, intc_phandles, + aplic_s_phandle, 0, + IRQ_S_EXT, s->soc.num_harts); +} + +static void create_fdt_uart(void *fdt, const MemMapEntry *mem, int irq, + int irqchip_phandle) +{ + g_autofree char *name =3D g_strdup_printf("/soc/serial@%"HWADDR_PRIX, + mem->base); + + qemu_fdt_add_subnode(fdt, name); + qemu_fdt_setprop_string(fdt, name, "compatible", "ns16550a"); + qemu_fdt_setprop_sized_cells(fdt, name, "reg", 2, mem->base, 2, mem->s= ize); + qemu_fdt_setprop_cell(fdt, name, "reg-shift", 2); + qemu_fdt_setprop_cell(fdt, name, "reg-io-width", 4); + qemu_fdt_setprop_cell(fdt, name, "clock-frequency", 3686400); + qemu_fdt_setprop_cell(fdt, name, "interrupt-parent", irqchip_phandle); + qemu_fdt_setprop_cells(fdt, name, "interrupts", irq, 0x4); + + qemu_fdt_setprop_string(fdt, "/chosen", "stdout-path", name); + qemu_fdt_setprop_string(fdt, "/aliases", "serial0", name); +} + +static void finalize_fdt(TTAtlantisState *s) +{ + uint32_t aplic_s_phandle =3D next_phandle(); + uint32_t imsic_s_phandle =3D next_phandle(); + void *fdt =3D MACHINE(s)->fdt; + + create_fdt_cpu(s, s->memmap, aplic_s_phandle, imsic_s_phandle); + + /* + * We want to do this, but the Linux aplic driver was broken before v6= .16 + * + * qemu_fdt_setprop_cell(MACHINE(s)->fdt, "/soc", "interrupt-parent", + * aplic_s_phandle); + */ + + create_fdt_uart(fdt, &s->memmap[TT_ATL_UART0], TT_ATL_UART0_IRQ, + aplic_s_phandle); +} + +static void create_fdt(TTAtlantisState *s) +{ + MachineState *ms =3D MACHINE(s); + uint8_t rng_seed[32]; + g_autofree char *name =3D NULL; + void *fdt; + + fdt =3D create_device_tree(&s->fdt_size); + if (!fdt) { + error_report("create_device_tree() failed"); + exit(1); + } + ms->fdt =3D fdt; + + qemu_fdt_setprop_string(fdt, "/", "model", + "Tenstorrent Atlantis RISC-V Machine"); + qemu_fdt_setprop_string(fdt, "/", "compatible", "tenstorrent,atlantis"= ); + qemu_fdt_setprop_cell(fdt, "/", "#size-cells", 0x2); + qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 0x2); + + qemu_fdt_add_subnode(fdt, "/soc"); + qemu_fdt_setprop(fdt, "/soc", "ranges", NULL, 0); + qemu_fdt_setprop_string(fdt, "/soc", "compatible", "simple-bus"); + qemu_fdt_setprop_cell(fdt, "/soc", "#size-cells", 0x2); + qemu_fdt_setprop_cell(fdt, "/soc", "#address-cells", 0x2); + + qemu_fdt_add_subnode(fdt, "/chosen"); + + /* Pass seed to RNG */ + qemu_guest_getrandom_nofail(rng_seed, sizeof(rng_seed)); + qemu_fdt_setprop(fdt, "/chosen", "rng-seed", rng_seed, sizeof(rng_seed= )); + + qemu_fdt_add_subnode(fdt, "/aliases"); + + create_fdt_pmu(s); +} + +static void tt_atlantis_machine_done(Notifier *notifier, void *data) +{ + TTAtlantisState *s =3D container_of(notifier, TTAtlantisState, machine= _done); + MachineState *machine =3D MACHINE(s); + hwaddr start_addr =3D s->memmap[TT_ATL_DDR_LO].base; + hwaddr mem_size; + target_ulong firmware_end_addr, kernel_start_addr; + const char *firmware_name =3D riscv_default_firmware_name(&s->soc); + uint64_t fdt_load_addr; + uint64_t kernel_entry; + RISCVBootInfo boot_info; + + /* + * A user provided dtb must include everything, including + * dynamic sysbus devices. Our FDT needs to be finalized. + */ + if (machine->dtb =3D=3D NULL) { + finalize_fdt(s); + } + + mem_size =3D machine->ram_size; + if (mem_size > s->memmap[TT_ATL_DDR_LO].size) { + mem_size =3D s->memmap[TT_ATL_DDR_LO].size; + } + riscv_boot_info_init_discontig_mem(&boot_info, &s->soc, + s->memmap[TT_ATL_DDR_LO].base, + mem_size); + + firmware_end_addr =3D riscv_find_and_load_firmware(machine, &boot_info, + firmware_name, + &start_addr, NULL); + + kernel_start_addr =3D riscv_calc_kernel_start_addr(&boot_info, + firmware_end_addr); + if (machine->kernel_filename) { + riscv_load_kernel(machine, &boot_info, kernel_start_addr, + true, NULL); + } + kernel_entry =3D boot_info.image_low_addr; + + fdt_load_addr =3D riscv_compute_fdt_addr(s->memmap[TT_ATL_DDR_LO].base, + s->memmap[TT_ATL_DDR_LO].size, + machine, &boot_info); + riscv_load_fdt(fdt_load_addr, machine->fdt); + + /* load the reset vector */ + riscv_setup_rom_reset_vec(machine, &s->soc, start_addr, + s->memmap[TT_ATL_BOOTROM].base, + s->memmap[TT_ATL_BOOTROM].size, + kernel_entry, + fdt_load_addr); + +} + +static void tt_atlantis_machine_init(MachineState *machine) +{ + TTAtlantisState *s =3D TT_ATLANTIS_MACHINE(machine); + + MemoryRegion *system_memory =3D get_system_memory(); + MemoryRegion *ram_hi =3D g_new(MemoryRegion, 1); + MemoryRegion *ram_lo =3D g_new(MemoryRegion, 1); + MemoryRegion *bootrom =3D g_new(MemoryRegion, 1); + ram_addr_t lo_ram_size, hi_ram_size; + int hart_count =3D machine->smp.cpus; + int base_hartid =3D 0; + + s->memmap =3D tt_atlantis_memmap; + + object_initialize_child(OBJECT(machine), "soc", &s->soc, + TYPE_RISCV_HART_ARRAY); + object_property_set_str(OBJECT(&s->soc), "cpu-type", machine->cpu_type, + &error_abort); + object_property_set_int(OBJECT(&s->soc), "hartid-base", base_hartid, + &error_abort); + object_property_set_int(OBJECT(&s->soc), "num-harts", hart_count, + &error_abort); + object_property_set_int(OBJECT(&s->soc), "resetvec", + s->memmap[TT_ATL_BOOTROM].base, + &error_abort); + sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal); + + s->irqchip =3D riscv_create_aia(true, TT_IRQCHIP_GUESTS, + TT_IRQCHIP_NUM_SOURCES, + &s->memmap[TT_ATL_MAPLIC], + &s->memmap[TT_ATL_SAPLIC], + &s->memmap[TT_ATL_MIMSIC], + &s->memmap[TT_ATL_SIMSIC], + 0, base_hartid, hart_count, + TT_IRQCHIP_NUM_MSIS, + TT_IRQCHIP_NUM_PRIO_BITS); + + riscv_aclint_mtimer_create(s->memmap[TT_ATL_ACLINT].base, + TT_ACLINT_MTIME_SIZE, + base_hartid, hart_count, + TT_ACLINT_MTIMECMP, + TT_ACLINT_MTIME, + TT_ACLINT_TIMEBASE_FREQ, true); + + /* DDR */ + + /* The high address covers all of RAM, the low address just the first = 2GB */ + lo_ram_size =3D s->memmap[TT_ATL_DDR_LO].size; + hi_ram_size =3D s->memmap[TT_ATL_DDR_HI].size; + if (machine->ram_size > hi_ram_size) { + char *sz =3D size_to_str(hi_ram_size); + error_report("RAM size is too large, maximum is %s", sz); + g_free(sz); + exit(EXIT_FAILURE); + } + + memory_region_init_alias(ram_lo, OBJECT(machine), "ram.low", machine->= ram, + 0, lo_ram_size); + memory_region_init_alias(ram_hi, OBJECT(machine), "ram.high", machine-= >ram, + 0, hi_ram_size); + memory_region_add_subregion(system_memory, + s->memmap[TT_ATL_DDR_LO].base, ram_lo); + memory_region_add_subregion(system_memory, + s->memmap[TT_ATL_DDR_HI].base, ram_hi); + + /* Boot ROM */ + memory_region_init_rom(bootrom, NULL, "tt-atlantis.bootrom", + s->memmap[TT_ATL_BOOTROM].size, &error_fatal); + memory_region_add_subregion(system_memory, s->memmap[TT_ATL_BOOTROM].b= ase, + bootrom); + + /* UART */ + serial_mm_init(system_memory, s->memmap[TT_ATL_UART0].base, 2, + qdev_get_gpio_in(s->irqchip, TT_ATL_UART0_IRQ), + 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN); + + /* Load or create device tree */ + if (machine->dtb) { + machine->fdt =3D load_device_tree(machine->dtb, &s->fdt_size); + if (!machine->fdt) { + error_report("load_device_tree() failed"); + exit(1); + } + } else { + create_fdt(s); + } + + s->machine_done.notify =3D tt_atlantis_machine_done; + qemu_add_machine_init_done_notifier(&s->machine_done); +} + +static void tt_atlantis_machine_class_init(ObjectClass *oc, const void *da= ta) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->desc =3D "Tenstorrent Atlantis RISC-V SoC"; + mc->init =3D tt_atlantis_machine_init; + mc->max_cpus =3D 8; + mc->default_cpus =3D 8; + mc->default_ram_size =3D 2 * GiB; + mc->default_cpu_type =3D TYPE_RISCV_CPU_TT_ASCALON; + mc->block_default_type =3D IF_VIRTIO; + mc->no_cdrom =3D 1; + mc->default_ram_id =3D "tt_atlantis.ram"; +} + +static const TypeInfo tt_atlantis_types[] =3D { + { + .name =3D MACHINE_TYPE_NAME("tt-atlantis"), + .parent =3D TYPE_MACHINE, + .class_init =3D tt_atlantis_machine_class_init, + .instance_size =3D sizeof(TTAtlantisState), + }, +}; + +DEFINE_TYPES(tt_atlantis_types) diff --git a/include/hw/riscv/tt_atlantis.h b/include/hw/riscv/tt_atlantis.h new file mode 100644 index 0000000000..960dc07841 --- /dev/null +++ b/include/hw/riscv/tt_atlantis.h @@ -0,0 +1,51 @@ +/* + * Tenstorrent Atlantis RISC-V System on Chip + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright 2025 Tenstorrent, Joel Stanley + */ + +#ifndef HW_RISCV_TT_ATLANTIS_H +#define HW_RISCV_TT_ATLANTIS_H + +#include "hw/core/boards.h" +#include "hw/core/sysbus.h" +#include "hw/intc/riscv_imsic.h" +#include "hw/riscv/riscv_hart.h" + +#define TYPE_TT_ATLANTIS_MACHINE MACHINE_TYPE_NAME("tt-atlantis") +OBJECT_DECLARE_SIMPLE_TYPE(TTAtlantisState, TT_ATLANTIS_MACHINE) + +struct TTAtlantisState { + /*< private >*/ + MachineState parent; + + /*< public >*/ + Notifier machine_done; + const MemMapEntry *memmap; + + RISCVHartArrayState soc; + DeviceState *irqchip; + + int fdt_size; +}; + +enum { + TT_ATL_UART0_IRQ =3D 38, +}; + +enum { + TT_ATL_ACLINT, + TT_ATL_BOOTROM, + TT_ATL_DDR_LO, + TT_ATL_DDR_HI, + TT_ATL_MAPLIC, + TT_ATL_MIMSIC, + TT_ATL_SAPLIC, + TT_ATL_SIMSIC, + TT_ATL_TIMER, + TT_ATL_UART0, +}; + +#endif --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128860; cv=none; d=zohomail.com; s=zohoarc; b=fIbSFWg1kqPxBcCHgjS4d7ooZJXvrBxQUKQDDsI08m//SlUAdpEhxrCe1kWwYJaW/0QO+myo/GLAPPEVNuzOSTGU/oxK23E5WH/Fr/yYKYpTdQDFcUI6Yw+E0x1yecAvAOnm9NZiY0ag6MEWItTsNsgBKCLFIM2gHXn1yGJG/W8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128860; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b6oozqUu/iNCcUUmCAX8dgQSxE6ySmyL4OGkPFVC2WQ=; b=USFGE/a2b1m5dDvLmdwTYSF+ue/TBaan9x9p4DzKmNqrmdN8XwwjIcOQaAfKxoJoJERPbEH4aXkXBBt/25298zFSBrYiqK0MnxZKSEu9tzo8l0OR8kFRYEnSCf8GaUewawhUTWAR4qb58k1oPCrLTG57j656RiSnjbwrMiDU0k8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128860068386.5380378192706; Wed, 6 May 2026 21:41:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqX9-0000mj-B9; Thu, 07 May 2026 00:40:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqX8-0000mC-KZ for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:22 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqX7-00048n-3F for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:22 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-82f8b60e485so136849b3a.0 for ; Wed, 06 May 2026 21:40:20 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83965d36a12sm6575018b3a.27.2026.05.06.21.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128819; x=1778733619; darn=nongnu.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=b6oozqUu/iNCcUUmCAX8dgQSxE6ySmyL4OGkPFVC2WQ=; b=eIJ6CT3U6BLVNVjBI+F2zzz2xNfauCinwnZpzynk/F5zqnMPmTov6FdL2VQ925YHYI Owl9S4ys8CT6wKeLqP2utZd1zSuw7yo+vgft+rXJn/h8UmhTDNZ2m1Y3MR7ogMEwmh/N MfYGQtD4BPWVFGcK1kV0IdoVb/IUwv9b0Abc3Byz5OuyuXQCSr6Nzo39lCNleHTwtUOF ZDWV9zftXgONpf7GgNDL53HlZ16HPwE12tDyOL+3+QyZFAiCY0woG39vqbl0vHqqa0zI Lh5qEdRuv2L/ZhsOo8r1vb8+dTbZw5XL/qSisschBbIR8XmTpa8kkl/VAy/JE8X1dQTn uVVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128819; x=1778733619; 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=b6oozqUu/iNCcUUmCAX8dgQSxE6ySmyL4OGkPFVC2WQ=; b=Vv+bbMDSe8V/Os6ZD7Q34xij9SFkC25A7h5eTCEUsv83fyg13yKzCM7XGwgUC0Wfue SLlMkdEOs0SEgbcvNhgJ4gKFNyvODZ4idRX7WMRs85PFcxSLEd7quBk4G2qyyqD8D8fR ZfIPNCbdkC6w6UslLb0DjtrlGl6kazw9V+buPahhCiX9vYucuYSqjB4LuN4IF7igd5Nt UJ2PWdvopCxRZjKgCUxdaY0H/L0MwEwXbyqhm3VC+1Sb1vTi6EtZ3aEsv8UaTxpz2n5Y /wlGJwZDGHMX/re+md2P5xv3MDlWe9HjPpG4BC35WAuZbSkzCHN/yry+3t8WI3g4U7Bq ul5Q== X-Forwarded-Encrypted: i=1; AFNElJ98HfmIhXQ4iTw6T3DO/eenAZQBhgGg50yh9ccwW8+t+1iV2UG0OII6wMpjYQudDBr3TeroeKoAE+A5@nongnu.org X-Gm-Message-State: AOJu0YxjUIUtSsQeB2uW9F0i/e134lbUY7jNp81Ua7K+n6CjQrGsll8X 6HAtdubiiw9a/v5dUrG79W2IrmUY03snL8oSASAbaAf/bpqHyrXOHt2t X-Gm-Gg: AeBDietj3oXJjKbllE5FcnBc79MKmALxkzxx4edFwNw+HqLDmhu+yvydQNYh7MBzwqY 3e9VMM9+408u8y/RqfnPNo6ar+Sp95KCkQCG296kVRdxI6SglN5e3N697IO18PuyCZV1J3W+w/5 IS4iV0B4MGOf7KpYLDlSgpsAWc6gspk3pUtmLDYYoMavAxs7zOCryCN9EXQZG7tOFdv2HOnuRCe TQDlBIfZiE/5LRISpsnlfAxuOvOkRC63Bh8HPJ7k3CI7mepagCY9/x+NJ/rYCH7yMQ1VzjBjW1q 97r1emcWMXVb+KlSnxIMorlkXZnOjkeqFDWkpfb7Ln6zeH9dh1vJx5zkh1E4gE0G4ff5vl44LnN rNuJQ4s/GX71/jc9KPFWCOMgCEIfR5vt5bGFZtWps0mJKIS/F4kM53Gs2qfZRqI8L2VfPQh2DeO VQPD1qXNQPQIeKOsylggngNzLXZJYdCCHBsHu3gL0IbaVLfxzi2O1WS1wHn16x+ss4+ZTIGsntH 71R7Q0q X-Received: by 2002:a05:6a00:7084:b0:83b:a723:d704 with SMTP id d2e1a72fcca58-83ba723e38cmr1321314b3a.19.1778128819484; Wed, 06 May 2026 21:40:19 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Joel Stanley Subject: [PATCH v5 8/9] hw/riscv/atlantis: Provide a simple halting payload Date: Thu, 7 May 2026 14:38:36 +1000 Message-ID: <20260507043838.45652-9-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=npiggin@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128863046154100 Content-Type: text/plain; charset="utf-8" OpenSBI hangs before any console output if the domain init code sees the next stage is not in an executable region. If no kernel payload is provided to QEMU, the next stage address is NULL, and the riscv virt machine memory map ends up covering the 0 address with the catch all S-mode RWX region and so OpenSBI prints console messages and does not hang until the next stage boot. The Tenstorrent Atlantis machine address map has RAM starting at 0 and it loads OpenSBI there, so it is M-mode and not accessible by S-mode, tripping the early check and hang. Add a helper to set up a simple payload that gets OpenSBI messages to console, until OpenSBI can be fixed. Signed-off-by: Nicholas Piggin Reviewed-by: Daniel Henrique Barboza Signed-off-by: Joel Stanley Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/riscv/tt_atlantis.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/hw/riscv/tt_atlantis.c b/hw/riscv/tt_atlantis.c index 43f47fbd75..789a66870a 100644 --- a/hw/riscv/tt_atlantis.c +++ b/hw/riscv/tt_atlantis.c @@ -384,6 +384,30 @@ static void create_fdt(TTAtlantisState *s) create_fdt_pmu(s); } =20 +/* + * This works around a problem with OpenSBI hanging with no console output= if + * no payload is provided. By chance, machines with memory at 0x80000000 d= o get + * output, but Atlantis memory begins at 0x0 which takes a different OpenS= BI + * error path. + * + * This can be removed when OpenSBI is fixed in QEMU. + */ +static void tt_atlantis_setup_halting_payload_opensbi_fixup( + RISCVBootInfo *info, hwaddr addr) +{ + /* Store the payload vector in little_endian byte order */ + static const uint32_t payload_vec[] =3D { + const_le32(0x10500073), /* 1: wfi */ + const_le32(0xffdff06f), /* j 1b */ + }; + rom_add_blob_fixed_as("mrom.payload", payload_vec, sizeof(payload_vec), + addr, &address_space_memory); + + info->kernel_size =3D sizeof(payload_vec); + info->image_low_addr =3D addr; + info->image_high_addr =3D info->image_low_addr + info->kernel_size; +} + static void tt_atlantis_machine_done(Notifier *notifier, void *data) { TTAtlantisState *s =3D container_of(notifier, TTAtlantisState, machine= _done); @@ -421,6 +445,9 @@ static void tt_atlantis_machine_done(Notifier *notifier= , void *data) if (machine->kernel_filename) { riscv_load_kernel(machine, &boot_info, kernel_start_addr, true, NULL); + } else { + tt_atlantis_setup_halting_payload_opensbi_fixup(&boot_info, + kernel_start_addr); } kernel_entry =3D boot_info.image_low_addr; =20 --=20 2.53.0 From nobody Sat May 30 16:35:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1778128844; cv=none; d=zohomail.com; s=zohoarc; b=E4/M0PfEn8ekfoXyDMu2tM3ZsOtpJObG9tkhXAz7dPky96Befzo/Yu0CMU4qdHmTNRZJz4HLOyhq5ib7dHUCcvJi9bpkxeN26yolCQcavTuiGKX58nrxRde89g5aO52OjkFTwPdqtHJkqG0di2CIDYDxFWcWIkqG7SnRzUTQyFo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778128844; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QUD7XHPgCxrezwQ6+Da0nSaGVgnJAs27dGSg8/ZO85g=; b=b5uiuq8H6N9uEfYWHmEHLj6CTqqebnMlM6Yf5rTG7MkOAZU6Vj9FzqQ01Lv4pfSpfuUOvsGCTQ2LZ/ACgdoHolHANTrAaKiGy8gkya/lFJhBeSqEOtwiIiVG85bitIxUwdU2G46dpoLwi5lZrHWSFO/qiitHmunldKzX/yNssy8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1778128844437212.27537682402283; Wed, 6 May 2026 21:40:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wKqXF-0000p2-0l; Thu, 07 May 2026 00:40:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wKqXD-0000oD-8n for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:27 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wKqXB-00049W-6u for qemu-devel@nongnu.org; Thu, 07 May 2026 00:40:27 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2ad21f437eeso2537095ad.0 for ; Wed, 06 May 2026 21:40:24 -0700 (PDT) Received: from localhost (124.158.97.178.qld.leaptel.network. [124.158.97.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2babadee7c8sm9086415ad.57.2026.05.06.21.40.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 21:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778128824; x=1778733624; darn=nongnu.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=QUD7XHPgCxrezwQ6+Da0nSaGVgnJAs27dGSg8/ZO85g=; b=Kg/m3wavUezD6zkpZzOHEKTyPzVKHcNzD5alRnqheyl66Zr9IDSV+wwUGl8irCFu8/ BfBAZ4XOCRn/USGs6g8z5G4LbW322BnQQ4XGa+PWGuItVevMFizjRCU6qIyFoIev7gzI hJqyH9haOQErYAot5pMm6TPZa48P389c81t8iT1c2N3HmKCdAQAJVGJ3+RcGmum8fQs0 zIivbKCPdZBbAzlPuXi+zNnmHOMFNK2MTcg0fwvE/md8BJZ8LbsPBG8tmJHcQ7iUoQxz q8CNIhYlQKSgnSl1uBetEcM1Qh0F0MYowiuw25SuFoH9enK7Vhh5e35RK7dyHwgNxwab L2/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778128824; x=1778733624; 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=QUD7XHPgCxrezwQ6+Da0nSaGVgnJAs27dGSg8/ZO85g=; b=RDMN3ZGSMvLm4kzovC9eS3QKLt6bV9uZXf2W7QiXqPGcHRgVbWpWk9Mh2iAneJu56c RLMYFVz07rLHqJBBaW1+j/gMMOZ1cr5Pi0DDrJtHnu9qR/gLvNoEtIg8KpEnpDN5K0VA NhMag0F5Z5SeYbOsN1107+gxZ7mFiZGOlgZTVsGxSVROU99M4IzevlBRqShdvhtw5h+i tyAmSbqsB+zbJFgrDRPc5QexQqHtKM+R0XnTcu6g71ihfFNCXJw8MKyEj82DR9pydTqc kDzaVUP1fhvA1BjqMk7hNd8aHzwC2rCnSwNSWYxr3z9BkDVlhFuJGLbAWnUxHX6KE0eq IQzw== X-Forwarded-Encrypted: i=1; AFNElJ/BSL2HWAjLPXWZA54L5lS6o243alDBpsxzMAn2jezzXOMCboRLzAKgtTbB8fAyux1wIiS5T2HDl/iz@nongnu.org X-Gm-Message-State: AOJu0Ywn8l57zPtT0MqDQQ7DmnetWedQpTIXxUP6Z1M8QU+hhy9OVxC+ qAX9rgdqfJ87oHjWOuEj7e0tLF+Z6Onl5gXNcVSboKdM3ZAmWbs3vM9f X-Gm-Gg: AeBDiesbGUFWuij84mr5jiS5Hml0DETnF5Hal8T9VJrr4guQSRDU8l6+URv9NM3AN0a mgTaKEUkyROyGquPLIDuMkuV5V9PdFl/jJ0eV6mc2cHLs5624V7yiNe7Hviy8HQ8tlUip5mxBRi PxwDKdZxP8oxPpVLxijml0A7sY2Xi05E9ADcdIRztLhqifmcZQXhT1Ww2iVDDQ2c9KXrclWHB92 oQXXdv5prT24BgxEbRJpBHVDJIyOgUOBJsQFZ6EYzCvCYj103j0YgDGrSD1sP/gwgj9ceXZzVXv WvIoRup1mctp/Qw6QgzOF4nIWu7Mxf8RlX/djlJSZ02M60UwEhq6XdqZggqebn8iJ0HNunt0kBT a0MlXaeGEuNuyYgcA9mznx6bcxMSjbvsZX9PoQadMQrhy9u4TctZpwL/BgP8nbvm9storadYa2N pbR3NIjmGgms4khQuIOcnVsIsB/OrFI1veCoT0h/m59BRWlacFQ1V5CEaSgKS805eYedjvT3a+C wxkbY8MUZYA3jr4sz0= X-Received: by 2002:a17:903:2986:b0:2b4:6597:44d9 with SMTP id d9443c01a7336-2babc96104emr11118075ad.8.1778128823834; Wed, 06 May 2026 21:40:23 -0700 (PDT) From: Nicholas Piggin To: Alistair Francis , Daniel Henrique Barboza Cc: Nicholas Piggin , Chao Liu , Michael Ellerman , Joel Stanley , Anirudh Srinivasan , Portia Stephens , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Joel Stanley Subject: [PATCH v5 9/9] tests/functional/riscv64: Add tt-atlantis tests Date: Thu, 7 May 2026 14:38:37 +1000 Message-ID: <20260507043838.45652-10-npiggin@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260507043838.45652-1-npiggin@gmail.com> References: <20260507043838.45652-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=npiggin@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1778128846887154100 Add OpenSBI and Linux boot tests for the tt-atlantis machine. Based on tests/functional/riscv64/test_sifive_u.py. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Joel Stanley Signed-off-by: Nicholas Piggin --- MAINTAINERS | 1 + tests/functional/riscv64/meson.build | 1 + tests/functional/riscv64/test_opensbi.py | 4 ++ tests/functional/riscv64/test_tt_atlantis.py | 57 ++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100755 tests/functional/riscv64/test_tt_atlantis.py diff --git a/MAINTAINERS b/MAINTAINERS index 1ab5f3e45b..e106cadb81 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1776,6 +1776,7 @@ S: Supported F: docs/system/riscv/tt_*.rst F: hw/riscv/tt_*.c F: include/hw/riscv/tt_*.h +F: tests/functional/riscv64/test_tt_*.py =20 AMD Microblaze-V Generic Board M: Sai Pavan Boddu diff --git a/tests/functional/riscv64/meson.build b/tests/functional/riscv6= 4/meson.build index b996c89d7d..c4456fabd7 100644 --- a/tests/functional/riscv64/meson.build +++ b/tests/functional/riscv64/meson.build @@ -13,5 +13,6 @@ tests_riscv64_system_quick =3D [ tests_riscv64_system_thorough =3D [ 'boston', 'sifive_u', + 'tt_atlantis', 'tuxrun', ] diff --git a/tests/functional/riscv64/test_opensbi.py b/tests/functional/ri= scv64/test_opensbi.py index d077e40f42..0f8beb7e7a 100755 --- a/tests/functional/riscv64/test_opensbi.py +++ b/tests/functional/riscv64/test_opensbi.py @@ -28,6 +28,10 @@ def test_riscv_sifive_u(self): self.set_machine('sifive_u') self.boot_opensbi() =20 + def test_riscv_tt_atlantis(self): + self.set_machine('tt-atlantis') + self.boot_opensbi() + def test_riscv_virt(self): self.set_machine('virt') self.boot_opensbi() diff --git a/tests/functional/riscv64/test_tt_atlantis.py b/tests/functiona= l/riscv64/test_tt_atlantis.py new file mode 100755 index 0000000000..48abd5cd27 --- /dev/null +++ b/tests/functional/riscv64/test_tt_atlantis.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# Functional test that boots a Linux kernel on a Tenstorrent Atlantis mach= ine +# and checks the console +# +# Copyright (c) Linaro Ltd. +# Copyright 2026 Tenstorrent +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import Asset, LinuxKernelTest + + +class TTAtlantis(LinuxKernelTest): + + ASSET_KERNEL =3D Asset( + 'https://storage.tuxboot.com/kernels/6.11.9/riscv64/Image', + '174f8bb87f08961e54fa3fcd954a8e31f4645f6d6af4dd43983d5e9841490fb0') + ASSET_ROOTFS =3D Asset( + ('https://github.com/groeck/linux-build-test/raw/' + '9819da19e6eef291686fdd7b029ea00e764dc62f/rootfs/riscv64/' + 'rootfs.ext2.gz'), + 'b6ed95610310b7956f9bf20c4c9c0c05fea647900df441da9dfe767d24e8b28b') + + def do_test_riscv64_tt_atlantis(self, connect_disk): + self.set_machine('tt-atlantis') + kernel_path =3D self.ASSET_KERNEL.fetch() + rootfs_path =3D self.uncompress(self.ASSET_ROOTFS) + + self.vm.set_console() + kernel_command_line =3D self.KERNEL_COMMON_COMMAND_LINE + 'earlyco= n=3Dsbi ' + + if connect_disk: + kernel_command_line +=3D 'root=3D/dev/vda panic=3D-1 noreboot = rootwait ' + self.vm.add_args('-device', + 'virtio-blk,drive=3Ddrive0,serial=3D0x1234,bu= s=3Dpcie.0') + self.vm.add_args('-drive', + f'file=3D{rootfs_path},if=3Dnone,id=3Ddrive0,= format=3Draw') + pattern =3D 'Boot successful.' + else: + kernel_command_line +=3D 'panic=3D0 noreboot ' + pattern =3D 'Cannot open root device' + + self.vm.add_args('-kernel', kernel_path, + '-append', kernel_command_line, + '-no-reboot') + + self.vm.launch() + self.wait_for_console_pattern(pattern) + + def test_riscv64_tt_atlantis(self): + # tt-atlantis machine has no PCI host yet, so no disk + self.do_test_riscv64_tt_atlantis(False) + + +if __name__ =3D=3D '__main__': + LinuxKernelTest.main() --=20 2.53.0