Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4115894imm; Mon, 20 Aug 2018 10:04:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzAsWIjoCVvGeh8JRE2Om6LV5I2hUkrs9auG+H5E9qOcmNU1dhjjmRPHAWc+cMT7is7Tqks X-Received: by 2002:a62:3a9d:: with SMTP id v29-v6mr48722715pfj.215.1534784671039; Mon, 20 Aug 2018 10:04:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534784670; cv=none; d=google.com; s=arc-20160816; b=Ziy/w2TGEnOMKP5KAx0iwVc31EeQv8+46dzk4byaIyYGbEBbmqC/4oKZaDt1f0uEEg y9/IiYjapdBR589baS4yALQWcPok/TtXkHr6dCnnAjx4V730GTNLQnuccXyOm4Xrnw55 QhGbla0Acyyp4AQqdAxOQ4fGum5CTxxJIdPx7RAT4niseZGM+uMcMQNiHsKBNwG9ylB2 Fh3z0Pq+AaSd9oEwn7C/TCdm+eVSF4mFrwGUuOz+eXbil+EvnVCWjqDO8A6LPAB1TPlw G34Pt0koG+p9pjR+hJbfuwfGDaE/BlITT7frzbiW5XvrNrPj7PVBWm9+SYHkaIm42Qbq y7aw== 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:arc-authentication-results; bh=7427jeK5Guq1EV3P6kA9gOeCpo4xzj0uOJz4ECwyGuM=; b=T4MVdCUDuneqlqm5+pngTmnmlSBaZB6Htt2RJoPPEWbJ348UDfJ0uawdX1ZfHlMfpn ufVdO/lowNRdIYX1f/NCBhiuyBzomiEJe0eHswcsPfs+FYa8stHei5GffVNpDa4hON4M HA5Bf0Mhf47M8K6dM84vuTHdwdmWV1xzT5/Gx9iS6rDJvj/heeuh6KXGt9ZYeSnIPspu soUwWOXqoGvKwKm9T08X8Gb52mDNQedW1EWnjjqCXX4STDd1/o2iPMTQFB8esKizc5K0 fsKmD1tkKO99hhoHYyy+u+VNutZHciUWcYQcVKFuiyTUDe9MKn13tK+SjGggFPZPI9Y/ SxnQ== 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 r7-v6si7009078pgn.663.2018.08.20.10.04.15; Mon, 20 Aug 2018 10:04:30 -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 S1727067AbeHTT1a (ORCPT + 99 others); Mon, 20 Aug 2018 15:27:30 -0400 Received: from terminus.zytor.com ([198.137.202.136]:54457 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726099AbeHTT1a (ORCPT ); Mon, 20 Aug 2018 15:27:30 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w7KGABb92126004 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 20 Aug 2018 09:10:11 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w7KGABuC2126001; Mon, 20 Aug 2018 09:10:11 -0700 Date: Mon, 20 Aug 2018 09:10:11 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Andy Lutomirski Message-ID: Cc: mingo@kernel.org, dwmw2@infradead.org, luto@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, ak@linux.intel.com, bp@alien8.de, hpa@zytor.com, matt@softrans.com.au, jason.vas.dias@gmail.com, tglx@linutronix.de Reply-To: tglx@linutronix.de, jason.vas.dias@gmail.com, bp@alien8.de, linux-kernel@vger.kernel.org, ak@linux.intel.com, peterz@infradead.org, matt@softrans.com.au, hpa@zytor.com, dwmw2@infradead.org, luto@kernel.org, mingo@kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/vdso: Fix vDSO build if a retpoline is emitted Git-Commit-ID: 2e549b2ee0e358bc758480e716b881f9cabedb6a 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.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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: 2e549b2ee0e358bc758480e716b881f9cabedb6a Gitweb: https://git.kernel.org/tip/2e549b2ee0e358bc758480e716b881f9cabedb6a Author: Andy Lutomirski AuthorDate: Thu, 16 Aug 2018 12:41:15 -0700 Committer: Thomas Gleixner CommitDate: Mon, 20 Aug 2018 18:04:41 +0200 x86/vdso: Fix vDSO build if a retpoline is emitted Currently, if the vDSO ends up containing an indirect branch or call, GCC will emit the "external thunk" style of retpoline, and it will fail to link. Fix it by building the vDSO with inline retpoline thunks. I haven't seen any reports of this triggering on an unpatched kernel. Fixes: commit 76b043848fd2 ("x86/retpoline: Add initial retpoline support") Signed-off-by: Andy Lutomirski Signed-off-by: Thomas Gleixner Acked-by: Matt Rickard Cc: Borislav Petkov Cc: Jason Vas Dias Cc: David Woodhouse Cc: Peter Zijlstra Cc: Andi Kleen Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/c76538cd3afbe19c6246c2d1715bc6a60bd63985.1534448381.git.luto@kernel.org --- Makefile | 4 ++++ arch/x86/entry/vdso/Makefile | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a0650bf79606..7bab2e90e4e1 100644 --- a/Makefile +++ b/Makefile @@ -507,9 +507,13 @@ KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) endif RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register +RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk +RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) +RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) export RETPOLINE_CFLAGS +export RETPOLINE_VDSO_CFLAGS KBUILD_CFLAGS += $(call cc-option,-fno-PIE) KBUILD_AFLAGS += $(call cc-option,-fno-PIE) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 9f695f517747..fa3f439f0a92 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -68,9 +68,9 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ $(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ -fno-omit-frame-pointer -foptimize-sibling-calls \ - -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO + -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO $(RETPOLINE_VDSO_CFLAGS) -$(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) +$(vobjs): KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS) $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS)) $(CFL) # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. @@ -132,11 +132,13 @@ KBUILD_CFLAGS_32 := $(filter-out -mcmodel=kernel,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) +KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING +KBUILD_CFLAGS_32 += $(RETPOLINE_VDSO_CFLAGS) $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) $(obj)/vdso32.so.dbg: FORCE \