Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752739AbdHBUa7 (ORCPT ); Wed, 2 Aug 2017 16:30:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58122 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752299AbdHBUa5 (ORCPT ); Wed, 2 Aug 2017 16:30:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 443E0883AE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=rkrcmar@redhat.com Date: Wed, 2 Aug 2017 22:30:53 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: "Longpeng(Mike)" Cc: pbonzini@redhat.com, tglx@linutronix.de, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, weidong.huang@huawei.com, arei.gonglei@huawei.com, wangxinxin.wang@huawei.com Subject: Re: [PATCH] KVM: X86: init irq->level in kvm_pv_kick_cpu_op Message-ID: <20170802203052.GC32403@flask> References: <1501644051-211436-1-git-send-email-longpeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1501644051-211436-1-git-send-email-longpeng2@huawei.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 02 Aug 2017 20:30:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1708 Lines: 53 2017-08-02 11:20+0800, Longpeng(Mike): > 'lapic_irq' is a local variable and its 'level' field isn't > initialized, so 'level' is random, it doesn't matter but > makes UBSAN unhappy: > > UBSAN: Undefined behaviour in .../lapic.c:... > load of value 10 is not a valid value for type '_Bool' > ... > Call Trace: > [] dump_stack+0x1e/0x20 > [] ubsan_epilogue+0x12/0x55 > [] __ubsan_handle_load_invalid_value+0x118/0x162 > [] kvm_apic_set_irq+0xc3/0xf0 [kvm] > [] kvm_irq_delivery_to_apic_fast+0x450/0x910 [kvm] > [] kvm_irq_delivery_to_apic+0xfa/0x7a0 [kvm] > [] kvm_emulate_hypercall+0x62e/0x760 [kvm] > [] handle_vmcall+0x1a/0x30 [kvm_intel] > [] vmx_handle_exit+0x7a2/0x1fa0 [kvm_intel] > ... > > Signed-off-by: Longpeng(Mike) > --- Applied, thanks. --- Thinking whether it's time to change it to: diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 72d82ab1ee22..0c33642a4ff7 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6215,15 +6215,11 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr, */ static void kvm_pv_kick_cpu_op(struct kvm *kvm, unsigned long flags, int apicid) { - struct kvm_lapic_irq lapic_irq; + struct kvm_lapic_irq lapic_irq = { + .dest_id = apicid, + .delivery_mode = APIC_DM_REMRD, + }; - lapic_irq.shorthand = 0; - lapic_irq.dest_mode = 0; - lapic_irq.level = 0; - lapic_irq.dest_id = apicid; - lapic_irq.msi_redir_hint = false; - - lapic_irq.delivery_mode = APIC_DM_REMRD; kvm_irq_delivery_to_apic(kvm, NULL, &lapic_irq, NULL); }