Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2249247imm; Thu, 7 Jun 2018 07:41:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIpfybaGVNgsS8aPLhnna8Cg9RJuzD0JQjduVQ+Dzitq4QLihDTKItxUSl9QEBAfJgOJ1rt X-Received: by 2002:a17:902:246a:: with SMTP id m39-v6mr2295333plg.141.1528382500906; Thu, 07 Jun 2018 07:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528382500; cv=none; d=google.com; s=arc-20160816; b=KUH4gSJdKDgNXqGZ31JsE1yfr8D4mveQVIbsgcYx2aTSd/PUOk67Q1+ge6BNtZPCv9 562jRVC6NiruJrFtk00NK4QCgiYSdMOgAbH1w5FiMeXf5tS0ky+AwHNaw2WAJ2Cyp/8R 7lNHJl8F3wAiQsFMEZwQXk0frId0wyWkIzSbRu4diWms5rRXFCrIlZf4TlqIMT9FCI9y owEwWCng1hQG1YqPm/LTOHATIAdIV0oGhIJGz1xda46ec0u/pe6Uiit1qPp6CVXDH+uA Ty0BPYkbe+7IYP2Knb8mTN5ERp4weyvOtCPVbGNODEB0pq1i8UtoxJIrTDEmW2yX5gKI N1YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=oBxUTzkCZRHN7TjTKYKGXQf1c6IHsuAozZ07WhI+XX4=; b=H3YbYe6Tcv1U6YdFbYzOJ+MP8oJfdxOYJ9BCZ21QnW1M0pYzpczbYqj3nvSnifPNJ2 FiHbgWWXp4eYvyssBj2rVyUPWDg0vB0/UJ7Pwz5biNROOv93OtQmSxIjPNImyhNVOQ2I +/1ELY2cmW+LqAZ5PUv6hJ0sVd6/ezEJGYRPObvbkW0HqdhUMYtStG4Hsn+bys+dOKX9 AcUfAsSQfcVI7hCpHNo/EEHG/N37X1sU0lU16r7IxLzklgvfm3Lo+1Eg3FtMAVTToHfz PDsV8ereCem+sJSUbOC8ENJLEb9v4cuLRpcpkkwpo3q8dU+6+liO4RZuBy1wyTaCC76h 2KcQ== 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 o61-v6si31963264pld.109.2018.06.07.07.41.25; Thu, 07 Jun 2018 07:41:40 -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 S934279AbeFGOjN (ORCPT + 99 others); Thu, 7 Jun 2018 10:39:13 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40484 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934244AbeFGOin (ORCPT ); Thu, 7 Jun 2018 10:38:43 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbY-0005hK-Rt; Thu, 07 Jun 2018 15:09:33 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb9-00036o-Ck; Thu, 07 Jun 2018 15:09:07 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Ingo Molnar" , "Jessica Yu" , "Robert Richter" , "Kees Cook" , oprofile-list@lists.sf.net, "Peter Zijlstra" , "Arnd Bergmann" , "Martin Sebor" , stable@decadent.org.uk, "Linus Torvalds" , "Thomas Gleixner" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 275/410] x86/oprofile: Fix bogus GCC-8 warning in nmi_setup() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 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 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: Ben Hutchings --- 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 @@ -471,7 +471,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,