From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cYCcX-00059k-Tb for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:07:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cYCcX-0006GH-33 for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:07:49 -0500 Received: from mail-vk0-x22f.google.com ([2607:f8b0:400c:c05::22f]:33966) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cYCcW-0006GC-VE for qemu-devel@nongnu.org; Mon, 30 Jan 2017 09:07:49 -0500 Received: by mail-vk0-x22f.google.com with SMTP id r136so216124037vke.1 for ; Mon, 30 Jan 2017 06:07:48 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20170120133139.31080-24-pbonzini@redhat.com> References: <20170120133139.31080-1-pbonzini@redhat.com> <20170120133139.31080-24-pbonzini@redhat.com> From: Peter Maydell Date: Mon, 30 Jan 2017 14:07:28 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PULL 23/35] x86: ioapic: dump version for "info ioapic" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: QEMU Developers , Peter Xu On 20 January 2017 at 13:31, Paolo Bonzini wrote: > From: Peter Xu > > Signed-off-by: Peter Xu > Message-Id: <1483952153-7221-3-git-send-email-peterx@redhat.com> > Signed-off-by: Paolo Bonzini > --- > hw/intc/ioapic_common.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c > index 1b7ec5e..97c4f9c 100644 > --- a/hw/intc/ioapic_common.c > +++ b/hw/intc/ioapic_common.c > @@ -58,7 +58,8 @@ void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s) > uint32_t remote_irr = 0; > int i; > > - monitor_printf(mon, "ioapic id=0x%02x sel=0x%02x", s->id, s->ioregsel); > + monitor_printf(mon, "ioapic ver=0x%x id=0x%02x sel=0x%02x", > + s->version, s->id, s->ioregsel); > if (s->ioregsel) { > monitor_printf(mon, " (redir[%u])\n", > (s->ioregsel - IOAPIC_REG_REDTBL_BASE) >> 1); Coverity points out (CID 1369422) that this is a use of a possibly uninitialized field. In kvm_ioapic_dump_state() we do: IOAPICCommonState s; kvm_ioapic_get(&s); ioapic_print_redtbl(mon, &s); and kvm_ioapic_get() doesn't initialize s->version, so when we come to print it in ioapic_print_redtbl() it's uninitialized. The easy fix is to initialize version to something. The underlying problem here I think is that we're manufacturing a fake IOAPICCommonState rather than finding the one that corresponds to the actual IOAPIC device in the system... thanks -- PMM