From patchwork Wed Aug 27 13:22:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 383454 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 069F41400B7 for ; Wed, 27 Aug 2014 23:22:44 +1000 (EST) Received: from localhost ([::1]:59544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMdBR-00073v-Da for incoming@patchwork.ozlabs.org; Wed, 27 Aug 2014 09:22:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58502) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMdB5-0006lg-Eg for qemu-devel@nongnu.org; Wed, 27 Aug 2014 09:22:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMdAx-0002g4-Vj for qemu-devel@nongnu.org; Wed, 27 Aug 2014 09:22:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMdAx-0002fy-Nd for qemu-devel@nongnu.org; Wed, 27 Aug 2014 09:22:11 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7RDM63N028767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Aug 2014 09:22:06 -0400 Received: from yakj.usersys.redhat.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7RDM3d0013914; Wed, 27 Aug 2014 09:22:04 -0400 Message-ID: <53FDDB7A.8020604@redhat.com> Date: Wed, 27 Aug 2014 15:22:02 +0200 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Pavel Dovgaluk , qemu-devel@nongnu.org References: <20140826071427.1672.48119.stgit@PASHA-ISP> <20140826071503.1672.32964.stgit@PASHA-ISP> <53FC5ADE.8030306@redhat.com> <002401cfc1f0$b5aefe50$210cfaf0$@Dovgaluk@ispras.ru> <53FDD09C.4040208@redhat.com> <002b01cfc1f7$4c954e90$e5bfebb0$@Dovgaluk@ispras.ru> In-Reply-To: <002b01cfc1f7$4c954e90$e5bfebb0$@Dovgaluk@ispras.ru> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: zealot351@gmail.com, maria.klimushenkova@ispras.ru Subject: Re: [Qemu-devel] [PATCH 06/12] kvmvapic: 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 Il 27/08/2014 15:03, Pavel Dovgaluk ha scritto: >> > Hmm, probably not. The bug would not be other timers accessing the >> > APIC, because that would also call apic_sync_vapic and the only effect >> > would be an extra useless synchronization. The bug would happen if the >> > APIC is accessed by the CPU before the timer has the occasion to run. > Sorry, but I don't understand which problem we will solve with apic_sync_vapic. In KVM mode, it is not a problem to call apic_enable_vapic before APIC state is loaded; all vapic processing is delayed anyway to after the VCPUs are started. In TCG mode, apic_enable_vapic calls apic_sync_vapic. Taking inspiration from what KVM does, the fix could be even simpler than a change state handler. run_on_cpu functions do not run while the VM is stopped, so the following should work: void apic_handle_tpr_access_report(DeviceState *dev, target_ulong ip, > All fields that were added to vmstate are not affected by this function. The sipi_vector and wait_for_sipi parts of this patch are okay. You should split those in a separate patch. Paolo diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index ce3d903..81d1ad7 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -91,13 +91,20 @@ void apic_enable_tpr_access_reporting(DeviceState *dev, bool enable) } } +static void do_apic_enable_vapic(void *data) +{ + APICCommonState *s = APIC_COMMON(data); + APICCommonClass *info = APIC_COMMON_GET_CLASS(s); + + info->vapic_base_update(s); +} + void apic_enable_vapic(DeviceState *dev, hwaddr paddr) { APICCommonState *s = APIC_COMMON(dev); - APICCommonClass *info = APIC_COMMON_GET_CLASS(s); s->vapic_paddr = paddr; - info->vapic_base_update(s); + run_on_cpu(CPU(s->cpu), do_apic_enable_vapic, s); }