Received: from eggs.gnu.org ([2001:4830:134:3::10]:51620) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUxmw-0007FH-8f for qemu-devel@nongnu.org; Fri, 19 Sep 2014 08:59:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XUxmj-0005kY-LK for qemu-devel@nongnu.org; Fri, 19 Sep 2014 08:59:50 -0400 Received: from mail.ispras.ru ([83.149.199.45]:54865) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XUxmj-0005j0-Cl for qemu-devel@nongnu.org; Fri, 19 Sep 2014 08:59:37 -0400 From: "Pavel Dovgaluk" References: <1410530338-17615-1-git-send-email-pbonzini@redhat.com> <1410530338-17615-14-git-send-email-pbonzini@redhat.com> <30501.4520571151$1411123417@news.gmane.org> <541C1BBE.6090808@redhat.com> In-Reply-To: <541C1BBE.6090808@redhat.com> Date: Fri, 19 Sep 2014 16:50:10 +0400 Message-ID: <000401cfd408$3f6208d0$be261a70$@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 > Il 19/09/2014 12:43, Pavel Dovgaluk ha scritto: > > 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. > > IIUC the fix would be to move part of vapic_enable out to its separate > function, and call it from do_vapic_enable? Could you prepare a patch? static int vapic_enable(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_write(vapic_paddr + offsetof(VAPICState, enabled), &enabled, sizeof(enabled)); apic_enable_vapic(cpu->apic_state, vapic_paddr); s->state = VAPIC_ACTIVE; return 0; } vapic_paddr depends on cpu_number. cpu_number cannot be retrieved when do_vapic_enable executes. Thus we cannot reconstruct vapic_paddr in that function. Pavel Dovgalyuk