From patchwork Fri Jul 3 09:38:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Guihua X-Patchwork-Id: 490962 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 757F9140776 for ; Fri, 3 Jul 2015 19:41:07 +1000 (AEST) Received: from localhost ([::1]:40071 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAxSx-0002sO-QO for incoming@patchwork.ozlabs.org; Fri, 03 Jul 2015 05:41:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAxSJ-0001yU-IJ for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:40:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZAxSH-00084S-3j for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:40:23 -0400 Received: from [59.151.112.132] (port=2311 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZAxSG-000847-NZ for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:40:21 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98053846" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 03 Jul 2015 17:44:16 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t639ccb4010629; Fri, 3 Jul 2015 17:38:38 +0800 Received: from G08FNSTD140041.g08.fujitsu.local (10.167.226.252) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 3 Jul 2015 17:40:18 +0800 From: Zhu Guihua To: , , , , Date: Fri, 3 Jul 2015 17:38:57 +0800 Message-ID: <97e75cd0dfa993c412d1fc142549693223ced4c9.1435742812.git.zhugh.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.252] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: chen.fan.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com, Zhu Guihua Subject: [Qemu-devel] [PATCH v9 2/4] x86: use new method to correct reset sequence X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Something must be occur during reset of the X86 platform in a specific order. For example, the apic reset should be after some devices (such as hpet, rtc) reset, so that the apic register could be set to default values. This patch uses the new QEMUMachine reset method to solve the above problem, ensuring the various reset happen in the correct order. Signed-off-by: Zhu Guihua --- hw/i386/pc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9f16128..314930a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1860,6 +1860,22 @@ static void pc_machine_initfn(Object *obj) NULL, NULL); } +static void pc_machine_reset(void) +{ + CPUState *cs; + X86CPU *cpu; + + qemu_devices_reset(); + + CPU_FOREACH(cs) { + cpu = X86_CPU(cs); + + if (cpu->apic_state) { + device_reset(cpu->apic_state); + } + } +} + static unsigned pc_cpu_index_to_socket_id(unsigned cpu_index) { unsigned pkg_id, core_id, smt_id; @@ -1877,6 +1893,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->get_hotplug_handler = mc->get_hotplug_handler; mc->get_hotplug_handler = pc_get_hotpug_handler; mc->cpu_index_to_socket_id = pc_cpu_index_to_socket_id; + mc->reset = pc_machine_reset; hc->plug = pc_machine_device_plug_cb; hc->unplug_request = pc_machine_device_unplug_request_cb; hc->unplug = pc_machine_device_unplug_cb;