From patchwork Tue Feb 20 20:58:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 128969 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp5056128ljc; Tue, 20 Feb 2018 12:59:42 -0800 (PST) X-Google-Smtp-Source: AH8x226YsNX0O3i2j6cluvgPAR/RFSG3yEA2Sxfufn9GiaG+HPOLPS0qTgA1iG5jCBHO5eWit27l X-Received: by 2002:a17:902:51e9:: with SMTP id y96-v6mr838359plh.344.1519160382129; Tue, 20 Feb 2018 12:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519160382; cv=none; d=google.com; s=arc-20160816; b=RyRJ8mBIuxY6OuxhBrqm7MhDjgaqIgnwD1fBpbPqIg0OsrCcSg3xzmXJ6rKMg8wbL4 8tgq1rzUi9WkMGzruo4Dhfe+mlrOsumezq7Rb3u9Z4fDQNcRayvt/1gtQmgFnIbwHc0v utzZgd8Ox4sv+jQ1WiOTvvFd82IlDHmlzz5sV9QyP6utZ4HHgF2GgEudRvOdIe5QcWQ2 qUmHQ6oaH8RSRQswlsG36QMjEK8P2yTRnm3rgxqcqKDCCetKIRrP7YB/3r31lM/vtSY9 0VVuiEgw8QvwkEBG1OlPC+GmROCMZLHw/8hErHpv1yja/cD6HgFZQ/++tt0B4ekJmc2v xW9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=I18Y2wIneEcAy0iIrEMeoqpevcbpjfAMxM0ryG25aw4=; b=Jk5sRDF+luw2slufNtdo2ucm44WjxqKF8raxyDwxjcsWaOnNKiHkMPHjI2UNyS86cI QScLYGg5MDQ19HhwSQX5U7L58v9ake6i3rEz2dKUyzfFT+utFTrByVkRXNvQwDzMEK9M 1OjwCEpCTRN2/wKfja3qDMDpza17wSYPVa76rwbwnzU7WPY0GGp80y/EMReyLkxrjk/O tmmzueOeH9ahuTE3/Gx/sHw1lkdPCzkmQhxS6d/pHWhpUhasHMH2LyAGe1Bqto5acuoq T3vEmE21kCAh76UWSFVjLae8WMC46ETYChaeAbz5U+ZqDA1ZUlWpi8Xf0pYxUkKbD9Tj VOYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 c1-v6si9191831plz.783.2018.02.20.12.59.41; Tue, 20 Feb 2018 12:59:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750829AbeBTU7k (ORCPT + 10 others); Tue, 20 Feb 2018 15:59:40 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:37311 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750799AbeBTU7j (ORCPT ); Tue, 20 Feb 2018 15:59:39 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.129]) with ESMTPA (Nemesis) id 0M7yHR-1ebGNR3DZx-00vjLH; Tue, 20 Feb 2018 21:58:28 +0100 From: Arnd Bergmann To: Robert Richter , Thomas Gleixner , Ingo Molnar , x86@kernel.org Cc: Arnd Bergmann , Martin Sebor , stable@vger.kernel.org, "H. Peter Anvin" , Kees Cook , Jessica Yu , oprofile-list@lists.sf.net, linux-kernel@vger.kernel.org Subject: [PATCH] x86: oprofile: nmi_int: fix bogus gcc-8 warning Date: Tue, 20 Feb 2018 21:58:21 +0100 Message-Id: <20180220205826.2008875-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:60/+K93AohkaXPCtCjzEuVmkDxlGn4HOWmVgcqrhY3Ue5rxR2wP a2VN8XpIPn9v1KBJmaWj+lmoICEBfrfDLsIsfHhR2IoEc86+lZBxcu8jVv7OQkFg4fkD2yh NyQV0PLK/E0tVMKzn9K3z4iI1Nu9skqqxT3VigZ8rIsliGm0Z4rB5AaqSwga4cfzZBoiebo j/SYmyEjkPsjZHsVqEpLQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:5DmU568mD+A=:6PMtccOFEhmLLRp07jCati HSler0LkTj5yGsommVlhtAZDqGtsDPSB+HLnPa5jDUQW/Vu29ewx3Lz6ehM8C84m2WHMjPAAX iBVL5tuEFGtxDKgXDeLfoLzNeOO/d0doaQCvUOHePles8zt45yYwZgeKU/ldH8pyfnaYwVP9k QbhL4TklZa1IjYGeiJp7BJWeyJB3RU8t+3xO35r+zhowiffLoMhNBLPYpaACNI91Q0o0YN2gK ovOPP0TM7IA0q2fAnNBvGm3xiEtHBNpr9TF++zCh6dNYg3fJflZMUVuMcIdcko8IliT0mnDnS kkvwbV6pLiWOwZ0Q+0cbzmLphybKSsmi6WY7mBy6Xu0znlYziMYuFhxiQtR5MEGunI64ccLyq 0503t2Vsm75RHP+N8bKU+MaaVkrgqzUGJ2+9yIwK98GIKzfZxOyMbCoeDKWQxf+u3RS5gVZSl OYR8uxKU/1/1mdu2p/jpfZ0FfbRjzsEJJR7crE0C6Cet8HS55/lv8bRJs5FzSDhJcAMz2v47K PiS/EvT7MsI3Xz4pSnmM2toNWTwPpEfvCY5q5rkFTDHaSuaQ5FAMOpkjXsBaUCw81JA3rybiD EZU8pz4LTQl4jLnXWMXrodOVL81/g4ZPUL3cjlZNuyIBmiEo1a3iSiGak1tUfXlAJd8PH6xi+ yFDInVk/6uRU56eVYcqlvn/x6w7pce6PVUf3ssU5WsFYI5WCUqk2zC0ZNH2kXudIDoQY+bFht bj3o9FmNhaTnlmRUXlPm60p/6gZu15iqRM2ohA== Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org gcc-8 shows a warning for the x86 oprofile code that copies per-cpu data from CPU 0 to all other CPUs, which when building a non-SMP kernel turns into a memcpy() with identical source and destination pointers: arch/x86/oprofile/nmi_int.c: In function 'mux_clone': arch/x86/oprofile/nmi_int.c:285:2: error: 'memcpy' source argument is the same as destination [-Werror=restrict] memcpy(per_cpu(cpu_msrs, cpu).multiplex, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ per_cpu(cpu_msrs, 0).multiplex, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(struct op_msr) * model->num_virt_counters); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/oprofile/nmi_int.c: In function 'nmi_setup': arch/x86/oprofile/nmi_int.c:466:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict] arch/x86/oprofile/nmi_int.c:470:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict] I have analyzed a number of such warnings now: some are valid and the gcc warning is welcome. Others turned out to be false-positives, and gcc was changed to not warn about those any more. This is a corner case that is a false-positive but the gcc developers feel it's better to keep warning about it. In this case, it seems best to work around it by telling gcc a little more clearly that this code path is never hit with an IS_ENABLED() configuration check. Cc:stable as we also want old kernels to build cleanly with gcc-8. Cc: Martin Sebor Cc: stable@vger.kernel.org Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84095 Signed-off-by: Arnd Bergmann --- arch/x86/oprofile/nmi_int.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.9.0 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c index 174c59774cc9..1d6d14db96c0 100644 --- a/arch/x86/oprofile/nmi_int.c +++ b/arch/x86/oprofile/nmi_int.c @@ -460,7 +460,7 @@ static int nmi_setup(void) goto fail; for_each_possible_cpu(cpu) { - if (!cpu) + if (!IS_ENABLED(CONFIG_SMP) || !cpu) continue; memcpy(per_cpu(cpu_msrs, cpu).counters, @@ -470,7 +470,6 @@ static int nmi_setup(void) memcpy(per_cpu(cpu_msrs, cpu).controls, per_cpu(cpu_msrs, 0).controls, sizeof(struct op_msr) * model->num_controls); - mux_clone(cpu); }