From patchwork Wed Sep 20 16:29:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 9961835 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 4F2D160208 for ; Wed, 20 Sep 2017 16:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F2C329198 for ; Wed, 20 Sep 2017 16:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33D9E2919B; Wed, 20 Sep 2017 16:30:44 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF92829198 for ; Wed, 20 Sep 2017 16:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751937AbdITQaC (ORCPT ); Wed, 20 Sep 2017 12:30:02 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36350 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751581AbdITQaA (ORCPT ); Wed, 20 Sep 2017 12:30:00 -0400 Received: by mail-pf0-f193.google.com with SMTP id f84so1385406pfj.3; Wed, 20 Sep 2017 09:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=30RxeibIpppgxPJFamU/flTAJbbcbNLVZYc2OxGBx3k=; b=fltd/ZWDfFQgKDb39L6MufWzOXkvFpeHcYb5c4/fkoApb//tB0itZgkzPHvGW3Iev4 gH3l84Hj8UbaHAZ3AwW6IZCjo3HDbnitfj2jj0SFc4QVZ9r3jCf5YcSvHzA35h30kjcq OESIQO2dW55h73rXNzLA2+JmfUi8C9iT+CwBJxtYL8HnIU9PhkgaUwzAhawfCPuO9GnO LG/B/8zGRUK73BF2W6nHvV77O2ij5UdNrhfFF1qN12QmgMLdE+M3Pe86o7j3+ijC1q5I ENP2j/8gCzs673UrvA4MH5k8ULAt3hm5ulXbOx7CI4tFXi9/6H5pTLwtLB8DPlhTP60I AQjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=30RxeibIpppgxPJFamU/flTAJbbcbNLVZYc2OxGBx3k=; b=agYm2ofGMzoQG5fd9ZGbonFaXfbEcBTPJyUKGImzewJoHb4QhHb6BZrnjHPE3zq06X uug25z7YJhrHvi9t1zPDmjv8RQY9Du0p0JcrAt5ljM7F4l9XfpY/Z92oliR3lYmZt9Ri dQnzzlnVYVVtaE92qr7QLa8vqVZ7QeWntlLDWx0MkVnnUi4Ww79Fwe9aKnrQ9fk/MyyP Zvl78o+2QE4prWmBCDKI7A6O0JHZBdOPzXuQAAqFLu6Rn1c2dvo1xrdsaLSy0IKwJ8bB MI2mT/93AtIAIAkhc6Y9o80/O8ZmvjgE/aTNSETMaYFcVUSvOjbcs0bona7n8SZ7RY74 IuDQ== X-Gm-Message-State: AHPjjUgHTY7Jxsr9gTqIy0ZTfF8KR11NF3oD6QrHGrmXaHC+d3OemffI MxApr+EENObPQ8jm8O/R/p4= X-Google-Smtp-Source: AOwi7QAS/LY8NebR6RlNDYDehU4J8ng99i6q5cGaVpwzRrnUzZRHXAsLmOJEEx3YN67u1zQyFBzbew== X-Received: by 10.84.216.21 with SMTP id m21mr2650982pli.273.1505924999357; Wed, 20 Sep 2017 09:29:59 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:58 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Cc: Petr Mladek , Steven Rostedt , Andrew Morton , Jessica Yu , Alexei Starovoitov , linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [RFC][PATCH v2 6/7] symbol lookup: use new kernel and module dereference functions Date: Thu, 21 Sep 2017 01:29:08 +0900 Message-Id: <20170920162910.32053-7-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170920162910.32053-1-sergey.senozhatsky@gmail.com> References: <20170920162910.32053-1-sergey.senozhatsky@gmail.com> Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Call appropriate function descriptor dereference ARCH callbacks: - dereference_kernel_function_descriptor() if the pointer is a kernel symbol; - dereference_module_function_descriptor() if the pointer is a module symbol. This patch also removes dereference_function_descriptor() from '%pF/%pf' vsprintf handler, because it has the same behavior with '%pS/%ps' now. Signed-off-by: Sergey Senozhatsky --- Documentation/printk-formats.txt | 15 +++++---------- kernel/kallsyms.c | 1 + kernel/module.c | 1 + lib/vsprintf.c | 5 +---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Documentation/printk-formats.txt b/Documentation/printk-formats.txt index 361789df51ec..b2afafc84638 100644 --- a/Documentation/printk-formats.txt +++ b/Documentation/printk-formats.txt @@ -50,26 +50,23 @@ Symbols/Function Pointers :: + %pS versatile_init+0x0/0x110 + %ps versatile_init %pF versatile_init+0x0/0x110 %pf versatile_init - %pS versatile_init+0x0/0x110 %pSR versatile_init+0x9/0x110 (with __builtin_extract_return_addr() translation) - %ps versatile_init %pB prev_fn_of_versatile_init+0x88/0x88 -The ``F`` and ``f`` specifiers are for printing function pointers, -for example, f->func, &gettimeofday. They have the same result as -``S`` and ``s`` specifiers. But they do an extra conversion on -ia64, ppc64 and parisc64 architectures where the function pointers -are actually function descriptors. - The ``S`` and ``s`` specifiers can be used for printing symbols from direct addresses, for example, __builtin_return_address(0), (void *)regs->ip. They result in the symbol name with (``S``) or without (``s``) offsets. If KALLSYMS are disabled then the symbol address is printed instead. +Note, that the ``F`` and ``f`` specifiers are identical to ``S`` (``s``) +and thus deprecated. + The ``B`` specifier results in the symbol name with offsets and should be used when printing stack backtraces. The specifier takes into consideration the effect of compiler optimisations which may occur @@ -77,8 +74,6 @@ when tail-call``s are used and marked with the noreturn GCC attribute. Examples:: - printk("Going to call: %pF\n", gettimeofday); - printk("Going to call: %pF\n", p->func); printk("%s: called from %pS\n", __func__, (void *)_RET_IP_); printk("%s: called from %pS\n", __func__, (void *)__builtin_return_address(0)); diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 127e7cfafa55..e2fc09ea9509 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -322,6 +322,7 @@ const char *kallsyms_lookup(unsigned long addr, if (is_ksym_addr(addr)) { unsigned long pos; + addr = dereference_kernel_function_descriptor(addr); pos = get_symbol_pos(addr, symbolsize, offset); /* Grab name */ kallsyms_expand_symbol(get_symbol_offset(pos), diff --git a/kernel/module.c b/kernel/module.c index b792e814150a..63361de377ad 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3948,6 +3948,7 @@ const char *module_address_lookup(unsigned long addr, preempt_disable(); mod = __module_address(addr); if (mod) { + addr = dereference_module_function_descriptor(mod, addr); if (modname) *modname = mod->name; ret = get_ksymbol(mod, addr, size, offset); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bcd906a39010..bf04b4f5d8e7 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -40,7 +40,6 @@ #include "../mm/internal.h" /* For the trace_print_flags arrays */ #include /* for PAGE_SIZE */ -#include /* for dereference_function_descriptor() */ #include /* cpu_to_le16 */ #include @@ -1721,10 +1720,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, } switch (*fmt) { - case 'F': + case 'F': /* %pF and %pf are kept for compatibility reasons only */ case 'f': - ptr = (void *)dereference_function_descriptor((unsigned long)ptr); - /* Fallthrough */ case 'S': case 's': case 'B':