From patchwork Fri Jun 9 10:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9777967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5644B60350 for ; Fri, 9 Jun 2017 10:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43A79285FB for ; Fri, 9 Jun 2017 10:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3526B285E8; Fri, 9 Jun 2017 10:28: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1A60285E8 for ; Fri, 9 Jun 2017 10:28:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=gGeQYkBjjvhoSIQ99iKcK/ok533AZg/yF9jXn9qTTYo=; b=d5J aMA3QATJvT7dCg8CUSsp0ndniUs6UgsBiP0WvVe4gXeCjtC2cqlkrrpBPl56ixuKii//qlG33g16e EWmbXLZpPQj/2Z1doGiezBp6zRgJeidt7vWJVk9Wj0HZjzau4pKzYFd+Ss6gvdQuU58wUuGo7AjDN 32lTtwudMYqJ5dgQt6++JnN2p9GFJEuj6YQltbEe2bD4s9+Q6Il1DRjln+Sz7ZxJIbduskcga1DPk 5VofzEb5f4qYnTReuUMCw2CJ3v0zVZunFBITTNenFtjHmHzNO8+73Mr/rUOWTUS1ssDGHTPTmuzdC vOa6P2Nz6e2PWKehM2maelC0CyFAPZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dJH9z-0005NR-Tl; Fri, 09 Jun 2017 10:28:55 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJH9v-0005Cy-Sm for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2017 10:28:53 +0000 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0M9Xn5-1d948B2k2B-00CwsR; Fri, 09 Jun 2017 12:28:12 +0200 From: Arnd Bergmann To: Catalin Marinas , Will Deacon Subject: [PATCH] arm64: ftrace: fix building without CONFIG_MODULES Date: Fri, 9 Jun 2017 12:27:06 +0200 Message-Id: <20170609102807.2992510-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:mBYxkRqOVstY2Xh6T7s3DAVhrcg5lPs7kiB89RrfaAs1geZPJAk UVpsE4opb9XMjoRdmc81fbJrf9HJqKgoxMSDMO2l/0Wk2VsZTp5dw+Mr02CCk8JrbmCPIp1 cXmB2ZTw+3AMIQpU7txHt+48x2rtXCuXQCLBLGWhJy6HVUI58RLzF7WLGL2tqMHE3sEnuK8 fgfUIELrTqMF/dIwkxgSg== X-UI-Out-Filterresults: notjunk:1; V01:K0:V2pAlovHnNk=:CZBqXv/XWj2M9dBd8FDd4f wT1hVM5yEpaNeTQsLO0v01oTbHko9gj/Nph2w9wBLZPpEm86rqsBhjfbinGRkLn0hdXI4Qc9D lJHP9c/mYRnoSaYVQOZF+uXnwHZdi8HYWuDYXT0Lic6A5VSiKiq+wXufswDRkLZzM/xqK0ojH LsTinol8mkvubCN7V9Jjpil4thRd2vyUXKjcx44/IAs3VEUCvc9PIC6THQ2E3E5sjzTeLMjCZ KnUqeSllsEwFNILK4OpUAgoFDrc+UkinFeD/qjmuBGmjimWqHrQsb/+AsJ57ce7IR8tiJwTdH zZAiWaDB9zcG5JbChG9cO+lWGoMeE2a9f9kIm0wtfqRkO79KCMIh53o597WXD7/M+GGWLctEm wrQdajZmcjoyhwSVXe5oXAsbTLlWliI/7Uv4NPviZK7kU7KiWd0deH6OrvxMZGOiKNV41sben lusd9Y26MxgC/WN5EZ0XphfBaCLTUWiPD2QFnp/M8zsJa0102hdbKo1XNa8wYMDnC/6xHYO2h Rhlz/+eqHV19a09m+gb32P9wVrhY8im8qjRyrTuP+Y5jNjwxZ0MhmuICO30KPTgZI4FnB0A6y LVJAWmeN5LmH7HlZI6AxP2llE09FlHMryIXax8uiwj3VF16taZTWZp3D6m9M1+Z7Mq7Fty5JW xTeOT+G30ZrEuHp9H57HCkDSxVUPLJemuiZmq4QeFcpuk1MRJRziGepKCCrEOJkdws1U= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170609_032852_250533_E5F886D5 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Ard Biesheuvel , Rusty Russell , linux-kernel@vger.kernel.org, Steven Rostedt , Ingo Molnar , Jessica Yu , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When CONFIG_MODULES is disabled, we cannot dereference a module pointer: arch/arm64/kernel/ftrace.c: In function 'ftrace_make_call': arch/arm64/kernel/ftrace.c:107:36: error: dereferencing pointer to incomplete type 'struct module' trampoline = (unsigned long *)mod->arch.ftrace_trampoline; Also, the within_module() function is not defined: arch/arm64/kernel/ftrace.c: In function 'ftrace_make_nop': arch/arm64/kernel/ftrace.c:171:8: error: implicit declaration of function 'within_module'; did you mean 'init_module'? [-Werror=implicit-function-declaration] This addresses both by adding the appropriate stubs. Fixes: e71a4e1bebaf ("arm64: ftrace: add support for far branches to dynamic ftrace") Signed-off-by: Arnd Bergmann --- arch/arm64/include/asm/module.h | 6 ++++++ arch/arm64/kernel/ftrace.c | 2 +- include/linux/module.h | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/module.h b/arch/arm64/include/asm/module.h index 19bd97671bb8..ca5d024f4247 100644 --- a/arch/arm64/include/asm/module.h +++ b/arch/arm64/include/asm/module.h @@ -36,6 +36,12 @@ struct mod_arch_specific { }; #endif +#if defined(CONFIG_MODULES) && defined(CONFIG_ARM64_MODULE_PLTS) +#define module_ftrace_trampoline(mod) ((mod)->arch.ftrace_trampoline) +#else +#define module_ftrace_trampoline(mod) NULL +#endif + u64 module_emit_plt_entry(struct module *mod, void *loc, const Elf64_Rela *rela, Elf64_Sym *sym); diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 8a42be0693c9..7f5eb9939a55 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -104,7 +104,7 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) * is added in the future, but for now, the pr_err() below * deals with a theoretical issue only. */ - trampoline = (unsigned long *)mod->arch.ftrace_trampoline; + trampoline = module_ftrace_trampoline(mod); if (trampoline[0] != addr) { if (trampoline[0] != 0) { pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n"); diff --git a/include/linux/module.h b/include/linux/module.h index 21f56393602f..9196f532f158 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -671,6 +671,11 @@ static inline bool is_module_text_address(unsigned long addr) return false; } +static inline bool within_module(unsigned long addr, const struct module *mod) +{ + return false; +} + /* Get/put a kernel symbol (calls should be symmetric) */ #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) #define symbol_put(x) do { } while (0)