From patchwork Mon Oct 24 15:26:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101626 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp2639759qge; Mon, 24 Oct 2016 08:30:15 -0700 (PDT) X-Received: by 10.98.78.68 with SMTP id c65mr30255957pfb.43.1477323015763; Mon, 24 Oct 2016 08:30:15 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 20si15971821pgk.101.2016.10.24.08.30.11; Mon, 24 Oct 2016 08:30:15 -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 S941250AbcJXPaI (ORCPT + 27 others); Mon, 24 Oct 2016 11:30:08 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:60147 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935002AbcJXPaG (ORCPT ); Mon, 24 Oct 2016 11:30:06 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue104) with ESMTPA (Nemesis) id 0M8QKY-1ctZF61sjS-00vuDX; Mon, 24 Oct 2016 17:27:42 +0200 From: Arnd Bergmann To: Ingo Molnar Cc: Arnd Bergmann , Peter Zijlstra , Arnaldo Carvalho de Melo , Alexander Shishkin , Thomas Gleixner , "H. Peter Anvin" , x86@kernel.org, Josh Poimboeuf , Borislav Petkov , Andi Kleen , linux-kernel@vger.kernel.org Subject: [PATCH] perf/x86: always warn about broken BIOS Date: Mon, 24 Oct 2016 17:26:37 +0200 Message-Id: <20161024152736.2635492-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:R8TxBGC5j8atdlZR8G9SZFluY2EG67EQNUnZ+sptXFcH8Ci3ef9 QP4dTEWFezWlBqYv9VKJN2d9EzjIyLKNr/nRbcpbCGXgDfbuTzdJ+QPqNrJ2ZuzeFx6Jgw/ t1aJwLurEyVcFkCbRzRGMYTWo51NqRYWZ6sNB5OBaUQ8vtx/Gxxh430PZ2OyrwcHEGRpntu UljlGokPUmI+HhDoPvxoQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:B+gI+rn71gE=:Fdufd77JH/bza85m7DCsrE nGEyIFYODQtJTUjWp9u+5jN6mBREkBcjqPh8t6L5sVnIAQ+1KX+2OnPg2DoCzuf1FQ7N4jSRN PzdSGxAYCHiLay3NF7p+rAZPnhp9SM35MRE1EApVvYATv7hHqJeAw+whpa1Tby8C8PAVy/Tjo Q8oXKi9joiNJQB/eLKxx1kHdH8eqe+p4BSBF41skwXL7GrajpljUk2w9/MZ/NN/bw6zpdkUD/ rGhB/I0+xbHmuNqpzcp7/qlEqap5z2gj/cqqdblfKcya9aGCKGwxOmVcWxpWXJBb5/0L5MVIT gXvOWhBDBqzRhCYwKSHRbozx6GsEF7o/6z56BcPDWrWuAeFj68u2dIS9G+Wa3mGPDEbVGav2f QIuyaJZ99LF2bGSMto4zyLCCwmlvmg0OUPROjJycrey3Z0PQoOdPyW4NII7CdL34Q7ktil+Jv ytH9C8Sb0GwR5/0iEz916EjJggolU336sbCi83Usf3MVqw2tgjo6B28z5vN2BaSZBj4aiODy+ +krhKrWGjF6bdhGL4r30+DLo7dDXuIz69FEGJ+OrQa1MAY7k4l8wRzo4HJvQZhtTS01TFpz9/ sAXO89uKlm8zil0J7HZqgIlAN578TDEt7xNfzoFwDikhKjhQafIeHRAtxwzhcsjkAloiuboA/ t0zrmMZJnEi98e797xZZM8ZeSVQvquhS29Jl78Lv1klL1E7m1TY2q2U5/KMTP1jYzk+UteI28 8ge7wN/yIlpBGLrL Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The intialization function checks for various failure scenarios, but unfortunately the compiler gets a little confused about the possible combinations, leading to a false-positive build warning when -Wmaybe-uninitialized is set: arch/x86/events/core.c: In function ‘init_hw_perf_events’: arch/x86/events/core.c:264:3: warning: ‘reg_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] arch/x86/events/core.c:264:3: warning: ‘val_fail’ may be used uninitialized in this function [-Wmaybe-uninitialized] pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n", It seems reasonable to move the check for the broken BIOS a little higher in the function, which will lead to the kernel warning about both the BIOS and and broken hardware if both are faulty, but it has no effect otherwise at runtime. Moving it ahead of the check for broken hardware however gets rid of the compile-time warning. Signed-off-by: Arnd Bergmann --- arch/x86/events/core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) -- 2.9.0 diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 76697acdc507..185d3b27e881 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -228,6 +228,15 @@ static bool check_hw_exists(void) } /* + * We still allow the PMU driver to operate: + */ + if (bios_fail) { + pr_cont("Broken BIOS detected, complain to your hardware vendor.\n"); + pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n", + reg_fail, val_fail); + } + + /* * If all the counters are enabled, the below test will always * fail. The tools will also become useless in this scenario. * Just fail and disable the hardware counters. @@ -252,15 +261,6 @@ static bool check_hw_exists(void) if (ret || val != val_new) goto msr_fail; - /* - * We still allow the PMU driver to operate: - */ - if (bios_fail) { - pr_cont("Broken BIOS detected, complain to your hardware vendor.\n"); - pr_err(FW_BUG "the BIOS has corrupted hw-PMU resources (MSR %x is %Lx)\n", - reg_fail, val_fail); - } - return true; msr_fail: