From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672255; cv=none; d=zohomail.com; s=zohoarc; b=Qnizn5M3kIRuE2KhYjVJuyHwUyW6yInkY8GqTUR9uH5gEG35211C+qQ4Rm5fpJqgCyQ7WADrwqbxZHT3iAfeGOSLCm2xYSD8J/voEgAcFp2tTR0JayN0aYqMXL8eWrr1g1mvxrAUp7FmyuScKDbJIv4WVZRpE65Y7cjS9o9ytKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672255; 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=SUOXp0KMuwuEQ8v4SeRb+knalLC8nOeygatHRi5aG0s=; b=DOjEakLsfoZbUyUPjdMb+KWuuL6Q+aATakH4Z4IC3jYIXaq0mXqj6cpzEkg2XyF8Uf2cd2yJz6V40H7XO8Atjeo32gH+pGIGfcW/E55ogGhk2DVnmdxMVg8JD5D6SkRAfn6TyA4tX+rFr/c0pgvr5eSdnjuubYb3k/jt3Dt4Ugg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672255548853.7678715976363; Mon, 30 Oct 2023 06:24:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSCv-0006gY-Tj; Mon, 30 Oct 2023 09:21:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSCu-0006fj-AV for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:28 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSCh-0002ma-CG for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:28 -0400 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-2806cbd43b8so644273a91.3 for ; Mon, 30 Oct 2023 06:21:14 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672074; x=1699276874; 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=SUOXp0KMuwuEQ8v4SeRb+knalLC8nOeygatHRi5aG0s=; b=hnnS9KwXX/Z0crtQcK8FxOO4sC9pyyCHrITiBrpX43IsHQUsyt3yTK4W8tyHR3r+Rl EH6E1ZXmaHXnPMXDe80ZxAXrOti1BuhRkigStxIsWrqfUYFgZ0IHZ47NfKtpRK2n58Zc rM5SqQPiWjkA8lp6VLjD4T+yggYoliD40ZbzFLdc8Ckm0QCHB0f1A3rJrQupxlcJCc6B lrWU2yhGSErHpFOMeIodn+kTNzLdgn3bP5p5aa5Y5+gBTvOIVMnTzbWIoyyN44BY2a97 Xg06z0JTPAU0mG+Phhn7ofI6oTuI9mulWl37FGFEhkL5uaZMklwe6kv1shuruFjhB3U4 oIAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672074; x=1699276874; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SUOXp0KMuwuEQ8v4SeRb+knalLC8nOeygatHRi5aG0s=; b=OsHztHCLfCeG+1lZadrF3Qj7HA1XVT/NgLJLpMn8bNrldqziqtlJqapmk3Yw8YF6AA 9mh8+y6Od+lS0zy5K1NyVyw3IunyQ3baaU64t4KV0MHySbPSir0AX55iY1VYjAzya6yB 1JlHi9DVYwj647sAJGl3OL1kNdA23jAsF+tSTlTEpELxocogUFTBcrqZkCgsswXSenhg wiot9CB3l0K0ycDQmlBVUH4oXmqmUysYCvym7hsC9nPWYu1k5ucTaJ2Dq7Fg0btuWdDb iE1KoI+jX1HQFeknXUDYNr4rGnX3471BFaY9iiqOfQv/72zWpGzvN30fRlYx/G+Y4EAK 1uAQ== X-Gm-Message-State: AOJu0YxVE4ZeRIkwJ3s+lYzgQ/vL2tEB19zGu7UHpboa9m5+t57cX3d7 vX+qGbYh6/N79O1Dgo9r+M61TQA1PnLvX/YBCn5A3Q== X-Google-Smtp-Source: AGHT+IG4ylQBs6LZOhsOt0Se2nKd5BP3sMF8YJ6XfPfTPZ/u54QE72FuQedbmQH/RxpoHgCvOpHz2w== X-Received: by 2002:a17:90a:4b:b0:27f:f788:f950 with SMTP id 11-20020a17090a004b00b0027ff788f950mr7767621pjb.42.1698672073963; Mon, 30 Oct 2023 06:21:13 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 01/13] hw/arm/virt-acpi-build.c: Migrate fw_cfg creation to common location Date: Mon, 30 Oct 2023 18:50:46 +0530 Message-Id: <20231030132058.763556-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1036.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672256846100002 Content-Type: text/plain; charset="utf-8" RISC-V also needs to use the same code to create fw_cfg in DSDT. So, avoid code duplication by moving the code in arm and riscv to a device specific file. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Acked-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 19 ++----------------- hw/nvram/fw_cfg-acpi.c | 23 +++++++++++++++++++++++ hw/nvram/meson.build | 1 + hw/riscv/virt-acpi-build.c | 19 ++----------------- include/hw/nvram/fw_cfg_acpi.h | 15 +++++++++++++++ 5 files changed, 43 insertions(+), 34 deletions(-) create mode 100644 hw/nvram/fw_cfg-acpi.c create mode 100644 include/hw/nvram/fw_cfg_acpi.h diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 9ce136cd88..dd2e95f0ea 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -35,7 +35,7 @@ #include "target/arm/cpu.h" #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" -#include "hw/nvram/fw_cfg.h" +#include "hw/nvram/fw_cfg_acpi.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" @@ -94,21 +94,6 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapE= ntry *uart_memmap, aml_append(scope, dev); } =20 -static void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_mem= map) -{ - Aml *dev =3D aml_device("FWCF"); - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); - /* device present, functioning, decoding, not shown in UI */ - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base, - fw_cfg_memmap->size, AML_READ_WRITE= )); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); -} - static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memma= p) { Aml *dev, *crs; @@ -864,7 +849,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) if (vmc->acpi_expose_flash) { acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); } - acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]); + fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]); acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO], (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms= ); diff --git a/hw/nvram/fw_cfg-acpi.c b/hw/nvram/fw_cfg-acpi.c new file mode 100644 index 0000000000..4e48baeaa0 --- /dev/null +++ b/hw/nvram/fw_cfg-acpi.c @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Add fw_cfg device in DSDT + * + */ + +#include "hw/nvram/fw_cfg_acpi.h" +#include "hw/acpi/aml-build.h" + +void fw_cfg_acpi_dsdt_add(Aml *scope, const MemMapEntry *fw_cfg_memmap) +{ + Aml *dev =3D aml_device("FWCF"); + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); + /* device present, functioning, decoding, not shown in UI */ + aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + + Aml *crs =3D aml_resource_template(); + aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base, + fw_cfg_memmap->size, AML_READ_WRITE= )); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); +} diff --git a/hw/nvram/meson.build b/hw/nvram/meson.build index 75e415b1a0..4996c72456 100644 --- a/hw/nvram/meson.build +++ b/hw/nvram/meson.build @@ -17,3 +17,4 @@ system_ss.add(when: 'CONFIG_XLNX_EFUSE_ZYNQMP', if_true: = files( system_ss.add(when: 'CONFIG_XLNX_BBRAM', if_true: files('xlnx-bbram.c')) =20 specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_nvram.c')) +specific_ss.add(when: 'CONFIG_ACPI', if_true: files('fw_cfg-acpi.c')) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 7331248f59..d8772c2821 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -28,6 +28,7 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/utils.h" +#include "hw/nvram/fw_cfg_acpi.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/reset.h" @@ -97,22 +98,6 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtStat= e *s) } } =20 -static void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_mem= map) -{ - Aml *dev =3D aml_device("FWCF"); - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); - - /* device present, functioning, decoding, not shown in UI */ - aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base, - fw_cfg_memmap->size, AML_READ_WRITE= )); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); -} - /* RHCT Node[N] starts at offset 56 */ #define RHCT_NODE_ARRAY_OFFSET 56 =20 @@ -226,7 +211,7 @@ static void build_dsdt(GArray *table_data, scope =3D aml_scope("\\_SB"); acpi_dsdt_add_cpus(scope, s); =20 - acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]); + fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]); =20 aml_append(dsdt, scope); =20 diff --git a/include/hw/nvram/fw_cfg_acpi.h b/include/hw/nvram/fw_cfg_acpi.h new file mode 100644 index 0000000000..b6553d86fc --- /dev/null +++ b/include/hw/nvram/fw_cfg_acpi.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * ACPI support for fw_cfg + * + */ + +#ifndef FW_CFG_ACPI_H +#define FW_CFG_ACPI_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" + +void fw_cfg_acpi_dsdt_add(Aml *scope, const MemMapEntry *fw_cfg_memmap); + +#endif --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672200; cv=none; d=zohomail.com; s=zohoarc; b=QPST/eCr0VxQQ+nNamoQflwuxGEUSIVELPRzMfM09+hML9JGA30WScxZn3ekO7zluzsqRTGM5CNTg6n+akExsugCNKgMTYZPiLWFjoJl31om13QdM31S+Cdh9eng67687L+cvzFoLAB8LM1+rVkhei1Gp1M8i9G4wKPJIC1umn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672200; 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=/WGOkPkGN7tv/gSpkSvp7dZKwocQSlsYgp8ZegSWvEw=; b=mOLuL2rf3rOFBXQg9tHSQz8OjSlMH9ZV+zuu4OvJGGiqdlT8mGvp1vBzfOw+mfxs4v17hYWG2QoS9v3NCbdf+q6kI0TVQWfhLmTM+xt5fw6Oza9ciIdRObMNvP2+QijT3ce1KcpTaWxxPiG8gpyg90TjaCX0yOH/Ke8zJPi7ODU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672200389261.93005556785624; Mon, 30 Oct 2023 06:23:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSCx-0006hW-Mb; Mon, 30 Oct 2023 09:21:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSCv-0006gZ-UC for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:29 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSCo-0002p6-Cn for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:29 -0400 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-5a9bf4fbd3fso3508906a12.1 for ; Mon, 30 Oct 2023 06:21:20 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672080; x=1699276880; 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=/WGOkPkGN7tv/gSpkSvp7dZKwocQSlsYgp8ZegSWvEw=; b=lZ7sHuE+svFs/69m+Bi1x9hQXYgZE2M2fXTCWhDosBBOkhc0kLN28CiITB2/6vKc3J wXgVv6nSSOz0QOnU0GH24/ytTfAUVdfmw+0EOOFxSshCJlPhTPxzM28rMl5hcGNibDc8 HWSdhtDX0JywFhoS3oxd6bAZizXJ+CPViG0KKaTTcAskYtfcNMKnw2v7AooZA3ozwoUl HsRs7tzMUWKgYpXiHHgMtYsrdFkcB78z/U4RXqXU9la4ncE1tNCAp7hbwQXCzdbco2mL wtzib5qtKsUljvSQgRyh45q+uZ/5xjfI4RUPq3bo4J6aXKMQYK8Bh6rY29V7RIH6OMie 6ypg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672080; x=1699276880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/WGOkPkGN7tv/gSpkSvp7dZKwocQSlsYgp8ZegSWvEw=; b=pWQ3Iq3kqDrHGriyWnh5que4jPeejnOS4Gd2QyLyum2z9m0mB6HczLGcV2dFMbPD00 HhdWcBPQ1xTdmPI+qFkexY+AyYGMe8FOfYV813iXEYSQJt1NUg2F+CLWbRylgQwWOQ1z wNOZHmWKE3MC38Y4Mm4g+kn17jsIn/NFyzSMNiTkh27TV0k1IIuH2F33+GkKI9ezV4EO 8iJ8na79muoLf3Gaji5CcUhuYQi7gKI1Iofl6q016SbZMi+jDEWRzgt43JQWf8RWcGM3 GyYxvPFVytrU6NaFEuquNnnY4nl7TekoUDkK+uMhnIYp/2yL0UJColFTZfY1JOBwb08A Rxdg== X-Gm-Message-State: AOJu0Yx9yoqw3Pqfaf/clTOGdGGTn52fk0yHS/RrDdzEc5+hKkpJkYYx bn6/UhFczuu7gl6vFGZtqfgyMA== X-Google-Smtp-Source: AGHT+IFp4uDISJ4JbAUxYjg7kJAxiWnpWcOhtWgjw7N7aUOtB3hdXlZ6X5hfvXtmJeDmmgHUheBxXQ== X-Received: by 2002:a17:90a:2dca:b0:280:35d:4532 with SMTP id q10-20020a17090a2dca00b00280035d4532mr8841203pjm.14.1698672080074; Mon, 30 Oct 2023 06:21:20 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 02/13] hw/arm/virt-acpi-build.c: Migrate virtio creation to common location Date: Mon, 30 Oct 2023 18:50:47 +0530 Message-Id: <20231030132058.763556-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x531.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672201728100005 Content-Type: text/plain; charset="utf-8" RISC-V also needs to create the virtio in DSDT in the same way as ARM. So, instead of duplicating the code, move this function to the device specific file which is common across architectures. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Acked-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 32 ++++---------------------------- hw/virtio/meson.build | 1 + hw/virtio/virtio-acpi.c | 32 ++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-acpi.h | 16 ++++++++++++++++ 4 files changed, 53 insertions(+), 28 deletions(-) create mode 100644 hw/virtio/virtio-acpi.c create mode 100644 include/hw/virtio/virtio-acpi.h diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index dd2e95f0ea..b73ddd0c38 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -58,6 +58,7 @@ #include "migration/vmstate.h" #include "hw/acpi/ghes.h" #include "hw/acpi/viot.h" +#include "hw/virtio/virtio-acpi.h" =20 #define ARM_SPI_BASE 32 =20 @@ -118,32 +119,6 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemM= apEntry *flash_memmap) aml_append(scope, dev); } =20 -static void acpi_dsdt_add_virtio(Aml *scope, - const MemMapEntry *virtio_mmio_memmap, - uint32_t mmio_irq, int num) -{ - hwaddr base =3D virtio_mmio_memmap->base; - hwaddr size =3D virtio_mmio_memmap->size; - int i; - - for (i =3D 0; i < num; i++) { - uint32_t irq =3D mmio_irq + i; - Aml *dev =3D aml_device("VR%02u", i); - aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); - aml_append(dev, aml_name_decl("_UID", aml_int(i))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)); - aml_append(crs, - aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, - AML_EXCLUSIVE, &irq, 1)); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); - base +=3D size; - } -} - static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, uint32_t irq, VirtMachineState *vms) { @@ -850,8 +825,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); } fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]); - acpi_dsdt_add_virtio(scope, &memmap[VIRT_MMIO], - (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); + virtio_acpi_dsdt_add(scope, memmap[VIRT_MMIO].base, memmap[VIRT_MMIO].= size, + (irqmap[VIRT_MMIO] + ARM_SPI_BASE), + 0, NUM_VIRTIO_TRANSPORTS); acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms= ); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index c0055a7832..9d62097a21 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -79,3 +79,4 @@ system_ss.add(when: 'CONFIG_ALL', if_true: files('virtio-= stub.c')) system_ss.add(files('virtio-hmp-cmds.c')) =20 specific_ss.add_all(when: 'CONFIG_VIRTIO', if_true: specific_virtio_ss) +system_ss.add(when: 'CONFIG_ACPI', if_true: files('virtio-acpi.c')) diff --git a/hw/virtio/virtio-acpi.c b/hw/virtio/virtio-acpi.c new file mode 100644 index 0000000000..682283800f --- /dev/null +++ b/hw/virtio/virtio-acpi.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * virtio ACPI Support + * + */ + +#include "hw/virtio/virtio-acpi.h" +#include "hw/acpi/aml-build.h" + +void virtio_acpi_dsdt_add(Aml *scope, const hwaddr base, const hwaddr size, + uint32_t mmio_irq, long int start_index, int num) +{ + long int i; + hwaddr virtio_base =3D base; + + for (i =3D start_index; i < start_index + num; i++) { + uint32_t irq =3D mmio_irq + i; + Aml *dev =3D aml_device("VR%02u", (unsigned)i); + aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); + aml_append(dev, aml_name_decl("_UID", aml_int(i))); + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + + Aml *crs =3D aml_resource_template(); + aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)); + aml_append(crs, + aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &irq, 1)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + virtio_base +=3D size; + } +} diff --git a/include/hw/virtio/virtio-acpi.h b/include/hw/virtio/virtio-acp= i.h new file mode 100644 index 0000000000..844e102569 --- /dev/null +++ b/include/hw/virtio/virtio-acpi.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * ACPI support for virtio + */ + +#ifndef VIRTIO_ACPI_H +#define VIRTIO_ACPI_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" + +void virtio_acpi_dsdt_add(Aml *scope, const hwaddr virtio_mmio_base, + const hwaddr virtio_mmio_size, uint32_t mmio_irq, + long int start_index, int num); + +#endif --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672142; cv=none; d=zohomail.com; s=zohoarc; b=AOnPBfowv8WVWCfcW+zGouYyeEL7X9/bNkJVUUQnPXibN8p9GTk27pWdB+LJGlCzY2pQE7XhC6/2CaTOzJGp2/4Li45qgTU/DvHkOiW6pdkhjz4nTtE+2jNuoaWYz65YIxfFR2VdyAp+zYSiKX5FIrHc6BV9qiQlDTj+SVc1TUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672142; 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=Gj3Rp2NxdAvXLBlpU2SKgm21Lwc0GSM72ztmmw3HKvQ=; b=OZG2QuJJNv0LHJlpyvvpFYnsxcHK8inpvJ+0XYIaouQVeGT69keAuz/JdBkt3b7/2ehzrRFohn2+AzSKKjqxpqWnefHMxeol7n4eKaIv1fz+3dRg3Dx99IRGW+IMtn73zvrBqcz1M9YOGnpoZA8yo3pcboWsTMt/O4u6UU2gEkk= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672142189220.46528576109029; Mon, 30 Oct 2023 06:22:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSD0-0006k5-Pb; Mon, 30 Oct 2023 09:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSCw-0006hC-J5 for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:30 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSCt-0002qJ-Oc for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:30 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5a9bc2ec556so2960621a12.0 for ; Mon, 30 Oct 2023 06:21:27 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672086; x=1699276886; 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=Gj3Rp2NxdAvXLBlpU2SKgm21Lwc0GSM72ztmmw3HKvQ=; b=Z4tcBdnhGYzNgp2PWTWmFWhN7XqqWnymztnqBzUgR8wBpUw1rBn1X8lIPRfFtVmN8E avwRx+wuZeeNb8N44GKoUHSKvEzzqv7L8rxLDI2TJOVYnQKR95//Pmj6SceP9jxzWXZ9 cADrSKl/9kAeOHvKl9xSWE7UKw8j/InkqUh/Mf+oOTWVq8UL/4nA+DJcOmiSVM+qlEnl ds/dtH5ZEks7Uv1dEfm22I9HLyN0ApriMgNwGuXZCEbnQqrIKm9E2rXWT99GNOydnlC4 2YqzcrBy9ZRbuy8SRTxznxSimzY4I8f7SgCza3fgJJws0DWrY/DhM5b7lp+ckpNWWtwY TUjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672086; x=1699276886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gj3Rp2NxdAvXLBlpU2SKgm21Lwc0GSM72ztmmw3HKvQ=; b=okR1/amHR5njmzLvbT3YZRf4izgeTUCl2Dp19k8UZHsa5x+EOnMIQL4wFlwjtoAv1D 7YL/bMcelFWmEEPznbxYVtfgnIuikFq5mUk+RVD2M7rn1y2kmjhEr8IoYI44j1foCNrc 47vbg4Qvj++SPmm+xLeVrsKSvwqTnueDlJb1z8bcZhslPwhqO61O41RJbjXEIpGxuPDx /UBL/9Z01e8AhgoW46li2/euaNVO1OcWBOQIH1S/jqa+5gH8OlvACqrTJLsE5hjX9bwR ui6xoIPThH2BTj5Et+yfEENJ9v4NP0hOtOL8PSK9r1tNF6UO2IivqNCzpLK51vWm3LVm MzxQ== X-Gm-Message-State: AOJu0YwBVSSrU6co6fFA6J1Y7cO6LLnUvvYRK5FpRdAn0p5LxEQ55FQb 5dgvLUpapQxrl0I+aBcowWVPAMvnf1CmSXAOQf2FGQ== X-Google-Smtp-Source: AGHT+IHsyE+kY2OM78NC+lmK0fUqEDT7Rk+sOEyzlKG6O2ydwvXA8VxaJZ4hpsb0oEYw2bngxddfYw== X-Received: by 2002:a17:90a:199e:b0:280:9073:c474 with SMTP id 30-20020a17090a199e00b002809073c474mr335428pji.38.1698672086384; Mon, 30 Oct 2023 06:21:26 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 03/13] hw/i386/acpi-microvm.c: Use common function to add virtio in DSDT Date: Mon, 30 Oct 2023 18:50:48 +0530 Message-Id: <20231030132058.763556-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x535.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672142582100001 Content-Type: text/plain; charset="utf-8" With common function to add virtio in DSDT created now, update microvm code also to use it instead of duplicate code. Suggested-by: Andrew Jones Signed-off-by: Sunil V L Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/i386/acpi-microvm.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index 2909a73933..279da6b4aa 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -37,6 +37,7 @@ #include "hw/pci/pci.h" #include "hw/pci/pcie_host.h" #include "hw/usb/xhci.h" +#include "hw/virtio/virtio-acpi.h" #include "hw/virtio/virtio-mmio.h" #include "hw/input/i8042.h" =20 @@ -77,19 +78,7 @@ static void acpi_dsdt_add_virtio(Aml *scope, uint32_t irq =3D mms->virtio_irq_base + index; hwaddr base =3D VIRTIO_MMIO_BASE + index * 512; hwaddr size =3D 512; - - Aml *dev =3D aml_device("VR%02u", (unsigned)index); - aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); - aml_append(dev, aml_name_decl("_UID", aml_int(index))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); - - Aml *crs =3D aml_resource_template(); - aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)= ); - aml_append(crs, - aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_H= IGH, - AML_EXCLUSIVE, &irq, 1)); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); + virtio_acpi_dsdt_add(scope, base, size, irq, index, 1); } } } --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672141; cv=none; d=zohomail.com; s=zohoarc; b=jkQfVGtibrhhOGWkFFRi2guFRg3eUZ7rjs86nX7FAz+G/rvjlAegTtZeyvzJTWPkqlYhxnxJJQirTLhl02YCg+hhIpgurDVj7wDjQ9PmODqYX41NT7o0WuAhw392ngOD11f900PmvcPjMyaGRqbj4nPL56oqvxT14ByQc6lxb+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672141; 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=3MxEnwCcrzZXPmJ6j2nD9uSFRJXenxo4trg/FCDg9Lw=; b=EWAWFYgxtJ5rxPOlzHM3OQQrlvytBGMOZUrczxUa8/K5aqLuUUprD/Or5gQOmm4w5itrXf6jjU0QNZn2yQLw78RotKsaC1plik2l6gbADLBIvg5HKSr6FOngOm6SXqTzUKN8zyG+7LWSlGcTjbtGF+PddqKbrGsRLYAiw01DEOY= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169867214138722.328473590396356; Mon, 30 Oct 2023 06:22:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSD4-0006kp-ES; Mon, 30 Oct 2023 09:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSD2-0006kB-LV for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:36 -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 1qxSD0-0002rg-UD for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:36 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-5b92b852390so3296607a12.2 for ; Mon, 30 Oct 2023 06:21:33 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672092; x=1699276892; 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=3MxEnwCcrzZXPmJ6j2nD9uSFRJXenxo4trg/FCDg9Lw=; b=iQ8rYoxx8JAUnnEqzI2wu6a64DKimwaCWnnmdxpU/invdkfHpAX/eQ0xHEnFn48dDp 1raZlhHcpqPyBtsT9Wx6PU5Cyiqi+sJGkbhan1VEEKIc3jeDIsVSrhP1eTeKz8CY+RjF iVdV3tLuYnsgR7PTNRFwny8ivPhYb1rFWQcxRp+wvuyao4l9ZZrjM/FjUhpQxYPluyGm FKQKH9duZO3MXIKyWOOT2dCSfHGrXHp/GmH0uCVd109gpsLmSCjmBlhTvTakKWUKQM1j b+0t/RGjP21VouOsAjnu5qvSTzPYXP+e0IeKmTbi3HkLBkYJYAJCg+D2O2Bkyz+TP45d uEtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672092; x=1699276892; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3MxEnwCcrzZXPmJ6j2nD9uSFRJXenxo4trg/FCDg9Lw=; b=SOaGg3JjIx+6M0wmBJfBhq7W9k2MGFVHeSgUdU0IpJq0RSqmy9hGr3kGKpaBYiOAFq U32qn2+3qnDlaUgxvxnbQCMK8BR6EJ6qH+LZjApet0MPZfEsn2n+vSVw9FL+Y3nqPatu mHddGVM+vN0pnZ4Fd8npc+LnB+b/kTcvsjB+zeYJkTZMobCzSJQ3eNKCb9I04/7qoENq gQ0xbQx4KkCJ1663N2c0EJbNBoCVcyEAkq09s2Z5Lm+z981C1hNt2x/q1Pf60h1fNO8m CSd0RedvteIug7PUSKaVzoXHL5iW1jnUABjUIrtDLLBEgpkvYH9h1UX/S5BINTAN4a5h XRRA== X-Gm-Message-State: AOJu0YwSuzuePzzTYwP6d7GeR5Zdl91csjMU5y6fLAxpIZNtvLYfzlG+ SjpODVAbCDX+7i9w24qSepb/EQ== X-Google-Smtp-Source: AGHT+IGz9BoAuc1OxVm8essEWnuxVdFLX4kQQcS5JHc8mPj2AGMUy8cH8Vx5sndMSdnpV5frbPKPiA== X-Received: by 2002:a17:90a:28f:b0:280:1d67:16a6 with SMTP id w15-20020a17090a028f00b002801d6716a6mr6143828pja.34.1698672092478; Mon, 30 Oct 2023 06:21:32 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 04/13] hw/riscv: virt: Make few IMSIC macros and functions public Date: Mon, 30 Oct 2023 18:50:49 +0530 Message-Id: <20231030132058.763556-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=sunilvl@ventanamicro.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672142657100004 Content-Type: text/plain; charset="utf-8" Some macros and static function related to IMSIC are defined in virt.c. They are required in virt-acpi-build.c. So, make them public. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Acked-by: Michael S. Tsirkin --- hw/riscv/virt.c | 25 +------------------------ include/hw/riscv/virt.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 1732c42915..085654ab2f 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -38,7 +38,6 @@ #include "kvm/kvm_riscv.h" #include "hw/intc/riscv_aclint.h" #include "hw/intc/riscv_aplic.h" -#include "hw/intc/riscv_imsic.h" #include "hw/intc/sifive_plic.h" #include "hw/misc/sifive_test.h" #include "hw/platform-bus.h" @@ -54,28 +53,6 @@ #include "hw/acpi/aml-build.h" #include "qapi/qapi-visit-common.h" =20 -/* - * The virt machine physical address space used by some of the devices - * namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets, - * number of CPUs, and number of IMSIC guest files. - * - * Various limits defined by VIRT_SOCKETS_MAX_BITS, VIRT_CPUS_MAX_BITS, - * and VIRT_IRQCHIP_MAX_GUESTS_BITS are tuned for maximum utilization - * of virt machine physical address space. - */ - -#define VIRT_IMSIC_GROUP_MAX_SIZE (1U << IMSIC_MMIO_GROUP_MIN_SHIFT) -#if VIRT_IMSIC_GROUP_MAX_SIZE < \ - IMSIC_GROUP_SIZE(VIRT_CPUS_MAX_BITS, VIRT_IRQCHIP_MAX_GUESTS_BITS) -#error "Can't accommodate single IMSIC group in address space" -#endif - -#define VIRT_IMSIC_MAX_SIZE (VIRT_SOCKETS_MAX * \ - VIRT_IMSIC_GROUP_MAX_SIZE) -#if 0x4000000 < VIRT_IMSIC_MAX_SIZE -#error "Can't accommodate all IMSIC groups in address space" -#endif - /* KVM AIA only supports APLIC MSI. APLIC Wired is always emulated by QEMU= . */ static bool virt_use_kvm_aia(RISCVVirtState *s) { @@ -512,7 +489,7 @@ static void create_fdt_socket_plic(RISCVVirtState *s, g_free(plic_cells); } =20 -static uint32_t imsic_num_bits(uint32_t count) +uint32_t imsic_num_bits(uint32_t count) { uint32_t ret =3D 0; =20 diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index e5c474b26e..5b03575ed3 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -23,6 +23,7 @@ #include "hw/riscv/riscv_hart.h" #include "hw/sysbus.h" #include "hw/block/flash.h" +#include "hw/intc/riscv_imsic.h" =20 #define VIRT_CPUS_MAX_BITS 9 #define VIRT_CPUS_MAX (1 << VIRT_CPUS_MAX_BITS) @@ -127,4 +128,28 @@ enum { =20 bool virt_is_acpi_enabled(RISCVVirtState *s); void virt_acpi_setup(RISCVVirtState *vms); +uint32_t imsic_num_bits(uint32_t count); + +/* + * The virt machine physical address space used by some of the devices + * namely ACLINT, PLIC, APLIC, and IMSIC depend on number of Sockets, + * number of CPUs, and number of IMSIC guest files. + * + * Various limits defined by VIRT_SOCKETS_MAX_BITS, VIRT_CPUS_MAX_BITS, + * and VIRT_IRQCHIP_MAX_GUESTS_BITS are tuned for maximum utilization + * of virt machine physical address space. + */ + +#define VIRT_IMSIC_GROUP_MAX_SIZE (1U << IMSIC_MMIO_GROUP_MIN_SHIFT) +#if VIRT_IMSIC_GROUP_MAX_SIZE < \ + IMSIC_GROUP_SIZE(VIRT_CPUS_MAX_BITS, VIRT_IRQCHIP_MAX_GUESTS_BITS) +#error "Can't accomodate single IMSIC group in address space" +#endif + +#define VIRT_IMSIC_MAX_SIZE (VIRT_SOCKETS_MAX * \ + VIRT_IMSIC_GROUP_MAX_SIZE) +#if 0x4000000 < VIRT_IMSIC_MAX_SIZE +#error "Can't accomodate all IMSIC groups in address space" +#endif + #endif --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672193; cv=none; d=zohomail.com; s=zohoarc; b=WmP9CtLjxIQNvAJZG2Hy5ks0gi2hQO56TRiisdUxiws6RssRwXJ76MwzAMD1h8qcuKTmkO58WOSO+tF6ciim9BibjnxX1CPOr9uRUVKj6BrPybxskMLDtxIAgkdrOKjHDXOit+oLcJVqEhChaOTrLBxujz3KyU/y+PMrlj11Zig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672193; 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=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=bwlyRGLPWx7xYnP7kCHIFm7nqpNKcnzuFx9Jk3gYnr8ZUH2qoRVkWUA1hnc55cssOGn7skV4gkJ2b1i/wdMxcvMeaScEe2h1FapYX4DI7uYkU1C7X3WEg7Jzy7/89D+4xs5tAptrJZPacigjvNMJMHLzPAWKGf6cvNOVo68EavA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672193643416.95367183925873; Mon, 30 Oct 2023 06:23:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDX-00078I-DH; Mon, 30 Oct 2023 09:22:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDJ-0006vM-SG for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:55 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSD6-0002sX-PY for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:53 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-28003daaaa6so3333090a91.0 for ; Mon, 30 Oct 2023 06:21:39 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672099; x=1699276899; 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=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=lQQ4C7c3mRreoQkkHleTHMuw2zAwPWQzNo7UISTq9me0V6Dn4Pym9AFkavbuTypNEe dlcgdHUpxilD0BFCl8AImV+D3hiyrVQ+XgIcNnk+HAn6/QVuAVzgXL/K24O3ZS87wDYw /ohm7u/4nholELax1VGMPr57Plwnu8BQ2+kR+QrPmCimB+3lzBle0rI3lVEQ9uq0xpD+ uQp8hbWWHAhOkxthyq71E8ubTIsGDcupZxcCkMDZayxdKIyiGVVKQ0Bv9m92bo5AswIS nPNBpbVew7tsWsYkzX7jvCnuavWpMWT2fVqMwT93mwyr2URd3+zGvjzXJMnFxlsl8rB7 3rsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672099; x=1699276899; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=bGFaxMVnKqQUeWU+Bzw1mypWw96frZV7iP4Z0MFU23XEuNIKb+lUkyopDgvl9xaCZM 8EULNTyJBMxEWM7V92Abc4IGat4VmJgwQzByyOchxVREnPNIP9oCwnGiqInGvIuMwc5+ tm0IxJmA2f6zcibZPRn1XKSz/0695na38ZXvyRorkzBU/ZCUyY7teQ/IG3nE7IjhBlpK jsI5E0C2wFtf437YS2Vyr4xk/Z2bhzDc1wwnISHAgDUKTntm7z1g3wpTSLazEp9IcBxE S1Nce7GMmyI+Wj2jP8Tm6jk0hXIz3LN7uUmCFKfokboJvPa+9S1fcByZWbFmR4XHSUp4 oHrQ== X-Gm-Message-State: AOJu0Yy6tTcCUanEjKMYCq6/38X3uBBnwBNkh1ffDCear09fnLwR16YW JpZeH28z9ylTXZBuy8iF0Nd4cQ== X-Google-Smtp-Source: AGHT+IG96CFMPuZ4Y3n82YU8KOu7zNFWK4ESAx9dtVW5+uhXsKe8Ov5tQog9/m+WSVVJG8RvJIMU8A== X-Received: by 2002:a17:90a:53c7:b0:27d:63c:34f2 with SMTP id y65-20020a17090a53c700b0027d063c34f2mr8674243pjh.41.1698672098656; Mon, 30 Oct 2023 06:21:38 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 05/13] hw/riscv/virt-acpi-build.c: Add AIA support in RINTC Date: Mon, 30 Oct 2023 18:50:50 +0530 Message-Id: <20231030132058.763556-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1030.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672195686100003 Content-Type: text/plain; charset="utf-8" Update the RINTC structure in MADT with AIA related fields. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis Reviewed-by: Andrew Jones Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 43 ++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index d8772c2821..3f9536356e 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -38,6 +38,7 @@ #include "hw/intc/riscv_aclint.h" =20 #define ACPI_BUILD_TABLE_SIZE 0x20000 +#define ACPI_BUILD_INTC_ID(socket, index) ((socket << 24) | (index)) =20 typedef struct AcpiBuildState { /* Copy of table in RAM (for patching) */ @@ -59,17 +60,50 @@ static void acpi_align_size(GArray *blob, unsigned alig= n) =20 static void riscv_acpi_madt_add_rintc(uint32_t uid, const CPUArchIdList *arch_ids, - GArray *entry) + GArray *entry, + RISCVVirtState *s) { + uint8_t guest_index_bits =3D imsic_num_bits(s->aia_guests + 1); uint64_t hart_id =3D arch_ids->cpus[uid].arch_id; + uint32_t imsic_size, local_cpu_id, socket_id; + uint64_t imsic_socket_addr, imsic_addr; + MachineState *ms =3D MACHINE(s); =20 + socket_id =3D arch_ids->cpus[uid].props.node_id; + local_cpu_id =3D (arch_ids->cpus[uid].arch_id - + riscv_socket_first_hartid(ms, socket_id)) % + riscv_socket_hart_count(ms, socket_id); + imsic_socket_addr =3D s->memmap[VIRT_IMSIC_S].base + + (socket_id * VIRT_IMSIC_GROUP_MAX_SIZE); + imsic_size =3D IMSIC_HART_SIZE(guest_index_bits); + imsic_addr =3D imsic_socket_addr + local_cpu_id * imsic_size; build_append_int_noprefix(entry, 0x18, 1); /* Type */ - build_append_int_noprefix(entry, 20, 1); /* Length */ + build_append_int_noprefix(entry, 36, 1); /* Length */ build_append_int_noprefix(entry, 1, 1); /* Version */ build_append_int_noprefix(entry, 0, 1); /* Reserved */ build_append_int_noprefix(entry, 0x1, 4); /* Flags */ build_append_int_noprefix(entry, hart_id, 8); /* Hart ID */ build_append_int_noprefix(entry, uid, 4); /* ACPI Processor UID= */ + /* External Interrupt Controller ID */ + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { + build_append_int_noprefix(entry, + ACPI_BUILD_INTC_ID( + arch_ids->cpus[uid].props.node_id, + local_cpu_id), + 4); + } else { + build_append_int_noprefix(entry, 0, 4); + } + + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC) { + /* IMSIC Base address */ + build_append_int_noprefix(entry, imsic_addr, 8); + /* IMSIC Size */ + build_append_int_noprefix(entry, imsic_size, 4); + } else { + build_append_int_noprefix(entry, 0, 8); + build_append_int_noprefix(entry, 0, 4); + } } =20 static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) @@ -88,7 +122,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtStat= e *s) aml_int(arch_ids->cpus[i].arch_id))); =20 /* build _MAT object */ - riscv_acpi_madt_add_rintc(i, arch_ids, madt_buf); + riscv_acpi_madt_add_rintc(i, arch_ids, madt_buf, s); aml_append(dev, aml_name_decl("_MAT", aml_buffer(madt_buf->len, (uint8_t *)madt_buf->data))); @@ -227,6 +261,7 @@ static void build_dsdt(GArray *table_data, * 5.2.12 Multiple APIC Description Table (MADT) * REF: https://github.com/riscv-non-isa/riscv-acpi/issues/15 * https://drive.google.com/file/d/1R6k4MshhN3WTT-hwqAquu5nX6xSEqK2l/= view + * https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/= view */ static void build_madt(GArray *table_data, BIOSLinker *linker, @@ -246,7 +281,7 @@ static void build_madt(GArray *table_data, =20 /* RISC-V Local INTC structures per HART */ for (int i =3D 0; i < arch_ids->len; i++) { - riscv_acpi_madt_add_rintc(i, arch_ids, table_data); + riscv_acpi_madt_add_rintc(i, arch_ids, table_data, s); } =20 acpi_table_end(linker, &table); --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672196; cv=none; d=zohomail.com; s=zohoarc; b=ha8lNp5c0fHF9nJAOCOSNHGBlGnm/wvP6kmWfwbwbJnbY111oqiaebOssogqRf4aKRsdm+Syt2kU01G/exvitVugHL/2GZKq6mRhU/nRQhqEFq8fYnH1MMVxBAp6GFwQ8ISg8pPDOXe1BcH9+4XeGij/raAEi1de7T01RFJVjbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672196; 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=BIDV9HkogsPZri1ipsWFjw8pgoXgN2I+UnERgpGK/Yw=; b=k1Ok9QEEzmMxaA0L9Z+C6f334HbwyCiwEwLOjMHYRQZ671YyIF3YEb26lNIl2Dt03saztyFMAxXmzj3OxETQvGrt4ks2a1S0Av0MfwfUdjVxN2knndtwNxqHaZ++tu2CuJC1f7ZBlP9D7N9D7+kh3Ps2LKPkru0JA2DHXehZdlI= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672196223927.6450417104425; Mon, 30 Oct 2023 06:23:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDY-0007BA-5s; Mon, 30 Oct 2023 09:22:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDK-0006vT-VJ for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:55 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDC-0002t0-DI for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:54 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-2802c41b716so1046542a91.1 for ; Mon, 30 Oct 2023 06:21:45 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672105; x=1699276905; 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=BIDV9HkogsPZri1ipsWFjw8pgoXgN2I+UnERgpGK/Yw=; b=PJQb6V0/KsqFiOvUR8QwbKDVdSPW5nI6fAL7EMOQT4xNt0P2RYkP0w7OHJWsDSFMCS OrR/lku1Gm78xERUfDOVuXM95yz2E0LfBOYSI1OgL9gKe4mT4AcxLgI3ciW6RL9T0iPd /WD4fmmczQ8CzDGeGolj7QvHVjr/r7IkA/BgjoZoC3xAbBj0bJpP32+tQEknZHIzcx2J 7ZJK57S/djJpifFAoIh6MkMeFiGbjHzmZe+TmpQLruIev0uewwlEB4G+jdKCWtsO0vhL iwk1ZNymygTs1UyfCLme6mO+a4l+0yjxNdfb3NZuMOHTp7XtIfg/NavDcqBlDfRhTnRM lmbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672105; x=1699276905; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BIDV9HkogsPZri1ipsWFjw8pgoXgN2I+UnERgpGK/Yw=; b=Oo9SNW2pG8L6Qce3YMhqiJUR3jAh/XF3lKj4pjZ17SsZqsstxDv4sbCmb9z8nT9hMu IexqXsqlog1pgXUj7FsTzgt85X0mfKkRi3+cZPhPPIi1GpOVaBI1LBFWoF/eqpk6JwLe fsmqe3XOsVLbEUMlSPBo3z4sBLqrIMtf5LZha+6+tUt6DFyF+Rq+UWYalCpDebVptKe6 f3CvH14nf4AJ+33yPMD3ZLcHKNk0MwoceMynxx8lgZrNLa0ucpEoFOOHQQ3tICRHTQ3y +Rl8wC8IzWC3wAbpVTcMD7QDJ637ubZeDLEiVX6bTDKm6ApVVEDOi8jo8zyF65ZXWkHa 7mKA== X-Gm-Message-State: AOJu0Yxpuj0qhSBVqFVg7l4SGbCz9IM+K+awN7LncAOdl5bbhYCi23n1 h8NJjiwqsz3Yn/MSBpHGlOASvA== X-Google-Smtp-Source: AGHT+IFRPoFornQFbNfuWl2WYyq9+RZdueNk/du10rqKeTIuDl98LiiD1u7x8rg76lbExjP/rDLi8g== X-Received: by 2002:a17:90a:134c:b0:280:35ce:5e0f with SMTP id y12-20020a17090a134c00b0028035ce5e0fmr2556293pjf.11.1698672104692; Mon, 30 Oct 2023 06:21:44 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 06/13] hw/riscv/virt-acpi-build.c: Add IMSIC in the MADT Date: Mon, 30 Oct 2023 18:50:51 +0530 Message-Id: <20231030132058.763556-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1030.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672199661100003 Content-Type: text/plain; charset="utf-8" Add IMSIC structure in MADT when IMSIC is configured. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 3f9536356e..6bb21014fd 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -270,6 +270,19 @@ static void build_madt(GArray *table_data, MachineClass *mc =3D MACHINE_GET_CLASS(s); MachineState *ms =3D MACHINE(s); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(ms); + uint8_t group_index_bits =3D imsic_num_bits(riscv_socket_count(ms)); + uint8_t guest_index_bits =3D imsic_num_bits(s->aia_guests + 1); + uint16_t imsic_max_hart_per_socket =3D 0; + uint8_t hart_index_bits; + uint8_t socket; + + for (socket =3D 0; socket < riscv_socket_count(ms); socket++) { + if (imsic_max_hart_per_socket < s->soc[socket].num_harts) { + imsic_max_hart_per_socket =3D s->soc[socket].num_harts; + } + } + + hart_index_bits =3D imsic_num_bits(imsic_max_hart_per_socket); =20 AcpiTable table =3D { .sig =3D "APIC", .rev =3D 6, .oem_id =3D s->oem_= id, .oem_table_id =3D s->oem_table_id }; @@ -284,6 +297,28 @@ static void build_madt(GArray *table_data, riscv_acpi_madt_add_rintc(i, arch_ids, table_data, s); } =20 + /* IMSIC */ + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC) { + /* IMSIC */ + build_append_int_noprefix(table_data, 0x19, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + build_append_int_noprefix(table_data, 1, 1); /* Version */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + /* Number of supervisor mode Interrupt Identities */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_MSIS, 2); + /* Number of guest mode Interrupt Identities */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_MSIS, 2); + /* Guest Index Bits */ + build_append_int_noprefix(table_data, guest_index_bits, 1); + /* Hart Index Bits */ + build_append_int_noprefix(table_data, hart_index_bits, 1); + /* Group Index Bits */ + build_append_int_noprefix(table_data, group_index_bits, 1); + /* Group Index Shift */ + build_append_int_noprefix(table_data, IMSIC_MMIO_GROUP_MIN_SHIFT, = 1); + } + acpi_table_end(linker, &table); } =20 --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672256; cv=none; d=zohomail.com; s=zohoarc; b=M2n03nU1//qSIuo/IqS/GirbDdjAdmdDsSi33HrajB5x0WQd8JPibQptnjUgoAPtWwm/JfMzG0RqRCU9NyW+u+2oh4+2RxtoqEXRnEZ2TekEvSXV+5W/HvUinOkZJ/jmyZhdU3O2X6xn5D+TKpR2ly0ZUl+Z6YTv5qpi18IFzy8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672256; 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=ORc0KuU7dj7mwdwjtfEfqGad9JCJByagTk9Twvr3H/4=; b=SW424cuHA8LyOF/4Le/3p7HJ00zFuN5XFKz8plmNeqBFKbjl3laJ/21WjEMl67+BmlHTMPuMutsojlsVX14Ndpp3TBAB8Fkpze13k9Pe5FnNLOiMpvySbaHbT7rZlQChg4urGUupFsCruXjheqtkAYTaBCzrGrxgukPvix0IuFg= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672256336943.1571154786731; Mon, 30 Oct 2023 06:24:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDZ-0007Gj-UB; Mon, 30 Oct 2023 09:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDM-0006vi-Eq for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:58 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDI-0002ta-5B for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:56 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-28010522882so1986388a91.0 for ; Mon, 30 Oct 2023 06:21:51 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672111; x=1699276911; 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=ORc0KuU7dj7mwdwjtfEfqGad9JCJByagTk9Twvr3H/4=; b=DxtUE4+Gs7ieXiNBzH00YaG+EWZpQ381PzSqz0QqgdxlYNtFci2uTNOctJ23BYkelW jTmZI0t517azQfdVP8fR0QiPMAgG3CpalxqrHMfsXegFx2d3PqQtdigi5cASILBydrpM vnhciMZ7AJclYhJ2bcEAIO+GEqsoWF+OW16xxrlPMm3tRRWPQTRuSU0b0OKhy/0zlxMH m2BcaumRHqpMJ47WQvmwrOWpX1XewTphdACFDMAWXYsyscSh9SrADsvschaHQwLc5dvQ ryMI+d69NEEZ+CyjKTlcCTJbrpjk118s/6+tuzP8ZSC+jyEBd+hA/cdMtrCcGsDBQ9kU bWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672111; x=1699276911; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ORc0KuU7dj7mwdwjtfEfqGad9JCJByagTk9Twvr3H/4=; b=kOlaQdS4xZpfy02jqGVL8Dn2W6pGTzq+ul2kIE1q+Fn5AeQRiVGj1lNDAHG8CioOSK 4zrmi3cqRCn/6El4tM9fCucfQxKaAglXQRdVYqg13KrqWP3LL/1D7pOuwowHtTwvX7Bv jU3hIReQ9v6SAbvwxbHiN+86jbxrr7+JrmwTzedz3Q93sLv2hA7zyfHTXh4EMLnKdx1z sCwjk8WG5exgj5r/Q8gZoxZDAXTQ1FJDUTY6yjLO072LrxSp77gt7XrYZqPH2ETM++4k MknjtoioKvGAGwazQFM+agE6cE5NLzNIqDU7B2rd+PEqvXK5mX2NQZOe2ywe6la6g9O0 +aqg== X-Gm-Message-State: AOJu0YwzfHWIxFKsws2LA3kA6m/c6pI3lsYjf1RWfr3yZSHmo7My2YxN S+0rFOVjJeell3WBwxnfGMLzyQ== X-Google-Smtp-Source: AGHT+IEiOA519teQtjb2OiCJYdFLHS9hEJmlBI1mKCb6PR1+/9K+6FrWex+qs6uE++fWr93xGCHMqg== X-Received: by 2002:a17:90b:1a8d:b0:27d:3968:8366 with SMTP id ng13-20020a17090b1a8d00b0027d39688366mr7023209pjb.8.1698672110792; Mon, 30 Oct 2023 06:21:50 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 07/13] hw/riscv/virt-acpi-build.c: Add APLIC in the MADT Date: Mon, 30 Oct 2023 18:50:52 +0530 Message-Id: <20231030132058.763556-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102a.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672256825100001 Content-Type: text/plain; charset="utf-8" Add APLIC structures for each socket in the MADT when system is configured with APLIC as the external wired interrupt controller. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 6bb21014fd..ec49c8804b 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -274,6 +274,8 @@ static void build_madt(GArray *table_data, uint8_t guest_index_bits =3D imsic_num_bits(s->aia_guests + 1); uint16_t imsic_max_hart_per_socket =3D 0; uint8_t hart_index_bits; + uint64_t aplic_addr; + uint32_t gsi_base; uint8_t socket; =20 for (socket =3D 0; socket < riscv_socket_count(ms); socket++) { @@ -319,6 +321,38 @@ static void build_madt(GArray *table_data, build_append_int_noprefix(table_data, IMSIC_MMIO_GROUP_MIN_SHIFT, = 1); } =20 + if (s->aia_type !=3D VIRT_AIA_TYPE_NONE) { + /* APLICs */ + 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; + 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 = */ + build_append_int_noprefix(table_data, socket, 1); /* APLIC ID= */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + build_append_int_noprefix(table_data, 0, 8); /* Hardware= ID */ + /* Number of IDCs */ + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { + build_append_int_noprefix(table_data, + s->soc[socket].num_harts, + 2); + } else { + build_append_int_noprefix(table_data, 0, 2); + } + /* Total External Interrupt Sources Supported */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_SOURCES= , 2); + /* Global System Interrupt Base */ + build_append_int_noprefix(table_data, gsi_base, 4); + /* APLIC Address */ + build_append_int_noprefix(table_data, aplic_addr, 8); + /* APLIC size */ + build_append_int_noprefix(table_data, + s->memmap[VIRT_APLIC_S].size, 4); + } + } + acpi_table_end(linker, &table); } =20 --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672255; cv=none; d=zohomail.com; s=zohoarc; b=mccVlLgnb9YHBhaQpHcqtoYyIoJx2t3c3Z0DBKcQIL0jh3ZLVPumgvDFX4xpWqy9dyS2XygkYpXn2HT+3Uu9IP6SQ4aLzfT/dgmC+Q9C/Y1GlTwN2215x10D/zpjUcOrIDBw55eEvOi5aiu3C/gcW5gY8bTwp456FqRAtyIGTlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672255; 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=2vd4z02i5MUjS+md3dmfd4/u+HVQ03/wckr2cfGkWeU=; b=im6XsnaQjnhf++Zh6NQQOuS+rMX+SNhsfzlEOTtq9Qvw8QNesoU059a0Ct8jVDMVMFMSy2vCZ3j0Q2rcD3JQS9Vvp1vJoI2Nr7bQaUWGdOPqCdob3WfJpwmfCxAWqRAFab4Lgc2RvT2MnlwfO65zU3tCVK3DV29OPruAFu4Bgdc= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169867225504695.57286609225343; Mon, 30 Oct 2023 06:24:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDh-0007Ot-BU; Mon, 30 Oct 2023 09:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDV-00074U-Fh for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:06 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDP-0002ul-IF for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:05 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2802e5ae23bso1513985a91.2 for ; Mon, 30 Oct 2023 06:21:58 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672117; x=1699276917; 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=2vd4z02i5MUjS+md3dmfd4/u+HVQ03/wckr2cfGkWeU=; b=ghmFyvwn68lkuISEhWMAsIA3EkNl7OzbKlW0m6vVc+eSEdq3BWidiDYtq4jAfhlW4l MqXd29ddPvcC5NAKRc9Zs56cg9ZLSL++oz00O23/F5dqJBUFuiHYWb7N9OAPoJJcZGUs 3tapIM245t58N0FNqRzDk3cNajlDTPxRut3mrd7y7v1njiNufsSYgthTjR5/mEvvBRBW NU3w2QIQdUs2SgsP1ueusCjHtdV9J2WR65Gj370kRvDKp26Lh3L4tqT+1LJrNKjFFeVk zYlAw7/Yh9gIr8/2zkxSqQ9abtsHlMh+cDohER3Ukp017GlaH+nN61hKmufaj7MsS9PD NkdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672117; x=1699276917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2vd4z02i5MUjS+md3dmfd4/u+HVQ03/wckr2cfGkWeU=; b=plOloYTgvLT+rhj0NDL/HueRrQR248M+k6DfGs6P+IXZM8+dHxs+2SfT6eaDtqhx/h 5gYdEa7T3NCTrUMtPksnvvalnNyZGkWadzL9Gy+iUukNafAWPWDiZcFAl3/I4Avn6Zv1 n87k3RZG2pQzFz2Y1pF689QOB4cq9695z0lyLkqz63lC2Jrk7V1fQ0kGO1VSq3V6C91X 9Fa1Gf61wgjlZo0kEEY9kHCLW803dF2wkayBfHBgkJo4EcAqyaTBmo6bH29Tt3pf3VPi JH1QoPBt8fhD10Ktc5l7AysfUDF/Ul2HksonjxwB5lwIqERPVJbJO9tDp+loixyjXEmn ybkQ== X-Gm-Message-State: AOJu0YyukX9GUUWcreAHyQc03hqCe2/tykzdBg6/zS2OjqLwg/jy2iqV q8ul04nT9Ur9VKYSKQxwVelV4g== X-Google-Smtp-Source: AGHT+IHDn2wy02EXuXT0Z4Z9ussfO3Li6+pXvbXuj79ujZU3aZB55p46cV9v1FoQ+PeuLzhna42cJg== X-Received: by 2002:a17:90a:d101:b0:280:3f37:f8a1 with SMTP id l1-20020a17090ad10100b002803f37f8a1mr3705355pju.12.1698672116904; Mon, 30 Oct 2023 06:21:56 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 08/13] hw/riscv/virt-acpi-build.c: Add CMO information in RHCT Date: Mon, 30 Oct 2023 18:50:53 +0530 Message-Id: <20231030132058.763556-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102d.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672256880100006 Content-Type: text/plain; charset="utf-8" When CMO related extensions like Zicboz, Zicbom and Zicbop are enabled, the block size for those extensions need to be communicated via CMO node in RHCT. Add CMO node in RHCT if any of those CMO extensions are detected. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 64 +++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index ec49c8804b..506d487ede 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -140,6 +140,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtSta= te *s) * 5.2.36 RISC-V Hart Capabilities Table (RHCT) * REF: https://github.com/riscv-non-isa/riscv-acpi/issues/16 * https://drive.google.com/file/d/1nP3nFiH4jkPMp6COOxP6123DCZKR-tia/= view + * https://drive.google.com/file/d/1sKbOa8m1UZw1JkquZYe3F1zQBN1xXsaf/= view */ static void build_rhct(GArray *table_data, BIOSLinker *linker, @@ -149,8 +150,8 @@ static void build_rhct(GArray *table_data, MachineState *ms =3D MACHINE(s); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(ms); size_t len, aligned_len; - uint32_t isa_offset, num_rhct_nodes; - RISCVCPU *cpu; + uint32_t isa_offset, num_rhct_nodes, cmo_offset =3D 0; + RISCVCPU *cpu =3D &s->soc[0].harts[0]; char *isa; =20 AcpiTable table =3D { .sig =3D "RHCT", .rev =3D 1, .oem_id =3D s->oem_= id, @@ -166,6 +167,9 @@ static void build_rhct(GArray *table_data, =20 /* ISA + N hart info */ num_rhct_nodes =3D 1 + ms->smp.cpus; + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + num_rhct_nodes++; + } =20 /* Number of RHCT nodes*/ build_append_int_noprefix(table_data, num_rhct_nodes, 4); @@ -177,7 +181,6 @@ static void build_rhct(GArray *table_data, isa_offset =3D table_data->len - table.table_offset; build_append_int_noprefix(table_data, 0, 2); /* Type 0 */ =20 - cpu =3D &s->soc[0].harts[0]; isa =3D riscv_isa_string(cpu); len =3D 8 + strlen(isa) + 1; aligned_len =3D (len % 2) ? (len + 1) : len; @@ -193,14 +196,59 @@ static void build_rhct(GArray *table_data, build_append_int_noprefix(table_data, 0x0, 1); /* Optional Paddi= ng */ } =20 + /* CMO node */ + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + cmo_offset =3D table_data->len - table.table_offset; + build_append_int_noprefix(table_data, 1, 2); /* Type */ + build_append_int_noprefix(table_data, 10, 2); /* Length */ + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + + /* CBOM block size */ + if (cpu->cfg.cbom_blocksize) { + build_append_int_noprefix(table_data, + __builtin_ctz(cpu->cfg.cbom_blocksiz= e), + 1); + } else { + build_append_int_noprefix(table_data, 0, 1); + } + + /* CBOP block size */ + build_append_int_noprefix(table_data, 0, 1); + + /* CBOZ block size */ + if (cpu->cfg.cboz_blocksize) { + build_append_int_noprefix(table_data, + __builtin_ctz(cpu->cfg.cboz_blocksiz= e), + 1); + } else { + build_append_int_noprefix(table_data, 0, 1); + } + } + /* Hart Info Node */ for (int i =3D 0; i < arch_ids->len; i++) { + len =3D 16; + int num_offsets =3D 1; build_append_int_noprefix(table_data, 0xFFFF, 2); /* Type */ - build_append_int_noprefix(table_data, 16, 2); /* Length */ - build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ - build_append_int_noprefix(table_data, 1, 2); /* Number of offse= ts */ - build_append_int_noprefix(table_data, i, 4); /* ACPI Processor = UID */ - build_append_int_noprefix(table_data, isa_offset, 4); /* Offsets[0= ] */ + + /* Length */ + if (cmo_offset) { + len +=3D 4; + num_offsets++; + } + + build_append_int_noprefix(table_data, len, 2); + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + /* Number of offsets */ + build_append_int_noprefix(table_data, num_offsets, 2); + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor U= ID */ + + /* Offsets */ + build_append_int_noprefix(table_data, isa_offset, 4); + if (cmo_offset) { + build_append_int_noprefix(table_data, cmo_offset, 4); + } } =20 acpi_table_end(linker, &table); --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672145; cv=none; d=zohomail.com; s=zohoarc; b=nSbhI1Zt3NHSBBcIfwGt+tolnsvkjz2MRqwnzn9pBp1C+zdSbQFUNPl23ck8v6cEAlRri/h7qpqcLxRwhj9cAlQ+MyRz9m177YGHxeVrd/6jnvvNuppj591RQo1YoauhZsccwgyIY8nHgtI9KpmPxPdsGIsVETTgwou7hjjrTNM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672145; 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=KMqId8zOyBROAfCr/ApxNc76H4ky9nZ2QMykSoL/rsY=; b=iS3UCDHBVXw3NJpCRGbgjZP4uzKfZocQ5VdSpCqNqsuvKi5Ba3EHHnAqNXxulvBspcRxrNRdj7WgzHffn+dF1eIjOyTpzHSpi3jj5Y0Kdah+8Gm81bzoevBNTsaVhGH2vTJAOthFhjTDWhr30DgG5fPlt4txKOmmQhHRNzlkYiQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672145274494.52670840733106; Mon, 30 Oct 2023 06:22:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDi-0007U9-PA; Mon, 30 Oct 2023 09:22:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDb-0007Kb-DC for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:11 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDV-0002wh-6J for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:09 -0400 Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-5b7f3f470a9so2785317a12.0 for ; Mon, 30 Oct 2023 06:22:03 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:22:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672123; x=1699276923; 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=KMqId8zOyBROAfCr/ApxNc76H4ky9nZ2QMykSoL/rsY=; b=K8hSxs2adzuioHyQUmz3x01DYknUu/V+uO0xt66icezh/TPkwEdTYmOD06OHOndqmG E2vGfrbR2qHe+GouMnCLUBbvKqbtxkB+OdCJvO/LBW3jbSOfEESXt2a3zSK0uP2m7QGO yE4zXvoUqdzO3ywmFWUmCkY70puJMGF3f0y9D0jU/e1nWqH0lDxNl4lwHxvGq91ZkVnW MY1D7QUXh7R+MpvoKKcQoL/Ew/QwQrjZyB6Z2aC35eRCLBoSAsXHgVzQGH27TVVoB4S4 JESYu6R1JMKingqIU1xxfTJ1XzvBZZPgy7xITuq5LoBm8SI3QrilQtkgEc7R5Z/BhH7j XAVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672123; x=1699276923; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KMqId8zOyBROAfCr/ApxNc76H4ky9nZ2QMykSoL/rsY=; b=vTGAkmUzOcGrm0Mk7AgNKKKoaOEAjLRin6YBS/glTX5a+WHyxycOzCT8Aj3LFr6mUu QDhuI8PpgMP5eawFejftiJV7zeL1nwKY9ZavBVGQODheuyrQLva8L/EEAnRcQ3I9lJSX sKNAjzl130plLIW46rjXsshyKZNHGv6UR7LTsP0m2bGQZwBSYljEsj4HrugMdLWAA8kC 3BngSLk/3v8pzZ9uLSJ1664OBvqb7DJHhkNM7i6GuI1rXELVh2ZsrXQklR1IRX7xGLbi G7CUrGcydGADKILyUMi52+X2vjlAeZP86r6k5JYNVlxAomj7/ZM1qnD6cjUGhpHS1eSn uUVQ== X-Gm-Message-State: AOJu0Yw1BFFAm6AWeNsKkeQacwRQsmWlO7CyiNkePQkRhJ57QqhK258x oAcFrz0JDlEbOFQeeqo/OOWfXQ== X-Google-Smtp-Source: AGHT+IFOiulnjgN0kd/fyC1foDXEvjOurWfnQyH2RfEyEK/ZsXeI8o1Bm8bcLDOhbxM65z2GlhKrEw== X-Received: by 2002:a17:90a:ff17:b0:280:53b2:4b9f with SMTP id ce23-20020a17090aff1700b0028053b24b9fmr1914561pjb.20.1698672123012; Mon, 30 Oct 2023 06:22:03 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 09/13] hw/riscv/virt-acpi-build.c: Add MMU node in RHCT Date: Mon, 30 Oct 2023 18:50:54 +0530 Message-Id: <20231030132058.763556-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x535.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672146510100001 Content-Type: text/plain; charset="utf-8" MMU type information is available via MMU node in RHCT. Add this node in RHCT. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 506d487ede..86c38f7c2b 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -152,6 +152,8 @@ static void build_rhct(GArray *table_data, size_t len, aligned_len; uint32_t isa_offset, num_rhct_nodes, cmo_offset =3D 0; RISCVCPU *cpu =3D &s->soc[0].harts[0]; + uint32_t mmu_offset =3D 0; + uint8_t satp_mode_max; char *isa; =20 AcpiTable table =3D { .sig =3D "RHCT", .rev =3D 1, .oem_id =3D s->oem_= id, @@ -171,6 +173,10 @@ static void build_rhct(GArray *table_data, num_rhct_nodes++; } =20 + if (cpu->cfg.satp_mode.supported !=3D 0) { + num_rhct_nodes++; + } + /* Number of RHCT nodes*/ build_append_int_noprefix(table_data, num_rhct_nodes, 4); =20 @@ -226,6 +232,26 @@ static void build_rhct(GArray *table_data, } } =20 + /* MMU node structure */ + if (cpu->cfg.satp_mode.supported !=3D 0) { + satp_mode_max =3D satp_mode_max_from_map(cpu->cfg.satp_mode.map); + mmu_offset =3D table_data->len - table.table_offset; + build_append_int_noprefix(table_data, 2, 2); /* Type */ + build_append_int_noprefix(table_data, 8, 2); /* Length */ + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + /* MMU Type */ + if (satp_mode_max =3D=3D VM_1_10_SV57) { + build_append_int_noprefix(table_data, 2, 1); /* Sv57 */ + } else if (satp_mode_max =3D=3D VM_1_10_SV48) { + build_append_int_noprefix(table_data, 1, 1); /* Sv48 */ + } else if (satp_mode_max =3D=3D VM_1_10_SV39) { + build_append_int_noprefix(table_data, 0, 1); /* Sv39 */ + } else { + assert(1); + } + } + /* Hart Info Node */ for (int i =3D 0; i < arch_ids->len; i++) { len =3D 16; @@ -238,17 +264,25 @@ static void build_rhct(GArray *table_data, num_offsets++; } =20 + if (mmu_offset) { + len +=3D 4; + num_offsets++; + } + build_append_int_noprefix(table_data, len, 2); build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ /* Number of offsets */ build_append_int_noprefix(table_data, num_offsets, 2); build_append_int_noprefix(table_data, i, 4); /* ACPI Processor U= ID */ - /* Offsets */ build_append_int_noprefix(table_data, isa_offset, 4); if (cmo_offset) { build_append_int_noprefix(table_data, cmo_offset, 4); } + + if (mmu_offset) { + build_append_int_noprefix(table_data, mmu_offset, 4); + } } =20 acpi_table_end(linker, &table); --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672239; cv=none; d=zohomail.com; s=zohoarc; b=goRFY7j0DiG/H35BKCNQl38IL2BfycxOccFKqdbjgKA9FpabmPHh1Jo67F7MK7ZpfbdPMmLFj7lY4NrWD/Rha2V1tMlkUMxNPd4WT/3z9WdWC+m8eG9gMaXJgLldGiTwi2HZgMTvT9hDzwP0CdCYyCyQHhNwppF+R92dTgv1JaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672239; 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=n2AEKPFDQhVIMBEHE5TQIcbVSuyI4I2t6bJBUFDoioQ=; b=GLjJjh9BU8fC8zfGFSVbvBMppl3ECGRWqtor0iBZXk5j+Zm1l0yMDn1ZbXPMqmhzVdq0fa/xlorPiBgePTrSWndBfGyyBRagZ/aLbULErHoImLRVdCc0y3aeTdYUqqPcJyT1oV7oTJ7/Q4uOclkHxCtBNWETk9t4J5+mhpRR1YA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169867223914316.905310576152715; Mon, 30 Oct 2023 06:23:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDn-0007mb-F4; Mon, 30 Oct 2023 09:22:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDl-0007jA-Mx for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:21 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDb-0002xU-4R for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:21 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-5b9a7357553so447596a12.0 for ; Mon, 30 Oct 2023 06:22:10 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.22.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672129; x=1699276929; 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=n2AEKPFDQhVIMBEHE5TQIcbVSuyI4I2t6bJBUFDoioQ=; b=KzqZvIIKdBBu9aFVMMlvN5a4TxZrUz3/MPIiqj66MBpWkMUWJhcE/66iIuaUYBcpb+ b1ug5h9iePXM5s3ZvMB0Du954RpyEmPWczC0BlX9tgdzjaLFtnL1jqtFK/LCcnGPauXC MDYw4gHycmYdtGEtNfZbxySRGblZvQzi0U+rVmRIyD20XJIiCnbEiml8rWqG58bKWxkL 0YLvPCuJ2N9sBX/ukKXGjoWO7HQ2GlZkJRRKyiofNaKxCV7xM8AWrz+cwRJL/BNDHpJm VTNXcTXJWF0CymbsJvzsT6ruNtBrjiFRXnrwp1P2DpC+RIAt5cIQIvB+YcR7YYXJtI2j 7kRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672129; x=1699276929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n2AEKPFDQhVIMBEHE5TQIcbVSuyI4I2t6bJBUFDoioQ=; b=PaMS82cQFFY6kN1xTHt15w0H7wENEmfVCUEYqrfXFKQWvm0Dsrdn41mW9xwhGxMYWr BZN8CBcyli8HEetOarSe/epBFwL5UPNMdXopPvWGkmN9NiPa1dC+9kzK+lzZrU80DY2Q LSHfylyDz56QQc3kU1SflwchD/0lMfX2B48YOpd3EmAo2/IqK5Lnsj6W59AsKegzqF6q ofWMa8UeJD4C/nnYiV5gm46VkX6o0o0CfsoHfOOx5UIRB3hzOpByNlqdkSVf+wdPb45V rzvXKhemHih8+GL00M3bs3h9IVVGFPppNXfQ9zfy754unfa+AZCoBEBvwAUdk7mxaTVG mVNA== X-Gm-Message-State: AOJu0YyZs3wP4wnLZB8rXX9vqbEb/7o9IQNrLHuP1ds0JW6XQBFBWr/4 DG6GBc90pP0GG0yfTkh7ggtclQ== X-Google-Smtp-Source: AGHT+IGn0sU/9Ns0hPS88EmNIgP4uCAntWhgG+zcL0OomivcN87/L5Ewz3fPnrW3dBtQ6UE6dxyozQ== X-Received: by 2002:a17:90a:d497:b0:280:18ba:f016 with SMTP id s23-20020a17090ad49700b0028018baf016mr7121388pju.47.1698672128960; Mon, 30 Oct 2023 06:22:08 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L Subject: [PATCH v5 10/13] hw/pci-host/gpex: Define properties for MMIO ranges Date: Mon, 30 Oct 2023 18:50:55 +0530 Message-Id: <20231030132058.763556-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x52d.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672240323100001 Content-Type: text/plain; charset="utf-8" ACPI DSDT generator needs information like ECAM range, PIO range, 32-bit and 64-bit PCI MMIO range etc related to the PCI host bridge. Instead of making these values machine specific, create properties for the GPEX host bridge with default value 0. During initialization, the firmware can initialize these properties with correct values for the platform. This basically allows DSDT generator code independent of the machine specific memory map accesses. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin Reviewed-by: Daniel Henrique Barboza --- hw/pci-host/gpex-acpi.c | 13 +++++++++++++ hw/pci-host/gpex.c | 12 ++++++++++++ include/hw/pci-host/gpex.h | 28 ++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c index 1092dc3b70..f69413ea2c 100644 --- a/hw/pci-host/gpex-acpi.c +++ b/hw/pci-host/gpex-acpi.c @@ -281,3 +281,16 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig = *cfg) =20 crs_range_set_free(&crs_range_set); } + +void acpi_dsdt_add_gpex_host(Aml *scope, uint32_t irq) +{ + bool ambig; + Object *obj =3D object_resolve_path_type("", TYPE_GPEX_HOST, &ambig); + + if (!obj || ambig) { + return; + } + + GPEX_HOST(obj)->gpex_cfg.irq =3D irq; + acpi_dsdt_add_gpex(scope, &GPEX_HOST(obj)->gpex_cfg); +} diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index a6752fac5e..41f4e73f6e 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -154,6 +154,18 @@ static Property gpex_host_properties[] =3D { */ DEFINE_PROP_BOOL("allow-unmapped-accesses", GPEXHost, allow_unmapped_accesses, true), + DEFINE_PROP_UINT64(PCI_HOST_ECAM_BASE, GPEXHost, gpex_cfg.ecam.base, 0= ), + DEFINE_PROP_SIZE(PCI_HOST_ECAM_SIZE, GPEXHost, gpex_cfg.ecam.size, 0), + DEFINE_PROP_UINT64(PCI_HOST_PIO_BASE, GPEXHost, gpex_cfg.pio.base, 0), + DEFINE_PROP_SIZE(PCI_HOST_PIO_SIZE, GPEXHost, gpex_cfg.pio.size, 0), + DEFINE_PROP_UINT64(PCI_HOST_BELOW_4G_MMIO_BASE, GPEXHost, + gpex_cfg.mmio32.base, 0), + DEFINE_PROP_SIZE(PCI_HOST_BELOW_4G_MMIO_SIZE, GPEXHost, + gpex_cfg.mmio32.size, 0), + DEFINE_PROP_UINT64(PCI_HOST_ABOVE_4G_MMIO_BASE, GPEXHost, + gpex_cfg.mmio64.base, 0), + DEFINE_PROP_SIZE(PCI_HOST_ABOVE_4G_MMIO_SIZE, GPEXHost, + gpex_cfg.mmio64.size, 0), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h index b0240bd768..441c6b8b20 100644 --- a/include/hw/pci-host/gpex.h +++ b/include/hw/pci-host/gpex.h @@ -40,6 +40,15 @@ struct GPEXRootState { /*< public >*/ }; =20 +struct GPEXConfig { + MemMapEntry ecam; + MemMapEntry mmio32; + MemMapEntry mmio64; + MemMapEntry pio; + int irq; + PCIBus *bus; +}; + struct GPEXHost { /*< private >*/ PCIExpressHost parent_obj; @@ -55,19 +64,22 @@ struct GPEXHost { int irq_num[GPEX_NUM_IRQS]; =20 bool allow_unmapped_accesses; -}; =20 -struct GPEXConfig { - MemMapEntry ecam; - MemMapEntry mmio32; - MemMapEntry mmio64; - MemMapEntry pio; - int irq; - PCIBus *bus; + struct GPEXConfig gpex_cfg; }; =20 int gpex_set_irq_num(GPEXHost *s, int index, int gsi); =20 void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg); +void acpi_dsdt_add_gpex_host(Aml *scope, uint32_t irq); + +#define PCI_HOST_PIO_BASE "pio-base" +#define PCI_HOST_PIO_SIZE "pio-size" +#define PCI_HOST_ECAM_BASE "ecam-base" +#define PCI_HOST_ECAM_SIZE "ecam-size" +#define PCI_HOST_BELOW_4G_MMIO_BASE "below-4g-mmio-base" +#define PCI_HOST_BELOW_4G_MMIO_SIZE "below-4g-mmio-size" +#define PCI_HOST_ABOVE_4G_MMIO_BASE "above-4g-mmio-base" +#define PCI_HOST_ABOVE_4G_MMIO_SIZE "above-4g-mmio-size" =20 #endif /* HW_GPEX_H */ --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672186; cv=none; d=zohomail.com; s=zohoarc; b=K6pTdlvNbKD5SRf68U5ZgDoM7HpNucIEj/fK5+WOaL1EDlTGMMy0C5pxzqHJdXk+vQdvVBLh6ZgNUjZIGLF6N+gM8V+B2UJEq1/gaPReSwiosoYS4hvNG+bB5fG3PEOZmHBvyiSHG9VFhVs4+tMUwnYMGhfclGoSKAqIObKTL9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672186; 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=HncjleNoJsEGyqiT6wT23WVuZGRFARBjkFMSxC0xdSs=; b=jqqpk6L7Qh7w+Ff4nX6CA/tofevItO3YnbV41MStef1mSpH0mgINTuWgwT2tF1pK9impQrBPai2RcJIqiDwhShuxcXHrFSfchkLUjxf7wRBqWe1Q0ziBVeoTp29Wai5t1SND5P1K7JmQcRIKL9ySJ8DLnqQX2zXO7VFH5Xn0fD0= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672186628441.7905116609826; Mon, 30 Oct 2023 06:23:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDk-0007fj-Sx; Mon, 30 Oct 2023 09:22:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDj-0007YG-FA for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:19 -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 1qxSDg-0002yG-S3 for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:19 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2800bdf888dso2075911a91.1 for ; Mon, 30 Oct 2023 06:22:16 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672135; x=1699276935; 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=HncjleNoJsEGyqiT6wT23WVuZGRFARBjkFMSxC0xdSs=; b=TiVrR8/fPgVaos7XlA/Hl3CaTNuSF6Ll31KLYOcMa99qis36FAnt11ZP3eFSGdfTfT 8rJEmpL2ojvC9kQrEtYip/2mehWyo2bVf+Xe1erTkqbulpuQagfPgc2GbtUZvqL9MXrW 8vmWhUSl8UJH5Yn5wP9KxlmyjFel5Z6LhcV3zLQ89TuJb6PLP4RFYPRPR6cnqJPHLHOk 903HgZos7qyRZ9PIFNFruncHZquscoHxTMpD53aWaBLfBuJ2FonL9qOP+aElit2HLklU elGSwBtU/ELyscyuiRhr/GbsuUCs7Ylbj2/1jcTJ8VAKnDzDKCWM/5BWq3V4cR02SJi7 Tmfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672135; x=1699276935; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HncjleNoJsEGyqiT6wT23WVuZGRFARBjkFMSxC0xdSs=; b=sfer+ZyzbUT3XOh9Ow4PcJK0n+cphZE6+SD28HpQF79fyVL7Q2JPwHZcTe68guw6hs TN6l3VPTw8MGVRxG1pI/QV/jMhtGLXvzinhdVgnTAKzz5AkFtOW5Gir+GEY9GLQv/gsH qRDMMOukMi/ryKyj902njkdUYLzjIvxOF/MkCu1+AKSkmWYHni2Xz1cgUFpRm+ZiglXa LI7I6mtiB4fzpiJ4XeUe2R3Duce5vkGuZS1aBRE4hMYfWpy45QcLIrzhwltNErFEIg6C QGwANzbR7tKibn2SlNaOPHnL7CCIf9yp7mEpBvhVi2174Vsdb8X6N8bnajqv0wQTARah blBA== X-Gm-Message-State: AOJu0YzyMj6/ilJiTeS+BjFWRAnNMjp9TofzLupL+9ou8V4VUCe/Zgkn ybZoKh/42QezOSWAH1NTf3PbZg== X-Google-Smtp-Source: AGHT+IEFF4twgB756xgB8uVPWYYoejlQkHbWt7Wj4Mu/rTci7+/OYk0h7mibViZZHi4znGxHuPm/8g== X-Received: by 2002:a17:90a:590e:b0:277:68c3:64b9 with SMTP id k14-20020a17090a590e00b0027768c364b9mr16457349pji.5.1698672135057; Mon, 30 Oct 2023 06:22:15 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L Subject: [PATCH v5 11/13] hw/riscv/virt: Update GPEX MMIO related properties Date: Mon, 30 Oct 2023 18:50:56 +0530 Message-Id: <20231030132058.763556-12-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=sunilvl@ventanamicro.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672187339100001 Content-Type: text/plain; charset="utf-8" Update the GPEX host bridge properties related to MMIO ranges with values set for the virt machine. Suggested-by: Igor Mammedov Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt.c | 47 ++++++++++++++++++++++++++++------------- include/hw/riscv/virt.h | 1 + 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 085654ab2f..e64886a4d8 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1049,21 +1049,45 @@ static void create_fdt(RISCVVirtState *s, const Mem= MapEntry *memmap) } =20 static inline DeviceState *gpex_pcie_init(MemoryRegion *sys_mem, - hwaddr ecam_base, hwaddr ecam_si= ze, - hwaddr mmio_base, hwaddr mmio_si= ze, - hwaddr high_mmio_base, - hwaddr high_mmio_size, - hwaddr pio_base, - DeviceState *irqchip) + DeviceState *irqchip, + RISCVVirtState *s) { DeviceState *dev; MemoryRegion *ecam_alias, *ecam_reg; MemoryRegion *mmio_alias, *high_mmio_alias, *mmio_reg; + hwaddr ecam_base =3D s->memmap[VIRT_PCIE_ECAM].base; + hwaddr ecam_size =3D s->memmap[VIRT_PCIE_ECAM].size; + hwaddr mmio_base =3D s->memmap[VIRT_PCIE_MMIO].base; + hwaddr mmio_size =3D s->memmap[VIRT_PCIE_MMIO].size; + hwaddr high_mmio_base =3D virt_high_pcie_memmap.base; + hwaddr high_mmio_size =3D virt_high_pcie_memmap.size; + hwaddr pio_base =3D s->memmap[VIRT_PCIE_PIO].base; + hwaddr pio_size =3D s->memmap[VIRT_PCIE_PIO].size; qemu_irq irq; int i; =20 dev =3D qdev_new(TYPE_GPEX_HOST); =20 + /* Set GPEX object properties for the virt machine */ + object_property_set_uint(OBJECT(GPEX_HOST(dev)), PCI_HOST_ECAM_BASE, + ecam_base, NULL); + object_property_set_int(OBJECT(GPEX_HOST(dev)), PCI_HOST_ECAM_SIZE, + ecam_size, NULL); + object_property_set_uint(OBJECT(GPEX_HOST(dev)), + PCI_HOST_BELOW_4G_MMIO_BASE, + mmio_base, NULL); + object_property_set_int(OBJECT(GPEX_HOST(dev)), PCI_HOST_BELOW_4G_MMIO= _SIZE, + mmio_size, NULL); + object_property_set_uint(OBJECT(GPEX_HOST(dev)), + PCI_HOST_ABOVE_4G_MMIO_BASE, + high_mmio_base, NULL); + object_property_set_int(OBJECT(GPEX_HOST(dev)), PCI_HOST_ABOVE_4G_MMIO= _SIZE, + high_mmio_size, NULL); + object_property_set_uint(OBJECT(GPEX_HOST(dev)), PCI_HOST_PIO_BASE, + pio_base, NULL); + object_property_set_int(OBJECT(GPEX_HOST(dev)), PCI_HOST_PIO_SIZE, + pio_size, NULL); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); =20 ecam_alias =3D g_new0(MemoryRegion, 1); @@ -1094,6 +1118,7 @@ static inline DeviceState *gpex_pcie_init(MemoryRegio= n *sys_mem, gpex_set_irq_num(GPEX_HOST(dev), i, PCIE_IRQ + i); } =20 + GPEX_HOST(dev)->gpex_cfg.bus =3D PCI_HOST_BRIDGE(GPEX_HOST(dev))->bus; return dev; } =20 @@ -1492,15 +1517,7 @@ static void virt_machine_init(MachineState *machine) qdev_get_gpio_in(virtio_irqchip, VIRTIO_IRQ + i)); } =20 - gpex_pcie_init(system_memory, - memmap[VIRT_PCIE_ECAM].base, - memmap[VIRT_PCIE_ECAM].size, - memmap[VIRT_PCIE_MMIO].base, - memmap[VIRT_PCIE_MMIO].size, - virt_high_pcie_memmap.base, - virt_high_pcie_memmap.size, - memmap[VIRT_PCIE_PIO].base, - pcie_irqchip); + gpex_pcie_init(system_memory, pcie_irqchip, s); =20 create_platform_bus(s, mmio_irqchip); =20 diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 5b03575ed3..f89790fd58 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -61,6 +61,7 @@ struct RISCVVirtState { char *oem_table_id; OnOffAuto acpi; const MemMapEntry *memmap; + struct GPEXHost *gpex_host; }; =20 enum { --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672207; cv=none; d=zohomail.com; s=zohoarc; b=kvBKaOk5apy98G1/GO7hQy5ugUtj7Zsy4iYWApis9f1ksur+6OlShNI9Xc7gMXWZBk5LrbdKH2U5Nh6k4+TSD0x68FkyKnGKbcbXzgQMa+zimS1RFY7tRS+36fzMCZuj3ugGdaFiWzILdPIi1dN9x3WpIvY5NAeRVOV/MM0/4UU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672207; 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=+IAaldn5RVA9cV47Xi68k8nkyyuxtPnS4XmmOD4/W2k=; b=idENfjaWbTgwV3wiIBQ8FkymaE4/pnlIy2rr70L5BPshbnoEemdDfMXVZXojqUEtt714u+dvZtrnf575syF7zJvPs5ZnLH3wwcpEJkud7WkJFVgygGG2/45ueoyvCzAcypIbh1JGuy0gv0yeq1Xo59C9Is+a132Md742bgvSTm4= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672207640119.63551562885414; Mon, 30 Oct 2023 06:23:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDq-00084G-GH; Mon, 30 Oct 2023 09:22:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDp-0007yO-6e for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:25 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDm-0002zP-RQ for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:24 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-2800bb246ceso2015118a91.1 for ; Mon, 30 Oct 2023 06:22:22 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672141; x=1699276941; 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=+IAaldn5RVA9cV47Xi68k8nkyyuxtPnS4XmmOD4/W2k=; b=OtJzOM5khhIVTTBrdjmge4TP81lm/zwZR+LyvLQHY3YSl8zSvNhGlS+eIB5g8Hk+L/ YhrKOxl/BKBMvTUKbQo8PvlaOs7Jh5Xl37qIVRx3hm4Ja8a2snwE1+ehsdU6aYLJSkID EfX4+x4Q1UX5CjZbf2XChBITEbRCDDz6AZcCg6MsoQo21PAaGdeyuo/hCv3xcbQA5J4Q 7KoWPcbA64jWn0yDiLG7kJGR2ECiQVTOvV5XGgo5UGdEE9t4lESnQeOJyOxAKCFTpdzs z/ja4TH1eQpeRjcqjgYme6JvyeyhahlLGCGXVmeJUuVa7KCzOO83WUvTT38m3xl+oWYE 8RRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672141; x=1699276941; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+IAaldn5RVA9cV47Xi68k8nkyyuxtPnS4XmmOD4/W2k=; b=ixtZ8Z3LsLaLzMTJIa6jQKrjKKpmIjiQJslgmC75tmLpoEP+QA0tXLn4ntazFXDMxA dbNawVnaQhuUVx9/lkYm+quCMDXg8gXsebtQ+LPIihspMfzVNGxil+jsUmb67ZlqINR6 Yl9zYnHYGeB3xXBMj2khEBquL1FVUVmZv9g1Un6Nb5eVfGvzlQZ2TQy4wOOjIEOa6ak8 zAIozRoTS4762VvfcjR4j8lLkmqNEiSgPNBgnDOJ5uDLMro7C5zeuWsnYAH8q9EefjF1 tQlPoJw2pzP0gjMlz3sFq+rAysBlTMa3VWOkAlDrK07Cor643Z3Wpbaj1SvWj4o03QTC 604g== X-Gm-Message-State: AOJu0YzToi6tMYtVkDrEQZx1PmQwsPhFrd3CQAvA6bvveM917kHnwXi8 qCvzIScLpSeoZYdVUF0f4ZDCNQ== X-Google-Smtp-Source: AGHT+IGFDAt4dS5cm8wT+RdlCr2Uhn65HL5qGlloedulfJS0WA/kYnrMTDUkhX0Y1FbyEEr7uE9lVA== X-Received: by 2002:a17:90a:1a44:b0:280:24a:9141 with SMTP id 4-20020a17090a1a4400b00280024a9141mr7099148pjl.28.1698672141567; Mon, 30 Oct 2023 06:22:21 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L Subject: [PATCH v5 12/13] hw/riscv/virt-acpi-build.c: Add IO controllers and devices Date: Mon, 30 Oct 2023 18:50:57 +0530 Message-Id: <20231030132058.763556-13-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1034.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672209771100003 Content-Type: text/plain; charset="utf-8" Add basic IO controllers and devices like PCI, VirtIO and UART in the ACPI namespace. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/Kconfig | 1 + hw/riscv/virt-acpi-build.c | 79 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index b6a5eb4452..a50717be87 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -45,6 +45,7 @@ config RISCV_VIRT select FW_CFG_DMA select PLATFORM_BUS select ACPI + select ACPI_PCI =20 config SHAKTI_C bool diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 86c38f7c2b..4d03a27efd 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -27,15 +27,18 @@ #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/pci.h" #include "hw/acpi/utils.h" +#include "hw/intc/riscv_aclint.h" #include "hw/nvram/fw_cfg_acpi.h" +#include "hw/pci-host/gpex.h" +#include "hw/riscv/virt.h" +#include "hw/riscv/numa.h" +#include "hw/virtio/virtio-acpi.h" +#include "migration/vmstate.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "sysemu/reset.h" -#include "migration/vmstate.h" -#include "hw/riscv/virt.h" -#include "hw/riscv/numa.h" -#include "hw/intc/riscv_aclint.h" =20 #define ACPI_BUILD_TABLE_SIZE 0x20000 #define ACPI_BUILD_INTC_ID(socket, index) ((socket << 24) | (index)) @@ -132,6 +135,39 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtSt= ate *s) } } =20 +static void +acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, + uint32_t uart_irq) +{ + Aml *dev =3D aml_device("COM0"); + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0501"))); + aml_append(dev, aml_name_decl("_UID", aml_int(0))); + + Aml *crs =3D aml_resource_template(); + aml_append(crs, aml_memory32_fixed(uart_memmap->base, + uart_memmap->size, AML_READ_WRITE= )); + aml_append(crs, + aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &uart_irq, 1)); + aml_append(dev, aml_name_decl("_CRS", crs)); + + Aml *pkg =3D aml_package(2); + aml_append(pkg, aml_string("clock-frequency")); + aml_append(pkg, aml_int(3686400)); + + Aml *UUID =3D aml_touuid("DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301"); + + Aml *pkg1 =3D aml_package(1); + aml_append(pkg1, pkg); + + Aml *package =3D aml_package(2); + aml_append(package, UUID); + aml_append(package, pkg1); + + aml_append(dev, aml_name_decl("_DSD", package)); + aml_append(scope, dev); +} + /* RHCT Node[N] starts at offset 56 */ #define RHCT_NODE_ARRAY_OFFSET 56 =20 @@ -310,6 +346,8 @@ static void build_dsdt(GArray *table_data, RISCVVirtState *s) { Aml *scope, *dsdt; + MachineState *ms =3D MACHINE(s); + uint8_t socket_count; const MemMapEntry *memmap =3D s->memmap; AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 2, .oem_id =3D s->oem_= id, .oem_table_id =3D s->oem_table_id }; @@ -329,6 +367,29 @@ static void build_dsdt(GArray *table_data, =20 fw_cfg_acpi_dsdt_add(scope, &memmap[VIRT_FW_CFG]); =20 + socket_count =3D riscv_socket_count(ms); + + acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0], UART0_IRQ); + + if (socket_count =3D=3D 1) { + virtio_acpi_dsdt_add(scope, memmap[VIRT_VIRTIO].base, + memmap[VIRT_VIRTIO].size, + VIRTIO_IRQ, 0, VIRTIO_COUNT); + acpi_dsdt_add_gpex_host(scope, PCIE_IRQ); + } 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_COUNT); + acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + VIRT_IRQCHIP_NUM_SOURCES= ); + } else { + virtio_acpi_dsdt_add(scope, memmap[VIRT_VIRTIO].base, + memmap[VIRT_VIRTIO].size, + VIRTIO_IRQ + VIRT_IRQCHIP_NUM_SOURCES, 0, + VIRTIO_COUNT); + acpi_dsdt_add_gpex_host(scope, PCIE_IRQ + VIRT_IRQCHIP_NUM_SOURCES= * 2); + } + aml_append(dsdt, scope); =20 /* copy AML table into ACPI tables blob and patch header there */ @@ -465,6 +526,16 @@ static void virt_acpi_build(RISCVVirtState *s, AcpiBui= ldTables *tables) acpi_add_table(table_offsets, tables_blob); build_rhct(tables_blob, tables->linker, s); =20 + acpi_add_table(table_offsets, tables_blob); + { + AcpiMcfgInfo mcfg =3D { + .base =3D s->memmap[VIRT_PCIE_MMIO].base, + .size =3D s->memmap[VIRT_PCIE_MMIO].size, + }; + build_mcfg(tables_blob, tables->linker, &mcfg, s->oem_id, + s->oem_table_id); + } + /* XSDT is pointed to by RSDP */ xsdt =3D tables_blob->len; build_xsdt(tables_blob, tables->linker, table_offsets, s->oem_id, --=20 2.39.2 From nobody Wed Nov 27 11:42:09 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672218; cv=none; d=zohomail.com; s=zohoarc; b=BqzSB/OgwtrK6DjrH7LTq3QXwu8DRkV3NGr+umvNMl2JzM4YlVzUlPm7il2s1azbw/VJMr2eAiPkW/vk8LOu/AyyXqURZVUuhayCzmvv3Qsp2vu5izGh4jHe0nwkYY5ifEkcCQsVgyxPtvBnm36xOeioMjEphYhSECRHGvVqBi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672218; 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=2ClCKii7oO8Jb+60noegclT3zC+MTWH46ePT9qOzRUs=; b=i00o2wamNaEPGjoQYW6Dx14IPzDtvY5KZ9+vxMDG2fTIZtagiSxIynJr4jOp/nGnt2++DbXkd9yrIaK54CWOOA5L2El7YQ4qCc37h9o/cAXg4mTVqbVavJh9CjekSvWsD80T1D/ByLsXgtm1q7kfkd/vlqFsLOtQV0p/lUiV3P8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16986722187293.886584810462864; Mon, 30 Oct 2023 06:23:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSE0-0008Hz-DA; Mon, 30 Oct 2023 09:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxSDw-0008Cx-QC for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:32 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSDu-00030D-6j for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:22:32 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-5b9a7357553so447837a12.0 for ; Mon, 30 Oct 2023 06:22:29 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.22.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672148; x=1699276948; 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=2ClCKii7oO8Jb+60noegclT3zC+MTWH46ePT9qOzRUs=; b=GyD8UbEVtnHWcl34FzjTjFtpwzPHxjltG5eCHR15Hdw9scTjTTWJ0xIRPibLycIN6c iyeEJGjqqIQ6/DKuE2Imi4MMGRjZU8zkdyxs40eyxcx8WzyJOv3MQz9xeJanevbrJHWb BZJMJQT0jkQ+sfmJXMNhylk6cRKNtZJ9NyVMt3ApB6wUm6A3R86+DM7PRA6ystsQiUCv UdAfepUYbwMryN1JFKjVsTykw+veLOnhT4oDtOwhY2oaMJ7MZDAIAGSlO8x9vqkfuD8b owGc775gBIuvlRh0OcYbdGqW/VZcw6j864sOak0hFLZ8QENAQMhFTDkwe1V2b5eYJQnd Z4TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672148; x=1699276948; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2ClCKii7oO8Jb+60noegclT3zC+MTWH46ePT9qOzRUs=; b=XE16CXH0E2JRd8cS+VqVAenmAZFP1e/n1QXnZJ7fxl7CO6I7bXiG28vqlOz2IKX1Ns hyWi65P56C1KLtEjMGhjoQT3twZL/rkQkgAk3ssDQaJ344P4YM8eQIugCOkmpu0smRBJ Rnnnh1BufvJCOugp1Nxo+uBP+y14BliWVpsGwshue3WJCeZ/iaGXOqUM8G86jVyjXu3s B0DXWqQIKtCZcfsKzSW/tJJ0pwF3tdze2c4OvbMi0qLk01YdXHBf5MLs+SQdOvDJ9bpU u9Xctr475v4uOJ04/tQYvPFOkVx5PXrHF0JjLjMy0M0DamTCDz4Zkq9q7niv+2Js/tvW czgA== X-Gm-Message-State: AOJu0YwY6uShGcTzFq5BQPAEHmDoOGBZ1toVFLQibKMEApu5FWYj4rLH CdE7PlPfMSXOGM+b6KjivuEeWA== X-Google-Smtp-Source: AGHT+IE/T5pPchMg4rrYme6dNCLANmpnRIQWfq5epYmbIaaULYZlnOd9qwpmiDSKziNkj9bvzQZiXg== X-Received: by 2002:a17:90a:ac09:b0:280:19b8:83a6 with SMTP id o9-20020a17090aac0900b0028019b883a6mr6525499pjq.13.1698672148053; Mon, 30 Oct 2023 06:22:28 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 13/13] hw/riscv/virt-acpi-build.c: Add PLIC in MADT Date: Mon, 30 Oct 2023 18:50:58 +0530 Message-Id: <20231030132058.763556-14-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x536.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, 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: 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 @ventanamicro.com) X-ZM-MESSAGEID: 1698672219964100001 Content-Type: text/plain; charset="utf-8" Add PLIC structures for each socket in the MADT when system is configured with PLIC as the external interrupt controller. Signed-off-by: Haibo Xu Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 4d03a27efd..d4a02579d6 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -94,6 +94,12 @@ static void riscv_acpi_madt_add_rintc(uint32_t uid, arch_ids->cpus[uid].props.node_id, local_cpu_id), 4); + } else if (s->aia_type =3D=3D VIRT_AIA_TYPE_NONE) { + build_append_int_noprefix(entry, + ACPI_BUILD_INTC_ID( + arch_ids->cpus[uid].props.node_id, + 2 * local_cpu_id + 1), + 4); } else { build_append_int_noprefix(entry, 0, 4); } @@ -494,6 +500,29 @@ static void build_madt(GArray *table_data, build_append_int_noprefix(table_data, s->memmap[VIRT_APLIC_S].size, 4); } + } else { + /* PLICs */ + for (socket =3D 0; socket < riscv_socket_count(ms); socket++) { + aplic_addr =3D s->memmap[VIRT_PLIC].base + + s->memmap[VIRT_PLIC].size * socket; + gsi_base =3D VIRT_IRQCHIP_NUM_SOURCES * socket; + build_append_int_noprefix(table_data, 0x1B, 1); /* Type */ + build_append_int_noprefix(table_data, 36, 1); /* Length */ + build_append_int_noprefix(table_data, 1, 1); /* Version */ + build_append_int_noprefix(table_data, socket, 1); /* PLIC ID */ + build_append_int_noprefix(table_data, 0, 8); /* Hardware = ID */ + /* Total External Interrupt Sources Supported */ + build_append_int_noprefix(table_data, + VIRT_IRQCHIP_NUM_SOURCES - 1, 2); + build_append_int_noprefix(table_data, 0, 2); /* Max Priori= ty */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + /* PLIC Size */ + build_append_int_noprefix(table_data, s->memmap[VIRT_PLIC].siz= e, 4); + /* PLIC Address */ + build_append_int_noprefix(table_data, aplic_addr, 8); + /* Global System Interrupt Vector Base */ + build_append_int_noprefix(table_data, gsi_base, 4); + } } =20 acpi_table_end(linker, &table); --=20 2.39.2