{"id":814462,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814462/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170916035347.19705-5-sergey.senozhatsky@gmail.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/1.2/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<20170916035347.19705-5-sergey.senozhatsky@gmail.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20170916035347.19705-5-sergey.senozhatsky@gmail.com/","date":"2017-09-16T03:53:46","name":"[4/5] parisc64: Add .opd based function descriptor dereference","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"9cdac2dedc09fbd5749d43e684c674a9860c955b","submitter":{"id":3905,"url":"http://patchwork.ozlabs.org/api/1.2/people/3905/?format=json","name":"Sergey Senozhatsky","email":"sergey.senozhatsky@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170916035347.19705-5-sergey.senozhatsky@gmail.com/mbox/","series":[{"id":3413,"url":"http://patchwork.ozlabs.org/api/1.2/series/3413/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=3413","date":"2017-09-16T03:53:42","name":"printk/ia64/ppc64/parisc64: let's deprecate %pF/%pf printk specifiers","version":1,"mbox":"http://patchwork.ozlabs.org/series/3413/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814462/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814462/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xvJdk5Z03z9t16\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 14:07:54 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xvJdk4MrtzDrnw\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 14:07:54 +1000 (AEST)","from mail-pg0-x244.google.com (mail-pg0-x244.google.com\n\t[IPv6:2607:f8b0:400e:c05::244])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xvJRY4c6JzDrnl\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 16 Sep 2017 13:59:05 +1000 (AEST)","by mail-pg0-x244.google.com with SMTP id m30so2240752pgn.5\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 15 Sep 2017 20:59:05 -0700 (PDT)","from localhost.localdomain ([121.137.63.184])\n\tby smtp.gmail.com with ESMTPSA id\n\t76sm4448230pfp.158.2017.09.15.20.58.59\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 15 Sep 2017 20:59:03 -0700 (PDT)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"B9yS/sQa\"; dkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"B9yS/sQa\"; dkim-atps=neutral","ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400e:c05::244; helo=mail-pg0-x244.google.com;\n\tenvelope-from=sergey.senozhatsky@gmail.com; receiver=<UNKNOWN>)","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"B9yS/sQa\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=pbzYOzxbOw6DTwzifZOrQKTCkzmMvM1AuZ6bZBhn/8I=;\n\tb=B9yS/sQadvK96q1aIc5hTaldbqGJxKmWOZVclkuWvDhvllUkDv+5wFFmCKpgn1cLAA\n\tH7x9e98ZIsQ419oDJTJOLNfBYbEsPb/JH/HTuykLHWC5G0jZPQlpDkXFK5An/HMo5XUZ\n\tOD6OOc3LTqA1qF0EgGHjQGttdLlEccIX56KeA/MP80uN8d2RWuiP9IE5wuatW+QzCCK4\n\tsOMICC26mnYTXqWayqsA4IACV674ytavudrLB4ND1rmxXKlm3k1Sknzz82CEDunNamzv\n\tDCQ/HJiGSRSkWJ2JkQ7qTpyjJGeALAgDZfwJTjxTyDkvtYspdsruMEx98/CovfT/c3xd\n\t2Y/A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=pbzYOzxbOw6DTwzifZOrQKTCkzmMvM1AuZ6bZBhn/8I=;\n\tb=C8tOJskilY8rLhJ6427w8oGV7HAxW/XKh9Ef2mUQYL5kwyKnB4FRJzX5rWBzOtovrN\n\tclrMpmW937eyuZrVeWXH5m9e7LPnMKRsCgdlmh9Hk9XUn31+GXH5ZjwBOy6xOtYdJW6g\n\tYPqhkGug7vF9uXwtpP+YcgRL5Nu4c1X6udLPwFe/DzYrt6ucNlEy0faqr6GRpmgz7cGk\n\t+3w6Fp7mmg3BrfwQ1QDLhykDRklvQRkWC0dxqEhlGuAtlO4zAmE5nuHr9OrJDoAyC8MN\n\tqOedGiRrX/n4seK1QPzThwuM1oRiVtx/EOUAACSOrBcpKx6xaepTvTreXUTvrTzpLTIL\n\t60bw==","X-Gm-Message-State":"AHPjjUjlLcVxWyvI9v/FnBrGniNbVu8CxHGme0ybU6tk32Zl2UkTHMJH\n\tdNry5p1hLa6eUw==","X-Google-Smtp-Source":"ADKCNb72JBLpCpXAZRIhvidNNJivAjezU/LFSmdoHpDu8p3KLbsGSzVCVXfc4iL0d9r2cUj11lkcHA==","X-Received":"by 10.99.126.84 with SMTP id o20mr26925543pgn.293.1505534343684; \n\tFri, 15 Sep 2017 20:59:03 -0700 (PDT)","From":"Sergey Senozhatsky <sergey.senozhatsky@gmail.com>","To":"Tony Luck <tony.luck@intel.com>, Fenghua Yu <fenghua.yu@intel.com>,\n\tBenjamin Herrenschmidt <benh@kernel.crashing.org>,\n\tPaul Mackerras <paulus@samba.org>,\n\tMichael Ellerman <mpe@ellerman.id.au>, \n\t\"James E . J . Bottomley\" <jejb@parisc-linux.org>,\n\tHelge Deller <deller@gmx.de>","Subject":"[PATCH 4/5] parisc64: Add .opd based function descriptor dereference","Date":"Sat, 16 Sep 2017 12:53:46 +0900","Message-Id":"<20170916035347.19705-5-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>","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Petr Mladek <pmladek@suse.com>, linux-ia64@vger.kernel.org,\n\tlinux-parisc@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,\n\tSteven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org,\n\tSergey Senozhatsky <sergey.senozhatsky@gmail.com>,\n\tJessica Yu <jeyu@kernel.org>, Andrew Morton <akpm@linux-foundation.org>, \n\tlinuxppc-dev@lists.ozlabs.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"We are moving towards separate kernel and module function descriptor\ndereference callbacks. This patch enables it for parisc64.\n\nFor pointers that belong to the kernel\n-  Added __start_opd and __end_opd pointers, to track the kernel\n   .opd section address range;\n\n-  Added dereference_kernel_function_descriptor(). Now we\n   will dereference only function pointers that are within\n   [__start_opd, __end_opd];\n\nFor pointers that belong to a module\n-  Added dereference_module_function_descriptor() to handle module\n   function descriptor dereference. Now we will dereference only\n   pointers that are within [module->opd.start, module->opd.end].\n\nSigned-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>\n---\n arch/parisc/boot/compressed/vmlinux.lds.S |  2 ++\n arch/parisc/include/asm/sections.h        |  3 +++\n arch/parisc/kernel/module.c               | 14 ++++++++++++++\n arch/parisc/kernel/process.c              | 10 ++++++++++\n arch/parisc/kernel/vmlinux.lds.S          |  2 ++\n 5 files changed, 31 insertions(+)","diff":"diff --git a/arch/parisc/boot/compressed/vmlinux.lds.S b/arch/parisc/boot/compressed/vmlinux.lds.S\nindex a4ce3314e78e..4ebd4e65524c 100644\n--- a/arch/parisc/boot/compressed/vmlinux.lds.S\n+++ b/arch/parisc/boot/compressed/vmlinux.lds.S\n@@ -29,7 +29,9 @@ SECTIONS\n \t. = ALIGN(16);\n \t/* Linkage tables */\n \t.opd : {\n+\t\t__start_opd = .;\n \t\t*(.opd)\n+\t\t__end_opd = .;\n \t} PROVIDE (__gp = .);\n \t.plt : {\n \t\t*(.plt)\ndiff --git a/arch/parisc/include/asm/sections.h b/arch/parisc/include/asm/sections.h\nindex 9d13c3507ad6..e3cde650b2f9 100644\n--- a/arch/parisc/include/asm/sections.h\n+++ b/arch/parisc/include/asm/sections.h\n@@ -6,7 +6,10 @@\n \n #ifdef CONFIG_64BIT\n #undef dereference_function_descriptor\n+#undef dereference_kernel_function_descriptor\n+\n void *dereference_function_descriptor(void *);\n+void *dereference_kernel_function_descriptor(void *);\n #endif\n \n #endif\ndiff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c\nindex f1a76935a314..bc2eae8634fd 100644\n--- a/arch/parisc/kernel/module.c\n+++ b/arch/parisc/kernel/module.c\n@@ -954,3 +954,17 @@ void module_arch_cleanup(struct module *mod)\n {\n \tderegister_unwind_table(mod);\n }\n+\n+#ifdef CONFIG_64BIT\n+unsigned long dereference_module_function_descriptor(struct module *mod,\n+\t\t\t\t\t     unsigned long addr)\n+{\n+\tvoid *opd_sz = mod->arch.fdesc_offset +\n+\t\t       mod->arch.fdesc_max * sizeof(Elf64_Fdesc);\n+\n+\tif (addr < mod->arch.fdesc_offset || opd_sz < addr)\n+\t\treturn addr;\n+\n+\treturn dereference_function_descriptor(addr);\n+}\n+#endif\ndiff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c\nindex 30f92391a93e..f30776bdaa79 100644\n--- a/arch/parisc/kernel/process.c\n+++ b/arch/parisc/kernel/process.c\n@@ -267,6 +267,8 @@ get_wchan(struct task_struct *p)\n }\n \n #ifdef CONFIG_64BIT\n+extern char __start_opd[], __end_opd[];\n+\n void *dereference_function_descriptor(void *ptr)\n {\n \tElf64_Fdesc *desc = ptr;\n@@ -276,6 +278,14 @@ void *dereference_function_descriptor(void *ptr)\n \t\tptr = p;\n \treturn ptr;\n }\n+\n+void *dereference_kernel_function_descriptor(void *ptr)\n+{\n+\tif (ptr < (void *)__start_opd || (void *)__end_opd < ptr)\n+\t\treturn ptr;\n+\n+\treturn dereference_function_descriptor(ptr);\n+}\n #endif\n \n static inline unsigned long brk_rnd(void)\ndiff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S\nindex ffe2cbf52d1a..ab030895dd1e 100644\n--- a/arch/parisc/kernel/vmlinux.lds.S\n+++ b/arch/parisc/kernel/vmlinux.lds.S\n@@ -99,7 +99,9 @@ SECTIONS\n \t. = ALIGN(16);\n \t/* Linkage tables */\n \t.opd : {\n+\t\t__start_opd = .;\n \t\t*(.opd)\n+\t\t__end_opd = .;\n \t} PROVIDE (__gp = .);\n \t.plt : {\n \t\t*(.plt)\n","prefixes":["4/5"]}