[PATCH v2 1/4] smbios: add processor-family option

Heinrich Schuchardt posted 4 patches 11 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <alistair.francis@wdc.com>, Bin Meng <bin.meng@windriver.com>, Weiwei Li <liwei1518@gmail.com>, Daniel Henrique Barboza <dbarboza@ventanamicro.com>, Liu Zhiwei <zhiwei_liu@linux.alibaba.com>, "Michael S. Tsirkin" <mst@redhat.com>, Igor Mammedov <imammedo@redhat.com>, Ani Sinha <anisinha@redhat.com>
There is a newer version of this series
[PATCH v2 1/4] smbios: add processor-family option
Posted by Heinrich Schuchardt 11 months ago
For RISC-V the SMBIOS standard requires specific values of the processor
family value depending on the bitness of the CPU.

Add a processor-family option for SMBIOS table 4.

The value of processor-family may exceed 255 and therefore must be provided
in the Processor Family 2 field. Set the Processor Family field to 0xFE
which signals that the Processor Family 2 is used.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	new patch
---
 hw/smbios/smbios.c | 13 +++++++++++--
 qemu-options.hx    |  4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 2a90601ac5..647bc6d603 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -102,6 +102,7 @@ static struct {
 #define DEFAULT_CPU_SPEED 2000
 
 static struct {
+    uint16_t processor_family;
     const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
     uint64_t max_speed;
     uint64_t current_speed;
@@ -110,6 +111,7 @@ static struct {
     .max_speed = DEFAULT_CPU_SPEED,
     .current_speed = DEFAULT_CPU_SPEED,
     .processor_id = 0,
+    .processor_family = 0x01, /* Other */
 };
 
 struct type8_instance {
@@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
         .name = "part",
         .type = QEMU_OPT_STRING,
         .help = "part number",
+    }, {
+        .name = "processor-family",
+        .type = QEMU_OPT_NUMBER,
+        .help = "processor family",
     }, {
         .name = "processor-id",
         .type = QEMU_OPT_NUMBER,
@@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
     snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
     SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
     t->processor_type = 0x03; /* CPU */
-    t->processor_family = 0x01; /* Other */
+    t->processor_family = 0xfe; /* use Processor Family 2 field */
     SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
     if (type4.processor_id == 0) {
         t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
@@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
     t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
 
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
-    t->processor_family2 = cpu_to_le16(0x01); /* Other */
+    t->processor_family2 = cpu_to_le16(type4.processor_family);
 
     if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
         t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
@@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
                 return;
             }
             save_opt(&type4.sock_pfx, opts, "sock_pfx");
+            type4.processor_family = qemu_opt_get_number(opts,
+                                                         "processor-family",
+                                                         0x01 /* Other */);
             save_opt(&type4.manufacturer, opts, "manufacturer");
             save_opt(&type4.version, opts, "version");
             save_opt(&type4.serial, opts, "serial");
diff --git a/qemu-options.hx b/qemu-options.hx
index b66570ae00..7bdb414345 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
     "                specify SMBIOS type 3 fields\n"
     "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
     "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
-    "              [,processor-id=%d]\n"
+    "              [,processor-family=%d,processor-id=%d]\n"
     "                specify SMBIOS type 4 fields\n"
     "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
     "                specify SMBIOS type 8 fields\n"
@@ -2722,7 +2722,7 @@ SRST
 ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
     Specify SMBIOS type 3 fields
 
-``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
+``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
     Specify SMBIOS type 4 fields
 
 ``-smbios type=11[,value=str][,path=filename]``
-- 
2.43.0
Re: [PATCH v2 1/4] smbios: add processor-family option
Posted by Andrew Jones 10 months, 1 week ago
On Fri, Dec 29, 2023 at 01:07:21PM +0100, Heinrich Schuchardt wrote:
> For RISC-V the SMBIOS standard requires specific values of the processor
> family value depending on the bitness of the CPU.
> 
> Add a processor-family option for SMBIOS table 4.
> 
> The value of processor-family may exceed 255 and therefore must be provided
> in the Processor Family 2 field. Set the Processor Family field to 0xFE
> which signals that the Processor Family 2 is used.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	new patch
> ---
>  hw/smbios/smbios.c | 13 +++++++++++--
>  qemu-options.hx    |  4 ++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index 2a90601ac5..647bc6d603 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -102,6 +102,7 @@ static struct {
>  #define DEFAULT_CPU_SPEED 2000
>  
>  static struct {
> +    uint16_t processor_family;
>      const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
>      uint64_t max_speed;
>      uint64_t current_speed;
> @@ -110,6 +111,7 @@ static struct {
>      .max_speed = DEFAULT_CPU_SPEED,
>      .current_speed = DEFAULT_CPU_SPEED,
>      .processor_id = 0,
> +    .processor_family = 0x01, /* Other */
>  };
>  
>  struct type8_instance {
> @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
>          .name = "part",
>          .type = QEMU_OPT_STRING,
>          .help = "part number",
> +    }, {
> +        .name = "processor-family",
> +        .type = QEMU_OPT_NUMBER,
> +        .help = "processor family",
>      }, {
>          .name = "processor-id",
>          .type = QEMU_OPT_NUMBER,
> @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
>      SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
>      t->processor_type = 0x03; /* CPU */
> -    t->processor_family = 0x01; /* Other */
> +    t->processor_family = 0xfe; /* use Processor Family 2 field */
>      SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
>      if (type4.processor_id == 0) {
>          t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
> @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
>  
>      t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
> -    t->processor_family2 = cpu_to_le16(0x01); /* Other */
> +    t->processor_family2 = cpu_to_le16(type4.processor_family);
>  
>      if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
>          t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
> @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>                  return;
>              }
>              save_opt(&type4.sock_pfx, opts, "sock_pfx");
> +            type4.processor_family = qemu_opt_get_number(opts,
> +                                                         "processor-family",
> +                                                         0x01 /* Other */);
>              save_opt(&type4.manufacturer, opts, "manufacturer");
>              save_opt(&type4.version, opts, "version");
>              save_opt(&type4.serial, opts, "serial");
> diff --git a/qemu-options.hx b/qemu-options.hx
> index b66570ae00..7bdb414345 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
>      "                specify SMBIOS type 3 fields\n"
>      "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
>      "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
> -    "              [,processor-id=%d]\n"
> +    "              [,processor-family=%d,processor-id=%d]\n"
>      "                specify SMBIOS type 4 fields\n"
>      "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
>      "                specify SMBIOS type 8 fields\n"
> @@ -2722,7 +2722,7 @@ SRST
>  ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
>      Specify SMBIOS type 3 fields
>  
> -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
> +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
>      Specify SMBIOS type 4 fields
>  
>  ``-smbios type=11[,value=str][,path=filename]``
> -- 
> 2.43.0
> 
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Re: [PATCH v2 1/4] smbios: add processor-family option
Posted by Alistair Francis 10 months, 1 week ago
On Fri, Dec 29, 2023 at 10:48 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> For RISC-V the SMBIOS standard requires specific values of the processor
> family value depending on the bitness of the CPU.
>
> Add a processor-family option for SMBIOS table 4.
>
> The value of processor-family may exceed 255 and therefore must be provided
> in the Processor Family 2 field. Set the Processor Family field to 0xFE
> which signals that the Processor Family 2 is used.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
> v2:
>         new patch
> ---
>  hw/smbios/smbios.c | 13 +++++++++++--
>  qemu-options.hx    |  4 ++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index 2a90601ac5..647bc6d603 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -102,6 +102,7 @@ static struct {
>  #define DEFAULT_CPU_SPEED 2000
>
>  static struct {
> +    uint16_t processor_family;
>      const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
>      uint64_t max_speed;
>      uint64_t current_speed;
> @@ -110,6 +111,7 @@ static struct {
>      .max_speed = DEFAULT_CPU_SPEED,
>      .current_speed = DEFAULT_CPU_SPEED,
>      .processor_id = 0,
> +    .processor_family = 0x01, /* Other */
>  };
>
>  struct type8_instance {
> @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
>          .name = "part",
>          .type = QEMU_OPT_STRING,
>          .help = "part number",
> +    }, {
> +        .name = "processor-family",
> +        .type = QEMU_OPT_NUMBER,
> +        .help = "processor family",
>      }, {
>          .name = "processor-id",
>          .type = QEMU_OPT_NUMBER,
> @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
>      SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
>      t->processor_type = 0x03; /* CPU */
> -    t->processor_family = 0x01; /* Other */
> +    t->processor_family = 0xfe; /* use Processor Family 2 field */
>      SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
>      if (type4.processor_id == 0) {
>          t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
> @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
>
>      t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
> -    t->processor_family2 = cpu_to_le16(0x01); /* Other */
> +    t->processor_family2 = cpu_to_le16(type4.processor_family);
>
>      if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
>          t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
> @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>                  return;
>              }
>              save_opt(&type4.sock_pfx, opts, "sock_pfx");
> +            type4.processor_family = qemu_opt_get_number(opts,
> +                                                         "processor-family",
> +                                                         0x01 /* Other */);
>              save_opt(&type4.manufacturer, opts, "manufacturer");
>              save_opt(&type4.version, opts, "version");
>              save_opt(&type4.serial, opts, "serial");
> diff --git a/qemu-options.hx b/qemu-options.hx
> index b66570ae00..7bdb414345 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
>      "                specify SMBIOS type 3 fields\n"
>      "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
>      "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
> -    "              [,processor-id=%d]\n"
> +    "              [,processor-family=%d,processor-id=%d]\n"
>      "                specify SMBIOS type 4 fields\n"
>      "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
>      "                specify SMBIOS type 8 fields\n"
> @@ -2722,7 +2722,7 @@ SRST
>  ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
>      Specify SMBIOS type 3 fields
>
> -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
> +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
>      Specify SMBIOS type 4 fields
>
>  ``-smbios type=11[,value=str][,path=filename]``
> --
> 2.43.0
>
>
Re: [PATCH v2 1/4] smbios: add processor-family option
Posted by Alistair Francis 10 months, 3 weeks ago
On Fri, Dec 29, 2023 at 10:48 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> For RISC-V the SMBIOS standard requires specific values of the processor
> family value depending on the bitness of the CPU.

Can you provide some details of where this is described? I can't seem to find it

Alistair

>
> Add a processor-family option for SMBIOS table 4.
>
> The value of processor-family may exceed 255 and therefore must be provided
> in the Processor Family 2 field. Set the Processor Family field to 0xFE
> which signals that the Processor Family 2 is used.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         new patch
> ---
>  hw/smbios/smbios.c | 13 +++++++++++--
>  qemu-options.hx    |  4 ++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> index 2a90601ac5..647bc6d603 100644
> --- a/hw/smbios/smbios.c
> +++ b/hw/smbios/smbios.c
> @@ -102,6 +102,7 @@ static struct {
>  #define DEFAULT_CPU_SPEED 2000
>
>  static struct {
> +    uint16_t processor_family;
>      const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
>      uint64_t max_speed;
>      uint64_t current_speed;
> @@ -110,6 +111,7 @@ static struct {
>      .max_speed = DEFAULT_CPU_SPEED,
>      .current_speed = DEFAULT_CPU_SPEED,
>      .processor_id = 0,
> +    .processor_family = 0x01, /* Other */
>  };
>
>  struct type8_instance {
> @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
>          .name = "part",
>          .type = QEMU_OPT_STRING,
>          .help = "part number",
> +    }, {
> +        .name = "processor-family",
> +        .type = QEMU_OPT_NUMBER,
> +        .help = "processor family",
>      }, {
>          .name = "processor-id",
>          .type = QEMU_OPT_NUMBER,
> @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
>      SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
>      t->processor_type = 0x03; /* CPU */
> -    t->processor_family = 0x01; /* Other */
> +    t->processor_family = 0xfe; /* use Processor Family 2 field */
>      SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
>      if (type4.processor_id == 0) {
>          t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
> @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>      t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
>
>      t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
> -    t->processor_family2 = cpu_to_le16(0x01); /* Other */
> +    t->processor_family2 = cpu_to_le16(type4.processor_family);
>
>      if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
>          t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
> @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>                  return;
>              }
>              save_opt(&type4.sock_pfx, opts, "sock_pfx");
> +            type4.processor_family = qemu_opt_get_number(opts,
> +                                                         "processor-family",
> +                                                         0x01 /* Other */);
>              save_opt(&type4.manufacturer, opts, "manufacturer");
>              save_opt(&type4.version, opts, "version");
>              save_opt(&type4.serial, opts, "serial");
> diff --git a/qemu-options.hx b/qemu-options.hx
> index b66570ae00..7bdb414345 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
>      "                specify SMBIOS type 3 fields\n"
>      "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
>      "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
> -    "              [,processor-id=%d]\n"
> +    "              [,processor-family=%d,processor-id=%d]\n"
>      "                specify SMBIOS type 4 fields\n"
>      "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
>      "                specify SMBIOS type 8 fields\n"
> @@ -2722,7 +2722,7 @@ SRST
>  ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
>      Specify SMBIOS type 3 fields
>
> -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
> +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
>      Specify SMBIOS type 4 fields
>
>  ``-smbios type=11[,value=str][,path=filename]``
> --
> 2.43.0
>
>
Re: [PATCH v2 1/4] smbios: add processor-family option
Posted by Heinrich Schuchardt 10 months, 3 weeks ago
On 1/5/24 06:24, Alistair Francis wrote:
> On Fri, Dec 29, 2023 at 10:48 PM Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
>>
>> For RISC-V the SMBIOS standard requires specific values of the processor
>> family value depending on the bitness of the CPU.
> 
> Can you provide some details of where this is described? I can't seem to find it
> 
> Alistair

System Management BIOS (SMBIOS) Reference Specification 3.7.0 (DSP0134)
https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.7.0.pdf
7.5.2 Processor Information — Processor Family
Table 23 – Processor Information: Processor Family field

200h 512 RISC-V RV32
201h 513 RISC-V RV64
202h 514 RISC-V RV128

While for other architectures values for different CPU generations have 
been defined the values for RISC-V only depend on the bitness.

Best regards

Heinrich

> 
>>
>> Add a processor-family option for SMBIOS table 4.
>>
>> The value of processor-family may exceed 255 and therefore must be provided
>> in the Processor Family 2 field. Set the Processor Family field to 0xFE
>> which signals that the Processor Family 2 is used.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> v2:
>>          new patch
>> ---
>>   hw/smbios/smbios.c | 13 +++++++++++--
>>   qemu-options.hx    |  4 ++--
>>   2 files changed, 13 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
>> index 2a90601ac5..647bc6d603 100644
>> --- a/hw/smbios/smbios.c
>> +++ b/hw/smbios/smbios.c
>> @@ -102,6 +102,7 @@ static struct {
>>   #define DEFAULT_CPU_SPEED 2000
>>
>>   static struct {
>> +    uint16_t processor_family;
>>       const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
>>       uint64_t max_speed;
>>       uint64_t current_speed;
>> @@ -110,6 +111,7 @@ static struct {
>>       .max_speed = DEFAULT_CPU_SPEED,
>>       .current_speed = DEFAULT_CPU_SPEED,
>>       .processor_id = 0,
>> +    .processor_family = 0x01, /* Other */
>>   };
>>
>>   struct type8_instance {
>> @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
>>           .name = "part",
>>           .type = QEMU_OPT_STRING,
>>           .help = "part number",
>> +    }, {
>> +        .name = "processor-family",
>> +        .type = QEMU_OPT_NUMBER,
>> +        .help = "processor family",
>>       }, {
>>           .name = "processor-id",
>>           .type = QEMU_OPT_NUMBER,
>> @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>>       snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
>>       SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
>>       t->processor_type = 0x03; /* CPU */
>> -    t->processor_family = 0x01; /* Other */
>> +    t->processor_family = 0xfe; /* use Processor Family 2 field */
>>       SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
>>       if (type4.processor_id == 0) {
>>           t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
>> @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
>>       t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
>>
>>       t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
>> -    t->processor_family2 = cpu_to_le16(0x01); /* Other */
>> +    t->processor_family2 = cpu_to_le16(type4.processor_family);
>>
>>       if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
>>           t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
>> @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
>>                   return;
>>               }
>>               save_opt(&type4.sock_pfx, opts, "sock_pfx");
>> +            type4.processor_family = qemu_opt_get_number(opts,
>> +                                                         "processor-family",
>> +                                                         0x01 /* Other */);
>>               save_opt(&type4.manufacturer, opts, "manufacturer");
>>               save_opt(&type4.version, opts, "version");
>>               save_opt(&type4.serial, opts, "serial");
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index b66570ae00..7bdb414345 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
>>       "                specify SMBIOS type 3 fields\n"
>>       "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
>>       "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
>> -    "              [,processor-id=%d]\n"
>> +    "              [,processor-family=%d,processor-id=%d]\n"
>>       "                specify SMBIOS type 4 fields\n"
>>       "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
>>       "                specify SMBIOS type 8 fields\n"
>> @@ -2722,7 +2722,7 @@ SRST
>>   ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
>>       Specify SMBIOS type 3 fields
>>
>> -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
>> +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
>>       Specify SMBIOS type 4 fields
>>
>>   ``-smbios type=11[,value=str][,path=filename]``
>> --
>> 2.43.0
>>
>>


Re: [PATCH v2 1/4] smbios: add processor-family option
Posted by Alistair Francis 10 months, 1 week ago
On Fri, Jan 5, 2024 at 3:44 PM Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> On 1/5/24 06:24, Alistair Francis wrote:
> > On Fri, Dec 29, 2023 at 10:48 PM Heinrich Schuchardt
> > <heinrich.schuchardt@canonical.com> wrote:
> >>
> >> For RISC-V the SMBIOS standard requires specific values of the processor
> >> family value depending on the bitness of the CPU.
> >
> > Can you provide some details of where this is described? I can't seem to find it
> >
> > Alistair
>
> System Management BIOS (SMBIOS) Reference Specification 3.7.0 (DSP0134)
> https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.7.0.pdf
> 7.5.2 Processor Information — Processor Family
> Table 23 – Processor Information: Processor Family field
>
> 200h 512 RISC-V RV32
> 201h 513 RISC-V RV64
> 202h 514 RISC-V RV128
>
> While for other architectures values for different CPU generations have
> been defined the values for RISC-V only depend on the bitness.

Ah, I first read the commit message as saying this is RISC-V specific,
which I couldn't find in the spec.

I now realise you just mean it's important for RISC-V

Alistair

>
> Best regards
>
> Heinrich
>
> >
> >>
> >> Add a processor-family option for SMBIOS table 4.
> >>
> >> The value of processor-family may exceed 255 and therefore must be provided
> >> in the Processor Family 2 field. Set the Processor Family field to 0xFE
> >> which signals that the Processor Family 2 is used.
> >>
> >> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> >> ---
> >> v2:
> >>          new patch
> >> ---
> >>   hw/smbios/smbios.c | 13 +++++++++++--
> >>   qemu-options.hx    |  4 ++--
> >>   2 files changed, 13 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
> >> index 2a90601ac5..647bc6d603 100644
> >> --- a/hw/smbios/smbios.c
> >> +++ b/hw/smbios/smbios.c
> >> @@ -102,6 +102,7 @@ static struct {
> >>   #define DEFAULT_CPU_SPEED 2000
> >>
> >>   static struct {
> >> +    uint16_t processor_family;
> >>       const char *sock_pfx, *manufacturer, *version, *serial, *asset, *part;
> >>       uint64_t max_speed;
> >>       uint64_t current_speed;
> >> @@ -110,6 +111,7 @@ static struct {
> >>       .max_speed = DEFAULT_CPU_SPEED,
> >>       .current_speed = DEFAULT_CPU_SPEED,
> >>       .processor_id = 0,
> >> +    .processor_family = 0x01, /* Other */
> >>   };
> >>
> >>   struct type8_instance {
> >> @@ -337,6 +339,10 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = {
> >>           .name = "part",
> >>           .type = QEMU_OPT_STRING,
> >>           .help = "part number",
> >> +    }, {
> >> +        .name = "processor-family",
> >> +        .type = QEMU_OPT_NUMBER,
> >> +        .help = "processor family",
> >>       }, {
> >>           .name = "processor-id",
> >>           .type = QEMU_OPT_NUMBER,
> >> @@ -726,7 +732,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
> >>       snprintf(sock_str, sizeof(sock_str), "%s%2x", type4.sock_pfx, instance);
> >>       SMBIOS_TABLE_SET_STR(4, socket_designation_str, sock_str);
> >>       t->processor_type = 0x03; /* CPU */
> >> -    t->processor_family = 0x01; /* Other */
> >> +    t->processor_family = 0xfe; /* use Processor Family 2 field */
> >>       SMBIOS_TABLE_SET_STR(4, processor_manufacturer_str, type4.manufacturer);
> >>       if (type4.processor_id == 0) {
> >>           t->processor_id[0] = cpu_to_le32(smbios_cpuid_version);
> >> @@ -758,7 +764,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
> >>       t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket;
> >>
> >>       t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
> >> -    t->processor_family2 = cpu_to_le16(0x01); /* Other */
> >> +    t->processor_family2 = cpu_to_le16(type4.processor_family);
> >>
> >>       if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
> >>           t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket);
> >> @@ -1402,6 +1408,9 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
> >>                   return;
> >>               }
> >>               save_opt(&type4.sock_pfx, opts, "sock_pfx");
> >> +            type4.processor_family = qemu_opt_get_number(opts,
> >> +                                                         "processor-family",
> >> +                                                         0x01 /* Other */);
> >>               save_opt(&type4.manufacturer, opts, "manufacturer");
> >>               save_opt(&type4.version, opts, "version");
> >>               save_opt(&type4.serial, opts, "serial");
> >> diff --git a/qemu-options.hx b/qemu-options.hx
> >> index b66570ae00..7bdb414345 100644
> >> --- a/qemu-options.hx
> >> +++ b/qemu-options.hx
> >> @@ -2694,7 +2694,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
> >>       "                specify SMBIOS type 3 fields\n"
> >>       "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
> >>       "              [,asset=str][,part=str][,max-speed=%d][,current-speed=%d]\n"
> >> -    "              [,processor-id=%d]\n"
> >> +    "              [,processor-family=%d,processor-id=%d]\n"
> >>       "                specify SMBIOS type 4 fields\n"
> >>       "-smbios type=8[,external_reference=str][,internal_reference=str][,connector_type=%d][,port_type=%d]\n"
> >>       "                specify SMBIOS type 8 fields\n"
> >> @@ -2722,7 +2722,7 @@ SRST
> >>   ``-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]``
> >>       Specify SMBIOS type 3 fields
> >>
> >> -``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-id=%d]``
> >> +``-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]``
> >>       Specify SMBIOS type 4 fields
> >>
> >>   ``-smbios type=11[,value=str][,path=filename]``
> >> --
> >> 2.43.0
> >>
> >>
>