From patchwork Wed Aug 2 20:30:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= X-Patchwork-Id: 9877659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 19CFF6037D for ; Wed, 2 Aug 2017 20:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CC5728824 for ; Wed, 2 Aug 2017 20:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0182A28827; Wed, 2 Aug 2017 20:31:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,HK_RANDOM_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DB528824 for ; Wed, 2 Aug 2017 20:31:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbdHBUa7 (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 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 443E0883AE; Wed, 2 Aug 2017 20:30:57 +0000 (UTC) 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 Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 1CA2D1712D; Wed, 2 Aug 2017 20:30:53 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 02 Aug 2017 22:30:53 +0200 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-Disposition: inline In-Reply-To: <1501644051-211436-1-git-send-email-longpeng2@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); }