Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3307403imu; Mon, 19 Nov 2018 13:56:36 -0800 (PST) X-Google-Smtp-Source: AJdET5cRnPUelPcMSu75viSWfUiuIV3/SpdHP/NcAxnBdcNtVP0hilWZak8O1L43bUFyIc9CeXdf X-Received: by 2002:a62:1d14:: with SMTP id d20mr24562374pfd.221.1542664596041; Mon, 19 Nov 2018 13:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542664596; cv=none; d=google.com; s=arc-20160816; b=U1IpAX6Y3ryGYvVvhHgZduvwR3HOHqf1tQIU7FdsTflmidBEqE/BeNhufJNP4tVcHA mkohwBCOB1nAgK7ThyNtnbA2RV3ENkC6aUTRAGL1Z+l9U6l86wC6vhI7VwWPicCl4sVl Y24hzZTalVYnwdj5XgDBGUQheu8q2J41PgiXzddLpKXcM/uNd0ZF4PTC/LNIsNX4lRRJ 0iMYqnZNk8jAGlgLA/UqLfneNLBbThWrlkMVeJnwpO7JJ3L1IG6lES325JGk6aatJOHb F5iQ0Zk0MyZs+iXUNxPMmPVe7sz9Q/QT6rij0c9ANlCP8Frw3VBPp/SXaHqkY+3z1iVi OMzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from; bh=0lwKd3VCdluxV9TIoAnzM2ZXz+CjhIEXN1/3QJINxnU=; b=QsfDMEIw4wPgWeHNP6VW8SxtJ72J4a5fRMPoF1NaASfDdXQ1TYQlpjTucVY6ia90ff WxJz0Vqrctjn8pqMiKTqtayR9wHMSLzUWiUwyx+UcjQJjVz24FNpNKNVE2Tsffk2Isa2 asNb25Q7AdNw67Oh+gbS8lP+PA9jA/qLkbgM7DHSPQnKeG9STh4YE8kXOX9jJn0patFR 6IzazyKHsQkJ8dvBzZ2y7C5TifBWNKFWbUOIMsTDeeAVMjdrYxhVvZGbxBVU3y7nwm5D aYKY6fX2tKWnTBxSr5AHlSMo6oP30gPSXcYcbrBuvF4/3mdgGAiqZr1vKPev61GGbhHR wQow== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s59si868653plb.237.2018.11.19.13.56.21; Mon, 19 Nov 2018 13:56:35 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731829AbeKTIUo (ORCPT + 99 others); Tue, 20 Nov 2018 03:20:44 -0500 Received: from mga09.intel.com ([134.134.136.24]:32114 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731793AbeKTIUn (ORCPT ); Tue, 20 Nov 2018 03:20:43 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2018 13:55:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,254,1539673200"; d="scan'208";a="92423920" Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by orsmga006.jf.intel.com with ESMTP; 19 Nov 2018 13:55:01 -0800 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 , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue Subject: [RFC PATCH v6 08/11] x86: Insert endbr32/endbr64 to vDSO Date: Mon, 19 Nov 2018 13:49:31 -0800 Message-Id: <20181119214934.6174-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181119214934.6174-1-yu-cheng.yu@intel.com> References: <20181119214934.6174-1-yu-cheng.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 141d415a8c80..0b1b464e7ae7 100644 --- a/arch/x86/entry/vdso/Makefile +++ b/arch/x86/entry/vdso/Makefile @@ -108,13 +108,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) @@ -172,6 +176,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 -- 2.17.1