From patchwork Mon Aug 31 09:47:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhu Guihua X-Patchwork-Id: 512407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A6EC71401DA for ; Mon, 31 Aug 2015 19:50:03 +1000 (AEST) Received: from localhost ([::1]:35354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLiz-0007FE-Kl for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2015 05:50:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLiP-0006OL-8R for qemu-devel@nongnu.org; Mon, 31 Aug 2015 05:49:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWLiL-0006Zg-Bk for qemu-devel@nongnu.org; Mon, 31 Aug 2015 05:49:25 -0400 Received: from [59.151.112.132] (port=5776 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWLiL-0006XR-03 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 05:49:21 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100193248" Received: from bogon (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 31 Aug 2015 17:52:25 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t7V9nBqs006380; Mon, 31 Aug 2015 17:49:11 +0800 Received: from G08FNSTD140041.g08.fujitsu.local (10.167.226.252) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 31 Aug 2015 17:49:19 +0800 From: Zhu Guihua To: , , , , Date: Mon, 31 Aug 2015 17:47:45 +0800 Message-ID: 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 v10 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, some devices (such as hpet, rtc) reset will send irq to apic, this will update the apic register. In order to ensure the apic register could be set to default values, apic reset must be after those devices reset. 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e15971c..875ada8 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1928,6 +1928,27 @@ static void pc_machine_initfn(Object *obj) NULL, &error_abort); } +static void pc_machine_reset(void) +{ + CPUState *cs; + X86CPU *cpu; + + qemu_devices_reset(); + + /* When some devices (such as hpet, rtc) do their reset, they will + * send irq to APIC. This will modify the value of the APIC register. + * In order to ensure the APIC register can be set to default value, + * APIC reset must be after those 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; @@ -1948,6 +1969,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->default_boot_order = "cad"; mc->hot_add_cpu = pc_hot_add_cpu; mc->max_cpus = 255; + 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;