From patchwork Thu Aug 30 14:40:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10581889 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B31F5A4 for ; Thu, 30 Aug 2018 14:46:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ABDC2B735 for ; Thu, 30 Aug 2018 14:46:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E4CA2BC88; Thu, 30 Aug 2018 14:46:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE34E2B735 for ; Thu, 30 Aug 2018 14:46:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 519036B5249; Thu, 30 Aug 2018 10:44:46 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3FC346B5245; Thu, 30 Aug 2018 10:44:46 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22D8A6B5248; Thu, 30 Aug 2018 10:44:46 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id CC5766B5244 for ; Thu, 30 Aug 2018 10:44:45 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id v195-v6so5167925pgb.0 for ; Thu, 30 Aug 2018 07:44:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to :subject:date:message-id:in-reply-to:references; bh=DzxbjDY4h6ee9dgtV6hY0nHV4jolczbZKl0Vg0iYMGs=; b=TDe7Oduq6vB1sFXqi4nRsLCJg4hdMg1Un2u9a9z+Q8mUHQ/GXyz3NU26dfAwQ+uZcl Ye7sxxuIB2s0HfMHHBfIvNsJHPsqsyzIYamwQzWb5WHddJD3o47QR9WlrNJmcH8X65MC oh76krv+KSrEUpXtTmVjz9B3Tb1zWmh1kbqPJMWhjpjsB/B0Zy+KKsw5zigo0/bkJ0qB 3u46MNjdi1BBk1M7VXVAHxUvQnflZd62zE/Sr8PdOu2+uXMs7n52S4zj5TsyKMLTaueu 56IrfgTucuFQymQBWKl6U4Jz5OEJQ70ReVELGe1nKcf/EXKhPUqgX+SxbIXR7gbYmFuV I4Vg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: APzg51AmIZryaZNQq0zNdLI82KHYVm0k9nD5mu3P0wU5Rn3xxPS6iju+ YwbIR9lGSEo+woqHoHJ3xlVFvlNtuH1nhD0mdeRmwdA00vN6A8zAdrTCEpce4sP7bzouezmpQnX K8RVpFTG9gm/umWNm6cfqELwwwS1zpuugDeHtB4K7ASjpgeChGwI0fgGULYIenShQXQ== X-Received: by 2002:a62:2483:: with SMTP id k3-v6mr10961177pfk.195.1535640285516; Thu, 30 Aug 2018 07:44:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYdgbUYBrt3ZUKE7V5ZsywnBHzLdT7kwdZBUrhm//A3s3e3Z4VUg330OR4IhVjR5gB5G6Bz X-Received: by 2002:a62:2483:: with SMTP id k3-v6mr10961155pfk.195.1535640284826; Thu, 30 Aug 2018 07:44:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535640284; cv=none; d=google.com; s=arc-20160816; b=IjkFTSBd0bA0ETNqCxbkJ5Y954+FTOnjMkBZwEGwMroZKeX/w9zC7YuAMAHzU+0vYk WnrHS6zNTBvfr+eMy5r/ZuHp0GLn7erzsAFXanFSksHDXa9MjOdUDPIE47T5CfzzYqie WZJrX8nvHIR5IQNXJ/JMhsFQ3Bk77bKgc70hWUC/lHw7dcoklgQAaZfPPiS3MWhcbTig Drnw1JPxRjg3R1gkwy4X6FyMqFbfDqllW168oAGaV9KOqdNgfs+E8asTNlsVRhWOY0Fv bUK6z09ScwhfazHFx0evQtj+dnW35NLsuBCNASi4axKXoyXllCHTrJPZokR5V7bZLY7P 2EzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :arc-authentication-results; bh=DzxbjDY4h6ee9dgtV6hY0nHV4jolczbZKl0Vg0iYMGs=; b=Y6FAuOpy/jMR6tsxBa9ToojmFMkULuEkzClbQgsZEgY2egiviJ/srvOKz3wlq02rbs P11ndsu138Tid8eL4j76rnTtlmCEAt4cdE1ymrl0KiUvaAzeP5T9RzL1V//Ekv7Ibg2J zpyqgQRz+G15fLP156Z3IFK01QNy+aPTlJfy+hXUlfebU68TST7OTXnNWphWhkAFo8FR I1Xnw65wouKyTlOOsurJprznyHFoYeXX2amLgh6f2f9WwaEEKQMewVqXsrjKzQklAMwA hBCEfUPpmtqBpMVl+2vgzasQvrVaMEAbCdIi3oMZzMMUtnyIRyMROYUurXD+0rnBOnB+ i8dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga18.intel.com (mga18.intel.com. [134.134.136.126]) by mx.google.com with ESMTPS id m13-v6si6713043pgk.251.2018.08.30.07.44.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 07:44:44 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) client-ip=134.134.136.126; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 07:44:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,307,1531810800"; d="scan'208";a="228910414" Received: from 2b52.sc.intel.com ([143.183.136.52]) by orsmga004.jf.intel.com with ESMTP; 30 Aug 2018 07:44:33 -0700 From: Yu-cheng Yu To: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , "Ravi V. Shankar" , Vedvyas Shanbhogue Subject: [RFC PATCH v3 7/8] x86: Insert endbr32/endbr64 to vDSO Date: Thu, 30 Aug 2018 07:40:08 -0700 Message-Id: <20180830144009.3314-8-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830144009.3314-1-yu-cheng.yu@intel.com> References: <20180830144009.3314-1-yu-cheng.yu@intel.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: "H.J. Lu" When Intel indirect branch tracking is enabled, functions in vDSO which may be called indirectly must have endbr32 or endbr64 as the first instruction. Compiler must support -fcf-protection=branch so that it can be used to compile vDSO. Signed-off-by: H.J. Lu --- arch/x86/entry/vdso/.gitignore | 4 ++++ arch/x86/entry/vdso/Makefile | 12 +++++++++++- arch/x86/entry/vdso/vdso-layout.lds.S | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/.gitignore b/arch/x86/entry/vdso/.gitignore index aae8ffdd5880..552941fdfae0 100644 --- a/arch/x86/entry/vdso/.gitignore +++ b/arch/x86/entry/vdso/.gitignore @@ -5,3 +5,7 @@ vdso32-sysenter-syms.lds vdso32-int80-syms.lds vdso-image-*.c vdso2c +vclock_gettime.S +vgetcpu.S +vclock_gettime.asm +vgetcpu.asm diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index fa3f439f0a92..8694f70c08e6 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -102,13 +102,17 @@ vobjx32s := $(foreach F,$(vobjx32s-y),$(obj)/$F) # Convert 64bit object file to x32 for x32 vDSO. quiet_cmd_x32 = X32 $@ - cmd_x32 = $(OBJCOPY) -O elf32-x86-64 $< $@ + cmd_x32 = $(OBJCOPY) -R .note.gnu.property -O elf32-x86-64 $< $@ $(obj)/%-x32.o: $(obj)/%.o FORCE $(call if_changed,x32) targets += vdsox32.lds $(vobjx32s-y) +ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER + $(obj)/vclock_gettime.o $(obj)/vgetcpu.o $(obj)/vdso32/vclock_gettime.o: KBUILD_CFLAGS += -fcf-protection=branch +endif + $(obj)/%.so: OBJCOPYFLAGS := -S $(obj)/%.so: $(obj)/%.so.dbg $(call if_changed,objcopy) @@ -160,6 +164,12 @@ quiet_cmd_vdso = VDSO $@ VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ $(call ld-option, --build-id) -Bsymbolic +ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER + VDSO_LDFLAGS += $(call ldoption, -z$(comma)ibt) +endif +ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER + VDSO_LDFLAGS += $(call ldoption, -z$(comma)shstk) +endif GCOV_PROFILE := n # diff --git a/arch/x86/entry/vdso/vdso-layout.lds.S b/arch/x86/entry/vdso/vdso-layout.lds.S index acfd5ba7d943..cabaeedfed78 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -74,6 +74,7 @@ SECTIONS .fake_shstrtab : { *(.fake_shstrtab) } :text + .note.gnu.property : { *(.note.gnu.property) } :text :note .note : { *(.note.*) } :text :note .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr