All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Jones <drjones@redhat.com>
To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org
Cc: imammedo@redhat.com, ehabkost@redhat.com, pbonzini@redhat.com,
	peter.maydell@linaro.org, david@gibson.dropbear.id.au,
	dgibson@redhat.com, agraf@suse.de
Subject: [Qemu-devel] [PATCH RFC 15/16] smbios: don't use smp_cores, smp_threads
Date: Fri, 10 Jun 2016 19:40:26 +0200	[thread overview]
Message-ID: <1465580427-13596-16-git-send-email-drjones@redhat.com> (raw)
In-Reply-To: <1465580427-13596-1-git-send-email-drjones@redhat.com>

SMBIOS needs cpu topology for Type4 tables, so we need to pass
it in. There are several parameters so we use a structure. There
are two callers (of non-legacy, which generates Type4 tables),
x86 and arm, so we also update both to pass the topology
parameters from their MachineState properties (directly in the
case of x86, indirectly through VirtGuestInfo in the case of arm).

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 hw/arm/virt.c              |  9 ++++++++-
 hw/i386/pc.c               | 13 ++++++++++---
 hw/smbios/smbios.c         | 20 +++++++++++---------
 include/hw/smbios/smbios.h | 10 ++++++++++
 4 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 769a49aa5be77..4482fab91c139 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1067,6 +1067,13 @@ static void virt_build_smbios(VirtGuestInfo *guest_info)
     uint8_t *smbios_tables, *smbios_anchor;
     size_t smbios_tables_len, smbios_anchor_len;
     const char *product = "QEMU Virtual Machine";
+    struct smbios_cpu_topology topo = {
+        .sockets = guest_info->sockets,
+        .cores   = guest_info->cores,
+        .threads = guest_info->threads,
+        .maxcpus = guest_info->maxcpus,
+        .cpus    = guest_info->cpus,
+    };
 
     if (!fw_cfg) {
         return;
@@ -1079,7 +1086,7 @@ static void virt_build_smbios(VirtGuestInfo *guest_info)
     smbios_set_defaults("QEMU", product,
                         "1.0", false, true, SMBIOS_ENTRY_POINT_30);
 
-    smbios_get_tables(NULL, 0, &smbios_tables, &smbios_tables_len,
+    smbios_get_tables(NULL, 0, &topo, &smbios_tables, &smbios_tables_len,
                       &smbios_anchor, &smbios_anchor_len);
 
     if (smbios_anchor) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 4fa86d6387ce9..afea1a535a653 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -701,12 +701,19 @@ static uint32_t x86_cpu_apic_id_from_index(MachineState *ms,
     }
 }
 
-static void pc_build_smbios(FWCfgState *fw_cfg)
+static void pc_build_smbios(MachineState *ms, FWCfgState *fw_cfg)
 {
     uint8_t *smbios_tables, *smbios_anchor;
     size_t smbios_tables_len, smbios_anchor_len;
     struct smbios_phys_mem_area *mem_array;
     unsigned i, array_count;
+    struct smbios_cpu_topology topo = {
+        .sockets = ms->sockets,
+        .cores   = ms->cores,
+        .threads = ms->threads,
+        .maxcpus = ms->maxcpus,
+        .cpus    = ms->cpus,
+    };
 
     smbios_tables = smbios_get_table_legacy(&smbios_tables_len);
     if (smbios_tables) {
@@ -725,7 +732,7 @@ static void pc_build_smbios(FWCfgState *fw_cfg)
             array_count++;
         }
     }
-    smbios_get_tables(mem_array, array_count,
+    smbios_get_tables(mem_array, array_count, &topo,
                       &smbios_tables, &smbios_tables_len,
                       &smbios_anchor, &smbios_anchor_len);
     g_free(mem_array);
@@ -1176,7 +1183,7 @@ void pc_machine_done(Notifier *notifier, void *data)
 
     acpi_setup();
     if (pcms->fw_cfg) {
-        pc_build_smbios(pcms->fw_cfg);
+        pc_build_smbios(MACHINE(pcms), pcms->fw_cfg);
     }
 }
 
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index cf18ecfd8599c..99b5f984b945a 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -20,7 +20,6 @@
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "sysemu/sysemu.h"
-#include "sysemu/cpus.h"
 #include "hw/smbios/smbios.h"
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
@@ -64,7 +63,9 @@ static SmbiosEntryPoint ep;
 static int smbios_type4_count = 0;
 static bool smbios_immutable;
 static bool smbios_have_defaults;
-static uint32_t smbios_cpuid_version, smbios_cpuid_features, smbios_smp_sockets;
+static uint32_t smbios_cpuid_version, smbios_cpuid_features;
+
+static struct smbios_cpu_topology smbios_cpu_topology;
 
 static DECLARE_BITMAP(have_binfile_bitmap, SMBIOS_MAX_TYPE+1);
 static DECLARE_BITMAP(have_fields_bitmap, SMBIOS_MAX_TYPE+1);
@@ -325,7 +326,8 @@ opts_init(smbios_register_config);
 
 static void smbios_validate_table(void)
 {
-    uint32_t expect_t4_count = smbios_legacy ? smp_cpus : smbios_smp_sockets;
+    uint32_t expect_t4_count = smbios_legacy ? smp_cpus
+                                             : smbios_cpu_topology.sockets;
 
     if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
         error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
@@ -637,8 +639,8 @@ static void smbios_build_type_4_table(unsigned instance)
     SMBIOS_TABLE_SET_STR(4, serial_number_str, type4.serial);
     SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset);
     SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part);
-    t->core_count = t->core_enabled = smp_cores;
-    t->thread_count = smp_threads;
+    t->core_count = t->core_enabled = smbios_cpu_topology.cores;
+    t->thread_count = smbios_cpu_topology.threads;
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
     t->processor_family2 = cpu_to_le16(0x01); /* Other */
 
@@ -864,6 +866,7 @@ static void smbios_entry_point_setup(void)
 
 void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
                        const unsigned int mem_array_size,
+                       const struct smbios_cpu_topology *topo,
                        uint8_t **tables, size_t *tables_len,
                        uint8_t **anchor, size_t *anchor_len)
 {
@@ -875,16 +878,15 @@ void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
         return;
     }
 
+    smbios_cpu_topology = *topo;
+
     if (!smbios_immutable) {
         smbios_build_type_0_table();
         smbios_build_type_1_table();
         smbios_build_type_2_table();
         smbios_build_type_3_table();
 
-        smbios_smp_sockets = DIV_ROUND_UP(max_cpus, smp_cores * smp_threads);
-        assert(smbios_smp_sockets >= 1);
-
-        for (i = 0; i < smbios_smp_sockets; i++) {
+        for (i = 0; i < smbios_cpu_topology.sockets; i++) {
             smbios_build_type_4_table(i);
         }
 
diff --git a/include/hw/smbios/smbios.h b/include/hw/smbios/smbios.h
index ba3674609edf4..64f41ee9e2605 100644
--- a/include/hw/smbios/smbios.h
+++ b/include/hw/smbios/smbios.h
@@ -23,6 +23,15 @@ struct smbios_phys_mem_area {
     uint64_t length;
 };
 
+/* cpu topology, used by type 4 table */
+struct smbios_cpu_topology {
+    int sockets;
+    int cores;
+    int threads;
+    int maxcpus;
+    int cpus;
+};
+
 /*
  * SMBIOS spec defined tables
  */
@@ -264,6 +273,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
 uint8_t *smbios_get_table_legacy(size_t *length);
 void smbios_get_tables(const struct smbios_phys_mem_area *mem_array,
                        const unsigned int mem_array_size,
+                       const struct smbios_cpu_topology *topo,
                        uint8_t **tables, size_t *tables_len,
                        uint8_t **anchor, size_t *anchor_len);
 #endif /*QEMU_SMBIOS_H */
-- 
2.4.11

  parent reply	other threads:[~2016-06-10 17:41 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 17:40 [Qemu-devel] [PATCH RFC 00/16] Rework SMP parameters Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 01/16] vl: smp_parse: cleanups Andrew Jones
2016-06-14  1:15   ` David Gibson
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 02/16] vl: smp: add checks for maxcpus based topologies Andrew Jones
2016-06-14  1:28   ` David Gibson
2016-06-14  6:43     ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 03/16] hw/smbios/smbios: fix number of sockets calculation Andrew Jones
2016-07-11 14:23   ` Igor Mammedov
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 04/16] hw/core/machine: Introduce pre_init Andrew Jones
2016-06-14  1:30   ` David Gibson
2016-06-14  5:58     ` Andrew Jones
2016-07-14 20:10       ` Eduardo Habkost
2016-07-15  6:26         ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 05/16] hw/core/machine: add smp properites Andrew Jones
2016-06-14  2:00   ` David Gibson
2016-06-14  6:08     ` Andrew Jones
2016-06-15  0:37       ` David Gibson
2016-06-15  7:11         ` Andrew Jones
2016-07-14 20:18           ` Eduardo Habkost
2016-07-15  6:29             ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 06/16] vl: move smp parsing to machine pre_init Andrew Jones
2016-06-13 17:04   ` Paolo Bonzini
2016-06-13 20:35     ` Andrew Jones
2016-06-14  8:17       ` Paolo Bonzini
2016-06-14 11:39         ` Andrew Jones
2016-06-14 11:53           ` Paolo Bonzini
2016-06-14 14:03             ` Andrew Jones
2016-06-14 14:05               ` Paolo Bonzini
2016-06-15  0:51               ` David Gibson
2016-06-15  7:19                 ` Andrew Jones
2016-06-15  0:43         ` David Gibson
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties Andrew Jones
2016-06-11  6:54   ` Thomas Huth
2016-06-12 13:48     ` Andrew Jones
2016-06-14  2:12       ` David Gibson
2016-06-14  6:19         ` Andrew Jones
2016-06-15  0:56           ` David Gibson
2016-07-14 20:07             ` Eduardo Habkost
2016-07-15  6:35               ` Andrew Jones
2016-07-15  9:11                 ` Igor Mammedov
2016-07-15 16:10                   ` [Qemu-devel] QOM: best way for parents to pass information to children? (was Re: [PATCH RFC 07/16] qom/cpu: make nr-cores, nr-threads real properties) Eduardo Habkost
2016-07-15 16:30                     ` Andreas Färber
2016-07-15 17:43                       ` Eduardo Habkost
2016-07-15 18:38                         ` Igor Mammedov
2016-07-15 21:33                           ` Eduardo Habkost
2016-07-16 15:30                             ` Andrew Jones
2016-07-19 11:54                               ` Eduardo Habkost
2016-07-18  7:23                             ` Igor Mammedov
2016-07-19 11:59                               ` Eduardo Habkost
2016-07-19 12:21                                 ` Paolo Bonzini
2016-07-19 13:29                                   ` Igor Mammedov
2016-07-19 13:39                                     ` Paolo Bonzini
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 08/16] hw/core/machine: set cpu global nr_cores, nr_threads in pre_init Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 09/16] hw/i386/pc: don't use smp_cores, smp_threads Andrew Jones
2016-07-14 20:33   ` Eduardo Habkost
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 10/16] hw/ppc/spapr: " Andrew Jones
2016-06-14  3:03   ` David Gibson
2016-06-14  6:23     ` Andrew Jones
2016-06-15  0:59       ` David Gibson
2016-06-15  7:34         ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 11/16] target-ppc: don't use smp_threads Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 12/16] hw/arm/virt: rename *.smp_cpus to *.cpus Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 13/16] hw/arm/virt: don't use smp_cpus, max_cpus Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 14/16] hw/arm/virt: stash cpu topo info in VirtGuestInfo Andrew Jones
2016-07-14 20:43   ` Eduardo Habkost
2016-07-15  6:40     ` Andrew Jones
2016-06-10 17:40 ` Andrew Jones [this message]
2016-07-14 20:51   ` [Qemu-devel] [PATCH RFC 15/16] smbios: don't use smp_cores, smp_threads Eduardo Habkost
2016-07-15  6:45     ` Andrew Jones
2016-06-10 17:40 ` [Qemu-devel] [PATCH RFC 16/16] sysemu/cpus: bye, bye " Andrew Jones
2016-06-11  6:42 ` [Qemu-devel] [PATCH RFC 00/16] Rework SMP parameters Thomas Huth
2016-06-12 13:58   ` Andrew Jones
2016-06-12 14:03 ` Andrew Jones
2016-07-14  9:16 ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465580427-13596-16-git-send-email-drjones@redhat.com \
    --to=drjones@redhat.com \
    --cc=agraf@suse.de \
    --cc=david@gibson.dropbear.id.au \
    --cc=dgibson@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.