From patchwork Thu Oct 11 15:16:51 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: 10636913 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 DA1BC17E1 for ; Thu, 11 Oct 2018 15:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C72A42BA5B for ; Thu, 11 Oct 2018 15:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB1E12BA5E; Thu, 11 Oct 2018 15:22: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 4A1FE2BA5B for ; Thu, 11 Oct 2018 15:22:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 262606B02A2; Thu, 11 Oct 2018 11:22:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0CE896B02A5; Thu, 11 Oct 2018 11:22:09 -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 EAFF96B02A4; Thu, 11 Oct 2018 11:22:08 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id A596E6B02A0 for ; Thu, 11 Oct 2018 11:22:08 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id p89-v6so8074202pfj.12 for ; Thu, 11 Oct 2018 08:22:08 -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=0lwKd3VCdluxV9TIoAnzM2ZXz+CjhIEXN1/3QJINxnU=; b=VIuh3VOMT7Un8kUQME8YzhsCax6NBr2tfABLN5c07KRyxMbiMsI+6cgXhf45obx0j4 kO65MboUXhVAQy6TC4gDHY4UOWuga94jR/AU21HvKG+/0Ac9kqaD5KjMb+CyT3XI+EC7 QOqliVncWenBqmg1z7loEHBtywM5gO5jUdKGUK1nomnD7o9azTVmKYeaEA/S8PS5nuK2 vgH1lYMAHVz30bVYm/NSSVdrag4gSQVKg5rnlQb4VwtY7h7EwoPx5Glgsf2arFktFXca OxldvPecmrZiArb/jVXO0bu9dsyViW6Y0yY5FTjN2oQ7weFy+XJ5TaVbF/5dvREnXz9o SwGg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 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: ABuFfoiPsHjIzKP+TinUVcTlCdzidiPILEExUoHOO1VpGnGrzPzbJLd0 H0hVMbZahGRmDRTv1qoPPM7FwguF+yvt5VhbHBHdcF98R8JAm3K/PweSWGuQ2yttqH5FZvvTtZR aBw+QibjKiNY3C6pAFOEWbXJgsHSthVu/X1DRGmNv3cVdBUjup9kadGbDmgoolqciHg== X-Received: by 2002:a17:902:ab8a:: with SMTP id f10-v6mr2003195plr.203.1539271328239; Thu, 11 Oct 2018 08:22:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV63qtc88facBe+xtQXKlcJrDjadKAxv6eqg/mFhD44QIx7ON7ctsa/oReYhgQbsVDOGX9SEA X-Received: by 2002:a17:902:ab8a:: with SMTP id f10-v6mr2003162plr.203.1539271327563; Thu, 11 Oct 2018 08:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539271327; cv=none; d=google.com; s=arc-20160816; b=OiCzMFzb38oKqADZJzT5vGfaDXDgAnVcbNzfAnWo+6UXwLHcP/TuPnc5ozyfU/klKJ juUl2Nqn/vNTh+KYH8hAS17C5CgNpQK399bRETgvoVVY0PipaQH8L0csa+UJRvh721mZ xHqGL55srFKPLjDf7o7VYUoc8TRkjT4ghvvTq16pmQpbf2TZgVYD2ZyKOC1UARWqYOLn r3sCmFuCkJPv6XB3l24kaLuQwrWlEfOEoEwm8GsqGkDdZr4KM/MaI7dFZnqmOsdqzla7 6h/UAjEAly7TCyXZWhxp3e5rO/60cLKI5vZpZuBEYyXwGxTF2qaOpVfzKqbakQ+UjUgn DS6w== 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=0lwKd3VCdluxV9TIoAnzM2ZXz+CjhIEXN1/3QJINxnU=; b=dEDHDDoom5emIN0F4YqOwTmiLeNfDoW9QRbczrLHC++K48IeHyt1xxU9vQddNW0U12 m3JOcLmGCLygS7/7Dt5xso2FG2I0STsBzw2iQKC8sf/bcbcIxq5mo21rRq1y27LroEcu W1uXb/Xxc9G6KVk/7R96pautZRZV2szNHA11iBEO7W/rOS+vmxalDR/zsb33MruNd6Wf 88p7jV8fXV5qtXA3FXuwOHyofLvMZWDEQvf471hfpv9iY3PLsccZPRf4mNot67oQyA4M NPJTEDPINmE44AJULI7n3McSa5QS2FeSV49MTvy3k+5G3mM0Y3mtCDIzwzo1oaU3U282 6rtg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) smtp.mailfrom=yu-cheng.yu@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga14.intel.com (mga14.intel.com. [192.55.52.115]) by mx.google.com with ESMTPS id 33-v6si28541073plh.50.2018.10.11.08.22.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 08:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 as permitted sender) client-ip=192.55.52.115; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yu-cheng.yu@intel.com designates 192.55.52.115 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 fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2018 08:22:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,368,1534834800"; d="scan'208";a="77271639" Received: from 2b52.sc.intel.com ([143.183.136.147]) by fmsmga007.fm.intel.com with ESMTP; 11 Oct 2018 08:21:45 -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 , 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: [PATCH v5 08/11] x86: Insert endbr32/endbr64 to vDSO Date: Thu, 11 Oct 2018 08:16:51 -0700 Message-Id: <20181011151654.27221-9-yu-cheng.yu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181011151654.27221-1-yu-cheng.yu@intel.com> References: <20181011151654.27221-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 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