Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp440456ybb; Thu, 28 Mar 2019 05:44:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2bhM+nGiI8/lukId1i29wSRwNRHPG+NY7AFPCcf5hRURpz4RMcg0HexNOjn3wqGuHZUF0 X-Received: by 2002:a63:d4f:: with SMTP id 15mr40021629pgn.162.1553777099405; Thu, 28 Mar 2019 05:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553777099; cv=none; d=google.com; s=arc-20160816; b=q4zPPAxCHS1BMi91Xq8eIBFl00eapwzI4tQ5N3v1hCBOI/xsGpRzAeilxztzBlZM46 u6zpihgzIsIFSxC7D9RPo6RCdeaumVjrRPjvkTAtvLZ0EnNWl+9aNlTw9d/O2fCuIv7A 9MiHjKg6ijt/D2O4/yjB6KsLy+usd7hm1fPMUlxmp/PpoVbsCZ0vnRfyeWfkZrimQ+bh cbiOsa/6EDr+eMk6FI0jWN4DZ1iTrHy4ohq7xjxkiItBJyZOqcnxHjG6aYjKGPcPpK71 v/C2nIzNsyVSfDHwaUxpt84IaOwTqgC/nbdzx94KrqrkCGVXl6vYgFvX1VftU3/YdazM LWdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=0oO+LeqvGP0ltr7CaS5f6lvOltBoWWugKY9ZSTvMxVc=; b=js22YMjL4W7UTsOUY5ONp+KFlOG4wRmMV3PrHZMVXAGhFYVRJipV4W0WJap8pm9GTR OcLFmmpvYSqYBfonwecBqbunwgCOvYsL4fM+46FNL2SvaMlt2IWe4ps63CLb5nwtVRRn MXNQb/4T5o/k4qYzDhNHwGJQkOLtIVt7/P7oGdo3P5Gku+i0o+kcWwU4wLJOsdh8ag9g /VTUDBGS+clrjgr3Iec7K1S1zOgRQje9zDoeAWWFWnfQNlVmyM5jzOpRl9Iy0g4y6UFf GN0Z7T9iyi+Csir5sUBXqHj/ImeOwXArQdoUN7OtUrnQc9XdM6GcPtFHffieEti8lgn5 atww== 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 b8si21364813pgl.153.2019.03.28.05.44.43; Thu, 28 Mar 2019 05:44:59 -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 S1727135AbfC1Mn7 (ORCPT + 99 others); Thu, 28 Mar 2019 08:43:59 -0400 Received: from terminus.zytor.com ([198.137.202.136]:59489 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbfC1Mn7 (ORCPT ); Thu, 28 Mar 2019 08:43:59 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x2SCh3WV3319930 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 28 Mar 2019 05:43:03 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x2SCh2C43319927; Thu, 28 Mar 2019 05:43:02 -0700 Date: Thu, 28 Mar 2019 05:43:02 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Daniel Borkmann Message-ID: Cc: magnus.karlsson@intel.com, dwmw2@infradead.org, tglx@linutronix.de, mliska@suse.cz, torvalds@linux-foundation.org, ast@kernel.org, hpa@zytor.com, daniel@iogearbox.net, mingo@kernel.org, bjorn.topel@intel.com, davem@davemloft.net, linux-kernel@vger.kernel.org, hjl.tools@gmail.com, brouer@redhat.com Reply-To: davem@davemloft.net, bjorn.topel@intel.com, mingo@kernel.org, daniel@iogearbox.net, hpa@zytor.com, torvalds@linux-foundation.org, ast@kernel.org, mliska@suse.cz, tglx@linutronix.de, dwmw2@infradead.org, magnus.karlsson@intel.com, brouer@redhat.com, hjl.tools@gmail.com, linux-kernel@vger.kernel.org In-Reply-To: <20190325135620.14882-1-daniel@iogearbox.net> References: <20190325135620.14882-1-daniel@iogearbox.net> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/retpolines: Disable switch jump tables when retpolines are enabled Git-Commit-ID: a9d57ef15cbe327fe54416dd194ee0ea66ae53a4 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=2.2 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_03_06,FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a9d57ef15cbe327fe54416dd194ee0ea66ae53a4 Gitweb: https://git.kernel.org/tip/a9d57ef15cbe327fe54416dd194ee0ea66ae53a4 Author: Daniel Borkmann AuthorDate: Mon, 25 Mar 2019 14:56:20 +0100 Committer: Thomas Gleixner CommitDate: Thu, 28 Mar 2019 13:39:48 +0100 x86/retpolines: Disable switch jump tables when retpolines are enabled Commit ce02ef06fcf7 ("x86, retpolines: Raise limit for generating indirect calls from switch-case") raised the limit under retpolines to 20 switch cases where gcc would only then start to emit jump tables, and therefore effectively disabling the emission of slow indirect calls in this area. After this has been brought to attention to gcc folks [0], Martin Liska has then fixed gcc to align with clang by avoiding to generate switch jump tables entirely under retpolines. This is taking effect in gcc starting from stable version 8.4.0. Given kernel supports compilation with older versions of gcc where the fix is not being available or backported anymore, we need to keep the extra KBUILD_CFLAGS around for some time and generally set the -fno-jump-tables to align with what more recent gcc is doing automatically today. More than 20 switch cases are not expected to be fast-path critical, but it would still be good to align with gcc behavior for versions < 8.4.0 in order to have consistency across supported gcc versions. vmlinux size is slightly growing by 0.27% for older gcc. This flag is only set to work around affected gcc, no change for clang. [0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86952 Suggested-by: Martin Liska Signed-off-by: Daniel Borkmann Signed-off-by: Thomas Gleixner Cc: David Woodhouse Cc: Linus Torvalds Cc: Jesper Dangaard Brouer Cc: Björn Töpel Cc: Magnus Karlsson Cc: Alexei Starovoitov Cc: H.J. Lu Cc: Alexei Starovoitov Cc: David S. Miller Link: https://lkml.kernel.org/r/20190325135620.14882-1-daniel@iogearbox.net --- arch/x86/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 2d8b9d8ca4f8..a587805c6687 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -219,8 +219,12 @@ ifdef CONFIG_RETPOLINE # Additionally, avoid generating expensive indirect jumps which # are subject to retpolines for small number of switch cases. # clang turns off jump table generation by default when under - # retpoline builds, however, gcc does not for x86. - KBUILD_CFLAGS += $(call cc-option,--param=case-values-threshold=20) + # retpoline builds, however, gcc does not for x86. This has + # only been fixed starting from gcc stable version 8.4.0 and + # onwards, but not for older ones. See gcc bug #86952. + ifndef CONFIG_CC_IS_CLANG + KBUILD_CFLAGS += $(call cc-option,-fno-jump-tables) + endif endif archscripts: scripts_basic