Received: by 10.223.148.5 with SMTP id 5csp7313249wrq; Thu, 18 Jan 2018 04:02:53 -0800 (PST) X-Google-Smtp-Source: ACJfBov1xyhielC/e48MM4kCeucpmPUcxKJfSK3D8h9xLWqrlOu6CFa0/H7RUjb2PXGVe6ungeNw X-Received: by 10.99.105.72 with SMTP id e69mr29022971pgc.239.1516276973657; Thu, 18 Jan 2018 04:02:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516276973; cv=none; d=google.com; s=arc-20160816; b=lSt9uKeMSfzNBIQuUiu/ad3ZFEEvzXabmPrttsAAS5CnGHMbyU0OihaGFEC/n1y5hC 7TUY4OIeYYI17YL5nwJHv7f1rt/SYC99yIAp0Yp6FrGn+eSI4EZi71q2nO7i2Doog7tm WMFnUBt+S47mGhzSAdzM4lkRCqP/G4ppNWuV0ucIPWfMRIVA61eA7+wdhjTAIns3upCV mlc94cwfjqOhOdG248Wl4Z5OrCcQQCID7+y05g0LBcxEMyfEDmYNMyc8kDWAbthamYEb oVmExqek/HPMkDFyZndPpxFMMIRKuaaM32pFiQ2f5g6dclcrGCo/nrbxmu+ux6xd1ayC PM/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dmarc-filter:arc-authentication-results; bh=xxx7ZWmfEUP8glmGgF+KvApkqQTJ1j+2YapPeuXWko4=; b=cb69e/+f3f7Ladmo0a8jIzGDs7zMTzp2C+6L1Fk8Fo+aA04BMIXPX3G/UwSvch8sHI O+Of6TaoKPHp5CCp08e8Pgse2oOSgDW+sDYAZJ1LWsRrLD4HCwKyZJQ9HbRt/+jOC+rE +rwTD0J9BQEsYQrIRhDA8riZYiSbQriRUYJJr5zhAhR6YIYMngyhO5LZehIsmA9/ER2t qCQgrcUnCPdgoVw1qpymsbb8RgxPzBNARBUlBgvdIkYPfluI3Hkj3sBIL36U9UGpe2nD a7hcgE1coINT1DLcyRAKWv2bwjRlPOEKY/+/pbXOeFDxbw0NNrNerEceLusmym90vZL4 KL/Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w6si3814793pgo.491.2018.01.18.04.02.38; Thu, 18 Jan 2018 04:02:53 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755028AbeARMBp (ORCPT + 99 others); Thu, 18 Jan 2018 07:01:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:40112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754855AbeARMBn (ORCPT ); Thu, 18 Jan 2018 07:01:43 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7A29D21718; Thu, 18 Jan 2018 12:01:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A29D21718 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org From: Masami Hiramatsu To: Ingo Molnar , David Woodhouse Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, Andi Kleen , Greg Kroah-Hartman , Arjan van de Ven , Peter Zijlstra , Ananth N Mavinakayanahalli , Thomas Gleixner , "H . Peter Anvin" Subject: [PATCH v1 tip/master 1/3] retpoline: Introduce start/end markers of indirect thunk Date: Thu, 18 Jan 2018 21:01:19 +0900 Message-Id: <151627687913.24682.16564356005083781238.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <151627684798.24682.2979775081582774869.stgit@devbox> References: <151627684798.24682.2979775081582774869.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce start/end markers of __x86_indirect_thunk_* functions. These thunk functions are placed in .text.__x86.indirect_thunk.* sections. So this puts those sections in the end of kernel text and adds __indirect_thunk_start/end so that other subsystem (e.g. kprobes) can identify it. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/nospec-branch.h | 3 +++ arch/x86/kernel/vmlinux.lds.S | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index 7b45d8424150..19ba5ad19c65 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -194,6 +194,9 @@ enum spectre_v2_mitigation { SPECTRE_V2_IBRS, }; +extern char __indirect_thunk_start[]; +extern char __indirect_thunk_end[]; + /* * On VMEXIT we must ensure that no RSB predictions learned in the guest * can be followed in the host, by overwriting the RSB completely. Both diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 1e413a9326aa..1a5a663620ce 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -74,6 +74,9 @@ jiffies_64 = jiffies; #endif +#define X86_INDIRECT_THUNK(reg) \ + *(.text.__x86.indirect_thunk.##reg) + PHDRS { text PT_LOAD FLAGS(5); /* R_E */ data PT_LOAD FLAGS(6); /* RW_ */ @@ -124,6 +127,38 @@ SECTIONS ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big"); #endif +#ifdef CONFIG_RETPOLINE + __indirect_thunk_start = .; +#ifdef CONFIG_X86_64 + X86_INDIRECT_THUNK(rax) + X86_INDIRECT_THUNK(rbx) + X86_INDIRECT_THUNK(rcx) + X86_INDIRECT_THUNK(rdx) + X86_INDIRECT_THUNK(rsi) + X86_INDIRECT_THUNK(rdi) + X86_INDIRECT_THUNK(rbp) + X86_INDIRECT_THUNK(rsp) + X86_INDIRECT_THUNK(r8) + X86_INDIRECT_THUNK(r9) + X86_INDIRECT_THUNK(r10) + X86_INDIRECT_THUNK(r11) + X86_INDIRECT_THUNK(r12) + X86_INDIRECT_THUNK(r13) + X86_INDIRECT_THUNK(r14) + X86_INDIRECT_THUNK(r15) +#else + X86_INDIRECT_THUNK(eax) + X86_INDIRECT_THUNK(ebx) + X86_INDIRECT_THUNK(ecx) + X86_INDIRECT_THUNK(edx) + X86_INDIRECT_THUNK(esi) + X86_INDIRECT_THUNK(edi) + X86_INDIRECT_THUNK(ebp) + X86_INDIRECT_THUNK(esp) +#endif + __indirect_thunk_end = .; +#endif + /* End of text section */ _etext = .; } :text = 0x9090