Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4925039imc; Mon, 25 Feb 2019 13:46:10 -0800 (PST) X-Google-Smtp-Source: AHgI3IbkrTxbN4b3qV12//jOPgdbkI3iTa/W27stEiYio756Fx0G+W9mbwb/gj+VCxFsKR6MKZTJ X-Received: by 2002:a62:cf02:: with SMTP id b2mr22296064pfg.71.1551131170133; Mon, 25 Feb 2019 13:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551131170; cv=none; d=google.com; s=arc-20160816; b=jSVuTWqBx+NB43p36LY/yvO/f55jFESoYbr1ASCe8V6n3ERmDj04+5b8oAsvNseSbq YcgQ8d8hpZh7jF6cI/y4jqbEVWMq6L0TPX4w2IpeVlZaMV/F9zUTJCQWltcZdFv+TViv qM82KLZ07qg7OvMzfAARgU1mi5d4ej0dqezC6R2f4EJufBnbyUbVNEX3rU2fH7BzQIvb dE7viCEvWUx2ZETwAJjzNYLb2YaIq30Tyi5NewdQZwfDL7YM92AmMcNqVW2fLif4Bvr8 1LZkr+Ia/X6TWAss6FzdT3nIC+BTrbLsSDPNWFflm1gbPp2tVoNQcO2p4T/xctWn+wx4 hd/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NratZg4+xRWTbzbViBSwRr9/mi4MrGWDs4vXqNRhcJA=; b=Z1Nv+xqga+o20/QjQ568lzJjtPepWeMwEOKfK+6BDykb6fejz+uXV7yLreIP4fxstG 8yzuKdwpplnB/NkBgWAjD3CbJUV4NmV//COAQlquFPlvhEU1rHRzjI+dqgVlT/iCtO3z 7q0fXP/u4pK2sYZP/NrWjf+62CzGUexHhLpEJn+Pm0pT74Bbautczjwx+8+Ff/oP2/TA InJw/jW0KBjNWAleyqD8Rah6Ur7eMokGZ8So/I+fFlTj9XFfzA2nw/W+isXlfpq1ATN9 F+HgxPh5IgQx53Tt+k6kpTwk6+1pm/8Ey6mtyN43NWRyZT2wW0coastidJ7UM+hvtfVt /nrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HeiuJ4eA; 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 w14si10192767pga.212.2019.02.25.13.45.55; Mon, 25 Feb 2019 13:46:10 -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; dkim=pass header.i=@kernel.org header.s=default header.b=HeiuJ4eA; 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 S1732257AbfBYVbK (ORCPT + 99 others); Mon, 25 Feb 2019 16:31:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:36718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732038AbfBYVbG (ORCPT ); Mon, 25 Feb 2019 16:31:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A8742184D; Mon, 25 Feb 2019 21:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551130265; bh=7Qpa2GLiJyH3j5BLiudMJWt7g7G7CucHxVqyzqtDWPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HeiuJ4eAgB+75WK2TeepChpnElPgsRJlAe6UnRKwyZ6z0sEuKpP4a22wPhryPp+Hj thEQwLIjX1RDq3wMcHwj1YrGQG+YOoVXVtvUHWusR7ex+DdttlTKhdgrP7R3peWLff 8+8kTqMwqWVjryTwj0gQBwdRrDYq17IQblT01poY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eli Friedman , Joe Perches , Linus Torvalds , Nick Desaulniers , "Michael S. Tsirkin" , Miguel Ojeda , Sasha Levin Subject: [PATCH 4.20 059/183] include/linux/compiler*.h: fix OPTIMIZER_HIDE_VAR Date: Mon, 25 Feb 2019 22:10:32 +0100 Message-Id: <20190225195104.432674475@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195054.748060397@linuxfoundation.org> References: <20190225195054.748060397@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 3e2ffd655cc6a694608d997738989ff5572a8266 ] Since commit 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") clang no longer reuses the OPTIMIZER_HIDE_VAR macro from compiler-gcc - instead it gets the version in include/linux/compiler.h. Unfortunately that version doesn't actually prevent compiler from optimizing out the variable. Fix up by moving the macro out from compiler-gcc.h to compiler.h. Compilers without incline asm support will keep working since it's protected by an ifdef. Also fix up comments to match reality since we are no longer overriding any macros. Build-tested with gcc and clang. Fixes: 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive") Cc: Eli Friedman Cc: Joe Perches Cc: Linus Torvalds Reviewed-by: Nick Desaulniers Signed-off-by: Michael S. Tsirkin Signed-off-by: Miguel Ojeda Signed-off-by: Sasha Levin --- include/linux/compiler-clang.h | 5 ++--- include/linux/compiler-gcc.h | 4 ---- include/linux/compiler-intel.h | 4 +--- include/linux/compiler.h | 4 +++- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index 3e7dafb3ea809..7ddaeb5182e33 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -3,9 +3,8 @@ #error "Please don't include directly, include instead." #endif -/* Some compiler specific definitions are overwritten here - * for Clang compiler - */ +/* Compiler specific definitions for Clang compiler */ + #define uninitialized_var(x) x = *(&(x)) /* same as gcc, this was present in clang-2.6 so we can assume it works diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 977ddf2774f97..c61c4bb2bd15f 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -58,10 +58,6 @@ (typeof(ptr)) (__ptr + (off)); \ }) -/* Make the optimizer believe the variable can be manipulated arbitrarily. */ -#define OPTIMIZER_HIDE_VAR(var) \ - __asm__ ("" : "=r" (var) : "0" (var)) - /* * A trick to suppress uninitialized variable warning without generating any * code diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index 517bd14e12224..b17f3cd18334d 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -5,9 +5,7 @@ #ifdef __ECC -/* Some compiler specific definitions are overwritten here - * for Intel ECC compiler - */ +/* Compiler specific definitions for Intel ECC compiler */ #include diff --git a/include/linux/compiler.h b/include/linux/compiler.h index fc5004a4b07d7..445348facea97 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -161,7 +161,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #endif #ifndef OPTIMIZER_HIDE_VAR -#define OPTIMIZER_HIDE_VAR(var) barrier() +/* Make the optimizer believe the variable can be manipulated arbitrarily. */ +#define OPTIMIZER_HIDE_VAR(var) \ + __asm__ ("" : "=r" (var) : "0" (var)) #endif /* Not-quite-unique ID. */ -- 2.19.1