From patchwork Sat Sep 30 02:53:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 9979069 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 435386037F for ; Sat, 30 Sep 2017 02:55:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F79297C2 for ; Sat, 30 Sep 2017 02:55:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D94D297CD; Sat, 30 Sep 2017 02:55:27 +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 D0932297C2 for ; Sat, 30 Sep 2017 02:55:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbdI3CyS (ORCPT ); Fri, 29 Sep 2017 22:54:18 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35620 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649AbdI3CyQ (ORCPT ); Fri, 29 Sep 2017 22:54:16 -0400 Received: by mail-pf0-f196.google.com with SMTP id i23so850769pfi.2; Fri, 29 Sep 2017 19:54:15 -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=K+v/0/d6sAf3raDOGxIoPVECJNQChMsKyhodg+/Qr8Q=; b=ePbAldmbj3MkOrs1ZswQuWAp/1UDX5C26MvCj7Yzklww2xrGY8fF8FLyMrV6G+lmRJ 9+WhSIQnCXexIils7nPhTXbvQZa1rflVqTvyxdgQ7CqZlrU7PG/TRimIgmZ2cwtHfVLt KZ1zbQ4wQCNIjDbUFrrUc39SMxtEZ+Gf5/vzpfTlibA5zWxGGHTr/H7R5uIvZeu8VoRr wfZesFgpugL0gHd+9keLz0a/E0AR2RW/Frx15JM9ebutNrUUgoo29ppulboflDW7q/Yf iLe/R8RCsbiPa39ZERqFf3S7Os3YqZGYSSog9ao1JbeZq7MRW78WJ4bJiJyDviKT6weJ SPLA== 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=K+v/0/d6sAf3raDOGxIoPVECJNQChMsKyhodg+/Qr8Q=; b=tOoxF2+ZlcbuqCthEeg10uzQN/QkvD1tHYccUa6hfhUUYDKeob2Ow4KXfNk3wvHNOi p23kpz7kivYFs7g1gELrHZvRmh+j3RZ62onRMLnXjXEZksvmmdn30w8HYN39Pjs85ZNl FSjLaqNpO7CA5Gy6RGPRLkFPGRVuD+lo5WK6XDNI0xx3WQJGz6H6mGB0s8ufvpZM8vWj qFTWKywVMpRa2qgffNZYVtZcL+D+NzCT4eWr6aMhQwT6UKghLlDOcz6XpfN6XStCKAnA +cYxyUzTlj+O+ZSAepZ8Xkz/HtKYizVy37ezZXy+iQ2I0PM2pQ0ZU9XpGE8LKqCnOxUj tqKw== X-Gm-Message-State: AHPjjUgvmsT1XeYTC70hLk0attZq13EYfEqoJUXk72uhgxTslyQvDZ1q 3BckZ0i1aQv7xVz9Q4D3VsI= X-Google-Smtp-Source: AOwi7QA2snFrq1jTdLNyo0A3EVXx2F21jhsCqq4Z1E+9MQ4yGg5cijXWA7tz4lO7SfPPm8I5Lbgsqw== X-Received: by 10.84.194.1 with SMTP id g1mr8848532pld.74.1506740055445; Fri, 29 Sep 2017 19:54:15 -0700 (PDT) Received: from localhost.localdomain ([175.223.27.84]) by smtp.gmail.com with ESMTPSA id b1sm8680714pgn.94.2017.09.29.19.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 19:54:14 -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 3/7] ia64: Add .opd based function descriptor dereference Date: Sat, 30 Sep 2017 11:53:15 +0900 Message-Id: <20170930025319.987-4-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 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 Tested-by: Helge Deller # parisc64 Tested-by: Santosh Sivaraj # powerpc64 Acked-by: Michael Ellerman # powerpc64 Tested-by: Tony Luck # ia64 Reviewed-by: Petr Mladek --- 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 = .; } /*