diff options
author | Peter Maydell | 2017-01-24 16:39:09 +0100 |
---|---|---|
committer | Peter Maydell | 2017-01-24 16:39:09 +0100 |
commit | a678502e4f7580a6f143f680404aaee57ac3f4b5 (patch) | |
tree | bc436746e83c888dd10d078cfe2ea7a8726a967c /hw/i386/pc.c | |
parent | Makefile: Add qemu-doc.txt to distclean and dependencies (diff) | |
parent | kvm: Allow invtsc migration if tsc-khz is set explicitly (diff) | |
download | qemu-a678502e4f7580a6f143f680404aaee57ac3f4b5.tar.gz qemu-a678502e4f7580a6f143f680404aaee57ac3f4b5.tar.xz qemu-a678502e4f7580a6f143f680404aaee57ac3f4b5.zip |
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging
x86, machine, numa queue (2017-01-23)
# gpg: Signature made Mon 23 Jan 2017 23:26:59 GMT
# gpg: using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/x86-and-machine-pull-request:
kvm: Allow invtsc migration if tsc-khz is set explicitly
kvm: Simplify invtsc check
hw/core/null-machine: Add the possibility to instantiate a CPU and RAM
qemu-options: Rename variables on the -numa "cpus" option
MAINTAINERS: Add an entry for hw/core/null-machine.c
machine: Make possible_cpu_arch_ids() return const pointer
pc: don't return cpu pointer from pc_new_cpu() as it's not needed anymore
pc: cleanup: move smbios_set_cpuid() into pc_build_smbios()
arch_init: Remove unnecessary default_config_files table
vl: Ensure the numa_post_machine_init func in the appropriate location
i386: Return migration-safe field on query-cpu-definitions
i386: Remove AMD feature flag aliases from Opteron models
x86: add AVX512_VPOPCNTDQ features
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/i386/pc.c')
-rw-r--r-- | hw/i386/pc.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f721fde0c2..c949cf0ecc 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -701,16 +701,20 @@ static uint32_t x86_cpu_apic_id_from_index(unsigned int cpu_index) } } -static void pc_build_smbios(FWCfgState *fw_cfg) +static void pc_build_smbios(PCMachineState *pcms) { 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; + X86CPU *cpu = X86_CPU(pcms->possible_cpus->cpus[0].cpu); + + /* tell smbios about cpuid version and features */ + smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); smbios_tables = smbios_get_table_legacy(&smbios_tables_len); if (smbios_tables) { - fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, + fw_cfg_add_bytes(pcms->fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); } @@ -731,9 +735,9 @@ static void pc_build_smbios(FWCfgState *fw_cfg) g_free(mem_array); if (smbios_anchor) { - fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-tables", + fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-tables", smbios_tables, smbios_tables_len); - fw_cfg_add_file(fw_cfg, "etc/smbios/smbios-anchor", + fw_cfg_add_file(pcms->fw_cfg, "etc/smbios/smbios-anchor", smbios_anchor, smbios_anchor_len); } } @@ -1088,28 +1092,24 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) } } -static X86CPU *pc_new_cpu(const char *typename, int64_t apic_id, - Error **errp) +static void pc_new_cpu(const char *typename, int64_t apic_id, Error **errp) { - X86CPU *cpu = NULL; + Object *cpu = NULL; Error *local_err = NULL; - cpu = X86_CPU(object_new(typename)); + cpu = object_new(typename); - object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err); - object_property_set_bool(OBJECT(cpu), true, "realized", &local_err); + object_property_set_int(cpu, apic_id, "apic-id", &local_err); + object_property_set_bool(cpu, true, "realized", &local_err); + object_unref(cpu); if (local_err) { error_propagate(errp, local_err); - object_unref(OBJECT(cpu)); - cpu = NULL; } - return cpu; } void pc_hot_add_cpu(const int64_t id, Error **errp) { - X86CPU *cpu; ObjectClass *oc; PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); int64_t apic_id = x86_cpu_apic_id_from_index(id); @@ -1129,12 +1129,11 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) assert(pcms->possible_cpus->cpus[0].cpu); /* BSP is always present */ oc = OBJECT_CLASS(CPU_GET_CLASS(pcms->possible_cpus->cpus[0].cpu)); - cpu = pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); + pc_new_cpu(object_class_get_name(oc), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); return; } - object_unref(OBJECT(cpu)); } void pc_cpus_init(PCMachineState *pcms) @@ -1144,7 +1143,6 @@ void pc_cpus_init(PCMachineState *pcms) ObjectClass *oc; const char *typename; gchar **model_pieces; - X86CPU *cpu = NULL; MachineState *machine = MACHINE(pcms); /* init CPUs */ @@ -1186,14 +1184,9 @@ void pc_cpus_init(PCMachineState *pcms) pcms->possible_cpus->cpus[i].arch_id = x86_cpu_apic_id_from_index(i); pcms->possible_cpus->len++; if (i < smp_cpus) { - cpu = pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), - &error_fatal); - object_unref(OBJECT(cpu)); + pc_new_cpu(typename, x86_cpu_apic_id_from_index(i), &error_fatal); } } - - /* tell smbios about cpuid version and features */ - smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]); } static void pc_build_feature_control_file(PCMachineState *pcms) @@ -1266,7 +1259,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { - pc_build_smbios(pcms->fw_cfg); + pc_build_smbios(pcms); pc_build_feature_control_file(pcms); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); @@ -2247,15 +2240,11 @@ static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index) return topo.pkg_id; } -static CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) +static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *machine) { PCMachineState *pcms = PC_MACHINE(machine); - int len = sizeof(CPUArchIdList) + - sizeof(CPUArchId) * (pcms->possible_cpus->len); - CPUArchIdList *list = g_malloc(len); - - memcpy(list, pcms->possible_cpus, len); - return list; + assert(pcms->possible_cpus); + return pcms->possible_cpus; } static HotpluggableCPUList *pc_query_hotpluggable_cpus(MachineState *machine) |