Received: from eggs.gnu.org ([2001:4830:134:3::10]:52131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6hdF-0000sZ-6k for qemu-devel@nongnu.org; Tue, 15 Nov 2016 12:34:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6hdC-0004Cj-2q for qemu-devel@nongnu.org; Tue, 15 Nov 2016 12:34:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:8551) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6hdB-0004CC-To for qemu-devel@nongnu.org; Tue, 15 Nov 2016 12:34:50 -0500 Date: Tue, 15 Nov 2016 15:34:45 -0200 From: Eduardo Habkost Message-ID: <20161115173445.GK5057@thinpad.lan.raisama.net> References: <1479212236-183810-1-git-send-email-imammedo@redhat.com> <1479212236-183810-4-git-send-email-imammedo@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479212236-183810-4-git-send-email-imammedo@redhat.com> Subject: Re: [Qemu-devel] [PATCH for-2.8 v2 3/3] pc: fix FW_CFG_NB_CPUS to account for -device added CPUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Stefan Hajnoczi , Kevin O'Connor , Gerd Hoffmann , Laszlo Ersek , Alexander Graf , Paolo Bonzini , David Gibson , Mark Cave-Ayland , Artyom Tarasenko , Peter Maydell , Richard Henderson On Tue, Nov 15, 2016 at 01:17:16PM +0100, Igor Mammedov wrote: [...] > @@ -1265,6 +1267,8 @@ void pc_machine_done(Notifier *notifier, void *data) > if (pcms->fw_cfg) { > pc_build_smbios(pcms->fw_cfg); > pc_build_feature_control_file(pcms); > + /* update FW_CFG_NB_CPUS to account for -device added CPUs */ > + fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); > } > > if (pcms->apic_id_limit > 255) { > @@ -1342,7 +1346,7 @@ void xen_load_linux(PCMachineState *pcms) > assert(MACHINE(pcms)->kernel_filename != NULL); > > fw_cfg = fw_cfg_init_io(FW_CFG_IO_BASE); > - fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); > + fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); > rom_set_fw(fw_cfg); > > load_linux(pcms, fw_cfg); > @@ -1824,9 +1828,10 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, > } > } > > + /* increment the number of CPUs */ > + pcms->boot_cpus++; > if (dev->hotplugged) { > - /* increment the number of CPUs */ > - rtc_set_memory(pcms->rtc, 0x5f, rtc_get_memory(pcms->rtc, 0x5f) + 1); > + rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus); > } > > found_cpu = pc_find_cpu_slot(pcms, CPU(dev), NULL); > @@ -1880,7 +1885,10 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev, > found_cpu->cpu = NULL; > object_unparent(OBJECT(dev)); > > - rtc_set_memory(pcms->rtc, 0x5f, rtc_get_memory(pcms->rtc, 0x5f) - 1); > + /* decrement the number of CPUs */ > + pcms->boot_cpus--; > + /* Update the number of CPUs in CMOS */ > + rtc_set_cpus_count(pcms->rtc, pcms->boot_cpus); Don't we need to call fw_cfg_modify_i16() on hotplug/hot-unplug, too? -- Eduardo