From patchwork Wed Sep 20 16:29:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816355 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 3xy50T0D0nz9t2V for ; Thu, 21 Sep 2017 02:33:45 +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="Y7eqD8Ht"; 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 3xy50S5zLXzDqYd for ; Thu, 21 Sep 2017 02:33:44 +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="Y7eqD8Ht"; 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:c05::242; helo=mail-pg0-x242.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="Y7eqD8Ht"; dkim-atps=neutral Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 3xy4vd228HzDqYN for ; Thu, 21 Sep 2017 02:29:33 +1000 (AEST) Received: by mail-pg0-x242.google.com with SMTP id m30so1906201pgn.5 for ; Wed, 20 Sep 2017 09:29:33 -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=G3fttGkVsLeBQ/cCLWZ6QdhMs0FgorO2EWGYUeruwG0=; b=Y7eqD8Ht+CcUll8q0UACbHJ1DqwnvRJgaqu3+IL/Sicf6UonArIbxf19UmrfHEqskB 6HXNwkgFlb76npldONMLJzUFMkhw7UxIrt++k+WQOuQqIdNweSyywJ0T5sXLKCYIOgTH UWP3X7e/w/EcY41pbQLE4bw2sYY7nbAEWISSAE/YvgiGYBpbfH0bVbecMAOuXnuvbWM2 hn7dNRyWmWk69LO341FwX56EZ5brYlZpfPa25HbO/4zUq6t02LCSmAcRt052kEmyKFS4 oAWUYqZHZ3fLDyC+s8+IW/RpHwMMjFvxkoibSbazJRCCjjubXy2Wm+AwhYjjmD27RSl3 +EIw== 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=G3fttGkVsLeBQ/cCLWZ6QdhMs0FgorO2EWGYUeruwG0=; b=FODncM7gfrCws8yhUiAt3yxRy7+bvY+8s78Vyf8E4D/anu77Ce7zggXvmO7AhXjtdY JCsr7YBPe7q2a+WJP0dpJjgljmwz6OgMQtam95qQX3nTDPU755fUBTEdzoDSrwgsegbC UBGgvSDKsGoHBppOFGNDBB1APIj7gdKWY6IT+Dv2P1l7w47lv3XbFBqUjTPRLHFWcHxA ra7PB3+V93+ZWj1mzCttf+cB1bsQ1YjjtX9F8xGQLNv2dJEsdKXo6tLK+qnqq1sORt9u /tZr8+u4ix7kWTWH7ObjtqfGtmjgb6FErNkRMG0JnGU8+5sqGM6xUkRIA1DO4SOwVrDy HlSA== X-Gm-Message-State: AHPjjUgXC0JL3wX4wGHon+WSA62LuIKA4b7+fXyj0acSVAjDYXNZUSBV IWFNo94FcbbM6RYFsTrbA9Y= X-Google-Smtp-Source: AOwi7QC9NDeyUMFXPom2wdTml5vvs2L6YlGXxxyyIl/OPsvINQTv4D1YAUBl82hj7MzwNMTZHoJHHw== X-Received: by 10.159.244.9 with SMTP id x9mr2648860plr.34.1505924970757; Wed, 20 Sep 2017 09:29:30 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:29 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 1/7] switch dereference_function_descriptor() to `unsigned long' Date: Thu, 21 Sep 2017 01:29:03 +0900 Message-Id: <20170920162910.32053-2-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" 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 --- 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 a45a67d526f8..f00a5f93492a 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 0ee9c6866ada..396b0bda696e 100644 --- a/init/main.c +++ b/init/main.c @@ -761,7 +761,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 38c2412401a1..ca4c34d1d5a4 100644 --- a/kernel/extable.c +++ b/kernel/extable.c @@ -150,7 +150,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': From patchwork Wed Sep 20 16:29:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816357 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy52c4xWkz9t2Q for ; Thu, 21 Sep 2017 02:35:36 +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="odRRVgYd"; 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 3xy52c3K1QzDqR8 for ; Thu, 21 Sep 2017 02:35:36 +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="odRRVgYd"; 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::241; helo=mail-pf0-x241.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="odRRVgYd"; dkim-atps=neutral Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::241]) (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 3xy4vk3KZSzDqYd for ; Thu, 21 Sep 2017 02:29:38 +1000 (AEST) Received: by mail-pf0-x241.google.com with SMTP id e69so1379774pfg.4 for ; Wed, 20 Sep 2017 09:29:38 -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=y7ek0k6yNfVDcFDcWSjt90y7isFoahrknAhAcPVdQLE=; b=odRRVgYd1jq1sdQF0VOWPjdANOEOyKuA1HOfhF89TuiDihNbu0NGGHlgo3jL+vMQBP sLvUFxigHH/abAhu7zDp3w/X5FA2DHMRAPhvL5KFzjli7wA3Hg7tyQD/Qec0OSWK7GGn 5FbnWtqSybPrDqsGiJSFiM1dcDvUqgJ/46nHsqvwfoO5btbf3oTILmBefIvuFHWCvsVe SLn0y96cuThxbH7VK7mJU8HDnh6hdJiGXx95aqnu223nR05xjuj92k0eE9/uTQT5DJTX y7QVxoIMT9ML+Ns9i+rlCv1tPkGhlct7kCvT8F0pmXy8+W1Jq184kqdt+OReXjQbPAoT YjUQ== 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=y7ek0k6yNfVDcFDcWSjt90y7isFoahrknAhAcPVdQLE=; b=sVxTwRveex3TkHR8ZATWOCfGdTxbGfOFF3kQ+ENTISjIapzLeuTaG3d65InVMcSxGC rUZYlUu5ujwnsGJ+PLedR5xpHRJLfvkfLikYlB8E5eHD2NPZIKtqKW7pgCN1vdJGE7b7 FSC3IS8yHkX42xFTY5Uh2MeBqKQfRU4lec0pE906JAEJNXq0fbK1jB5sodrDmVZtaNYu ogFoSgC2axP/OoPH3AnBlAkhzxH1gyds7KxWxjqNgqKgONmLKB8Yndgo2MnwHXlp7UDx dG471tqvZy0MEILZxFUtu98UThdmUTUYTTn6qgpc9Np4sXqlHZkZAKNXRUELnybBuf3+ OAqQ== X-Gm-Message-State: AHPjjUiizGnXvdnG5SDXBUQOrLzcvS5e5W5EFCQ0DLM+eDod2hVqFqZc 8vLwFApmO+gnxmel8nqJZ+E= X-Google-Smtp-Source: AOwi7QBfKTgMwxwUkZ2Szsm1K2G9KlbvlIlVSiGj+W/I1VmkvOf8kyTrkqI/YjPo2Uf1fAuOJXUb3A== X-Received: by 10.99.136.73 with SMTP id l70mr2766706pgd.185.1505924976402; Wed, 20 Sep 2017 09:29:36 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:35 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 2/7] sections: split dereference_function_descriptor() Date: Thu, 21 Sep 2017 01:29:04 +0900 Message-Id: <20170920162910.32053-3-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" There are two format specifiers to print out a pointer in symbolic format: '%pS/%ps' and '%pF/%pf'. On most architectures, the two mean exactly the same thing, but some architectures (ia64, ppc64, parisc64) use an indirect pointer for C function pointers, where the function pointer points to a function descriptor (which in turn contains the actual pointer to the code). The '%pF/%pf, when used appropriately, automatically does the appropriate function descriptor dereference on such architectures. The "when used appropriately" part is tricky. Basically this is a subtle ABI detail, specific to some platforms, that made it to the API level and people can be unaware of it and miss the whole "we need to dereference the function" business out. [1] proves that point (note that it fixes only '%pF' and '%pS', there might be '%pf' and '%ps' cases as well). It appears that we can handle everything within the affected arches and make '%pS/%ps' smart enough to retire '%pF/%pf'. Function descriptors live in .opd elf section and all affected arches (ia64, ppc64, parisc64) handle it properly for kernel and modules. So we, technically, can decide if the dereference is needed by simply looking at the pointer: if it belongs to .opd section then we need to dereference it. The kernel and modules have their own .opd sections, obviously, that's why we need to split dereference_function_descriptor() and use separate kernel and module dereference arch callbacks. This patch does the first step, it a) adds dereference_kernel_function_descriptor() function. b) adds a weak alias to dereference_module_function_descriptor() function. So, for the time being, we will have: 1) dereference_function_descriptor() A generic function, that simply dereferences the pointer. There is bunch of places that call it: kgdbts, init/main.c, extable, etc. 2) dereference_kernel_function_descriptor() A function to call on kernel symbols that does kernel .opd section address range test. 3) dereference_module_function_descriptor() A function to call on modules' symbols that does modules' .opd section address range test. [1] https://marc.info/?l=linux-kernel&m=150472969730573 Signed-off-by: Sergey Senozhatsky --- include/asm-generic/sections.h | 8 ++++++-- include/linux/moduleloader.h | 4 ++++ kernel/module.c | 6 ++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h index e5da44eddd2f..387f22c41e0d 100644 --- a/include/asm-generic/sections.h +++ b/include/asm-generic/sections.h @@ -29,6 +29,7 @@ * __ctors_start, __ctors_end * __irqentry_text_start, __irqentry_text_end * __softirqentry_text_start, __softirqentry_text_end + * __start_opd, __end_opd */ extern char _text[], _stext[], _etext[]; extern char _data[], _sdata[], _edata[]; @@ -47,12 +48,15 @@ extern char __softirqentry_text_start[], __softirqentry_text_end[]; /* Start and end of .ctors section - used for constructor calls. */ extern char __ctors_start[], __ctors_end[]; +/* Start and end of .opd section - used for function descriptors. */ +extern char __start_opd[], __end_opd[]; + extern __visible const void __nosave_begin, __nosave_end; -/* function descriptor handling (if any). Override - * in asm/sections.h */ +/* Function descriptor handling (if any). Override in asm/sections.h */ #ifndef dereference_function_descriptor #define dereference_function_descriptor(p) (p) +#define dereference_kernel_function_descriptor(p) (p) #endif /* random extra sections (if any). Override diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h index 4d0cb9bba93e..172904e9cded 100644 --- a/include/linux/moduleloader.h +++ b/include/linux/moduleloader.h @@ -85,6 +85,10 @@ void module_arch_cleanup(struct module *mod); /* Any cleanup before freeing mod->module_init */ void module_arch_freeing_init(struct module *mod); +/* Dereference module function descriptor */ +unsigned long dereference_module_function_descriptor(struct module *mod, + unsigned long addr); + #ifdef CONFIG_KASAN #include #define MODULE_ALIGN (PAGE_SIZE << KASAN_SHADOW_SCALE_SHIFT) diff --git a/kernel/module.c b/kernel/module.c index ea77ab13bead..b792e814150a 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2121,6 +2121,12 @@ void __weak module_arch_freeing_init(struct module *mod) { } +unsigned long __weak dereference_module_function_descriptor(struct module *mod, + unsigned long addr) +{ + return addr; +} + /* Free a module, remove from lists, etc. */ static void free_module(struct module *mod) { From patchwork Wed Sep 20 16:29:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816360 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy54j6gsPz9t2V for ; Thu, 21 Sep 2017 02:37:25 +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="jajmRc0Z"; 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 3xy54h5rnVzDqZ9 for ; Thu, 21 Sep 2017 02:37:24 +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="jajmRc0Z"; 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:c05::243; helo=mail-pg0-x243.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="jajmRc0Z"; dkim-atps=neutral Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (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 3xy4vq4bLZzDqYG for ; Thu, 21 Sep 2017 02:29:43 +1000 (AEST) Received: by mail-pg0-x243.google.com with SMTP id i130so1920804pgc.0 for ; Wed, 20 Sep 2017 09:29:43 -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=IVAulDM2MKKdZk1OZegitOzApbierimhT0gYtTgDJWc=; b=jajmRc0ZwsnkFVu18tnfxCImmLKjOkv2J3cQnWjcnxLMLIaTxwNsBEoWzq4mqKDy2j BdNBQS+J3vJ/A70Tz8I36e13wX8ZTSL/TIWbqPvz6t6+EtYVBLN5ih/uA4xK5RRsYMt/ n8hr/Bjx88YKXXN2iN65HO+GSWkfmHSrvhm+OTjeSrsZZjPyh2Z7UjQ80dRBnad19tfk Ag5TQyEao/v266G6eiOaZN+HG41/1uhcW2QoLl1Pqj4Up14jQeYLapwZV2lxzNO4hqqB aTlOZ3FT5cJu35ilAUPt00B+cIJx+yhrQkwI74Rex4ARpVENszlSJ+dVajmIuOKOjhD/ 2dtw== 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=IVAulDM2MKKdZk1OZegitOzApbierimhT0gYtTgDJWc=; b=ne2jyuPYwDQsGIkkiQJzEdzoJOgBGKumf3fH27N4cOuor55UflULq2RVewnda+6D7w /fz44fQJEb7jwCCNIiMUzwyhfzpHna73DAWkuX6RQk7HEzxyROVX/q9oIFjQul0HyM9M sb5I7ASC/KHbPxNiqxNgPrB7Gulat2NE0EzpmHcuxCRe63wIEBzKl3D8E1AWurduAL/p 705aDTGJVATMBwftnnNBQcUqJ3AlDz7mm1g2EEozUm2vHPyLRp4Z7MXDNvxqpf7EIrEO ZjwxGSB/VwwHd2m4QcdzKMlJCTzaDy0QpW6QDmMoK6pMyC/I8za/yRUuN2zLyIn4u/AK 3f1g== X-Gm-Message-State: AHPjjUhwMv2GvjeH+OwpYmdBMV2b2T1JkErgciqd90qWm0z2P4DC+Ybu +DKDiKkx/pigVPso9QuJShQ= X-Google-Smtp-Source: AOwi7QBP83WtIrL8LGb2FGXLigRnemasRkz5paUxfjDZz+Z9pZJ3qIlcuPqNOuhInxK7aoVNubFARg== X-Received: by 10.99.123.17 with SMTP id w17mr2779371pgc.57.1505924981970; Wed, 20 Sep 2017 09:29:41 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:41 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 3/7] ia64: Add .opd based function descriptor dereference Date: Thu, 21 Sep 2017 01:29:05 +0900 Message-Id: <20170920162910.32053-4-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" We are moving towards separate kernel and module function descriptor dereference callbacks. This patch enables it for IA64. For pointers that belong to the kernel - Added __start_opd and __end_opd pointers, to track the kernel .opd section address range; - Added dereference_kernel_function_descriptor(). Now we will dereference only function pointers that are within [__start_opd, __end_opd]; For pointers that belong to a module - Added dereference_module_function_descriptor() to handle module function descriptor dereference. Now we will dereference only pointers that are within [module->opd.start, module->opd.end]. Signed-off-by: Sergey Senozhatsky --- arch/ia64/include/asm/sections.h | 10 +++++++++- arch/ia64/kernel/module.c | 13 +++++++++++++ arch/ia64/kernel/vmlinux.lds.S | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h index de6bfa1ef8fb..3ba7ce9d8bc8 100644 --- a/arch/ia64/include/asm/sections.h +++ b/arch/ia64/include/asm/sections.h @@ -37,6 +37,14 @@ static inline unsigned long dereference_function_descriptor(unsigned long ptr) return ptr; } +#undef dereference_kernel_function_descriptor +static inline unsigned long +dereference_kernel_function_descriptor(unsigned long addr) +{ + if (addr < (unsigned long)__start_opd || + addr >= (unsigned long)__end_opd) + return addr; + return dereference_function_descriptor(addr); +} #endif /* _ASM_IA64_SECTIONS_H */ - diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c index d1d945c6bd05..0741ae6fa957 100644 --- a/arch/ia64/kernel/module.c +++ b/arch/ia64/kernel/module.c @@ -35,6 +35,7 @@ #include #include +#include #define ARCH_MODULE_DEBUG 0 @@ -917,3 +918,15 @@ module_arch_cleanup (struct module *mod) if (mod->arch.core_unw_table) unw_remove_unwind_table(mod->arch.core_unw_table); } + +unsigned long +dereference_module_function_descriptor(struct module *mod, unsigned long addr) +{ + Elf64_Shdr *opd = mod->arch.opd; + + if (addr < opd->sh_addr || + addr >= (opd->sh_addr + opd->sh_size)) + return addr; + + return dereference_function_descriptor(addr); +} diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S index 798026dde52e..f872ba5ff82a 100644 --- a/arch/ia64/kernel/vmlinux.lds.S +++ b/arch/ia64/kernel/vmlinux.lds.S @@ -107,7 +107,9 @@ SECTIONS { RODATA .opd : AT(ADDR(.opd) - LOAD_OFFSET) { + __start_opd = .; *(.opd) + __end_opd = .; } /* From patchwork Wed Sep 20 16:29:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816362 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 3xy57b605dz9t2Q for ; Thu, 21 Sep 2017 02:39:55 +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="qT+NjFfZ"; 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 3xy57b2WdHzDqY3 for ; Thu, 21 Sep 2017 02:39:55 +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="qT+NjFfZ"; 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:c05::242; helo=mail-pg0-x242.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="qT+NjFfZ"; dkim-atps=neutral Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 3xy4vx3Pv0zDqXp for ; Thu, 21 Sep 2017 02:29:49 +1000 (AEST) Received: by mail-pg0-x242.google.com with SMTP id d8so1911938pgt.3 for ; Wed, 20 Sep 2017 09:29:49 -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=CnpHgZ2+ZTbCeZd1Ck+ekMy+VDRmM6IJjtCT7xMUDx0=; b=qT+NjFfZCLQ+T28UFYOveLZbPebjdNHNDpSawkskKAh78+fZUB7mF6vKhqke6hUtE+ t8KLdhyP2uSNMiOzmf5qo3TXOMY4x0ZNGV9iovw5+ElQ46EMoKEXzZxzII+LQ87Lma6O 16wqhqrmam07MQtdAL9DzybtPJ0SnRRjc3IMsSwU0EHIUj/TagxQyzWCqq0HaupEmE4F k89vTKN1T1LwBwqS/LfRJqOpGiJSXiYR2vH7wpAIChBWhOoARyqx0B/m2K5oTY2b6h8k G788Kbsx+l/2NdSdgNd7/TZXzZM/1M+coMb2fBzvLdrnVVNGvmBixyPddhC+IDcnUplX SgEw== 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=CnpHgZ2+ZTbCeZd1Ck+ekMy+VDRmM6IJjtCT7xMUDx0=; b=l+YZhT8CjAV1FfKkWHulo9e/zRi89IZTJ8Ei7b4yGwrqgTGc6cyueR6uLSuC+feyQa BiEUY2us1Z0wdBs/SV/UvYYGVjxSPfPlWO4x3NpN5U2/FqU0VD0QMlHK9a2dWGTGnjRz IiihsSI3hexIDQLKcn565KqovhYRtFLseq8YYYkiRGF0yPnSHNS8hBS7z8rstxH5Zoxy xPxc4XkV9VO+xBmu07DCzEXc/eAP3t/e3Q86qB3rpm8Z45S1H765Yvt9zsFLT+C+XOrc 1Ofyoi9YbZac8dM75GK4loBEsr7H7bcdxLubbTr1rjua9OGzf7ncwFxug1l6Q2ALC9ob 4cUw== X-Gm-Message-State: AHPjjUhHZ2jmqW0semJaZm86z/xrZKc7a7xDPBNM5iW47Hozz5PyVpeh UKMhQMLk3MVBrvX7r8M2GNY= X-Google-Smtp-Source: AOwi7QCrWWE7JWto/ELgrvGD7Q73g/KaZRTUdedeG7gRRvMzwtVaqTFnXpCqR3nF+W0msrQuVMrdsg== X-Received: by 10.84.194.1 with SMTP id g1mr2651908pld.74.1505924987817; Wed, 20 Sep 2017 09:29:47 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:47 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 4/7] powerpc64: Add .opd based function descriptor dereference Date: Thu, 21 Sep 2017 01:29:06 +0900 Message-Id: <20170920162910.32053-5-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" We are moving towards separate kernel and module function descriptor dereference callbacks. This patch enables it for powerpc64. For pointers that belong to the kernel - Added __start_opd and __end_opd pointers, to track the kernel .opd section address range; - Added dereference_kernel_function_descriptor(). Now we will dereference only function pointers that are within [__start_opd, __end_opd]; For pointers that belong to a module - Added dereference_module_function_descriptor() to handle module function descriptor dereference. Now we will dereference only pointers that are within [module->opd.start, module->opd.end]. Signed-off-by: Sergey Senozhatsky --- arch/powerpc/include/asm/module.h | 3 +++ arch/powerpc/include/asm/sections.h | 11 +++++++++++ arch/powerpc/kernel/module_64.c | 16 ++++++++++++++++ arch/powerpc/kernel/vmlinux.lds.S | 2 ++ 4 files changed, 32 insertions(+) diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h index 6c0132c7212f..7e28442827f1 100644 --- a/arch/powerpc/include/asm/module.h +++ b/arch/powerpc/include/asm/module.h @@ -45,6 +45,9 @@ struct mod_arch_specific { unsigned long tramp; #endif + /* For module function descriptor dereference */ + unsigned long start_opd; + unsigned long end_opd; #else /* powerpc64 */ /* Indices of PLT sections within module. */ unsigned int core_plt_section; diff --git a/arch/powerpc/include/asm/sections.h b/arch/powerpc/include/asm/sections.h index 67379b8945e8..6b4ee0d1645f 100644 --- a/arch/powerpc/include/asm/sections.h +++ b/arch/powerpc/include/asm/sections.h @@ -75,6 +75,17 @@ static inline unsigned long dereference_function_descriptor(unsigned long ptr) ptr = (unsigned long)p; return ptr; } + +#undef dereference_kernel_function_descriptor +static inline unsigned long +dereference_kernel_function_descriptor(unsigned long addr) +{ + if (addr < (unsigned long)__start_opd || + addr >= (unsigned long)__end_opd) + return addr; + + return dereference_function_descriptor(addr); +} #endif /* PPC64_ELF_ABI_v1 */ #endif diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index 0b0f89685b67..94caec045a90 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -344,6 +344,11 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, else if (strcmp(secstrings+sechdrs[i].sh_name,"__versions")==0) dedotify_versions((void *)hdr + sechdrs[i].sh_offset, sechdrs[i].sh_size); + else if (!strcmp(secstrings + sechdrs[i].sh_name, ".opd")) { + me->arch.start_opd = sechdrs[i].sh_addr; + me->arch.end_opd = sechdrs[i].sh_addr + + sechdrs[i].sh_size; + } /* We don't handle .init for the moment: rename to _init */ while ((p = strstr(secstrings + sechdrs[i].sh_name, ".init"))) @@ -712,6 +717,17 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, return 0; } +#ifdef PPC64_ELF_ABI_v1 +unsigned long dereference_module_function_descriptor(struct module *mod, + unsigned long addr) +{ + if (addr < mod->arch.start_opd || addr >= mod->arch.end_opd) + return addr; + + return dereference_function_descriptor(addr); +} +#endif /* PPC64_ELF_ABI_v1 */ + #ifdef CONFIG_DYNAMIC_FTRACE #ifdef CC_USING_MPROFILE_KERNEL diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index 882628fa6987..70e10251e083 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -277,7 +277,9 @@ SECTIONS } .opd : AT(ADDR(.opd) - LOAD_OFFSET) { + __start_opd = .; *(.opd) + __end_opd = .; } . = ALIGN(256); From patchwork Wed Sep 20 16:29:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816364 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy59w0t6mz9t2Q for ; Thu, 21 Sep 2017 02:41:56 +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="EYACIY/8"; 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 3xy59v6Z4NzDqb3 for ; Thu, 21 Sep 2017 02:41:55 +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="EYACIY/8"; 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="EYACIY/8"; 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 3xy4w31xGVzDqXs for ; Thu, 21 Sep 2017 02:29:55 +1000 (AEST) Received: by mail-pf0-x244.google.com with SMTP id f84so1385308pfj.3 for ; Wed, 20 Sep 2017 09:29:55 -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=5eIjg/ySaCRfpzRnqi0tMWSm+HJQGizVM74onIhSWcg=; b=EYACIY/85bxiwzKyji/JGfkKrb+hKh2w1Grph1h2siq0bq3Bc0+kjazx5ywiVeqER0 rpUwLa88CPEsABVDMWkxHl31lQ9mOJ6DLab//9Ohwe0McxnhtwnjtTEnfFBxwZA9NPqQ uIaJAM3FNhKL+jyDnvM3YShaO+eTbtPOGwRroFytBFXAaBZ3nftEl7bD0xH1+RV3AoS3 1d6u7YOhUOczgA57eczgncO3/P26Xba8CI3ES2NQl+k5biCpxho+FZ3MgP+SElxRE31i sbXuE872rsEQCJ+qUchpxXKYWpenpTaDAtLQJYSfl6ufyFI2VdPY3Dv8ZLaXQb+FZ76P KUBQ== 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=5eIjg/ySaCRfpzRnqi0tMWSm+HJQGizVM74onIhSWcg=; b=rPbrfaRamcrnOSiH2LUPGGDaXB4XF2IIDlsc5OOYQEW4lRd/AP25kbaIoanhrXPZpI KC+QWJJT7w8L66Vzpbo0BMkw/67foqzs3e47TbueNmaZDrkwvOjBeLVrn7LJOGY19KRL rtaz1fwy93tGNApd9J5iX7DdBYioDJDjwhj7LwoZOqKvBQz5kxxNVd3gAmCiRa+fYKJM zEhImnrBYcuqsq7dJdMxTmH3tVzvzALOCTv8jDoXxzyVSGxbIdFFCcEg3S8Vv17tu0wH XjakqLMh6UOvX2hHtUPznPXpFFtlNql+DMr/H0B+9tau/1kedZ+1lgxFCDwD308s1ZGV PKUA== X-Gm-Message-State: AHPjjUhjTxYTm8apGcS3CXCyFaeKilNCEFrtajLyBkmDMQryTdaBsOkL xKMYPCtnYMni2lHTEoAEptc= X-Google-Smtp-Source: AOwi7QAYa+3JtEOvkBLsP+qwgBdQG8fYt4kSJ3hmVGmmEX/f380U2izXDo5cNKhDv/DbogyDvWzVfA== X-Received: by 10.99.154.18 with SMTP id o18mr1720623pge.18.1505924993567; Wed, 20 Sep 2017 09:29:53 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:29:52 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 5/7] parisc64: Add .opd based function descriptor dereference Date: Thu, 21 Sep 2017 01:29:07 +0900 Message-Id: <20170920162910.32053-6-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" We are moving towards separate kernel and module function descriptor dereference callbacks. This patch enables it for parisc64. For pointers that belong to the kernel - Added __start_opd and __end_opd pointers, to track the kernel .opd section address range; - Added dereference_kernel_function_descriptor(). Now we will dereference only function pointers that are within [__start_opd, __end_opd]; For pointers that belong to a module - Added dereference_module_function_descriptor() to handle module function descriptor dereference. Now we will dereference only pointers that are within [module->opd.start, module->opd.end]. Signed-off-by: Sergey Senozhatsky Signed-off-by: Helge Deller --- arch/parisc/boot/compressed/vmlinux.lds.S | 2 ++ arch/parisc/include/asm/sections.h | 2 ++ arch/parisc/kernel/module.c | 17 +++++++++++++++++ arch/parisc/kernel/process.c | 9 +++++++++ arch/parisc/kernel/vmlinux.lds.S | 2 ++ 5 files changed, 32 insertions(+) diff --git a/arch/parisc/boot/compressed/vmlinux.lds.S b/arch/parisc/boot/compressed/vmlinux.lds.S index a4ce3314e78e..4ebd4e65524c 100644 --- a/arch/parisc/boot/compressed/vmlinux.lds.S +++ b/arch/parisc/boot/compressed/vmlinux.lds.S @@ -29,7 +29,9 @@ SECTIONS . = ALIGN(16); /* Linkage tables */ .opd : { + __start_opd = .; *(.opd) + __end_opd = .; } PROVIDE (__gp = .); .plt : { *(.plt) diff --git a/arch/parisc/include/asm/sections.h b/arch/parisc/include/asm/sections.h index 59fbe0067112..845ddc9a3421 100644 --- a/arch/parisc/include/asm/sections.h +++ b/arch/parisc/include/asm/sections.h @@ -7,6 +7,8 @@ #ifdef CONFIG_64BIT #undef dereference_function_descriptor unsigned long dereference_function_descriptor(unsigned long); +#undef dereference_kernel_function_descriptor +unsigned long dereference_kernel_function_descriptor(unsigned long); #endif #endif diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c index f1a76935a314..28f89b3dcc11 100644 --- a/arch/parisc/kernel/module.c +++ b/arch/parisc/kernel/module.c @@ -66,6 +66,7 @@ #include #include +#include #if 0 #define DEBUGP printk @@ -954,3 +955,19 @@ void module_arch_cleanup(struct module *mod) { deregister_unwind_table(mod); } + +#ifdef CONFIG_64BIT +unsigned long dereference_module_function_descriptor(struct module *mod, + unsigned long addr) +{ + unsigned long start_opd = (Elf64_Addr)mod->core_layout.base + + mod->arch.fdesc_offset; + unsigned long end_opd = start_opd + + mod->arch.fdesc_count * sizeof(Elf64_Fdesc); + + if (addr < start_opd || addr >= end_opd) + return addr; + + return dereference_function_descriptor(addr); +} +#endif diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index f00a5f93492a..ff13726b2d2d 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -276,6 +276,15 @@ unsigned long dereference_function_descriptor(unsigned long ptr) ptr = (unsigned long)p; return ptr; } + +unsigned long dereference_kernel_function_descriptor(unsigned long addr) +{ + if (addr < (unsigned long)__start_opd || + addr >= (unsigned long)__end_opd) + return addr; + + return dereference_function_descriptor(addr); +} #endif static inline unsigned long brk_rnd(void) diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S index ffe2cbf52d1a..ab030895dd1e 100644 --- a/arch/parisc/kernel/vmlinux.lds.S +++ b/arch/parisc/kernel/vmlinux.lds.S @@ -99,7 +99,9 @@ SECTIONS . = ALIGN(16); /* Linkage tables */ .opd : { + __start_opd = .; *(.opd) + __end_opd = .; } PROVIDE (__gp = .); .plt : { *(.plt) 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': From patchwork Wed Sep 20 16:29:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 816366 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xy5Fz1sn5z9t2Q for ; Thu, 21 Sep 2017 02:45:27 +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="g33OEuK6"; 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 3xy5Fz0XpBzDqj8 for ; Thu, 21 Sep 2017 02:45:27 +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="g33OEuK6"; 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:c05::242; helo=mail-pg0-x242.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="g33OEuK6"; dkim-atps=neutral Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 3xy4wH0rbhzDqYY for ; Thu, 21 Sep 2017 02:30:07 +1000 (AEST) Received: by mail-pg0-x242.google.com with SMTP id u18so1919413pgo.1 for ; Wed, 20 Sep 2017 09:30:07 -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=HJqhUlNnWHdffPLzDjDRPKA3+7BArB5/r6DxGIZj5oI=; b=g33OEuK6nTtEpDQOIPbrRhPIn/I4HgD2NHO2mWXr3Q4fbDS0yC58g79e5XVh6pfII/ Sl6TatUiOsHhqn7s0Uo7NLmkbt+V+4uYZ9N4+/zcfOCsi9kjD4x1qPzeIbEl6YOTuK5r ntqJkG+2GEaXMYJL7h1uQ1jAfdq2uxSra1h9Zj650pYR0aaDq9BNI7Dg4K1aDcNg0l1z vrVdc2kvTioAPArW/A/qZIfjWzdeyAPHxbjfwV2kR0pqHRZGBepFkot6seoR7nC9u2La 04AWWWRqDyTiEuIEQH3mhlAUb6/vJZMExDPb2VSn41W1uEZzCK8WqIZHQBc9yuRjQ6cC VBfA== 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=HJqhUlNnWHdffPLzDjDRPKA3+7BArB5/r6DxGIZj5oI=; b=Ue/wxaMqdGlq5iV1jngQ0GUBQSvNzcOxzdYYNzt1gfnOxFUOvS69hBThJx5+vK85CN 16qkoyJSK0q0cq0CTU8QB5II1BKQ8nvZhMZ8coDErxTlFhG7CUkvvudb50M0REAZwyap 4pLPzhc0k24TX+M6d0LGdcoegB2dmKUei7ayfYGR5g+/WJEZFa8Ucg50RT8b9Yr24UT0 2hRduamGVaciyfdmtW9UBk5NpyZtH8jd49Zeyu05MU+VhzzGzUmoXqHADZaikEl21xgA tXf0mrLBB1mCpDgCrsHDZ+alqJtZyGqKv2dHaVeeJJEJ4rnga2XfyPAp3CyM/Bpibx46 1Brg== X-Gm-Message-State: AHPjjUh+TB5e0+HkX83GdnfD3rny8fUA9hgohIAVdnaPtAd9TCttBlmy dPsdHZXNEhu9wIg4gm7KSbw= X-Google-Smtp-Source: AOwi7QDFueRMZKFGzhb2953NehyciXW4SyKQCVnC2ZD58b12+vb/xEkXNNtIeP6AR0LqOv5K7lFGXQ== X-Received: by 10.98.12.84 with SMTP id u81mr2735453pfi.93.1505925005415; Wed, 20 Sep 2017 09:30:05 -0700 (PDT) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id c185sm8890567pfb.57.2017.09.20.09.30.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 09:30:04 -0700 (PDT) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley , Helge Deller Subject: [RFC][PATCH v2 7/7] checkpatch: add pF/pf deprecation warning Date: Thu, 21 Sep 2017 01:29:09 +0900 Message-Id: <20170920162910.32053-8-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 , Andy Whitcroft , Joe Perches , Andrew Morton , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" We deprecated '%pF/%pf' printk specifiers, since '%pS/%ps' is now smart enough to handle function pointer dereference on platforms where such dereference is required. checkpatch warning example: WARNING: Use '%pS/%ps' instead. This pointer extension was deprecated: '%pF' Signed-off-by: Sergey Senozhatsky Cc: Andy Whitcroft Cc: Joe Perches --- scripts/checkpatch.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index dd2c262aebbf..5945e4843466 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5762,18 +5762,20 @@ sub process { for (my $count = $linenr; $count <= $lc; $count++) { my $fmt = get_quoted_string($lines[$count - 1], raw_line($count, 0)); $fmt =~ s/%%//g; - if ($fmt =~ /(\%[\*\d\.]*p(?![\WFfSsBKRraEhMmIiUDdgVCbGNO]).)/) { + if ($fmt =~ /(\%[\*\d\.]*p(?![\WSsBKRraEhMmIiUDdgVCbGNO]).)/) { $bad_extension = $1; last; } } if ($bad_extension ne "") { my $stat_real = raw_line($linenr, 0); + my $error_msg = "Invalid vsprintf pointer extension "; for (my $count = $linenr + 1; $count <= $lc; $count++) { $stat_real = $stat_real . "\n" . raw_line($count, 0); } + $error_msg = "Use '%pS/%ps' instead. This pointer extension was deprecated:" if ($bad_extension =~ /pF|pf/); WARN("VSPRINTF_POINTER_EXTENSION", - "Invalid vsprintf pointer extension '$bad_extension'\n" . "$here\n$stat_real\n"); + "$error_msg '$bad_extension'\n" . "$here\n$stat_real\n"); } }