From patchwork Sat Sep 30 02:53:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 9979073 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 1AE976037F for ; Sat, 30 Sep 2017 02:55:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10A6F297C2 for ; Sat, 30 Sep 2017 02:55:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 054FC297CD; Sat, 30 Sep 2017 02:55:32 +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 7802E297C2 for ; Sat, 30 Sep 2017 02:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbdI3Cx6 (ORCPT ); Fri, 29 Sep 2017 22:53:58 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34549 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbdI3Cxz (ORCPT ); Fri, 29 Sep 2017 22:53:55 -0400 Received: by mail-pf0-f193.google.com with SMTP id g65so854756pfe.1; Fri, 29 Sep 2017 19:53:54 -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=sWZnsuvp0lbERrQZoI5SZe2Z+Fe6tQp7lynvtJZToYs=; b=RZgA8FoP7My19YtGv0TKLfZ4qH1JwuLj0IrpHm/GLNrjUIYsycS//32bxx70TobWQj lYDE38ik05Dvm7Dq9A4tJPR+F7/KBOtjI5EDejSrwAzngRu4gURHuOsnnApUNvvdbj4e nkVif+X4zINKDPb/UU6Zx14blDy2UHt4ileIsfWK9IF0DAVtG5ZUIJmboi3Muutuunh7 dIpBYAt5WnU1MDcPSAhZq5gfhIYIWgGrmwIe00z31eueCIZSgh/s0lIRuJHNXgxvps1a lDgD0CJmORlC88n5RUXA88OYD/93SdFuo174D3UpIkCvhSlP1yGX18Exe20Kp0rkKJVe fWdQ== 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=sWZnsuvp0lbERrQZoI5SZe2Z+Fe6tQp7lynvtJZToYs=; b=auiqmeoL29dzXJ5inI70nc3T6QyoCRbSpaz06i5F9YXdAedoGlXW78zswnHUFZRb+E oWNx1lUGUNQhC2mCdsb9nhckdnbny9nT0Ybk+cqIMbymWADKm3Ulvg+66zgofSS3Ex9h OlrzHLp2z6/xlK78jFdKdockpHLnuuJt1zLhxrRI4c0kccab9ZcyCaRpGGyelxjnUGUZ Jdq2JZS9cXcX/ZcEh0+NAW0bmqiekV8GGI2MUU3G7BzNff9A0Ovp43cV0Qs/b/oaOY87 CzRAqcJP3FP3KwmES/wN0jxYYjhhxGdLN9mj0/9TU3nDwFfGS5TbksKsvNqNM4jRE184 db/w== X-Gm-Message-State: AHPjjUj976SD1ZWKy9bcRGDFEAqEbFeNcO9bbt99RcscbyQ6Kzirkw3V A3t4tKHixpsiWKITT90ludE= X-Google-Smtp-Source: AOwi7QBXmFx/xMBHPTBsQspemfeHy3he+QD45DeWtnfRSBRY+mT2nX+YodIjN3Bn4BjAx53ymzaM9w== X-Received: by 10.159.208.69 with SMTP id w5mr8844787plz.381.1506740034557; Fri, 29 Sep 2017 19:53:54 -0700 (PDT) Received: from localhost.localdomain ([175.223.27.84]) by smtp.gmail.com with ESMTPSA id b1sm8680714pgn.94.2017.09.29.19.53.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 19:53:53 -0700 (PDT) From: Sergey Senozhatsky To: Petr Mladek , Steven Rostedt Cc: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller , 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: [PATCHv3 1/7] switch dereference_function_descriptor() to `unsigned long' Date: Sat, 30 Sep 2017 11:53:13 +0900 Message-Id: <20170930025319.987-2-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20170930025319.987-1-sergey.senozhatsky@gmail.com> References: <20170930025319.987-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 Convert dereference_function_descriptor() to accept and return `unsigned long'. There will be two new ARCH function for kernel and module function pointer dereference, which will work with `unsigned long', so the patch unifies interfaces. Besides, dereference_function_descriptor() mostly work with `unsigned long': drivers/misc/kgdbts.c: addr = (unsigned long) dereference_function_descriptor((void *)addr); init/main.c: addr = (unsigned long) dereference_function_descriptor(fn); kernel/extable.c: addr = (unsigned long) dereference_function_descriptor(ptr); kernel/module.c: unsigned long a = (unsigned long)dereference_function_descriptor(addr); Convert dereference_function_descriptor() users tree-wide. Signed-off-by: Sergey Senozhatsky Tested-by: Helge Deller # parisc64 Tested-by: Santosh Sivaraj # powerpc64 Acked-by: Michael Ellerman # powerpc64 Tested-by: Tony Luck # ia64 --- arch/ia64/include/asm/sections.h | 6 +++--- arch/parisc/include/asm/sections.h | 2 +- arch/parisc/kernel/process.c | 6 +++--- arch/parisc/mm/init.c | 4 ++-- arch/powerpc/include/asm/sections.h | 6 +++--- drivers/misc/kgdbts.c | 2 +- init/main.c | 2 +- kernel/extable.c | 2 +- kernel/module.c | 2 +- lib/vsprintf.c | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h index 2ab2003698ef..de6bfa1ef8fb 100644 --- a/arch/ia64/include/asm/sections.h +++ b/arch/ia64/include/asm/sections.h @@ -27,13 +27,13 @@ extern char __start_unwind[], __end_unwind[]; extern char __start_ivt_text[], __end_ivt_text[]; #undef dereference_function_descriptor -static inline void *dereference_function_descriptor(void *ptr) +static inline unsigned long dereference_function_descriptor(unsigned long ptr) { - struct fdesc *desc = ptr; + struct fdesc *desc = (struct fdesc *)ptr; void *p; if (!probe_kernel_address(&desc->ip, p)) - ptr = p; + ptr = (unsigned long)p; return ptr; } diff --git a/arch/parisc/include/asm/sections.h b/arch/parisc/include/asm/sections.h index 9d13c3507ad6..59fbe0067112 100644 --- a/arch/parisc/include/asm/sections.h +++ b/arch/parisc/include/asm/sections.h @@ -6,7 +6,7 @@ #ifdef CONFIG_64BIT #undef dereference_function_descriptor -void *dereference_function_descriptor(void *); +unsigned long dereference_function_descriptor(unsigned long); #endif #endif diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 30f92391a93e..d350aa913acc 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -267,13 +267,13 @@ get_wchan(struct task_struct *p) } #ifdef CONFIG_64BIT -void *dereference_function_descriptor(void *ptr) +unsigned long dereference_function_descriptor(unsigned long ptr) { - Elf64_Fdesc *desc = ptr; + Elf64_Fdesc *desc = (Elf64_Fdesc *)ptr; void *p; if (!probe_kernel_address(&desc->addr, p)) - ptr = p; + ptr = (unsigned long)p; return ptr; } #endif diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index 1ca9a2b4239f..06e1b79e2946 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c @@ -389,10 +389,10 @@ static void __init setup_bootmem(void) static int __init parisc_text_address(unsigned long vaddr) { static unsigned long head_ptr __initdata; + unsigned long addr = (unsigned long)&parisc_kernel_start; if (!head_ptr) - head_ptr = PAGE_MASK & (unsigned long) - dereference_function_descriptor(&parisc_kernel_start); + head_ptr = PAGE_MASK & dereference_function_descriptor(addr); return core_kernel_text(vaddr) || vaddr == head_ptr; } diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h index 7902d6358854..67379b8945e8 100644 --- a/arch/powerpc/include/asm/sections.h +++ b/arch/powerpc/include/asm/sections.h @@ -66,13 +66,13 @@ static inline int overlaps_kvm_tmp(unsigned long start, unsigned long end) #ifdef PPC64_ELF_ABI_v1 #undef dereference_function_descriptor -static inline void *dereference_function_descriptor(void *ptr) +static inline unsigned long dereference_function_descriptor(unsigned long ptr) { - struct ppc64_opd_entry *desc = ptr; + struct ppc64_opd_entry *desc = (struct ppc64_opd_entry *)ptr; void *p; if (!probe_kernel_address(&desc->funcaddr, p)) - ptr = p; + ptr = (unsigned long)p; return ptr; } #endif /* PPC64_ELF_ABI_v1 */ diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index fc7efedbc4be..6a5a159dfb75 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -225,7 +225,7 @@ static unsigned long lookup_addr(char *arg) addr = (unsigned long)_do_fork; else if (!strcmp(arg, "hw_break_val")) addr = (unsigned long)&hw_break_val; - addr = (unsigned long) dereference_function_descriptor((void *)addr); + addr = dereference_function_descriptor(addr); return addr; } diff --git a/init/main.c b/init/main.c index 83bdfa4750b1..ac56f7a4501f 100644 --- a/init/main.c +++ b/init/main.c @@ -764,7 +764,7 @@ static bool __init_or_module initcall_blacklisted(initcall_t fn) if (list_empty(&blacklisted_initcalls)) return false; - addr = (unsigned long) dereference_function_descriptor(fn); + addr = dereference_function_descriptor((unsigned long)fn); sprint_symbol_no_offset(fn_name, addr); /* diff --git a/kernel/extable.c b/kernel/extable.c index 9aa1cc41ecf7..e48d6ba4ce6c 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -167,7 +167,7 @@ int kernel_text_address(unsigned long addr) int func_ptr_is_kernel_text(void *ptr) { unsigned long addr; - addr = (unsigned long) dereference_function_descriptor(ptr); + addr = dereference_function_descriptor((unsigned long)ptr); if (core_kernel_text(addr)) return 1; return is_module_text_address(addr); diff --git a/kernel/module.c b/kernel/module.c index de66ec825992..ea77ab13bead 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1067,7 +1067,7 @@ EXPORT_SYMBOL(__symbol_put); void symbol_put_addr(void *addr) { struct module *modaddr; - unsigned long a = (unsigned long)dereference_function_descriptor(addr); + unsigned long a = dereference_function_descriptor((unsigned long)addr); if (core_kernel_text(a)) return; diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 86c3385b9eb3..bcd906a39010 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -1723,7 +1723,7 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr, switch (*fmt) { case 'F': case 'f': - ptr = dereference_function_descriptor(ptr); + ptr = (void *)dereference_function_descriptor((unsigned long)ptr); /* Fallthrough */ case 'S': case 's':