From patchwork Wed Nov 16 14:17:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 695591 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tJmc46600z9t2D for ; Thu, 17 Nov 2016 01:19:48 +1100 (AEDT) Received: from localhost ([::1]:52810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c713v-0000Po-V7 for incoming@patchwork.ozlabs.org; Wed, 16 Nov 2016 09:19:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c712a-0007yw-43 for qemu-devel@nongnu.org; Wed, 16 Nov 2016 09:18:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c712X-0007yc-46 for qemu-devel@nongnu.org; Wed, 16 Nov 2016 09:18:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35850) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c712W-0007wt-RW for qemu-devel@nongnu.org; Wed, 16 Nov 2016 09:18:17 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2720315561; Wed, 16 Nov 2016 14:18:16 +0000 (UTC) Received: from localhost (ovpn-116-133.phx2.redhat.com [10.3.116.133]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAGEIFK5006212; Wed, 16 Nov 2016 09:18:15 -0500 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Date: Wed, 16 Nov 2016 12:17:34 -0200 Message-Id: <1479305856-32556-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1479305856-32556-1-git-send-email-ehabkost@redhat.com> References: <1479305856-32556-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 16 Nov 2016 14:18:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] Revert "pc: Add 'etc/boot-cpus' fw_cfg file for machine with more than 255 CPUs" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcel Apfelbaum , Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov This reverts commit 080ac219cc7d9c55adf925c3545b7450055ad625. Legacy FW_CFG_NB_CPUS will be reused instead of 'etc/boot-cpus' fw_cfg file since it does the same and there is no point to maintaing duplicate guest ABI, if it can be helped. Signed-off-by: Igor Mammedov Message-Id: <1479212236-183810-2-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 44 +++++++++++++++----------------------------- include/hw/i386/pc.h | 2 -- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index a9b1950..c227ead 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1086,6 +1086,17 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) } } +static int pc_present_cpus_count(PCMachineState *pcms) +{ + int i, boot_cpus = 0; + for (i = 0; i < pcms->possible_cpus->len; i++) { + if (pcms->possible_cpus->cpus[i].cpu) { + boot_cpus++; + } + } + return boot_cpus; +} + static X86CPU *pc_new_cpu(const char *typename, int64_t apic_id, Error **errp) { @@ -1222,19 +1233,6 @@ static void pc_build_feature_control_file(PCMachineState *pcms) fw_cfg_add_file(pcms->fw_cfg, "etc/msr_feature_control", val, sizeof(*val)); } -static void rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count) -{ - if (cpus_count > 0xff) { - /* If the number of CPUs can't be represented in 8 bits, the - * BIOS must use "etc/boot-cpus". Set RTC field to 0 just - * to make old BIOSes fail more predictably. - */ - rtc_set_memory(rtc, 0x5f, 0); - } else { - rtc_set_memory(rtc, 0x5f, cpus_count - 1); - } -} - static void pc_machine_done(Notifier *notifier, void *data) { @@ -1243,7 +1241,7 @@ void pc_machine_done(Notifier *notifier, void *data) PCIBus *bus = pcms->bus; /* set the number of CPUs */ - rtc_set_cpus_count(pcms->rtc, le16_to_cpu(pcms->boot_cpus_le)); + rtc_set_memory(pcms->rtc, 0x5f, pc_present_cpus_count(pcms) - 1); if (bus) { int extra_hosts = 0; @@ -1264,15 +1262,8 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (pcms->fw_cfg) { - MachineClass *mc = MACHINE_GET_CLASS(pcms); - pc_build_smbios(pcms->fw_cfg); pc_build_feature_control_file(pcms); - - if (mc->max_cpus > 255) { - fw_cfg_add_file(pcms->fw_cfg, "etc/boot-cpus", &pcms->boot_cpus_le, - sizeof(pcms->boot_cpus_le)); - } } if (pcms->apic_id_limit > 255) { @@ -1819,11 +1810,9 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, } } - /* increment the number of CPUs */ - pcms->boot_cpus_le = cpu_to_le16(le16_to_cpu(pcms->boot_cpus_le) + 1); if (dev->hotplugged) { - /* Update the number of CPUs in CMOS */ - rtc_set_cpus_count(pcms->rtc, le16_to_cpu(pcms->boot_cpus_le)); + /* increment the number of CPUs */ + rtc_set_memory(pcms->rtc, 0x5f, rtc_get_memory(pcms->rtc, 0x5f) + 1); } found_cpu = pc_find_cpu_slot(pcms, CPU(dev), NULL); @@ -1877,10 +1866,7 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev, found_cpu->cpu = NULL; object_unparent(OBJECT(dev)); - /* decrement the number of CPUs */ - pcms->boot_cpus_le = cpu_to_le16(le16_to_cpu(pcms->boot_cpus_le) - 1); - /* Update the number of CPUs in CMOS */ - rtc_set_cpus_count(pcms->rtc, le16_to_cpu(pcms->boot_cpus_le)); + rtc_set_memory(pcms->rtc, 0x5f, rtc_get_memory(pcms->rtc, 0x5f) - 1); out: error_propagate(errp, local_err); } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 8eb517f..e32e957 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -36,7 +36,6 @@ /** * PCMachineState: * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling - * @boot_cpus_le: number of present VCPUs, referenced by 'etc/boot-cpus' fw_cfg */ struct PCMachineState { /*< private >*/ @@ -71,7 +70,6 @@ struct PCMachineState { bool apic_xrupt_override; unsigned apic_id_limit; CPUArchIdList *possible_cpus; - uint16_t boot_cpus_le; /* NUMA information: */ uint64_t numa_nodes;