From nobody Tue Nov 26 18:34:10 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; dmarc=pass(p=none dis=none) header.from=canonical.com ARC-Seal: i=1; a=rsa-sha256; t=1706035492; cv=none; d=zohomail.com; s=zohoarc; b=nUDOBs/4fTUO0kJKHULfu6pit27+rnnRdbCRl0bt7YTsveeF6LxJHflMKQTHeOQrAcAPidH342IuuU7hfA7ls6IyW+gGiJYM28HrqvDAFkjbjpZZVlorquFfxQVmYw7aNDTZB1fVUkyC1/c6WlVQBvkX3f5pVvRZjjbSiZWb3rM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706035492; 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=iGr0FnTYaT+qArrCpsR1nJW5AEkfoz2acQmeTnnwl5I=; b=Qu5btF97l9pzMAPwvUsQQoIaLmk6U0YAj/iyFsxTDnXLGC07/4LW5P0F+3yb4Kg6nvoV2k6Ru+gF7yM5lObdCwDQL8r3BBAzCUm21cvbpayq57EtsV4dLIC0dSHAEAovGQxr/tTYXLTAiLzaziFFco686wS6pi8MBlttARgYDvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1706035492434953.6078245494629; Tue, 23 Jan 2024 10:44:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSLkV-0004tp-05; Tue, 23 Jan 2024 13:43:51 -0500 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 1rSLkJ-0004lg-Ej for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:42 -0500 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSLkH-0002pA-8n for qemu-devel@nongnu.org; Tue, 23 Jan 2024 13:43:39 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F108C40A04 for ; Tue, 23 Jan 2024 18:43:19 +0000 (UTC) Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-339214f9199so2544409f8f.3 for ; Tue, 23 Jan 2024 10:43:19 -0800 (PST) Received: from workstation5.fritz.box (ip-178-202-040-247.um47.pools.vodafone-ip.de. [178.202.40.247]) by smtp.gmail.com with ESMTPSA id u9-20020a5d6ac9000000b00337d392c6c3sm14180252wrw.13.2024.01.23.10.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1706035399; bh=iGr0FnTYaT+qArrCpsR1nJW5AEkfoz2acQmeTnnwl5I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WIIYqj4ptsSdCYilcm1hp9CLZx0wgx8/S7mZeX/NdGZep0C8MRniWLS2nGHbUfoM8 64a3gVma3lcK6DgsrAxciMo0eai7eKk60j0JJF7E6OURlz3z2Jdw3aBX90gKraGmDW 3nQQnv6PO+EZgg0n2heeP92rLRo/jd4F+O+f9AszaDl8HfHSwQ5hW2cfA0acwZKRKb JtC4GkMlkOrs/YIENK0iAcm/9EAEPaE9Xhd6AM9aNGZtJkYFpNUt+msRmqL79Irr18 I7fi/vPysixdNJj3JHHvDcnpDVoclV7HNQBAOCj7jrzVQtACwFBFXXtiKAszI6Hxmc nO1NH5QuSiz+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706035393; x=1706640193; 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=iGr0FnTYaT+qArrCpsR1nJW5AEkfoz2acQmeTnnwl5I=; b=VpDWsG6hyimISun+UO0Q5fCTge0iDFn7cXjEKxlaEWO2GygOAHxzMDcmDsFgPFp5Zg EJKdhIGusZ/1TvpOOG09UCZS+vBYzgUHbnyijVQXfhgaVs+7hQf2M4Pnt3pVhYHyIEvD QrKDF2+muSVupQmPbrcAqyxapmZd09g+6wmNizcYBRy6Kv1N914TF6y+1g3L306IPZkO iXZbircMdQDUwU3YI14RxZ0UET5/pZZo+EbSR2gne00bU5eZ6S+c4jBDwdP/3dofskGW mwGs0dkvVqxhqT/hH3BI9J4LRYM4w9G55YQp3iqOA/fu1gmE03+aJGociZxMznW2I9pQ AXCA== X-Gm-Message-State: AOJu0Yx3nQpCyiJXzCzq/Mu/ELOhu9WNHU+r+f6zra1y+wpNdmB91trp wb0D4sSHWnCjoJ5OrM04r964hjSGeUxehT3PlseUj3AUYLA+VrOrecmN6/mPH8lqAW10sJRenjA RhASLS2l39+B41FwI3Rf86XDymyrMqIDd+UueOXmHaL3Kavdneb5KOjJzJJx5KmFysk2V X-Received: by 2002:adf:f243:0:b0:337:cdc5:daf4 with SMTP id b3-20020adff243000000b00337cdc5daf4mr3549855wrp.9.1706035393570; Tue, 23 Jan 2024 10:43:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhLhrfATAl+MbUI9CG7wf9yl5VnYt7D1KtWSc4Uw3hcCY/iekiY5zgW3rbp/1ejbrfypYWjg== X-Received: by 2002:adf:f243:0:b0:337:cdc5:daf4 with SMTP id b3-20020adff243000000b00337cdc5daf4mr3549842wrp.9.1706035393317; Tue, 23 Jan 2024 10:43:13 -0800 (PST) From: Heinrich Schuchardt To: Palmer Dabbelt , Alistair Francis Cc: Andrew Jones , Paolo Bonzini , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Heinrich Schuchardt Subject: [PATCH v4 3/4] target/riscv: SMBIOS support for RISC-V virt machine Date: Tue, 23 Jan 2024 19:42:28 +0100 Message-ID: <20240123184229.10415-4-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123184229.10415-1-heinrich.schuchardt@canonical.com> References: <20240123184229.10415-1-heinrich.schuchardt@canonical.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=185.125.188.123; envelope-from=heinrich.schuchardt@canonical.com; helo=smtp-relay-internal-1.canonical.com X-Spam_score_int: -56 X-Spam_score: -5.7 X-Spam_bar: ----- X-Spam_report: (-5.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.327, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @canonical.com) X-ZM-MESSAGEID: 1706035492920100002 Content-Type: text/plain; charset="utf-8" Generate SMBIOS tables for the RISC-V mach-virt. Add CONFIG_SMBIOS=3Dy to the RISC-V default config. Set the default processor family in the type 4 table. The implementation is based on the corresponding ARM and Loongson code. With the patch the following firmware tables are provided: etc/smbios/smbios-anchor etc/smbios/smbios-tables Signed-off-by: Heinrich Schuchardt Reviewed-by: Andrew Jones --- v4: remove a superfluous #ifdef v3: use misa_mxl_max to determine bitness v2: set processor family --- hw/riscv/Kconfig | 1 + hw/riscv/virt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index a50717be87..5d644eb7b1 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -41,6 +41,7 @@ config RISCV_VIRT select RISCV_IMSIC select SIFIVE_PLIC select SIFIVE_TEST + select SMBIOS select VIRTIO_MMIO select FW_CFG_DMA select PLATFORM_BUS diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index f9fd1341fc..1b333af4f0 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -36,6 +36,7 @@ #include "hw/riscv/boot.h" #include "hw/riscv/numa.h" #include "kvm/kvm_riscv.h" +#include "hw/firmware/smbios.h" #include "hw/intc/riscv_aclint.h" #include "hw/intc/riscv_aplic.h" #include "hw/intc/sifive_plic.h" @@ -1263,6 +1264,45 @@ static void create_platform_bus(RISCVVirtState *s, D= eviceState *irqchip) sysbus_mmio_get_region(sysbus, 0)); } =20 +static void virt_build_smbios(RISCVVirtState *s) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(s); + MachineState *ms =3D MACHINE(s); + uint8_t *smbios_tables, *smbios_anchor; + size_t smbios_tables_len, smbios_anchor_len; + struct smbios_phys_mem_area mem_array; + const char *product =3D "QEMU Virtual Machine"; + + if (kvm_enabled()) { + product =3D "KVM Virtual Machine"; + } + + smbios_set_defaults("QEMU", product, mc->name, false, + true, SMBIOS_ENTRY_POINT_TYPE_64); + + if (riscv_is_32bit(&s->soc[0])) { + smbios_set_default_processor_family(0x200); + } else { + smbios_set_default_processor_family(0x201); + } + + /* build the array of physical mem area from base_memmap */ + mem_array.address =3D s->memmap[VIRT_DRAM].base; + mem_array.length =3D ms->ram_size; + + smbios_get_tables(ms, &mem_array, 1, + &smbios_tables, &smbios_tables_len, + &smbios_anchor, &smbios_anchor_len, + &error_fatal); + + if (smbios_anchor) { + fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-tables", + smbios_tables, smbios_tables_len); + fw_cfg_add_file(s->fw_cfg, "etc/smbios/smbios-anchor", + smbios_anchor, smbios_anchor_len); + } +} + static void virt_machine_done(Notifier *notifier, void *data) { RISCVVirtState *s =3D container_of(notifier, RISCVVirtState, @@ -1351,6 +1393,8 @@ static void virt_machine_done(Notifier *notifier, voi= d *data) riscv_setup_direct_kernel(kernel_entry, fdt_load_addr); } =20 + virt_build_smbios(s); + if (virt_is_acpi_enabled(s)) { virt_acpi_setup(s); } --=20 2.43.0