From patchwork Sat Sep 16 03:53:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 9954115 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 A8045601E8 for ; Sat, 16 Sep 2017 03:59:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99AD72922D for ; Sat, 16 Sep 2017 03:59:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E7A829287; Sat, 16 Sep 2017 03:59:37 +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 2B6D92922D for ; Sat, 16 Sep 2017 03:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751830AbdIPD7Y (ORCPT ); Fri, 15 Sep 2017 23:59:24 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34733 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751562AbdIPD7J (ORCPT ); Fri, 15 Sep 2017 23:59:09 -0400 Received: by mail-pf0-f194.google.com with SMTP id g65so2071346pfe.1; Fri, 15 Sep 2017 20:59:09 -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=jqMjDFZPlndvRBevPf6/l+Sbczz31K9fx87lxL4edT4=; b=oiBW2WKdxlwW9vsvbFYtD7e8dUTs1YXu3AFEShaY4CzfbJ/yOB9nIQlqztpnapR1BE qQjUprLVJnlEFlhwJ6ut07uJCp7cxRVUDQx6VirY4/Qz63Lk8u35eE8lbHZZe05Dv+pZ MR9IyqhhAez2WVnPxWl3ZqrIWWtfc1yCQfb9HH0jMa5xb1a5nAKYC4z704CdUmjwXmp/ fWFROfT/meCHa4RD3on2hGDW799q07nbiX9SBxFLLyKkC6gNJm7ArJM+woSlix1P/bvB d5kvMogyTS2DoFYY308UWMStKo81zKDWeLEr+q5t2uoRlZX9tBm5EQ0Kitdd2JqajMUO h4WA== 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=jqMjDFZPlndvRBevPf6/l+Sbczz31K9fx87lxL4edT4=; b=LQ2FoFMcDpQ9cQmUk4AUY5DCYB0zFh0vsD3JnCRanrfc5h0/h14hDLblmixulUOjvo yyDbh56IYAAYCL89BxHUYWfMCBLqDoqNnKNxZnbcod89wJ0Pt7vzcQ9g8WydLTzqdX8b qvCCzjQndbHxm2R9UBeodI5NaW+nBOEj++qfRkx+wO42cGx+LXKPqYvBjgcirPlvIF8I jRAbBaZjn5dWwxvem1fOSvBGBKkDLcBzpetTDh//I4g018YWGZ3P4mn1BwhuUK4QR87h bdfvVN/ZL5808vRc8CaAxSrOBwRbUaIZH0qTW6qT44Tzj4S6vpTYJUf2di68QEcfiPMz 1ySg== X-Gm-Message-State: AHPjjUgsoq67m7jimNRYiyEvHz9x558WnKYMpmM53qFZGvzsE8fQPc5w l1l2uNkmjKZKtQ== X-Google-Smtp-Source: ADKCNb4X5vFccnXsuJlsc4soNewupyWR/oxNEKfrTixQS056WWEFvtXUduzjurNjJIeQc+SqxXbJrA== X-Received: by 10.84.174.67 with SMTP id q61mr29826581plb.242.1505534349202; Fri, 15 Sep 2017 20:59:09 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id 76sm4448230pfp.158.2017.09.15.20.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 20:59:08 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "James E . J . 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: [PATCH 5/5] symbol lookup: use new kernel and module dereference functions Date: Sat, 16 Sep 2017 12:53:47 +0900 Message-Id: <20170916035347.19705-6-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170916035347.19705-1-sergey.senozhatsky@gmail.com> References: <20170916035347.19705-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 87cdb46863cd..4f591f2bbf5a 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 86c3385b9eb3..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 = dereference_function_descriptor(ptr); - /* Fallthrough */ case 'S': case 's': case 'B':