qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] hw/smbios: fix thead count field in type 4 table


From: Tianrui Zhao
Subject: [PATCH] hw/smbios: fix thead count field in type 4 table
Date: Tue, 30 May 2023 20:20:34 +0800

The thread_count value in smbios type_4 table should be
(ms->smp.cores * ms->smp.threads). As according to smbios spec 7.5
Processor Information (Type 4), the field "Thread Count" means the
"Number of threads per processor socket" rather than number of
threads per core.

When apply this patch, use "-smp 4,sockets=1,cores=2,threads=2" to
boot VM, the dmidecode -t 4 shows like:

Handle 0x0400, DMI type 4, 48 bytes
Processor Information
        Socket Designation: CPU 0
        ...
        Core Count: 2
        Core Enabled: 2
        Thread Count: 4
        Characteristics: None

Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
---
 hw/smbios/smbios.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index d2007e70fb..56aeaa069d 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -713,6 +713,7 @@ static void smbios_build_type_4_table(MachineState *ms, 
unsigned instance)
 {
     char sock_str[128];
     size_t tbl_len = SMBIOS_TYPE_4_LEN_V28;
+    int count;
 
     if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_64) {
         tbl_len = SMBIOS_TYPE_4_LEN_V30;
@@ -749,15 +750,15 @@ static void smbios_build_type_4_table(MachineState *ms, 
unsigned instance)
 
     t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
     t->core_enabled = t->core_count;
-
-    t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
+    count = ms->smp.cores * ms->smp.threads;
+    t->thread_count = (count > 255) ? 0xFF : count;
 
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
     t->processor_family2 = cpu_to_le16(0x01); /* Other */
 
     if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
         t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
-        t->thread_count2 = cpu_to_le16(ms->smp.threads);
+        t->thread_count2 = cpu_to_le16(count);
     }
 
     SMBIOS_BUILD_TABLE_POST;
-- 
2.39.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]