* [PATCH 1/1] target/riscv: SMBIOS support for RISC-V virt machine
@ 2023-12-18 7:40 Heinrich Schuchardt
2023-12-18 8:49 ` Sunil V L
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2023-12-18 7:40 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Palmer Dabbelt, Alistair Francis, Bin Meng, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, qemu-riscv, qemu-devel,
Heinrich Schuchardt
Generate SMBIOS tables for the RISC-V mach-virt.
Add CONFIG_SMBIOS=y to the RISC-V default config.
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
Booting Ubuntu 23.10 via EDK II allowed displaying the SMBIOS table using
the dmidecode command:
Handle 0x0100, DMI type 1, 27 bytes
System Information
Manufacturer: QEMU
Product Name: QEMU Virtual Machine
Version: virt
...
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
hw/riscv/Kconfig | 1 +
hw/riscv/virt.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
index b6a5eb4452..1e11ac9432 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 d2eac24156..6c27cb5330 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/riscv_imsic.h"
@@ -1249,6 +1250,39 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)
sysbus_mmio_get_region(sysbus, 0));
}
+static void virt_build_smbios(RISCVVirtState *s)
+{
+ MachineClass *mc = MACHINE_GET_CLASS(s);
+ MachineState *ms = 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 = "QEMU Virtual Machine";
+
+ if (kvm_enabled()) {
+ product = "KVM Virtual Machine";
+ }
+
+ smbios_set_defaults("QEMU", product, mc->name, false,
+ true, SMBIOS_ENTRY_POINT_TYPE_64);
+
+ /* build the array of physical mem area from base_memmap */
+ mem_array.address = s->memmap[VIRT_DRAM].base;
+ mem_array.length = 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 = container_of(notifier, RISCVVirtState,
@@ -1337,6 +1371,8 @@ static void virt_machine_done(Notifier *notifier, void *data)
riscv_setup_direct_kernel(kernel_entry, fdt_load_addr);
}
+ virt_build_smbios(s);
+
if (virt_is_acpi_enabled(s)) {
virt_acpi_setup(s);
}
--
2.40.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] target/riscv: SMBIOS support for RISC-V virt machine
2023-12-18 7:40 [PATCH 1/1] target/riscv: SMBIOS support for RISC-V virt machine Heinrich Schuchardt
@ 2023-12-18 8:49 ` Sunil V L
2023-12-18 9:23 ` Heinrich Schuchardt
0 siblings, 1 reply; 3+ messages in thread
From: Sunil V L @ 2023-12-18 8:49 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Paolo Bonzini, Palmer Dabbelt, Alistair Francis, Bin Meng,
Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei, qemu-riscv,
qemu-devel
Hi Heinrich,
Thanks for the patch!.
On Mon, Dec 18, 2023 at 08:40:18AM +0100, Heinrich Schuchardt wrote:
> Generate SMBIOS tables for the RISC-V mach-virt.
> Add CONFIG_SMBIOS=y to the RISC-V default config.
>
> 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
>
> Booting Ubuntu 23.10 via EDK II allowed displaying the SMBIOS table using
> the dmidecode command:
>
> Handle 0x0100, DMI type 1, 27 bytes
> System Information
> Manufacturer: QEMU
> Product Name: QEMU Virtual Machine
> Version: virt
> ...
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> hw/riscv/Kconfig | 1 +
> hw/riscv/virt.c | 36 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 37 insertions(+)
>
> diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
> index b6a5eb4452..1e11ac9432 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 d2eac24156..6c27cb5330 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/riscv_imsic.h"
> @@ -1249,6 +1250,39 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)
> sysbus_mmio_get_region(sysbus, 0));
> }
>
> +static void virt_build_smbios(RISCVVirtState *s)
> +{
Can we avoid duplicating this function which exists in other
architectures?
Thanks,
Sunil
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] target/riscv: SMBIOS support for RISC-V virt machine
2023-12-18 8:49 ` Sunil V L
@ 2023-12-18 9:23 ` Heinrich Schuchardt
0 siblings, 0 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2023-12-18 9:23 UTC (permalink / raw)
To: Sunil V L
Cc: Paolo Bonzini, Palmer Dabbelt, Alistair Francis, Bin Meng,
Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei, qemu-riscv,
qemu-devel
On 12/18/23 09:49, Sunil V L wrote:
> Hi Heinrich,
>
> Thanks for the patch!.
>
> On Mon, Dec 18, 2023 at 08:40:18AM +0100, Heinrich Schuchardt wrote:
>> Generate SMBIOS tables for the RISC-V mach-virt.
>> Add CONFIG_SMBIOS=y to the RISC-V default config.
>>
>> 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
>>
>> Booting Ubuntu 23.10 via EDK II allowed displaying the SMBIOS table using
>> the dmidecode command:
>>
>> Handle 0x0100, DMI type 1, 27 bytes
>> System Information
>> Manufacturer: QEMU
>> Product Name: QEMU Virtual Machine
>> Version: virt
>> ...
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> hw/riscv/Kconfig | 1 +
>> hw/riscv/virt.c | 36 ++++++++++++++++++++++++++++++++++++
>> 2 files changed, 37 insertions(+)
>>
>> diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig
>> index b6a5eb4452..1e11ac9432 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 d2eac24156..6c27cb5330 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/riscv_imsic.h"
>> @@ -1249,6 +1250,39 @@ static void create_platform_bus(RISCVVirtState *s, DeviceState *irqchip)
>> sysbus_mmio_get_region(sysbus, 0));
>> }
>>
>> +static void virt_build_smbios(RISCVVirtState *s)
>> +{
> Can we avoid duplicating this function which exists in other
> architectures?
>
Every architecture uses it own structures (e.g. RISCVVirtState) and
constants (e.g VIRT_DRAM). As long as this is not addressed we will have
to live with this piece of code duplication.
After this patch is accepted we will have to work on improving SMBIOS
3.7.0 compliance:
* Table 22
* * field Processor Family should contain a RISC-V specfic value. Maybe
derived from TARGET_RISCV##.
* * field Processor ID should contain the value of mvendorid of hart 0
(i.e. cpu->cfg.mvendorid).
* Table 44
The required contents of this table are provided in
https://github.com/riscv/riscv-smbios .
Best regards
Heinrich
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-18 9:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 7:40 [PATCH 1/1] target/riscv: SMBIOS support for RISC-V virt machine Heinrich Schuchardt
2023-12-18 8:49 ` Sunil V L
2023-12-18 9:23 ` Heinrich Schuchardt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.