Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4809369yba; Tue, 30 Apr 2019 04:52:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwhaSAYycYr58nywkWUnseHMXl9HrOD2fMwceu2vI4w0V0ilqKYBfWxMlUr37Svc+nAgbk X-Received: by 2002:a17:902:8f88:: with SMTP id z8mr62472340plo.54.1556625157406; Tue, 30 Apr 2019 04:52:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625157; cv=none; d=google.com; s=arc-20160816; b=zl/4UxeT1IktYF9mVSwWY8m6cz7Td0j3TbK/iXYsgrGreHpaOQmCtgJFrfCv0efKLI Yq1kKOWAu5I9l1D5g9J0AjLqmIJbbHOd9atUG1bsxeGKbNBVS4C/E44nmewmudtitLfi RklOosWkKNbndLNPAh1wW/LjuRGcwfbZIWq9CI1H9qLyQGPp8T7oZwpjcvNq+i+DCarp GJ8bzi2H7H6N7c/FecVhuoL72eDGZmgqT5VsvI+5Iu3YJHdHhiW5M7WdxLUriEWgnn9A h+JuBQjIYxt37mDn4u6+7T8UAa4klMhL2B9G8cs7d1UsHzltAxlOvSPTNi2FPMaKyYxw sjzg== 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=E7i8DwusyUg+YiB1NpWTb02Wi674TlVM+TV6ncSt+Ck=; b=sfzHXst5BCS3i1qDrKgOa9nx6cnNK1QI2YRnSun05UpX5aLTzn7pREg2/PdCjZa5Di 4SMFqjZ3drDtqF/EVkfv9f6Vu4AcUig3vsOn9FKTpHDB4apNuks7mJZgWVHdUx6jlRNK RtoLh/xLOZQKV4bpN+fY1wyZNKEC2DJkqbdsjUas7k9Q8YRkO5J5tHCL1jemvtxF6F0d CCUt9pzxJLoLIJKabK55qGcUltEjWIYw00gkbccdrkl9HrquVFU7EX+WzZexU6j88jpI eB0H89AT9eirugOEo/gQQ+CgyEauMWZC2RPhyoc73nOnUQH9jdu5o6KDIRKOb956T1qb R63Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0zwtNpDs; 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 cc13si8496991plb.412.2019.04.30.04.52.21; Tue, 30 Apr 2019 04:52:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0zwtNpDs; 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 S1731259AbfD3Lus (ORCPT + 99 others); Tue, 30 Apr 2019 07:50:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:37976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731242AbfD3Luq (ORCPT ); Tue, 30 Apr 2019 07:50:46 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 3FAF7217D7; Tue, 30 Apr 2019 11:50:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625045; bh=cUaKSgK4eY5t1e5ug1XCmp54Ae2uvXdLgtwXw4kbrhg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0zwtNpDsDqoOi6/+u4LN0174egLutNmMcrBtJOA8ISo8g1mmwKsnsIqe8tks5UmEM FOdb4Vx3JE+uEng7v+7dIxg/tXjWETjXEBr91HnV7h3VtflCU95BfDOLNB6ereNr3a dn+OP329aiP1KeA2Yf8PtQGP1Bqqflo20+MaRVMg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martin Liska , Daniel Borkmann , Thomas Gleixner , David Woodhouse , Linus Torvalds , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Alexei Starovoitov , "H.J. Lu" , "David S. Miller" Subject: [PATCH 5.0 70/89] x86/retpolines: Disable switch jump tables when retpolines are enabled Date: Tue, 30 Apr 2019 13:39:01 +0200 Message-Id: <20190430113613.022729570@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Daniel Borkmann commit a9d57ef15cbe327fe54416dd194ee0ea66ae53a4 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- arch/x86/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -220,8 +220,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