From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561747914; cv=none; d=zoho.com; s=zohoarc; b=hnxh4ZFQo+idat5HTo7hq5KZwV/JvPuR02Y++GbZjz6UQctF7snEyMPGzqe9vMO1aeV0z2aIyO3sCtqsEkinPShE7msJa1A7ufK37+iIOPSdl/aXhryqfQmbiMukdH6Dp71hV+jgucH8KAwzJ+0183XfHyYQdSXklR1JTIaxpWY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561747914; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=U/YmGmlPrWRoK2cRXiRvINcb9RRUe1R8qHYLICW+I3M=; b=DaZdCv5nTAnl4hzhXq9BhuhYgcWZWtqC8XsiJZj4kcXPuJnnql9K2BhDzBLUe8kUhZ5YIO8TLnlYSGnaR3dLZL/0oJy84Su/esC7nPgWML2YSNHfcU1LtkSMhtbLSnXzeTMgjIhHftnS5Rbq9oOTQtKES/8oLmdLrzUCcdNwDTA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561747914417462.2636195586574; Fri, 28 Jun 2019 11:51:54 -0700 (PDT) Received: from localhost ([::1]:35509 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyH-0003nL-DT for importer@patchew.org; Fri, 28 Jun 2019 14:51:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40039) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvuy-0001sc-CA for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvut-0000vi-Ev for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvus-0000hE-5y for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17703307D86F; Fri, 28 Jun 2019 18:48:00 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67E875DD65; Fri, 28 Jun 2019 18:47:59 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:14 -0300 Message-Id: <20190628184742.5961-2-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Jun 2019 18:48:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 01/29] hw/boards: Add struct CpuTopology to MachineState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The cpu topology property CpuTopology is added to the MachineState and its members are initialized with the leagcy global smp variables. From this commit, the code in the system emulation mode is supposed to use cpu topology variables from MachineState instead of the global ones defined in vl.c and there is no semantic change. Suggested-by: Igor Mammedov Suggested-by: Eduardo Habkost Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-2-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 15 +++++++++++++++ vl.c | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index eaa050a7ab..31dab77b4b 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -231,6 +231,20 @@ typedef struct DeviceMemoryState { MemoryRegion mr; } DeviceMemoryState; =20 +/** + * CpuTopology: + * @cpus: the number of present logical processors on the machine + * @cores: the number of cores in one package + * @threads: the number of threads in one core + * @max_cpus: the maximum number of logical processors on the machine + */ +typedef struct CpuTopology { + unsigned int cpus; + unsigned int cores; + unsigned int threads; + unsigned int max_cpus; +} CpuTopology; + /** * MachineState: */ @@ -273,6 +287,7 @@ struct MachineState { const char *cpu_type; AccelState *accelerator; CPUArchIdList *possible_cpus; + CpuTopology smp; struct NVDIMMState *nvdimms_state; }; =20 diff --git a/vl.c b/vl.c index 99a56b5556..e9698cb1b1 100644 --- a/vl.c +++ b/vl.c @@ -4059,6 +4059,11 @@ int main(int argc, char **argv, char **envp) =20 smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); =20 + current_machine->smp.cpus =3D smp_cpus; + current_machine->smp.max_cpus =3D max_cpus; + current_machine->smp.cores =3D smp_cores; + current_machine->smp.threads =3D smp_threads; + /* sanity-check smp_cpus and max_cpus against machine_class */ if (smp_cpus < machine_class->min_cpus) { error_report("Invalid SMP CPUs %d. The min CPUs " --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561747916; cv=none; d=zoho.com; s=zohoarc; b=FmFZRk5RGYYSBOIhqd+JQLcr6PbujWbhYFubOxiyRNA5zrqfOKq++C/sonFO92FbOAuNB7yt3v6Ptl1xQjxmEpaaq2o138IrF4aQW6Dzz7u3psoTWKme3R/72RFEF77vyCRU5hKv2LaTZVn/BiG3Ntw4Sq+ww9lWa0agUM8/uPc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561747916; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ymX9CjgianPd1XaY1cWhUVKaEFUiMBdv0yCmzdtTjeU=; b=GoicmX3kIz2riYE+ZqBOCesuBLQ0RNWLYI+npjWnOJHxWCODrewZ5agc7Xk0rPcjMTQUvpCys9dMTUsOp9SqIxhguLXy0CToR9qgiQcrMZQhnBgxBiwU4TDLPhvkljmSIkE8X/DPdY/Z+8VYw7XdXkeZNWdy09FlAFA9SF7RoxY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561747916454914.5940844585314; Fri, 28 Jun 2019 11:51:56 -0700 (PDT) Received: from localhost ([::1]:35510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyM-0003xJ-Ev for importer@patchew.org; Fri, 28 Jun 2019 14:51:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40047) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvv0-0001st-1M for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvuw-0000xb-BO for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50000) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvut-0000lS-EK for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3E3ED309175F; Fri, 28 Jun 2019 18:48:03 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 398795D71B; Fri, 28 Jun 2019 18:48:01 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:15 -0300 Message-Id: <20190628184742.5961-3-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 28 Jun 2019 18:48:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 02/29] machine: Refactor smp-related call chains to pass MachineState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu To get rid of the global smp_* variables we're currently using, it's recomm= ended to pass MachineState in the list of incoming parameters for functions that = use global smp variables, thus some redundant parameters are dropped. It's appl= ied for legacy smbios_*(), *_machine_reset(), hot_add_cpu() and mips *_create_c= pu(). Suggested-by: Igor Mammedov Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-3-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 4 ++-- include/hw/firmware/smbios.h | 5 +++-- include/hw/i386/pc.h | 2 +- hw/arm/virt.c | 2 +- hw/hppa/machine.c | 2 +- hw/i386/acpi-build.c | 2 +- hw/i386/pc.c | 9 ++++----- hw/mips/mips_malta.c | 22 +++++++++++----------- hw/ppc/pnv.c | 3 +-- hw/ppc/spapr.c | 3 +-- hw/s390x/s390-virtio-ccw.c | 6 +++--- hw/smbios/smbios.c | 26 +++++++++++++++----------- monitor/qmp-cmds.c | 2 +- vl.c | 2 +- 14 files changed, 46 insertions(+), 44 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 31dab77b4b..843d82c77d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -172,8 +172,8 @@ struct MachineClass { const char *deprecation_reason; =20 void (*init)(MachineState *state); - void (*reset)(void); - void (*hot_add_cpu)(const int64_t id, Error **errp); + void (*reset)(MachineState *state); + void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **err= p); int (*kvm_type)(MachineState *machine, const char *arg); =20 BlockInterfaceType block_default_type; diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index 6fef32a3c9..02a0ced0a0 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -268,8 +268,9 @@ void smbios_set_cpuid(uint32_t version, uint32_t featur= es); void smbios_set_defaults(const char *manufacturer, const char *product, const char *version, bool legacy_mode, bool uuid_encoded, SmbiosEntryPointType ep_type); -uint8_t *smbios_get_table_legacy(size_t *length); -void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, +uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length); +void smbios_get_tables(MachineState *ms, + const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len); diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index c54cc54a47..884e35b9b2 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -186,7 +186,7 @@ void pc_register_ferr_irq(qemu_irq irq); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); =20 void pc_cpus_init(PCMachineState *pcms); -void pc_hot_add_cpu(const int64_t id, Error **errp); +void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp); =20 void pc_guest_info_init(PCMachineState *pcms); =20 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 431e2900fd..4a0ac3baf0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1344,7 +1344,7 @@ static void virt_build_smbios(VirtMachineState *vms) vmc->smbios_old_sys_ver ? "1.0" : mc->name, false, true, SMBIOS_ENTRY_POINT_30); =20 - smbios_get_tables(NULL, 0, &smbios_tables, &smbios_tables_len, + smbios_get_tables(MACHINE(vms), NULL, 0, &smbios_tables, &smbios_table= s_len, &smbios_anchor, &smbios_anchor_len); =20 if (smbios_anchor) { diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index d1b1d3caa4..416e67bab1 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -240,7 +240,7 @@ static void machine_hppa_init(MachineState *machine) cpu[0]->env.gr[21] =3D smp_cpus; } =20 -static void hppa_machine_reset(void) +static void hppa_machine_reset(MachineState *ms) { int i; =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 31a1c1e3ad..8ae7d88b11 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -184,7 +184,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) pm->pcihp_io_len =3D 0; =20 assert(obj); - init_common_fadt_data(obj, &pm->fadt); + init_common_fadt_data(machine, obj, &pm->fadt); if (piix) { /* w2k requires FADT(rev1) or it won't boot, keep PC compatible */ pm->fadt.rev =3D 1; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e96360b47a..da1cdd6853 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -958,7 +958,7 @@ static void pc_build_smbios(PCMachineState *pcms) /* tell smbios about cpuid version and features */ smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1_EDX]= ); =20 - smbios_tables =3D smbios_get_table_legacy(&smbios_tables_len); + smbios_tables =3D smbios_get_table_legacy(ms, &smbios_tables_len); if (smbios_tables) { fw_cfg_add_bytes(pcms->fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_tables, smbios_tables_len); @@ -975,7 +975,7 @@ static void pc_build_smbios(PCMachineState *pcms) array_count++; } } - smbios_get_tables(mem_array, array_count, + smbios_get_tables(ms, mem_array, array_count, &smbios_tables, &smbios_tables_len, &smbios_anchor, &smbios_anchor_len); g_free(mem_array); @@ -1530,9 +1530,8 @@ static void pc_new_cpu(const char *typename, int64_t = apic_id, Error **errp) error_propagate(errp, local_err); } =20 -void pc_hot_add_cpu(const int64_t id, Error **errp) +void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) { - MachineState *ms =3D MACHINE(qdev_get_machine()); int64_t apic_id =3D x86_cpu_apic_id_from_index(id); Error *local_err =3D NULL; =20 @@ -2619,7 +2618,7 @@ static void pc_machine_initfn(Object *obj) pc_system_flash_create(pcms); } =20 -static void pc_machine_reset(void) +static void pc_machine_reset(MachineState *machine) { CPUState *cs; X86CPU *cpu; diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 37ec89b07e..132127882d 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1124,15 +1124,15 @@ static void main_cpu_reset(void *opaque) } } =20 -static void create_cpu_without_cps(const char *cpu_type, +static void create_cpu_without_cps(MachineState *ms, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { CPUMIPSState *env; MIPSCPU *cpu; int i; =20 - for (i =3D 0; i < smp_cpus; i++) { - cpu =3D MIPS_CPU(cpu_create(cpu_type)); + for (i =3D 0; i < ms->smp.cpus; i++) { + cpu =3D MIPS_CPU(cpu_create(ms->cpu_type)); =20 /* Init internal devices */ cpu_mips_irq_init_cpu(cpu); @@ -1146,15 +1146,15 @@ static void create_cpu_without_cps(const char *cpu_= type, *cbus_irq =3D env->irq[4]; } =20 -static void create_cps(MaltaState *s, const char *cpu_type, +static void create_cps(MachineState *ms, MaltaState *s, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { Error *err =3D NULL; =20 sysbus_init_child_obj(OBJECT(s), "cps", OBJECT(&s->cps), sizeof(s->cps= ), TYPE_MIPS_CPS); - object_property_set_str(OBJECT(&s->cps), cpu_type, "cpu-type", &err); - object_property_set_int(OBJECT(&s->cps), smp_cpus, "num-vp", &err); + object_property_set_str(OBJECT(&s->cps), ms->cpu_type, "cpu-type", &er= r); + object_property_set_int(OBJECT(&s->cps), ms->smp.cpus, "num-vp", &err); object_property_set_bool(OBJECT(&s->cps), true, "realized", &err); if (err !=3D NULL) { error_report("%s", error_get_pretty(err)); @@ -1167,13 +1167,13 @@ static void create_cps(MaltaState *s, const char *c= pu_type, *cbus_irq =3D NULL; } =20 -static void mips_create_cpu(MaltaState *s, const char *cpu_type, +static void mips_create_cpu(MachineState *ms, MaltaState *s, qemu_irq *cbus_irq, qemu_irq *i8259_irq) { - if ((smp_cpus > 1) && cpu_supports_cps_smp(cpu_type)) { - create_cps(s, cpu_type, cbus_irq, i8259_irq); + if ((ms->smp.cpus > 1) && cpu_supports_cps_smp(ms->cpu_type)) { + create_cps(ms, s, cbus_irq, i8259_irq); } else { - create_cpu_without_cps(cpu_type, cbus_irq, i8259_irq); + create_cpu_without_cps(ms, cbus_irq, i8259_irq); } } =20 @@ -1217,7 +1217,7 @@ void mips_malta_init(MachineState *machine) qdev_init_nofail(dev); =20 /* create CPU */ - mips_create_cpu(s, machine->cpu_type, &cbus_irq, &i8259_irq); + mips_create_cpu(machine, s, &cbus_irq, &i8259_irq); =20 /* allocate RAM */ if (ram_size > 2 * GiB) { diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 9db43916ac..1cac1bd227 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -529,9 +529,8 @@ static void pnv_powerdown_notify(Notifier *n, void *opa= que) } } =20 -static void pnv_reset(void) +static void pnv_reset(MachineState *machine) { - MachineState *machine =3D MACHINE(qdev_get_machine()); PnvMachineState *pnv =3D PNV_MACHINE(machine); void *fdt; Object *obj; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b502fcac2e..6cf0ac400b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1691,9 +1691,8 @@ static int spapr_reset_drcs(Object *child, void *opaq= ue) return 0; } =20 -static void spapr_machine_reset(void) +static void spapr_machine_reset(MachineState *machine) { - MachineState *machine =3D MACHINE(qdev_get_machine()); SpaprMachineState *spapr =3D SPAPR_MACHINE(machine); PowerPCCPU *first_ppc_cpu; uint32_t rtas_limit; diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 87b2039f1b..e09bf8f1b6 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -339,7 +339,7 @@ static inline void s390_do_cpu_ipl(CPUState *cs, run_on= _cpu_data arg) s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); } =20 -static void s390_machine_reset(void) +static void s390_machine_reset(MachineState *machine) { enum s390_reset reset_type; CPUState *cs, *t; @@ -440,9 +440,9 @@ static HotplugHandler *s390_get_hotplug_handler(Machine= State *machine, return NULL; } =20 -static void s390_hot_add_cpu(const int64_t id, Error **errp) +static void s390_hot_add_cpu(MachineState *machine, + const int64_t id, Error **errp) { - MachineState *machine =3D MACHINE(qdev_get_machine()); ObjectClass *oc; =20 g_assert(machine->possible_cpus->cpus[0].cpu); diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a36448fc8d..7bcd67b098 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -27,6 +27,7 @@ #include "sysemu/cpus.h" #include "hw/firmware/smbios.h" #include "hw/loader.h" +#include "hw/boards.h" #include "exec/cpu-common.h" #include "smbios_build.h" =20 @@ -341,9 +342,10 @@ static void smbios_register_config(void) =20 opts_init(smbios_register_config); =20 -static void smbios_validate_table(void) +static void smbios_validate_table(MachineState *ms) { - uint32_t expect_t4_count =3D smbios_legacy ? smp_cpus : smbios_smp_soc= kets; + uint32_t expect_t4_count =3D smbios_legacy ? + ms->smp.cpus : smbios_smp_sockets; =20 if (smbios_type4_count && smbios_type4_count !=3D expect_t4_count) { error_report("Expected %d SMBIOS Type 4 tables, got %d instead", @@ -428,7 +430,7 @@ static void smbios_build_type_1_fields(void) } } =20 -uint8_t *smbios_get_table_legacy(size_t *length) +uint8_t *smbios_get_table_legacy(MachineState *ms, size_t *length) { if (!smbios_legacy) { *length =3D 0; @@ -438,7 +440,7 @@ uint8_t *smbios_get_table_legacy(size_t *length) if (!smbios_immutable) { smbios_build_type_0_fields(); smbios_build_type_1_fields(); - smbios_validate_table(); + smbios_validate_table(ms); smbios_immutable =3D true; } *length =3D smbios_entries_len; @@ -570,7 +572,7 @@ static void smbios_build_type_3_table(void) SMBIOS_BUILD_TABLE_POST; } =20 -static void smbios_build_type_4_table(unsigned instance) +static void smbios_build_type_4_table(MachineState *ms, unsigned instance) { char sock_str[128]; =20 @@ -597,8 +599,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 =3D t->core_enabled =3D smp_cores; - t->thread_count =3D smp_threads; + t->core_count =3D t->core_enabled =3D ms->smp.cores; + t->thread_count =3D ms->smp.threads; t->processor_characteristics =3D cpu_to_le16(0x02); /* Unknown */ t->processor_family2 =3D cpu_to_le16(0x01); /* Other */ =20 @@ -839,7 +841,8 @@ static void smbios_entry_point_setup(void) } } =20 -void smbios_get_tables(const struct smbios_phys_mem_area *mem_array, +void smbios_get_tables(MachineState *ms, + const struct smbios_phys_mem_area *mem_array, const unsigned int mem_array_size, uint8_t **tables, size_t *tables_len, uint8_t **anchor, size_t *anchor_len) @@ -858,11 +861,12 @@ void smbios_get_tables(const struct smbios_phys_mem_a= rea *mem_array, smbios_build_type_2_table(); smbios_build_type_3_table(); =20 - smbios_smp_sockets =3D DIV_ROUND_UP(smp_cpus, smp_cores * smp_thre= ads); + smbios_smp_sockets =3D DIV_ROUND_UP(ms->smp.cpus, + ms->smp.cores * ms->smp.threads); assert(smbios_smp_sockets >=3D 1); =20 for (i =3D 0; i < smbios_smp_sockets; i++) { - smbios_build_type_4_table(i); + smbios_build_type_4_table(ms, i); } =20 smbios_build_type_11_table(); @@ -888,7 +892,7 @@ void smbios_get_tables(const struct smbios_phys_mem_are= a *mem_array, smbios_build_type_38_table(); smbios_build_type_127_table(); =20 - smbios_validate_table(); + smbios_validate_table(ms); smbios_entry_point_setup(); smbios_immutable =3D true; } diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 01ce77e129..27585cd743 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -124,7 +124,7 @@ void qmp_cpu_add(int64_t id, Error **errp) =20 mc =3D MACHINE_GET_CLASS(current_machine); if (mc->hot_add_cpu) { - mc->hot_add_cpu(id, errp); + mc->hot_add_cpu(current_machine, id, errp); } else { error_setg(errp, "Not supported"); } diff --git a/vl.c b/vl.c index e9698cb1b1..918e8413ef 100644 --- a/vl.c +++ b/vl.c @@ -1617,7 +1617,7 @@ void qemu_system_reset(ShutdownCause reason) cpu_synchronize_all_states(); =20 if (mc && mc->reset) { - mc->reset(); + mc->reset(current_machine); } else { qemu_devices_reset(); } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748170; cv=none; d=zoho.com; s=zohoarc; b=l5208lRUfzoGBnwCvu6mU+uoFIsVzkWIZinbTiBSGdSE7W6PNL5MbcANn15bRNVgOI7+o8CTC34dczi6yuNLydOgNwtpC5Q4vd9+B2uQ35su+Xw+EDmL4ZHqk2ny/HEX2iHyxvURKwsxIQXztd+YjLcdrgq1bYli0XNESAKXYiI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748170; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oiK1TCaZjT0q0IQUsElrsILsCIkz971g0GPjh+iItpg=; b=bZKGAXNPM7ZGsbEx/5EVdt1zyPpBJA8oyBqK31b/V036UsuXg5AApJhcDeu51VoS87QYgYtP3wAMfAs/Kass0nmEr6DroaoOZjP1NHqaFx4Kf/XkfVAUCF5kmc1aFAua84KvdGuLRSRD3nxSFQ7dpajRda+9G1Gjqf4ONt6fVOo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748170645988.6180553638175; Fri, 28 Jun 2019 11:56:10 -0700 (PDT) Received: from localhost ([::1]:35546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw2V-0007nY-Md for importer@patchew.org; Fri, 28 Jun 2019 14:56:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40145) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvv3-0001zq-TO for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvv0-00010m-8M for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44128) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvuz-0000pj-TT for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2643F2F8BE7; Fri, 28 Jun 2019 18:48:08 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CE7F5C882; Fri, 28 Jun 2019 18:48:06 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:16 -0300 Message-Id: <20190628184742.5961-4-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 28 Jun 2019 18:48:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 03/29] general: Replace global smp variables with smp machine properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu Basically, the context could get the MachineState reference via call chains or unrecommended qdev_get_machine() in !CONFIG_USER_ONLY mode. A local variable of the same name would be introduced in the declaration phase out of less effort OR replace it on the spot if it's only used once in the context. No semantic changes. Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-4-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- accel/kvm/kvm-all.c | 4 ++-- backends/hostmem.c | 6 ++++-- cpus.c | 6 ++++-- exec.c | 3 ++- gdbstub.c | 4 ++++ hw/cpu/core.c | 4 +++- migration/postcopy-ram.c | 8 +++++++- numa.c | 1 + target/openrisc/sys_helper.c | 6 +++++- tcg/tcg.c | 13 ++++++++++++- 10 files changed, 44 insertions(+), 11 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index e3cf72883b..3d86ae5052 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1542,8 +1542,8 @@ static int kvm_init(MachineState *ms) const char *name; int num; } num_cpus[] =3D { - { "SMP", smp_cpus }, - { "hotpluggable", max_cpus }, + { "SMP", ms->smp.cpus }, + { "hotpluggable", ms->smp.max_cpus }, { NULL, } }, *nc =3D num_cpus; int soft_vcpus_limit, hard_vcpus_limit; diff --git a/backends/hostmem.c b/backends/hostmem.c index 04baf479a1..463102aa15 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -222,6 +222,7 @@ static void host_memory_backend_set_prealloc(Object *ob= j, bool value, { Error *local_err =3D NULL; HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); + MachineState *ms =3D MACHINE(qdev_get_machine()); =20 if (backend->force_prealloc) { if (value) { @@ -241,7 +242,7 @@ static void host_memory_backend_set_prealloc(Object *ob= j, bool value, void *ptr =3D memory_region_get_ram_ptr(&backend->mr); uint64_t sz =3D memory_region_size(&backend->mr); =20 - os_mem_prealloc(fd, ptr, sz, smp_cpus, &local_err); + os_mem_prealloc(fd, ptr, sz, ms->smp.cpus, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -311,6 +312,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) { HostMemoryBackend *backend =3D MEMORY_BACKEND(uc); HostMemoryBackendClass *bc =3D MEMORY_BACKEND_GET_CLASS(uc); + MachineState *ms =3D MACHINE(qdev_get_machine()); Error *local_err =3D NULL; void *ptr; uint64_t sz; @@ -375,7 +377,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) */ if (backend->prealloc) { os_mem_prealloc(memory_region_get_fd(&backend->mr), ptr, sz, - smp_cpus, &local_err); + ms->smp.cpus, &local_err); if (local_err) { goto out; } diff --git a/cpus.c b/cpus.c index 1af51b73dd..86b91fcd56 100644 --- a/cpus.c +++ b/cpus.c @@ -2078,8 +2078,10 @@ static void qemu_dummy_start_vcpu(CPUState *cpu) =20 void qemu_init_vcpu(CPUState *cpu) { - cpu->nr_cores =3D smp_cores; - cpu->nr_threads =3D smp_threads; + MachineState *ms =3D MACHINE(qdev_get_machine()); + + cpu->nr_cores =3D ms->smp.cores; + cpu->nr_threads =3D ms->smp.threads; cpu->stopped =3D true; cpu->random_seed =3D qemu_guest_random_seed_thread_part1(); =20 diff --git a/exec.c b/exec.c index e7622d1956..50ea9c5aaa 100644 --- a/exec.c +++ b/exec.c @@ -1874,6 +1874,7 @@ static void *file_ram_alloc(RAMBlock *block, bool truncate, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); void *area; =20 block->page_size =3D qemu_fd_getpagesize(fd); @@ -1930,7 +1931,7 @@ static void *file_ram_alloc(RAMBlock *block, } =20 if (mem_prealloc) { - os_mem_prealloc(fd, area, memory, smp_cpus, errp); + os_mem_prealloc(fd, area, memory, ms->smp.cpus, errp); if (errp && *errp) { qemu_ram_munmap(fd, area, memory); return NULL; diff --git a/gdbstub.c b/gdbstub.c index 8618e34311..687c02e598 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -34,6 +34,7 @@ #include "sysemu/sysemu.h" #include "exec/gdbstub.h" #include "hw/cpu/cluster.h" +#include "hw/boards.h" #endif =20 #define MAX_PACKET_LENGTH 4096 @@ -1171,6 +1172,9 @@ static int gdb_handle_vcont(GDBState *s, const char *= p) CPU_FOREACH(cpu) { max_cpus =3D max_cpus <=3D cpu->cpu_index ? cpu->cpu_index + 1 : m= ax_cpus; } +#else + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; #endif /* uninitialised CPUs stay 0 */ newstates =3D g_new0(char, max_cpus); diff --git a/hw/cpu/core.c b/hw/cpu/core.c index e57c73f0ce..9874c5c870 100644 --- a/hw/cpu/core.c +++ b/hw/cpu/core.c @@ -13,6 +13,7 @@ #include "qemu/module.h" #include "qapi/error.h" #include "sysemu/cpus.h" +#include "hw/boards.h" =20 static void core_prop_get_core_id(Object *obj, Visitor *v, const char *nam= e, void *opaque, Error **errp) @@ -71,13 +72,14 @@ static void core_prop_set_nr_threads(Object *obj, Visit= or *v, const char *name, =20 static void cpu_core_instance_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); CPUCore *core =3D CPU_CORE(obj); =20 object_property_add(obj, "core-id", "int", core_prop_get_core_id, core_prop_set_core_id, NULL, NULL, NULL); object_property_add(obj, "nr-threads", "int", core_prop_get_nr_threads, core_prop_set_nr_threads, NULL, NULL, NULL); - core->nr_threads =3D smp_threads; + core->nr_threads =3D ms->smp.threads; } =20 static void cpu_core_class_init(ObjectClass *oc, void *data) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index e2aa57a701..9faacacc9e 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -29,6 +29,7 @@ #include "sysemu/balloon.h" #include "qemu/error-report.h" #include "trace.h" +#include "hw/boards.h" =20 /* Arbitrary limit on size of each discard command, * keeps them around ~200 bytes @@ -128,6 +129,8 @@ static void migration_exit_cb(Notifier *n, void *data) =20 static struct PostcopyBlocktimeContext *blocktime_context_new(void) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; PostcopyBlocktimeContext *ctx =3D g_new0(PostcopyBlocktimeContext, 1); ctx->page_fault_vcpu_time =3D g_new0(uint32_t, smp_cpus); ctx->vcpu_addr =3D g_new0(uintptr_t, smp_cpus); @@ -141,10 +144,11 @@ static struct PostcopyBlocktimeContext *blocktime_con= text_new(void) =20 static uint32List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx) { + MachineState *ms =3D MACHINE(qdev_get_machine()); uint32List *list =3D NULL, *entry =3D NULL; int i; =20 - for (i =3D smp_cpus - 1; i >=3D 0; i--) { + for (i =3D ms->smp.cpus - 1; i >=3D 0; i--) { entry =3D g_new0(uint32List, 1); entry->value =3D ctx->vcpu_blocktime[i]; entry->next =3D list; @@ -807,6 +811,8 @@ static void mark_postcopy_blocktime_end(uintptr_t addr) { MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyBlocktimeContext *dc =3D mis->blocktime_ctx; + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; int i, affected_cpu =3D 0; bool vcpu_total_blocktime =3D false; uint32_t read_vcpu_time, low_time_offset; diff --git a/numa.c b/numa.c index 955ec0c830..7594eb5a7e 100644 --- a/numa.c +++ b/numa.c @@ -64,6 +64,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeOpt= ions *node, uint16_t nodenr; uint16List *cpus =3D NULL; MachineClass *mc =3D MACHINE_GET_CLASS(ms); + unsigned int max_cpus =3D ms->smp.max_cpus; =20 if (node->has_nodeid) { nodenr =3D node->nodeid; diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index 8f11cb8202..1053409a04 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -24,6 +24,9 @@ #include "exec/helper-proto.h" #include "exception.h" #include "sysemu/sysemu.h" +#ifndef CONFIG_USER_ONLY +#include "hw/boards.h" +#endif =20 #define TO_SPR(group, number) (((group) << 11) + (number)) =20 @@ -194,6 +197,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, targe= t_ulong rd, target_ulong spr) { #ifndef CONFIG_USER_ONLY + MachineState *ms =3D MACHINE(qdev_get_machine()); OpenRISCCPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); int idx; @@ -241,7 +245,7 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env, targe= t_ulong rd, return cpu->parent_obj.cpu_index; =20 case TO_SPR(0, 129): /* NUMCORES */ - return max_cpus; + return ms->smp.max_cpus; =20 case TO_SPR(0, 1024) ... TO_SPR(0, 1024 + (16 * 32)): /* Shadow GPRs */ idx =3D (spr - 1024); diff --git a/tcg/tcg.c b/tcg/tcg.c index 02a2680169..be2c33c400 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -45,6 +45,10 @@ #include "exec/cpu-common.h" #include "exec/exec-all.h" =20 +#if !defined(CONFIG_USER_ONLY) +#include "hw/boards.h" +#endif + #include "tcg-op.h" =20 #if UINTPTR_MAX =3D=3D UINT32_MAX @@ -620,6 +624,10 @@ static size_t tcg_n_regions(void) size_t i; =20 /* Use a single region if all we have is one vCPU thread */ +#if !defined(CONFIG_USER_ONLY) + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; +#endif if (max_cpus =3D=3D 1 || !qemu_tcg_mttcg_enabled()) { return 1; } @@ -752,6 +760,7 @@ void tcg_register_thread(void) #else void tcg_register_thread(void) { + MachineState *ms =3D MACHINE(qdev_get_machine()); TCGContext *s =3D g_malloc(sizeof(*s)); unsigned int i, n; bool err; @@ -769,7 +778,7 @@ void tcg_register_thread(void) =20 /* Claim an entry in tcg_ctxs */ n =3D atomic_fetch_inc(&n_tcg_ctxs); - g_assert(n < max_cpus); + g_assert(n < ms->smp.max_cpus); atomic_set(&tcg_ctxs[n], s); =20 tcg_ctx =3D s; @@ -979,6 +988,8 @@ void tcg_context_init(TCGContext *s) tcg_ctxs =3D &tcg_ctx; n_tcg_ctxs =3D 1; #else + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; tcg_ctxs =3D g_new(TCGContext *, max_cpus); #endif =20 --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748146; cv=none; d=zoho.com; s=zohoarc; b=YT7295vbVuvVFh4F1eckY5IflNMNj0iqcyov6Ql4Qq0Af/9tJmgDiyw3m22D6D5xSj1qQ/avManQRu+oUbIkcRTczSlHX6ByEJPYr3ve04pcLzztmyg7bAYeiZaiD/gIh/fGof7X12P6t7GOlLYU4MGqgx1N5ULM6ChW4ov2n2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748146; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mGRF2KkC/lVCF+Y7yPZjqgs0a++XzlPXN1FWljOR9wY=; b=WUBREReQBGWVZLdP9QCkOSTvmSs24ducrr8r9bNxtiWPhPbbKfD1jE2HKxY7ON5RkmHpb2Gul8qhU0P/d5pYdvtwcLxl80NopGB5z07FMJvIAlV/Qsfe50iuQmtfkvWTilFZsffOp8t15P3Z0ccMjKthImoVU/wSigNvtwmJShU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748146890465.68415909520945; Fri, 28 Jun 2019 11:55:46 -0700 (PDT) Received: from localhost ([::1]:35544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw26-0007dx-06 for importer@patchew.org; Fri, 28 Jun 2019 14:55:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40164) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvv6-00022X-Cf for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvv2-00014G-R2 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40002) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvv2-00013H-I3 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D745D30C1CBE; Fri, 28 Jun 2019 18:48:19 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56DBF5DA9B; Fri, 28 Jun 2019 18:48:13 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:17 -0300 Message-Id: <20190628184742.5961-5-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 28 Jun 2019 18:48:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 04/29] hw/ppc: Replace global smp variables with machine smp properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in ppc are replaced with smp machine properties. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Message-Id: <20190518205428.90532-5-like.xu@linux.intel.com> Acked-by: David Gibson Signed-off-by: Eduardo Habkost --- hw/ppc/e500.c | 3 +++ hw/ppc/mac_newworld.c | 3 ++- hw/ppc/mac_oldworld.c | 3 ++- hw/ppc/pnv.c | 6 ++++-- hw/ppc/prep.c | 4 ++-- hw/ppc/spapr.c | 34 ++++++++++++++++++++++++++-------- hw/ppc/spapr_rtas.c | 4 +++- 7 files changed, 42 insertions(+), 15 deletions(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index bfda1266af..a3eac7f057 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -308,6 +308,7 @@ static int ppce500_load_device_tree(PPCE500MachineState= *pms, bool dry_run) { MachineState *machine =3D MACHINE(pms); + unsigned int smp_cpus =3D machine->smp.cpus; const PPCE500MachineClass *pmc =3D PPCE500_MACHINE_GET_CLASS(pms); CPUPPCState *env =3D first_cpu->env_ptr; int ret =3D -1; @@ -735,6 +736,7 @@ static DeviceState *ppce500_init_mpic_qemu(PPCE500Machi= neState *pms, SysBusDevice *s; int i, j, k; MachineState *machine =3D MACHINE(pms); + unsigned int smp_cpus =3D machine->smp.cpus; const PPCE500MachineClass *pmc =3D PPCE500_MACHINE_GET_CLASS(pms); =20 dev =3D qdev_create(NULL, TYPE_OPENPIC); @@ -847,6 +849,7 @@ void ppce500_init(MachineState *machine) struct boot_info *boot_info; int dt_size; int i; + unsigned int smp_cpus =3D machine->smp.cpus; /* irq num for pin INTA, INTB, INTC and INTD is 1, 2, 3 and * 4 respectively */ unsigned int pci_irq_nrs[PCI_NUM_PINS] =3D {1, 2, 3, 4}; diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 4d835f32b5..d78d2a7ec4 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -136,6 +136,7 @@ static void ppc_core99_init(MachineState *machine) DeviceState *dev, *pic_dev; hwaddr nvram_addr =3D 0xFFF04000; uint64_t tbfreq; + unsigned int smp_cpus =3D machine->smp.cpus; =20 linux_boot =3D (kernel_filename !=3D NULL); =20 @@ -465,7 +466,7 @@ static void ppc_core99_init(MachineState *machine) sysbus_mmio_map(s, 1, CFG_ADDR + 2); =20 fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpu= s); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, machine_arch); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index eddd005a7c..4bc4f365a4 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -101,6 +101,7 @@ static void ppc_heathrow_init(MachineState *machine) DeviceState *dev, *pic_dev; BusState *adb_bus; int bios_size; + unsigned int smp_cpus =3D machine->smp.cpus; uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -324,7 +325,7 @@ static void ppc_heathrow_init(MachineState *machine) sysbus_mmio_map(s, 1, CFG_ADDR + 2); =20 fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpu= s); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 1cac1bd227..41b21015ae 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -688,7 +688,8 @@ static void pnv_init(MachineState *machine) object_property_add_child(OBJECT(pnv), chip_name, chip, &error_fat= al); object_property_set_int(chip, PNV_CHIP_HWID(i), "chip-id", &error_fatal); - object_property_set_int(chip, smp_cores, "nr-cores", &error_fatal); + object_property_set_int(chip, machine->smp.cores, + "nr-cores", &error_fatal); object_property_set_bool(chip, true, "realized", &error_fatal); } g_free(chip_typename); @@ -1142,6 +1143,7 @@ static void pnv_chip_instance_init(Object *obj) =20 static void pnv_chip_core_realize(PnvChip *chip, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); Error *error =3D NULL; PnvChipClass *pcc =3D PNV_CHIP_GET_CLASS(chip); const char *typename =3D pnv_chip_core_typename(chip); @@ -1175,7 +1177,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Erro= r **errp) snprintf(core_name, sizeof(core_name), "core[%d]", core_hwid); object_initialize_child(OBJECT(chip), core_name, pnv_core, typesiz= e, typename, &error_fatal, NULL); - object_property_set_int(OBJECT(pnv_core), smp_threads, "nr-threads= ", + object_property_set_int(OBJECT(pnv_core), ms->smp.threads, "nr-thr= eads", &error_fatal); object_property_set_int(OBJECT(pnv_core), core_hwid, CPU_CORE_PROP_CORE_ID, &error_fatal); diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 2a8009e20b..f60c1120b8 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -428,7 +428,7 @@ static void ppc_prep_init(MachineState *machine) linux_boot =3D (kernel_filename !=3D NULL); =20 /* init CPUs */ - for (i =3D 0; i < smp_cpus; i++) { + for (i =3D 0; i < machine->smp.cpus; i++) { cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); env =3D &cpu->env; =20 @@ -770,7 +770,7 @@ static void ibm_40p_init(MachineState *machine) boot_device =3D machine->boot_order[0]; } =20 - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpu= s); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_PREP); =20 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6cf0ac400b..51256ac9ca 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -106,6 +106,9 @@ */ static int spapr_vcpu_id(SpaprMachineState *spapr, int cpu_index) { + MachineState *ms =3D MACHINE(spapr); + unsigned int smp_threads =3D ms->smp.threads; + assert(spapr->vsmt); return (cpu_index / smp_threads) * spapr->vsmt + cpu_index % smp_threads; @@ -153,8 +156,10 @@ static void pre_2_10_vmstate_unregister_dummy_icp(int = i) =20 int spapr_max_server_number(SpaprMachineState *spapr) { + MachineState *ms =3D MACHINE(spapr); + assert(spapr->vsmt); - return DIV_ROUND_UP(max_cpus * spapr->vsmt, smp_threads); + return DIV_ROUND_UP(ms->smp.max_cpus * spapr->vsmt, ms->smp.threads); } =20 static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu, @@ -287,6 +292,7 @@ static void spapr_populate_pa_features(SpaprMachineStat= e *spapr, =20 static int spapr_fixup_cpu_dt(void *fdt, SpaprMachineState *spapr) { + MachineState *ms =3D MACHINE(spapr); int ret =3D 0, offset, cpus_offset; CPUState *cs; char cpu_model[32]; @@ -296,7 +302,7 @@ static int spapr_fixup_cpu_dt(void *fdt, SpaprMachineSt= ate *spapr) PowerPCCPU *cpu =3D POWERPC_CPU(cs); DeviceClass *dc =3D DEVICE_GET_CLASS(cs); int index =3D spapr_get_vcpu_id(cpu); - int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); + int compat_smt =3D MIN(ms->smp.threads, ppc_compat_max_vthreads(cp= u)); =20 if (!spapr_is_thread0_in_vcore(spapr, cpu)) { continue; @@ -442,6 +448,7 @@ static int spapr_populate_memory(SpaprMachineState *spa= pr, void *fdt) static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset, SpaprMachineState *spapr) { + MachineState *ms =3D MACHINE(spapr); PowerPCCPU *cpu =3D POWERPC_CPU(cs); CPUPPCState *env =3D &cpu->env; PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cs); @@ -453,7 +460,8 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *f= dt, int offset, uint32_t cpufreq =3D kvm_enabled() ? kvmppc_get_clockfreq() : 10000000= 00; uint32_t page_sizes_prop[64]; size_t page_sizes_prop_size; - uint32_t vcpus_per_socket =3D smp_threads * smp_cores; + unsigned int smp_threads =3D ms->smp.threads; + uint32_t vcpus_per_socket =3D smp_threads * ms->smp.cores; uint32_t pft_size_prop[] =3D {0, cpu_to_be32(spapr->htab_shift)}; int compat_smt =3D MIN(smp_threads, ppc_compat_max_vthreads(cpu)); SpaprDrc *drc; @@ -1026,6 +1034,7 @@ int spapr_h_cas_compose_response(SpaprMachineState *s= papr, =20 static void spapr_dt_rtas(SpaprMachineState *spapr, void *fdt) { + MachineState *ms =3D MACHINE(spapr); int rtas; GString *hypertas =3D g_string_sized_new(256); GString *qemu_hypertas =3D g_string_sized_new(256); @@ -1036,7 +1045,7 @@ static void spapr_dt_rtas(SpaprMachineState *spapr, v= oid *fdt) cpu_to_be32(max_device_addr >> 32), cpu_to_be32(max_device_addr & 0xffffffff), 0, cpu_to_be32(SPAPR_MEMORY_BLOCK_SIZE), - cpu_to_be32(max_cpus / smp_threads), + cpu_to_be32(ms->smp.max_cpus / ms->smp.threads), }; uint32_t maxdomain =3D cpu_to_be32(spapr->gpu_numa_id > 1 ? 1 : 0); uint32_t maxdomains[] =3D { @@ -2543,7 +2552,7 @@ static void spapr_validate_node_memory(MachineState *= machine, Error **errp) /* find cpu slot in machine->possible_cpus by core_id */ static CPUArchId *spapr_find_cpu_slot(MachineState *ms, uint32_t id, int *= idx) { - int index =3D id / smp_threads; + int index =3D id / ms->smp.threads; =20 if (index >=3D ms->possible_cpus->len) { return NULL; @@ -2556,10 +2565,12 @@ static CPUArchId *spapr_find_cpu_slot(MachineState = *ms, uint32_t id, int *idx) =20 static void spapr_set_vsmt_mode(SpaprMachineState *spapr, Error **errp) { + MachineState *ms =3D MACHINE(spapr); Error *local_err =3D NULL; bool vsmt_user =3D !!spapr->vsmt; int kvm_smt =3D kvmppc_smt_threads(); int ret; + unsigned int smp_threads =3D ms->smp.threads; =20 if (!kvm_enabled() && (smp_threads > 1)) { error_setg(&local_err, "TCG cannot support more than 1 thread/core= " @@ -2633,6 +2644,9 @@ static void spapr_init_cpus(SpaprMachineState *spapr) SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(machine); const char *type =3D spapr_get_cpu_core_type(machine->cpu_type); const CPUArchIdList *possible_cpus; + unsigned int smp_cpus =3D machine->smp.cpus; + unsigned int smp_threads =3D machine->smp.threads; + unsigned int max_cpus =3D machine->smp.max_cpus; int boot_cores_nr =3D smp_cpus / smp_threads; int i; =20 @@ -3859,6 +3873,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, const char *type =3D object_get_typename(OBJECT(dev)); CPUArchId *core_slot; int index; + unsigned int smp_threads =3D machine->smp.threads; =20 if (dev->hotplugged && !mc->has_hotpluggable_cpus) { error_setg(&local_err, "CPU hotplug not supported for this machine= "); @@ -4124,14 +4139,16 @@ spapr_cpu_index_to_props(MachineState *machine, uns= igned cpu_index) =20 static int64_t spapr_get_default_cpu_node_id(const MachineState *ms, int i= dx) { - return idx / smp_cores % nb_numa_nodes; + return idx / ms->smp.cores % nb_numa_nodes; } =20 static const CPUArchIdList *spapr_possible_cpu_arch_ids(MachineState *mach= ine) { int i; + unsigned int smp_threads =3D machine->smp.threads; + unsigned int smp_cpus =3D machine->smp.cpus; const char *core_type; - int spapr_max_cores =3D max_cpus / smp_threads; + int spapr_max_cores =3D machine->smp.max_cpus / smp_threads; MachineClass *mc =3D MACHINE_GET_CLASS(machine); =20 if (!mc->has_hotpluggable_cpus) { @@ -4254,6 +4271,7 @@ int spapr_get_vcpu_id(PowerPCCPU *cpu) void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + MachineState *ms =3D MACHINE(spapr); int vcpu_id; =20 vcpu_id =3D spapr_vcpu_id(spapr, cpu_index); @@ -4262,7 +4280,7 @@ void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index= , Error **errp) error_setg(errp, "Can't create CPU with id %d in KVM", vcpu_id); error_append_hint(errp, "Adjust the number of cpus to %d " "or try to raise the number of threads per core\= n", - vcpu_id * smp_threads / spapr->vsmt); + vcpu_id * ms->smp.threads / spapr->vsmt); return; } =20 diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c index 5bc1a93271..a618a2ac0f 100644 --- a/hw/ppc/spapr_rtas.c +++ b/hw/ppc/spapr_rtas.c @@ -235,6 +235,8 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *c= pu, target_ulong args, uint32_t nret, target_ulong rets) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; target_ulong parameter =3D rtas_ld(args, 0); target_ulong buffer =3D rtas_ld(args, 1); target_ulong length =3D rtas_ld(args, 2); @@ -248,7 +250,7 @@ static void rtas_ibm_get_system_parameter(PowerPCCPU *c= pu, "MaxPlatProcs=3D%d", max_cpus, current_machine->ram_size / MiB, - smp_cpus, + ms->smp.cpus, max_cpus); ret =3D sysparm_st(buffer, length, param_val, strlen(param_val) + = 1); g_free(param_val); --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748175; cv=none; d=zoho.com; s=zohoarc; b=AQnCUTNWA7PXpOhan+3YQRpyZpDNDLkPyQlX1EX+GBecxeCftGvIEKSFnBFoF2kxmTXlk/OPegNjnYY143zKlVakmfZADU3yMLSZljkNOBbYwFmZFPmAyOUbEMDkX458fM7mIPJPY1RgTliCxkB1LtC6olNO+0/DlR2oPg6sTsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748175; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=x7CCYfkk9BOp3hR6i5ahuwrPzhBnbhQa+o1qqhYQXns=; b=RO+7BfetK9cw11DYHKRMvgdB+zU3Cjz14NQ6GFBVconO4opOJi3xiEhVsMdxW1k+px4HGBrt2YTJEDaiILg4fhMr2WF8ZzP3ebLk6tW/VgC5PV9F/hmxwaKLonKT2O8v3zV7Ov9vl0Zf/7IKbcGkRiALhuvysybyfUqv/2u0pvQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748175538786.36795653505; Fri, 28 Jun 2019 11:56:15 -0700 (PDT) Received: from localhost ([::1]:35548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw2e-0007tF-Ls for importer@patchew.org; Fri, 28 Jun 2019 14:56:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40200) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvv9-00025c-HD for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvv6-00018Q-Na for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvv6-00017U-E1 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:24 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7CAD2F8BCC; Fri, 28 Jun 2019 18:48:23 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12CF5608CA; Fri, 28 Jun 2019 18:48:22 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:18 -0300 Message-Id: <20190628184742.5961-6-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 28 Jun 2019 18:48:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 05/29] hw/riscv: Replace global smp variables with machine smp properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in riscv are replaced with smp machine properties. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Message-Id: <20190518205428.90532-6-like.xu@linux.intel.com> Reviewed-by: Alistair Francis [ehabkost: fix spike_board_init()] Signed-off-by: Eduardo Habkost --- hw/riscv/sifive_e.c | 6 ++++-- hw/riscv/sifive_plic.c | 3 +++ hw/riscv/sifive_u.c | 6 ++++-- hw/riscv/spike.c | 3 +++ hw/riscv/virt.c | 1 + 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 80ac56fa7d..bd25e11a87 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -137,6 +137,7 @@ static void riscv_sifive_e_init(MachineState *machine) =20 static void riscv_sifive_e_soc_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); SiFiveESoCState *s =3D RISCV_E_SOC(obj); =20 object_initialize_child(obj, "cpus", &s->cpus, @@ -144,7 +145,7 @@ static void riscv_sifive_e_soc_init(Object *obj) &error_abort, NULL); object_property_set_str(OBJECT(&s->cpus), SIFIVE_E_CPU, "cpu-type", &error_abort); - object_property_set_int(OBJECT(&s->cpus), smp_cpus, "num-harts", + object_property_set_int(OBJECT(&s->cpus), ms->smp.cpus, "num-harts", &error_abort); sysbus_init_child_obj(obj, "riscv.sifive.e.gpio0", &s->gpio, sizeof(s->gpio), @@ -153,6 +154,7 @@ static void riscv_sifive_e_soc_init(Object *obj) =20 static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); const struct MemmapEntry *memmap =3D sifive_e_memmap; Error *err =3D NULL; =20 @@ -183,7 +185,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev= , Error **errp) SIFIVE_E_PLIC_CONTEXT_STRIDE, memmap[SIFIVE_E_PLIC].size); sifive_clint_create(memmap[SIFIVE_E_CLINT].base, - memmap[SIFIVE_E_CLINT].size, smp_cpus, + memmap[SIFIVE_E_CLINT].size, ms->smp.cpus, SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE); sifive_mmio_emulate(sys_mem, "riscv.sifive.e.aon", memmap[SIFIVE_E_AON].base, memmap[SIFIVE_E_AON].size); diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c index 70a4413599..0950e89e15 100644 --- a/hw/riscv/sifive_plic.c +++ b/hw/riscv/sifive_plic.c @@ -24,6 +24,7 @@ #include "qemu/error-report.h" #include "hw/sysbus.h" #include "hw/pci/msi.h" +#include "hw/boards.h" #include "target/riscv/cpu.h" #include "sysemu/sysemu.h" #include "hw/riscv/sifive_plic.h" @@ -439,6 +440,8 @@ static void sifive_plic_irq_request(void *opaque, int i= rq, int level) =20 static void sifive_plic_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; SiFivePLICState *plic =3D SIFIVE_PLIC(dev); int i; =20 diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index 5ecc47cea3..43bf256946 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -321,13 +321,14 @@ static void riscv_sifive_u_init(MachineState *machine) =20 static void riscv_sifive_u_soc_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); SiFiveUSoCState *s =3D RISCV_U_SOC(obj); =20 object_initialize_child(obj, "cpus", &s->cpus, sizeof(s->cpus), TYPE_RISCV_HART_ARRAY, &error_abort, NULL); object_property_set_str(OBJECT(&s->cpus), SIFIVE_U_CPU, "cpu-type", &error_abort); - object_property_set_int(OBJECT(&s->cpus), smp_cpus, "num-harts", + object_property_set_int(OBJECT(&s->cpus), ms->smp.cpus, "num-harts", &error_abort); =20 sysbus_init_child_obj(obj, "gem", &s->gem, sizeof(s->gem), @@ -336,6 +337,7 @@ static void riscv_sifive_u_soc_init(Object *obj) =20 static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); SiFiveUSoCState *s =3D RISCV_U_SOC(dev); const struct MemmapEntry *memmap =3D sifive_u_memmap; MemoryRegion *system_memory =3D get_system_memory(); @@ -371,7 +373,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev= , Error **errp) sifive_uart_create(system_memory, memmap[SIFIVE_U_UART1].base, serial_hd(1), qdev_get_gpio_in(DEVICE(s->plic), SIFIVE_U_UART1_IRQ= )); sifive_clint_create(memmap[SIFIVE_U_CLINT].base, - memmap[SIFIVE_U_CLINT].size, smp_cpus, + memmap[SIFIVE_U_CLINT].size, ms->smp.cpus, SIFIVE_SIP_BASE, SIFIVE_TIMECMP_BASE, SIFIVE_TIME_BASE); =20 for (i =3D 0; i < SIFIVE_U_PLIC_NUM_SOURCES; i++) { diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 5b33d4be3b..d91d49dcae 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -172,6 +172,7 @@ static void spike_board_init(MachineState *machine) MemoryRegion *main_mem =3D g_new(MemoryRegion, 1); MemoryRegion *mask_rom =3D g_new(MemoryRegion, 1); int i; + unsigned int smp_cpus =3D machine->smp.cpus; =20 /* Initialize SOC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc= ), @@ -254,6 +255,7 @@ static void spike_v1_10_0_board_init(MachineState *mach= ine) MemoryRegion *main_mem =3D g_new(MemoryRegion, 1); MemoryRegion *mask_rom =3D g_new(MemoryRegion, 1); int i; + unsigned int smp_cpus =3D machine->smp.cpus; =20 if (!qtest_enabled()) { info_report("The Spike v1.10.0 machine has been deprecated. " @@ -342,6 +344,7 @@ static void spike_v1_09_1_board_init(MachineState *mach= ine) MemoryRegion *main_mem =3D g_new(MemoryRegion, 1); MemoryRegion *mask_rom =3D g_new(MemoryRegion, 1); int i; + unsigned int smp_cpus =3D machine->smp.cpus; =20 if (!qtest_enabled()) { info_report("The Spike v1.09.1 machine has been deprecated. " diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 84d94d0c42..8e11fe5f2f 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -394,6 +394,7 @@ static void riscv_virt_board_init(MachineState *machine) char *plic_hart_config; size_t plic_hart_config_len; int i; + unsigned int smp_cpus =3D machine->smp.cpus; void *fdt; =20 /* Initialize SOC */ --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748417; cv=none; d=zoho.com; s=zohoarc; b=PNMuWukJnbL1u62wL4A061bcV38Cy6oDFkGOgyxD6aYBOUXuP+QMwAFx+j30nX4rBXx99gZXXHx0QLcOiwOz8Y2AV/8x1ptqLgvi9SAVl9JwytuI0NM1Tnzub3Gzuezr0J5yrGUdeviZawajGGZSayCC3xDjPFBzRK9skPDBpg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748417; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lKxSG3Afg9C0uJt2rf6OI0QtuvDyLbMtgRRy/AyxCwc=; b=c8I4jYqT8YitAsS5PvPnGq8BJwMVIcnAwUZD8G0o/U51g4dLA0rc9FtWud/GGM4/N/RP7CGluUQ59KbnX38qf/FId6L9qdHJ4LJSLZEcKe3E7iud/Q9GON/GeehSc7CJgH3dSfaSckTVN7R+18FUS6+uo4iwJSwN91qV0FiJHvQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748417551663.2336086789351; Fri, 28 Jun 2019 12:00:17 -0700 (PDT) Received: from localhost ([::1]:35575 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw6Q-0003Om-4f for importer@patchew.org; Fri, 28 Jun 2019 15:00:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40237) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvvN-0002Bp-Cp for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvvJ-0001Xb-MN for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34490) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvvJ-0001VA-EB for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:37 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35679B2DC5; Fri, 28 Jun 2019 18:48:31 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id D98485C730; Fri, 28 Jun 2019 18:48:25 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:19 -0300 Message-Id: <20190628184742.5961-7-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 18:48:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 06/29] hw/s390x: Replace global smp variables with machine smp properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in s390x are replaced with smp machine properties. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Message-Id: <20190518205428.90532-7-like.xu@linux.intel.com> Acked-by: Christian Borntraeger Reviewed-by: Cornelia Huck [ehabkost: fix build failure at VCPU_IRQ_BUF_SIZE] Signed-off-by: Eduardo Habkost fixup! hw/s390x: Replace global smp variables with machine smp properties Signed-off-by: Eduardo Habkost --- hw/s390x/s390-virtio-ccw.c | 3 ++- hw/s390x/sclp.c | 2 +- target/s390x/cpu.c | 3 +++ target/s390x/excp_helper.c | 5 +++++ target/s390x/kvm.c | 10 ++++++---- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index e09bf8f1b6..5b6a9a4e55 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -84,7 +84,7 @@ static void s390_init_cpus(MachineState *machine) /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); =20 - for (i =3D 0; i < smp_cpus; i++) { + for (i =3D 0; i < machine->smp.cpus; i++) { s390x_new_cpu(machine->cpu_type, i, &error_fatal); } } @@ -411,6 +411,7 @@ static CpuInstanceProperties s390_cpu_index_to_props(Ma= chineState *ms, static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms) { int i; + unsigned int max_cpus =3D ms->smp.max_cpus; =20 if (ms->possible_cpus) { g_assert(ms->possible_cpus && ms->possible_cpus->len =3D=3D max_cp= us); diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 4510a800cb..fac7c3bb6c 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -64,7 +64,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) prepare_cpu_entries(sclp, read_info->entries, &cpu_count); read_info->entries_cpu =3D cpu_to_be16(cpu_count); read_info->offset_cpu =3D cpu_to_be16(offsetof(ReadInfo, entries)); - read_info->highest_cpu =3D cpu_to_be16(max_cpus - 1); + read_info->highest_cpu =3D cpu_to_be16(machine->smp.max_cpus - 1); =20 read_info->ibc_val =3D cpu_to_be32(s390_get_ibc_val()); =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index f2d93644d5..cafb8fe3f0 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -37,6 +37,7 @@ #include "hw/qdev-properties.h" #ifndef CONFIG_USER_ONLY #include "hw/hw.h" +#include "hw/boards.h" #include "sysemu/arch_init.h" #include "sysemu/sysemu.h" #include "sysemu/tcg.h" @@ -197,6 +198,8 @@ static void s390_cpu_realizefn(DeviceState *dev, Error = **errp) } =20 #if !defined(CONFIG_USER_ONLY) + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; if (cpu->env.core_id >=3D max_cpus) { error_setg(&err, "Unable to add CPU with core-id: %" PRIu32 ", maximum core-id: %d", cpu->env.core_id, diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index 202456cdc5..892f659d5a 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -31,6 +31,7 @@ #ifndef CONFIG_USER_ONLY #include "sysemu/sysemu.h" #include "hw/s390x/s390_flic.h" +#include "hw/boards.h" #endif =20 void QEMU_NORETURN tcg_s390_program_interrupt(CPUS390XState *env, uint32_t= code, @@ -315,6 +316,10 @@ static void do_ext_interrupt(CPUS390XState *env) g_assert(cpu_addr < S390_MAX_CPUS); lowcore->cpu_addr =3D cpu_to_be16(cpu_addr); clear_bit(cpu_addr, env->emergency_signals); +#ifndef CONFIG_USER_ONLY + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; +#endif if (bitmap_empty(env->emergency_signals, max_cpus)) { env->pending_int &=3D ~INTERRUPT_EMERGENCY_SIGNAL; } diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 0267c6c2f6..6e814c230b 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -119,8 +119,8 @@ * Needs to be big enough to contain max_cpus emergency signals * and in addition NR_LOCAL_IRQS interrupts */ -#define VCPU_IRQ_BUF_SIZE (sizeof(struct kvm_s390_irq) * \ - (max_cpus + NR_LOCAL_IRQS)) +#define VCPU_IRQ_BUF_SIZE(max_cpus) (sizeof(struct kvm_s390_irq) * \ + (max_cpus + NR_LOCAL_IRQS)) =20 static CPUWatchpoint hw_watchpoint; /* @@ -362,9 +362,10 @@ unsigned long kvm_arch_vcpu_id(CPUState *cpu) =20 int kvm_arch_init_vcpu(CPUState *cs) { + unsigned int max_cpus =3D MACHINE(qdev_get_machine())->smp.max_cpus; S390CPU *cpu =3D S390_CPU(cs); kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state); - cpu->irqstate =3D g_malloc0(VCPU_IRQ_BUF_SIZE); + cpu->irqstate =3D g_malloc0(VCPU_IRQ_BUF_SIZE(max_cpus)); return 0; } =20 @@ -1950,9 +1951,10 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu= _state) =20 void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu) { + unsigned int max_cpus =3D MACHINE(qdev_get_machine())->smp.max_cpus; struct kvm_s390_irq_state irq_state =3D { .buf =3D (uint64_t) cpu->irqstate, - .len =3D VCPU_IRQ_BUF_SIZE, + .len =3D VCPU_IRQ_BUF_SIZE(max_cpus), }; CPUState *cs =3D CPU(cpu); int32_t bytes; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748406; cv=none; d=zoho.com; s=zohoarc; b=oLhAoVBWN73hkrBfbo0/6s54TFmCbIsgRHY4yma0BBhusol50loc1Off5WQ6SCStbyy2+1W66eRjJ5boIOyq9vo6oMCfyToUgByvP7gISf/f6f8aVwiDzEb56y5/9Hc2v3VYhkv68C2nrQzedENGtEy8LrrUnmdPWbfcHJhjR0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748406; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nepRu4h44ZDQ1bzaVnB5Rx9j6WEaC1aK7YPMrGkqQdA=; b=H50mLtkNrl7tdsuAQVc3obXAZPrgGQe+NFEYZMkzGB4xZNPPLbvauCN7Z1khAxSqC97UOC3WEx70fr7kUsmzI/xd61gq/EaYKmoeEEZaKLA9h9Ou87rSIK2x1IpMYalSj890VtKvbELSbZI8A5cIquZBiBNqNJSyCT7wKpGHgoM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748406237260.84913792550014; Fri, 28 Jun 2019 12:00:06 -0700 (PDT) Received: from localhost ([::1]:35572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw6K-0003Kj-RF for importer@patchew.org; Fri, 28 Jun 2019 15:00:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40264) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvvS-0002J3-7J for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvvP-0001hP-8A for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50320) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvvO-0001f9-H9 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:48:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C65B4316290D; Fri, 28 Jun 2019 18:48:41 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79126600C6; Fri, 28 Jun 2019 18:48:39 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:20 -0300 Message-Id: <20190628184742.5961-8-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 28 Jun 2019 18:48:41 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 07/29] hw/i386: Replace global smp variables with machine smp properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in i386 are replaced with smp machine properties. To avoid calling qdev_get_machine() as much as possible, some related funti= ons for acpi data generations are refactored. No semantic changes. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Message-Id: <20190518205428.90532-8-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/i386/acpi-build.c | 11 +++++++---- hw/i386/kvmvapic.c | 7 +++++-- hw/i386/pc.c | 24 +++++++++++++++--------- hw/i386/xen/xen-hvm.c | 4 ++++ target/i386/cpu.c | 4 +++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 8ae7d88b11..d281ffa89e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -43,6 +43,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" @@ -123,7 +124,8 @@ typedef struct FwCfgTPMConfig { =20 static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg); =20 -static void init_common_fadt_data(Object *o, AcpiFadtData *data) +static void init_common_fadt_data(MachineState *ms, Object *o, + AcpiFadtData *data) { uint32_t io =3D object_property_get_uint(o, ACPI_PM_PROP_PM_IO_BASE, N= ULL); AmlAddressSpace as =3D AML_AS_SYSTEM_IO; @@ -139,7 +141,8 @@ static void init_common_fadt_data(Object *o, AcpiFadtDa= ta *data) * CPUs for more than 8 CPUs, "Clustered Logical" mode has to = be * used */ - ((max_cpus > 8) ? (1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL) = : 0), + ((ms->smp.max_cpus > 8) ? + (1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL) : 0), .int_model =3D 1 /* Multiple APIC */, .rtc_century =3D RTC_CENTURY, .plvl2_lat =3D 0xfff /* C2 state not supported */, @@ -173,7 +176,7 @@ static Object *object_resolve_type_unambiguous(const ch= ar *typename) return o; } =20 -static void acpi_get_pm_info(AcpiPmInfo *pm) +static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) { Object *piix =3D object_resolve_type_unambiguous(TYPE_PIIX4_PM); Object *lpc =3D object_resolve_type_unambiguous(TYPE_ICH9_LPC_DEVICE); @@ -2612,7 +2615,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState= *machine) AcpiSlicOem slic_oem =3D { .id =3D NULL, .table_id =3D NULL }; Object *vmgenid_dev; =20 - acpi_get_pm_info(&pm); + acpi_get_pm_info(machine, &pm); acpi_get_misc_info(&misc); acpi_get_pci_holes(&pci_hole, &pci_hole64); acpi_get_slic_oem(&slic_oem); diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index ca8df462b6..9c2ab4aac5 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -18,6 +18,7 @@ #include "sysemu/kvm.h" #include "hw/i386/apic_internal.h" #include "hw/sysbus.h" +#include "hw/boards.h" #include "tcg/tcg.h" =20 #define VAPIC_IO_PORT 0x7e @@ -442,11 +443,12 @@ static void do_patch_instruction(CPUState *cs, run_on= _cpu_data data) =20 static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong = ip) { + MachineState *ms =3D MACHINE(qdev_get_machine()); CPUState *cs =3D CPU(cpu); VAPICHandlers *handlers; PatchInfo *info; =20 - if (smp_cpus =3D=3D 1) { + if (ms->smp.cpus =3D=3D 1) { handlers =3D &s->rom_state.up; } else { handlers =3D &s->rom_state.mp; @@ -747,6 +749,7 @@ static void do_vapic_enable(CPUState *cs, run_on_cpu_da= ta data) static void kvmvapic_vm_state_change(void *opaque, int running, RunState state) { + MachineState *ms =3D MACHINE(qdev_get_machine()); VAPICROMState *s =3D opaque; uint8_t *zero; =20 @@ -755,7 +758,7 @@ static void kvmvapic_vm_state_change(void *opaque, int = running, } =20 if (s->state =3D=3D VAPIC_ACTIVE) { - if (smp_cpus =3D=3D 1) { + if (ms->smp.cpus =3D=3D 1) { run_on_cpu(first_cpu, do_vapic_enable, RUN_ON_CPU_HOST_PTR(s)); } else { zero =3D g_malloc0(s->rom_state.vapic_size); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index da1cdd6853..73de30cc20 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -928,12 +928,14 @@ void enable_compat_apic_id_mode(void) * no concept of "CPU index", and the NUMA tables on fw_cfg need the APIC = ID of * all CPUs up to max_cpus. */ -static uint32_t x86_cpu_apic_id_from_index(unsigned int cpu_index) +static uint32_t x86_cpu_apic_id_from_index(MachineState *ms, + unsigned int cpu_index) { uint32_t correct_id; static bool warned; =20 - correct_id =3D x86_apicid_from_cpu_idx(smp_cores, smp_threads, cpu_ind= ex); + correct_id =3D x86_apicid_from_cpu_idx(ms->smp.cores, + ms->smp.threads, cpu_index); if (compat_apic_id_mode) { if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { error_report("APIC IDs set in compatibility mode, " @@ -1532,7 +1534,7 @@ static void pc_new_cpu(const char *typename, int64_t = apic_id, Error **errp) =20 void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) { - int64_t apic_id =3D x86_cpu_apic_id_from_index(id); + int64_t apic_id =3D x86_cpu_apic_id_from_index(ms, id); Error *local_err =3D NULL; =20 if (id < 0) { @@ -1568,9 +1570,10 @@ void pc_cpus_init(PCMachineState *pcms) * * This is used for FW_CFG_MAX_CPUS. See comments on bochs_bios_init(). */ - pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(max_cpus - 1) + 1; + pcms->apic_id_limit =3D x86_cpu_apic_id_from_index(ms, + ms->smp.max_cpus - 1)= + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); - for (i =3D 0; i < smp_cpus; i++) { + for (i =3D 0; i < ms->smp.cpus; i++) { pc_new_cpu(possible_cpus->cpus[i].type, possible_cpus->cpus[i].arc= h_id, &error_fatal); } @@ -2294,6 +2297,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, X86CPU *cpu =3D X86_CPU(dev); MachineState *ms =3D MACHINE(hotplug_dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); + unsigned int smp_cores =3D ms->smp.cores; + unsigned int smp_threads =3D ms->smp.threads; =20 if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) { error_setg(errp, "Invalid CPU type, expected cpu type: '%s'", @@ -2303,7 +2308,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, =20 /* if APIC ID is not set, set it based on socket/core/thread propertie= s */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { - int max_socket =3D (max_cpus - 1) / smp_threads / smp_cores; + int max_socket =3D (ms->smp.max_cpus - 1) / smp_threads / smp_core= s; =20 if (cpu->socket_id < 0) { error_setg(errp, "CPU socket-id is not set"); @@ -2653,13 +2658,14 @@ static int64_t pc_get_default_cpu_node_id(const Mac= hineState *ms, int idx) =20 assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - smp_cores, smp_threads, &topo); + ms->smp.cores, ms->smp.threads, &topo); return topo.pkg_id % nb_numa_nodes; } =20 static const CPUArchIdList *pc_possible_cpu_arch_ids(MachineState *ms) { int i; + unsigned int max_cpus =3D ms->smp.max_cpus; =20 if (ms->possible_cpus) { /* @@ -2678,9 +2684,9 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) =20 ms->possible_cpus->cpus[i].type =3D ms->cpu_type; ms->possible_cpus->cpus[i].vcpus_count =3D 1; - ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= i); + ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= ms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - smp_cores, smp_threads, &topo); + ms->smp.cores, ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; ms->possible_cpus->cpus[i].props.has_core_id =3D true; diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 2939122e7c..941bd25e66 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -750,6 +750,8 @@ static ioreq_t *cpu_get_ioreq_from_shared_memory(XenIOS= tate *state, int vcpu) /* retval--the number of ioreq packet */ static ioreq_t *cpu_get_ioreq(XenIOState *state) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int max_cpus =3D ms->smp.max_cpus; int i; evtchn_port_t port; =20 @@ -1377,6 +1379,8 @@ static int xen_map_ioreq_server(XenIOState *state) =20 void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { + MachineState *ms =3D MACHINE(pcms); + unsigned int max_cpus =3D ms->smp.max_cpus; int i, rc; xen_pfn_t ioreq_pfn; XenIOState *state; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index da6eb67cfb..78830d403a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -56,6 +56,7 @@ #include "hw/hw.h" #include "hw/xen/xen.h" #include "hw/i386/apic_internal.h" +#include "hw/boards.h" #endif =20 #include "disas/capstone.h" @@ -5384,9 +5385,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) } =20 #ifndef CONFIG_USER_ONLY + MachineState *ms =3D MACHINE(qdev_get_machine()); qemu_register_reset(x86_cpu_machine_reset_cb, cpu); =20 - if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || smp_cpus > 1) { + if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || ms->smp.cpus > 1) { x86_cpu_apic_create(cpu, &local_err); if (local_err !=3D NULL) { goto out; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748970; cv=none; d=zoho.com; s=zohoarc; b=A2DjJx+UPAqPMdfWj1wA0OH+ozVu79w7EZ3vLrp+gPHoECSpDhlRH/zmSZDRsdqThvu9eBWQsN9PLmZJYh2xlzrYoAC2EKimVaVrjhXa0kOdAteHSIFM+MCDxY1OiYrmDYJeN0PFDi6w/BK9/bDNq+cRRWUB7xsRXGVEaWGm7W4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748970; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=k0rVCL0Bgvfnxkpp4dHY1d85Kzy/mLoPSaNjUPuZl88=; b=ZtcVDhHhJ321ZXYSB+BgO837TL3urDC+gZ1CJVqHoNnfYBMliFT4HI6kOfdEbU8V2yd9wRjUFSXPtRi/U/3CFWRVPMs+r8Xjx0LQfl4DNpcRcJCBUTVCQukfJUF/KOiSJ2XcxtEbDhb7/DygLVzwF5Zp26lvKqVX7ESNDVe/HOY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748970927356.4833427747766; Fri, 28 Jun 2019 12:09:30 -0700 (PDT) Received: from localhost ([::1]:35614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwFP-00081f-KN for importer@patchew.org; Fri, 28 Jun 2019 15:09:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40403) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvwC-0002xt-3I for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvw7-0002Kv-Ns for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvw7-0002Jv-8B for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 82D6B309175F; Fri, 28 Jun 2019 18:49:21 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE18D5D705; Fri, 28 Jun 2019 18:48:48 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:21 -0300 Message-Id: <20190628184742.5961-9-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Fri, 28 Jun 2019 18:49:26 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 08/29] hw/arm: Replace global smp variables with machine smp properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in arm are replaced with smp machine properties. The init_cpus() and *_create_rpu() are refactored to pass MachineState. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-9-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- hw/arm/fsl-imx6.c | 6 +++++- hw/arm/fsl-imx6ul.c | 6 +++++- hw/arm/fsl-imx7.c | 7 +++++-- hw/arm/highbank.c | 1 + hw/arm/mcimx6ul-evk.c | 2 +- hw/arm/mcimx7d-sabre.c | 2 +- hw/arm/raspi.c | 4 ++-- hw/arm/realview.c | 1 + hw/arm/sabrelite.c | 2 +- hw/arm/vexpress.c | 16 ++++++++++------ hw/arm/virt.c | 8 +++++++- hw/arm/xlnx-zynqmp.c | 16 ++++++++++------ target/arm/cpu.c | 8 +++++++- 13 files changed, 56 insertions(+), 23 deletions(-) diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c index 7129517378..de45833097 100644 --- a/hw/arm/fsl-imx6.c +++ b/hw/arm/fsl-imx6.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "hw/arm/fsl-imx6.h" +#include "hw/boards.h" #include "sysemu/sysemu.h" #include "chardev/char.h" #include "qemu/error-report.h" @@ -33,11 +34,12 @@ =20 static void fsl_imx6_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX6State *s =3D FSL_IMX6(obj); char name[NAME_SIZE]; int i; =20 - for (i =3D 0; i < MIN(smp_cpus, FSL_IMX6_NUM_CPUS); i++) { + for (i =3D 0; i < MIN(ms->smp.cpus, FSL_IMX6_NUM_CPUS); i++) { snprintf(name, NAME_SIZE, "cpu%d", i); object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]), "cortex-a9-" TYPE_ARM_CPU, &error_abort, N= ULL); @@ -93,9 +95,11 @@ static void fsl_imx6_init(Object *obj) =20 static void fsl_imx6_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX6State *s =3D FSL_IMX6(dev); uint16_t i; Error *err =3D NULL; + unsigned int smp_cpus =3D ms->smp.cpus; =20 if (smp_cpus > FSL_IMX6_NUM_CPUS) { error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c index 05505bac56..f860165438 100644 --- a/hw/arm/fsl-imx6ul.c +++ b/hw/arm/fsl-imx6ul.c @@ -20,6 +20,7 @@ #include "qapi/error.h" #include "hw/arm/fsl-imx6ul.h" #include "hw/misc/unimp.h" +#include "hw/boards.h" #include "sysemu/sysemu.h" #include "qemu/error-report.h" #include "qemu/module.h" @@ -28,11 +29,12 @@ =20 static void fsl_imx6ul_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX6ULState *s =3D FSL_IMX6UL(obj); char name[NAME_SIZE]; int i; =20 - for (i =3D 0; i < MIN(smp_cpus, FSL_IMX6UL_NUM_CPUS); i++) { + for (i =3D 0; i < MIN(ms->smp.cpus, FSL_IMX6UL_NUM_CPUS); i++) { snprintf(name, NAME_SIZE, "cpu%d", i); object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]), "cortex-a7-" TYPE_ARM_CPU, &error_abort, N= ULL); @@ -156,10 +158,12 @@ static void fsl_imx6ul_init(Object *obj) =20 static void fsl_imx6ul_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX6ULState *s =3D FSL_IMX6UL(dev); int i; qemu_irq irq; char name[NAME_SIZE]; + unsigned int smp_cpus =3D ms->smp.cpus; =20 if (smp_cpus > FSL_IMX6UL_NUM_CPUS) { error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c index b7e3526b4f..036a05176e 100644 --- a/hw/arm/fsl-imx7.c +++ b/hw/arm/fsl-imx7.c @@ -22,6 +22,7 @@ #include "qapi/error.h" #include "hw/arm/fsl-imx7.h" #include "hw/misc/unimp.h" +#include "hw/boards.h" #include "sysemu/sysemu.h" #include "qemu/error-report.h" #include "qemu/module.h" @@ -30,12 +31,12 @@ =20 static void fsl_imx7_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX7State *s =3D FSL_IMX7(obj); char name[NAME_SIZE]; int i; =20 - - for (i =3D 0; i < MIN(smp_cpus, FSL_IMX7_NUM_CPUS); i++) { + for (i =3D 0; i < MIN(ms->smp.cpus, FSL_IMX7_NUM_CPUS); i++) { snprintf(name, NAME_SIZE, "cpu%d", i); object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]), ARM_CPU_TYPE_NAME("cortex-a7"), &error_abo= rt, @@ -155,11 +156,13 @@ static void fsl_imx7_init(Object *obj) =20 static void fsl_imx7_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); FslIMX7State *s =3D FSL_IMX7(dev); Object *o; int i; qemu_irq irq; char name[NAME_SIZE]; + unsigned int smp_cpus =3D ms->smp.cpus; =20 if (smp_cpus > FSL_IMX7_NUM_CPUS) { error_setg(errp, "%s: Only %d CPUs are supported (%d requested)", diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 72ca78108a..def0f1ce6a 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -241,6 +241,7 @@ static void calxeda_init(MachineState *machine, enum cx= machines machine_id) SysBusDevice *busdev; qemu_irq pic[128]; int n; + unsigned int smp_cpus =3D machine->smp.cpus; qemu_irq cpu_irq[4]; qemu_irq cpu_fiq[4]; qemu_irq cpu_virq[4]; diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c index 31511059e4..bbffb11c2a 100644 --- a/hw/arm/mcimx6ul-evk.c +++ b/hw/arm/mcimx6ul-evk.c @@ -42,7 +42,7 @@ static void mcimx6ul_evk_init(MachineState *machine) .kernel_filename =3D machine->kernel_filename, .kernel_cmdline =3D machine->kernel_cmdline, .initrd_filename =3D machine->initrd_filename, - .nb_cpus =3D smp_cpus, + .nb_cpus =3D machine->smp.cpus, }; =20 object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->so= c), diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c index d6b190d85d..72eab03a0c 100644 --- a/hw/arm/mcimx7d-sabre.c +++ b/hw/arm/mcimx7d-sabre.c @@ -45,7 +45,7 @@ static void mcimx7d_sabre_init(MachineState *machine) .kernel_filename =3D machine->kernel_filename, .kernel_cmdline =3D machine->kernel_cmdline, .initrd_filename =3D machine->initrd_filename, - .nb_cpus =3D smp_cpus, + .nb_cpus =3D machine->smp.cpus, }; =20 object_initialize(&s->soc, sizeof(s->soc), TYPE_FSL_IMX7); diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index cb23330940..5b2620acb4 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -116,7 +116,7 @@ static void setup_boot(MachineState *machine, int versi= on, size_t ram_size) =20 binfo.board_id =3D raspi_boardid[version]; binfo.ram_size =3D ram_size; - binfo.nb_cpus =3D smp_cpus; + binfo.nb_cpus =3D machine->smp.cpus; =20 if (version <=3D 2) { /* The rpi1 and 2 require some custom setup code to run in Secure @@ -194,7 +194,7 @@ static void raspi_init(MachineState *machine, int versi= on) /* Setup the SOC */ object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), &error_abort); - object_property_set_int(OBJECT(&s->soc), smp_cpus, "enabled-cpus", + object_property_set_int(OBJECT(&s->soc), machine->smp.cpus, "enabled-c= pus", &error_abort); int board_rev =3D version =3D=3D 3 ? 0xa02082 : 0xa21041; object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", diff --git a/hw/arm/realview.c b/hw/arm/realview.c index 12d6e93a35..7c56c8d2ed 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -69,6 +69,7 @@ static void realview_init(MachineState *machine, NICInfo *nd; I2CBus *i2c; int n; + unsigned int smp_cpus =3D machine->smp.cpus; int done_nic =3D 0; qemu_irq cpu_irq[4]; int is_mpcore =3D 0; diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c index 97230ac827..934f4c9261 100644 --- a/hw/arm/sabrelite.c +++ b/hw/arm/sabrelite.c @@ -105,7 +105,7 @@ static void sabrelite_init(MachineState *machine) sabrelite_binfo.kernel_filename =3D machine->kernel_filename; sabrelite_binfo.kernel_cmdline =3D machine->kernel_cmdline; sabrelite_binfo.initrd_filename =3D machine->initrd_filename; - sabrelite_binfo.nb_cpus =3D smp_cpus; + sabrelite_binfo.nb_cpus =3D machine->smp.cpus; sabrelite_binfo.secure_boot =3D true; sabrelite_binfo.write_secondary_boot =3D sabrelite_write_secondary; sabrelite_binfo.secondary_cpu_reset_hook =3D sabrelite_reset_secondary; diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 2b3b0c2334..5d932c27c0 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -203,12 +203,14 @@ struct VEDBoardInfo { DBoardInitFn *init; }; =20 -static void init_cpus(const char *cpu_type, const char *privdev, - hwaddr periphbase, qemu_irq *pic, bool secure, bool = virt) +static void init_cpus(MachineState *ms, const char *cpu_type, + const char *privdev, hwaddr periphbase, + qemu_irq *pic, bool secure, bool virt) { DeviceState *dev; SysBusDevice *busdev; int n; + unsigned int smp_cpus =3D ms->smp.cpus; =20 /* Create the actual CPUs */ for (n =3D 0; n < smp_cpus; n++) { @@ -269,6 +271,7 @@ static void a9_daughterboard_init(const VexpressMachine= State *vms, const char *cpu_type, qemu_irq *pic) { + MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *lowram =3D g_new(MemoryRegion, 1); @@ -295,7 +298,7 @@ static void a9_daughterboard_init(const VexpressMachine= State *vms, memory_region_add_subregion(sysmem, 0x60000000, ram); =20 /* 0x1e000000 A9MPCore (SCU) private memory region */ - init_cpus(cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, + init_cpus(machine, cpu_type, TYPE_A9MPCORE_PRIV, 0x1e000000, pic, vms->secure, vms->virt); =20 /* Daughterboard peripherals : 0x10020000 .. 0x20000000 */ @@ -355,6 +358,7 @@ static void a15_daughterboard_init(const VexpressMachin= eState *vms, const char *cpu_type, qemu_irq *pic) { + MachineState *machine =3D MACHINE(vms); MemoryRegion *sysmem =3D get_system_memory(); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); @@ -377,8 +381,8 @@ static void a15_daughterboard_init(const VexpressMachin= eState *vms, memory_region_add_subregion(sysmem, 0x80000000, ram); =20 /* 0x2c000000 A15MPCore private memory region (GIC) */ - init_cpus(cpu_type, TYPE_A15MPCORE_PRIV, 0x2c000000, pic, vms->secure, - vms->virt); + init_cpus(machine, cpu_type, TYPE_A15MPCORE_PRIV, + 0x2c000000, pic, vms->secure, vms->virt); =20 /* A15 daughterboard peripherals: */ =20 @@ -706,7 +710,7 @@ static void vexpress_common_init(MachineState *machine) daughterboard->bootinfo.kernel_filename =3D machine->kernel_filename; daughterboard->bootinfo.kernel_cmdline =3D machine->kernel_cmdline; daughterboard->bootinfo.initrd_filename =3D machine->initrd_filename; - daughterboard->bootinfo.nb_cpus =3D smp_cpus; + daughterboard->bootinfo.nb_cpus =3D machine->smp.cpus; daughterboard->bootinfo.board_id =3D VEXPRESS_BOARD_ID; daughterboard->bootinfo.loader_start =3D daughterboard->loader_start; daughterboard->bootinfo.smp_loader_start =3D map[VE_SRAM]; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4a0ac3baf0..026a5be18b 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -558,11 +558,13 @@ static void create_v2m(VirtMachineState *vms, qemu_ir= q *pic) =20 static void create_gic(VirtMachineState *vms, qemu_irq *pic) { + MachineState *ms =3D MACHINE(vms); /* We create a standalone GIC */ DeviceState *gicdev; SysBusDevice *gicbusdev; const char *gictype; int type =3D vms->gic_version, i; + unsigned int smp_cpus =3D ms->smp.cpus; uint32_t nb_redist_regions =3D 0; =20 gictype =3D (type =3D=3D 3) ? gicv3_class_name() : gic_class_name(); @@ -1038,13 +1040,14 @@ static bool virt_firmware_init(VirtMachineState *vm= s, =20 static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace= *as) { + MachineState *ms =3D MACHINE(vms); hwaddr base =3D vms->memmap[VIRT_FW_CFG].base; hwaddr size =3D vms->memmap[VIRT_FW_CFG].size; FWCfgState *fw_cfg; char *nodename; =20 fw_cfg =3D fw_cfg_init_mem_wide(base + 8, base, 8, base + 16, as); - fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)ms->smp.cpus); =20 nodename =3D g_strdup_printf("/fw-cfg@%" PRIx64, base); qemu_fdt_add_subnode(vms->fdt, nodename); @@ -1477,6 +1480,8 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 =3D true; + unsigned int smp_cpus =3D machine->smp.cpus; + unsigned int max_cpus =3D machine->smp.max_cpus; =20 /* * In accelerated mode, the memory map is computed earlier in kvm_type= () @@ -1844,6 +1849,7 @@ static int64_t virt_get_default_cpu_node_id(const Mac= hineState *ms, int idx) static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) { int n; + unsigned int max_cpus =3D ms->smp.max_cpus; VirtMachineState *vms =3D VIRT_MACHINE(ms); =20 if (ms->possible_cpus) { diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index a1ca9b5adf..a60830d37a 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -21,6 +21,7 @@ #include "cpu.h" #include "hw/arm/xlnx-zynqmp.h" #include "hw/intc/arm_gic_common.h" +#include "hw/boards.h" #include "exec/address-spaces.h" #include "sysemu/kvm.h" #include "kvm_arm.h" @@ -171,12 +172,13 @@ static inline int arm_gic_ppi_index(int cpu_nr, int p= pi_index) return GIC_NUM_SPI_INTR + cpu_nr * GIC_INTERNAL + ppi_index; } =20 -static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s, const char *boot_cp= u, - Error **errp) +static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, + const char *boot_cpu, Error **errp) { Error *err =3D NULL; int i; - int num_rpus =3D MIN(smp_cpus - XLNX_ZYNQMP_NUM_APU_CPUS, XLNX_ZYNQMP_= NUM_RPU_CPUS); + int num_rpus =3D MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS, + XLNX_ZYNQMP_NUM_RPU_CPUS); =20 if (num_rpus <=3D 0) { /* Don't create rpu-cluster object if there's nothing to put in it= */ @@ -221,9 +223,10 @@ static void xlnx_zynqmp_create_rpu(XlnxZynqMPState *s,= const char *boot_cpu, =20 static void xlnx_zynqmp_init(Object *obj) { + MachineState *ms =3D MACHINE(qdev_get_machine()); XlnxZynqMPState *s =3D XLNX_ZYNQMP(obj); int i; - int num_apus =3D MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); + int num_apus =3D MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS); =20 object_initialize_child(obj, "apu-cluster", &s->apu_cluster, sizeof(s->apu_cluster), TYPE_CPU_CLUSTER, @@ -290,11 +293,12 @@ static void xlnx_zynqmp_init(Object *obj) =20 static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) { + MachineState *ms =3D MACHINE(qdev_get_machine()); XlnxZynqMPState *s =3D XLNX_ZYNQMP(dev); MemoryRegion *system_memory =3D get_system_memory(); uint8_t i; uint64_t ram_size; - int num_apus =3D MIN(smp_cpus, XLNX_ZYNQMP_NUM_APU_CPUS); + int num_apus =3D MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS); const char *boot_cpu =3D s->boot_cpu ? s->boot_cpu : "apu-cpu[0]"; ram_addr_t ddr_low_size, ddr_high_size; qemu_irq gic_spi[GIC_NUM_SPI_INTR]; @@ -456,7 +460,7 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error= **errp) "RPUs just use -smp 6."); } =20 - xlnx_zynqmp_create_rpu(s, boot_cpu, &err); + xlnx_zynqmp_create_rpu(ms, s, boot_cpu, &err); if (err) { error_propagate(errp, err); return; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 376db154f0..73f7d9394d 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -30,6 +30,7 @@ #include "hw/qdev-properties.h" #if !defined(CONFIG_USER_ONLY) #include "hw/loader.h" +#include "hw/boards.h" #endif #include "sysemu/sysemu.h" #include "sysemu/tcg.h" @@ -1361,6 +1362,9 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) init_cpreg_list(cpu); =20 #ifndef CONFIG_USER_ONLY + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; + if (cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SECURITY)) { cs->num_ases =3D 2; =20 @@ -1901,10 +1905,12 @@ static void cortex_a9_initfn(Object *obj) #ifndef CONFIG_USER_ONLY static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + /* Linux wants the number of processors from here. * Might as well set the interrupt-controller bit too. */ - return ((smp_cpus - 1) << 24) | (1 << 23); + return ((ms->smp.cpus - 1) << 24) | (1 << 23); } #endif =20 --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748970; cv=none; d=zoho.com; s=zohoarc; b=kk0yiwRf+V1Dx8AbyrliEbyuYfuL2/skwJeLxvYsAES7GI5CQYjamqabZ4q09esXXIW+6l6Li9ZY2a1TvkfAUFuKLh7YxEjaY+PwS0c9HRFf2Kv6OOOmYe6lim/ZzGaigWJOUG/p6mbs2Ii4MKBnhyL9KI5kVcA8Z2hZeFKBuO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748970; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=8pmT9EzPSOaSBI97+9vDFbZGI5zx1aiZhUi1BA9ECv0=; b=bfHOfWGW2S7lykZBxprx18nm072LSq1bJBk3eBKfFSrX9HiuUug7gNNpSwVrX6vJAyMLl6jEiKFGs8kPUvKXNjVGCf9MND4HAF7PBGXAKSmfRwarxDfHPvK/LM9cp1qzHuRFGH3ugfI2nWgGZLHtD4btOy7d1MkOIlX9oQ6dAgw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748970920515.2539090869733; Fri, 28 Jun 2019 12:09:30 -0700 (PDT) Received: from localhost ([::1]:35616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwFS-00085X-0a for importer@patchew.org; Fri, 28 Jun 2019 15:09:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40428) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvwK-0003AZ-5X for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvwH-0002Sg-Hg for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38628) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwH-0002SA-9O for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 957E1C057F4B; Fri, 28 Jun 2019 18:49:36 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 990745D9CA; Fri, 28 Jun 2019 18:49:35 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:22 -0300 Message-Id: <20190628184742.5961-10-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 28 Jun 2019 18:49:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 09/29] hw: Replace global smp variables with MachineState for all remaining archs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in alpha/hppa/mips/openrisc/sparc*/xtensa codes are replaced with smp properties from MachineState. A local variable of the same name would be introduced in the declaration phase if it's used widely in the context OR replace it on the spot if it's only used once. No semantic changes. Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-10-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- hw/alpha/dp264.c | 1 + hw/hppa/machine.c | 2 ++ hw/mips/boston.c | 2 +- hw/mips/mips_malta.c | 2 ++ hw/openrisc/openrisc_sim.c | 1 + hw/sparc/sun4m.c | 2 ++ hw/sparc64/sun4u.c | 4 ++-- hw/xtensa/sim.c | 2 +- hw/xtensa/xtfpga.c | 1 + 9 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 0347eb897c..9dfb835013 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -63,6 +63,7 @@ static void clipper_init(MachineState *machine) char *palcode_filename; uint64_t palcode_entry, palcode_low, palcode_high; uint64_t kernel_entry, kernel_low, kernel_high; + unsigned int smp_cpus =3D machine->smp.cpus; =20 /* Create up to 4 cpus. */ memset(cpus, 0, sizeof(cpus)); diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 416e67bab1..662838d83b 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -72,6 +72,7 @@ static void machine_hppa_init(MachineState *machine) MemoryRegion *ram_region; MemoryRegion *cpu_region; long i; + unsigned int smp_cpus =3D machine->smp.cpus; =20 ram_size =3D machine->ram_size; =20 @@ -242,6 +243,7 @@ static void machine_hppa_init(MachineState *machine) =20 static void hppa_machine_reset(MachineState *ms) { + unsigned int smp_cpus =3D ms->smp.cpus; int i; =20 qemu_devices_reset(); diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 749582e5aa..9eeccbea9a 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -458,7 +458,7 @@ static void boston_mach_init(MachineState *machine) sizeof(s->cps), TYPE_MIPS_CPS); object_property_set_str(OBJECT(&s->cps), machine->cpu_type, "cpu-type", &err); - object_property_set_int(OBJECT(&s->cps), smp_cpus, "num-vp", &err); + object_property_set_int(OBJECT(&s->cps), machine->smp.cpus, "num-vp", = &err); object_property_set_bool(OBJECT(&s->cps), true, "realized", &err); =20 if (err !=3D NULL) { diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 132127882d..20e019bf66 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -1095,6 +1095,8 @@ static int64_t load_kernel (void) =20 static void malta_mips_config(MIPSCPU *cpu) { + MachineState *ms =3D MACHINE(qdev_get_machine()); + unsigned int smp_cpus =3D ms->smp.cpus; CPUMIPSState *env =3D &cpu->env; CPUState *cs =3D CPU(cpu); =20 diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index 87b9feaa96..b85f0df323 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -130,6 +130,7 @@ static void openrisc_sim_init(MachineState *machine) qemu_irq *cpu_irqs[2]; qemu_irq serial_irq; int n; + unsigned int smp_cpus =3D machine->smp.cpus; =20 for (n =3D 0; n < smp_cpus; n++) { cpu =3D OPENRISC_CPU(cpu_create(machine->cpu_type)); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 7e4f61fc3e..a8004a5fe3 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -871,6 +871,8 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef, FWCfgState *fw_cfg; DeviceState *dev; SysBusDevice *s; + unsigned int smp_cpus =3D machine->smp.cpus; + unsigned int max_cpus =3D machine->smp.max_cpus; =20 /* init CPUs */ for(i =3D 0; i < smp_cpus; i++) { diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 4230b17b87..5d87be811d 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -697,8 +697,8 @@ static void sun4uv_init(MemoryRegion *address_space_mem, &FW_CFG_IO(dev)->comb_iomem); =20 fw_cfg =3D FW_CFG(dev); - fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); - fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)machine->smp.cpus); + fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, (uint16_t)machine->smp.max_cpu= s); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id); fw_cfg_add_i64(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_entry); diff --git a/hw/xtensa/sim.c b/hw/xtensa/sim.c index b6922c39d5..09165b6f4d 100644 --- a/hw/xtensa/sim.c +++ b/hw/xtensa/sim.c @@ -59,7 +59,7 @@ static void xtensa_sim_init(MachineState *machine) const char *kernel_filename =3D machine->kernel_filename; int n; =20 - for (n =3D 0; n < smp_cpus; n++) { + for (n =3D 0; n < machine->smp.cpus; n++) { cpu =3D XTENSA_CPU(cpu_create(machine->cpu_type)); env =3D &cpu->env; =20 diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index e05ef75a75..f7f3e11e93 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -238,6 +238,7 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, M= achineState *machine) const unsigned system_io_size =3D 224 * MiB; uint32_t freq =3D 10000000; int n; + unsigned int smp_cpus =3D machine->smp.cpus; =20 if (smp_cpus > 1) { mx_pic =3D xtensa_mx_pic_init(31); --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749239; cv=none; d=zoho.com; s=zohoarc; b=csr1F4k1zn9kosl5mMGQhEuxkTSijAn32HBZivGVPnr8JQGO1U09O5g/urJ9Hth4e3uQompDIyF0B4/au1BfkmrKbl38/rGUaeCvAvnXunCCKx4I3Du3T/ukSZ0enNZ668b7rHE8tcMLT4Z5epKVeWushys29/2WWj++1CDxABI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749239; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=twRl2RfAifpnyyxC8bm/i7FXcyJ6R9H8OV2VPsT9Y6M=; b=kvsOhPE/hIipskD4b9bh2/AT0JKdLFZu5AzQrXvncOWnw1tp9A8nJqaJRaLJjUfsSdKUuS8jj0hbjwsEqx5Nc/DbP13Or9ffL3GJQm9D9fXYzT2OgFpjRddpHEi/4UItl7dhV/Tnlv1IS3NqrxLkz/xTdV90X2PqhdeFpcjnuDg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156174923915395.34799303765396; Fri, 28 Jun 2019 12:13:59 -0700 (PDT) Received: from localhost ([::1]:35652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwJf-0003MN-86 for importer@patchew.org; Fri, 28 Jun 2019 15:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40455) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvwP-0003SD-K4 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvwN-0002XI-0w for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60730) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwM-0002We-Or for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 099F530872F4; Fri, 28 Jun 2019 18:49:42 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2763219C59; Fri, 28 Jun 2019 18:49:40 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:23 -0300 Message-Id: <20190628184742.5961-11-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Jun 2019 18:49:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 10/29] vl.c: Replace smp global variables with smp machine properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The global smp variables in vl.c are completely replaced with machine prope= rties. Form this commit, the smp_cpus/smp_cores/smp_threads/max_cpus are deprecated and only machine properties within MachineState are fully applied and enabl= ed. Signed-off-by: Like Xu Reviewed-by: Alistair Francis Message-Id: <20190518205428.90532-11-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- vl.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/vl.c b/vl.c index 918e8413ef..96f4dd828b 100644 --- a/vl.c +++ b/vl.c @@ -165,10 +165,6 @@ static Chardev **serial_hds; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack =3D 0; int singlestep =3D 0; -int smp_cpus; -unsigned int max_cpus; -int smp_cores =3D 1; -int smp_threads =3D 1; int acpi_enabled =3D 1; int no_hpet =3D 0; int fd_bootchk =3D 1; @@ -1267,8 +1263,9 @@ static void smp_parse(QemuOpts *opts) sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * sockets; } else { - max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D max_cpus / (cores * threads); + current_machine->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D current_machine->smp.max_cpus / (cores * threa= ds); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; @@ -1285,34 +1282,37 @@ static void smp_parse(QemuOpts *opts) exit(1); } =20 - max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); + current_machine->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); =20 - if (max_cpus < cpus) { + if (current_machine->smp.max_cpus < cpus) { error_report("maxcpus must be equal to or greater than smp"); exit(1); } =20 - if (sockets * cores * threads > max_cpus) { + if (sockets * cores * threads > current_machine->smp.max_cpus) { error_report("cpu topology: " "sockets (%u) * cores (%u) * threads (%u) > " "maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, cores, threads, + current_machine->smp.max_cpus); exit(1); } =20 - if (sockets * cores * threads !=3D max_cpus) { + if (sockets * cores * threads !=3D current_machine->smp.max_cpus) { warn_report("Invalid CPU topology deprecated: " "sockets (%u) * cores (%u) * threads (%u) " "!=3D maxcpus (%u)", - sockets, cores, threads, max_cpus); + sockets, cores, threads, + current_machine->smp.max_cpus); } =20 - smp_cpus =3D cpus; - smp_cores =3D cores; - smp_threads =3D threads; + current_machine->smp.cpus =3D cpus; + current_machine->smp.cores =3D cores; + current_machine->smp.threads =3D threads; } =20 - if (smp_cpus > 1) { + if (current_machine->smp.cpus > 1) { Error *blocker =3D NULL; error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); replay_add_blocker(blocker); @@ -4054,26 +4054,25 @@ int main(int argc, char **argv, char **envp) machine_class->default_cpus =3D machine_class->default_cpus ?: 1; =20 /* default to machine_class->default_cpus */ - smp_cpus =3D machine_class->default_cpus; - max_cpus =3D machine_class->default_cpus; + current_machine->smp.cpus =3D machine_class->default_cpus; + current_machine->smp.max_cpus =3D machine_class->default_cpus; + current_machine->smp.cores =3D 1; + current_machine->smp.threads =3D 1; =20 smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); =20 - current_machine->smp.cpus =3D smp_cpus; - current_machine->smp.max_cpus =3D max_cpus; - current_machine->smp.cores =3D smp_cores; - current_machine->smp.threads =3D smp_threads; - /* sanity-check smp_cpus and max_cpus against machine_class */ - if (smp_cpus < machine_class->min_cpus) { + if (current_machine->smp.cpus < machine_class->min_cpus) { error_report("Invalid SMP CPUs %d. The min CPUs " - "supported by machine '%s' is %d", smp_cpus, + "supported by machine '%s' is %d", + current_machine->smp.cpus, machine_class->name, machine_class->min_cpus); exit(1); } - if (max_cpus > machine_class->max_cpus) { + if (current_machine->smp.max_cpus > machine_class->max_cpus) { error_report("Invalid SMP CPUs %d. The max CPUs " - "supported by machine '%s' is %d", max_cpus, + "supported by machine '%s' is %d", + current_machine->smp.max_cpus, machine_class->name, machine_class->max_cpus); exit(1); } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748398; cv=none; d=zoho.com; s=zohoarc; b=Hq9M/Nkdqvb9P6msR4dfd5QOirQPfQou4qdLgR5AOPGfWkCrsgHaqDeu8ENcGsyaFYS18/s/fegdGlkFKut0yC0bfyV3JZfALsu0SYmTyMKhFXX6Z03BDZIPmViwrehPZdpFb6H9jUGWPoXSpH6rWfsNYKUXAff3LXDN/t9X4SA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748398; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=bRf1hLHu/vcOuyYxX/fpgt81msTvXpCc+W6ZzOxKSfM=; b=GwzDW0f2QvBe+x9V3TEy9VBiGEUBmnEBOF6avF3wY87ysFJ4pxbYCwOD4zGQob1AMF0M5RhR4QeRdxKURF0r67GwVDWi4wIC1fZLsFd3toq5o/myDvOgciXk5n/cUGFq4tbe0D7O2cU+t0tCl9RHt+iRueU/N9IX4j6JIqywDjQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748398331957.2788762697792; Fri, 28 Jun 2019 11:59:58 -0700 (PDT) Received: from localhost ([::1]:35570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgw6C-00038c-Dm for importer@patchew.org; Fri, 28 Jun 2019 14:59:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40502) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvwY-0003nx-LK for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvwV-0002dr-6d for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41486) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwU-0002dA-U0 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:49:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3A7C2C18B2EA; Fri, 28 Jun 2019 18:49:50 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EE555D9CA; Fri, 28 Jun 2019 18:49:47 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:24 -0300 Message-Id: <20190628184742.5961-12-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 28 Jun 2019 18:49:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 11/29] i386: Add die-level cpu topology to x86CPU on PCMachine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The die-level as the first PC-specific cpu topology is added to the leagcy cpu topology model, which has one die per package implicitly and only the numbers of sockets/cores/threads are configurable. In the new model with die-level support, the total number of logical processors (including offline) on board will be calculated as: #cpus =3D #sockets * #dies * #cores * #threads and considering compatibility, the default value for #dies would be initialized to one in x86_cpu_initfn() and pc_machine_initfn(). Signed-off-by: Like Xu Message-Id: <20190612084104.34984-2-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- include/hw/i386/pc.h | 2 ++ target/i386/cpu.h | 2 ++ hw/i386/pc.c | 9 +++++++-- target/i386/cpu.c | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 884e35b9b2..764996e6b4 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -24,6 +24,7 @@ * PCMachineState: * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling * @boot_cpus: number of present VCPUs + * @smp_dies: number of dies per one package */ struct PCMachineState { /*< private >*/ @@ -59,6 +60,7 @@ struct PCMachineState { bool apic_xrupt_override; unsigned apic_id_limit; uint16_t boot_cpus; + unsigned smp_dies; =20 /* NUMA information: */ uint64_t numa_nodes; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 93345792f4..14c19e61b1 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1385,6 +1385,8 @@ typedef struct CPUX86State { uint64_t xss; =20 TPRAccess tpr_access_type; + + unsigned nr_dies; } CPUX86State; =20 struct kvm_msrs; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 73de30cc20..e18b1bade2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2306,9 +2306,13 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, return; } =20 - /* if APIC ID is not set, set it based on socket/core/thread propertie= s */ + /* + * If APIC ID is not set, + * set it based on socket/die/core/thread properties. + */ if (cpu->apic_id =3D=3D UNASSIGNED_APIC_ID) { - int max_socket =3D (ms->smp.max_cpus - 1) / smp_threads / smp_core= s; + int max_socket =3D (ms->smp.max_cpus - 1) / + smp_threads / smp_cores / pcms->smp_dies; =20 if (cpu->socket_id < 0) { error_setg(errp, "CPU socket-id is not set"); @@ -2619,6 +2623,7 @@ static void pc_machine_initfn(Object *obj) pcms->smbus_enabled =3D true; pcms->sata_enabled =3D true; pcms->pit_enabled =3D true; + pcms->smp_dies =3D 1; =20 pc_system_flash_create(pcms); } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 78830d403a..fac3cc028e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5639,6 +5639,7 @@ static void x86_cpu_initfn(Object *obj) CPUX86State *env =3D &cpu->env; FeatureWord w; =20 + env->nr_dies =3D 1; cpu_set_cpustate_pointers(cpu); =20 object_property_add(obj, "family", "int", --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749563; cv=none; d=zoho.com; s=zohoarc; b=fM0X8rMD9JJCm1N/g53sVlC31cy1t4dWyH54LMw4NcmnqTkA5qHFE4uyqLEqljlfTAiE/pEQAmCTBkJcNGFmnb25yJspA07Lv2vxGTnOD6yPE36h839Su+2i2YWpFS/eeX0wRH4zcvuZjut6pxmFJcSvpk1Rm4MyEswVux9x434= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749563; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sMuigYUQvCa+RjtBvu4EHfk1uBlBOL487vSmGEjQnLg=; b=AHuiT6KmFiWRNoUG7omTKSz7jdFYObHKcXGTH8BYEY+n49zazpLs52g6dUmIYsHKduVKF30FwJ8m4MOEx7g5xRG4V8rBCY+lu5WSe+de5KbJYJMEHCWLWQtlLvYuIVWKLetorZrskRHyZ27Vw2pYhnUqsrSOQsM9MFBoenYqpDM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749563486921.8361980231359; Fri, 28 Jun 2019 12:19:23 -0700 (PDT) Received: from localhost ([::1]:35678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwOt-0006J2-0g for importer@patchew.org; Fri, 28 Jun 2019 15:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40549) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvwl-0003wn-1S for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvwh-0002oq-Md for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35166) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwh-0002nj-Eq for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B84C88F915; Fri, 28 Jun 2019 18:49:55 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E176760920; Fri, 28 Jun 2019 18:49:54 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:25 -0300 Message-Id: <20190628184742.5961-13-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 18:50:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 12/29] hw/i386: Adjust nr_dies with configured smp_dies for PCMachine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu To support multiple dies configuration on PCMachine, the best place to set CPUX86State->nr_dies with requested PCMachineState->smp_dies is in pc_new_cpu() and pc_cpu_pre_plug(). Refactoring pc_new_cpu() is applied and redundant parameter "const char *typename" would be removed. Suggested-by: Eduardo Habkost Signed-off-by: Like Xu Message-Id: <20190612084104.34984-3-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e18b1bade2..211015324a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1518,12 +1518,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, i= nt level) } } =20 -static void pc_new_cpu(const char *typename, int64_t apic_id, Error **errp) +static void pc_new_cpu(PCMachineState *pcms, int64_t apic_id, Error **errp) { Object *cpu =3D NULL; Error *local_err =3D NULL; + CPUX86State *env =3D NULL; =20 - cpu =3D object_new(typename); + cpu =3D object_new(MACHINE(pcms)->cpu_type); + + env =3D &X86_CPU(cpu)->env; + env->nr_dies =3D pcms->smp_dies; =20 object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); @@ -1549,7 +1553,7 @@ void pc_hot_add_cpu(MachineState *ms, const int64_t i= d, Error **errp) return; } =20 - pc_new_cpu(ms->cpu_type, apic_id, &local_err); + pc_new_cpu(PC_MACHINE(ms), apic_id, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -1574,8 +1578,7 @@ void pc_cpus_init(PCMachineState *pcms) ms->smp.max_cpus - 1)= + 1; possible_cpus =3D mc->possible_cpu_arch_ids(ms); for (i =3D 0; i < ms->smp.cpus; i++) { - pc_new_cpu(possible_cpus->cpus[i].type, possible_cpus->cpus[i].arc= h_id, - &error_fatal); + pc_new_cpu(pcms, possible_cpus->cpus[i].arch_id, &error_fatal); } } =20 @@ -2295,6 +2298,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, CPUArchId *cpu_slot; X86CPUTopoInfo topo; X86CPU *cpu =3D X86_CPU(dev); + CPUX86State *env =3D &cpu->env; MachineState *ms =3D MACHINE(hotplug_dev); PCMachineState *pcms =3D PC_MACHINE(hotplug_dev); unsigned int smp_cores =3D ms->smp.cores; @@ -2306,6 +2310,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, return; } =20 + env->nr_dies =3D pcms->smp_dies; + /* * If APIC ID is not set, * set it based on socket/die/core/thread properties. --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748939; cv=none; d=zoho.com; s=zohoarc; b=jnqn048C8embsLTskF9vduCY3OMvW8ZR7e1JnzBMx/zgzfzo1YKV8eGrfojDMZDT2AeUnesuNG6Ee6f9kR/SAqCAttv04C1KCj3+6sC/JfxgNRC1vt4rgriP7OG2c/KycZHG1zBpJ7iC+po3x5g+8Ygj/qoGPtQ6JF3uxUXYwFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748939; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4KPGrp5Cyn6jLAJLGMRAUMzmt1ewtnbMkd5V5ga3EHI=; b=QJFPdUthNw6Cs1BJS5exqJhsSAwmV3B6rzioTP8C3yw3K664hq9frO9KWYFiO1WSWZV94laaQP5qLDkEi2I/ivzd9hoqFk476AFfzNAkLqWYU6DOBY8uqQGYIc0eD6ZS7sQkSbC6riBPDpwhhOs8mJrndp+86+9O3GXl6f+tyns= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156174893935060.94567801659605; Fri, 28 Jun 2019 12:08:59 -0700 (PDT) Received: from localhost ([::1]:35612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwEq-0007UH-Hj for importer@patchew.org; Fri, 28 Jun 2019 15:08:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40601) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvx2-0003yl-2H for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvws-0002xb-38 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwr-0002wd-Qm for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:14 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA0457EBDC; Fri, 28 Jun 2019 18:50:12 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E780919C59; Fri, 28 Jun 2019 18:50:10 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:26 -0300 Message-Id: <20190628184742.5961-14-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 28 Jun 2019 18:50:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 13/29] i386/cpu: Consolidate die-id validity in smp context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The field die_id (default as 0) and has_die_id are introduced to X86CPU. Following the legacy smp check rules, the die_id validity is added to the same contexts as leagcy smp variables such as hmp_hotpluggable_cpus(), machine_set_cpu_numa_node(), cpu_slot_to_string() and pc_cpu_pre_plug(). Acked-by: Dr. David Alan Gilbert Signed-off-by: Like Xu Message-Id: <20190612084104.34984-4-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- qapi/misc.json | 6 ++++-- include/hw/i386/topology.h | 2 ++ target/i386/cpu.h | 1 + hw/core/machine.c | 12 ++++++++++++ hw/i386/pc.c | 14 ++++++++++++++ monitor/hmp-cmds.c | 3 +++ target/i386/cpu.c | 2 ++ 7 files changed, 38 insertions(+), 2 deletions(-) diff --git a/qapi/misc.json b/qapi/misc.json index dc4cf9da20..577f7166f4 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2920,10 +2920,11 @@ # # @node-id: NUMA node ID the CPU belongs to # @socket-id: socket number within node/board the CPU belongs to -# @core-id: core number within socket the CPU belongs to +# @die-id: die number within node/board the CPU belongs to (Since 4.1) +# @core-id: core number within die the CPU belongs to # @thread-id: thread number within core the CPU belongs to # -# Note: currently there are 4 properties that could be present +# Note: currently there are 5 properties that could be present # but management should be prepared to pass through other # properties with device_add command to allow for future # interface extension. This also requires the filed names to be kept in @@ -2934,6 +2935,7 @@ { 'struct': 'CpuInstanceProperties', 'data': { '*node-id': 'int', '*socket-id': 'int', + '*die-id': 'int', '*core-id': 'int', '*thread-id': 'int' } diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index 1ebaee0f76..c9fb41588e 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -47,6 +47,7 @@ typedef uint32_t apic_id_t; =20 typedef struct X86CPUTopoInfo { unsigned pkg_id; + unsigned die_id; unsigned core_id; unsigned smt_id; } X86CPUTopoInfo; @@ -130,6 +131,7 @@ static inline void x86_topo_ids_from_apicid(apic_id_t a= picid, topo->core_id =3D (apicid >> apicid_core_offset(nr_cores, nr_threads))= & ~(0xFFFFFFFFUL << apicid_core_width(nr_cores, nr_thread= s)); topo->pkg_id =3D apicid >> apicid_pkg_offset(nr_cores, nr_threads); + topo->die_id =3D 0; } =20 /* Make APIC ID for the CPU 'cpu_index' diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 14c19e61b1..4d2ae2384e 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1500,6 +1500,7 @@ struct X86CPU { =20 int32_t node_id; /* NUMA node this CPU belongs to */ int32_t socket_id; + int32_t die_id; int32_t core_id; int32_t thread_id; =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index ea5a01aa49..7a44adab39 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -682,6 +682,11 @@ void machine_set_cpu_numa_node(MachineState *machine, return; } =20 + if (props->has_die_id && !slot->props.has_die_id) { + error_setg(errp, "die-id is not supported"); + return; + } + /* skip slots with explicit mismatch */ if (props->has_thread_id && props->thread_id !=3D slot->props.thre= ad_id) { continue; @@ -691,6 +696,10 @@ void machine_set_cpu_numa_node(MachineState *machine, continue; } =20 + if (props->has_die_id && props->die_id !=3D slot->props.die_id) { + continue; + } + if (props->has_socket_id && props->socket_id !=3D slot->props.sock= et_id) { continue; } @@ -948,6 +957,9 @@ static char *cpu_slot_to_string(const CPUArchId *cpu) if (cpu->props.has_socket_id) { g_string_append_printf(s, "socket-id: %"PRId64, cpu->props.socket_= id); } + if (cpu->props.has_die_id) { + g_string_append_printf(s, "die-id: %"PRId64, cpu->props.die_id); + } if (cpu->props.has_core_id) { if (s->len) { g_string_append_printf(s, ", "); diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 211015324a..98a314dcf0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2327,6 +2327,10 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, error_setg(errp, "Invalid CPU socket-id: %u must be in range 0= :%u", cpu->socket_id, max_socket); return; + } else if (cpu->die_id > pcms->smp_dies - 1) { + error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u= ", + cpu->die_id, max_socket); + return; } if (cpu->core_id < 0) { error_setg(errp, "CPU core-id is not set"); @@ -2346,6 +2350,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, } =20 topo.pkg_id =3D cpu->socket_id; + topo.die_id =3D cpu->die_id; topo.core_id =3D cpu->core_id; topo.smt_id =3D cpu->thread_id; cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); @@ -2383,6 +2388,13 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_= dev, } cpu->socket_id =3D topo.pkg_id; =20 + if (cpu->die_id !=3D -1 && cpu->die_id !=3D topo.die_id) { + error_setg(errp, "property die-id: %u doesn't match set apic-id:" + " 0x%x (die-id: %u)", cpu->die_id, cpu->apic_id, topo.die_id); + return; + } + cpu->die_id =3D topo.die_id; + if (cpu->core_id !=3D -1 && cpu->core_id !=3D topo.core_id) { error_setg(errp, "property core-id: %u doesn't match set apic-id:" " 0x%x (core-id: %u)", cpu->core_id, cpu->apic_id, topo.core_i= d); @@ -2700,6 +2712,8 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) ms->smp.cores, ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; + ms->possible_cpus->cpus[i].props.has_die_id =3D true; + ms->possible_cpus->cpus[i].props.die_id =3D topo.die_id; ms->possible_cpus->cpus[i].props.has_core_id =3D true; ms->possible_cpus->cpus[i].props.core_id =3D topo.core_id; ms->possible_cpus->cpus[i].props.has_thread_id =3D true; diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c283dde0e9..7f50c9d83a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -3114,6 +3114,9 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict = *qdict) if (c->has_socket_id) { monitor_printf(mon, " socket-id: \"%" PRIu64 "\"\n", c->soc= ket_id); } + if (c->has_die_id) { + monitor_printf(mon, " die-id: \"%" PRIu64 "\"\n", c->die_id= ); + } if (c->has_core_id) { monitor_printf(mon, " core-id: \"%" PRIu64 "\"\n", c->core_= id); } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index fac3cc028e..bd0f873883 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5865,11 +5865,13 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, 0), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, 0), DEFINE_PROP_INT32("core-id", X86CPU, core_id, 0), + DEFINE_PROP_INT32("die-id", X86CPU, die_id, 0), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, 0), #else DEFINE_PROP_UINT32("apic-id", X86CPU, apic_id, UNASSIGNED_APIC_ID), DEFINE_PROP_INT32("thread-id", X86CPU, thread_id, -1), DEFINE_PROP_INT32("core-id", X86CPU, core_id, -1), + DEFINE_PROP_INT32("die-id", X86CPU, die_id, -1), DEFINE_PROP_INT32("socket-id", X86CPU, socket_id, -1), #endif DEFINE_PROP_INT32("node-id", X86CPU, node_id, CPU_UNSET_NUMA_NODE_ID), --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749922; cv=none; d=zoho.com; s=zohoarc; b=jbgwptpWiLCkxqT9BQNPpgSnx5g9PGYz/3ABeSnDtfnvXMD/PUUWS+pUlhlQZPQONj0OWHUbnGkTl2Z12p8fGtWHAefTd0P8eaCQiu7BcfXJzkKtVuGPt8/2lEPkRZUWi4PbVj+I7+Bfk+kSx9iGRlefMsvlVUg57oFjJxU7EIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749922; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kM1++zGcHHsANfP06AK1HUBQewDkZuQhDXqx4qRFgfE=; b=Gbt2eeZ//0F4XTH6Ws/GQbzON5Wik6XieM9cPBB00eo9FgDi0jezeX8ZMcEeIFV+mklO2csbCcHq4ahuHSddYNIfJaFMu1If21rEtyTybhLfZmkICfGNceNLXfhN36EJEm+WLDUTlIY0UHOAqvdUXwoLVN5oi57kFdD0OEPK450= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749922470309.2974305116028; Fri, 28 Jun 2019 12:25:22 -0700 (PDT) Received: from localhost ([::1]:35708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwUg-0001Jh-Gr for importer@patchew.org; Fri, 28 Jun 2019 15:25:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40625) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvx6-00042D-8R for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvx1-00034r-V4 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvwv-0002zX-CR for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:18 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFD7A7E421; Fri, 28 Jun 2019 18:50:16 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90D785C634; Fri, 28 Jun 2019 18:50:14 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:27 -0300 Message-Id: <20190628184742.5961-15-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 28 Jun 2019 18:50:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 14/29] i386: Update new x86_apicid parsing rules with die_offset support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu In new sockets/dies/cores/threads model, the apicid of logical cpu could imply die level info of guest cpu topology thus x86_apicid_from_cpu_idx() need to be refactored with #dies value, so does apicid_*_offset(). To keep semantic compatibility, the legacy pkg_offset which helps to generate CPUIDs such as 0x3 for L3 cache should be mapping to die_offset. Signed-off-by: Like Xu Message-Id: <20190612084104.34984-5-like.xu@linux.intel.com> [ehabkost: squash unit test patch] Message-Id: <20190612084104.34984-6-like.xu@linux.intel.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- include/hw/i386/topology.h | 76 ++++++++++++++++++++++++---------- hw/i386/pc.c | 29 ++++++++----- target/i386/cpu.c | 13 +++--- tests/test-x86-cpuid.c | 84 ++++++++++++++++++++------------------ 4 files changed, 126 insertions(+), 76 deletions(-) diff --git a/include/hw/i386/topology.h b/include/hw/i386/topology.h index c9fb41588e..4ff5b2da6c 100644 --- a/include/hw/i386/topology.h +++ b/include/hw/i386/topology.h @@ -63,88 +63,120 @@ static unsigned apicid_bitwidth_for_count(unsigned cou= nt) =20 /* Bit width of the SMT_ID (thread ID) field on the APIC ID */ -static inline unsigned apicid_smt_width(unsigned nr_cores, unsigned nr_thr= eads) +static inline unsigned apicid_smt_width(unsigned nr_dies, + unsigned nr_cores, + unsigned nr_threads) { return apicid_bitwidth_for_count(nr_threads); } =20 /* Bit width of the Core_ID field */ -static inline unsigned apicid_core_width(unsigned nr_cores, unsigned nr_th= reads) +static inline unsigned apicid_core_width(unsigned nr_dies, + unsigned nr_cores, + unsigned nr_threads) { return apicid_bitwidth_for_count(nr_cores); } =20 +/* Bit width of the Die_ID field */ +static inline unsigned apicid_die_width(unsigned nr_dies, + unsigned nr_cores, + unsigned nr_threads) +{ + return apicid_bitwidth_for_count(nr_dies); +} + /* Bit offset of the Core_ID field */ -static inline unsigned apicid_core_offset(unsigned nr_cores, +static inline unsigned apicid_core_offset(unsigned nr_dies, + unsigned nr_cores, unsigned nr_threads) { - return apicid_smt_width(nr_cores, nr_threads); + return apicid_smt_width(nr_dies, nr_cores, nr_threads); +} + +/* Bit offset of the Die_ID field */ +static inline unsigned apicid_die_offset(unsigned nr_dies, + unsigned nr_cores, + unsigned nr_threads) +{ + return apicid_core_offset(nr_dies, nr_cores, nr_threads) + + apicid_core_width(nr_dies, nr_cores, nr_threads); } =20 /* Bit offset of the Pkg_ID (socket ID) field */ -static inline unsigned apicid_pkg_offset(unsigned nr_cores, unsigned nr_th= reads) +static inline unsigned apicid_pkg_offset(unsigned nr_dies, + unsigned nr_cores, + unsigned nr_threads) { - return apicid_core_offset(nr_cores, nr_threads) + - apicid_core_width(nr_cores, nr_threads); + return apicid_die_offset(nr_dies, nr_cores, nr_threads) + + apicid_die_width(nr_dies, nr_cores, nr_threads); } =20 /* Make APIC ID for the CPU based on Pkg_ID, Core_ID, SMT_ID * * The caller must make sure core_id < nr_cores and smt_id < nr_threads. */ -static inline apic_id_t apicid_from_topo_ids(unsigned nr_cores, +static inline apic_id_t apicid_from_topo_ids(unsigned nr_dies, + unsigned nr_cores, unsigned nr_threads, const X86CPUTopoInfo *topo) { - return (topo->pkg_id << apicid_pkg_offset(nr_cores, nr_threads)) | - (topo->core_id << apicid_core_offset(nr_cores, nr_threads)) | + return (topo->pkg_id << apicid_pkg_offset(nr_dies, nr_cores, nr_threa= ds)) | + (topo->die_id << apicid_die_offset(nr_dies, nr_cores, nr_threa= ds)) | + (topo->core_id << apicid_core_offset(nr_dies, nr_cores, nr_threa= ds)) | topo->smt_id; } =20 /* Calculate thread/core/package IDs for a specific topology, * based on (contiguous) CPU index */ -static inline void x86_topo_ids_from_idx(unsigned nr_cores, +static inline void x86_topo_ids_from_idx(unsigned nr_dies, + unsigned nr_cores, unsigned nr_threads, unsigned cpu_index, X86CPUTopoInfo *topo) { - unsigned core_index =3D cpu_index / nr_threads; + topo->pkg_id =3D cpu_index / (nr_dies * nr_cores * nr_threads); + topo->die_id =3D cpu_index / (nr_cores * nr_threads) % nr_dies; + topo->core_id =3D cpu_index / nr_threads % nr_cores; topo->smt_id =3D cpu_index % nr_threads; - topo->core_id =3D core_index % nr_cores; - topo->pkg_id =3D core_index / nr_cores; } =20 /* Calculate thread/core/package IDs for a specific topology, * based on APIC ID */ static inline void x86_topo_ids_from_apicid(apic_id_t apicid, + unsigned nr_dies, unsigned nr_cores, unsigned nr_threads, X86CPUTopoInfo *topo) { topo->smt_id =3D apicid & - ~(0xFFFFFFFFUL << apicid_smt_width(nr_cores, nr_threads= )); - topo->core_id =3D (apicid >> apicid_core_offset(nr_cores, nr_threads))= & - ~(0xFFFFFFFFUL << apicid_core_width(nr_cores, nr_thread= s)); - topo->pkg_id =3D apicid >> apicid_pkg_offset(nr_cores, nr_threads); - topo->die_id =3D 0; + ~(0xFFFFFFFFUL << apicid_smt_width(nr_dies, nr_cores, nr_threa= ds)); + topo->core_id =3D + (apicid >> apicid_core_offset(nr_dies, nr_cores, nr_threads)) & + ~(0xFFFFFFFFUL << apicid_core_width(nr_dies, nr_cores, nr_thre= ads)); + topo->die_id =3D + (apicid >> apicid_die_offset(nr_dies, nr_cores, nr_threads)) & + ~(0xFFFFFFFFUL << apicid_die_width(nr_dies, nr_cores, nr_threa= ds)); + topo->pkg_id =3D apicid >> apicid_pkg_offset(nr_dies, nr_cores, nr_thr= eads); } =20 /* Make APIC ID for the CPU 'cpu_index' * * 'cpu_index' is a sequential, contiguous ID for the CPU. */ -static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_cores, +static inline apic_id_t x86_apicid_from_cpu_idx(unsigned nr_dies, + unsigned nr_cores, unsigned nr_threads, unsigned cpu_index) { X86CPUTopoInfo topo; - x86_topo_ids_from_idx(nr_cores, nr_threads, cpu_index, &topo); - return apicid_from_topo_ids(nr_cores, nr_threads, &topo); + x86_topo_ids_from_idx(nr_dies, nr_cores, nr_threads, cpu_index, &topo); + return apicid_from_topo_ids(nr_dies, nr_cores, nr_threads, &topo); } =20 #endif /* HW_I386_TOPOLOGY_H */ diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 98a314dcf0..9921ce4f5e 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -931,10 +931,11 @@ void enable_compat_apic_id_mode(void) static uint32_t x86_cpu_apic_id_from_index(MachineState *ms, unsigned int cpu_index) { + PCMachineState *pcms =3D PC_MACHINE(ms); uint32_t correct_id; static bool warned; =20 - correct_id =3D x86_apicid_from_cpu_idx(ms->smp.cores, + correct_id =3D x86_apicid_from_cpu_idx(pcms->smp_dies, ms->smp.cores, ms->smp.threads, cpu_index); if (compat_apic_id_mode) { if (cpu_index !=3D correct_id && !warned && !qtest_enabled()) { @@ -2353,18 +2354,21 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug= _dev, topo.die_id =3D cpu->die_id; topo.core_id =3D cpu->core_id; topo.smt_id =3D cpu->thread_id; - cpu->apic_id =3D apicid_from_topo_ids(smp_cores, smp_threads, &top= o); + cpu->apic_id =3D apicid_from_topo_ids(pcms->smp_dies, smp_cores, + smp_threads, &topo); } =20 cpu_slot =3D pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); if (!cpu_slot) { MachineState *ms =3D MACHINE(pcms); =20 - x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &to= po); - error_setg(errp, "Invalid CPU [socket: %u, core: %u, thread: %u] w= ith" - " APIC ID %" PRIu32 ", valid index range 0:%d", - topo.pkg_id, topo.core_id, topo.smt_id, cpu->apic_id, - ms->possible_cpus->len - 1); + x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, + smp_cores, smp_threads, &topo); + error_setg(errp, + "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" + " APIC ID %" PRIu32 ", valid index range 0:%d", + topo.pkg_id, topo.die_id, topo.core_id, topo.smt_id, + cpu->apic_id, ms->possible_cpus->len - 1); return; } =20 @@ -2380,7 +2384,8 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_d= ev, /* TODO: move socket_id/core_id/thread_id checks into x86_cpu_realizef= n() * once -smp refactoring is complete and there will be CPU private * CPUState::nr_cores and CPUState::nr_threads fields instead of globa= ls */ - x86_topo_ids_from_apicid(cpu->apic_id, smp_cores, smp_threads, &topo); + x86_topo_ids_from_apicid(cpu->apic_id, pcms->smp_dies, + smp_cores, smp_threads, &topo); if (cpu->socket_id !=3D -1 && cpu->socket_id !=3D topo.pkg_id) { error_setg(errp, "property socket-id: %u doesn't match set apic-id= :" " 0x%x (socket-id: %u)", cpu->socket_id, cpu->apic_id, topo.pk= g_id); @@ -2678,10 +2683,12 @@ pc_cpu_index_to_props(MachineState *ms, unsigned cp= u_index) static int64_t pc_get_default_cpu_node_id(const MachineState *ms, int idx) { X86CPUTopoInfo topo; + PCMachineState *pcms =3D PC_MACHINE(ms); =20 assert(idx < ms->possible_cpus->len); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[idx].arch_id, - ms->smp.cores, ms->smp.threads, &topo); + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); return topo.pkg_id % nb_numa_nodes; } =20 @@ -2689,6 +2696,7 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) { int i; unsigned int max_cpus =3D ms->smp.max_cpus; + PCMachineState *pcms =3D PC_MACHINE(ms); =20 if (ms->possible_cpus) { /* @@ -2709,7 +2717,8 @@ static const CPUArchIdList *pc_possible_cpu_arch_ids(= MachineState *ms) ms->possible_cpus->cpus[i].vcpus_count =3D 1; ms->possible_cpus->cpus[i].arch_id =3D x86_cpu_apic_id_from_index(= ms, i); x86_topo_ids_from_apicid(ms->possible_cpus->cpus[i].arch_id, - ms->smp.cores, ms->smp.threads, &topo); + pcms->smp_dies, ms->smp.cores, + ms->smp.threads, &topo); ms->possible_cpus->cpus[i].props.has_socket_id =3D true; ms->possible_cpus->cpus[i].props.socket_id =3D topo.pkg_id; ms->possible_cpus->cpus[i].props.has_die_id =3D true; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bd0f873883..3a38fe3633 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4267,7 +4267,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, { X86CPU *cpu =3D env_archcpu(env); CPUState *cs =3D env_cpu(env); - uint32_t pkg_offset; + uint32_t die_offset; uint32_t limit; uint32_t signature[3]; =20 @@ -4356,10 +4356,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, eax, ebx, ecx, edx); break; case 3: /* L3 cache info */ - pkg_offset =3D apicid_pkg_offset(cs->nr_cores, cs->nr_thre= ads); + die_offset =3D apicid_die_offset(env->nr_dies, + cs->nr_cores, cs->nr_threads); if (cpu->enable_l3_cache) { encode_cache_cpuid4(env->cache_info_cpuid4.l3_cache, - (1 << pkg_offset), cs->nr_cores, + (1 << die_offset), cs->nr_cores, eax, ebx, ecx, edx); break; } @@ -4441,12 +4442,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, =20 switch (count) { case 0: - *eax =3D apicid_core_offset(cs->nr_cores, cs->nr_threads); + *eax =3D apicid_core_offset(env->nr_dies, + cs->nr_cores, cs->nr_threads); *ebx =3D cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; break; case 1: - *eax =3D apicid_pkg_offset(cs->nr_cores, cs->nr_threads); + *eax =3D apicid_pkg_offset(env->nr_dies, + cs->nr_cores, cs->nr_threads); *ebx =3D cs->nr_cores * cs->nr_threads; *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; break; diff --git a/tests/test-x86-cpuid.c b/tests/test-x86-cpuid.c index ff225006e4..1942287f33 100644 --- a/tests/test-x86-cpuid.c +++ b/tests/test-x86-cpuid.c @@ -28,74 +28,80 @@ =20 static void test_topo_bits(void) { - /* simple tests for 1 thread per core, 1 core per socket */ - g_assert_cmpuint(apicid_smt_width(1, 1), =3D=3D, 0); - g_assert_cmpuint(apicid_core_width(1, 1), =3D=3D, 0); + /* simple tests for 1 thread per core, 1 core per die, 1 die per packa= ge */ + g_assert_cmpuint(apicid_smt_width(1, 1, 1), =3D=3D, 0); + g_assert_cmpuint(apicid_core_width(1, 1, 1), =3D=3D, 0); + g_assert_cmpuint(apicid_die_width(1, 1, 1), =3D=3D, 0); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 0), =3D=3D, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1), =3D=3D, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 2), =3D=3D, 2); - g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 3), =3D=3D, 3); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 0), =3D=3D, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 1), =3D=3D, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 2), =3D=3D, 2); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 1, 1, 3), =3D=3D, 3); =20 =20 /* Test field width calculation for multiple values */ - g_assert_cmpuint(apicid_smt_width(1, 2), =3D=3D, 1); - g_assert_cmpuint(apicid_smt_width(1, 3), =3D=3D, 2); - g_assert_cmpuint(apicid_smt_width(1, 4), =3D=3D, 2); + g_assert_cmpuint(apicid_smt_width(1, 1, 2), =3D=3D, 1); + g_assert_cmpuint(apicid_smt_width(1, 1, 3), =3D=3D, 2); + g_assert_cmpuint(apicid_smt_width(1, 1, 4), =3D=3D, 2); =20 - g_assert_cmpuint(apicid_smt_width(1, 14), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 15), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 16), =3D=3D, 4); - g_assert_cmpuint(apicid_smt_width(1, 17), =3D=3D, 5); + g_assert_cmpuint(apicid_smt_width(1, 1, 14), =3D=3D, 4); + g_assert_cmpuint(apicid_smt_width(1, 1, 15), =3D=3D, 4); + g_assert_cmpuint(apicid_smt_width(1, 1, 16), =3D=3D, 4); + g_assert_cmpuint(apicid_smt_width(1, 1, 17), =3D=3D, 5); =20 =20 - g_assert_cmpuint(apicid_core_width(30, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(31, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(32, 2), =3D=3D, 5); - g_assert_cmpuint(apicid_core_width(33, 2), =3D=3D, 6); + g_assert_cmpuint(apicid_core_width(1, 30, 2), =3D=3D, 5); + g_assert_cmpuint(apicid_core_width(1, 31, 2), =3D=3D, 5); + g_assert_cmpuint(apicid_core_width(1, 32, 2), =3D=3D, 5); + g_assert_cmpuint(apicid_core_width(1, 33, 2), =3D=3D, 6); =20 + g_assert_cmpuint(apicid_die_width(1, 30, 2), =3D=3D, 0); + g_assert_cmpuint(apicid_die_width(2, 30, 2), =3D=3D, 1); + g_assert_cmpuint(apicid_die_width(3, 30, 2), =3D=3D, 2); + g_assert_cmpuint(apicid_die_width(4, 30, 2), =3D=3D, 2); =20 /* build a weird topology and see if IDs are calculated correctly */ =20 /* This will use 2 bits for thread ID and 3 bits for core ID */ - g_assert_cmpuint(apicid_smt_width(6, 3), =3D=3D, 2); - g_assert_cmpuint(apicid_core_width(6, 3), =3D=3D, 3); - g_assert_cmpuint(apicid_pkg_offset(6, 3), =3D=3D, 5); + g_assert_cmpuint(apicid_smt_width(1, 6, 3), =3D=3D, 2); + g_assert_cmpuint(apicid_core_offset(1, 6, 3), =3D=3D, 2); + g_assert_cmpuint(apicid_die_offset(1, 6, 3), =3D=3D, 5); + g_assert_cmpuint(apicid_pkg_offset(1, 6, 3), =3D=3D, 5); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 0), =3D=3D, 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1), =3D=3D, 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2), =3D=3D, 2); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 0), =3D=3D, 0); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1), =3D=3D, 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2), =3D=3D, 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 0), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 0), =3D=3D, (1 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 1), =3D=3D, (1 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 1 * 3 + 2), =3D=3D, (1 << 2) | 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 0), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 0), =3D=3D, (2 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 1), =3D=3D, (2 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 2 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 2 * 3 + 2), =3D=3D, (2 << 2) | 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 0), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 0), =3D=3D, (5 << 2) | 0); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 1), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 1), =3D=3D, (5 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 5 * 3 + 2), =3D=3D, + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, 5 * 3 + 2), =3D=3D, (5 << 2) | 2); =20 - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 6 * 3 + 0 * 3 + 0),= =3D=3D, - (1 << 5)); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 1 * 6 * 3 + 1 * 3 + 1),= =3D=3D, - (1 << 5) | (1 << 2) | 1); - g_assert_cmpuint(x86_apicid_from_cpu_idx(6, 3, 3 * 6 * 3 + 5 * 3 + 2),= =3D=3D, - (3 << 5) | (5 << 2) | 2); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + 1 * 6 * 3 + 0 * 3 + 0), =3D=3D, (1 << 5)); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + 1 * 6 * 3 + 1 * 3 + 1), =3D=3D, (1 << 5) | (1 << 2) |= 1); + g_assert_cmpuint(x86_apicid_from_cpu_idx(1, 6, 3, + 3 * 6 * 3 + 5 * 3 + 2), =3D=3D, (3 << 5) | (5 << 2) |= 2); } =20 int main(int argc, char **argv) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749235; cv=none; d=zoho.com; s=zohoarc; b=GEAEkVw01iHQb/VkEZ2ljhnXtJwAXC+k7WYsBZwNBHFlmMqRIkEAjz+IMpEa5+xmqxP2c1WfVqBkabuCHDFGg86bMEHsKT/+cMm6cw1RaBmId+FfB0A9yrbsEvXQUTG3KFsBXKbA/RNZ7q67BJvVP9GYZ8FG3lT/mbkPxYC2LEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749235; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XT/1ufMIjKtM8Ti0iH1x9urSTHVRuqEvNynWC8Njznc=; b=R5oBjIZLYkYDjK/5AzLzqe8JQ0T/yMJ5jKhDOk4kD+dT9tP0ruwmjgAU+CsC332wHlhcHeDdiKYB0erRDSCeo7P6J3CITI9VbXvDz9c0/FlyClZKXnuCEVUw3cjj+CCkLPCsmHTFTvI8XudORgKHGlsziTn3tpmXCl+onBGKoKw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749235990586.5591904645255; Fri, 28 Jun 2019 12:13:55 -0700 (PDT) Received: from localhost ([::1]:35650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwJf-0003ML-2Y for importer@patchew.org; Fri, 28 Jun 2019 15:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40637) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvx8-00043f-8I for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvx4-00036v-8T for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvx3-00033r-RC for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:26 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7E9587633; Fri, 28 Jun 2019 18:50:22 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E69595D71B; Fri, 28 Jun 2019 18:50:20 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:28 -0300 Message-Id: <20190628184742.5961-16-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 18:50:22 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 15/29] pc: fix possible NULL pointer dereference in pc_machine_get_device_memory_region_size() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov QEMU will crash when device-memory-region-size property is read if ms->devi= ce_memory wasn't initialized yet. Crash can be reproduced with: $QEMU -preconfig -qmp unix:qmp_socket,server,nowait & ./scripts/qmp/qom-get -s qmp_socket /machine.device-memory-region-size Instead of crashing return 0 if ms->device_memory hasn't been initialized. Signed-off-by: Igor Mammedov Message-Id: <20190624090200.5383-1-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9921ce4f5e..9b953eeeea 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2489,7 +2489,11 @@ pc_machine_get_device_memory_region_size(Object *obj= , Visitor *v, Error **errp) { MachineState *ms =3D MACHINE(obj); - int64_t value =3D memory_region_size(&ms->device_memory->mr); + int64_t value =3D 0; + + if (ms->device_memory) { + value =3D memory_region_size(&ms->device_memory->mr); + } =20 visit_type_int(v, name, &value, errp); } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749241; cv=none; d=zoho.com; s=zohoarc; b=mqHj5hqJX90qAdoxi6b3DSe0jCgqzt4BTLAOFnaqm2ctR6mYME0M3eIXekwjLM5yDZfgZmUVO1qWtY5KKkfC0Iidq56ljwPw4XBt8QWKdmPFqDuhUkKcMeQV244ThVLSViKD3klovckINarpeXpZU4+BVSzC4Ix12al1m8Fs8PY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749241; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ad6xxoCVhkT1wkxzY7MEA50fPeeIKuLKS2BSPLUroCc=; b=XUrrCJ4z1QWH0lbyew0zhzPPkrvTWTZXjgmtjESELIE35P4jkKU23AVYeoBc8f1Al0GfPuaLxxD4f/ue1Bz1N27OBVFu6RCBuisvt/fiCBH1AfS6H4xVs3N81eMuait8fPDD13ORXLcKM+XCDQLW5LlPKIjQvQ1p6b2XT9TWdnM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749241906771.0783631221614; Fri, 28 Jun 2019 12:14:01 -0700 (PDT) Received: from localhost ([::1]:35648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwJX-00038C-G5 for importer@patchew.org; Fri, 28 Jun 2019 15:13:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40665) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvxT-00049H-RZ for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvxE-0003KG-UU for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvx8-0003C4-7X for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 871AD811BD; Fri, 28 Jun 2019 18:50:29 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4B88600C6; Fri, 28 Jun 2019 18:50:27 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:29 -0300 Message-Id: <20190628184742.5961-17-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 18:50:29 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 16/29] machine: show if CLI option '-numa node, mem' is supported in QAPI schema X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Legacy '-numa node,mem' option has a number of issues and mgmt often defaults to it. Unfortunately it's no possible to replace it with an alternative '-numa memdev' without breaking migration compatibility. What's possible though is to deprecate it, keeping option working with old machine types only. In order to help users to find out if being deprecated CLI option '-numa node,mem' is still supported by particular machine type, add new "numa-mem-supported" property to output of query-machines. "numa-mem-supported" is set to 'true' for machines that currently support NUMA, but it will be flipped to 'false' later on, once deprecation period expires and kept 'true' only for old machine types that used to support the legacy option so it won't break existing configuration that are using it. Signed-off-by: Igor Mammedov Message-Id: <1560172207-378962-1-git-send-email-imammedo@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Eduardo Habkost --- qapi/misc.json | 5 ++++- include/hw/boards.h | 3 +++ hw/arm/virt.c | 1 + hw/i386/pc.c | 1 + hw/ppc/spapr.c | 1 + vl.c | 1 + 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index 577f7166f4..ccd56c9191 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2014,12 +2014,15 @@ # # @hotpluggable-cpus: cpu hotplug via -device is supported (since 2.7.0) # +# @numa-mem-supported: true if '-numa node,mem' option is supported by +# the machine type and false otherwise (since 4.1) +# # Since: 1.2.0 ## { 'struct': 'MachineInfo', 'data': { 'name': 'str', '*alias': 'str', '*is-default': 'bool', 'cpu-max': 'int', - 'hotpluggable-cpus': 'bool'} } + 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool'} } =20 ## # @query-machines: diff --git a/include/hw/boards.h b/include/hw/boards.h index 843d82c77d..47cba6ce6c 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -159,6 +159,8 @@ typedef struct { * @kvm_type: * Return the type of KVM corresponding to the kvm-type string option or * computed based on other criteria such as the host kernel capabilitie= s. + * @numa_mem_supported: + * true if '--numa node.mem' option is supported and false otherwise */ struct MachineClass { /*< private >*/ @@ -211,6 +213,7 @@ struct MachineClass { bool ignore_boot_device_suffixes; bool smbus_no_migration_support; bool nvdimm_supported; + bool numa_mem_supported; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 026a5be18b..b0a29be099 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1951,6 +1951,7 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; hc->plug =3D virt_machine_device_plug_cb; + mc->numa_mem_supported =3D true; } =20 static void virt_instance_init(Object *obj) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9b953eeeea..114fd5f8d4 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2792,6 +2792,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D true; + mc->numa_mem_supported =3D true; =20 object_class_property_add(oc, PC_MACHINE_DEVMEM_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 51256ac9ca..821f0d4a49 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4367,6 +4367,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) * in which LMBs are represented and hot-added */ mc->numa_mem_align_shift =3D 28; + mc->numa_mem_supported =3D true; =20 smc->default_caps.caps[SPAPR_CAP_HTM] =3D SPAPR_CAP_OFF; smc->default_caps.caps[SPAPR_CAP_VSX] =3D SPAPR_CAP_ON; diff --git a/vl.c b/vl.c index 96f4dd828b..1729410e92 100644 --- a/vl.c +++ b/vl.c @@ -1430,6 +1430,7 @@ MachineInfoList *qmp_query_machines(Error **errp) info->name =3D g_strdup(mc->name); info->cpu_max =3D !mc->max_cpus ? 1 : mc->max_cpus; info->hotpluggable_cpus =3D mc->has_hotpluggable_cpus; + info->numa_mem_supported =3D mc->numa_mem_supported; =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750097; cv=none; d=zoho.com; s=zohoarc; b=fgfpvE6Wapyw+5Es14wNhdvAXOp5WEO37DmeiiztaHEj9sPxY5C5gOSquzDIGlt77DYmuhl5PAD57R55c8DlAC1gfdqrflIspL7vtESnuOT8C5zJzhzhaHSMg35L16Lupoii3QJWBUvSGXsRUtFF+JvUyWkR6Le+lyT4QSre4ls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750097; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pXmv+n36bUkPxsHXKPAY0bqz9I+J1tPA2Rbam5u3vLM=; b=MRFL/qeH+xG7e8sM2tnaMN+uDImP5ZkgbsQVn5b32Z4nUd+mEuiGM9l4ADPmpTAMWI+/jOy3NBX/zi4ZPRIt/zsqtr2EFUgesTi6M9CXNwmT9Qp9szlo/EP/9h7lx5crJPZYghGxjT19NNuzyagn+NuKlP6jP5VhSuqrKPDaigI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750097755830.5765476907676; Fri, 28 Jun 2019 12:28:17 -0700 (PDT) Received: from localhost ([::1]:35730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwXb-0004OM-4Z for importer@patchew.org; Fri, 28 Jun 2019 15:28:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40763) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvxb-0004Fu-Pg for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvxX-0003ZE-BJ for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvxW-0003IP-UW for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 672B73082131; Fri, 28 Jun 2019 18:50:34 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id B63CF5D705; Fri, 28 Jun 2019 18:50:33 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:30 -0300 Message-Id: <20190628184742.5961-18-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 28 Jun 2019 18:50:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 17/29] numa: deprecate 'mem' parameter of '-numa node' option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov The parameter allows to configure fake NUMA topology where guest VM simulates NUMA topology but not actually getting performance benefits from it. The same or better results could be achieved using 'memdev' parameter. Beside of unpredictable performance, '-numa node.mem' option has other issues when it's used with combination of -mem-path + + -mem-prealloc + memdev backends (pc-dimm), breaking binding of memdev backends since mem-path/mem-prealloc are global and affect the most of RAM allocations. It's possible to make memdevs and global -mem-path/mem-prealloc to play nicely together but that will just complicate already complicated code and add unobious ways it could break on 2 different memmory allocation pathes and their combinations. Instead of it, consolidate all guest RAM allocation over memdev which still allows to create fake NUMA configurations if desired and leaves one simplifyed code path to consider when it comes to guest RAM allocation. To achieve desired simplification deprecate 'mem' parameter as its ad-hoc partitioning of initial RAM MemoryRegion can't be translated to memdev based backend transparently to users and in compatible manner (migration wise). Later down the road that will allow to consolidate means of how guest RAM is allocated and would permit us to clean up quite a bit memory allocations and numa code, leaving only 'memdev' implementation in place. Signed-off-by: Igor Mammedov Message-Id: <1559205199-233510-3-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 2 ++ qemu-deprecated.texi | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/numa.c b/numa.c index 7594eb5a7e..7d449c7e95 100644 --- a/numa.c +++ b/numa.c @@ -122,6 +122,8 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, =20 if (node->has_mem) { numa_info[nodenr].node_mem =3D node->mem; + warn_report("Parameter -numa node,mem is deprecated," + " use -numa node,memdev instead"); } if (node->has_memdev) { Object *o; diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index df04f2840b..44c9a95966 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -88,6 +88,22 @@ The @code{-realtime mlock=3Don|off} argument has been re= placed by the The ``-virtfs_synth'' argument is now deprecated. Please use ``-fsdev synt= h'' and ``-device virtio-9p-...'' instead. =20 +@subsection -numa node,mem=3D@var{size} (since 4.1) + +The parameter @option{mem} of @option{-numa node} is used to assign a part= of +guest RAM to a NUMA node. But when using it, it's impossible to manage spe= cified +RAM chunk on the host side (like bind it to a host node, setting bind poli= cy, ...), +so guest end-ups with the fake NUMA configuration with suboptiomal perform= ance. +However since 2014 there is an alternative way to assign RAM to a NUMA node +using parameter @option{memdev}, which does the same as @option{mem} and a= dds +means to actualy manage node RAM on the host side. Use parameter @option{m= emdev} +with @var{memory-backend-ram} backend as an replacement for parameter @opt= ion{mem} +to achieve the same fake NUMA effect or a properly configured +@var{memory-backend-file} backend to actually benefit from NUMA configurat= ion. +In future new machine versions will not accept the option but it will still +work with old machine types. User can check QAPI schema to see if the lega= cy +option is supported by looking at MachineInfo::numa-mem-supported property. + @section QEMU Machine Protocol (QMP) commands =20 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749533; cv=none; d=zoho.com; s=zohoarc; b=OGfaO7MrM6IKoyBnrPacXZGQAkBeXAqCehQAgfYAX9jNXR15vX5Dj6wbj13VT7+gWa3TxvxGmzDPV/hT826e9e+wBBowadvKDzjBN7PcnO7g5cEO6HcKJJzGsaMeL2R6wadTz8LGgSVfpcZnSvF3vcXLQP6KSxbpZpeflkzxIQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749533; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jrp0vlfNW1XTMz056ejIprWq2DAZ5pLhY3E2D7DMOV8=; b=mfG/M5Q9astZsDg9XQgXlaj2vjjiHthfz1tXT1sJt4gEbkZ5Z4rUtMdzTmve/7Id4UOg1jekVZS2AtQU3PKn+Ch2VtO9igKotKjJ5WN95TI3+GsjB5dmqhYFAMI7gacwCc/mevez+R/feRAerWOydTUvFz6TmHE17zoXMp7Ig4Y= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749533112940.955760957867; Fri, 28 Jun 2019 12:18:53 -0700 (PDT) Received: from localhost ([::1]:35674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwOQ-00065R-AW for importer@patchew.org; Fri, 28 Jun 2019 15:18:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40761) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvxb-0004FZ-L6 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvxX-0003ZM-EP for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvxX-0003My-63 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:50:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F1D63001802; Fri, 28 Jun 2019 18:50:40 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 745455D705; Fri, 28 Jun 2019 18:50:38 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:31 -0300 Message-Id: <20190628184742.5961-19-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 28 Jun 2019 18:50:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 18/29] numa: deprecate implict memory distribution between nodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Implicit RAM distribution between nodes has exactly the same issues as: "numa: deprecate 'mem' parameter of '-numa node' option" only with QEMU being the user that's 'adding' 'mem' parameter. Deprecate it, to get it out of the way so that we could consolidate guest RAM allocation using memory backends making it consistent and possibly later on transition to using memory devices instead of adhoc memory mapping for the initial RAM. Signed-off-by: Igor Mammedov Message-Id: <1559205199-233510-4-git-send-email-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 3 +++ qemu-deprecated.texi | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/numa.c b/numa.c index 7d449c7e95..c1f5e84fa5 100644 --- a/numa.c +++ b/numa.c @@ -410,6 +410,9 @@ void numa_complete_configuration(MachineState *ms) if (i =3D=3D nb_numa_nodes) { assert(mc->numa_auto_assign_ram); mc->numa_auto_assign_ram(mc, numa_info, nb_numa_nodes, ram_siz= e); + warn_report("Default splitting of RAM between nodes is depreca= ted," + " Use '-numa node,memdev' to explictly define RAM" + " allocation per node"); } =20 numa_total =3D 0; diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 44c9a95966..2fe9b72121 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -104,6 +104,14 @@ In future new machine versions will not accept the opt= ion but it will still work with old machine types. User can check QAPI schema to see if the lega= cy option is supported by looking at MachineInfo::numa-mem-supported property. =20 +@subsection -numa node (without memory specified) (since 4.1) + +Splitting RAM by default between NUMA nodes has the same issues as @option= {mem} +parameter described above with the difference that the role of the user pl= ays +QEMU using implicit generic or board specific splitting rule. +Use @option{memdev} with @var{memory-backend-ram} backend or @option{mem} = (if +it's supported by used machine type) to define mapping explictly instead. + @section QEMU Machine Protocol (QMP) commands =20 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749578; cv=none; d=zoho.com; s=zohoarc; b=dOjgifKp6T0BiVYGdj+fcFHfdTa6/v1+kpa3h6dseiBUjFA90QIJ8Aao8eff+eoMAsy0ADG99JN0EmNmTFwxGuzalyxaPOkpeg3cmYYCX0mz5FHXUeUydcmKitjcQ+2lMrnMmm+s0OvKi6lmsr2ipb75uT6CLZjjSESYDOYac9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749578; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=d7aIUbRSUsyGEHIDedG33BCwpxnVEQYUi5TyjHs8bx8=; b=lB7bSNaDLrCGHispNMo/A5nlM9wAN+9nVTrMGa5SQpR46lkdGW7pxhJWgK7BUk+98k+DBeMXXBYTQ32U0WMU12kxmWBgRC03FKTyBwaozQvrkc29BZ2wqgKVarclGMHnYVq7zwNUvP3Q+cp5q6yD5sRIBiEJPKAuMHnYY0Eyik0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15617495787831014.5200920043425; Fri, 28 Jun 2019 12:19:38 -0700 (PDT) Received: from localhost ([::1]:35676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwOs-0006Iv-GM for importer@patchew.org; Fri, 28 Jun 2019 15:19:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40896) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvy0-0004b4-0Q for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvxx-0003zq-6m for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvxx-0003yz-18 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 546DA3086215; Fri, 28 Jun 2019 18:51:20 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD4AC1001284; Fri, 28 Jun 2019 18:50:55 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:32 -0300 Message-Id: <20190628184742.5961-20-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 28 Jun 2019 18:51:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 19/29] hppa: Delete unused hppa_cpu_list() function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" hppa_cpu_list() is dead code and is never called. Delete it. Cc: Richard Henderson Reviewed-by: Igor Mammedov Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Eduardo Habkost Message-Id: <20190517191332.23400-1-ehabkost@redhat.com> Acked-by: Richard Henderson Signed-off-by: Eduardo Habkost --- target/hppa/cpu.h | 2 -- target/hppa/cpu.c | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 2e1f2ac67c..aab251bc4b 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -241,8 +241,6 @@ void hppa_translate_init(void); =20 #define CPU_RESOLVING_TYPE TYPE_HPPA_CPU =20 -void hppa_cpu_list(void); - static inline target_ulong hppa_form_gva_psw(target_ureg psw, uint64_t spc, target_ureg off) { diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 368cb71e6d..71b6aca45d 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -111,23 +111,6 @@ static void hppa_cpu_realizefn(DeviceState *dev, Error= **errp) #endif } =20 -static void hppa_cpu_list_entry(gpointer data, gpointer user_data) -{ - ObjectClass *oc =3D data; - - qemu_printf(" %s\n", object_class_get_name(oc)); -} - -void hppa_cpu_list(void) -{ - GSList *list; - - list =3D object_class_get_list_sorted(TYPE_HPPA_CPU, false); - qemu_printf("Available CPUs:\n"); - g_slist_foreach(list, hppa_cpu_list_entry, NULL); - g_slist_free(list); -} - static void hppa_cpu_initfn(Object *obj) { CPUState *cs =3D CPU(obj); --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750356; cv=none; d=zoho.com; s=zohoarc; b=PadKql+9EXfp/Vx5365PElVsbMFyGBolCHuyQNTswdGCPnZDc36FWm67Gz2W5r4yA8ZkuyL12USqGqoOvTa9BzWsGqkUPnE72H0tOs00ZUol0kl97UrbeiiSaST4cLQGXSlVq8EUMkmYQThfosR0E4w2KR9/Cc3cOGFhREGNBMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750356; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=LByaWuEsXdBwxEnu19XEi/XO5aCj/66zNDea4gXshYY=; b=M/2/rIWATcamD6z6F19hxsGFJ/KTTBGll7V+Q7bw4aHYElixz7CZIXfVrc/v0A9ax0wqbcdV30FFmXgI7FawIKCoG3V470RvFRbMs+gCdv6nneSJ620ayfPQPMElzH3GKtElwFxNIVu8q3vPaoi/mDYQWBRFxbxZz/MfjUSGfTY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750356655287.25329982040114; Fri, 28 Jun 2019 12:32:36 -0700 (PDT) Received: from localhost ([::1]:35748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwbo-00071S-Sg for importer@patchew.org; Fri, 28 Jun 2019 15:32:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40922) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvy4-0004be-2X for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvy0-00042R-59 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32958) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvxz-00041n-V0 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1E15C30872C6; Fri, 28 Jun 2019 18:51:23 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E97A1001B05; Fri, 28 Jun 2019 18:51:22 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:33 -0300 Message-Id: <20190628184742.5961-21-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Jun 2019 18:51:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 20/29] target/i386: fix feature check in hyperv-stub.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Kagan , Igor Mammedov , Paolo Bonzini , Vitaly Kuznetsov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Alex Benn=C3=A9e Commit 2d384d7c8 broken the build when built with: configure --without-default-devices --disable-user The reason was the conversion of cpu->hyperv_synic to cpu->hyperv_synic_kvm_only although the rest of the patch introduces a feature checking mechanism. So I've fixed the KVM_EXIT_HYPERV_SYNIC in hyperv-stub to do the same feature check as in the real hyperv.c Signed-off-by: Alex Benn=C3=A9e Cc: Vitaly Kuznetsov Cc: Paolo Bonzini Cc: Roman Kagan Message-Id: <20190624123835.28869-1-alex.bennee@linaro.org> Reviewed-by: Vitaly Kuznetsov Acked-by: Paolo Bonzini Reviewed-by: Roman Kagan Signed-off-by: Eduardo Habkost --- target/i386/hyperv-stub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/hyperv-stub.c b/target/i386/hyperv-stub.c index fe548cbae2..0028527e79 100644 --- a/target/i386/hyperv-stub.c +++ b/target/i386/hyperv-stub.c @@ -15,7 +15,7 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exi= t *exit) { switch (exit->type) { case KVM_EXIT_HYPERV_SYNIC: - if (!cpu->hyperv_synic) { + if (!hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC)) { return -1; } =20 --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750703; cv=none; d=zoho.com; s=zohoarc; b=npfO/bCQZqEdRqI5JyqhoIvEMOlIGZq2XkOqmXzwvwm5EplVcsYt6xrY0ZlezQbm2isZqhgBXi4fLOCqUajNIaGGu1fZV02BWIloIEh+jKwZgKYPrkGwO3xosHXjH2bQ7WQjjGRxrTeOogoNKQXju0mn5cf6Uf+r0BDGmmgend8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750703; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yI0DTvgtqmTyz37XJ/DlFo/9KvXesh10dzx72zIrawk=; b=bcV1gjSbHwjtkuAkfUe7svYzzcjiIg6QyqxfdffKHBLjBS+3jTNR1OQv4bhUPwwOKBh6PO4GWmh+iCDCNbSomok+rpKzSfdoCYw/ZJWuuFlc8ROSBUUoU8TRqYkPJuVZ0el2WO8fAfnaBL71E8rMmqspraLHMl65z/vd3qJAHes= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750703954385.6303315917563; Fri, 28 Jun 2019 12:38:23 -0700 (PDT) Received: from localhost ([::1]:35810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwhA-0002Cc-Nw for importer@patchew.org; Fri, 28 Jun 2019 15:38:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40955) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyA-0004dt-VT for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvy8-00048R-5S for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvy7-00046D-Vi for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:32 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ED39B59440; Fri, 28 Jun 2019 18:51:28 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51B561001284; Fri, 28 Jun 2019 18:51:28 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:34 -0300 Message-Id: <20190628184742.5961-22-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 28 Jun 2019 18:51:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 21/29] deprecate -mem-path fallback to anonymous RAM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Igor Mammedov Fallback might affect guest or worse whole host performance or functionality if backing file were used to share guest RAM with another process. Patch deprecates fallback so that we could remove it in future and ensure that QEMU will provide expected behavior and fail if it can't use user provided backing file. Signed-off-by: Igor Mammedov Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster Message-Id: <20190626074228.11558-1-imammedo@redhat.com> Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Eduardo Habkost --- numa.c | 6 ++++-- qemu-deprecated.texi | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/numa.c b/numa.c index c1f5e84fa5..48fd43ecc6 100644 --- a/numa.c +++ b/numa.c @@ -495,8 +495,10 @@ static void allocate_system_memory_nonnuma(MemoryRegio= n *mr, Object *owner, if (mem_prealloc) { exit(1); } - error_report("falling back to regular RAM allocation."); - + warn_report("falling back to regular RAM allocation"); + error_printf("This is deprecated. Make sure that -mem-path " + " specified path has sufficient resources to allo= cate" + " -m specified RAM amount"); /* Legacy behavior: if allocation failed, fall back to * regular RAM allocation. */ diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 2fe9b72121..9cba82d5ec 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -112,6 +112,15 @@ QEMU using implicit generic or board specific splittin= g rule. Use @option{memdev} with @var{memory-backend-ram} backend or @option{mem} = (if it's supported by used machine type) to define mapping explictly instead. =20 +@subsection -mem-path fallback to RAM (since 4.1) +Currently if guest RAM allocation from file pointed by @option{mem-path} +fails, QEMU falls back to allocating from RAM, which might result +in unpredictable behavior since the backing file specified by the user +is ignored. In the future, users will be responsible for making sure +the backing storage specified with @option{-mem-path} can actually provide +the guest RAM configured with @option{-m} and QEMU will fail to start up if +RAM allocation is unsuccessful. + @section QEMU Machine Protocol (QMP) commands =20 @subsection block-dirty-bitmap-add "autoload" parameter (since 2.12.0) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749928; cv=none; d=zoho.com; s=zohoarc; b=jd1HnTfHG6hgFUdc93K3JN1MsIh7lNih+NMHCWJ55nPPiuPpvafyFIbKEVg4Z4+sT+ZvWUMACjN2taqsNJq8+d4nJgta/zCxqNd89Z38fMg62e7ztC1QMhoLRI6d8p+DKxLbE5exkfL0xVO1+Zy8AG4v9A0huogYb97TxCZ2jS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749928; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=1fGnZP58faChoodaUUwBVkRLQ8leibeUhTL8OJr674k=; b=Px8GE9PAS8Zs9SSecEy//56u/fnTHYg3Z0o4cGPxhT847kBDoPktlidt1O/qH9+p0scIkQtMTwivATdQs1cWd72PzE7mDHq+kZ/mrc57mluBoF2sbCFsL5WYoAFrmi+1hXYbIgeptZv4NLiyc1+cQjSoI2kkjUGjbhX/HKQEG2w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561749928254681.6078031713633; Fri, 28 Jun 2019 12:25:28 -0700 (PDT) Received: from localhost ([::1]:35704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwUY-00014F-20 for importer@patchew.org; Fri, 28 Jun 2019 15:25:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40976) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyF-0004fV-Nm for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyB-0004Ba-Sm for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyB-0004Ai-N9 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:51:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEDF92F8BE7; Fri, 28 Jun 2019 18:51:34 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F11960922; Fri, 28 Jun 2019 18:51:33 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:35 -0300 Message-Id: <20190628184742.5961-23-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 28 Jun 2019 18:51:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 22/29] i386: Don't print warning if phys-bits was set automatically X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If cpu->host_phys_bits_limit is set, QEMU will make cpu->phys_bits be lower than host_phys_bits on some cases. This triggers a warning that was supposed to be printed only if phys-bits was explicitly set in the command-line. Reorder the code so the value of cpu->phys_bits is validated before the cpu->host_phys_bits handling. This will avoid unexpected warnings when cpu->host_phys_bits_limit is set. Signed-off-by: Eduardo Habkost Message-Id: <20190611205420.20286-1-ehabkost@redhat.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3a38fe3633..390f47adc5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5293,15 +5293,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) uint32_t host_phys_bits =3D x86_host_phys_bits(); static bool warned; =20 - if (cpu->host_phys_bits) { - /* The user asked for us to use the host physical bits */ - cpu->phys_bits =3D host_phys_bits; - if (cpu->host_phys_bits_limit && - cpu->phys_bits > cpu->host_phys_bits_limit) { - cpu->phys_bits =3D cpu->host_phys_bits_limit; - } - } - /* Print a warning if the user set it to a value that's not the * host value. */ @@ -5313,6 +5304,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) warned =3D true; } =20 + if (cpu->host_phys_bits) { + /* The user asked for us to use the host physical bits */ + cpu->phys_bits =3D host_phys_bits; + if (cpu->host_phys_bits_limit && + cpu->phys_bits > cpu->host_phys_bits_limit) { + cpu->phys_bits =3D cpu->host_phys_bits_limit; + } + } + if (cpu->phys_bits && (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS || cpu->phys_bits < 32)) { --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561749918; cv=none; d=zoho.com; s=zohoarc; b=MmEG5VybgoqRmDyJDtKgDI83YEBwzr+d4xm99d4OjDnXntmxpyVW2G2TkHgIprs42qIQiBScd+k61BbQ1RHXBSfyIwbcqvbWhoPHUeugTdisUDTBLRuZbWAhVEP9Vt7gEgKAJGN+oNaFLzq2MHn5s/W9izZM/UmBn0BKfUTSteM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561749918; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/2dmmiix3uBeaMmcmyfkeX/nypbGH/M45N92tYntKa0=; b=jDJpuDO3Nj96B07F+TrBM+ikYmSntzknj3ZWPiGg66YzncwBXpWT8M5UTn0o3zJWZYfkjbwYIqsUZm0oULesEWP7L9ZtteOCx/k536t6jh5PR+DHJwbN4cqR/b1/0hy3RZy9ZNDmMgAqRhnbRJuKgsLI1XFQTtQ6eMjgcFDde9c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 15617499183391003.3639796153051; Fri, 28 Jun 2019 12:25:18 -0700 (PDT) Received: from localhost ([::1]:35706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwUf-0001Iy-8N for importer@patchew.org; Fri, 28 Jun 2019 15:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41230) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyy-0005Ps-8M for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyv-0005L7-Ni for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35768) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyv-0004xV-Fn for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85EF07CBA0; Fri, 28 Jun 2019 18:52:08 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E061B5D705; Fri, 28 Jun 2019 18:52:07 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:36 -0300 Message-Id: <20190628184742.5961-24-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 28 Jun 2019 18:52:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 23/29] i386: Fix signedness of hyperv_spinlock_attempts X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The current default value for hv-spinlocks is 0xFFFFFFFF (meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of 0xFFFFFFFF. Fix this by changing the type of X86CPU::hyperv_spinlock_attempts to uint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter. Signed-off-by: Eduardo Habkost Message-Id: <20190615200505.31348-1-ehabkost@redhat.com> Reviewed-by: Vitaly Kuznetsov Reviewed-by: Roman Kagan Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 4d2ae2384e..ff26351538 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1408,7 +1408,7 @@ struct X86CPU { CPUNegativeOffsetState neg; CPUX86State env; =20 - int hyperv_spinlock_attempts; + uint32_t hyperv_spinlock_attempts; char *hyperv_vendor_id; bool hyperv_synic_kvm_only; uint64_t hyperv_features; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561748669; cv=none; d=zoho.com; s=zohoarc; b=VMG3DCN3dksO2EhuMileDr6NLMIQ1ZUBLZToUlF+XtP27M7iHa+rCB274pza79txF6Eh314L412cdjH+zshF51BSWREYfVJB1eD/Yh9Rc4nfgOkgdQ8g2zPxsw31DW9ov53j12vdin9A0KU+wZDEyGrct4U17LgIhTJr7cjsn4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561748669; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=U5/xxJWrJPGt4jJ9rfgGktiEfBmuS121E54PN7UVUJ4=; b=Yfd+BQWKosQv6CIUejvl54p1ZD/3qEbnJZyClShqE7xJCUiWs5yiALdZD48Zzqn+cF13dpAgAz/v7Fuys4P9LK578+Hb4ATn1wThIL60eNDleFqW0jOUwtAywtKqjcc0FreBKytwGHuHQ7x4Zcvgijn6TscynsdgolhutvHYnVk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561748669277104.86319104826623; Fri, 28 Jun 2019 12:04:29 -0700 (PDT) Received: from localhost ([::1]:35582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwAT-0004lS-7o for importer@patchew.org; Fri, 28 Jun 2019 15:04:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41226) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyy-0005Pq-8A for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyv-0005KH-Gi for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyr-00050I-JW for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49F1130872F7; Fri, 28 Jun 2019 18:52:11 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A089B5C730; Fri, 28 Jun 2019 18:52:10 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:37 -0300 Message-Id: <20190628184742.5961-25-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 28 Jun 2019 18:52:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 24/29] i386: make 'hv-spinlocks' a regular uint32 property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Roman Kagan , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Roman Kagan X86CPU.hv-spinlocks is a uint32 property that has a special setter validating the value to be no less than 0xFFF and no bigger than UINT_MAX. The latter check is redundant; as for the former, there appears to be no reason to prohibit the user from setting it to a lower value. So nuke the dedicated getter/setter pair and convert 'hv-spinlocks' to a regular uint32 property. Signed-off-by: Roman Kagan Message-Id: <20190618110659.14744-1-rkagan@virtuozzo.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 45 ++------------------------------------------- 1 file changed, 2 insertions(+), 43 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 390f47adc5..8d5d34849c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3518,46 +3518,6 @@ static void x86_cpu_get_feature_words(Object *obj, V= isitor *v, visit_type_X86CPUFeatureWordInfoList(v, "feature-words", &list, errp); } =20 -static void x86_get_hv_spinlocks(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - X86CPU *cpu =3D X86_CPU(obj); - int64_t value =3D cpu->hyperv_spinlock_attempts; - - visit_type_int(v, name, &value, errp); -} - -static void x86_set_hv_spinlocks(Object *obj, Visitor *v, const char *name, - void *opaque, Error **errp) -{ - const int64_t min =3D 0xFFF; - const int64_t max =3D UINT_MAX; - X86CPU *cpu =3D X86_CPU(obj); - Error *err =3D NULL; - int64_t value; - - visit_type_int(v, name, &value, &err); - if (err) { - error_propagate(errp, err); - return; - } - - if (value < min || value > max) { - error_setg(errp, "Property %s.%s doesn't take value %" PRId64 - " (minimum: %" PRId64 ", maximum: %" PRId64 ")", - object_get_typename(obj), name ? name : "null", - value, min, max); - return; - } - cpu->hyperv_spinlock_attempts =3D value; -} - -static const PropertyInfo qdev_prop_spinlocks =3D { - .name =3D "int", - .get =3D x86_get_hv_spinlocks, - .set =3D x86_set_hv_spinlocks, -}; - /* Convert all '_' in a feature string option name to '-', to make feature * name conform to QOM property naming rule, which uses '-' instead of '_'. */ @@ -5682,8 +5642,6 @@ static void x86_cpu_initfn(Object *obj) object_property_add(obj, "crash-information", "GuestPanicInformation", x86_cpu_get_crash_info_qom, NULL, NULL, NULL, NULL= ); =20 - cpu->hyperv_spinlock_attempts =3D HYPERV_SPINLOCK_NEVER_RETRY; - for (w =3D 0; w < FEATURE_WORDS; w++) { int bitnr; =20 @@ -5880,7 +5838,8 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_INT32("node-id", X86CPU, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_BOOL("pmu", X86CPU, enable_pmu, false), =20 - { .name =3D "hv-spinlocks", .info =3D &qdev_prop_spinlocks }, + DEFINE_PROP_UINT32("hv-spinlocks", X86CPU, hyperv_spinlock_attempts, + HYPERV_SPINLOCK_NEVER_RETRY), DEFINE_PROP_BIT64("hv-relaxed", X86CPU, hyperv_features, HYPERV_FEAT_RELAXED, 0), DEFINE_PROP_BIT64("hv-vapic", X86CPU, hyperv_features, --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750096; cv=none; d=zoho.com; s=zohoarc; b=LhO4cUucXDcfqlSH2zxUtMuccK+3Cm1zdI5qVXUlCKzv20yTAvzTkKJuAeYcC8XXdSWWfUVT4ov6CqSdmHEB5iOgT6Js7pEAa39GQko9xvVGuhzhYWhi0lPtYYXHBVWBpFqNU1YpJEUmlolxOID8YfWgEDtAC9v8r3okSQmyWzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750096; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=k0vtqKbfyAuWdEX+PYMoNMU2eZvT7ppESpndtnaOM5Y=; b=HQHkMpZQDYBXuG8+pSAtBdZ5lVwqqiLGuQpN8i1qu18EXeYZru+ETD3dsbqQFcFId0VUO8lnEU7Pf9dcGRkw6LJvYvisxcQ5+Y2SG+3nHSNIS8uX7IfCpZVF5Xr+ukuCJdjzzodKPu3qYMFF8CgrUEJOPTWtieblLjCUnR0OZi8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156175009644199.946671794856; Fri, 28 Jun 2019 12:28:16 -0700 (PDT) Received: from localhost ([::1]:35728 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwXZ-0004Km-Hl for importer@patchew.org; Fri, 28 Jun 2019 15:28:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41241) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyy-0005QR-Md for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyv-0005Le-VD for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50040) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyv-0005BV-Nw for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC8BF369BC; Fri, 28 Jun 2019 18:52:18 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 499FB19C59; Fri, 28 Jun 2019 18:52:18 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:38 -0300 Message-Id: <20190628184742.5961-26-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 28 Jun 2019 18:52:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 25/29] x86/cpu: use FeatureWordArray to define filtered_features X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Wei Yang , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Wei Yang Use the same definition as features/user_features in CPUX86State. Signed-off-by: Wei Yang Message-Id: <20190620023746.9869-1-richardw.yang@linux.intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index ff26351538..85319f4ae1 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1440,7 +1440,7 @@ struct X86CPU { } mwait; =20 /* Features that were filtered out because of missing host capabilitie= s */ - uint32_t filtered_features[FEATURE_WORDS]; + FeatureWordArray filtered_features; =20 /* Enable PMU CPUID bits. This can't be enabled by default yet because * it doesn't have ABI stability guarantees, as it passes all PMU CPUID --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750871; cv=none; d=zoho.com; s=zohoarc; b=oQVYWryGP1TUciHIYSrV4yYQItesMj1UIPIa4Mls5h7mRdoDvQ/ua3DbYAGhBDqFKJaAVrfc2vEJC9tZsI7kcE9rHaLUV2YH9oDX7aYFQIMvVTippTt72L0rAS3CyWO5+6eS6HDRxtRq7nTqMbhjmCg1yYo0bZFhCfBB/swwnx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750871; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jHZ5kaijuY6gs7iAmI0xL0XN1zrOsKThmH1Ot4bg0Qk=; b=l01pGQeIbeu4tBNX1NbcyKPtVrADKoKpj9HRZ1QMfa2qiXChAAqt7rIi3DoGPHfXtLQCWa1u2eT+1VLnzg/YVtW/yLV65Qee8AzVQ5wF/XI+qctY6itDvPyB4vfCjNZanWzMd0lXruolEAiRUEaI01nfnBtsf/D8E6i/1l1WW2I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750871139967.1181530961678; Fri, 28 Jun 2019 12:41:11 -0700 (PDT) Received: from localhost ([::1]:35836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwk5-0005LP-ID for importer@patchew.org; Fri, 28 Jun 2019 15:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41242) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvyy-0005QU-MK for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyw-0005MH-51 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyv-0005Jj-Ui for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:22 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C64F81E0D; Fri, 28 Jun 2019 18:52:21 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id B69BA60920; Fri, 28 Jun 2019 18:52:20 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:39 -0300 Message-Id: <20190628184742.5961-27-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 28 Jun 2019 18:52:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 26/29] i386: Remove unused host_cpudef variable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The variable is completely unused, probably a leftover from previous code clean up. Signed-off-by: Eduardo Habkost Message-Id: <20190625050008.12789-3-ehabkost@redhat.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8d5d34849c..35ecb4113c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3134,14 +3134,8 @@ static void max_x86_cpu_initfn(Object *obj) char vendor[CPUID_VENDOR_SZ + 1] =3D { 0 }; char model_id[CPUID_MODEL_ID_SZ + 1] =3D { 0 }; int family, model, stepping; - X86CPUDefinition host_cpudef =3D { }; - uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; - - host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx); =20 host_vendor_fms(vendor, &family, &model, &stepping); - cpu_x86_fill_model_id(model_id); =20 object_property_set_str(OBJECT(cpu), vendor, "vendor", &error_abor= t); --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750348; cv=none; d=zoho.com; s=zohoarc; b=A5sTSVhXvDJf+mp5UrUC/JCpsALvblXmIClnG9knj/58HHLwmvM0CWguYga+oXz1fNiROjETBirU1j7IAgK+rnhC8VI8EPOOPKP8ZOXRflUVUtwnKnnOpOH0Q+0eEPMgoDaZxq5Aq5uTjV2TCDt0NT8LckgtfXcQdk2br3t37Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750348; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CrlutvsJvPCHpD7OCwr1kgTDnunhWS4PL+TJUito/D8=; b=RSdWs2WK6znVECC/XZyZHqiASIlbcOkU1f9magkyFtHJd8zxSrft6XZ8ikHTtHAgFB4kW91oFAhirzUm4NxfJdudheR8TGzkCa6+QyJ8y5vdvwom0JkS60WkEKDwSAmhjZiO/K71ktLMUgU+G9WotPbWuDjikgmqfTLvydhwH5k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 156175034869475.59603289222571; Fri, 28 Jun 2019 12:32:28 -0700 (PDT) Received: from localhost ([::1]:35746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwbV-0006tZ-F7 for importer@patchew.org; Fri, 28 Jun 2019 15:32:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41291) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvz1-0005W4-Iq for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvyy-0005Qk-M7 for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59190) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvyy-0005P2-9W for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 626583082131; Fri, 28 Jun 2019 18:52:23 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E344260BE0; Fri, 28 Jun 2019 18:52:22 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:40 -0300 Message-Id: <20190628184742.5961-28-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 28 Jun 2019 18:52:23 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 27/29] target/i386: Add CPUID.1F generation support for multi-dies PCMachine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu The CPUID.1F as Intel V2 Extended Topology Enumeration Leaf would be exposed if guests want to emulate multiple software-visible die within each package. Per Intel's SDM, the 0x1f is a superset of 0xb, thus they can be generated by almost same code as 0xb except die_offset setting. If the number of dies per package is greater than 1, the cpuid_min_level would be adjusted to 0x1f regardless of whether the host supports CPUID.1F. Likewise, the CPUID.1F wouldn't be exposed if env->nr_dies < 2. Suggested-by: Eduardo Habkost Signed-off-by: Like Xu Message-Id: <20190620054525.37188-2-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 1 + target/i386/cpu.c | 41 +++++++++++++++++++++++++++++++++++++++++ target/i386/kvm.c | 12 ++++++++++++ 3 files changed, 54 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 85319f4ae1..0a96c78669 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -736,6 +736,7 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_TOPOLOGY_LEVEL_INVALID (0U << 8) #define CPUID_TOPOLOGY_LEVEL_SMT (1U << 8) #define CPUID_TOPOLOGY_LEVEL_CORE (2U << 8) +#define CPUID_TOPOLOGY_LEVEL_DIE (5U << 8) =20 /* MSR Feature Bits */ #define MSR_ARCH_CAP_RDCL_NO (1U << 0) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 35ecb4113c..ea52db0600 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4413,6 +4413,42 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, *ecx |=3D CPUID_TOPOLOGY_LEVEL_INVALID; } =20 + assert(!(*eax & ~0x1f)); + *ebx &=3D 0xffff; /* The count doesn't need to be reliable. */ + break; + case 0x1F: + /* V2 Extended Topology Enumeration Leaf */ + if (env->nr_dies < 2) { + *eax =3D *ebx =3D *ecx =3D *edx =3D 0; + break; + } + + *ecx =3D count & 0xff; + *edx =3D cpu->apic_id; + switch (count) { + case 0: + *eax =3D apicid_core_offset(env->nr_dies, cs->nr_cores, + cs->nr_threads); + *ebx =3D cs->nr_threads; + *ecx |=3D CPUID_TOPOLOGY_LEVEL_SMT; + break; + case 1: + *eax =3D apicid_die_offset(env->nr_dies, cs->nr_cores, + cs->nr_threads); + *ebx =3D cs->nr_cores * cs->nr_threads; + *ecx |=3D CPUID_TOPOLOGY_LEVEL_CORE; + break; + case 2: + *eax =3D apicid_pkg_offset(env->nr_dies, cs->nr_cores, + cs->nr_threads); + *ebx =3D env->nr_dies * cs->nr_cores * cs->nr_threads; + *ecx |=3D CPUID_TOPOLOGY_LEVEL_DIE; + break; + default: + *eax =3D 0; + *ebx =3D 0; + *ecx |=3D CPUID_TOPOLOGY_LEVEL_INVALID; + } assert(!(*eax & ~0x1f)); *ebx &=3D 0xffff; /* The count doesn't need to be reliable. */ break; @@ -5094,6 +5130,11 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14); } =20 + /* CPU topology with multi-dies support requires CPUID[0x1F] */ + if (env->nr_dies > 1) { + x86_cpu_adjust_level(cpu, &env->cpuid_min_level, 0x1F); + } + /* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); diff --git a/target/i386/kvm.c b/target/i386/kvm.c index e4b4f5756a..473a17e9a5 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1451,6 +1451,10 @@ int kvm_arch_init_vcpu(CPUState *cs) } break; } + case 0x1f: + if (env->nr_dies < 2) { + break; + } case 4: case 0xb: case 0xd: @@ -1458,6 +1462,11 @@ int kvm_arch_init_vcpu(CPUState *cs) if (i =3D=3D 0xd && j =3D=3D 64) { break; } + + if (i =3D=3D 0x1f && j =3D=3D 64) { + break; + } + c->function =3D i; c->flags =3D KVM_CPUID_FLAG_SIGNIFCANT_INDEX; c->index =3D j; @@ -1469,6 +1478,9 @@ int kvm_arch_init_vcpu(CPUState *cs) if (i =3D=3D 0xb && !(c->ecx & 0xff00)) { break; } + if (i =3D=3D 0x1f && !(c->ecx & 0xff00)) { + break; + } if (i =3D=3D 0xd && c->eax =3D=3D 0) { continue; } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750089; cv=none; d=zoho.com; s=zohoarc; b=RYv5qJqOLzxUNmRRdv0sAmzwG11K0gc6fP9OB2RHoIQb4EYRSFis5/uP2C43/yNxdcICm+0NRQ9Oyp/gAs8XqmlGWFSDbHYBs093i1UcGWJ0UVnsi8v42rqJ5V5GkIhvDXHuzYsJD3BPcf1XsLBzCeeiFy5RUAp9QyIOi+IJ/3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750089; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ASNt4z2zUTC+tDaRAzd+3KtA1KLG/GjaDok71e/7hMk=; b=MuRtG4GBGKOHDrUDf9qSFJoKgKSPbEl0J2ZiOzTRZCNayn3JprTYk2NEDP7B67nN7p7GyrpcSGsVzp9xHu3ofMMDLQZwhlyQT6Pkz8joW8eXIxp5D10z+7SFJ7AKhzjdD1goRb7NI4+TXD02AIzOjYqpqybOmkY5nqvMMBbJ/Fg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750089951749.1124795242056; Fri, 28 Jun 2019 12:28:09 -0700 (PDT) Received: from localhost ([::1]:35726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwXS-00047E-V3 for importer@patchew.org; Fri, 28 Jun 2019 15:28:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41328) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvz5-0005aA-2i for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvz0-0005UC-Rv for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvz0-0005S1-Ds for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A152730C1CA2; Fri, 28 Jun 2019 18:52:25 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9CB35C21A; Fri, 28 Jun 2019 18:52:24 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:41 -0300 Message-Id: <20190628184742.5961-29-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 28 Jun 2019 18:52:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 28/29] machine: Refactor smp_parse() in vl.c as MachineClass::smp_parse() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu To make smp_parse() more flexible and expansive, a smp_parse function pointer is added to MachineClass that machine types could override. The generic smp_parse() code in vl.c is moved to hw/core/machine.c, and become the default implementation of MachineClass::smp_parse. A PC-specific function called pc_smp_parse() has been added to hw/i386/pc.c, which in this patch changes nothing against the default one . Suggested-by: Eduardo Habkost Signed-off-by: Like Xu Reviewed-by: Eduardo Habkost Message-Id: <20190620054525.37188-3-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- include/hw/boards.h | 5 +++ include/hw/i386/pc.h | 1 + hw/core/machine.c | 76 ++++++++++++++++++++++++++++++++++++++++++ hw/i386/pc.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ vl.c | 75 ++--------------------------------------- 5 files changed, 163 insertions(+), 73 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 47cba6ce6c..72b0e60176 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -161,6 +161,10 @@ typedef struct { * computed based on other criteria such as the host kernel capabilitie= s. * @numa_mem_supported: * true if '--numa node.mem' option is supported and false otherwise + * @smp_parse: + * The function pointer to hook different machine specific functions for + * parsing "smp-opts" from QemuOpts to MachineState::CpuTopology and mo= re + * machine specific topology fields, such as smp_dies for PCMachine. */ struct MachineClass { /*< private >*/ @@ -177,6 +181,7 @@ struct MachineClass { void (*reset)(MachineState *state); void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **err= p); int (*kvm_type)(MachineState *machine, const char *arg); + void (*smp_parse)(MachineState *ms, QemuOpts *opts); =20 BlockInterfaceType block_default_type; int units_per_default_bus; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 764996e6b4..ee79d71ccc 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -189,6 +189,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int l= evel); =20 void pc_cpus_init(PCMachineState *pcms); void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp); +void pc_smp_parse(MachineState *ms, QemuOpts *opts); =20 void pc_guest_info_init(PCMachineState *pcms); =20 diff --git a/hw/core/machine.c b/hw/core/machine.c index 7a44adab39..4be0599e82 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -11,6 +11,9 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/option.h" +#include "qapi/qmp/qerror.h" +#include "sysemu/replay.h" #include "qemu/units.h" #include "hw/boards.h" #include "qapi/error.h" @@ -725,6 +728,78 @@ void machine_set_cpu_numa_node(MachineState *machine, } } =20 +static void smp_parse(MachineState *ms, QemuOpts *opts) +{ + if (opts) { + unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); + unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); + unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + + /* compute missing values, prefer sockets over cores over threads = */ + if (cpus =3D=3D 0 || sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + cpus =3D cores * threads * sockets; + } else { + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D ms->smp.max_cpus / (cores * threads); + } + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D cpus / (sockets * threads); + cores =3D cores > 0 ? cores : 1; + } else if (threads =3D=3D 0) { + threads =3D cpus / (cores * sockets); + threads =3D threads > 0 ? threads : 1; + } else if (sockets * cores * threads < cpus) { + error_report("cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) < " + "smp_cpus (%u)", + sockets, cores, threads, cpus); + exit(1); + } + + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + + if (ms->smp.max_cpus < cpus) { + error_report("maxcpus must be equal to or greater than smp"); + exit(1); + } + + if (sockets * cores * threads > ms->smp.max_cpus) { + error_report("cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) > " + "maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + exit(1); + } + + if (sockets * cores * threads !=3D ms->smp.max_cpus) { + warn_report("Invalid CPU topology deprecated: " + "sockets (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + } + + ms->smp.cpus =3D cpus; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + } + + if (ms->smp.cpus > 1) { + Error *blocker =3D NULL; + error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); + replay_add_blocker(blocker); + } +} + static void machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -732,6 +807,7 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) /* Default 128 MB as guest ram size */ mc->default_ram_size =3D 128 * MiB; mc->rom_file_has_mr =3D true; + mc->smp_parse =3D smp_parse; =20 /* numa node memory size aligned on 8MB by default. * On Linux, each node's border has to be 8MB aligned diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 114fd5f8d4..b9c25bed35 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -79,6 +79,8 @@ #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" #include "standard-headers/asm-x86/bootparam.h" +#include "sysemu/replay.h" +#include "qapi/qmp/qerror.h" =20 /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -1537,6 +1539,82 @@ static void pc_new_cpu(PCMachineState *pcms, int64_t= apic_id, Error **errp) error_propagate(errp, local_err); } =20 +/* + * This function is very similar to smp_parse() + * in hw/core/machine.c but includes CPU die support. + */ +void pc_smp_parse(MachineState *ms, QemuOpts *opts) +{ + if (opts) { + unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); + unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); + unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); + + /* compute missing values, prefer sockets over cores over threads = */ + if (cpus =3D=3D 0 || sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + cpus =3D cores * threads * sockets; + } else { + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + sockets =3D ms->smp.max_cpus / (cores * threads); + } + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D cpus / (sockets * threads); + cores =3D cores > 0 ? cores : 1; + } else if (threads =3D=3D 0) { + threads =3D cpus / (cores * sockets); + threads =3D threads > 0 ? threads : 1; + } else if (sockets * cores * threads < cpus) { + error_report("cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) < " + "smp_cpus (%u)", + sockets, cores, threads, cpus); + exit(1); + } + + ms->smp.max_cpus =3D + qemu_opt_get_number(opts, "maxcpus", cpus); + + if (ms->smp.max_cpus < cpus) { + error_report("maxcpus must be equal to or greater than smp"); + exit(1); + } + + if (sockets * cores * threads > ms->smp.max_cpus) { + error_report("cpu topology: " + "sockets (%u) * cores (%u) * threads (%u) > " + "maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + exit(1); + } + + if (sockets * cores * threads !=3D ms->smp.max_cpus) { + warn_report("Invalid CPU topology deprecated: " + "sockets (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, cores, threads, + ms->smp.max_cpus); + } + + ms->smp.cpus =3D cpus; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + } + + if (ms->smp.cpus > 1) { + Error *blocker =3D NULL; + error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); + replay_add_blocker(blocker); + } +} + void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp) { int64_t apic_id =3D x86_cpu_apic_id_from_index(ms, id); @@ -2782,6 +2860,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; mc->hot_add_cpu =3D pc_hot_add_cpu; + mc->smp_parse =3D pc_smp_parse; mc->block_default_type =3D IF_IDE; mc->max_cpus =3D 255; mc->reset =3D pc_machine_reset; diff --git a/vl.c b/vl.c index 1729410e92..f6e591b80c 100644 --- a/vl.c +++ b/vl.c @@ -1247,78 +1247,6 @@ static QemuOptsList qemu_smp_opts =3D { }, }; =20 -static void smp_parse(QemuOpts *opts) -{ - if (opts) { - unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); - unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); - unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); - unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); - - /* compute missing values, prefer sockets over cores over threads = */ - if (cpus =3D=3D 0 || sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - if (cpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * sockets; - } else { - current_machine->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D current_machine->smp.max_cpus / (cores * threa= ds); - } - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * threads); - cores =3D cores > 0 ? cores : 1; - } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * sockets); - threads =3D threads > 0 ? threads : 1; - } else if (sockets * cores * threads < cpus) { - error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " - "smp_cpus (%u)", - sockets, cores, threads, cpus); - exit(1); - } - - current_machine->smp.max_cpus =3D - qemu_opt_get_number(opts, "maxcpus", cpus); - - if (current_machine->smp.max_cpus < cpus) { - error_report("maxcpus must be equal to or greater than smp"); - exit(1); - } - - if (sockets * cores * threads > current_machine->smp.max_cpus) { - error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) > " - "maxcpus (%u)", - sockets, cores, threads, - current_machine->smp.max_cpus); - exit(1); - } - - if (sockets * cores * threads !=3D current_machine->smp.max_cpus) { - warn_report("Invalid CPU topology deprecated: " - "sockets (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, cores, threads, - current_machine->smp.max_cpus); - } - - current_machine->smp.cpus =3D cpus; - current_machine->smp.cores =3D cores; - current_machine->smp.threads =3D threads; - } - - if (current_machine->smp.cpus > 1) { - Error *blocker =3D NULL; - error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp"); - replay_add_blocker(blocker); - } -} - static void realtime_init(void) { if (enable_mlock) { @@ -4060,7 +3988,8 @@ int main(int argc, char **argv, char **envp) current_machine->smp.cores =3D 1; current_machine->smp.threads =3D 1; =20 - smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); + machine_class->smp_parse(current_machine, + qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); =20 /* sanity-check smp_cpus and max_cpus against machine_class */ if (current_machine->smp.cpus < machine_class->min_cpus) { --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Fri May 10 05:48:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561750283; cv=none; d=zoho.com; s=zohoarc; b=BHs1wIO1WbxmvqmJv5GkVZyTGA+ilKXiCwR2mNwLsjJb5xfB9Nt6v6yRgaq+mYZL/lzhRdnqlqkziMxCCG1csvWvcekqNAH9la8ttSNM/QTx025wI53srRrLL3fmDS/oX8J+NEBrlJctnqESRSbJt6SMFW2+fxgip8ILxFjxnE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561750283; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4pP52NUwNOpFXfcbhbJI9/Oy9D9EVnxpV6oJhnGp2hM=; b=NcXyzL7rehTi+0rRY+LqBxe3ZLDbQSV+NohWqJ7VcdegXVeu/V924s5tQLx99c0k/XKhK9fQmFD+7uY3b7U62nEkLef9DAvZRG4R9ErHLQefVlkYsvp5971YgoNcN47jM/Y2XeK7Iv3xUzz/91hz1aIzPwNTUhDkqVzr0IQtZAU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561750283142747.625456274907; Fri, 28 Jun 2019 12:31:23 -0700 (PDT) Received: from localhost ([::1]:35744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgwaG-0006hq-0D for importer@patchew.org; Fri, 28 Jun 2019 15:30:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41345) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hgvz9-0005b9-9p for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hgvz2-0005X1-TJ for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38192) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hgvz2-0005Vc-HF for qemu-devel@nongnu.org; Fri, 28 Jun 2019 14:52:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB22B307D844; Fri, 28 Jun 2019 18:52:27 +0000 (UTC) Received: from localhost (ovpn-116-7.gru2.redhat.com [10.97.116.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38CC7600C6; Fri, 28 Jun 2019 18:52:27 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org, Marcel Apfelbaum Date: Fri, 28 Jun 2019 15:47:42 -0300 Message-Id: <20190628184742.5961-30-ehabkost@redhat.com> In-Reply-To: <20190628184742.5961-1-ehabkost@redhat.com> References: <20190628184742.5961-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Fri, 28 Jun 2019 18:52:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 29/29] vl.c: Add -smp, dies=* command line support and update doc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Igor Mammedov , Like Xu , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Like Xu For PC target, users could configure the number of dies per one package via command line with this patch, such as "-smp dies=3D2,cores=3D4". The parsing rules of new cpu-topology model obey the same restrictions/logic as the legacy socket/core/thread model especially on missing values computi= ng. Signed-off-by: Like Xu Message-Id: <20190620054525.37188-4-like.xu@linux.intel.com> Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 30 +++++++++++++++++------------- vl.c | 3 +++ qemu-options.hx | 17 +++++++++-------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b9c25bed35..3f0f221a5b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1545,9 +1545,12 @@ static void pc_new_cpu(PCMachineState *pcms, int64_t= apic_id, Error **errp) */ void pc_smp_parse(MachineState *ms, QemuOpts *opts) { + PCMachineState *pcms =3D PC_MACHINE(ms); + if (opts) { unsigned cpus =3D qemu_opt_get_number(opts, "cpus", 0); unsigned sockets =3D qemu_opt_get_number(opts, "sockets", 0); + unsigned dies =3D qemu_opt_get_number(opts, "dies", 1); unsigned cores =3D qemu_opt_get_number(opts, "cores", 0); unsigned threads =3D qemu_opt_get_number(opts, "threads", 0); =20 @@ -1557,24 +1560,24 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) threads =3D threads > 0 ? threads : 1; if (cpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * sockets; + cpus =3D cores * threads * dies * sockets; } else { ms->smp.max_cpus =3D qemu_opt_get_number(opts, "maxcpus", cpus); - sockets =3D ms->smp.max_cpus / (cores * threads); + sockets =3D ms->smp.max_cpus / (cores * threads * dies); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * threads); + cores =3D cpus / (sockets * dies * threads); cores =3D cores > 0 ? cores : 1; } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * sockets); + threads =3D cpus / (cores * dies * sockets); threads =3D threads > 0 ? threads : 1; - } else if (sockets * cores * threads < cpus) { + } else if (sockets * dies * cores * threads < cpus) { error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " + "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) < " "smp_cpus (%u)", - sockets, cores, threads, cpus); + sockets, dies, cores, threads, cpus); exit(1); } =20 @@ -1586,26 +1589,27 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) exit(1); } =20 - if (sockets * cores * threads > ms->smp.max_cpus) { + if (sockets * dies * cores * threads > ms->smp.max_cpus) { error_report("cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) > " + "sockets (%u) * dies (%u) * cores (%u) * threads = (%u) > " "maxcpus (%u)", - sockets, cores, threads, + sockets, dies, cores, threads, ms->smp.max_cpus); exit(1); } =20 - if (sockets * cores * threads !=3D ms->smp.max_cpus) { + if (sockets * dies * cores * threads !=3D ms->smp.max_cpus) { warn_report("Invalid CPU topology deprecated: " - "sockets (%u) * cores (%u) * threads (%u) " + "sockets (%u) * dies (%u) * cores (%u) * threads (= %u) " "!=3D maxcpus (%u)", - sockets, cores, threads, + sockets, dies, cores, threads, ms->smp.max_cpus); } =20 ms->smp.cpus =3D cpus; ms->smp.cores =3D cores; ms->smp.threads =3D threads; + pcms->smp_dies =3D dies; } =20 if (ms->smp.cpus > 1) { diff --git a/vl.c b/vl.c index f6e591b80c..23fe3e753b 100644 --- a/vl.c +++ b/vl.c @@ -1233,6 +1233,9 @@ static QemuOptsList qemu_smp_opts =3D { }, { .name =3D "sockets", .type =3D QEMU_OPT_NUMBER, + }, { + .name =3D "dies", + .type =3D QEMU_OPT_NUMBER, }, { .name =3D "cores", .type =3D QEMU_OPT_NUMBER, diff --git a/qemu-options.hx b/qemu-options.hx index 0d8beb4afd..a5b314a448 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -138,25 +138,26 @@ no incompatible TCG features have been enabled (e.g. = icount/replay). ETEXI =20 DEF("smp", HAS_ARG, QEMU_OPTION_smp, - "-smp [cpus=3D]n[,maxcpus=3Dcpus][,cores=3Dcores][,threads=3Dthreads][= ,sockets=3Dsockets]\n" + "-smp [cpus=3D]n[,maxcpus=3Dcpus][,cores=3Dcores][,threads=3Dthreads][= ,dies=3Ddies][,sockets=3Dsockets]\n" " set the number of CPUs to 'n' [default=3D1]\n" " maxcpus=3D maximum number of total cpus, including\n" " offline CPUs for hotplug, etc\n" - " cores=3D number of CPU cores on one socket\n" + " cores=3D number of CPU cores on one socket (for PC, i= t's on one die)\n" " threads=3D number of threads on one CPU core\n" + " dies=3D number of CPU dies on one socket (for PC only= )\n" " sockets=3D number of discrete sockets in the system\n= ", QEMU_ARCH_ALL) STEXI -@item -smp [cpus=3D]@var{n}[,cores=3D@var{cores}][,threads=3D@var{threads}= ][,sockets=3D@var{sockets}][,maxcpus=3D@var{maxcpus}] +@item -smp [cpus=3D]@var{n}[,cores=3D@var{cores}][,threads=3D@var{threads}= ][,dies=3Ddies][,sockets=3D@var{sockets}][,maxcpus=3D@var{maxcpus}] @findex -smp Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255 CPUs are supported. On Sparc32 target, Linux limits the number of usable C= PUs to 4. -For the PC target, the number of @var{cores} per socket, the number -of @var{threads} per cores and the total number of @var{sockets} can be -specified. Missing values will be computed. If any on the three values is -given, the total number of CPUs @var{n} can be omitted. @var{maxcpus} -specifies the maximum number of hotpluggable CPUs. +For the PC target, the number of @var{cores} per die, the number of @var{t= hreads} +per cores, the number of @var{dies} per packages and the total number of +@var{sockets} can be specified. Missing values will be computed. +If any on the three values is given, the total number of CPUs @var{n} can = be omitted. +@var{maxcpus} specifies the maximum number of hotpluggable CPUs. ETEXI =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, --=20 2.18.0.rc1.1.g3f1ff2140