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: 816365 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy5Cw5ffQz9t2Q for ; Thu, 21 Sep 2017 02:43:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fltd/ZWD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xy5Cw47Q8zDqZx for ; Thu, 21 Sep 2017 02:43:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fltd/ZWD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::244; helo=mail-pf0-x244.google.com; envelope-from=sergey.senozhatsky@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="fltd/ZWD"; dkim-atps=neutral Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xy4w90jxBzDqXp for ; Thu, 21 Sep 2017 02:30:01 +1000 (AEST) Received: by mail-pf0-x244.google.com with SMTP id g65so1389011pfe.1 for ; Wed, 20 Sep 2017 09:30:01 -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=axocLr6vtRaMk5lRz6PWvpM8d9T3tvChwf1tjJidbgQ1q7/lNL7o+rXjvTVCOAxPqW 4IUL7YTPZgrr/SIcs+zgEkT0Z3l573Nmm7iS4mwidncE0JFuwcUYNh8VHk0T178JKtNF MhsjZoYlDuYt1PPHuAmM/gRFkxG38qiGLuSG+sECXZMnwrFMwVT7lRHlMcI0Brn4vq1t ItYHRVs06Ifjtp5jGctSV63+zLPKrGqr1tM3je/OUwRj7HcYUURAiYD9Z9gO0dJIAtb+ tAPI7DReNaG8y+CAlF7wVvfL+tSq7CLB7UB19y+muSpf8KE8/PK6iqF321IPBqdjwvtE P0EQ== X-Gm-Message-State: AHPjjUiIdP6bQq9EUCIyLylQIrammsz56hgetAz3WSs0YxS8OW/rkoUB olo8F1W9QjcgGJG69+VFW4E= 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 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> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Petr Mladek , linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org, Alexei Starovoitov , Steven Rostedt , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Jessica Yu , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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':