[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/9] cpu/topology: add i386 support for smp machine
From: |
Like Xu |
Subject: |
[Qemu-devel] [PATCH 5/9] cpu/topology: add i386 support for smp machine properties |
Date: |
Fri, 29 Mar 2019 16:48:41 +0800 |
Signed-off-by: Like Xu <address@hidden>
---
hw/i386/acpi-build.c | 3 +++
hw/i386/kvmvapic.c | 5 +++++
hw/i386/pc.c | 12 ++++++++++++
target/i386/cpu.c | 4 ++++
4 files changed, 24 insertions(+)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 416da31..3813c28 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -44,6 +44,7 @@
#include "sysemu/tpm.h"
#include "hw/acpi/tpm.h"
#include "hw/acpi/vmgenid.h"
+#include "hw/boards.h"
#include "sysemu/tpm_backend.h"
#include "hw/timer/mc146818rtc_regs.h"
#include "hw/mem/memory-device.h"
@@ -127,6 +128,8 @@ typedef struct FwCfgTPMConfig {
static void init_common_fadt_data(Object *o, AcpiFadtData *data)
{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ unsigned int max_cpus = ms->topo.max_cpus;
uint32_t io = object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, NULL);
AmlAddressSpace as = AML_AS_SYSTEM_IO;
AcpiFadtData fadt = {
diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c
index 70f6f26..2463f8a 100644
--- a/hw/i386/kvmvapic.c
+++ b/hw/i386/kvmvapic.c
@@ -17,6 +17,7 @@
#include "sysemu/kvm.h"
#include "hw/i386/apic_internal.h"
#include "hw/sysbus.h"
+#include "hw/boards.h"
#include "tcg/tcg.h"
#define VAPIC_IO_PORT 0x7e
@@ -441,6 +442,8 @@ static void do_patch_instruction(CPUState *cs,
run_on_cpu_data data)
static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip)
{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ unsigned int smp_cpus = ms->topo.smp_cpus;
CPUState *cs = CPU(cpu);
VAPICHandlers *handlers;
PatchInfo *info;
@@ -746,6 +749,8 @@ static void do_vapic_enable(CPUState *cs, run_on_cpu_data
data)
static void kvmvapic_vm_state_change(void *opaque, int running,
RunState state)
{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ unsigned int smp_cpus = ms->topo.smp_cpus;
VAPICROMState *s = opaque;
uint8_t *zero;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 6077d27..2816bfd 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -931,6 +931,9 @@ void enable_compat_apic_id_mode(void)
*/
static uint32_t x86_cpu_apic_id_from_index(unsigned int cpu_index)
{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ unsigned int smp_cores = ms->topo.smp_cores;
+ unsigned int smp_threads = ms->topo.smp_threads;
uint32_t correct_id;
static bool warned;
@@ -1562,6 +1565,7 @@ void pc_cpus_init(PCMachineState *pcms)
const CPUArchIdList *possible_cpus;
MachineState *ms = MACHINE(pcms);
MachineClass *mc = MACHINE_GET_CLASS(pcms);
+ unsigned int smp_cpus = ms->topo.smp_cpus, max_cpus = ms->topo.max_cpus;
/* Calculates the limit to CPU APIC ID values
*
@@ -2291,6 +2295,9 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
X86CPU *cpu = X86_CPU(dev);
MachineState *ms = MACHINE(hotplug_dev);
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
+ unsigned int smp_cores = ms->topo.smp_cores;
+ unsigned int smp_threads = ms->topo.smp_threads;
+ unsigned int max_cpus = ms->topo.max_cpus;
if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) {
error_setg(errp, "Invalid CPU type, expected cpu type: '%s'",
@@ -2646,6 +2653,8 @@ pc_cpu_index_to_props(MachineState *ms, unsigned
cpu_index)
static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx)
{
X86CPUTopoInfo topo;
+ unsigned int smp_cores = ms->topo.smp_cores;
+ unsigned int smp_threads = ms->topo.smp_threads;
assert(idx < ms->possible_cpus->len);
x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id,
@@ -2656,6 +2665,9 @@ static int64_t pc_get_default_cpu_node_id(const
MachineState *ms, int idx)
static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms)
{
int i;
+ unsigned int max_cpus = ms->topo.max_cpus;
+ unsigned int smp_cores = ms->topo.smp_cores;
+ unsigned int smp_threads = ms->topo.smp_threads;
if (ms->possible_cpus) {
/*
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index d6bb57d..6dcdad4 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -53,6 +53,7 @@
#include "hw/hw.h"
#include "hw/xen/xen.h"
#include "hw/i386/apic_internal.h"
+#include "hw/boards.h"
#endif
#include "disas/capstone.h"
@@ -5291,6 +5292,9 @@ static void x86_cpu_realizefn(DeviceState *dev, Error
**errp)
}
#ifndef CONFIG_USER_ONLY
+ MachineState *ms = MACHINE(qdev_get_machine());
+ unsigned int smp_cpus = ms->topo.smp_cpus;
+
qemu_register_reset(x86_cpu_machine_reset_cb, cpu);
if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || smp_cpus > 1) {
--
1.8.3.1