Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2211091imm; Tue, 10 Jul 2018 15:32:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf2DipNsXaUif4f0grsG58QrJkSkTpx+eEmKzbI9Y237SqYUjpAAGVWtkfdY3ta4vDjGjpJ X-Received: by 2002:a62:574d:: with SMTP id l74-v6mr27598103pfb.29.1531261974777; Tue, 10 Jul 2018 15:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531261974; cv=none; d=google.com; s=arc-20160816; b=0oVQtqLBz+o6E7vd68PCdqpPUy1ancP5USoBjg7EFh++ATgc7M5aoR+CPi5vcB0bso EUwCKIRD8e5MloKlOH+EXJ0FuDUJJiJ7P1KkB4tlGvgHRdkl9+iRZZQJ4y9bMU/EleXa HO24jzPiWZhz85mATxCozZ+faIP8wVYlMBFRWRRG1YOL6IBFf5kt7KwCDk/hDEawWgHC H3AjIMLSKxwa1niPaGnUGWLGjlCjRM8VsOY8a3RAFhnqij0P0IddRHsIMtcGDadgxNhd eekg34kTPrw0MVDA7Clxb+T65XAU/aDfvjEf++UQ48f/bJZCYhe+XbbJsW9c+SohqA6M v2ag== 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:arc-authentication-results; bh=W5YwrobrT8JOjhjoevDTDjLhNNbaY43+nV/c8jdvH7s=; b=QkyOwMbfwLqmt5e071wg2AE1C/QNXE4baDfg1pOlzcwm1yzgV+2kgfVgt0ytUu9Hm4 zuYnEERUVJsGx3Vdh5WqpwjPf/ZDRdyOkOiIMmmoe5RHEJHBVNv0s3YPW2HmZ6Udbqjs Q64yD1o0ud/a3yOYgBfw1c53pAQuVCcm5DR+IAGQCOSoUjMk9GzH6Bbcb8hltXuodyaI Z3H6SlC7+/00bjI9A7T9i53812xvSwyrkPlZ+vOEmVDxsMa319FaaxQiDbjOc1Fgfn5m UhRI43wBEKiBck1o0O6PsmQy5dgZB552jl1uCCuL+dBvgnkHRvqNxe8Maf5WJbHXuUM+ /rDw== 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 l81-v6si19442931pfa.368.2018.07.10.15.32.39; Tue, 10 Jul 2018 15:32:54 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732628AbeGJWc6 (ORCPT + 99 others); Tue, 10 Jul 2018 18:32:58 -0400 Received: from mga11.intel.com ([192.55.52.93]:41892 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732408AbeGJWc3 (ORCPT ); Tue, 10 Jul 2018 18:32:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jul 2018 15:31:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,335,1526367600"; d="scan'208";a="70305454" Received: from 2b52.sc.intel.com ([143.183.136.52]) by fmsmga004.fm.intel.com with ESMTP; 10 Jul 2018 15:31:16 -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 v2 24/27] x86: Insert endbr32/endbr64 to vDSO Date: Tue, 10 Jul 2018 15:26:36 -0700 Message-Id: <20180710222639.8241-25-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180710222639.8241-1-yu-cheng.yu@intel.com> References: <20180710222639.8241-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 261802b1cc50..d49548ebec6f 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) @@ -164,6 +168,12 @@ quiet_cmd_vdso = VDSO $@ VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=both) \ $(call cc-ldoption, -Wl$(comma)--build-id) -Wl,-Bsymbolic $(LTO_CFLAGS) +ifdef CONFIG_X86_INTEL_BRANCH_TRACKING_USER + VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)-z$(comma)ibt) +endif +ifdef CONFIG_X86_INTEL_SHADOW_STACK_USER + VDSO_LDFLAGS += $(call cc-ldoption, -Wl$(comma)-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