From nobody Sat May 18 04:46:15 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=1562177413; cv=none; d=zoho.com; s=zohoarc; b=fCWhqmpSZ9vck0ZxB63XndeTO1PWbs1LSRVWafPfXprImgnPX47CK3qUvvgkx2GJxRWorMfrk6mO7Sn1nefJF7xS93ewnDuX9EwqMa0CUvS60+E7cNT/0tHeplZQFxljzLmO7rDQG7tg3D1dLRPYN61/oPRGyYGLmcYLtupN5po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177413; 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=Y/6bVxaJXfN8hOtIkRDjLtX7+CLHdxOBa2fXvFpr8m5W3x9Fuj3yZITD9TM/WdNnfIxM+OgtU6czawL1WdoWV+ABOLUwMNmz9E3/g1cTV7EffpV1BEavx+JLc2LY02Rn0mMQ7DHh5/pWmM3hLmBH/pj4ZexguWnUErOWIG0vyt8= 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 1562177413127292.94489720544357; Wed, 3 Jul 2019 11:10:13 -0700 (PDT) Received: from localhost ([::1]:38282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijhp-00066L-4P for importer@patchew.org; Wed, 03 Jul 2019 14:10:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56306) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfS-0004E9-Qm for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfQ-00009h-Ta for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54318) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfQ-00007g-9e for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:40 -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 9310630832F4; Wed, 3 Jul 2019 18:07:35 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 260DB1001DC0; Wed, 3 Jul 2019 18:07:34 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:44 -0300 Message-Id: <20190703180726.31267-2-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> 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.44]); Wed, 03 Jul 2019 18:07:35 +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 v4 01/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177527; cv=none; d=zoho.com; s=zohoarc; b=GJ5XLi6DE1yMB6vbskjHzCYd/dGy1eq4jKDcgWNyir6ZHgyQrEmxA3t/1T1vCgpD5rgT0TlTi6SddMPEZpRgJuqHC0bOIeOxeamyO+ciJieX57fsld8ogdN81fzikht8fFuoUqtAq0m4kN1MfI3sbSElM0MZo6j9c2nsSsUi2WQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177527; 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=Po3gi0VjZK0HKm1/j2gm3uQ723fcgjAhQswNOYOvv7Q=; b=OhJ1ceyIVM6wL2PFIc0CgcLqb6niR2c/7aUsQi7agr0PkEakeJiKMiVLWCDGCASu34kmaZUIK6FzZDtGkC/Y4q7f7RZxA7rFB9HUGfkH4pFbQUC3DV6tHaAADiRc+WSgTdRpjFDPlf2psp9u0FWxvcD5Ff2K8DDDVcNnO1ZBQrQ= 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 156217752776824.638751649033907; Wed, 3 Jul 2019 11:12:07 -0700 (PDT) Received: from localhost ([::1]:38304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijjh-0000nV-VK for importer@patchew.org; Wed, 03 Jul 2019 14:12:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56308) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfS-0004ED-RW for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfQ-00009W-Rg for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51580) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfP-00007j-2K for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:40 -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 D3F203086204; Wed, 3 Jul 2019 18:07:37 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E1F617DD0; Wed, 3 Jul 2019 18:07:36 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:45 -0300 Message-Id: <20190703180726.31267-3-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.42]); Wed, 03 Jul 2019 18:07:37 +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 v4 02/43] 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: Like Xu 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 ed009fa447..7b63a924a3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1345,7 +1345,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 b87e01e5b9..e364f79efd 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 Sat May 18 04:46:15 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=1562177416; cv=none; d=zoho.com; s=zohoarc; b=ib956a0woClwpRJ5kvl/zk93U6pyFanH9HchSz8xVqjeHb6f1OE5yudOBvRzLjmSr55EYyGBbL7An/lGlKqlvNeGnvDcWt4BsL4lTrUEvpOj0FVLxMVge9wxyLXixdyEdyG5FVyWMRv4kgAdJf2o/M4Ohku0VsDXxgh7jMrJoeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177416; 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=FHssyYWdUdnHAXYwguexL2qKgBdp30AfS+Qaxq5GGtd4ekS4EhACg4V/EngYc6XvGB9iwIrD1objkOEtt+x3KVA29hAGjdI+xl0NQ21S7P3Eswl2fQK1pdYMNhk6n76EptpxazYV5Ec4Qk/eM7i44MzaF6LTS63/YUkOYz0dR4M= 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 1562177416392382.5680818128428; Wed, 3 Jul 2019 11:10:16 -0700 (PDT) Received: from localhost ([::1]:38284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijhv-00069n-BS for importer@patchew.org; Wed, 03 Jul 2019 14:10:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56315) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfT-0004Eg-6w for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfR-00009s-39 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46486) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfQ-00008u-RF for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:41 -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 ECBD42F8BCD; Wed, 3 Jul 2019 18:07:39 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 751C7457C7; Wed, 3 Jul 2019 18:07:39 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:46 -0300 Message-Id: <20190703180726.31267-4-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.38]); Wed, 03 Jul 2019 18:07: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 v4 03/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177440; cv=none; d=zoho.com; s=zohoarc; b=TPBzpkjtljOnGGmbv2qlbMKMNi9vWtUANyOPXn2BBrZZr21hMDSEExotOUfi+alOa38Q7VnK7/sgfujuejiFthhALLfaQw1mMeHy82eqhGXffRN2CtfH8XCxQmS6jZHP4sLaQAvKuJVL55rJqVzk6YcSLLQDv6d1Dpn4K1J/qWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177440; 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=pjv+wLpP8N2PAJWwN0AnGpkpcjhKsCHnbWqg4QQ0cis=; b=bpXSQDCAJ65AcihztJbVvVHYwDdaEqbBTATU8DXa3Hxs4T941JggJWlSBrlIo/SyHN5os1gm9Hgky7CfprjsOuAJKfh/sHXMq1l9LIpouuXix3/VJ20vHRwtv9cyXlm/UVPQoL6pxnQauC15OkYkeTHJ4q+M4glE8JcPZ6sLgbY= 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 1562177440524975.9742830203463; Wed, 3 Jul 2019 11:10:40 -0700 (PDT) Received: from localhost ([::1]:38286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijiG-0006DC-4G for importer@patchew.org; Wed, 03 Jul 2019 14:10:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56343) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfV-0004HA-AW for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfT-0000BW-7f for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfS-0000Aa-Sw for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:43 -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 28329C049D67; Wed, 3 Jul 2019 18:07:42 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 76A8FBA9E; Wed, 3 Jul 2019 18:07:41 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:47 -0300 Message-Id: <20190703180726.31267-5-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.31]); Wed, 03 Jul 2019 18:07: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 v4 04/43] 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: Like Xu 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 c8d3245524..09bc6068f3 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 @@ -463,7 +464,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 da751addc4..9ffde5b6f7 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 e364f79efd..bd4531c822 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); @@ -1149,6 +1150,7 @@ static void pnv_chip_core_sanitize(PnvChip *chip, Err= or **errp) =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); @@ -1182,7 +1184,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 a248ce480d..ab3c1df1fc 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 Sat May 18 04:46:15 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=1562177861; cv=none; d=zoho.com; s=zohoarc; b=NtB/rbVV4hyd4qafKoVPerZ0eZAmN27gc2Hy29oSEHcbZWesLHGAZWlI/LkvefyvnJboqW79sSaqDw0ujaPC6N3Cch74XMaDX4olNdimWCG3KtG1La2V6WSCDCf8Myi+KUDGbbxudnMzM3CylgWfntvSweZOzcHne4fB+Zqo3Fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177861; 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=Wb+KCbsa+p1ashNrl5tVlBdv+ChG4Olw/eA2XCog0V0T/VQDhSrOrDm7Fd0llgmp73GmpHCqKAI9xDOzQBbYQg/6UZQ5F9YHgvfL1gx1Qvz7OKrxgo3prvsau2Gx8TpF5GvUxetNmSW7c1QIo7f3DmE2QLFvM7W79sl5+MVK+Ts= 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 1562177861827374.1841527724225; Wed, 3 Jul 2019 11:17:41 -0700 (PDT) Received: from localhost ([::1]:38334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijox-0004lY-PE for importer@patchew.org; Wed, 03 Jul 2019 14:17:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56368) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfX-0004Hm-BU for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfV-0000Ch-1w for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfU-0000CD-QN for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:44 -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 20ECC30B46F1; Wed, 3 Jul 2019 18:07:44 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A452A18249; Wed, 3 Jul 2019 18:07:43 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:48 -0300 Message-Id: <20190703180726.31267-6-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.46]); Wed, 03 Jul 2019 18:07:44 +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 v4 05/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177543; cv=none; d=zoho.com; s=zohoarc; b=P+u4u+izmi6h3fZle3/Rbl5ZUZribH3jFLGhDTYGCd9Hc6JP/KV4f4qf+KEIwsVP/yYLvw8fpawKMxYMN7vu62H87LtvqaMNqrX4s9GuYPePKIwjA98anjuJ3+gy66KGCeMBlkdK4UtJ5Tp9adowISTppjDOBpyOaH0oioWR4Jw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177543; 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=O77o7rGGWrBnOlq30WgFpdlbvgvjNgmbGB8WAy5/eMMSWOOQb8SL8CkonIy4wl82w5hiKY5tyav5gCeEvnpQ6x2nsf/nP1hBt0uYvQerPXNxBRgc37ogWzMGA4xe04x922ZjFGxLLXoSB0NH+gVpHxAymTTXUzaDruhcQxlokVE= 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 1562177543796801.0972556794453; Wed, 3 Jul 2019 11:12:23 -0700 (PDT) Received: from localhost ([::1]:38308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijjy-0001MQ-S8 for importer@patchew.org; Wed, 03 Jul 2019 14:12:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56391) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfd-0004Kz-AY for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfb-0000GY-Ai for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43130) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfZ-0000EH-8o for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:51 -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 17A76308FC4E; Wed, 3 Jul 2019 18:07:47 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 984108378F; Wed, 3 Jul 2019 18:07:45 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:49 -0300 Message-Id: <20190703180726.31267-7-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.43]); Wed, 03 Jul 2019 18:07:47 +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 v4 06/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177543; cv=none; d=zoho.com; s=zohoarc; b=h/d15YrVY+tv19UzGB3u+AoTsOUl6PWYg1uF4f/fGonLFchf1FHuOiiuDk6gdNZ/g28dhuDqnk9x6ZTnovGcWpQGQhOAcV8fwyW//lLCY/lf88hP5ENy8ssMb8NxoEfKwDD6asbQgOA3ut6wZh2px1gxdCvhjiGsPsOQ/HBmTvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177543; 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=8qwY8c0R2IK4NXHfXaKPb+TCimayQhbuiBM0ltdgN0o=; b=hioNPtzQoyK5Rk4eDJ6cQGgHGoqm2qh/w3+DDh5jQo44QCVTf2GA2NLlG4/0eEIfOsLsOBzU+6nzwnafODQy1Codpyv5OT8vITumHxtIAxFhai4cJIuDmdVaDZ8Q041rrjRQs57tfdnzHJEJZ8fu0M8P4Hol1VyZXEj0lD8frSg= 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 1562177543352962.5350530303239; Wed, 3 Jul 2019 11:12:23 -0700 (PDT) Received: from localhost ([::1]:38306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijjw-0001KA-Ur for importer@patchew.org; Wed, 03 Jul 2019 14:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56405) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfh-0004M7-6V for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfd-0000Hr-CG for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfb-0000FX-8P for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:53 -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 262B6308339E; Wed, 3 Jul 2019 18:07:49 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A865A58775; Wed, 3 Jul 2019 18:07:48 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:50 -0300 Message-Id: <20190703180726.31267-8-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.44]); Wed, 03 Jul 2019 18:07:49 +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 v4 07/43] 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: Like Xu 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 469f1260a4..e8e79e0917 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -756,6 +756,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 @@ -1383,6 +1385,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 Sat May 18 04:46:15 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=1562177892; cv=none; d=zoho.com; s=zohoarc; b=op3fnIAznXSyZ7C+I3ngBjMAH1lRZvGxptp3emwTGA3j5+y102ylgrqf7luvVbymNFctRqqiWvngC3zBRrNf/G/NOWX09VRmfEKe7dlieSCDd9Nv/ow/fPjWp5/PExLdkDaWKB71vaHmCF/INw86fevjXnF0jJthGGk69BBQfis= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177892; 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=oQzOIs0GDQ2GtxNhOjpk7Xb95brnv2bIvWS2euxNcPQ=; b=Kemg8ujFBh/6npFLJz0eBA3yOakT+2tyYwnYcLe/DQJLihXh/LcPKY6fMTsBI5EchVP7ilpTz1qI9acpXYrcoBn/xXjWfwdlN6VQdfC0Fg9jqOqDdJ0g5XdAEIpfPBqBrroVaXadPMm3oPx5p9FNy+ht+b/JJ38IzXlmvTXwj7g= 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 1562177892259585.2408519973472; Wed, 3 Jul 2019 11:18:12 -0700 (PDT) Received: from localhost ([::1]:38338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijpW-0005K1-81 for importer@patchew.org; Wed, 03 Jul 2019 14:18:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56434) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfl-0004Mm-VI for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfh-0000Jv-6r for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfd-0000Gg-AU for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:55 -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 468A785546; Wed, 3 Jul 2019 18:07:51 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9449618202; Wed, 3 Jul 2019 18:07:50 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:51 -0300 Message-Id: <20190703180726.31267-9-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.28]); Wed, 03 Jul 2019 18:07:51 +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 v4 08/43] 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: Like Xu 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> [ehabkost: Fix hw/arm/sbsa-ref.c and hw/arm/aspeed.c] Signed-off-by: Eduardo Habkost --- hw/arm/aspeed.c | 2 +- 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/sbsa-ref.c | 4 ++++ hw/arm/vexpress.c | 16 ++++++++++------ hw/arm/virt.c | 8 +++++++- hw/arm/xlnx-zynqmp.c | 16 ++++++++++------ target/arm/cpu.c | 8 +++++++- 15 files changed, 61 insertions(+), 24 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 8b6d304247..843b708247 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -187,7 +187,7 @@ static void aspeed_board_init(MachineState *machine, &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", &error_abort); - object_property_set_int(OBJECT(&bmc->soc), smp_cpus, "num-cpus", + object_property_set_int(OBJECT(&bmc->soc), machine->smp.cpus, "num-cpu= s", &error_abort); if (machine->kernel_filename) { /* 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 2eddf3f25c..119b281a50 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/sbsa-ref.c b/hw/arm/sbsa-ref.c index ee53f0ff60..e8c65e31c7 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -328,6 +328,7 @@ static void create_secure_ram(SBSAMachineState *sms, =20 static void create_gic(SBSAMachineState *sms, qemu_irq *pic) { + unsigned int smp_cpus =3D MACHINE(sms)->smp.cpus; DeviceState *gicdev; SysBusDevice *gicbusdev; const char *gictype; @@ -585,6 +586,8 @@ static void *sbsa_ref_dtb(const struct arm_boot_info *b= info, int *fdt_size) =20 static void sbsa_ref_init(MachineState *machine) { + unsigned int smp_cpus =3D machine->smp.cpus; + unsigned int max_cpus =3D machine->smp.max_cpus; SBSAMachineState *sms =3D SBSA_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(machine); MemoryRegion *sysmem =3D get_system_memory(); @@ -727,6 +730,7 @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineSta= te *sms, int idx) =20 static const CPUArchIdList *sbsa_ref_possible_cpu_arch_ids(MachineState *m= s) { + unsigned int max_cpus =3D ms->smp.max_cpus; SBSAMachineState *sms =3D SBSA_MACHINE(ms); int n; =20 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 7b63a924a3..20f191bc93 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -559,11 +559,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(); @@ -1039,13 +1041,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); @@ -1478,6 +1481,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= () @@ -1845,6 +1850,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 f21261c8ff..147e771ea1 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -31,6 +31,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" @@ -1587,6 +1588,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 @@ -2127,10 +2131,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 Sat May 18 04:46:15 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=1562178138; cv=none; d=zoho.com; s=zohoarc; b=MXRNOYgJcQkvZ1N/K7rgFzwc9D/x5w/eIP3rdyCEOyKIcT7vYa+b6cnkHa4b15lu+L9mj/9M+sA2tXfAIOXn2zUa9YCFSrTYVP/IZJJK1UAf4xh4q/4eJ/tka+sBMONWpFQqnh6d76lnxBWz+mdrSfeQv+GJaBmCB+9+V0jm7Vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178138; 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=L7CKhuLP9W+lYCZAKbGAWLGoWGBu+Ld9GaSeph90Lbwu12JBVIct6wSPtOqKgAX4YVzWjWVqrdp0Hq7jOdtzDSvy0TEg7jp6oLcvA8tUK8FUXpOuYwvIBZWJxzSmBEgi4mgXUzIXX+z7aITWl+JGwQB5oN5gFtHag24vAG+pZ4E= 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 1562178138320255.6202907183506; Wed, 3 Jul 2019 11:22:18 -0700 (PDT) Received: from localhost ([::1]:38360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijtZ-0001C1-C2 for importer@patchew.org; Wed, 03 Jul 2019 14:22:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56450) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfo-0004Mw-GX for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfl-0000Ly-2K for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfh-0000Hz-4k for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:07:59 -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 45C23C05167B; Wed, 3 Jul 2019 18:07:53 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C50478351A; Wed, 3 Jul 2019 18:07:52 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:52 -0300 Message-Id: <20190703180726.31267-10-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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]); Wed, 03 Jul 2019 18:07:53 +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 v4 09/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177551; cv=none; d=zoho.com; s=zohoarc; b=Kt5gb4zkX11Zv3TBb8xQ67BuvxgcoBo+BxhE9kXNW/H+961T/MTCddd/ZCpZGw47+aYYbhydnmsPRelI5XG1FLeWxJ6fUx3+lt2cAnHeRx/xPU50e0qH7INY5jRIJ+4+NnTTvJ1a3gyBQxBjeW87OBmEN0GeLoPizJ6OiO1rGqA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177551; 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=jgEmVTUxzdAbO9Up0C3AeeO/eqr25X2ctPh2w2nSBppzll8pbVptrqfzW4WMNqiVw6NvRYI0nhCU7aFvIcks2X2kQGNdbtZ8/6sgH9GJzFvvejmB0mE51Hdcg7jrGE2UX/9HGEp2KIrom5p8KZUlc84Ktv6Lrf3lFDz5zYbfbR8= 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 1562177551860820.6282515422104; Wed, 3 Jul 2019 11:12:31 -0700 (PDT) Received: from localhost ([::1]:38310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijk6-0001Q2-Rs for importer@patchew.org; Wed, 03 Jul 2019 14:12:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56452) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfo-0004My-HR for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfm-0000NE-M3 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43192) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfh-0000Io-5p for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:01 -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 32E68308FC4A; Wed, 3 Jul 2019 18:07:55 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB1F11001DC0; Wed, 3 Jul 2019 18:07:54 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:53 -0300 Message-Id: <20190703180726.31267-11-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> 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.43]); Wed, 03 Jul 2019 18:07:55 +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 v4 10/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562178487; cv=none; d=zoho.com; s=zohoarc; b=DfuldHvzX2ByAMqMZFWVPzswJcWooOZAoFv7opv+bwccyaOvlNBeMd+gwc4YBXHJ2wIlWnnos1Zj+glguL+bOHE/96zE1bpnz1+S2mYqW2LX7GCnDTFyIMWwBpGel96k4Nkfuxvi4lXvJt1+ogClm9Wupzv9b2fkZ6fRVnXUGsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178487; 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=jjneRXEuDwMI0jY4bYkNctJ2HhpoxblD9aIWGNou4/GFi+Y80JvUmpaTZjW9WvjszVREn630BuDFhor6BLaN5ZuBDbg0Leq42ya7G2EQJIuA3Xi4F5nHSKRnzZXkTDaUOm1A1eXiPX0WuCOepg27gyfMTvGPd9KZe13C/+Cee3U= 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 1562178487990995.469132089166; Wed, 3 Jul 2019 11:28:07 -0700 (PDT) Received: from localhost ([::1]:38396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijz9-0006Ju-Tw for importer@patchew.org; Wed, 03 Jul 2019 14:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56476) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfq-0004OF-G9 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfn-0000OC-S1 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37478) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfl-0000K4-1I for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:02 -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 262738762E; Wed, 3 Jul 2019 18:07:57 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC6A9BA9E; Wed, 3 Jul 2019 18:07:56 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:54 -0300 Message-Id: <20190703180726.31267-12-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.26]); Wed, 03 Jul 2019 18:07:57 +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 v4 11/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562177890; cv=none; d=zoho.com; s=zohoarc; b=f6lxGEMM56x0QGw5ltw1TItigtN5kpAFkw8Oo+uMJ6V9yRMx2I19RoXp7l0Ob/5O2VxaK32kSoY0dDgR+BpBIzsYxaFtzC0pURLL18dy2TJKnngL8jjlXaIK199LKv9c+Wviu/2DQme97HivKoIjBSIkhIPWgAGsNbNbaLASxxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177890; 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=m34t0FRqzkwugbY2ErywQqLCalcOg8I/e5Q4eCahSqLN1r5hGhrypSpA7bkujnlUh9+RuRwxvetz0t9FMbw3uJK9sGZZFOvs3t0Ohg6j0yBlMgu5b+7KGFvY9yvk32jnz3Jaf3ouOO17UOGwqKda2rabbaj4mSG1kmDtY47DqD8= 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 1562177890876601.9860267542706; Wed, 3 Jul 2019 11:18:10 -0700 (PDT) Received: from localhost ([::1]:38336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijpU-0005EO-TB for importer@patchew.org; Wed, 03 Jul 2019 14:18:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56477) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfq-0004OJ-Gi for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfo-0000Ok-IO for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9193) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfm-0000Kv-LX for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:03 -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 24C05307D848; Wed, 3 Jul 2019 18:07:59 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A77D4832BD; Wed, 3 Jul 2019 18:07:58 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:55 -0300 Message-Id: <20190703180726.31267-13-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.48]); Wed, 03 Jul 2019 18:07:59 +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 v4 12/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562178166; cv=none; d=zoho.com; s=zohoarc; b=RpwAXZ3M/TqjaA7ZXBEeanzIclXAscTKvs9cWUZz6wroqGatQPsXSBpObGG5E+N5tTj2brZPs2hmqqkPeOZWDARhlURsPi4Y/6r54gxwYYShwixAw+Wge0iDQEdgzaMcTOOT5vFb/O1QhfDA3W6Cw7kKGIm9ZVl2x+gUzgGpotQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178166; 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=deJs0ycxa78HREODB258uMIIBpDF+X9HS3SHs4g3SHo=; b=bwfrxl7sngzKY2FAf7gk1gEGWupFMSdaEgbjcUkGplSpd89+Em1lP6rpjRKutqPwQuCltmEVO9IR8bqp2mswCHpavXY67Gd8rOCRplOlkMde0U8vqk4UwX91PfE8uRgtemQABUkX1kaPwuQoPdTkyq7CodR/dp5rki5aXZFDdIo= 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 1562178166187794.8900385793244; Wed, 3 Jul 2019 11:22:46 -0700 (PDT) Received: from localhost ([::1]:38364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hiju1-0001m1-7m for importer@patchew.org; Wed, 03 Jul 2019 14:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56516) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfs-0004Oo-1a for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfq-0000QP-H6 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51722) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfo-0000Mg-JH for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -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 BE884308216C; Wed, 3 Jul 2019 18:08:01 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE3473795; Wed, 3 Jul 2019 18:08:00 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:56 -0300 Message-Id: <20190703180726.31267-14-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.42]); Wed, 03 Jul 2019 18:08:01 +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 v4 13/43] 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: Like Xu 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 9de35387c3..34abea0da9 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -3153,6 +3153,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 Sat May 18 04:46:15 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=1562178969; cv=none; d=zoho.com; s=zohoarc; b=nqoRMgva8iII535wosi+WFWDddr9x5Ukmx1vSefoowdRIrScUaZaPFv5YIAdg8Rcmuzu+fs+SsrEN7xGhVAQcJm+DPV9qAv4NvqubtSAsBABunCju6HsZV6YRS6l9vB0S3RiYSWdswoJ/2qnVcFuQ4vK7INBjoQdjsjFZ8QY4y8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178969; 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=ZDQlPEMhf859csqEF9CUrISVFnzy+/z4WkyHyyJjcaqV/GJmYaxPiaIkqFkRdKy3J/c16sUdy4PqlzUzfsUOidJpgrdO4s7hN8DYn2sVJHbx2MwfT591Th84I8gHdrw68n1G5r3biKm+FUNzyEXKqrpbEh2OkVAflb+TEM/sNUU= 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 1562178969258171.03804795647034; Wed, 3 Jul 2019 11:36:09 -0700 (PDT) Received: from localhost ([::1]:38456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik6y-0005Pr-6W for importer@patchew.org; Wed, 03 Jul 2019 14:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56527) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijft-0004PU-0N for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfq-0000Qi-OQ for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44258) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfq-0000OO-Fl for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -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 0A455308FEC0; Wed, 3 Jul 2019 18:08:04 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 596461001B27; Wed, 3 Jul 2019 18:08:03 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:57 -0300 Message-Id: <20190703180726.31267-15-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> 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.49]); Wed, 03 Jul 2019 18:08:04 +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 v4 14/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562178772; cv=none; d=zoho.com; s=zohoarc; b=KgRP7YJJ5BHKIazqcZQ0dC0yA6NAD69UA6cFoN0CXma1/q/369M7xBDP6yJFczgzpk009UlBSb+/m54ODhQ2bQrMMkEJmI61vIN0gKaSsfiIdhZIhaRMZ98DtvwSZC0OOIGcdRMmURpV0XXzZgsKRFBXkWSOPafda3gNp1fFjo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178772; 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=NsxgNNqiwKEclP7nPp1Hhu6MVvYtzzsvMa4Uv+f42snYpMlMS7zZbQLVX1UyP8Eu+jNXZ+e15kfTRlY/xkTIyv5EJtcIJo5Vov502cS5QJ6FseYLao+qhl454X9n0ssovQpc4Lc6Dk39tgoEvwq9J5P3HapVhxAmZ9NuXH8589o= 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 1562178772498847.9533236291169; Wed, 3 Jul 2019 11:32:52 -0700 (PDT) Received: from localhost ([::1]:38428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik3h-0001dW-Sj for importer@patchew.org; Wed, 03 Jul 2019 14:32:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56512) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfr-0004Om-SG for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfq-0000Qv-Va for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56990) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfq-0000Px-Q6 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:06 -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 19C513082AF2; Wed, 3 Jul 2019 18:08:06 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95C248351A; Wed, 3 Jul 2019 18:08:05 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:58 -0300 Message-Id: <20190703180726.31267-16-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.45]); Wed, 03 Jul 2019 18:08:06 +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 v4 15/43] 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: Igor Mammedov 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 Sat May 18 04:46:15 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=1562178441; cv=none; d=zoho.com; s=zohoarc; b=R2T+Y24lv6/WZbT1n/PLWNhWRKj/aULNHgafpKgJRH8Ts7o+gVuhhA0FoQJ2tkbJDgDILPu2JjV5le0ghkTv+2Ofu/wK1yZcDcksrCPYqP1vBnS4dn8UVI5ijyx4sLwuFPQWdUOxTcx9ECSRJae8kxRB9uQwSoUGmvGcVuvivlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178441; 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=ojTHsL0n2ZYilK0n5YlXE7ct4F+2rMmsu8SZhHfYttk=; b=TrfMbShuogeAYcSu0R1t+twBiGvLtx9la3BNuPcWTV+DJ/hzlmxmDuC8E04E3kCXIzNzpgMpqOEAzXXWTB+b6ZYWbz05fx7nlgI3PWRJWG8f//yysFbQmROWRxH1saBlNHaxl+wCk1DV4nmsj5PA4Qhmvvwokxc3MqXjlz54mjQ= 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 1562178441275122.91258110845797; Wed, 3 Jul 2019 11:27:21 -0700 (PDT) Received: from localhost ([::1]:38392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijyK-0005WR-9u for importer@patchew.org; Wed, 03 Jul 2019 14:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56546) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfv-0004Tp-I1 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfu-0000Ue-Af for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35946) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijft-0000ST-Dk for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:10 -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 B452EC058CA8; Wed, 3 Jul 2019 18:08:08 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BB551001F41; Wed, 3 Jul 2019 18:08:07 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:06:59 -0300 Message-Id: <20190703180726.31267-17-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> 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.32]); Wed, 03 Jul 2019 18:08: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 v4 16/43] 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: Igor Mammedov 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 20f191bc93..0b5138cb22 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1952,6 +1952,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 Sat May 18 04:46:15 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=1562178163; cv=none; d=zoho.com; s=zohoarc; b=iF248a0+j4DwjGDsvIOWDFic6XRfrrtEA47KbXUeEGqsniw8bxaQlPcifr5Vok4tbA2UupwS8gwQmp90fdFT26zQI0oHkaly5Pva6CRs5Mlf9dRwy0U0SuQacWvWfCRI1k9hMpmajP95dMJqKapSDn7RFrkX0Z+It6NaPNKHUMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178163; 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=FFE2o/SFYdgoE+jBI814KIf8ELZ2jZ3+20eOm/XXowfqYmg+1i/sEUmZGrwR9sHEA+B/qqa0S52jzX7N2C3zC4fxruwwbUuPZ7OrX90aee56+ccYKWe9UKjDKi3jr6lgGysSc81ayHIAaqq2YtfASHxyj6b7r88YJ/lbtJCoDtY= 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 1562178163866684.9808558342596; Wed, 3 Jul 2019 11:22:43 -0700 (PDT) Received: from localhost ([::1]:38362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijty-0001fh-Su for importer@patchew.org; Wed, 03 Jul 2019 14:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56563) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijfx-0004XW-4G for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfv-0000Vn-Ow for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35974) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfv-0000V7-HA for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:11 -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 D03E5C05566B; Wed, 3 Jul 2019 18:08:10 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 614CF17F37; Wed, 3 Jul 2019 18:08:10 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:00 -0300 Message-Id: <20190703180726.31267-18-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.32]); Wed, 03 Jul 2019 18:08:10 +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 v4 17/43] 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: Igor Mammedov 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 Sat May 18 04:46:15 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=1562179189; cv=none; d=zoho.com; s=zohoarc; b=USHe4i68oIeiwljndgKxx3kEeYaejL1MdVgy6yUPr5opVj90yJX+t7sBUAs6vRkQkfET01VwS5EcAM4MeD7S7pcsa5E2kl3NPiqaiAJvwMsFc/X9heJh/Q63Ue5O0cTvwxq+P/07EFGHtqMFQo7LFSdHRcIgfqJx2iioh+y63i8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179189; 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=danH0pxVySsruozet6BKdj9DLAEjMcpDu0DNKpIYv2og3s4ZGjy0bCnEzhh94HevNmmGz8hfAqbO49G2lEdWGBPN+CD67MGUVCwrJEMj+MTgGNhLDciCVfUcogqu1LfNvN2UcWJEnN4Qtj01VRR+VM6WVSVS2nVoXRroJMRYICM= 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 1562179189735390.04545197855896; Wed, 3 Jul 2019 11:39:49 -0700 (PDT) Received: from localhost ([::1]:38492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikAQ-0000Mb-MD for importer@patchew.org; Wed, 03 Jul 2019 14:39:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56574) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijg2-0004YG-0R for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijfx-0000Wz-SA for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52868) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijfx-0000WV-IA for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:13 -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 D1C5A356CD; Wed, 3 Jul 2019 18:08:12 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63BA9173B9; Wed, 3 Jul 2019 18:08:12 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:01 -0300 Message-Id: <20190703180726.31267-19-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.30]); Wed, 03 Jul 2019 18:08:12 +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 v4 18/43] 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: Igor Mammedov 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 Sat May 18 04:46:15 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=1562178641; cv=none; d=zoho.com; s=zohoarc; b=OCH2RW1Ej/TTNYIch9uxeDd0QmYenbS3RvoLk+kVuf9H2RSZTnHsJ68/Kbm4p3rnqlgjs4HO/eRogxQO3zaQtSK1JoRx37Ss4FIbCTCBsdWLzhU9d+csbtsiUcz/DjyrxrKh5F0qvnqcCa4AY7Vh6JXsY6li5aFLoaXtIl27a74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178641; h=Content-Type:Content-Transfer-Encoding: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=RcDnRM/RAY2A96wTprAxK/4jc1Z7uvLa5jlAnF5cYQTbAkCwYxjeIhJYNULznsCaX22mAglCjqaAqm5/FCJuekJWycGZx/c6eHDdC7LzpYByh2S/6Ez/GtS+ST1fMgLd+gKNkDYMAH/lACSQMAXc2fo8GU5OqpshpH0wnV+fDbE= 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 1562178641618470.45384558022783; Wed, 3 Jul 2019 11:30:41 -0700 (PDT) Received: from localhost ([::1]:38420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik1c-0000gT-BV for importer@patchew.org; Wed, 03 Jul 2019 14:30:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56585) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijg2-0004bv-Cr for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijg1-0000Yo-CI for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54610) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijg1-0000XZ-7A for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:17 -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 E3779308339E; Wed, 3 Jul 2019 18:08:14 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73D0F87C9; Wed, 3 Jul 2019 18:08:14 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:02 -0300 Message-Id: <20190703180726.31267-20-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.44]); Wed, 03 Jul 2019 18:08:14 +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 v4 19/43] 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: , 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 Sat May 18 04:46:15 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=1562178435; cv=none; d=zoho.com; s=zohoarc; b=VkRwwYLzIIEr4lt8pI2kllK2k2Jh4QwFXFNXAH0RAHhG/j/1LVdi4QL6euyAZnxUYdN3308XS5xVQndTTVQ7VI3+wYjn+ql1kml2GB49wNCQpRuCZgvQ6om+R2OiNu12WnGgfLTPciB67om5f5URm8FvhoEjBipXZ+efcmOi7GA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178435; 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=MgW4BrXZG6VG+5zTC7JhB7at5lb5FVhVF42SYibnXrbzlgvYKaNQyOKyegnt8XBP5Vkr0ECT2OzvuXjaerBF4G6PUwdJkG+12jlX5aZJqb6zvaOCmbC8LR6Pko3RAUmFk6v3WgXPnYkj9otgqrfLoHxTyREH+N3tBz9bRUps3iE= 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 1562178435764303.1048404838434; Wed, 3 Jul 2019 11:27:15 -0700 (PDT) Received: from localhost ([::1]:38390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijyH-0005NV-Pt for importer@patchew.org; Wed, 03 Jul 2019 14:27:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56592) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijg2-0004cz-Oi for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijg1-0000Z2-PY for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijg1-0000Ya-L3 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:17 -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 E573281F1B; Wed, 3 Jul 2019 18:08:16 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FB5C5877D; Wed, 3 Jul 2019 18:08:16 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:03 -0300 Message-Id: <20190703180726.31267-21-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Wed, 03 Jul 2019 18:08:17 +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 v4 20/43] 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: Vitaly Kuznetsov , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Roman Kagan 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 Sat May 18 04:46:15 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=1562178636; cv=none; d=zoho.com; s=zohoarc; b=bk7Zgmb5N95vPpSr/OY0wvDjvrSGjD97PIB+c7bEweoiUuMqyfhQoEEIVLW99/p5uvttKMu+nRftY9qYWfrWYvxAT6287D2JBV/7N8mYXSXrwkN9oWoBtLrWHT+m3yWkO15YVbrxQl3C5LjFwZUQllq6R/JzVbiYAkQjY5n3wYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178636; 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=PXlBANA9A+QIgCpZ08tl1bvBDlXpUVT+I1rL0FDOi1b9mc4MCB5iChlxeClLYPpPxRlpQO3V0huRO2YOMPIdsPGCsNM5/+av0d2Zo2K7m82+OJoZ7M4ZaDDfSar5TijcKW88U1Zx4Dln/1ynGmaDxFnF1kly4iHDMnj0BU4TH6o= 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 1562178636235169.9892050062565; Wed, 3 Jul 2019 11:30:36 -0700 (PDT) Received: from localhost ([::1]:38418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik1b-0000Zy-6L for importer@patchew.org; Wed, 03 Jul 2019 14:30:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56607) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijg5-0004hN-PL for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijg3-0000aY-TP for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijg3-0000a6-OT for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:19 -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 028663082200; Wed, 3 Jul 2019 18:08:19 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8824E58C94; Wed, 3 Jul 2019 18:08:18 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:04 -0300 Message-Id: <20190703180726.31267-22-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Wed, 03 Jul 2019 18:08:19 +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 v4 21/43] 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: Igor Mammedov 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 Sat May 18 04:46:15 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=1562179436; cv=none; d=zoho.com; s=zohoarc; b=FMgy/o3YFn0QLci/MW66+gHZ0KGrRy+wZmVQR/6QjnQV79bhLBxDH5npDMZBuKsQ5KkPOytHXJ/i2zseHoug93/mOatzaXpqYHkgirf2aEl+EuGz2aOu7Y8Gh5F+dyLIlYHWKi2zbjMSpeujsOIGSky9lKqerR1kSEH/GW35jes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179436; h=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=DOPSIgOJ70uHx8CjSxeYaOxrrALTmLVthgTlqBQTlWvd4ZiPuWF+lS5ZwE+ScFJjTks2nyE9Pztp95n+ERcjFaZ2IAsEuaLRcPO1xb6Onfa9Wc2gJwJEIG4YPDq9nNLnQNcgtIZACbVrpfljmJ5/ye434NUOqtFiyFPpXGIdx3Y= 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 1562179436043250.01713168806054; Wed, 3 Jul 2019 11:43:56 -0700 (PDT) Received: from localhost ([::1]:38516 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikEP-0004B4-L4 for importer@patchew.org; Wed, 03 Jul 2019 14:43:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56618) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijg7-0004hj-L5 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijg5-0000bf-TD for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43322) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijg5-0000bH-Ny for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08: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 EE51CC01F278; Wed, 3 Jul 2019 18:08:20 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FE9B1001DC0; Wed, 3 Jul 2019 18:08:20 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:05 -0300 Message-Id: <20190703180726.31267-23-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> 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.31]); Wed, 03 Jul 2019 18:08: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 v4 22/43] 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: , 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 Sat May 18 04:46:15 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=1562179727; cv=none; d=zoho.com; s=zohoarc; b=HC04UzNk8anomXfEBc61YthFjfbsUNhIMoqzPBmFYzKbjp+llI4Tw1B6dbaYITU30rQJasoM52Y00/A9L8LSZME/adS0RrRGvU+xHbnGvagImy5l/8/6FxwTNaJspfEYQbCN5G1xCNDMXeWw6IZ24tPkDltApXKD0oY33QgDq3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179727; h=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=bFK8cxWFP5+vHG1y8xdvjE/nbRv0tWWEiuJFvHSpyS0Xb0SE4hoDcAubW3NnQvk7UeQI41oiL4oP88MuSz+/J9KiPurg9SX6S2YTF0fE9QLJ3lfDFYpyFh26pl5EejZDSzFjQka/XOthJt6P4SKSvg8cUvicV4rfiYfdINqgODA= 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 1562179727501850.3275099233765; Wed, 3 Jul 2019 11:48:47 -0700 (PDT) Received: from localhost ([::1]:38544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikJ6-0000VT-8m for importer@patchew.org; Wed, 03 Jul 2019 14:48:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56641) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgD-0004jV-Dz for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgB-0000er-GR for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijg9-0000cK-Gm for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:27 -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 05F0230832C9; Wed, 3 Jul 2019 18:08:23 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8616491729; Wed, 3 Jul 2019 18:08:22 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:06 -0300 Message-Id: <20190703180726.31267-24-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.44]); Wed, 03 Jul 2019 18:08: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 v4 23/43] 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: , 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 Sat May 18 04:46:15 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=1562177892; cv=none; d=zoho.com; s=zohoarc; b=W5EmEdjIufh8u3Uyn7mLFRIln7Eve5IydldNvRoy/NeP44REVTfhrPraFGXAx1MrSzddHm91oEm0+Z+S4sDfSwRtpcm2katDYREPIftLudZJv0XEs2dsvyLAjyj0f0T9r/Za3a6IwA5t0LD5rfeoDWifMTVrRgaYD2mDV1e6C/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562177892; 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=kPep9XvaFBTKIa9TmBRivas0q36Z49loB40YdqGmzCILvAxDmHWc0aWOn9azOKjOhGR9gSpbcT/m39gYFE0N+GE+r5/xdlnRPaB1ePkPwwQDj+srJjdz555L/CWTJsw4LXpBntUVCkd66hL99Ns1bjpMU4YJ4OM4AuklINUoJq4= 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 1562177892929557.8788902586441; Wed, 3 Jul 2019 11:18:12 -0700 (PDT) Received: from localhost ([::1]:38340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijpW-0005M3-Uf for importer@patchew.org; Wed, 03 Jul 2019 14:18:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56660) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgI-0004kn-K2 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgD-0000fz-Cp for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45662) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgB-0000dR-Dn for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:28 -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 E02EF88307; Wed, 3 Jul 2019 18:08:24 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71B448351A; Wed, 3 Jul 2019 18:08:24 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:07 -0300 Message-Id: <20190703180726.31267-25-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.28]); Wed, 03 Jul 2019 18:08:24 +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 v4 24/43] 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: Roman Kagan 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 Sat May 18 04:46:15 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=1562180005; cv=none; d=zoho.com; s=zohoarc; b=RI+fkKDQU49jhUgCsuOPUKa8HS4ZNG/T2/jl418V66e1q86BZYllF8hqGOZ6t4w4rJjEhaKpaoWpKRxrcRuj+aFAHnduZTYJ+e6nvyFbMfUUpK2xcJ/zfKiMQec2n90lhP8/3h27Hhoi+FTeRvXst2EazvHZfEFsZxElP38I5zE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180005; 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=RhTaA/T1PcEeVJgBCKBLLP62e/Fi24sap7qglG4D4lTnie5SXzUWQcm+tH3ICNZtTWUOyE5LeLcJZe/KuaVQA/9e0+Z1OtwCJEhxuymvbODMvhKShpp0TZcNUlrKympAhIldURtfVkNjL4aY0Je8JdPU3dr4sZijBxKQj6XKbVg= 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 1562180005370593.5710003215377; Wed, 3 Jul 2019 11:53:25 -0700 (PDT) Received: from localhost ([::1]:38570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikNd-0004oU-6a for importer@patchew.org; Wed, 03 Jul 2019 14:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56659) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgI-0004km-Jz for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgD-0000gM-Gc for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgD-0000eS-AZ for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:29 -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 06A3481127; Wed, 3 Jul 2019 18:08:27 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A5DE832B6; Wed, 3 Jul 2019 18:08:26 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:08 -0300 Message-Id: <20190703180726.31267-26-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.27]); Wed, 03 Jul 2019 18:08: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 v4 25/43] 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: Wei Yang 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 Sat May 18 04:46:15 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=1562178936; cv=none; d=zoho.com; s=zohoarc; b=T2/DvGrsKi+v1m6LauZfOWtoLQ/2rHgp8L0YqsJ3bKhI0lNLAibFMCTcot8XAEP9I5bKaH7Nfkm8szjwncESuybtrxYh15YOs/lO9iWyYpUS+C8xXnTY9m0t//X7935IwWb5Bn4M0O94kDboOxvuVmXPgFYneG6JaDPHwKAiiiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178936; h=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=lqa50V6yK1oyxHYK0OVuNYEL8mG/A17m5Sqtbhg0ZPnFaKuiwXEUTUSuueOrNoO3ldIErt8wtby7OdlHJho5syhjrVtfAVEAmfX5RMPuSETmEAYlG0I0QYgrsD3N/L9ap+c1dBZxIvr200H8OGdUUHcjfyuJ+iH5V4x9neDM7Ug= 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 1562178936064328.47995085264654; Wed, 3 Jul 2019 11:35:36 -0700 (PDT) Received: from localhost ([::1]:38454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik6K-0004Mu-Pz for importer@patchew.org; Wed, 03 Jul 2019 14:35:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56686) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgO-0004mL-JE for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgL-0000kt-Vn for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgH-0000fj-4j for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:33 -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 E0D0D308FF23; Wed, 3 Jul 2019 18:08:28 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7239591729; Wed, 3 Jul 2019 18:08:28 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:09 -0300 Message-Id: <20190703180726.31267-27-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.49]); Wed, 03 Jul 2019 18:08:28 +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 v4 26/43] 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: , 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 Sat May 18 04:46:15 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=1562178936; cv=none; d=zoho.com; s=zohoarc; b=DYksFHA4Olzx0ZU7Dq2IddfUdGc1wfKpaG3loGHmu/qqxKtpH3TufOdzH+ODe221BL9hls9rCCrms54YI0TZrlnf0FC46KB2OXB4nky4AoHFiL3yync4Ym9hlty3j+NrNj1a2VtcDDufLQS7v3IqNdMagNfs/xu4aj/CLrxCSd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178936; 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=cJMOO86BfECpPXwfvZQ2IVl5UxrlUkbm97VMK88A1ePCBZD+ArkRxUsTUgOJNdw7xxBGEX1drbVvCWobdeB2JINWxdsf41QQtpTB4xH7LH9Nf3UVP0FWTM0uUtCCl56B87RP0jDz5s5a9ndWMG1i7Ii2Yf2wCVbHgVzN+QkAkOc= 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 1562178936210137.96712821564768; Wed, 3 Jul 2019 11:35:36 -0700 (PDT) Received: from localhost ([::1]:38452 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik6A-0004Kt-31 for importer@patchew.org; Wed, 03 Jul 2019 14:35:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56717) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgQ-0004pv-MG for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgO-0000mH-Kk for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgM-0000h8-M6 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:40 -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 E3B563092652; Wed, 3 Jul 2019 18:08:30 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F63A58775; Wed, 3 Jul 2019 18:08:30 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:10 -0300 Message-Id: <20190703180726.31267-28-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.43]); Wed, 03 Jul 2019 18:08:30 +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 v4 27/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562180249; cv=none; d=zoho.com; s=zohoarc; b=lEnvdjZ2jYrbfH8Ml5qibecFUAkPA5XLUCyc4vwFlzZ0ik8QeoyH1x81PhoW4JmJTn94WykkqMxmfcs+hrbuiDJcv2LHhWTBhjq4DJgShBi+k4h3b71z4YhgcgO/QzKTiaDUaet+7qx2Yq7d8RVZOgzsA6yXYLPdKEQQssDB6Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180249; 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=NSHlKZP/ErGXskJtNNnHleK4K6uW5+9TD/hlyLKSWnx6fTQNI5Ckx12CwtXSyy1ENenAk259XQU3gMzsrCd2qRNwHR3V4/q9CYhQt52W/ViJz5AnM0pdEHPaeriMrbSS1TqcTlxyBVCtdphmBUwJ0v6IvxTDu3mJxxadwXmQujk= 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 1562180249506225.74903863704253; Wed, 3 Jul 2019 11:57:29 -0700 (PDT) Received: from localhost ([::1]:38624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikRc-00024B-IQ for importer@patchew.org; Wed, 03 Jul 2019 14:57:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56756) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgS-0004sN-Oe for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgQ-0000nc-DN for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37762) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgO-0000iI-Jf for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:40 -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 0C1CD8E22B; Wed, 3 Jul 2019 18:08:33 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59FA217DD0; Wed, 3 Jul 2019 18:08:32 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:11 -0300 Message-Id: <20190703180726.31267-29-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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]); Wed, 03 Jul 2019 18:08:33 +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 v4 28/43] 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: Like Xu 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 Sat May 18 04:46:15 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=1562179028; cv=none; d=zoho.com; s=zohoarc; b=LM/ZOkLOHQlJLxFj1ftUEO4ZmpSRpD2I9Uuf9Ux5kdcON/YirzenA9O9o18MwJtpWHZe4cROGLqUpekg4Lu+p+/TGKVK/lQA7gn04h3Zl8AXn3hRnffGTifK93RkyBmRYIXQzFENDRuynswN67KQuUaJHZrSF/8fB3tiDzIdP0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179028; 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=dpspzqgElbXcARsTRGvP++rRJ/bBzsnU5feJGr3hakc=; b=f4PLQh66lk57Dot5tJ7HVu0TPS28Qxshj4fNQHnkZK0YvTNvoC7OM7mUca4IzEU7zWdkmyoKDXhqDhywnRbxBttaCNEqKo7h+xbLJht8888s8KKD72aUdo6itzW2TdExwzS2PQqCuxULR3iQ5NqQeJluiEVIslZDKNI2XK+OQ1c= 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 1562179028237632.9631934993369; Wed, 3 Jul 2019 11:37:08 -0700 (PDT) Received: from localhost ([::1]:38486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik7v-0007yX-AJ for importer@patchew.org; Wed, 03 Jul 2019 14:37:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56718) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgQ-0004py-ML for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgO-0000mN-LD for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52038) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgM-0000jU-On for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:40 -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 402D23082145; Wed, 3 Jul 2019 18:08:35 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C38711692C; Wed, 3 Jul 2019 18:08:34 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:12 -0300 Message-Id: <20190703180726.31267-30-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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]); Wed, 03 Jul 2019 18:08:35 +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 v4 29/43] 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: Like Xu 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 c18b79099a..e6d85d5fbd 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 From nobody Sat May 18 04:46:15 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=1562180119; cv=none; d=zoho.com; s=zohoarc; b=DWOg5HtON1fvp7EXIHlPVMJxUBwaTLr2qeRFsJi/nLoafFzW5xiSlNLngeRMIFm1Mn4hWJFddAARt/0uKxodQQ7OqaoNaY1R4XoKAy7ADgrbNGl/wc7S7/8pRqE+7X8ed8I7lF/RgQjlCqqmbJ8vC/Gx6tO41EsR3d8MV/PfCrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180119; h=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=InGV/ZrTse5J2qP6IPndRKz/mh55N448Q712MFGIAuE=; b=YY391XaTHaugkn0ijkByVlsrdHo4Ajy8BrbVA0Yjo7fkIPzPkRDfQLPBJejUbkcPmOWgnhc3RclblpoSHbaNnDqQVNQLgLajNuX4lb+GFq1dsF6OtqzIM3f6zgXTjpA7hfCcu4UXnLmIbz4cnbp03hcrsaosug5v9yvqQHc4+jI= 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 1562180119992573.5325057229667; Wed, 3 Jul 2019 11:55:19 -0700 (PDT) Received: from localhost ([::1]:38602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikPU-0007Nu-UR for importer@patchew.org; Wed, 03 Jul 2019 14:55:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56719) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgQ-0004pz-MP for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgO-0000mU-Qa for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47154) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgO-0000lK-K5 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:40 -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 A030130821FA; Wed, 3 Jul 2019 18:08:38 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC4B383789; Wed, 3 Jul 2019 18:08:36 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:13 -0300 Message-Id: <20190703180726.31267-31-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.47]); Wed, 03 Jul 2019 18:08:38 +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 v4 30/43] qmp: Add deprecation information to query-machines 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: , 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" Export machine type deprecation status through the query-machines QMP command. With this, libvirt and management software will be able to show this information to users and/or suggest changes to VM configuration to avoid deprecated machines. Signed-off-by: Eduardo Habkost Message-Id: <20190608233447.27970-2-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- qapi/misc.json | 7 ++++++- vl.c | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index ccd56c9191..733ffefa40 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -2017,12 +2017,17 @@ # @numa-mem-supported: true if '-numa node,mem' option is supported by # the machine type and false otherwise (since 4.1) # +# @deprecated: if true, the machine type is deprecated and may be removed +# in future versions of QEMU according to the QEMU deprecation +# policy (since 4.1.0) +# # Since: 1.2.0 ## { 'struct': 'MachineInfo', 'data': { 'name': 'str', '*alias': 'str', '*is-default': 'bool', 'cpu-max': 'int', - 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool'} } + 'hotpluggable-cpus': 'bool', 'numa-mem-supported': 'bool', + 'deprecated': 'bool' } } =20 ## # @query-machines: diff --git a/vl.c b/vl.c index 23fe3e753b..28cc6c4c93 100644 --- a/vl.c +++ b/vl.c @@ -1362,6 +1362,7 @@ MachineInfoList *qmp_query_machines(Error **errp) 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; + info->deprecated =3D !!mc->deprecation_reason; =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562179385; cv=none; d=zoho.com; s=zohoarc; b=Bk8/1zDPrdt101qsM/xSEtoSWUt8pCGPHR+4KI+62RX8N6Pk0gHltoBqbqTrYHrz8DXZBKCvYk4W7xrrtdqT0A6LYX0CLlgcmw+qCGTqjkPGehX6kvLK9N/fwE+3b9dXrSGN7CUxAPVxHrdHaXCuNdHOj4QUGNJmlmn2TL2UA+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179385; 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=7hGuhEwVEE++B5GNCgpIrkEyArdi2HOR2lp87MkMrY0=; b=RDprh+Xwhp23gMFP6E1UXTt/ViXg/2HVWHG0tkY0CUOawYmhGRRuOl4dxXnO/S4FofxQG8yfAfy/0Ytj1bla2VsMmd+vqr+/vEQ+qBv5A6mngiGKF/PNT1uM5E3u5nU9CmX2OpIEFBUr+M7Awfmhg/QF5vTUuvu8w7mk4Y+PGto= 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 1562179385060553.888559004398; Wed, 3 Jul 2019 11:43:05 -0700 (PDT) Received: from localhost ([::1]:38512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikDf-00039T-2m for importer@patchew.org; Wed, 03 Jul 2019 14:43:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56787) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgW-0004t8-3b for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgS-0000q3-OK for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgQ-0000md-Me for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:44 -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 A12F985538; Wed, 3 Jul 2019 18:08:40 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31ABC18248; Wed, 3 Jul 2019 18:08:40 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:14 -0300 Message-Id: <20190703180726.31267-32-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.28]); Wed, 03 Jul 2019 18:08: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 v4 31/43] i386: Introduce SnowRidge CPU model 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: Paul Lai 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: Paul Lai SnowRidge CPU supports Accelerator Infrastrcture Architecture (MOVDIRI, MOVDIR64B), CLDEMOTE and SPLIT_LOCK_DISABLE. MOVDIRI, MOVDIR64B, and CLDEMOTE are found via CPUID. The availability of SPLIT_LOCK_DISABLE is check via msr access References can be found in either: https://software.intel.com/en-us/articles/intel-sdm https://software.intel.com/en-us/download/intel-architecture-instruction-s= et-extensions-and-future-features-programming-reference Signed-off-by: Paul Lai Tested-by: Tao3 Xu Message-Id: <20190626162129.25345-1-paul.c.lai@intel.com> [ehabkost: squashed SPLIT_LOCK_DETECT patch] Message-Id: <20190626163232.25711-1-paul.c.lai@intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ea52db0600..6c04a258ed 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2688,6 +2688,77 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon Processor (Icelake)", }, + { + .name =3D "SnowRidge-Server", + .level =3D 27, + .vendor =3D CPUID_VENDOR_INTEL, + .family =3D 6, + .model =3D 134, + .stepping =3D 1, + .features[FEAT_1_EDX] =3D + /* missing: CPUID_PN CPUID_IA64 */ + /* missing: CPUID_DTS, CPUID_HT, CPUID_TM, CPUID_PBE */ + CPUID_FP87 | CPUID_VME | CPUID_DE | CPUID_PSE | + CPUID_TSC | CPUID_MSR | CPUID_PAE | CPUID_MCE | + CPUID_CX8 | CPUID_APIC | CPUID_SEP | + CPUID_MTRR | CPUID_PGE | CPUID_MCA | CPUID_CMOV | + CPUID_PAT | CPUID_PSE36 | CPUID_CLFLUSH | + CPUID_MMX | + CPUID_FXSR | CPUID_SSE | CPUID_SSE2, + .features[FEAT_1_ECX] =3D + CPUID_EXT_SSE3 | CPUID_EXT_PCLMULQDQ | CPUID_EXT_MONITOR | + CPUID_EXT_VMX | + CPUID_EXT_SSSE3 | + CPUID_EXT_CX16 | + CPUID_EXT_SSE41 | + CPUID_EXT_SSE42 | CPUID_EXT_X2APIC | CPUID_EXT_MOVBE | + CPUID_EXT_POPCNT | + CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_AES | CPUID_EXT_XSAVE= | + CPUID_EXT_RDRAND, + .features[FEAT_8000_0001_EDX] =3D + CPUID_EXT2_SYSCALL | + CPUID_EXT2_NX | + CPUID_EXT2_PDPE1GB | CPUID_EXT2_RDTSCP | + CPUID_EXT2_LM, + .features[FEAT_8000_0001_ECX] =3D + CPUID_EXT3_LAHF_LM | + CPUID_EXT3_3DNOWPREFETCH, + .features[FEAT_7_0_EBX] =3D + CPUID_7_0_EBX_FSGSBASE | + CPUID_7_0_EBX_SMEP | + CPUID_7_0_EBX_ERMS | + CPUID_7_0_EBX_MPX | /* missing bits 13, 15 */ + CPUID_7_0_EBX_RDSEED | + CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT | + CPUID_7_0_EBX_CLWB | + CPUID_7_0_EBX_SHA_NI, + .features[FEAT_7_0_ECX] =3D + CPUID_7_0_ECX_UMIP | + /* missing bit 5 */ + CPUID_7_0_ECX_GFNI | + CPUID_7_0_ECX_MOVDIRI | CPUID_7_0_ECX_CLDEMOTE | + CPUID_7_0_ECX_MOVDIR64B, + .features[FEAT_7_0_EDX] =3D + CPUID_7_0_EDX_SPEC_CTRL | + CPUID_7_0_EDX_ARCH_CAPABILITIES | CPUID_7_0_EDX_SPEC_CTRL_SSBD= | + CPUID_7_0_EDX_CORE_CAPABILITY, + .features[FEAT_CORE_CAPABILITY] =3D + MSR_CORE_CAP_SPLIT_LOCK_DETECT, + /* + * Missing: XSAVES (not supported by some Linux versions, + * including v4.1 to v4.12). + * KVM doesn't yet expose any XSAVES state save component, + * and the only one defined in Skylake (processor tracing) + * probably will block migration anyway. + */ + .features[FEAT_XSAVE] =3D + CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | + CPUID_XSAVE_XGETBV1, + .features[FEAT_6_EAX] =3D + CPUID_6_EAX_ARAT, + .xlevel =3D 0x80000008, + .model_id =3D "Intel Atom Processor (SnowRidge)", + }, { .name =3D "KnightsMill", .level =3D 0xd, --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562180320; cv=none; d=zoho.com; s=zohoarc; b=KU7SI9BVpT6wbIkcYDNGKW93tv3L7yb+dNaa/D+rrxcqI2BbhttCuDrGIn7LggnQ7VWelvphp0MWgzunsscbGnKOAq6CXdazia8H+PqQDNqq4fJQw9+5ruvgYVi2yAm9pvUeRU2EgdWz1RboXz9Nqrf7XdmokH7ng57bMc0gGak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180320; h=Content-Type:Content-Transfer-Encoding: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=OtUxMHXDESN4TA1qVleBBEuo43k/oHj9jhenuiGXzLs=; b=IcC7xz6g8bdEW5rD5KAhCmqlGPacDQ/TDdAcUBgzlNxoNKEeuga1lM2ZiuXzxXHGiTBuPYjEuIwtGdfwSBJZp4RfCQ9htsJAeIhYg6QkMVTo1grZjtLtoaGViBBAN8qp/vmFk1C4x3PTZ1uFi3jmyvT3Cs6vUTGGU17oogjIIyc= 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 156218032081878.24296305480038; Wed, 3 Jul 2019 11:58:40 -0700 (PDT) Received: from localhost ([::1]:38642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikSl-00038e-TX for importer@patchew.org; Wed, 03 Jul 2019 14:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56812) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgY-0004u9-2b for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgV-0000s6-EL for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37808) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgS-0000oS-NO for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:46 -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 B624D85A04; Wed, 3 Jul 2019 18:08:42 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4586D18248; Wed, 3 Jul 2019 18:08:42 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:15 -0300 Message-Id: <20190703180726.31267-33-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Wed, 03 Jul 2019 18:08:42 +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 v4 32/43] qmp: Add "alias-of" field to query-cpu-definitions 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Management software will be expected to resolve CPU model name aliases using the new field. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-2-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- qapi/target.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/qapi/target.json b/qapi/target.json index 1d4d54b600..0197c7962c 100644 --- a/qapi/target.json +++ b/qapi/target.json @@ -475,6 +475,12 @@ # to introspect properties configurable using -cpu or -global. # (since 2.9) # +# @alias-of: Name of CPU model this model is an alias for. The target of = the +# CPU model alias may change depending on the machine type. +# Management software is supposed to translate CPU model aliases +# in the VM configuration, because aliases may stop being +# migration-safe in the future (since 4.1) +# # @unavailable-features is a list of QOM property names that # represent CPU model attributes that prevent the CPU from running. # If the QOM property is read-only, that means there's no known @@ -498,7 +504,8 @@ '*migration-safe': 'bool', 'static': 'bool', '*unavailable-features': [ 'str' ], - 'typename': 'str' }, + 'typename': 'str', + '*alias-of' : 'str' }, 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386= ) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } =20 ## --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562179242; cv=none; d=zoho.com; s=zohoarc; b=ciBq4E3CTCNs5DXVycDMOOA7vgeAEugJ7r+uVa5GW0iZcAjQhqqQavSdqLZanYgiSXm9ff/Y/tYRResn90bzpuuOYnkV8V0bMc5F2Nz6I9dt6ZC01trP2Qckw8oGxlkUQw+P+3+GytEhnPrw2Wl7d41uivklcZXq8EOAG6cE/OU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179242; h=Content-Type:Content-Transfer-Encoding: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=gRIvRmCw4+HU5YLCZ12XDjz+iuqbeJUIa7IYQA+/1+c=; b=eBdcAGYLyfJ/k7jXYK7GB8k9D7NOOpKMP4WNQhvdNFqbMmGwff4YnX6nU/lq+FHJM9gZfRTdsePXzcP13GT8lQKmCQlURritKh05xBCs4ywF/JJnqhaHhgGz83UkBqeLqgJ3347y8Q9cL4vcyIC0VrFo1SunMVhjZz+xH887y/4= 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 1562179242731456.37295978179475; Wed, 3 Jul 2019 11:40:42 -0700 (PDT) Received: from localhost ([::1]:38496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikBJ-0000o5-KD for importer@patchew.org; Wed, 03 Jul 2019 14:40:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56814) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgY-0004uB-31 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgW-0000sv-8d for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgW-0000qL-2R for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:48 -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 E50EF30860A2; Wed, 3 Jul 2019 18:08:44 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B47817DD0; Wed, 3 Jul 2019 18:08:44 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:16 -0300 Message-Id: <20190703180726.31267-34-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.44]); Wed, 03 Jul 2019 18:08:44 +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 v4 33/43] i386: Add x-force-features option for testing 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add a new option that can be used to disable feature flag filtering. This will allow CPU model compatibility test cases to work without host hardware dependencies. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-3-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 6 ++++++ target/i386/cpu.c | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0a96c78669..4727226a6a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1417,6 +1417,12 @@ struct X86CPU { =20 bool check_cpuid; bool enforce_cpuid; + /* + * Force features to be enabled even if the host doesn't support them. + * This is dangerous and should be done only for testing CPUID + * compatibility. + */ + bool force_features; bool expose_kvm; bool expose_tcg; bool migratable; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6c04a258ed..9059121273 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5250,8 +5250,11 @@ static int x86_cpu_filter_features(X86CPU *cpu) uint32_t host_feat =3D x86_cpu_get_supported_feature_word(w, false); uint32_t requested_features =3D env->features[w]; - env->features[w] &=3D host_feat; - cpu->filtered_features[w] =3D requested_features & ~env->features[= w]; + uint32_t available_features =3D requested_features & host_feat; + if (!cpu->force_features) { + env->features[w] =3D available_features; + } + cpu->filtered_features[w] =3D requested_features & ~available_feat= ures; if (cpu->filtered_features[w]) { rv =3D 1; } @@ -5980,6 +5983,7 @@ static Property x86_cpu_properties[] =3D { =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), + DEFINE_PROP_BOOL("x-force-features", X86CPU, force_features, false), DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true), DEFINE_PROP_UINT32("phys-bits", X86CPU, phys_bits, 0), DEFINE_PROP_BOOL("host-phys-bits", X86CPU, host_phys_bits, false), --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562180402; cv=none; d=zoho.com; s=zohoarc; b=gvQxdOp8T4n0o/Zs/tHH9ZUCjs/7T6aTIloYcS/zRPyrkVc86JQx2WxVTYdEH4jZZF8r+qe8hohplWjODVHnegfqb3tyFKm8RJL6NdEzcfdBYwtiWowqORMddNgsvXb7+wFS+p7xldDlEBPzttPvhacfPABDDlHicSyKLJKjP3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180402; h=Content-Type:Content-Transfer-Encoding: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=K/rbE0AuDj5xddp69LbLZPHdAlL6rEdXaEGnrT0InHo=; b=E6w1YeFPDll+9jP5hoBb2V84NgbLpWIxIod09GZIz/fY4Pbyf+vdn7q9fzHc5rHcQIoWY9lTQs31/W3QBCrjdSOCLTph6RLTSCEdshL2DmhEQxTAgta61XluqjP0XA8Gqt2Bua8N+/sOMeUsn+eIt05hhGk2zMTZieFIlC+UdCk= 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 1562180402040803.2312790529994; Wed, 3 Jul 2019 12:00:02 -0700 (PDT) Received: from localhost ([::1]:38652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikTr-0004oE-DX for importer@patchew.org; Wed, 03 Jul 2019 14:59:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56813) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgY-0004uA-31 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgW-0000sq-87 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44632) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgW-0000rj-1j for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:48 -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 0343630BC57D; Wed, 3 Jul 2019 18:08:47 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 873AB457C7; Wed, 3 Jul 2019 18:08:46 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:17 -0300 Message-Id: <20190703180726.31267-35-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.49]); Wed, 03 Jul 2019 18:08:47 +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 v4 34/43] i386: Get model-id from CPU object on "-cpu help" 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When introducing versioned CPU models, the string at X86CPUDefinition::model_id might not be the model-id we'll really use. Instantiate a CPU object and check the model-id property on "-cpu help" Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-4-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9059121273..955ea20d69 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3837,18 +3837,28 @@ static GSList *get_sorted_cpu_model_list(void) return list; } =20 +static char *x86_cpu_class_get_model_id(X86CPUClass *xc) +{ + Object *obj =3D object_new(object_class_get_name(OBJECT_CLASS(xc))); + char *r =3D object_property_get_str(obj, "model-id", &error_abort); + object_unref(obj); + return r; +} + static void x86_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; X86CPUClass *cc =3D X86_CPU_CLASS(oc); char *name =3D x86_cpu_class_get_model_name(cc); - const char *desc =3D cc->model_description; - if (!desc && cc->cpu_def) { - desc =3D cc->cpu_def->model_id; + char *desc =3D g_strdup(cc->model_description); + + if (!desc) { + desc =3D x86_cpu_class_get_model_id(cc); } =20 qemu_printf("x86 %-20s %-48s\n", name, desc); g_free(name); + g_free(desc); } =20 /* list available CPU models and flags */ --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562178167; cv=none; d=zoho.com; s=zohoarc; b=Cw4ZXOIBxsDpBLQDSmpuQxgmRck79nlswclOjYZeM1sSqbcM2px1pMzG7PRYTRH8IrpZx0ImwquphxqypO9EgvQRfkt2N7Ry5QnzENxuNjV4i3xvKkJKRBoR2tYFBFvzoKyoawetlgj0Et87LMvbEAdYvZCX/jPyYS9kVkYvV7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178167; h=Content-Type:Content-Transfer-Encoding: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=ceZTxms1CxNAVkGgFDctYdnrbioHQC1s5GuEz79NwoA=; b=YrC8QEbw8JB35VAW9uPr1U+t4KGBJ12VsRMRJv8UZ1X2+IBWeLmfVcqftNd3DGl7FdXBMYo/7QzseZA7nTs5a14W6++rI9wvtlziKEhgsk5rUJyeXTgO+88tC8VigNaU6PTePRegStxjIY4otHgFxnZuKll2J0v6Ynxk6C+jEpQ= 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 1562178167760694.847841202629; Wed, 3 Jul 2019 11:22:47 -0700 (PDT) Received: from localhost ([::1]:38366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hiju2-0001oO-OA for importer@patchew.org; Wed, 03 Jul 2019 14:22:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56843) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgb-0004xq-3z for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgY-0000uY-FR for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgY-0000tl-0z for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:50 -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 53B603082200; Wed, 3 Jul 2019 18:08:49 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 763C31001DC3; Wed, 3 Jul 2019 18:08:48 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:18 -0300 Message-Id: <20190703180726.31267-36-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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]); Wed, 03 Jul 2019 18:08:49 +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 v4 35/43] i386: Register versioned CPU models 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add support for registration of multiple versions of CPU models. The existing CPU models will be registered with a "-v1" suffix. The -noTSX, -IBRS, and -IBPB CPU model variants will become versions of the original models in a separate patch, so make sure we register no versions for them. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-5-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu-qom.h | 10 +- target/i386/cpu.h | 10 + target/i386/cpu.c | 223 +++++++++++++++++++-- tests/acceptance/x86_cpu_model_versions.py | 105 ++++++++++ 4 files changed, 318 insertions(+), 30 deletions(-) create mode 100644 tests/acceptance/x86_cpu_model_versions.py diff --git a/target/i386/cpu-qom.h b/target/i386/cpu-qom.h index 22f95eb3a4..1a52f02a4c 100644 --- a/target/i386/cpu-qom.h +++ b/target/i386/cpu-qom.h @@ -36,13 +36,7 @@ #define X86_CPU_GET_CLASS(obj) \ OBJECT_GET_CLASS(X86CPUClass, (obj), TYPE_X86_CPU) =20 -/** - * X86CPUDefinition: - * - * CPU model definition data that was not converted to QOM per-subclass - * property defaults yet. - */ -typedef struct X86CPUDefinition X86CPUDefinition; +typedef struct X86CPUModel X86CPUModel; =20 /** * X86CPUClass: @@ -64,7 +58,7 @@ typedef struct X86CPUClass { /* CPU definition, automatically loaded by instance_init if not NULL. * Should be eventually replaced by subclass-specific property default= s. */ - X86CPUDefinition *cpu_def; + X86CPUModel *model; =20 bool host_cpuid_required; int ordering; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 4727226a6a..12bc3cd4a8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1929,6 +1929,16 @@ void apic_handle_tpr_access_report(DeviceState *d, t= arget_ulong ip, */ void x86_cpu_change_kvm_default(const char *prop, const char *value); =20 +/* Special values for X86CPUVersion: */ + +/* Resolve to latest CPU version */ +#define CPU_VERSION_LATEST -1 + +/* Don't resolve to any versioned CPU models, like old QEMU versions */ +#define CPU_VERSION_LEGACY 0 + +typedef int X86CPUVersion; + /* Return name of 32-bit register, from a R_* constant */ const char *get_register_name_32(unsigned int reg); =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 955ea20d69..a611c6eae2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1433,7 +1433,17 @@ static char *x86_cpu_class_get_model_name(X86CPUClas= s *cc) strlen(class_name) - strlen(X86_CPU_TYPE_SUFFIX)); } =20 -struct X86CPUDefinition { +typedef struct PropValue { + const char *prop, *value; +} PropValue; + +typedef struct X86CPUVersionDefinition { + X86CPUVersion version; + PropValue *props; +} X86CPUVersionDefinition; + +/* Base definition for a CPU model */ +typedef struct X86CPUDefinition { const char *name; uint32_t level; uint32_t xlevel; @@ -1445,8 +1455,41 @@ struct X86CPUDefinition { FeatureWordArray features; const char *model_id; CPUCaches *cache_info; + /* + * Definitions for alternative versions of CPU model. + * List is terminated by item with version =3D=3D 0. + * If NULL, version 1 will be registered automatically. + */ + const X86CPUVersionDefinition *versions; +} X86CPUDefinition; + +/* Reference to a specific CPU model version */ +struct X86CPUModel { + /* Base CPU definition */ + X86CPUDefinition *cpudef; + /* CPU model version */ + X86CPUVersion version; }; =20 +/* Get full model name for CPU version */ +static char *x86_cpu_versioned_model_name(X86CPUDefinition *cpudef, + X86CPUVersion version) +{ + assert(version > 0); + return g_strdup_printf("%s-v%d", cpudef->name, (int)version); +} + +static const X86CPUVersionDefinition *x86_cpu_def_get_versions(X86CPUDefin= ition *def) +{ + /* When X86CPUDefinition::versions is NULL, we register only v1 */ + static const X86CPUVersionDefinition default_version_list[] =3D { + { 1 }, + { /* end of list */ } + }; + + return def->versions ?: default_version_list; +} + static CPUCaches epyc_cache_info =3D { .l1d_cache =3D &(CPUCacheInfo) { .type =3D DATA_CACHE, @@ -1833,6 +1876,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_EXT3_LAHF_LM, .xlevel =3D 0x80000008, .model_id =3D "Intel Core i7 9xx (Nehalem Core i7, IBRS update)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Westmere", @@ -1887,6 +1935,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Westmere E56xx/L56xx/X56xx (IBRS update)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "SandyBridge", @@ -1951,6 +2004,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon E312xx (Sandy Bridge, IBRS update)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "IvyBridge", @@ -2021,6 +2079,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Haswell-noTSX", @@ -2057,6 +2120,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Haswell, no TSX)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Haswell-noTSX-IBRS", @@ -2095,6 +2163,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Haswell, no TSX, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Haswell", @@ -2171,6 +2244,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Haswell, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Broadwell-noTSX", @@ -2209,6 +2287,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Broadwell, no TSX)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Broadwell-noTSX-IBRS", @@ -2249,6 +2332,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Broadwell, no TSX, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Broadwell", @@ -2327,6 +2415,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Broadwell, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Skylake-Client", @@ -2419,6 +2512,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Skylake, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Skylake-Server", @@ -2521,6 +2619,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon Processor (Skylake, IBRS)", + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Cascadelake-Server", @@ -3029,6 +3132,11 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x8000001E, .model_id =3D "AMD EPYC Processor (with IBPB)", .cache_info =3D &epyc_cache_info, + /* + * This CPU model will eventually be replaced by an alias, + * don't register any versions for it. + */ + .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, }, { .name =3D "Dhyana", @@ -3082,10 +3190,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, }; =20 -typedef struct PropValue { - const char *prop, *value; -} PropValue; - /* KVM-specific features that are automatically added/removed * from all CPU models when KVM is enabled. */ @@ -3111,6 +3215,28 @@ static PropValue tcg_default_props[] =3D { }; =20 =20 +static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model) +{ + int v =3D 0; + const X86CPUVersionDefinition *vdef =3D + x86_cpu_def_get_versions(model->cpudef); + while (vdef->version) { + v =3D vdef->version; + vdef++; + } + return v; +} + +/* Return the actual version being used for a specific CPU model */ +static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *mode= l) +{ + X86CPUVersion v =3D model->version; + if (v =3D=3D CPU_VERSION_LATEST) { + return x86_cpu_model_last_version(model); + } + return v; +} + void x86_cpu_change_kvm_default(const char *prop, const char *value) { PropValue *pv; @@ -3188,8 +3314,6 @@ static void max_x86_cpu_class_init(ObjectClass *oc, v= oid *data) dc->props =3D max_x86_cpu_properties; } =20 -static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **e= rrp); - static void max_x86_cpu_initfn(Object *obj) { X86CPU *cpu =3D X86_CPU(obj); @@ -3980,10 +4104,40 @@ static void x86_cpu_apply_props(X86CPU *cpu, PropVa= lue *props) } } =20 +/* Apply properties for the CPU model version specified in model */ +static void x86_cpu_apply_version_props(X86CPU *cpu, X86CPUModel *model) +{ + const X86CPUVersionDefinition *vdef; + X86CPUVersion version =3D x86_cpu_model_resolve_version(model); + + if (version =3D=3D CPU_VERSION_LEGACY) { + return; + } + + for (vdef =3D x86_cpu_def_get_versions(model->cpudef); vdef->version; = vdef++) { + PropValue *p; + + for (p =3D vdef->props; p && p->prop; p++) { + object_property_parse(OBJECT(cpu), p->value, p->prop, + &error_abort); + } + + if (vdef->version =3D=3D version) { + break; + } + } + + /* + * If we reached the end of the list, version number was invalid + */ + assert(vdef->version =3D=3D version); +} + /* Load data from X86CPUDefinition into a X86CPU object */ -static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefinition *def, Error **e= rrp) +static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model, Error **er= rp) { + X86CPUDefinition *def =3D model->cpudef; CPUX86State *env =3D &cpu->env; const char *vendor; char host_vendor[CPUID_VENDOR_SZ + 1]; @@ -4040,11 +4194,12 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDef= inition *def, Error **errp) =20 object_property_set_str(OBJECT(cpu), vendor, "vendor", errp); =20 + x86_cpu_apply_version_props(cpu, model); } =20 #ifndef CONFIG_USER_ONLY /* Return a QDict containing keys for all properties that can be included - * in static expansion of CPU models. All properties set by x86_cpu_load_d= ef() + * in static expansion of CPU models. All properties set by x86_cpu_load_m= odel() * must be included in the dictionary. */ static QDict *x86_cpu_static_props(void) @@ -4258,23 +4413,33 @@ static gchar *x86_gdb_arch_name(CPUState *cs) =20 static void x86_cpu_cpudef_class_init(ObjectClass *oc, void *data) { - X86CPUDefinition *cpudef =3D data; + X86CPUModel *model =3D data; X86CPUClass *xcc =3D X86_CPU_CLASS(oc); =20 - xcc->cpu_def =3D cpudef; + xcc->model =3D model; xcc->migration_safe =3D true; } =20 -static void x86_register_cpudef_type(X86CPUDefinition *def) +static void x86_register_cpu_model_type(const char *name, X86CPUModel *mod= el) { - char *typename =3D x86_cpu_type_name(def->name); + char *typename =3D x86_cpu_type_name(name); TypeInfo ti =3D { .name =3D typename, .parent =3D TYPE_X86_CPU, .class_init =3D x86_cpu_cpudef_class_init, - .class_data =3D def, + .class_data =3D model, }; =20 + type_register(&ti); + g_free(typename); +} + +static void x86_register_cpudef_types(X86CPUDefinition *def) +{ + X86CPUModel *m; + const X86CPUVersionDefinition *vdef; + char *name; + /* AMD aliases are handled at runtime based on CPUID vendor, so * they shouldn't be set on the CPU model table. */ @@ -4282,9 +4447,23 @@ static void x86_register_cpudef_type(X86CPUDefinitio= n *def) /* catch mistakes instead of silently truncating model_id when too lon= g */ assert(def->model_id && strlen(def->model_id) <=3D 48); =20 + /* Unversioned model: */ + m =3D g_new0(X86CPUModel, 1); + m->cpudef =3D def; + m->version =3D CPU_VERSION_LEGACY; + x86_register_cpu_model_type(def->name, m); + + /* Versioned models: */ + + for (vdef =3D x86_cpu_def_get_versions(def); vdef->version; vdef++) { + X86CPUModel *m =3D g_new0(X86CPUModel, 1); + m->cpudef =3D def; + m->version =3D vdef->version; + name =3D x86_cpu_versioned_model_name(def, vdef->version); + x86_register_cpu_model_type(name, m); + g_free(name); + } =20 - type_register(&ti); - g_free(typename); } =20 #if !defined(CONFIG_USER_ONLY) @@ -5110,7 +5289,7 @@ static void x86_cpu_enable_xsave_components(X86CPU *c= pu) * involved in setting up CPUID data are: * * 1) Loading CPU model definition (X86CPUDefinition). This is - * implemented by x86_cpu_load_def() and should be completely + * implemented by x86_cpu_load_model() and should be completely * transparent, as it is done automatically by instance_init. * No code should need to look at X86CPUDefinition structs * outside instance_init. @@ -5432,7 +5611,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) =20 /* Cache information initialization */ if (!cpu->legacy_cache) { - if (!xcc->cpu_def || !xcc->cpu_def->cache_info) { + if (!xcc->model || !xcc->model->cpudef->cache_info) { char *name =3D x86_cpu_class_get_model_name(xcc); error_setg(errp, "CPU model '%s' doesn't support legacy-cache=3Doff"= , name); @@ -5440,7 +5619,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error= **errp) return; } env->cache_info_cpuid2 =3D env->cache_info_cpuid4 =3D env->cache_i= nfo_amd =3D - *xcc->cpu_def->cache_info; + *xcc->model->cpudef->cache_info; } else { /* Build legacy cache information */ env->cache_info_cpuid2.l1d_cache =3D &legacy_l1d_cache; @@ -5799,8 +5978,8 @@ static void x86_cpu_initfn(Object *obj) object_property_add_alias(obj, "sse4_1", obj, "sse4.1", &error_abort); object_property_add_alias(obj, "sse4_2", obj, "sse4.2", &error_abort); =20 - if (xcc->cpu_def) { - x86_cpu_load_def(cpu, xcc->cpu_def, &error_abort); + if (xcc->model) { + x86_cpu_load_model(cpu, xcc->model, &error_abort); } } =20 @@ -6139,7 +6318,7 @@ static void x86_cpu_register_types(void) =20 type_register_static(&x86_cpu_type_info); for (i =3D 0; i < ARRAY_SIZE(builtin_x86_defs); i++) { - x86_register_cpudef_type(&builtin_x86_defs[i]); + x86_register_cpudef_types(&builtin_x86_defs[i]); } type_register_static(&max_x86_cpu_type_info); type_register_static(&x86_base_cpu_type_info); diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/= x86_cpu_model_versions.py new file mode 100644 index 0000000000..b85d6f8604 --- /dev/null +++ b/tests/acceptance/x86_cpu_model_versions.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# +# Basic validation of x86 versioned CPU models and CPU model aliases +# +# Copyright (c) 2019 Red Hat Inc +# +# Author: +# Eduardo Habkost +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, see . +# + + +import avocado_qemu +import re + +class X86CPUModelAliases(avocado_qemu.Test): + """ + Validation of PC CPU model versions and CPU model aliases + + :avocado: tags=3Darch:x86_64 + """ + def validate_aliases(self, cpus): + for c in cpus.values(): + if 'alias-of' in c: + # all aliases must point to a valid CPU model name: + self.assertIn(c['alias-of'], cpus, + '%s.alias-of (%s) is not a valid CPU model n= ame' % (c['name'], c['alias-of'])) + # aliases must not point to aliases + self.assertNotIn('alias-of', cpus[c['alias-of']], + '%s.alias-of (%s) points to another alias= ' % (c['name'], c['alias-of'])) + + # aliases must not be static + self.assertFalse(c['static']) + + def validate_variant_aliases(self, cpus): + # -noTSX, -IBRS and -IBPB variants of CPU models are special: + # they shouldn't have their own versions: + self.assertNotIn("Haswell-noTSX-v1", cpus, + "Haswell-noTSX shouldn't be versioned") + self.assertNotIn("Broadwell-noTSX-v1", cpus, + "Broadwell-noTSX shouldn't be versioned") + self.assertNotIn("Nehalem-IBRS-v1", cpus, + "Nehalem-IBRS shouldn't be versioned") + self.assertNotIn("Westmere-IBRS-v1", cpus, + "Westmere-IBRS shouldn't be versioned") + self.assertNotIn("SandyBridge-IBRS-v1", cpus, + "SandyBridge-IBRS shouldn't be versioned") + self.assertNotIn("IvyBridge-IBRS-v1", cpus, + "IvyBridge-IBRS shouldn't be versioned") + self.assertNotIn("Haswell-noTSX-IBRS-v1", cpus, + "Haswell-noTSX-IBRS shouldn't be versioned") + self.assertNotIn("Haswell-IBRS-v1", cpus, + "Haswell-IBRS shouldn't be versioned") + self.assertNotIn("Broadwell-noTSX-IBRS-v1", cpus, + "Broadwell-noTSX-IBRS shouldn't be versioned") + self.assertNotIn("Broadwell-IBRS-v1", cpus, + "Broadwell-IBRS shouldn't be versioned") + self.assertNotIn("Skylake-Client-IBRS-v1", cpus, + "Skylake-Client-IBRS shouldn't be versioned") + self.assertNotIn("Skylake-Server-IBRS-v1", cpus, + "Skylake-Server-IBRS shouldn't be versioned") + self.assertNotIn("EPYC-IBPB-v1", cpus, + "EPYC-IBPB shouldn't be versioned") + + def test_4_0_alias_compatibility(self): + """Check if pc-*-4.0 unversioned CPU model won't be reported as al= iases""" + # pc-*-4.0 won't expose non-versioned CPU models as aliases + # We do this to help management software to keep compatibility + # with older QEMU versions that didn't have the versioned CPU model + self.vm.add_args('-S') + self.vm.set_machine('pc-i440fx-4.0') + self.vm.launch() + cpus =3D dict((m['name'], m) for m in self.vm.command('query-cpu-d= efinitions')) + + self.assertFalse(cpus['Cascadelake-Server']['static'], + 'unversioned Cascadelake-Server CPU model must no= t be static') + self.assertNotIn('alias-of', cpus['Cascadelake-Server'], + 'Cascadelake-Server must not be an alias') + self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'], + 'Cascadelake-Server-v1 must not be an alias') + + self.assertFalse(cpus['qemu64']['static'], + 'unversioned qemu64 CPU model must not be static') + self.assertNotIn('alias-of', cpus['qemu64'], + 'qemu64 must not be an alias') + self.assertNotIn('alias-of', cpus['qemu64-v1'], + 'qemu64-v1 must not be an alias') + + self.validate_variant_aliases(cpus) + + # On pc-*-4.0, no CPU model should be reported as an alias: + for name,c in cpus.items(): + self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (= name)) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562178443; cv=none; d=zoho.com; s=zohoarc; b=Bit65LB+IpRJ+FPUJSUbn+RPzxKYOQO1mmhj7PxKTRWOQZqCNEBo+4a1ZkYumHUN42OKxzOcAEC0MQtZKJ3N52ZTDmvYWGSvJuVQbZBc6othO+8FB3Uj6o4OhPqbePF/fKvJ/YXJH9JTFtekLlWB13Dbwb2gg4e95gQDibutvJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178443; h=Content-Type:Content-Transfer-Encoding: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=Dno2dw1B+2aJPir6M3SpFr18WRnQKuiTBfjoyIjqRCs=; b=dO0WqT9EwYMHWbi/JE2PBxT5jUeVVgKhPB3VnCChrzVwKxTkvn0F9mLMmxjmdyk2IlfZVUeYV2i9pVw+mV8ZDY+ENM+6yGjMCLV7GXssqnNo2k8G1L0QfQN7SZiLKueMzsuODjHjHY2UUDnrvN4H39JhMWTFUEBhvRvn0wYkWyo= 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 1562178443985269.7587011577838; Wed, 3 Jul 2019 11:27:23 -0700 (PDT) Received: from localhost ([::1]:38394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijyP-0005bs-Ph for importer@patchew.org; Wed, 03 Jul 2019 14:27:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56855) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgd-00054g-A4 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgb-0000wO-Tn for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43594) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgb-0000vz-MD for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:53 -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 007B0C04FFF6; Wed, 3 Jul 2019 18:08:53 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7B555C5BB; Wed, 3 Jul 2019 18:08:50 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:19 -0300 Message-Id: <20190703180726.31267-37-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.31]); Wed, 03 Jul 2019 18:08:53 +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 v4 36/43] i386: Define -IBRS, -noTSX, -IBRS versions of CPU models 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add versions of CPU models that are equivalent to their -IBRS, -noTSX and -IBRS variants. The separate variants will eventually be removed and become aliases for these CPU versions. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-6-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a611c6eae2..99ab6104f4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1851,6 +1851,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_EXT3_LAHF_LM, .xlevel =3D 0x80000008, .model_id =3D "Intel Core i7 9xx (Nehalem Class Core i7)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Nehalem-IBRS */ + .props =3D (PropValue[]) { + { "spec-ctrl", "on" }, + { "model-id", + "Intel Core i7 9xx (Nehalem Core i7, IBRS update)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Nehalem-IBRS", @@ -1907,6 +1921,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Westmere E56xx/L56xx/X56xx (Nehalem-C)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Westmere-IBRS */ + .props =3D (PropValue[]) { + { "spec-ctrl", "on" }, + { "model-id", + "Westmere E56xx/L56xx/X56xx (IBRS update)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Westmere-IBRS", @@ -1971,6 +1999,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon E312xx (Sandy Bridge)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to SandyBridge-IBRS */ + .props =3D (PropValue[]) { + { "spec-ctrl", "on" }, + { "model-id", + "Intel Xeon E312xx (Sandy Bridge, IBRS update)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "SandyBridge-IBRS", @@ -2043,6 +2085,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon E3-12xx v2 (Ivy Bridge)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to IvyBridge-IBRS */ + .props =3D (PropValue[]) { + { "spec-ctrl", "on" }, + { "model-id", + "Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "IvyBridge-IBRS", @@ -2205,6 +2261,52 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Haswell)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Haswell-noTSX */ + .props =3D (PropValue[]) { + { "hle", "off" }, + { "rtm", "off" }, + { "stepping", "1" }, + { "model-id", "Intel Core Processor (Haswell, no TSX)"= , }, + { /* end of list */ } + }, + }, + { + .version =3D 3, + /* Equivalent to Haswell-IBRS */ + .props =3D (PropValue[]) { + /* Restore TSX features removed by -v2 above */ + { "hle", "on" }, + { "rtm", "on" }, + /* + * Haswell and Haswell-IBRS had stepping=3D4 in + * QEMU 4.0 and older + */ + { "stepping", "4" }, + { "spec-ctrl", "on" }, + { "model-id", + "Intel Core Processor (Haswell, IBRS)" }, + { /* end of list */ } + } + }, + { + .version =3D 4, + /* Equivalent to Haswell-noTSX-IBRS */ + .props =3D (PropValue[]) { + { "hle", "off" }, + { "rtm", "off" }, + /* spec-ctrl was already enabled by -v3 above */ + { "stepping", "1" }, + { "model-id", + "Intel Core Processor (Haswell, no TSX, IBRS)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Haswell-IBRS", @@ -2375,6 +2477,45 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Broadwell)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Broadwell-noTSX */ + .props =3D (PropValue[]) { + { "hle", "off" }, + { "rtm", "off" }, + { "model-id", "Intel Core Processor (Broadwell, no TSX= )", }, + { /* end of list */ } + }, + }, + { + .version =3D 3, + /* Equivalent to Broadwell-IBRS */ + .props =3D (PropValue[]) { + /* Restore TSX features removed by -v2 above */ + { "hle", "on" }, + { "rtm", "on" }, + { "spec-ctrl", "on" }, + { "model-id", + "Intel Core Processor (Broadwell, IBRS)" }, + { /* end of list */ } + } + }, + { + .version =3D 4, + /* Equivalent to Broadwell-noTSX-IBRS */ + .props =3D (PropValue[]) { + { "hle", "off" }, + { "rtm", "off" }, + /* spec-ctrl was already enabled by -v3 above */ + { "model-id", + "Intel Core Processor (Broadwell, no TSX, IBRS)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Broadwell-IBRS", @@ -2465,6 +2606,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Core Processor (Skylake)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Skylake-Client-IBRS */ + .props =3D (PropValue[]) { + { "spec-ctrl", "on" }, + { "model-id", + "Intel Core Processor (Skylake, IBRS)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Skylake-Client-IBRS", @@ -2567,6 +2722,23 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon Processor (Skylake)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to Skylake-Server-IBRS */ + .props =3D (PropValue[]) { + /* clflushopt was not added to Skylake-Server-IBRS */ + /* TODO: add -v3 including clflushopt */ + { "clflushopt", "off" }, + { "spec-ctrl", "on" }, + { "model-id", + "Intel Xeon Processor (Skylake, IBRS)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "Skylake-Server-IBRS", @@ -3082,6 +3254,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x8000001E, .model_id =3D "AMD EPYC Processor", .cache_info =3D &epyc_cache_info, + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { + .version =3D 2, + /* Equivalent to EPYC-IBPB */ + .props =3D (PropValue[]) { + { "ibpb", "on" }, + { "model-id", + "AMD EPYC Processor (with IBPB)" }, + { /* end of list */ } + } + }, + { /* end of list */ } + } }, { .name =3D "EPYC-IBPB", --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562179446; cv=none; d=zoho.com; s=zohoarc; b=iqSJQM9XYdbowURn6VKBU9+41/bcHUIRM53/TeqAB9b/RCIozt0GHE0CWdZuuXL0Jcy2oCphMWBsljP5hm1qblUVWXMuyf1Oqylk/4yeX8DKRJfMywH2H2I+36zIibNc21BrX7PnP+TTn2iNpvNoybfFSn6H0llN8tNlrxn2DTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179446; h=Content-Type:Content-Transfer-Encoding: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=s1ehzfJIZuuydoTFGL0VjlZTTqGW6iV3ZUMUuSeS2uc=; b=HP1EjErUaO0ekWOpKCaZvVKLvLaW1K3lDS2SyJmSIQSH5glFHWLGjoaYBItdogblfahJGxlcmpU6qWZsckQ9f4013Sh1SoxoKESGh9lKToBtG/EwZaEHQtrePTkpDEFHWLpX1HKv+YusAyijiZE5+C38wXXrmePzZojxP9P3Y3o= 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 1562179446337748.5124720478727; Wed, 3 Jul 2019 11:44:06 -0700 (PDT) Received: from localhost ([::1]:38518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikEa-0004cN-A8 for importer@patchew.org; Wed, 03 Jul 2019 14:44:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56891) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgh-0005FH-BE for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijge-0000yi-DP for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46802) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijge-0000xa-5f for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:56 -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 7D0E381DE5; Wed, 3 Jul 2019 18:08:55 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9332A58775; Wed, 3 Jul 2019 18:08:54 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:20 -0300 Message-Id: <20190703180726.31267-38-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.25]); Wed, 03 Jul 2019 18:08:55 +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 v4 37/43] i386: Replace -noTSX, -IBRS, -IBPB CPU models with aliases 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The old CPU models will be just aliases for specific versions of the original CPU models. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-7-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 601 ++-------------------------------------------- 1 file changed, 21 insertions(+), 580 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 99ab6104f4..4646b0dde9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1439,6 +1439,7 @@ typedef struct PropValue { =20 typedef struct X86CPUVersionDefinition { X86CPUVersion version; + const char *alias; PropValue *props; } X86CPUVersionDefinition; =20 @@ -1855,7 +1856,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Nehalem-IBRS */ + .alias =3D "Nehalem-IBRS", .props =3D (PropValue[]) { { "spec-ctrl", "on" }, { "model-id", @@ -1866,36 +1867,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Nehalem-IBRS", - .level =3D 11, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 26, - .stepping =3D 3, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | - CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_SSE3, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_LAHF_LM, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core i7 9xx (Nehalem Core i7, IBRS update)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Westmere", .level =3D 11, @@ -1925,7 +1896,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Westmere-IBRS */ + .alias =3D "Westmere-IBRS", .props =3D (PropValue[]) { { "spec-ctrl", "on" }, { "model-id", @@ -1936,39 +1907,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Westmere-IBRS", - .level =3D 11, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 44, - .stepping =3D 1, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AES | CPUID_EXT_POPCNT | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_SYSCALL | CPUID_EXT2_NX, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Westmere E56xx/L56xx/X56xx (IBRS update)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "SandyBridge", .level =3D 0xd, @@ -2003,7 +1941,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to SandyBridge-IBRS */ + .alias =3D "SandyBridge-IBRS", .props =3D (PropValue[]) { { "spec-ctrl", "on" }, { "model-id", @@ -2014,44 +1952,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "SandyBridge-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 42, - .stepping =3D 1, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT | - CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | - CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | - CPUID_EXT_SSE3, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Xeon E312xx (Sandy Bridge, IBRS update)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "IvyBridge", .level =3D 0xd, @@ -2089,7 +1989,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to IvyBridge-IBRS */ + .alias =3D "IvyBridge-IBRS", .props =3D (PropValue[]) { { "spec-ctrl", "on" }, { "model-id", @@ -2100,131 +2000,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "IvyBridge-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 58, - .stepping =3D 9, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_POPCNT | - CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | - CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | CPUID_EXT_PCLMULQDQ | - CPUID_EXT_SSE3 | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_ERMS, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, - { - .name =3D "Haswell-noTSX", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 60, - .stepping =3D 1, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Haswell, no TSX)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, - { - .name =3D "Haswell-noTSX-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 60, - .stepping =3D 1, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Haswell, no TSX, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Haswell", .level =3D 0xd, @@ -2265,7 +2040,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Haswell-noTSX */ + .alias =3D "Haswell-noTSX", .props =3D (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, @@ -2276,7 +2051,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, { .version =3D 3, - /* Equivalent to Haswell-IBRS */ + .alias =3D "Haswell-IBRS", .props =3D (PropValue[]) { /* Restore TSX features removed by -v2 above */ { "hle", "on" }, @@ -2294,7 +2069,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, { .version =3D 4, - /* Equivalent to Haswell-noTSX-IBRS */ + .alias =3D "Haswell-noTSX-IBRS", .props =3D (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, @@ -2308,138 +2083,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Haswell-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 60, - .stepping =3D 4, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RTM, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Haswell, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, - { - .name =3D "Broadwell-noTSX", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 61, - .stepping =3D 2, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | - CPUID_7_0_EBX_SMAP, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Broadwell, no TSX)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, - { - .name =3D "Broadwell-noTSX-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 61, - .stepping =3D 2, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | - CPUID_7_0_EBX_SMAP, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Broadwell, no TSX, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Broadwell", .level =3D 0xd, @@ -2481,7 +2124,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Broadwell-noTSX */ + .alias =3D "Broadwell-noTSX", .props =3D (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, @@ -2491,7 +2134,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, { .version =3D 3, - /* Equivalent to Broadwell-IBRS */ + .alias =3D "Broadwell-IBRS", .props =3D (PropValue[]) { /* Restore TSX features removed by -v2 above */ { "hle", "on" }, @@ -2504,7 +2147,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { }, { .version =3D 4, - /* Equivalent to Broadwell-noTSX-IBRS */ + .alias =3D "Broadwell-noTSX-IBRS", .props =3D (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, @@ -2517,51 +2160,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Broadwell-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 61, - .stepping =3D 2, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | - CPUID_7_0_EBX_SMAP, - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Broadwell, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Skylake-Client", .level =3D 0xd, @@ -2610,7 +2208,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Skylake-Client-IBRS */ + .alias =3D "Skylake-Client-IBRS", .props =3D (PropValue[]) { { "spec-ctrl", "on" }, { "model-id", @@ -2621,58 +2219,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Skylake-Client-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 94, - .stepping =3D 3, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | - CPUID_7_0_EBX_SMAP, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | - CPUID_XSAVE_XGETBV1, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Core Processor (Skylake, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Skylake-Server", .level =3D 0xd, @@ -2726,7 +2272,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to Skylake-Server-IBRS */ + .alias =3D "Skylake-Server-IBRS", .props =3D (PropValue[]) { /* clflushopt was not added to Skylake-Server-IBRS */ /* TODO: add -v3 including clflushopt */ @@ -2740,63 +2286,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "Skylake-Server-IBRS", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_INTEL, - .family =3D 6, - .model =3D 85, - .stepping =3D 4, - .features[FEAT_1_EDX] =3D - CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | - CPUID_CLFLUSH | CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_M= CA | - CPUID_PGE | CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | - CPUID_MCE | CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | - CPUID_DE | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_AVX | CPUID_EXT_XSAVE | CPUID_EXT_AES | - CPUID_EXT_POPCNT | CPUID_EXT_X2APIC | CPUID_EXT_SSE42 | - CPUID_EXT_SSE41 | CPUID_EXT_CX16 | CPUID_EXT_SSSE3 | - CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 | - CPUID_EXT_TSC_DEADLINE_TIMER | CPUID_EXT_FMA | CPUID_EXT_MOVBE= | - CPUID_EXT_PCID | CPUID_EXT_F16C | CPUID_EXT_RDRAND, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_PDPE1GB | CPUID_EXT2_RDTSCP | - CPUID_EXT2_NX | CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_ABM | CPUID_EXT3_LAHF_LM | CPUID_EXT3_3DNOWPREFETCH, - .features[FEAT_7_0_EDX] =3D - CPUID_7_0_EDX_SPEC_CTRL, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | - CPUID_7_0_EBX_HLE | CPUID_7_0_EBX_AVX2 | CPUID_7_0_EBX_SMEP | - CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | - CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | - CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLWB | - CPUID_7_0_EBX_AVX512F | CPUID_7_0_EBX_AVX512DQ | - CPUID_7_0_EBX_AVX512BW | CPUID_7_0_EBX_AVX512CD | - CPUID_7_0_EBX_AVX512VL, - .features[FEAT_7_0_ECX] =3D - CPUID_7_0_ECX_PKU, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | - CPUID_XSAVE_XGETBV1, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .xlevel =3D 0x80000008, - .model_id =3D "Intel Xeon Processor (Skylake, IBRS)", - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Cascadelake-Server", .level =3D 0xd, @@ -3258,7 +2747,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { .version =3D 1 }, { .version =3D 2, - /* Equivalent to EPYC-IBPB */ + .alias =3D "EPYC-IBPB", .props =3D (PropValue[]) { { "ibpb", "on" }, { "model-id", @@ -3269,61 +2758,6 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, - { - .name =3D "EPYC-IBPB", - .level =3D 0xd, - .vendor =3D CPUID_VENDOR_AMD, - .family =3D 23, - .model =3D 1, - .stepping =3D 2, - .features[FEAT_1_EDX] =3D - CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUS= H | - CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE | - CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE | - CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE | - CPUID_VME | CPUID_FP87, - .features[FEAT_1_ECX] =3D - CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX | - CPUID_EXT_XSAVE | CPUID_EXT_AES | CPUID_EXT_POPCNT | - CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 | - CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 | - CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3, - .features[FEAT_8000_0001_EDX] =3D - CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB | - CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX | - CPUID_EXT2_SYSCALL, - .features[FEAT_8000_0001_ECX] =3D - CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH | - CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM | - CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM | - CPUID_EXT3_TOPOEXT, - .features[FEAT_8000_0008_EBX] =3D - CPUID_8000_0008_EBX_IBPB, - .features[FEAT_7_0_EBX] =3D - CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AV= X2 | - CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED= | - CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSH= OPT | - CPUID_7_0_EBX_SHA_NI, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component. - */ - .features[FEAT_XSAVE] =3D - CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | - CPUID_XSAVE_XGETBV1, - .features[FEAT_6_EAX] =3D - CPUID_6_EAX_ARAT, - .features[FEAT_SVM] =3D - CPUID_SVM_NPT | CPUID_SVM_NRIPSAVE, - .xlevel =3D 0x8000001E, - .model_id =3D "AMD EPYC Processor (with IBPB)", - .cache_info =3D &epyc_cache_info, - /* - * This CPU model will eventually be replaced by an alias, - * don't register any versions for it. - */ - .versions =3D (X86CPUVersionDefinition[]) { { /* end of list */ } = }, - }, { .name =3D "Dhyana", .level =3D 0xd, @@ -4648,6 +4082,13 @@ static void x86_register_cpudef_types(X86CPUDefiniti= on *def) name =3D x86_cpu_versioned_model_name(def, vdef->version); x86_register_cpu_model_type(name, m); g_free(name); + + if (vdef->alias) { + X86CPUModel *am =3D g_new0(X86CPUModel, 1); + am->cpudef =3D def; + am->version =3D vdef->version; + x86_register_cpu_model_type(vdef->alias, am); + } } =20 } --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562180573; cv=none; d=zoho.com; s=zohoarc; b=QBjOWKyoR7YsDDb3eO+YEeq8uNZUlgbultiboPbMeey3mRzILychMVsN/z3GO1yMtsYP/4AyB0zk/rcyDYNH+EnNmpL3FXEdhBhOFRX1+nxwTHo0BEERcTyxfovhWzD5KBotjr8aUFKXaTyS1MUw50lGPfc2CgsQejRGNigUabU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180573; h=Content-Type:Content-Transfer-Encoding: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=syH/qbe0SnkKimc3sC3ZNBiijXQFC9L2TBKu+BjPIw0=; b=P6DiKfmVVqMPZLIs9zgQHPNByyFZGklZSMeIiZFKXGvKauILJDLOCDY4LmeWMwj1hochHQ02vcnfXLo8gqnM1epp+Jr6YNK4nwDPXwd/5YKQ+k/tYXQmKlYfRfVpR7fSsqSrQvLzIqQE5G/oGmeNkWzEPzRkA+tsB1PF2KXGyuE= 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 1562180573184691.188624798889; Wed, 3 Jul 2019 12:02:53 -0700 (PDT) Received: from localhost ([::1]:38672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikWn-0006tG-6A for importer@patchew.org; Wed, 03 Jul 2019 15:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56901) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgi-0005Id-Mw for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgg-000116-LP for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46834) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgg-00010E-Dn for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:08:58 -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 B216285360; Wed, 3 Jul 2019 18:08:57 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07AA118233; Wed, 3 Jul 2019 18:08:56 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:21 -0300 Message-Id: <20190703180726.31267-39-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Wed, 03 Jul 2019 18:08:57 +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 v4 38/43] i386: Make unversioned CPU models be aliases 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This will make unversioned CPU models behavior depend on the machine type: * "pc-*-4.0" and older will not report them as aliases. This is done to keep compatibility with older QEMU versions after management software starts translating aliases. * "pc-*-4.1" will translate unversioned CPU models to -v1. This is done to keep compatibility with existing management software, that still relies on CPU model runnability promises. * "none" will translate unversioned CPU models to their latest version. This is planned become the default in future machine types (probably in pc-*-4.3). Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-8-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- include/hw/i386/pc.h | 3 + target/i386/cpu.h | 12 ++ hw/i386/pc.c | 3 + hw/i386/pc_piix.c | 4 + hw/i386/pc_q35.c | 4 + target/i386/cpu.c | 52 ++++++++- tests/acceptance/x86_cpu_model_versions.py | 126 +++++++++++++++++++++ 7 files changed, 203 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ee79d71ccc..1946c1023f 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -109,6 +109,9 @@ typedef struct PCMachineClass { =20 /* Compat options: */ =20 + /* Default CPU model version. See x86_cpu_set_default_version(). */ + int default_cpu_version; + /* ACPI compat: */ bool has_acpi_build; bool rsdp_in_ram; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 12bc3cd4a8..05393cf9d1 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1934,11 +1934,23 @@ void x86_cpu_change_kvm_default(const char *prop, c= onst char *value); /* Resolve to latest CPU version */ #define CPU_VERSION_LATEST -1 =20 +/* + * Resolve to version defined by current machine type. + * See x86_cpu_set_default_version() + */ +#define CPU_VERSION_AUTO -2 + /* Don't resolve to any versioned CPU models, like old QEMU versions */ #define CPU_VERSION_LEGACY 0 =20 typedef int X86CPUVersion; =20 +/* + * Set default CPU model version for CPU models having + * version =3D=3D CPU_VERSION_AUTO. + */ +void x86_cpu_set_default_version(X86CPUVersion version); + /* Return name of 32-bit register, from a R_* constant */ const char *get_register_name_32(unsigned int reg); =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3f0f221a5b..1df569620a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1649,6 +1649,9 @@ void pc_cpus_init(PCMachineState *pcms) const CPUArchIdList *possible_cpus; MachineState *ms =3D MACHINE(pcms); MachineClass *mc =3D MACHINE_GET_CLASS(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(mc); + + x86_cpu_set_default_version(pcmc->default_cpu_version); =20 /* Calculates the limit to CPU APIC ID values * diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c07c4a5b38..0a069bff54 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -430,9 +430,11 @@ static void pc_i440fx_machine_options(MachineClass *m) =20 static void pc_i440fx_4_1_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D 1; + pcmc->default_cpu_version =3D 1; } =20 DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL, @@ -440,9 +442,11 @@ DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL, =20 static void pc_i440fx_4_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_4_1_machine_options(m); m->alias =3D NULL; m->is_default =3D 0; + pcmc->default_cpu_version =3D CPU_VERSION_LEGACY; compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 57232aed6b..397e1fdd2f 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -367,8 +367,10 @@ static void pc_q35_machine_options(MachineClass *m) =20 static void pc_q35_4_1_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_machine_options(m); m->alias =3D "q35"; + pcmc->default_cpu_version =3D 1; } =20 DEFINE_Q35_MACHINE(v4_1, "pc-q35-4.1", NULL, @@ -376,8 +378,10 @@ DEFINE_Q35_MACHINE(v4_1, "pc-q35-4.1", NULL, =20 static void pc_q35_4_0_1_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_4_1_machine_options(m); m->alias =3D NULL; + pcmc->default_cpu_version =3D CPU_VERSION_LEGACY; /* * This is the default machine for the 4.0-stable branch. It is basica= lly * a 4.0 that doesn't use split irqchip by default. It MUST hence appl= y the diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 4646b0dde9..9b16cffb22 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1470,6 +1470,11 @@ struct X86CPUModel { X86CPUDefinition *cpudef; /* CPU model version */ X86CPUVersion version; + /* + * If true, this is an alias CPU model. + * This matters only for "-cpu help" and query-cpu-definitions + */ + bool is_alias; }; =20 /* Get full model name for CPU version */ @@ -2835,6 +2840,15 @@ static PropValue tcg_default_props[] =3D { }; =20 =20 +X86CPUVersion default_cpu_version =3D CPU_VERSION_LATEST; + +void x86_cpu_set_default_version(X86CPUVersion version) +{ + /* Translating CPU_VERSION_AUTO to CPU_VERSION_AUTO doesn't make sense= */ + assert(version !=3D CPU_VERSION_AUTO); + default_cpu_version =3D version; +} + static X86CPUVersion x86_cpu_model_last_version(const X86CPUModel *model) { int v =3D 0; @@ -2851,6 +2865,9 @@ static X86CPUVersion x86_cpu_model_last_version(const= X86CPUModel *model) static X86CPUVersion x86_cpu_model_resolve_version(const X86CPUModel *mode= l) { X86CPUVersion v =3D model->version; + if (v =3D=3D CPU_VERSION_AUTO) { + v =3D default_cpu_version; + } if (v =3D=3D CPU_VERSION_LATEST) { return x86_cpu_model_last_version(model); } @@ -3589,13 +3606,35 @@ static char *x86_cpu_class_get_model_id(X86CPUClass= *xc) return r; } =20 +static char *x86_cpu_class_get_alias_of(X86CPUClass *cc) +{ + X86CPUVersion version; + + if (!cc->model || !cc->model->is_alias) { + return NULL; + } + version =3D x86_cpu_model_resolve_version(cc->model); + if (version <=3D 0) { + return NULL; + } + return x86_cpu_versioned_model_name(cc->model->cpudef, version); +} + static void x86_cpu_list_entry(gpointer data, gpointer user_data) { ObjectClass *oc =3D data; X86CPUClass *cc =3D X86_CPU_CLASS(oc); char *name =3D x86_cpu_class_get_model_name(cc); char *desc =3D g_strdup(cc->model_description); + char *alias_of =3D x86_cpu_class_get_alias_of(cc); =20 + if (!desc && alias_of) { + if (cc->model && cc->model->version =3D=3D CPU_VERSION_AUTO) { + desc =3D g_strdup("(alias configured by machine type)"); + } else { + desc =3D g_strdup_printf("(alias of %s)", alias_of); + } + } if (!desc) { desc =3D x86_cpu_class_get_model_id(cc); } @@ -3603,6 +3642,7 @@ static void x86_cpu_list_entry(gpointer data, gpointe= r user_data) qemu_printf("x86 %-20s %-48s\n", name, desc); g_free(name); g_free(desc); + g_free(alias_of); } =20 /* list available CPU models and flags */ @@ -3651,6 +3691,14 @@ static void x86_cpu_definition_entry(gpointer data, = gpointer user_data) info->migration_safe =3D cc->migration_safe; info->has_migration_safe =3D true; info->q_static =3D cc->static_model; + /* + * Old machine types won't report aliases, so that alias translation + * doesn't break compatibility with previous QEMU versions. + */ + if (default_cpu_version !=3D CPU_VERSION_LEGACY) { + info->alias_of =3D x86_cpu_class_get_alias_of(cc); + info->has_alias_of =3D !!info->alias_of; + } =20 entry =3D g_malloc0(sizeof(*entry)); entry->value =3D info; @@ -4070,7 +4118,8 @@ static void x86_register_cpudef_types(X86CPUDefinitio= n *def) /* Unversioned model: */ m =3D g_new0(X86CPUModel, 1); m->cpudef =3D def; - m->version =3D CPU_VERSION_LEGACY; + m->version =3D CPU_VERSION_AUTO; + m->is_alias =3D true; x86_register_cpu_model_type(def->name, m); =20 /* Versioned models: */ @@ -4087,6 +4136,7 @@ static void x86_register_cpudef_types(X86CPUDefinitio= n *def) X86CPUModel *am =3D g_new0(X86CPUModel, 1); am->cpudef =3D def; am->version =3D vdef->version; + am->is_alias =3D true; x86_register_cpu_model_type(vdef->alias, am); } } diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/= x86_cpu_model_versions.py index b85d6f8604..165c0c7601 100644 --- a/tests/acceptance/x86_cpu_model_versions.py +++ b/tests/acceptance/x86_cpu_model_versions.py @@ -103,3 +103,129 @@ class X86CPUModelAliases(avocado_qemu.Test): # On pc-*-4.0, no CPU model should be reported as an alias: for name,c in cpus.items(): self.assertNotIn('alias-of', c, "%s shouldn't be an alias" % (= name)) + + def test_4_1_alias(self): + """Check if unversioned CPU model is an alias pointing to right ve= rsion""" + self.vm.add_args('-S') + self.vm.set_machine('pc-i440fx-4.1') + self.vm.launch() + + cpus =3D dict((m['name'], m) for m in self.vm.command('query-cpu-d= efinitions')) + + self.assertFalse(cpus['Cascadelake-Server']['static'], + 'unversioned Cascadelake-Server CPU model must no= t be static') + self.assertEquals(cpus['Cascadelake-Server'].get('alias-of'), 'Cas= cadelake-Server-v1', + 'Cascadelake-Server must be an alias of Cascadel= ake-Server-v1') + self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'], + 'Cascadelake-Server-v1 must not be an alias') + + self.assertFalse(cpus['qemu64']['static'], + 'unversioned qemu64 CPU model must not be static') + self.assertEquals(cpus['qemu64'].get('alias-of'), 'qemu64-v1', + 'qemu64 must be an alias of qemu64-v1') + self.assertNotIn('alias-of', cpus['qemu64-v1'], + 'qemu64-v1 must not be an alias') + + self.validate_variant_aliases(cpus) + + # On pc-*-4.1, -noTSX and -IBRS models should be aliases: + self.assertEquals(cpus["Haswell"].get('alias-of'), + "Haswell-v1", + "Haswell must be an alias") + self.assertEquals(cpus["Haswell-noTSX"].get('alias-of'), + "Haswell-v2", + "Haswell-noTSX must be an alias") + self.assertEquals(cpus["Haswell-IBRS"].get('alias-of'), + "Haswell-v3", + "Haswell-IBRS must be an alias") + self.assertEquals(cpus["Haswell-noTSX-IBRS"].get('alias-of'), + "Haswell-v4", + "Haswell-noTSX-IBRS must be an alias") + + self.assertEquals(cpus["Broadwell"].get('alias-of'), + "Broadwell-v1", + "Broadwell must be an alias") + self.assertEquals(cpus["Broadwell-noTSX"].get('alias-of'), + "Broadwell-v2", + "Broadwell-noTSX must be an alias") + self.assertEquals(cpus["Broadwell-IBRS"].get('alias-of'), + "Broadwell-v3", + "Broadwell-IBRS must be an alias") + self.assertEquals(cpus["Broadwell-noTSX-IBRS"].get('alias-of'), + "Broadwell-v4", + "Broadwell-noTSX-IBRS must be an alias") + + self.assertEquals(cpus["Nehalem"].get('alias-of'), + "Nehalem-v1", + "Nehalem must be an alias") + self.assertEquals(cpus["Nehalem-IBRS"].get('alias-of'), + "Nehalem-v2", + "Nehalem-IBRS must be an alias") + + self.assertEquals(cpus["Westmere"].get('alias-of'), + "Westmere-v1", + "Westmere must be an alias") + self.assertEquals(cpus["Westmere-IBRS"].get('alias-of'), + "Westmere-v2", + "Westmere-IBRS must be an alias") + + self.assertEquals(cpus["SandyBridge"].get('alias-of'), + "SandyBridge-v1", + "SandyBridge must be an alias") + self.assertEquals(cpus["SandyBridge-IBRS"].get('alias-of'), + "SandyBridge-v2", + "SandyBridge-IBRS must be an alias") + + self.assertEquals(cpus["IvyBridge"].get('alias-of'), + "IvyBridge-v1", + "IvyBridge must be an alias") + self.assertEquals(cpus["IvyBridge-IBRS"].get('alias-of'), + "IvyBridge-v2", + "IvyBridge-IBRS must be an alias") + + self.assertEquals(cpus["Skylake-Client"].get('alias-of'), + "Skylake-Client-v1", + "Skylake-Client must be an alias") + self.assertEquals(cpus["Skylake-Client-IBRS"].get('alias-of'), + "Skylake-Client-v2", + "Skylake-Client-IBRS must be an alias") + + self.assertEquals(cpus["Skylake-Server"].get('alias-of'), + "Skylake-Server-v1", + "Skylake-Server must be an alias") + self.assertEquals(cpus["Skylake-Server-IBRS"].get('alias-of'), + "Skylake-Server-v2", + "Skylake-Server-IBRS must be an alias") + + self.assertEquals(cpus["EPYC"].get('alias-of'), + "EPYC-v1", + "EPYC must be an alias") + self.assertEquals(cpus["EPYC-IBPB"].get('alias-of'), + "EPYC-v2", + "EPYC-IBPB must be an alias") + + self.validate_aliases(cpus) + + def test_none_alias(self): + """Check if unversioned CPU model is an alias pointing to some ver= sion""" + self.vm.add_args('-S') + self.vm.set_machine('none') + self.vm.launch() + + cpus =3D dict((m['name'], m) for m in self.vm.command('query-cpu-d= efinitions')) + + self.assertFalse(cpus['Cascadelake-Server']['static'], + 'unversioned Cascadelake-Server CPU model must no= t be static') + self.assertTrue(re.match('Cascadelake-Server-v[0-9]+', cpus['Casca= delake-Server']['alias-of']), + 'Cascadelake-Server must be an alias of versioned = CPU model') + self.assertNotIn('alias-of', cpus['Cascadelake-Server-v1'], + 'Cascadelake-Server-v1 must not be an alias') + + self.assertFalse(cpus['qemu64']['static'], + 'unversioned qemu64 CPU model must not be static') + self.assertTrue(re.match('qemu64-v[0-9]+', cpus['qemu64']['alias-o= f']), + 'qemu64 must be an alias of versioned CPU model') + self.assertNotIn('alias-of', cpus['qemu64-v1'], + 'qemu64-v1 must not be an alias') + + self.validate_aliases(cpus) --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562179773; cv=none; d=zoho.com; s=zohoarc; b=jAD7DzzAzlaGOG5XiEOjr9MZLOY5ojtJtRe1JDi3sfSQGuHJLmjNU+moeuFUV/5bgpb26jVjayRRD3TQIN484ckvVIDM6eJP47zYYqjk6nNHldGn+4NfS/oFtIAS+Nqj/m0X3n/gqCfr/IonQiu8MJRD5zFMF+sPJMNySvsg5dU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179773; h=Content-Type:Content-Transfer-Encoding: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=7SrTmbQQbldnJsvdMavIoujAtnvbzg/FaqjKfAMhy8g=; b=iu6DjhLOUppJw9TS/k72W8EdNoyNLEbhT7JCjaDSPzsHjKOv625emUeNJPVhj6bgxZ49irxWxhvDqf3oI87vzDDOtSUCAEoldyzBzvvSdowGqXoo9LO6LBCyGdayT93b0GyQiK3vvyMXd97vw8W5diZXFnYCS004LpbwlsJMMCU= 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 1562179773834671.7966077775807; Wed, 3 Jul 2019 11:49:33 -0700 (PDT) Received: from localhost ([::1]:38548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikJr-0001Vh-UF for importer@patchew.org; Wed, 03 Jul 2019 14:49:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56932) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgl-0005Pu-FI for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgk-00015L-Eg for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45880) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgk-00014g-9c for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:02 -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 9475B8553A; Wed, 3 Jul 2019 18:09:01 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5070E457C7; Wed, 3 Jul 2019 18:08:59 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:22 -0300 Message-Id: <20190703180726.31267-40-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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.28]); Wed, 03 Jul 2019 18:09:01 +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 v4 39/43] docs: Deprecate CPU model runnability guarantees 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Document that CPU model runnability guarantees won't apply to unversioned CPU models anymore. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-9-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- qemu-deprecated.texi | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 9cba82d5ec..18f85f70e1 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -276,3 +276,22 @@ Note that if you are exposing the export via /dev/nbd0= , it is easier to just export the entire image and then mount only /dev/nbd0p1 than it is to reinvoke @command{qemu-nbd -c /dev/nbd0} limited to just a subset of the image. + +@section Backwards compatibility + +@subsection Runnability guarantee of CPU models (since 4.1.0) + +Previous versions of QEMU never changed existing CPU models in +ways that introduced additional host software or hardware +requirements to the VM. This allowed management software to +safely change the machine type of an existing VM without +introducing new requirements ("runnability guarantee"). This +prevented CPU models from being updated to include CPU +vulnerability mitigations, leaving guests vulnerable in the +default configuration. + +The CPU model runnability guarantee won't apply anymore to +existing CPU models. Management software that needs runnability +guarantees must resolve the CPU model aliases using te +``alias-of'' field returned by the ``query-cpu-definitions'' QMP +command. --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562178796; cv=none; d=zoho.com; s=zohoarc; b=Lhsusw6mBGWXEKvktVNpmXSf6moKcEpMzVwjyjEqaWRAEe/iqiQ0dWQxHPMXzB7mxLfArZgMuHlqfNO8JeIWcfIbHCorzxSKHHvylVlxWxUhVjeL/Rra597hashQ6wZ4M/YMsmxUVXxBS6viCoPtE3owIBcK4XHXOfuLh7V/4/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178796; h=Content-Type:Content-Transfer-Encoding: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=AaKvqfgtvShz5evzV5gRNSWzzwYnjcPxW/UK+3/rq9Y=; b=mc5Ua/P9CqtgSyhHZ3mZ2YHdQKD6IXRsMrXQ6EjCMxIy8scuG+TaThJx5FfYRylG+olXrTMTsaIRMCFzuw9RXDuUxgXJ+WnIQEZj8YC+ub0f92IQIud9pDbZoChjWRiivb4mgIebcjb9SfI3y7ratyn8S+P5mGNCkEMrX/qp7xQ= 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 1562178796018224.3794200885569; Wed, 3 Jul 2019 11:33:16 -0700 (PDT) Received: from localhost ([::1]:38430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik42-0001mb-SA for importer@patchew.org; Wed, 03 Jul 2019 14:33:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56954) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgn-0005W8-Rk for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgm-00017B-JH for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgm-00016c-Ao for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:04 -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 966BF44BD1; Wed, 3 Jul 2019 18:09:03 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C69258C9D; Wed, 3 Jul 2019 18:09:02 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:23 -0300 Message-Id: <20190703180726.31267-41-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-1-ehabkost@redhat.com> MIME-Version: 1.0 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]); Wed, 03 Jul 2019 18:09:03 +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 v4 40/43] i386: Add Cascadelake-Server-v2 CPU model 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add new version of Cascadelake-Server CPU model, setting stepping=3D5 and enabling the IA32_ARCH_CAPABILITIES MSR with some flags. The new feature will introduce a new host software requirement, breaking our CPU model runnability promises. This means we can't enable the new CPU model version by default in QEMU 4.1, because management software isn't ready yet to resolve CPU model aliases. This is why "pc-*-4.1" will keep returning Cascadelake-Server-v1 if "-cpu Cascadelake-Server" is specified. Includes a test case to ensure the right combinations of machine-type + CPU model + command-line feature flags will work as expected. Signed-off-by: Eduardo Habkost Message-Id: <20190628002844.24894-10-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 14 +++++ tests/acceptance/x86_cpu_model_versions.py | 73 ++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9b16cffb22..0298396a91 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2343,6 +2343,20 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_6_EAX_ARAT, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon Processor (Cascadelake)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { .version =3D 2, + .props =3D (PropValue[]) { + { "stepping", "5" }, + { "arch-capabilities", "on" }, + { "rdctl-no", "on" }, + { "ibrs-all", "on" }, + { "skip-l1dfl-vmentry", "on" }, + { /* end of list */ } + }, + }, + { /* end of list */ } + } }, { .name =3D "Icelake-Client", diff --git a/tests/acceptance/x86_cpu_model_versions.py b/tests/acceptance/= x86_cpu_model_versions.py index 165c0c7601..1c9fd6a56e 100644 --- a/tests/acceptance/x86_cpu_model_versions.py +++ b/tests/acceptance/x86_cpu_model_versions.py @@ -25,6 +25,10 @@ import avocado_qemu import re =20 +def get_cpu_prop(vm, prop): + cpu_path =3D vm.command('query-cpus')[0].get('qom_path') + return vm.command('qom-get', path=3Dcpu_path, property=3Dprop) + class X86CPUModelAliases(avocado_qemu.Test): """ Validation of PC CPU model versions and CPU model aliases @@ -229,3 +233,72 @@ class X86CPUModelAliases(avocado_qemu.Test): 'qemu64-v1 must not be an alias') =20 self.validate_aliases(cpus) + + def test_Cascadelake_arch_capabilities_result(self): + # machine-type only: + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.1') + vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=3Don,chec= k=3Doff,enforce=3Doff') + vm.launch() + self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.1 + Cascadelake-Server should not ha= ve arch-capabilities') + + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.0') + vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=3Don,chec= k=3Doff,enforce=3Doff') + vm.launch() + self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.0 + Cascadelake-Server should not ha= ve arch-capabilities') + + # command line must override machine-type if CPU model is not vers= ioned: + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.0') + vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=3Don,chec= k=3Doff,enforce=3Doff,+arch-capabilities') + vm.launch() + self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.0 + Cascadelake-Server,+arch-capabili= ties should have arch-capabilities') + + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.1') + vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=3Don,chec= k=3Doff,enforce=3Doff,-arch-capabilities') + vm.launch() + self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.1 + Cascadelake-Server,-arch-capabil= ities should not have arch-capabilities') + + # versioned CPU model overrides machine-type: + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.0') + vm.add_args('-cpu', 'Cascadelake-Server-v1,x-force-features=3Don,c= heck=3Doff,enforce=3Doff') + vm.launch() + self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.1 + Cascadelake-Server-v1 should not= have arch-capabilities') + + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.0') + vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=3Don,c= heck=3Doff,enforce=3Doff') + vm.launch() + self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.1 + Cascadelake-Server-v1 should hav= e arch-capabilities') + + # command line must override machine-type and versioned CPU model: + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.0') + vm.add_args('-cpu', 'Cascadelake-Server,x-force-features=3Don,chec= k=3Doff,enforce=3Doff,+arch-capabilities') + vm.launch() + self.assertTrue(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.0 + Cascadelake-Server-v1,+arch-capa= bilities should have arch-capabilities') + + vm =3D self.get_vm() + vm.add_args('-S') + vm.set_machine('pc-i440fx-4.1') + vm.add_args('-cpu', 'Cascadelake-Server-v2,x-force-features=3Don,c= heck=3Doff,enforce=3Doff,-arch-capabilities') + vm.launch() + self.assertFalse(get_cpu_prop(vm, 'arch-capabilities'), + 'pc-i440fx-4.1 + Cascadelake-Server-v2,-arch-capa= bilities should not have arch-capabilities') --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562180016; cv=none; d=zoho.com; s=zohoarc; b=gYilNBYf0yWqrRnex2GVMGz8xWzMf4MWl3boRZ9ZWCL2rrPtJp7JSfV791+v2C456+r+8rRzYne8H21Idd/11crRz7WFEg84iTdKpleTYrFsbe0fDqd4IYe428fAZJraSLEYHQaTaA9hfA0ijlDX+eKlJjJ3ksFKCLjgM0spzSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562180016; h=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=43cI6P0Fl0vTLQgOWBjPUvyKgk4aLZBb5InP3a90tR4=; b=mds2WxrZO57D/k5pDnhBLhw7byjsItvjc5qkzE2POJG5M/ZVPStM87YgUfno9cX/s/3UGIu0N6F1O3dP5frT+jTi5f4fYlPrw+VABvKYpBFmC7Y57qFs2x19WHEjUpviCTrZoucxBAOQAXgiSjj5I4TiHduiFZP4ohyCB1FnD5E= 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 156218001675525.64133155386446; Wed, 3 Jul 2019 11:53:36 -0700 (PDT) Received: from localhost ([::1]:38574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikNo-0005G0-Qr for importer@patchew.org; Wed, 03 Jul 2019 14:53:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56980) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgs-0005hN-4t for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgr-0001B5-2a for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36484) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgq-0001Ai-TY for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:09 -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 36EBCC057E65; Wed, 3 Jul 2019 18:09:08 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA10918248; Wed, 3 Jul 2019 18:09:05 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:24 -0300 Message-Id: <20190703180726.31267-42-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.32]); Wed, 03 Jul 2019 18:09: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 v4 41/43] numa: Make deprecation warnings conditional on !qtest_enabled() 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: , 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" This will help us avoid spurious warnings during "make check". Note that this will silence the warnings generated by tests/numa-test, but not the ones generated by tests/bios-tables-test. We still need to change tests/bios-tables-test to use "-numa ...,memdev=3D" to silence these warnings. Signed-off-by: Eduardo Habkost Message-Id: <20190702215726.23661-1-ehabkost@redhat.com> --- numa.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/numa.c b/numa.c index 48fd43ecc6..2fcc99e154 100644 --- a/numa.c +++ b/numa.c @@ -35,6 +35,7 @@ #include "qapi/qapi-visit-misc.h" #include "hw/boards.h" #include "sysemu/hostmem.h" +#include "sysemu/qtest.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/memory-device.h" #include "qemu/option.h" @@ -122,8 +123,10 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *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 (!qtest_enabled()) { + warn_report("Parameter -numa node,mem is deprecated," + " use -numa node,memdev instead"); + } } if (node->has_memdev) { Object *o; @@ -410,9 +413,11 @@ 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"); + if (!qtest_enabled()) { + warn_report("Default splitting of RAM between nodes is dep= recated," + " Use '-numa node,memdev' to explictly define = RAM" + " allocation per node"); + } } =20 numa_total =3D 0; --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562179755; cv=none; d=zoho.com; s=zohoarc; b=J/bc4hCtinAcy09FNQwh5fiFAoOKcEnUkkK7T+1m8fz86MEcF5oyJ6eWznNT4HnAvW0CQ4hWB+Dpio65y/uJ5NBN0yQzwEBYwhNI+FGhqTJcXFKjqDrDWwAX+Rhqqd0opp0X0waJM8wrIyiw0H4FMJ1ej7ZzqtPmZYoSM6kDmMQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562179755; 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=QJJGea3pFdrSQiMGoV1uIlsJONCpHvX+5mvfMqDnWYI=; b=cgTrAuE/YM7v/x/tlZ8JSviHkyyQBxrJWaQ4AE0w7tXFH8gKY80KA0IA01dK1RDgS76EvTnlNtLC5Ay7iOxYMMfC2iacCZaCR5ancRB6pp99KwBUUu3HaGkVpVnrWbgScL1jIJOngTBYtRQKA09UdK/Fh7AGLFyIAByGKk7Zghk= 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 1562179755996798.8567693091774; Wed, 3 Jul 2019 11:49:15 -0700 (PDT) Received: from localhost ([::1]:38546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hikJb-0001M1-G1 for importer@patchew.org; Wed, 03 Jul 2019 14:49:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56998) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgu-0005km-48 for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgt-0001Dj-2j for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgs-0001DO-Te for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:11 -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 3C8EE88307; Wed, 3 Jul 2019 18:09:10 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C202A1391A; Wed, 3 Jul 2019 18:09:09 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:25 -0300 Message-Id: <20190703180726.31267-43-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.28]); Wed, 03 Jul 2019 18:09:10 +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 v4 42/43] numa: allow memory-less nodes when using memdev as backend 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: Igor Mammedov 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 fails to start if memory-less node is present when memdev is used qemu-system-x86_64 -object memory-backend-ram,id=3Dram0,size=3D128M \ -numa node -numa node,memdev=3Dram0 with error: "memdev option must be specified for either all or no nodes" which works as expected if legacy 'mem' is used. Fix check to make memory-less nodes valid when memdev option is used but still disallow mix of mem and memdev options. Signed-off-by: Igor Mammedov Message-Id: <20190702140745.27767-2-imammedo@redhat.com> Signed-off-by: Eduardo Habkost --- numa.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/numa.c b/numa.c index 2fcc99e154..4988f25cd4 100644 --- a/numa.c +++ b/numa.c @@ -49,7 +49,8 @@ QemuOptsList qemu_numa_opts =3D { .desc =3D { { 0 } } /* validated with OptsVisitor */ }; =20 -static int have_memdevs =3D -1; +static int have_memdevs; +static int have_mem; static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. * For all nodes, nodeid < max_numa_nodeid */ @@ -107,17 +108,11 @@ static void parse_numa_node(MachineState *ms, NumaNod= eOptions *node, } } =20 - if (node->has_mem && node->has_memdev) { - error_setg(errp, "cannot specify both mem=3D and memdev=3D"); - return; - } - - if (have_memdevs =3D=3D -1) { - have_memdevs =3D node->has_memdev; - } - if (node->has_memdev !=3D have_memdevs) { - error_setg(errp, "memdev option must be specified for either " - "all or no nodes"); + have_memdevs =3D have_memdevs ? : node->has_memdev; + have_mem =3D have_mem ? : node->has_mem; + if ((node->has_mem && have_memdevs) || (node->has_memdev && have_mem))= { + error_setg(errp, "numa configuration should use either mem=3D or m= emdev=3D," + "mixing both is not allowed"); return; } =20 --=20 2.18.0.rc1.1.g3f1ff2140 From nobody Sat May 18 04:46:15 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=1562178974; cv=none; d=zoho.com; s=zohoarc; b=LhP+j0ibjNI0NFIjCMRhL7CFEBJkuwpknfKGRVssKskRKnOCRy0NrCIOF1SoWvXcbyvDS7IUpkNQ6Hdbfau6JiiO+jlkQvzhlUa9FRHeZ8eA2xYruh93ukeiZJDh9FgAkl72K9j5rRgaPc6BmYbodn/+xGubbLkeLT1GBf/p0/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562178974; 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=V1NUNjHLnMz7jXLD/Gm+uPY0UOxDA9xZv73fl5HZsNI=; b=QK0QJkntPEovnkILBd0bQSpm/1uDqv6XpoZr1tSMGbpX92fKjX0RCGN4PavGqeyHD7jBEf9A0utW/Ic4kkbbji5cMTRN9Pq0plsN3oxYohcj14gsahe91C4zTxKsYicR7LuEnTDU5p+4kVK3Hy83NVtk/hk+d/KuW5+MxP/xkY8= 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 15621789741008.77535016619413; Wed, 3 Jul 2019 11:36:14 -0700 (PDT) Received: from localhost ([::1]:38458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hik70-0005Zl-5V for importer@patchew.org; Wed, 03 Jul 2019 14:36:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57018) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hijgy-0005mo-Dk for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hijgw-0001G2-GG for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hijgv-0001El-0T for qemu-devel@nongnu.org; Wed, 03 Jul 2019 14:09: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 438872F8BC4; Wed, 3 Jul 2019 18:09:12 +0000 (UTC) Received: from localhost (ovpn-116-30.gru2.redhat.com [10.97.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3A405877D; Wed, 3 Jul 2019 18:09:11 +0000 (UTC) From: Eduardo Habkost To: Peter Maydell , Paolo Bonzini , qemu-devel@nongnu.org, Marcel Apfelbaum , Richard Henderson Date: Wed, 3 Jul 2019 15:07:26 -0300 Message-Id: <20190703180726.31267-44-ehabkost@redhat.com> In-Reply-To: <20190703180726.31267-1-ehabkost@redhat.com> References: <20190703180726.31267-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.38]); Wed, 03 Jul 2019 18:09:12 +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 v4 43/43] tests: use -numa memdev option in tests instead of legacy 'mem' 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: Igor Mammedov 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 it will test preferred memdev option more extensively and remove undesired deprecation warnings during 'make check' Signed-off-by: Igor Mammedov Message-Id: <20190702140745.27767-3-imammedo@redhat.com> [ehabkost: remove numa-test.c changes] Signed-off-by: Eduardo Habkost --- tests/bios-tables-test.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 0ce55182f2..d863233fe9 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -688,6 +688,8 @@ static void test_acpi_q35_tcg_mmio64(void) }; =20 test_acpi_one("-m 128M,slots=3D1,maxmem=3D2G " + "-object memory-backend-ram,id=3Dram0,size=3D128M " + "-numa node,memdev=3Dram0 " "-device pci-testdev,membar=3D2G", &data); free_test_data(&data); @@ -701,7 +703,9 @@ static void test_acpi_piix4_tcg_cphp(void) data.machine =3D MACHINE_PC; data.variant =3D ".cphp"; test_acpi_one("-smp 2,cores=3D3,sockets=3D2,maxcpus=3D6" - " -numa node -numa node" + " -object memory-backend-ram,id=3Dram0,size=3D64M" + " -object memory-backend-ram,id=3Dram1,size=3D64M" + " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); @@ -715,7 +719,9 @@ static void test_acpi_q35_tcg_cphp(void) data.machine =3D MACHINE_Q35; data.variant =3D ".cphp"; test_acpi_one(" -smp 2,cores=3D3,sockets=3D2,maxcpus=3D6" - " -numa node -numa node" + " -object memory-backend-ram,id=3Dram0,size=3D64M" + " -object memory-backend-ram,id=3Dram1,size=3D64M" + " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); @@ -766,7 +772,9 @@ static void test_acpi_q35_tcg_memhp(void) data.machine =3D MACHINE_Q35; data.variant =3D ".memhp"; test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G" - " -numa node -numa node" + " -object memory-backend-ram,id=3Dram0,size=3D64M" + " -object memory-backend-ram,id=3Dram1,size=3D64M" + " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); @@ -780,7 +788,9 @@ static void test_acpi_piix4_tcg_memhp(void) data.machine =3D MACHINE_PC; data.variant =3D ".memhp"; test_acpi_one(" -m 128,slots=3D3,maxmem=3D1G" - " -numa node -numa node" + " -object memory-backend-ram,id=3Dram0,size=3D64M" + " -object memory-backend-ram,id=3Dram1,size=3D64M" + " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" " -numa dist,src=3D0,dst=3D1,val=3D21", &data); free_test_data(&data); @@ -793,7 +803,8 @@ static void test_acpi_q35_tcg_numamem(void) memset(&data, 0, sizeof(data)); data.machine =3D MACHINE_Q35; data.variant =3D ".numamem"; - test_acpi_one(" -numa node -numa node,mem=3D128", &data); + test_acpi_one(" -object memory-backend-ram,id=3Dram0,size=3D128M" + " -numa node -numa node,memdev=3Dram0", &data); free_test_data(&data); } =20 @@ -804,7 +815,8 @@ static void test_acpi_piix4_tcg_numamem(void) memset(&data, 0, sizeof(data)); data.machine =3D MACHINE_PC; data.variant =3D ".numamem"; - test_acpi_one(" -numa node -numa node,mem=3D128", &data); + test_acpi_one(" -object memory-backend-ram,id=3Dram0,size=3D128M" + " -numa node -numa node,memdev=3Dram0", &data); free_test_data(&data); } =20 @@ -818,17 +830,21 @@ static void test_acpi_tcg_dimm_pxm(const char *machin= e) test_acpi_one(" -machine nvdimm=3Don,nvdimm-persistence=3Dcpu" " -smp 4,sockets=3D4" " -m 128M,slots=3D3,maxmem=3D1G" - " -numa node,mem=3D32M,nodeid=3D0" - " -numa node,mem=3D32M,nodeid=3D1" - " -numa node,mem=3D32M,nodeid=3D2" - " -numa node,mem=3D32M,nodeid=3D3" + " -object memory-backend-ram,id=3Dram0,size=3D32M" + " -object memory-backend-ram,id=3Dram1,size=3D32M" + " -object memory-backend-ram,id=3Dram2,size=3D32M" + " -object memory-backend-ram,id=3Dram3,size=3D32M" + " -numa node,memdev=3Dram0,nodeid=3D0" + " -numa node,memdev=3Dram1,nodeid=3D1" + " -numa node,memdev=3Dram2,nodeid=3D2" + " -numa node,memdev=3Dram3,nodeid=3D3" " -numa cpu,node-id=3D0,socket-id=3D0" " -numa cpu,node-id=3D1,socket-id=3D1" " -numa cpu,node-id=3D2,socket-id=3D2" " -numa cpu,node-id=3D3,socket-id=3D3" - " -object memory-backend-ram,id=3Dram0,size=3D128M" + " -object memory-backend-ram,id=3Dram4,size=3D128M" " -object memory-backend-ram,id=3Dnvm0,size=3D128M" - " -device pc-dimm,id=3Ddimm0,memdev=3Dram0,node=3D1" + " -device pc-dimm,id=3Ddimm0,memdev=3Dram4,node=3D1" " -device nvdimm,id=3Ddimm1,memdev=3Dnvm0,node=3D2", &data); free_test_data(&data); --=20 2.18.0.rc1.1.g3f1ff2140