From nobody Fri Apr 26 18:41:02 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=1570532292; cv=none; d=zoho.com; s=zohoarc; b=dZMeyXUJZGGI5jP926wR1sUDmAdgMSME6w4Ch1Bs4O9hlkt0NZRWTda98YQNY5qcyr99zBgiGNGfU1Rk7S4dL4z+4V8A/c1AXcw+YDZaB2fjN/MNwERQJu8GfVbTgUZeRovGDK7aczJ4Obw+ezY4xHVKV5VZqVD430rNQiZo7UY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570532292; 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=V3QlmvJWuUl+vIR/S2oVxPKLV4tlamXv6WLSzciPmQg=; b=MCXGg2bBNT+RYZOZ2cgr+xj/Zv/Br3pyGPtGekClIUCKAFWFQZ26uRnI0TrVIG7NoDv6tluG+84S5NZSWDHAdX9zwrVAA0AtmTvJ6HKagqYsVz6HaNDaQeDGCVMA0UfLs6Cm+IBT9Xr3HO6U6mlqc4ltB70ggpJ98EM7EbV9qLw= 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 1570532292707620.6764090398364; Tue, 8 Oct 2019 03:58:12 -0700 (PDT) Received: from localhost ([::1]:53656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHnBz-0006Q2-J2 for importer@patchew.org; Tue, 08 Oct 2019 06:58:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46602) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn7P-0001sL-AR for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHn7N-0003kz-Nj for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49714) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHn7N-0003kI-Hx for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:25 -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 C89E5300CA4B; Tue, 8 Oct 2019 10:53:24 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 062DA5D9C9; Tue, 8 Oct 2019 10:53:22 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Subject: [PATCH 1/4] fw_cfg: bump file slots to 40 Date: Tue, 8 Oct 2019 12:52:56 +0200 Message-Id: <20191008105259.5378-2-lersek@redhat.com> In-Reply-To: <20191008105259.5378-1-lersek@redhat.com> References: <20191008105259.5378-1-lersek@redhat.com> MIME-Version: 1.0 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.42]); Tue, 08 Oct 2019 10:53:24 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Eduardo Habkost , Gerd Hoffmann , Paolo Bonzini , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" I count approximately 30 additions of named fw_cfg files, with fw_cfg_add_file() / fw_cfg_add_file_callback() / fw_cfg_modify_file(). On top of those, vgaroms/* and genroms/* files are added with invocations of rom_add_vga() and rom_add_option(). While it's pretty unlikely that a QEMU cmdline causes all of those named files to be added simultaneously, it now seems prudent to bump FW_CFG_FILE_SLOTS_DFLT from 32 to a higher value. Increment it by 8. Cc: Eduardo Habkost Cc: Gerd Hoffmann Cc: Igor Mammedov Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Philippe Mathieu-Daud=C3=A9 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek --- hw/core/machine.c | 2 ++ hw/nvram/fw_cfg.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1689ad3bf8af..fefc9e1f0dd0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -29,6 +29,8 @@ =20 GlobalProperty hw_compat_4_1[] =3D { { "virtio-pci", "x-pcie-flr-init", "off" }, + { "fw_cfg_mem", "x-file-slots", "0x20" }, + { "fw_cfg_io", "x-file-slots", "0x20" }, }; const size_t hw_compat_4_1_len =3D G_N_ELEMENTS(hw_compat_4_1); =20 diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 7dc3ac378ee0..cd785fad93b1 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -40,7 +40,7 @@ #include "qemu/cutils.h" #include "qapi/error.h" =20 -#define FW_CFG_FILE_SLOTS_DFLT 0x20 +#define FW_CFG_FILE_SLOTS_DFLT 0x28 =20 /* FW_CFG_VERSION bits */ #define FW_CFG_VERSION 0x01 --=20 2.19.1.3.g30247aa5d201 From nobody Fri Apr 26 18:41:02 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=1570532165; cv=none; d=zoho.com; s=zohoarc; b=FdnB0E41mgulWNbpqBLV6IGCtYHt2DGPr/GetWwnqjN9SSUdXIVms4y/lhmrj8ZJgqtsxAMyB+cH3NI1cEtdz6ovsMBOGUQ5PyMvWK1mo4DqwG2ipZcXYbmYVJ1XvI5W6hTKutoBgeAppQO+guVouNEgRNIXwRj/CQ+3njy59oE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570532165; h=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=30e6ndF5XGL0jGhB2RII/pukE41gLECpqmvocC41hcU=; b=WWCuhrIAuZsJm48fmpZIcvrt2TimbG3WAjOcU188OfQ+/gDXwZ+B7h/86HiTpTPwFMyo1svGrVFGYrcTrOACLkVu7q84Dq3ufg2e9lwxmZbm045B7ar7YYYV0iYieX3AqNEfV773BafuGjxsA76bsMiKFGqhiKbAtfF1RLBQFq4= 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 1570532165359321.58136645775585; Tue, 8 Oct 2019 03:56:05 -0700 (PDT) Received: from localhost ([::1]:53619 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn9s-0003YU-Vf for importer@patchew.org; Tue, 08 Oct 2019 06:56:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46627) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn7T-0001tD-PF for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHn7P-0003nt-J3 for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48220) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHn7P-0003m6-Au for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53: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 90F2D30BEBE6; Tue, 8 Oct 2019 10:53:26 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FC4B5D9C9; Tue, 8 Oct 2019 10:53:24 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Subject: [PATCH 2/4] target/i386: remove useless enable_compat_apic_id_mode() prototype Date: Tue, 8 Oct 2019 12:52:57 +0200 Message-Id: <20191008105259.5378-3-lersek@redhat.com> In-Reply-To: <20191008105259.5378-1-lersek@redhat.com> References: <20191008105259.5378-1-lersek@redhat.com> MIME-Version: 1.0 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]); Tue, 08 Oct 2019 10:53:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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 , Richard Henderson , Eduardo Habkost , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The enable_compat_apic_id_mode() function definition was removed earlier; there are no callers left. Remove the function declaration too. Cc: Eduardo Habkost Cc: Igor Mammedov Cc: Paolo Bonzini Cc: Richard Henderson Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/i386/cpu.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index eaa5395aa539..c9ab1a367939 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2126,8 +2126,6 @@ void x86_cpu_set_default_version(X86CPUVersion versio= n); /* Return name of 32-bit register, from a R_* constant */ const char *get_register_name_32(unsigned int reg); =20 -void enable_compat_apic_id_mode(void); - #define APIC_DEFAULT_ADDRESS 0xfee00000 #define APIC_SPACE_SIZE 0x100000 =20 --=20 2.19.1.3.g30247aa5d201 From nobody Fri Apr 26 18:41:02 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=1570532172; cv=none; d=zoho.com; s=zohoarc; b=MU7SrAELXRrSeHHUAC732vvpNpKGKFYn19sXXnLxzApJjsQhRIGy8ABE4g0hRzS4PN0ZJMAc8AmstVugb/IcZadpbgQkZe4MA1twMd6fif3un95spw7HMgeLFTsDLkfDgyPHrxT1DEHky3zbuQ465ufo5PQ/k2dSLsCsbJSc1cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570532172; 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=ZunLB50rhgNq23yvHBJlU14EWnBcwT57SPOh7kBdHJE=; b=RLk3rDuD5WQeA1ipAV7feIGmucSDTngZbrDm6/5JHitV3Fo3G0NWbEYcC7+517tOJ91IfYHKvNK8Dn4J2vXu34Dze0XwUUUvRJIv6/gtz+ToIawdD603r7On5No4es2weQS/hrsjfIHWLlx2Q2MgumgWZJdDtyr7mWhyjv8Pi00= 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 1570532172268897.5339348907686; Tue, 8 Oct 2019 03:56:12 -0700 (PDT) Received: from localhost ([::1]:53622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn9z-0003o1-B6 for importer@patchew.org; Tue, 08 Oct 2019 06:56:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46640) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn7X-0001tc-2N for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHn7V-0003pp-KH for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHn7U-0003pO-7O for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:32 -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 77EB430860A5; Tue, 8 Oct 2019 10:53:31 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id EB10D5D9C9; Tue, 8 Oct 2019 10:53:26 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Subject: [PATCH 3/4] hw/i386: add facility to expose CPU topology over fw-cfg Date: Tue, 8 Oct 2019 12:52:58 +0200 Message-Id: <20191008105259.5378-4-lersek@redhat.com> In-Reply-To: <20191008105259.5378-1-lersek@redhat.com> References: <20191008105259.5378-1-lersek@redhat.com> MIME-Version: 1.0 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]); Tue, 08 Oct 2019 10:53:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" FW_CFG_MAX_CPUS exposes the (exclusive) maximum APIC ID to guest firmware, due to historical reasons. That value is not useful to edk2, however. For supporting VCPU hotplug, edk2 needs: - the boot CPU count (already exposed in FW_CFG_NB_CPUS), - and the maximum foreseen CPU count (tracked in "MachineState.smp.max_cpus", but not currently exposed). Add a new fw-cfg file to expose "max_cpus". While at it, expose the rest of the topology too (die / core / thread counts), because I expect that the VCPU hotplug feature for OVMF will ultimately need those too, and the data size is not large. This is slightly complicated by the fact that the die count is specific to PCMachineState, but fw_cfg_arch_create() intends to be PC-independent (see commit 149c50cabcc4). For now, the feature is temporarily disabled. Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Igor Mammedov Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Philippe Mathieu-Daud=C3=A9 Cc: Richard Henderson Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/fw_cfg.h | 30 +++++++++++++++++++++++++++++- hw/i386/fw_cfg.c | 26 ++++++++++++++++++++++++-- hw/i386/pc.c | 4 ++-- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h index e0856a376996..d742435b9793 100644 --- a/hw/i386/fw_cfg.h +++ b/hw/i386/fw_cfg.h @@ -18,9 +18,37 @@ #define FW_CFG_E820_TABLE (FW_CFG_ARCH_LOCAL + 3) #define FW_CFG_HPET (FW_CFG_ARCH_LOCAL + 4) =20 +/** + * FWCfgX86Topology: expose the X86 CPU topology to guest firmware over fw= -cfg. + * + * All fields have little-endian encoding. + * + * @dies: Number of dies per package (aka socket). Set it to 1 unless = the + * concrete MachineState subclass defines it differently. + * @cores: Corresponds to @CpuTopology.@cores. + * @threads: Corresponds to @CpuTopology.@threads. + * @max_cpus: Corresponds to @CpuTopology.@max_cpus. + * + * Firmware can derive the package (aka socket) count with the following + * formula: + * + * DIV_ROUND_UP(@max_cpus, @dies * @cores * @threads) + * + * Firmware can derive APIC ID field widths and offsets per the standard + * calculations in "include/hw/i386/topology.h". + */ +typedef struct FWCfgX86Topology { + uint32_t dies; + uint32_t cores; + uint32_t threads; + uint32_t max_cpus; +} QEMU_PACKED FWCfgX86Topology; + FWCfgState *fw_cfg_arch_create(MachineState *ms, uint16_t boot_cpus, - uint16_t apic_id_limit); + uint16_t apic_id_limit, + unsigned smp_dies, + bool expose_topology); void fw_cfg_build_smbios(MachineState *ms, FWCfgState *fw_cfg); void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); =20 diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 39b6bc60520c..33d09875014f 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -85,9 +85,26 @@ void fw_cfg_build_smbios(MachineState *ms, FWCfgState *f= w_cfg) } } =20 +static void fw_cfg_expose_topology(FWCfgState *fw_cfg, + unsigned dies, + unsigned cores, + unsigned threads, + unsigned max_cpus) +{ + FWCfgX86Topology *topo =3D g_new(FWCfgX86Topology, 1); + + topo->dies =3D cpu_to_le32(dies); + topo->cores =3D cpu_to_le32(cores); + topo->threads =3D cpu_to_le32(threads); + topo->max_cpus =3D cpu_to_le32(max_cpus); + fw_cfg_add_file(fw_cfg, "etc/x86-smp-topology", topo, sizeof *topo); +} + FWCfgState *fw_cfg_arch_create(MachineState *ms, - uint16_t boot_cpus, - uint16_t apic_id_limit) + uint16_t boot_cpus, + uint16_t apic_id_limit, + unsigned smp_dies, + bool expose_topology) { FWCfgState *fw_cfg; uint64_t *numa_fw_cfg; @@ -143,6 +160,11 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, (1 + apic_id_limit + nb_numa_nodes) * sizeof(*numa_fw_cfg)); =20 + if (expose_topology) { + fw_cfg_expose_topology(fw_cfg, smp_dies, ms->smp.cores, + ms->smp.threads, ms->smp.max_cpus); + } + return fw_cfg; } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bcda50efcc23..bb72b12edad2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1738,8 +1738,8 @@ void pc_memory_init(PCMachineState *pcms, option_rom_mr, 1); =20 - fw_cfg =3D fw_cfg_arch_create(machine, - pcms->boot_cpus, pcms->apic_id_limit); + fw_cfg =3D fw_cfg_arch_create(machine, pcms->boot_cpus, pcms->apic_id_= limit, + pcms->smp_dies, false); =20 rom_set_fw(fw_cfg); =20 --=20 2.19.1.3.g30247aa5d201 From nobody Fri Apr 26 18:41:02 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=1570532168; cv=none; d=zoho.com; s=zohoarc; b=i9EhXqJtMdZHb7eFBa3HHmWvJBVNU/feVJ4M96sWSY7pJoo9cgmhc8uvuIZ/lNCGWvL9sYGaI21i9A3GmhY6E7/6GOVBFODgwdhe8TxHNfk0bgZMlVx716wEoW9wfrhXBVlmA62Go38RB2gdGPBB0sVgPz931XtLnDc4AbLdj4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570532168; 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=tQlHaghetltla2fYDdO0tJNnOd0nmgmuWtwKX66scIk=; b=PXfObwqRaIQPVFi9cITvCcBwyyOjWRLI3kr9vHQlXGgZFaLXaISvvf8/AEqH0hYkxDBmAT3rOTc+ZcAjHMXaaiMzTA76DN86oyd+azKYyQeLw6LnQ/JzLNyKmKVWqLUT+vAw7QffB6HjB0Vsvsb7TiJ1uhZip7/aLeGYGAtWqlo= 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 1570532168405644.111567182314; Tue, 8 Oct 2019 03:56:08 -0700 (PDT) Received: from localhost ([::1]:53624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn9y-0003qC-GA for importer@patchew.org; Tue, 08 Oct 2019 06:56:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46659) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHn7b-0001uT-D0 for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHn7Z-0003ro-MJ for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHn7Z-0003rE-ER for qemu-devel@nongnu.org; Tue, 08 Oct 2019 06:53:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AD703175281; Tue, 8 Oct 2019 10:53:36 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 789375D9C9; Tue, 8 Oct 2019 10:53:34 +0000 (UTC) From: Laszlo Ersek To: qemu devel list Subject: [PATCH 4/4] hw/i386/pc: expose CPU topology over fw-cfg Date: Tue, 8 Oct 2019 12:52:59 +0200 Message-Id: <20191008105259.5378-5-lersek@redhat.com> In-Reply-To: <20191008105259.5378-1-lersek@redhat.com> References: <20191008105259.5378-1-lersek@redhat.com> MIME-Version: 1.0 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]); Tue, 08 Oct 2019 10:53:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Eduardo Habkost , "Michael S. Tsirkin" , Paolo Bonzini , Igor Mammedov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Enable the small feature added in the last patch on 4.2+ PC machine types. Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Igor Mammedov Cc: Marcel Apfelbaum Cc: Paolo Bonzini Cc: Philippe Mathieu-Daud=C3=A9 Cc: Richard Henderson Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek --- include/hw/i386/pc.h | 3 +++ hw/i386/pc.c | 3 ++- hw/i386/pc_piix.c | 2 ++ hw/i386/pc_q35.c | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 6df4f4b6fbe7..96af441453bc 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -144,6 +144,9 @@ typedef struct PCMachineClass { =20 /* Enables contiguous-apic-ID mode */ bool compat_apic_id_mode; + + /* expose x86 CPU topology over fw_cfg */ + bool fwcfg_topology; } PCMachineClass; =20 #define TYPE_PC_MACHINE "generic-pc-machine" diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bb72b12edad2..12b13ba0e1c5 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1739,7 +1739,7 @@ void pc_memory_init(PCMachineState *pcms, 1); =20 fw_cfg =3D fw_cfg_arch_create(machine, pcms->boot_cpus, pcms->apic_id_= limit, - pcms->smp_dies, false); + pcms->smp_dies, pcmc->fwcfg_topology); =20 rom_set_fw(fw_cfg); =20 @@ -2798,6 +2798,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) pcmc->save_tsc_khz =3D true; pcmc->linuxboot_dma_enabled =3D true; pcmc->pvh_enabled =3D true; + pcmc->fwcfg_topology =3D true; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D pc_get_hotplug_handler; mc->hotplug_allowed =3D pc_hotplug_allowed; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6824b72124de..7fb87452889b 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -445,9 +445,11 @@ DEFINE_I440FX_MACHINE(v4_2, "pc-i440fx-4.2", NULL, =20 static void pc_i440fx_4_1_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_i440fx_4_2_machine_options(m); m->alias =3D NULL; m->is_default =3D 0; + pcmc->fwcfg_topology =3D false; compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len); compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 8fad20f3146a..3ec45659da02 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -377,8 +377,10 @@ DEFINE_Q35_MACHINE(v4_2, "pc-q35-4.2", NULL, =20 static void pc_q35_4_1_machine_options(MachineClass *m) { + PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_4_2_machine_options(m); m->alias =3D NULL; + pcmc->fwcfg_topology =3D false; compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len); compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len); } --=20 2.19.1.3.g30247aa5d201