From patchwork Thu Jul 17 11:02:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 371135 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 46AB7140179 for ; Thu, 17 Jul 2014 23:39:34 +1000 (EST) Received: from localhost ([::1]:44315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7luG-0006gO-Eb for incoming@patchwork.ozlabs.org; Thu, 17 Jul 2014 09:39:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jSU-00046Y-JQ for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:02:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7jSO-00043I-HN for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:02:42 -0400 Received: from mail.ispras.ru ([83.149.199.45]:47345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jSO-00042x-Al for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:02:36 -0400 Received: from [10.10.150.172] (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 88145540151; Thu, 17 Jul 2014 15:02:35 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 17 Jul 2014 15:02:39 +0400 Message-ID: <20140717110238.8352.38648.stgit@PASHA-ISP> In-Reply-To: <20140717110153.8352.80175.stgit@PASHA-ISP> References: <20140717110153.8352.80175.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 X-Mailman-Approved-At: Thu, 17 Jul 2014 09:36:32 -0400 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v2 07/49] kvmapic: fixing loading vmstate 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 vapic state should not be synchronized with APIC while loading, because APIC state could be not loaded yet at that moment. We just save vapic_paddr in APIC VMState instead of synchronization. Signed-off-by: Pavel Dovgalyuk --- hw/i386/kvmvapic.c | 22 +++++++++++++++++++++- hw/intc/apic_common.c | 5 ++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index cb855c7..417ab6a 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -351,6 +351,24 @@ static int get_kpcr_number(X86CPU *cpu) return kpcr.number; } +static int vapic_enable_post_load(VAPICROMState *s, X86CPU *cpu) +{ + int cpu_number = get_kpcr_number(cpu); + hwaddr vapic_paddr; + static const uint8_t enabled = 1; + + if (cpu_number < 0) { + return -1; + } + vapic_paddr = s->vapic_paddr + + (((hwaddr)cpu_number) << VAPIC_CPU_SHIFT); + cpu_physical_memory_rw(vapic_paddr + offsetof(VAPICState, enabled), + (void *)&enabled, sizeof(enabled), 1); + s->state = VAPIC_ACTIVE; + + return 0; +} + static int vapic_enable(VAPICROMState *s, X86CPU *cpu) { int cpu_number = get_kpcr_number(cpu); @@ -731,7 +749,9 @@ static void do_vapic_enable(void *data) VAPICROMState *s = data; X86CPU *cpu = X86_CPU(first_cpu); - vapic_enable(s, cpu); + /* Do not synchronize with APIC, because it was not loaded yet. + Just call the enable function which does not have synchronization. */ + vapic_enable_post_load(s, cpu); } static int vapic_post_load(void *opaque, int version_id) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index ce3d903..9d75ee0 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -347,7 +347,7 @@ static int apic_dispatch_post_load(void *opaque, int version_id) static const VMStateDescription vmstate_apic_common = { .name = "apic", - .version_id = 3, + .version_id = 4, .minimum_version_id = 3, .minimum_version_id_old = 1, .load_state_old = apic_load_old, @@ -374,6 +374,9 @@ static const VMStateDescription vmstate_apic_common = { VMSTATE_INT64(next_time, APICCommonState), VMSTATE_INT64(timer_expiry, APICCommonState), /* open-coded timer state */ + VMSTATE_INT32_V(sipi_vector, APICCommonState, 4), + VMSTATE_INT32_V(wait_for_sipi, APICCommonState, 4), + VMSTATE_UINT64_V(vapic_paddr, APICCommonState, 4), VMSTATE_END_OF_LIST() } };