From patchwork Thu Nov 9 23:48:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 836567 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 3yY0YM5kzvz9sRg for ; Fri, 10 Nov 2017 11:00:55 +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="vNjYcKWm"; 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 3yY0YM4DMYzDrM4 for ; Fri, 10 Nov 2017 11:00:55 +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="vNjYcKWm"; 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="vNjYcKWm"; 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 3yY0Kh28L4zDrKr for ; Fri, 10 Nov 2017 10:50:48 +1100 (AEDT) Received: by mail-pf0-x241.google.com with SMTP id x7so5441407pfa.1 for ; Thu, 09 Nov 2017 15:50:48 -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=BN46O+s3L77gknn0aCxUnu8+0O1IITmhZhbaANaB8vw=; b=vNjYcKWmJyAILH2iBZESL+EaC0SNRBbkUwpKaXnRm74O7loJ53xLLPyPl68GGHYBDn RRQnLEdvv00qTAqA5p4vAo35lY/o8KpBVfdHlA3tZm6L4hzKVbBCTnPHM3Zr0+9/Gz+Q bfbngg8D36jpZ8DIBTbik9LyXd9rot6vCtIMrYVJyhAoBau7AOkIXDbv7xV/u3qqV+Gy md8IWWYqUHd61P/nSZVEUubj3YJaKcYQEsugSD541X4ROLq62rrdeThJn+buhgKS0Pd5 HGJ6uLqBYxB3QBZyX7i1tRyEkQNBIEYfr5M7O/GJBtVKejjjhW2fzo3YoKM7qnW7NMmG pfNQ== 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=BN46O+s3L77gknn0aCxUnu8+0O1IITmhZhbaANaB8vw=; b=jhfJyMaRP2t0P2T9T0D+VRo+2MHj/6sxxnmcBYLCP8T1TjG8vWWTUHRpNubBDMJoK6 NNT2Ii0W6qFFKvZDZinr2MtEm9/xEFU9Mu6cymJlCit0LXv3ikmNeTPccjn1YPYOyFth qjaofSNZTQTrxU3lnyEDDWmFF/vxWG3IiQtale2u5GShXOeJs/6ZO/zY0GHh6PcE/7a6 DfiYMkm6om8CuPzIaOx24qKQeVEuJ0GjvREp7RteDVPJegcm4mMzm5B3rv2ZSHLsAJZD R6OyuDl8ESBdKX3ws5vLMeYgxfzChK9PnqLuNV/SisJwPvjU2OJvOVL670k/1qEB3qN+ s5jw== X-Gm-Message-State: AJaThX5aT6RJvDt0pO3momZ0PXUjlKYamxCVoO513/Ac82HChURdgyRl y14FVXUPn8sbpRee6HnP6oo= X-Google-Smtp-Source: ABhQp+QHjY61nAPUYKPvGsxEWgK1hvnW/PM1tCJe40m3lPBs6QLEt9WdIZ1P4wfZlb+1sKVqKB/t2Q== X-Received: by 10.98.166.148 with SMTP id r20mr2187866pfl.80.1510271446157; Thu, 09 Nov 2017 15:50:46 -0800 (PST) Received: from localhost.localdomain ([121.137.63.184]) by smtp.gmail.com with ESMTPSA id t25sm13160477pfh.67.2017.11.09.15.50.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 15:50:45 -0800 (PST) From: Sergey Senozhatsky To: Tony Luck , Fenghua Yu , Helge Deller , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , James Bottomley Subject: [PATCHv4 4/6] parisc64: Add .opd based function descriptor dereference Date: Fri, 10 Nov 2017 08:48:28 +0900 Message-Id: <20171109234830.5067-5-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 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 | 6 ++++++ arch/parisc/kernel/module.c | 16 ++++++++++++++++ arch/parisc/kernel/process.c | 9 +++++++++ arch/parisc/kernel/vmlinux.lds.S | 2 ++ 5 files changed, 35 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 accdf40aa5b7..5a40b51df80c 100644 --- a/arch/parisc/include/asm/sections.h +++ b/arch/parisc/include/asm/sections.h @@ -6,8 +6,14 @@ #include #ifdef CONFIG_64BIT + +#define HAVE_DEREFERENCE_FUNCTION_DESCRIPTOR 1 + #undef dereference_function_descriptor void *dereference_function_descriptor(void *); + +#undef dereference_kernel_function_descriptor +void *dereference_kernel_function_descriptor(void *); #endif #endif diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c index f1a76935a314..b5b3cb00f1fb 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,18 @@ void module_arch_cleanup(struct module *mod) { deregister_unwind_table(mod); } + +#ifdef CONFIG_64BIT +void *dereference_module_function_descriptor(struct module *mod, void *ptr) +{ + 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 (ptr < (void *)start_opd || ptr >= (void *)end_opd) + return ptr; + + return dereference_function_descriptor(ptr); +} +#endif diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 30f92391a93e..6c4585103a91 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c @@ -276,6 +276,15 @@ void *dereference_function_descriptor(void *ptr) ptr = p; return ptr; } + +void *dereference_kernel_function_descriptor(void *ptr) +{ + if (ptr < (void *)__start_opd || + ptr >= (void *)__end_opd) + return ptr; + + return dereference_function_descriptor(ptr); +} #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 159a2ec0b4e0..da2e31190efa 100644 --- a/arch/parisc/kernel/vmlinux.lds.S +++ b/arch/parisc/kernel/vmlinux.lds.S @@ -100,7 +100,9 @@ SECTIONS . = ALIGN(16); /* Linkage tables */ .opd : { + __start_opd = .; *(.opd) + __end_opd = .; } PROVIDE (__gp = .); .plt : { *(.plt)