Received: by 10.223.185.116 with SMTP id b49csp4191796wrg; Mon, 26 Feb 2018 12:55:02 -0800 (PST) X-Google-Smtp-Source: AG47ELvtR3bQeNdpJZWlo5FyknnPLp5j8fZBGUCDNWTArdoT9tcJ7BezOsHCKUfxnagK5he5LHnJ X-Received: by 10.99.64.198 with SMTP id n189mr3498867pga.191.1519678502640; Mon, 26 Feb 2018 12:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519678502; cv=none; d=google.com; s=arc-20160816; b=Aa0N3OuSJCakfrItAkgt5zhZp3CIWZMb1yWgnN04IV0HrLZ7wyZ6NrtvFNqd7zgUug 7WC0rGVuoCR2L/XaqP7pDPTrvcxIVDHk3TCLHu5KJF6pt3Rvga34p0GnYDj+zdJ83eNw uVhYZiQXoisR4R9eStYuctuRjRS+LixoqSoRGhvJnkuJnKttaWuJoh4IJjzICgRVsmig T5GSR2nHHS3t0CsORxP60xjs0a4QDq6eMvZnTF76dBVVFcaDIbY1XOtukG142/xBr+6O ShzhvkoBuOqSLUya1CINGF4J0Of7HYKcy8b93irVn2eN97FLewq16+wkMsUlN6gWUtVn FQyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4CAKnvNcIyJcCzCRCuLmpoyiA2j6Uerg9dWs5mEibF0=; b=V4zr7tOe1NhUliJme2RrdQG8xwrcZKZNO8fNZF7+1f3+krtyvHmL/tMGo77hf7RbMm OJ04pVNp/n43KdtzxzAdwenxoCsGabOJRo+Ls17naa6WFIdRYjiIEjf65e+WWaGl7Te+ fpzggGHeJLqqcd46okmDjFLw4s7sXWucnnoq2ShYvGpwICswbKYv7nlTrX9YHxSOMoF6 IMRd6Ggzk5jByfDT2MGl0/lNHI6ThBBQZZZoR2VODLBtxkuZreKw9Yr7kGGpDb0tU/Qr RPJWF7Ho31jH6Tl+uQt0mS7wuq9Zo+4SYMeEeB1sruC+bTD0Hp1U+EgNOZQxkbuvbR5/ 8YIQ== 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 m4si5976561pgc.351.2018.02.26.12.54.46; Mon, 26 Feb 2018 12:55:02 -0800 (PST) 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 S1752828AbeBZUYN (ORCPT + 99 others); Mon, 26 Feb 2018 15:24:13 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:35018 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbeBZUYK (ORCPT ); Mon, 26 Feb 2018 15:24:10 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 33E6AF8B; Mon, 26 Feb 2018 20:24:09 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Jessica Yu , Kees Cook , Linus Torvalds , Martin Sebor , Peter Zijlstra , Robert Richter , Thomas Gleixner , oprofile-list@lists.sf.net, Ingo Molnar Subject: [PATCH 4.14 26/54] x86/oprofile: Fix bogus GCC-8 warning in nmi_setup() Date: Mon, 26 Feb 2018 21:22:03 +0100 Message-Id: <20180226202145.709601114@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180226202144.375869933@linuxfoundation.org> References: <20180226202144.375869933@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 85c615eb52222bc5fab6c7190d146bc59fac289e upstream. 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. Signed-off-by: Arnd Bergmann Cc: Jessica Yu Cc: Kees Cook Cc: Linus Torvalds Cc: Martin Sebor Cc: Peter Zijlstra Cc: Robert Richter Cc: Thomas Gleixner Cc: oprofile-list@lists.sf.net Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/20180220205826.2008875-1-arnd@arndb.de Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84095 Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/oprofile/nmi_int.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- 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,