Received: from eggs.gnu.org ([2001:4830:134:3::10]:43143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDVVD-0006UQ-W4 for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:53:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDVV8-0004aj-5v for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:53:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57653) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDVV7-0004aR-Uy for qemu-devel@nongnu.org; Tue, 20 Jan 2015 04:53:34 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0K9rWXf000643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 20 Jan 2015 04:53:32 -0500 From: Markus Armbruster References: <1418227041-28151-1-git-send-email-pbonzini@redhat.com> Date: Tue, 20 Jan 2015 10:53:29 +0100 In-Reply-To: <1418227041-28151-1-git-send-email-pbonzini@redhat.com> (Paolo Bonzini's message of "Wed, 10 Dec 2014 16:57:21 +0100") Message-ID: <87d269n5gm.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] kvm/apic: fix 2.2->2.1 migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: imammedo@redhat.com, qemu-devel@nongnu.org Paolo Bonzini writes: > The wait_for_sipi field is set back to 1 after an INIT, so it was not > effective to reset it in kvm_apic_realize. Introduce a reset callback > and reset wait_for_sipi there. > > Reported-by: Igor Mammedov > Signed-off-by: Paolo Bonzini > --- > hw/i386/kvm/apic.c | 10 +++++++--- > hw/intc/apic_common.c | 5 +++++ > include/hw/i386/apic_internal.h | 1 + > 3 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c > index 271e97f..5b47056 100644 > --- a/hw/i386/kvm/apic.c > +++ b/hw/i386/kvm/apic.c > @@ -171,12 +171,15 @@ static const MemoryRegionOps kvm_apic_io_ops = { > .endianness = DEVICE_NATIVE_ENDIAN, > }; > > -static void kvm_apic_realize(DeviceState *dev, Error **errp) > +static void kvm_apic_reset(APICCommonState *s) > { > - APICCommonState *s = APIC_COMMON(dev); > - > /* Not used by KVM, which uses the CPU mp_state instead. */ > s->wait_for_sipi = 0; > +} > + > +static void kvm_apic_realize(DeviceState *dev, Error **errp) > +{ > + APICCommonState *s = APIC_COMMON(dev); > > memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, "kvm-apic-msi", > APIC_SPACE_SIZE); > @@ -191,6 +194,7 @@ static void kvm_apic_class_init(ObjectClass *klass, void *data) > APICCommonClass *k = APIC_COMMON_CLASS(klass); > > k->realize = kvm_apic_realize; > + k->reset = kvm_apic_reset; > k->set_base = kvm_apic_set_base; > k->set_tpr = kvm_apic_set_tpr; > k->get_tpr = kvm_apic_get_tpr; > diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c > index 4e62f25..d9bb188 100644 > --- a/hw/intc/apic_common.c > +++ b/hw/intc/apic_common.c > @@ -178,6 +178,7 @@ bool apic_next_timer(APICCommonState *s, int64_t current_time) > void apic_init_reset(DeviceState *dev) > { > APICCommonState *s = APIC_COMMON(dev); > + APICCommonClass *info = APIC_COMMON_GET_CLASS(s); > int i; > > if (!s) { *** CID 1264327: Dereference before null check (REVERSE_INULL) /hw/intc/apic_common.c: 184 in apic_init_reset() 178 void apic_init_reset(DeviceState *dev) 179 { 180 APICCommonState *s = APIC_COMMON(dev); 181 APICCommonClass *info = APIC_COMMON_GET_CLASS(s); 182 int i; 183 >>> CID 1264327: Dereference before null check (REVERSE_INULL) >>> Null-checking "s" suggests that it may be null, but it has >>> already been dereferenced on all paths leading to the check. 184 if (!s) { 185 return; 186 } 187 s->tpr = 0; 188 s->spurious_vec = 0xff; 189 s->log_dest = 0; [...]