Received: from eggs.gnu.org ([2001:4830:134:3::10]:52476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXTXi-0006gh-9x for qemu-devel@nongnu.org; Fri, 26 Sep 2014 07:18:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXTXc-0002Pp-6u for qemu-devel@nongnu.org; Fri, 26 Sep 2014 07:18:30 -0400 Received: from mail.ispras.ru ([83.149.199.45]:42914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXTXb-0002Nv-W1 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 07:18:24 -0400 From: "Pavel Dovgaluk" References: <1410530338-17615-1-git-send-email-pbonzini@redhat.com> <1410530338-17615-14-git-send-email-pbonzini@redhat.com> In-Reply-To: <1410530338-17615-14-git-send-email-pbonzini@redhat.com> Date: Fri, 26 Sep 2014 15:18:10 +0400 Message-ID: <001001cfd97b$8e5edc60$ab1c9520$@Dovgaluk@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Language: ru Subject: Re: [Qemu-devel] [PULL 13/21] apic_common: vapic_paddr synchronization fix List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: 'Paolo Bonzini' , qemu-devel@nongnu.org > From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini > > This patch postpones vapic_paddr initialization, which is performed > during migration. When vapic_paddr is synchronized within the migration > process, apic_common functions could operate with incorrect apic state, > if it hadn't loaded yet. This patch postpones the synchronization until > the virtual machine is started, ensuring that the whole virtual machine > state has been loaded. > > Signed-off-by: Pavel Dovgalyuk > Tested-by: Pavel Dovgalyuk > Signed-off-by: Paolo Bonzini > --- > hw/i386/kvmvapic.c | 37 ++++++++++++++++++++++++++----------- > 1 file changed, 26 insertions(+), 11 deletions(-) One more issue for this patch. > -static int vapic_post_load(void *opaque, int version_id) > +static void kvmvapic_vm_state_change(void *opaque, int running, > + RunState state) > { > VAPICROMState *s = opaque; > uint8_t *zero; > > + if (!running) { Exitting here doesn't remove vmsentry. When we load VM state for multiple times, list of the handlers will be filled with garbage. > + return; > + } > + > + if (s->state == VAPIC_ACTIVE) { > + if (smp_cpus == 1) { > + run_on_cpu(first_cpu, do_vapic_enable, s); > + } else { > + zero = g_malloc0(s->rom_state.vapic_size); > + cpu_physical_memory_write(s->vapic_paddr, zero, > + s->rom_state.vapic_size); > + g_free(zero); > + } > + } > + > + qemu_del_vm_change_state_handler(s->vmsentry); > +} Pavel Dovgalyuk