Received: from eggs.gnu.org ([2001:4830:134:3::10]:56046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUvej-0002Nq-3j for qemu-devel@nongnu.org; Fri, 19 Sep 2014 06:43:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUved-0006KO-2v for qemu-devel@nongnu.org; Fri, 19 Sep 2014 06:43:13 -0400 Received: from mail.ispras.ru ([83.149.199.45]:51904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUvec-0006Iw-RW for qemu-devel@nongnu.org; Fri, 19 Sep 2014 06:43:06 -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, 19 Sep 2014 14:43:01 +0400 Message-ID: <000301cfd3f6$7d5b6170$78122450$@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 Hi, Paolo! > From: Paolo Bonzini [mailto:paolo.bonzini@gmail.com] On Behalf Of Paolo Bonzini > From: Pavel Dovgalyuk > > 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. > > > +static int vapic_post_load(void *opaque, int version_id) > +{ > + VAPICROMState *s = opaque; > + > /* > * The old implementation of qemu-kvm did not provide the state > * VAPIC_STANDBY. Reconstruct it. > @@ -752,17 +776,8 @@ static int vapic_post_load(void *opaque, int version_id) > return -1; > } > } > - 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); > - } > - } > > + s->vmsentry = qemu_add_vm_change_state_handler(kvmvapic_vm_state_change, s); > return 0; I've tested this patch with replay. I enabled VM reset (which was previously disabled for replay) while loading the VM state and discovered the following problem. vapic_enable function in kvmapic.c retrieves cpu number with the get_kpcr_number() function. When cpu number is -1 vapic_enable exits and does not call apic_enable_vapic, which should setup vapic_paddr field. Without this call vapic_paddr remains initialized with default value and behavior of the virtual machine becomes different. Pavel Dovgalyuk