From patchwork Thu Jun 6 20:09:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu-cheng Yu X-Patchwork-Id: 10980437 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 EAAD51515 for ; Thu, 6 Jun 2019 20:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D81B228A6D for ; Thu, 6 Jun 2019 20:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA6E528AA7; Thu, 6 Jun 2019 20:17:57 +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 4FFA528A6D for ; Thu, 6 Jun 2019 20:17:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FCD66B02CC; Thu, 6 Jun 2019 16:17:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 42BCA6B02D2; Thu, 6 Jun 2019 16:17:35 -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 AE0556B02CC; Thu, 6 Jun 2019 16:17:34 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 2F03D6B02CA for ; Thu, 6 Jun 2019 16:17:34 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id s12so2178861plr.5 for ; Thu, 06 Jun 2019 13:17:34 -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=Hx9fQCfaehHECdP3yUizJoBr9I2sEjxAxWtfgK/yKTI=; b=STPXUahj12rqDzCZEoXhDAllgnMezT95+9RtTgT2xb+EhTQ2lr2f/4An38RVSNT+FH 2UDb9CwmQVgsbGkul76FJ48IfWukSEc3hWX5UjKhoHlIbR27+zV88ts5Ayu9QqMMQs+X LOzSuuiC2Cjf14zlufo+CgILtTHT7PXXytjlavPOFhF9vRiB3uyfx5ezj5lsH83iZSDq gAqEtjTeO25nHoJqZWRwS6xOwT8/WW6mqdujJpmNlMnLfXKR8g6JBwtEYN6Aq/LBrm0y R0zl/GfAFVFCh/WSupZAmF90+dIC9w8moYWAeG4HmzthhldQ/WnU4dGXa1IHhaSQw+po IhhA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 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: APjAAAU2/e+DNEqcPYjTM/+jU5VBVnJINR3xYw+3pyGBNJEDqU55uvRX BDJnsIUS3l0eAuc2kOfGmVHrz6xp0w5/Rfaf5+unDbefeo2wOi56FMaE6cy8Dg53ogbEemYpKGk URPu1hjUWj859JgJWdovdk3u1rgXp1xigFCirYg/vgAcW5GMDuVF9OcJyLa/s1p6zQw== X-Received: by 2002:a17:902:7003:: with SMTP id y3mr52080652plk.70.1559852253858; Thu, 06 Jun 2019 13:17:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8v11zYNr78rPRmoIaelqPmiM6j1XCexI3tWll0ujRDQOvmh2V5U4uqAU29z0Eziw8yDJu X-Received: by 2002:a17:902:7003:: with SMTP id y3mr52080571plk.70.1559852252590; Thu, 06 Jun 2019 13:17:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559852252; cv=none; d=google.com; s=arc-20160816; b=xsfriLt7oXl8uY0lyMFAm1xPpeedsBgOxit19mHRVecPxOUjlaJpY6SDZK+C8J7ONr lIrWzTeIfw9HLEPOUJCVM/YsbBd95EGMur3GI16P/yvIRXGEcnoEzW2CyKUafN1/3W73 GWcFR9lAvWMurryesbrFLQ1QSZwZgFHGuh9fnMjB5u8JJx7N0wse/6807x52JFPl148N VvmGkK29LLAxMKeaUk0XaMiaDwQC2lP7ifrwtnOoWSlSqwhj/joCMP96fQ82rks/IQ4j vaLnaE87/GN1NGI42T5nssOX74PE3i6znAh1B5c3D0N8GyEhJoyAGdwuuMpgsbu62csr OZjw== 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; bh=Hx9fQCfaehHECdP3yUizJoBr9I2sEjxAxWtfgK/yKTI=; b=yvwYHlECx4wTP+sgjiI0UYHStY8gzEb8nADy9dxi8KihmtMNGAG2nPPFdSSW2jTSEl aABMjLODVOGbpIoaZRPIipMKU8NIbB2l4JZh95RToPvuApa0jJ3T15X5McKTLpLjcTCc jn4C68Xm8SohiBdz05RHxM6vbIqjPew8I8eXhfIUamALG3JCybCvNZTUqZ3LOWzkg5uM fvLhblt32gHW+CePcBeeTMZUMqaaO8CeqQc1QXO82ickYia5VQK5vuklfQJdxVCyhtUA X7nHqzkeIkP3S0Fo2FmCNaUihQd8zJXJY28FW8zFfxx4hWZdneCzZXOsLsI/EG+emkIr Yn/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga02.intel.com (mga02.intel.com. [134.134.136.20]) by mx.google.com with ESMTPS id t11si66755plr.23.2019.06.06.13.17.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 13:17:32 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 as permitted sender) client-ip=134.134.136.20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 134.134.136.20 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 fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 13:17:32 -0700 X-ExtLoop1: 1 Received: from yyu32-desk1.sc.intel.com ([143.183.136.147]) by fmsmga001.fm.intel.com with ESMTP; 06 Jun 2019 13:17:31 -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 , Borislav Petkov , 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 , Dave Martin Subject: [PATCH v7 09/14] x86/vdso: Insert endbr32/endbr64 to vDSO Date: Thu, 6 Jun 2019 13:09:21 -0700 Message-Id: <20190606200926.4029-10-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190606200926.4029-1-yu-cheng.yu@intel.com> References: <20190606200926.4029-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 Acked-by: Andy Lutomirski --- arch/x86/entry/vdso/Makefile | 12 +++++++++++- arch/x86/entry/vdso/vdso-layout.lds.S | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile index 42fe42e82baf..718fc17b0d67 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 FORCE $(call if_changed,objcopy) @@ -173,6 +177,12 @@ quiet_cmd_vdso = VDSO $@ VDSO_LDFLAGS = -shared $(call ld-option, --hash-style=both) \ $(call ld-option, --build-id) $(call ld-option, --eh-frame-hdr) \ -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 93c6dc7812d0..3fea2ce318bc 100644 --- a/arch/x86/entry/vdso/vdso-layout.lds.S +++ b/arch/x86/entry/vdso/vdso-layout.lds.S @@ -52,6 +52,7 @@ SECTIONS *(.gnu.linkonce.b.*) } :text + .note.gnu.property : { *(.note.gnu.property) } :text :note .note : { *(.note.*) } :text :note .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr