Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp950740ybi; Fri, 12 Jul 2019 07:14:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqyowXZpwqqtUJiluYA4mBBtuhUepkxm+OkP3ZiFgb+arm4CppzuwP2ZDtdpi/Y3GnfzbX3i X-Received: by 2002:a63:5823:: with SMTP id m35mr11245358pgb.329.1562940861151; Fri, 12 Jul 2019 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562940861; cv=none; d=google.com; s=arc-20160816; b=Qqlu7Y6vWoojvTvyMeDsy5dl4MLMF/y45NqVVTpEEhGb7doksvOZoBkcYrZ7f6fN/S 2u8V3ZQQvEde7T2LcScp3MoN7uCjIjxfEyW1y1ZY3w6WqokUGPO+Fhg6ltkAYqvlIuhT icNFlCI+AM2LI3Y4yQrw6qbpAF4LcFtjGy9h7+OqSlfqOk89A12nnVw/Tqr728gLR1bP yyA3XONH7eJk+R35zfWN7Q0AC1sG4VxoMKbt4ia/MjHt6lFGHuGZGXXmt8t+nn0xeGpa GxUR1zSVIVAH5PmYrgZotDm+7q5UFU4Eu/DCrqK4MUKSKyBVQ6nXLxtsLJA+4qu+N542 pUiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=8c4jxWOyQNYg+EXZEt1rUQ27lN5OR3C4Tw6lA++twW8=; b=VxehNNSwefVLIFy49kfWJB9OurkbNotNLQNZjr6d1ytnXSr8UDvAnRMkFFdu5QDFaO Wxg7T9IQm0+BR2sTWox9FSNz6qyjBgNfUF/5IV5HFpX8DbNpD6DHd4H+KQuEYqtCEV3e gxZ8dAduBX1AFM3xS23OlZOfjmszliAwnWahEDFC2vwIw4QegN4q493QeXa+n4w7wg2g WOl85Kg3OeLiTi+to0Wvzc22TDcU9bWVEHtzxInFxlwLoVX7lHCE+B9HBzfXbZU3a99X cVGM6LKKLW+uhrpDjsGK4uyM+83joQSbw3bY8+DURaakw7I1iQhWorEUEE9WSiZSCr24 qzaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf7si7870888plb.435.2019.07.12.07.14.04; Fri, 12 Jul 2019 07:14:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbfGLONY (ORCPT + 99 others); Fri, 12 Jul 2019 10:13:24 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:33231 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbfGLONX (ORCPT ); Fri, 12 Jul 2019 10:13:23 -0400 Received: by mail-qk1-f193.google.com with SMTP id r6so6510291qkc.0; Fri, 12 Jul 2019 07:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8c4jxWOyQNYg+EXZEt1rUQ27lN5OR3C4Tw6lA++twW8=; b=dwyja7ltni5MvdIoZuAvkQXOUZwpQcyYgkc0mE1viIQRBQiq6VRNbhG04zY7TYUben qJ/lgbQyXArp86pDybLrdJf7G7uSoi7yJ75WskOXowDr3VG2jiixTfnYAeVuFN+X/GQe yZpmM7GpiU0uixbq+/LQr/Z9zNL85a0U9fF9rUc9hCtQvDAfUtESmobihMiiXGP8hnJl Df5LgbvGU21lY0rSzmoZ48gdRqIWDkqZRYxA7Dbc1o6Ye2c96OJBHPUmm+lWX1Xp15cp 5ACmhIPUlWqAEY/JHfc0uA6r+LGN5vxTTaHaN6RaK/ASOhbsMyneuCSg1uFiR/23fday lcdQ== X-Gm-Message-State: APjAAAUo71zyOqn+j6DlG5v2g3sknAnpM7bLXsesfDZ66isZNZJqpWdU RtLkrL3J9sCUiQDWOE9kfYYjwlzTfsenJY4GWmg= X-Received: by 2002:a37:76c5:: with SMTP id r188mr6432948qkc.394.1562940802620; Fri, 12 Jul 2019 07:13:22 -0700 (PDT) MIME-Version: 1.0 References: <20190712133324.3934659-1-arnd@arndb.de> <20190712135427.GB27820@rkaganb.sw.ru> In-Reply-To: <20190712135427.GB27820@rkaganb.sw.ru> From: Arnd Bergmann Date: Fri, 12 Jul 2019 16:13:06 +0200 Message-ID: Subject: Re: [PATCH] [v2] x86: kvm: avoid -Wsometimes-uninitized warning To: Roman Kagan Cc: Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "x86@kernel.org" , "H. Peter Anvin" , Vitaly Kuznetsov , Liran Alon , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "clang-built-linux@googlegroups.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 12, 2019 at 3:54 PM Roman Kagan wrote: > > On Fri, Jul 12, 2019 at 03:32:43PM +0200, Arnd Bergmann wrote: > > clang points out that running a 64-bit guest on a 32-bit host > > would lead to uninitialized variables: > > > > arch/x86/kvm/hyperv.c:1610:6: error: variable 'ingpa' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > > if (!longmode) { > > ^~~~~~~~~ > > arch/x86/kvm/hyperv.c:1632:55: note: uninitialized use occurs here > > trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa); > > ^~~~~ > > arch/x86/kvm/hyperv.c:1610:2: note: remove the 'if' if its condition is always true > > if (!longmode) { > > ^~~~~~~~~~~~~~~ > > arch/x86/kvm/hyperv.c:1595:18: note: initialize the variable 'ingpa' to silence this warning > > u64 param, ingpa, outgpa, ret = HV_STATUS_SUCCESS; > > ^ > > = 0 > > arch/x86/kvm/hyperv.c:1610:6: error: variable 'outgpa' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > > arch/x86/kvm/hyperv.c:1610:6: error: variable 'param' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] > > > > Since that combination is not supported anyway, change the condition > > to tell the compiler how the code is actually executed. > > > > Signed-off-by: Arnd Bergmann > > --- > > v2: make the change inside of is_64_bit_mode(). > > --- > > arch/x86/kvm/hyperv.c | 6 ++---- > > arch/x86/kvm/x86.h | 4 ++++ > > 2 files changed, 6 insertions(+), 4 deletions(-) > > Reviewed-by: Roman Kagan > > However I still think the log message could state it more explicitly > that it was the compiler's fault, and the patch is a workaround for it. > > Otherwise later on someone may decide to restore the similarity of > is_64_bit_mode() to other inlines in this file, and will be extremely > unlikely to test clang 32-bit build... Fair enough. I've reworded the changelog, as well as the patch to document this now, in a way that should make it harder to introduce the warning again by accident. Unfortunately, that #ifdef check cannot be turned into an if(IS_ENABLED()) because kvm_r8_read() is not defined on i386. Note that the 0-day bot now tests with clang as well, so you would definitely hear about a warning appearing. v3 coming. Arnd