From patchwork Thu Nov 9 23:48:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 836565 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 3yY0T73tbGz9sRg for ; Fri, 10 Nov 2017 10:57:15 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="O+L/SxPE"; 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 3yY0T666CmzDrL2 for ; Fri, 10 Nov 2017 10:57:14 +1100 (AEDT) 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="O+L/SxPE"; 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::242; helo=mail-pf0-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="O+L/SxPE"; dkim-atps=neutral Received: from mail-pf0-x242.google.com (mail-pf0-x242.google.com [IPv6:2607:f8b0:400e:c00::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 3yY0KS75BszDrKr for ; Fri, 10 Nov 2017 10:50:36 +1100 (AEDT) Received: by mail-pf0-x242.google.com with SMTP id n89so5420011pfk.11 for ; Thu, 09 Nov 2017 15:50:36 -0800 (PST) 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=UaqRt1smuZzvbe8uveWMIsZ0DA2RPsD/o2ale1Nc+rc=; b=O+L/SxPECrGH0GwSQ2KL+U37QRSp6CwXb78MkIEa4eIra5SE6Amt5WEq9DMPk1Xovq Ob3Ewz8eHlsRrN/eBjWTtId5eGnq8fr1yA9uPlFI4whr81grKqBv3Je0xoX7lXEzDrW6 ELncvnstdTEq3LN00kys9QUj+qF4JELv6sKMLcuiGHuAlncUJLq+h3JbwM13f0eJKxhL LuY3uuLkU6NHf/V7lTLap2XHnUDN4b8JkXWHlv4Mp7LilYEvo9Fvyr2Fcxb2S1zRD3dT P9DkDMhPQxX/8pdUdrQRc4AZghjoym90ax8ZpgvXNb/rDvmfJAKCucV8vsWsswMduevi 3d7Q== 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=UaqRt1smuZzvbe8uveWMIsZ0DA2RPsD/o2ale1Nc+rc=; b=FZtsjaVpSjWPqG/px4f3JpeqCQrebDgQHL1wq7O3qYbQ/OJVqny0skPVRkG8mKxxnV OdZNwN9jrq/W5bZkBkHCXlJpFLb5S1EAI+CdGdPyldpYNGMMwdJQB/YPHrOI+ePXpvp9 CdfBBPpudR6I24yYz5qY1LqbRoUBe9DsUyrG22z9YL/TadXmPp7ZhJwVizq3dHkbqJFU P6+JiE1KteqXu2F/bHxeW0clQbVSbjZ2CtzTkU13qhG91++wuODar7ykXQoJU0THT7Qg HeQ6MoFHD/WyqeDvzcOZWaeuWm0y1vpcb58yAC9CXI95B6IHYEBAuWwcS6XFpmdR3KYQ EMlw== X-Gm-Message-State: AJaThX5qR57q4LFYwpJwnOLvXy8nmX5IXbZrsYYjw7Ea+NOovhKs7oDG BWPjZ8PXYmAMR2Bqgz5lJBg= X-Google-Smtp-Source: ABhQp+T2wdePCUduJL9usty0aF4TXGsxg5uyn7tdRmkb+BJVvUrC+VL9euaWP+91xlV3ozCfNFNb0A== X-Received: by 10.98.113.130 with SMTP id m124mr2145880pfc.157.1510271435178; Thu, 09 Nov 2017 15:50:35 -0800 (PST) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id t25sm13160477pfh.67.2017.11.09.15.50.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 15:50:34 -0800 (PST) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley Subject: [PATCHv4 2/6] ia64: Add .opd based function descriptor dereference Date: Fri, 10 Nov 2017 08:48:26 +0900 Message-Id: <20171109234830.5067-3-sergey.senozhatsky@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171109234830.5067-1-sergey.senozhatsky@gmail.com> References: <20171109234830.5067-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, Sergey Senozhatsky , linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, Steven Rostedt , 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 | 12 ++++++++++++ arch/ia64/kernel/vmlinux.lds.S | 2 ++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/ia64/include/asm/sections.h b/arch/ia64/include/asm/sections.h index f3481408594e..cea15f2dd38d 100644 --- a/arch/ia64/include/asm/sections.h +++ b/arch/ia64/include/asm/sections.h @@ -27,6 +27,8 @@ extern char __start_gate_brl_fsys_bubble_down_patchlist[], __end_gate_brl_fsys_b extern char __start_unwind[], __end_unwind[]; extern char __start_ivt_text[], __end_ivt_text[]; +#define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1 + #undef dereference_function_descriptor static inline void *dereference_function_descriptor(void *ptr) { @@ -38,6 +40,12 @@ static inline void *dereference_function_descriptor(void *ptr) return ptr; } +#undef dereference_kernel_function_descriptor +static inline void *dereference_kernel_function_descriptor(void *ptr) +{ + if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd) + return ptr; + return dereference_function_descriptor(ptr); +} #endif /* _ASM_IA64_SECTIONS_H */ - diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c index 853b5611a894..326448f9df16 100644 --- a/arch/ia64/kernel/module.c +++ b/arch/ia64/kernel/module.c @@ -36,6 +36,7 @@ #include #include +#include #define ARCH_MODULE_DEBUG 0 @@ -918,3 +919,14 @@ module_arch_cleanup (struct module *mod) if (mod->arch.core_unw_table) unw_remove_unwind_table(mod->arch.core_unw_table); } + +void *dereference_module_function_descriptor(struct module *mod, void *ptr) +{ + Elf64_Shdr *opd = mod->arch.opd; + + if (ptr < (void *)opd->sh_addr || + ptr >= (void *)(opd->sh_addr + opd->sh_size)) + return ptr; + + return dereference_function_descriptor(ptr); +} diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S index 58db59da0bd8..31e688981b4b 100644 --- a/arch/ia64/kernel/vmlinux.lds.S +++ b/arch/ia64/kernel/vmlinux.lds.S @@ -108,7 +108,9 @@ SECTIONS { RODATA .opd : AT(ADDR(.opd) - LOAD_OFFSET) { + __start_opd = .; *(.opd) + __end_opd = .; } /*