Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp945471ybz; Fri, 1 May 2020 11:24:41 -0700 (PDT) X-Google-Smtp-Source: APiQypLpE5ReFrTbuvj4NC3GxWpSNHOp2vC3HZp/S5L08WJ/Nyga3Wpm5LAnKmRnGflHA5VrlMRh X-Received: by 2002:aa7:d542:: with SMTP id u2mr4810314edr.234.1588357480959; Fri, 01 May 2020 11:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588357480; cv=none; d=google.com; s=arc-20160816; b=OwXKFYqtUTEgMr2n2ETTLJ1cmdwPKnMWiEz9D9FN7omL1qDFpM77Iub9wkbXsq5M3t S+kwaVNeyzpppvl6QKPxr8DIwMuNnkVhNK/Sjd2zfsk1UbJ2Nrl+j8/kORFHSLbwEhhI dJGljL2HjEOLUJHrYsUocUnCHLtUpqM7OQQ47YukQdQwwFAugnnSeBVLb+y+PmqjUajc z6D8sEhsf1bmpaZt+WNG9VK66rGbhYHIjR3R8z7eTuLy8ukGOVe6vFAAfLe1gox2Sy9O +6k9XDBxh2iyBn2MSuzOZOaj20I1sYFFDhD1mNSFyK9/D0yVwfycIKuBAxZwWMP08WeT J6Qg== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=HoNuR4PAoQA5Z/M7KINjXx69fudOEPXvedvgc9WhWgI=; b=CzM7ikeh3boLiJX1L99Ju+A3Zg6J37mrPNvQVxZdYd9qliBZDP0zTkQOuEfpGksh2Y UsRoa622+qHpWHS/tVIhn442eFuifJq2DhCkjckQy7Vh3p7tdpJvkaMsZZVx8RlIZWOu a0Rkcy68t2ej4NcLCgHAai/J1WXjXRCRj7Rp1GGuN+IcXtSs3kJVoVIU2LPa/EdZbkRN X9wwzzP6vGUIKWSc+x8Me/PHEqN0RCdG8hdYF/qSqPJQ9cbaICaGy04dDTFt6QOu2C3M iiUWKHKcGpT6ve07v/HF6+8U0ncmZGH4h9YafCAQC4FUtB7hLxq18l0ZxJvbW4PDozPZ yDUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si2216257edy.68.2020.05.01.11.24.16; Fri, 01 May 2020 11:24:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730012AbgEASWf (ORCPT + 99 others); Fri, 1 May 2020 14:22:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730693AbgEASWa (ORCPT ); Fri, 1 May 2020 14:22:30 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4C7C061A0C; Fri, 1 May 2020 11:22:30 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jUaIr-0003eG-08; Fri, 01 May 2020 20:22:25 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 91C071C0085; Fri, 1 May 2020 20:22:19 +0200 (CEST) Date: Fri, 01 May 2020 18:22:19 -0000 From: "tip-bot2 for Peter Zijlstra" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] x86: Simplify retpoline declaration Cc: "Peter Zijlstra (Intel)" , Josh Poimboeuf , x86 , LKML In-Reply-To: <20200428191700.091696925@infradead.org> References: <20200428191700.091696925@infradead.org> MIME-Version: 1.0 Message-ID: <158835733956.8414.14836642152180567436.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: ca3f0d80dd57c8828bfb5bc0bc79750ea7a1ba26 Gitweb: https://git.kernel.org/tip/ca3f0d80dd57c8828bfb5bc0bc79750ea7a1ba26 Author: Peter Zijlstra AuthorDate: Wed, 22 Apr 2020 17:03:22 +02:00 Committer: Peter Zijlstra CommitterDate: Thu, 30 Apr 2020 20:14:34 +02:00 x86: Simplify retpoline declaration Because of how KSYM works, we need one declaration per line. Seeing how we're going to be doubling the amount of retpoline symbols, simplify the machinery in order to avoid having to copy/paste even more. Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lkml.kernel.org/r/20200428191700.091696925@infradead.org --- arch/x86/include/asm/GEN-for-each-reg.h | 25 ++++++++++++++++- arch/x86/include/asm/asm-prototypes.h | 28 +++++------------- arch/x86/lib/retpoline.S | 37 ++++++++++-------------- 3 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 arch/x86/include/asm/GEN-for-each-reg.h diff --git a/arch/x86/include/asm/GEN-for-each-reg.h b/arch/x86/include/asm/GEN-for-each-reg.h new file mode 100644 index 0000000..1b07fb1 --- /dev/null +++ b/arch/x86/include/asm/GEN-for-each-reg.h @@ -0,0 +1,25 @@ +#ifdef CONFIG_64BIT +GEN(rax) +GEN(rbx) +GEN(rcx) +GEN(rdx) +GEN(rsi) +GEN(rdi) +GEN(rbp) +GEN(r8) +GEN(r9) +GEN(r10) +GEN(r11) +GEN(r12) +GEN(r13) +GEN(r14) +GEN(r15) +#else +GEN(eax) +GEN(ebx) +GEN(ecx) +GEN(edx) +GEN(esi) +GEN(edi) +GEN(ebp) +#endif diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h index ce92c4a..aa7585e 100644 --- a/arch/x86/include/asm/asm-prototypes.h +++ b/arch/x86/include/asm/asm-prototypes.h @@ -17,24 +17,12 @@ extern void cmpxchg8b_emu(void); #endif #ifdef CONFIG_RETPOLINE -#ifdef CONFIG_X86_32 -#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_e ## reg(void); -#else -#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_r ## reg(void); -INDIRECT_THUNK(8) -INDIRECT_THUNK(9) -INDIRECT_THUNK(10) -INDIRECT_THUNK(11) -INDIRECT_THUNK(12) -INDIRECT_THUNK(13) -INDIRECT_THUNK(14) -INDIRECT_THUNK(15) -#endif -INDIRECT_THUNK(ax) -INDIRECT_THUNK(bx) -INDIRECT_THUNK(cx) -INDIRECT_THUNK(dx) -INDIRECT_THUNK(si) -INDIRECT_THUNK(di) -INDIRECT_THUNK(bp) + +#define DECL_INDIRECT_THUNK(reg) \ + extern asmlinkage void __x86_indirect_thunk_ ## reg (void); + +#undef GEN +#define GEN(reg) DECL_INDIRECT_THUNK(reg) +#include + #endif /* CONFIG_RETPOLINE */ diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S index 363ec13..9cc5480 100644 --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -24,25 +24,20 @@ SYM_FUNC_END(__x86_indirect_thunk_\reg) * only see one instance of "__x86_indirect_thunk_\reg" rather * than one per register with the correct names. So we do it * the simple and nasty way... + * + * Worse, you can only have a single EXPORT_SYMBOL per line, + * and CPP can't insert newlines, so we have to repeat everything + * at least twice. */ -#define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym) -#define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg) -#define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg) - -GENERATE_THUNK(_ASM_AX) -GENERATE_THUNK(_ASM_BX) -GENERATE_THUNK(_ASM_CX) -GENERATE_THUNK(_ASM_DX) -GENERATE_THUNK(_ASM_SI) -GENERATE_THUNK(_ASM_DI) -GENERATE_THUNK(_ASM_BP) -#ifdef CONFIG_64BIT -GENERATE_THUNK(r8) -GENERATE_THUNK(r9) -GENERATE_THUNK(r10) -GENERATE_THUNK(r11) -GENERATE_THUNK(r12) -GENERATE_THUNK(r13) -GENERATE_THUNK(r14) -GENERATE_THUNK(r15) -#endif + +#define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym) +#define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg) + +#undef GEN +#define GEN(reg) THUNK reg +#include + +#undef GEN +#define GEN(reg) EXPORT_THUNK(reg) +#include +