{"id":814460,"url":"http://patchwork.ozlabs.org/api/1.2/patches/814460/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170916035347.19705-3-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-3-sergey.senozhatsky@gmail.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/20170916035347.19705-3-sergey.senozhatsky@gmail.com/","date":"2017-09-16T03:53:44","name":"[2/5] ia64: Add .opd based function descriptor dereference","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"e4e0e207a62005824e5aaa069894c3c7e20ba66f","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-3-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/814460/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814460/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 3xvJYH6ck7z9t16\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 14:04:03 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xvJYH5CLhzDrct\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 16 Sep 2017 14:04:03 +1000 (AEST)","from mail-pg0-x243.google.com (mail-pg0-x243.google.com\n\t[IPv6:2607:f8b0:400e:c05::243])\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 3xvJRL5WH9zDrnw\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 16 Sep 2017 13:58:54 +1000 (AEST)","by mail-pg0-x243.google.com with SMTP id d8so2241256pgt.3\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 15 Sep 2017 20:58:54 -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.47\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 15 Sep 2017 20:58:52 -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=\"ihzKPt2J\"; 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=\"ihzKPt2J\"; dkim-atps=neutral","ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400e:c05::243; helo=mail-pg0-x243.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=\"ihzKPt2J\"; 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=OfRmoCKaZTxH76f85Hvnq8h3YMNL73s6OtfMeyJchEA=;\n\tb=ihzKPt2JNphNcRhzF55U+ViPAtPrQmrI4I8wS+uNzN58qPLY5oP3FWev2QdTmCt1h8\n\ts7JnP2zWINouAfPuaeoP1QXqNPESvMKATqc0+QIYSeDQ9VxzQzPng1sETMy6vwziSOFm\n\ttE9W6TFPC9Bww4gwudoAVpBeuYnSrjaKtBXvhLTNIw1GdqofUeYrcomKjQXkoggrHI08\n\tiJ6h4pAsD7NVc2XbPEbJX9qVT9rZZHPY6Tp7255fOc0VB+xW1Ici3AXwihBPaahFpjb2\n\tuqi6sGgghRXeWHQddHwcAsgzwZSBRDf4Gohtsh5gB4cqx34se+4ItzqwU73DrnW6wJnT\n\tDHXA==","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=OfRmoCKaZTxH76f85Hvnq8h3YMNL73s6OtfMeyJchEA=;\n\tb=WCFmAGiZ2agoZTLaGc6kMvE8AhSA35G0dYOCj3BoPQYnjRF8CwlQ/OtkPt2S/7f4MT\n\t/mryn08+LlC+EK5o+c1zbYiLKkdRIy2r0IupXJSTXTYlVNFvvR+G92d6FYkYJuSyjO9D\n\t4fWzSjiOoYw621XC8Oe8Ntvvx5aX2EoLd4kIQ+l+rPeGEl4KwMikcxxY4r5pkFk7Xyl3\n\talu/2QGilTiqqnrH2GO3CGf6VDfuib+PLh9EMU1B0SpBb6QOj3KBPwXgV94Z3twjsaf0\n\tGo82uH3iCdTqgk2EDkmoYAcgUHr+4edT5i14G51DEsJOmZWbNPi/EigUF0VM97+xKajp\n\tvtlg==","X-Gm-Message-State":"AHPjjUhmeoDuMwKjDnbsXbVWDU/ocpUwlsSsHNqqjazIyQf2dxn1Ue/3\n\t+CmXJjOlTVd3SA==","X-Google-Smtp-Source":"ADKCNb5+5Kec3ncfrrAw+emYdbKrMNgzOmgON9Y0elrR2xm82eoL2rFLeoBQGYifIqWj24otNRYx4g==","X-Received":"by 10.84.225.2 with SMTP id t2mr30313733plj.425.1505534332715;\n\tFri, 15 Sep 2017 20:58:52 -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 2/5] ia64: Add .opd based function descriptor dereference","Date":"Sat, 16 Sep 2017 12:53:44 +0900","Message-Id":"<20170916035347.19705-3-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 IA64.\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/ia64/include/asm/sections.h | 14 +++++++++++++-\n arch/ia64/kernel/module.c        | 13 +++++++++++++\n arch/ia64/kernel/vmlinux.lds.S   |  2 ++\n 3 files changed, 28 insertions(+), 1 deletion(-)","diff":"diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h\nindex 2ab2003698ef..bff3f3535609 100644\n--- a/arch/ia64/include/asm/sections.h\n+++ b/arch/ia64/include/asm/sections.h\n@@ -25,8 +25,11 @@ extern char __start_gate_fsyscall_patchlist[], __end_gate_fsyscall_patchlist[];\n extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_bubble_down_patchlist[];\n extern char __start_unwind[], __end_unwind[];\n extern char __start_ivt_text[], __end_ivt_text[];\n+extern char __start_opd[], __end_opd[];\n \n #undef dereference_function_descriptor\n+#undef dereference_kernel_function_descriptor\n+\n static inline void *dereference_function_descriptor(void *ptr)\n {\n \tstruct fdesc *desc = ptr;\n@@ -37,6 +40,15 @@ static inline void *dereference_function_descriptor(void *ptr)\n \treturn ptr;\n }\n \n+static inline void *dereference_kernel_function_descriptor(void *ptr)\n+{\n+\t/*\n+\t * Check if the ptr is a function descriptor and thus needs to\n+\t * be dereferenced.\n+\t */\n+\tif (ptr < (void *)__start_opd || (void *)__end_opd < ptr)\n+\t\treturn ptr;\n+\treturn dereference_function_descriptor(ptr);\n+}\n \n #endif /* _ASM_IA64_SECTIONS_H */\n-\ndiff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c\nindex d1d945c6bd05..d42f1e19d75d 100644\n--- a/arch/ia64/kernel/module.c\n+++ b/arch/ia64/kernel/module.c\n@@ -35,6 +35,7 @@\n \n #include <asm/patch.h>\n #include <asm/unaligned.h>\n+#include <asm/sections.h>\n \n #define ARCH_MODULE_DEBUG 0\n \n@@ -917,3 +918,15 @@ module_arch_cleanup (struct module *mod)\n \tif (mod->arch.core_unw_table)\n \t\tunw_remove_unwind_table(mod->arch.core_unw_table);\n }\n+\n+unsigned long dereference_module_function_descriptor(struct module *mod,\n+\t\t\t\t\t     unsigned long addr)\n+{\n+\tElf64_Shdr *opd = mod->arch.opd;\n+\n+\tif (addr < opd->sh_addr ||\n+\t\t\t(opd->sh_addr + opd->sh_size) < addr)\n+\t\treturn addr;\n+\n+\treturn dereference_function_descriptor(addr);\n+}\ndiff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S\nindex 798026dde52e..f872ba5ff82a 100644\n--- a/arch/ia64/kernel/vmlinux.lds.S\n+++ b/arch/ia64/kernel/vmlinux.lds.S\n@@ -107,7 +107,9 @@ SECTIONS {\n \tRODATA\n \n \t.opd : AT(ADDR(.opd) - LOAD_OFFSET) {\n+\t\t__start_opd = .;\n \t\t*(.opd)\n+\t\t__end_opd = .;\n \t}\n \n \t/*\n","prefixes":["2/5"]}