From patchwork Mon May 14 17:14:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135743 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2049606lji; Mon, 14 May 2018 10:15:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoqzxXOAfyQPJ/RtfqEMEaGBwwrFqkPFHBU8lJbyyjgqJKUsD3rc31YdByuWhLAE0jp9oG4 X-Received: by 2002:a62:da17:: with SMTP id c23-v6mr11492176pfh.128.1526318133447; Mon, 14 May 2018 10:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318133; cv=none; d=google.com; s=arc-20160816; b=cXrkjWOqupwHF3T6/9LuEyJD2lk4DGJC36Miqr96KtIFBTwUoI8ecno1cHRc1VF9e1 JUqr3O5I72VJoLMaq8nwCtKtInBs49h1TYAR0Dl8ky7NrgEzs0WzFpc5rRtFmDQFIprQ VH5LuEx20gUzAkak/WBtGqNE3OqO48bvRhcW0i45mDHWZRoqgJHtyjJ5OCkAonyZR+xH /IRtncLQljtCIgMooLEMiJdgkWEhCibl7bYQb093ijYnD2/u9asnMsGdUJvy2qaUhI/T viz1/8ITSeAI0ak5ckMvRTIDTVIr0b872DDOAW0MnqHlgHp+TkoHD03rCQ+YFGCjo7Xx dBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=i7kcUAjX4hkCW1ZNZSv8o/lUaBteICz2MEzb1A7dwIA=; b=AuPGVcha2cFvcX32L5YUWSDubyQrG0DzIrMf4f/UVMbzwUjyOZScl3vCSF6Z0rGdNw LEG4b4OLZyFXSXDQ9+WmjJW/OAJYayfJWGEBb2gjPWoXKi2cwiUU1hoaM0GzhchzJdIO EEEWpPjug+N1lKD1tfveYbZV+/mA7GksEntj9kHMydqPJNdtWj7YzwziJS1W044wu5nz iLDzkWtWXRTAJ0QROIVGn5IFPtgQcGY4XQIeZ16UAvWz9/9OkXOEhbqkw0+GYJwwfb2K Dcr9fhgYhAkQLVHBOy66FADZeIDZXHcu//+EbO+F1AJ3YjIdD8d5KUFf1GId2w4TxhSs W+nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si7866340pgp.10.2018.05.14.10.15.33; Mon, 14 May 2018 10:15:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754066AbeENRP3 (ORCPT + 29 others); Mon, 14 May 2018 13:15:29 -0400 Received: from foss.arm.com ([217.140.101.70]:46922 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbeENRPZ (ORCPT ); Mon, 14 May 2018 13:15:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8244D1596; Mon, 14 May 2018 10:15:25 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2789C3F59F; Mon, 14 May 2018 10:15:22 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Andrew Morton , Benjamin Herrenschmidt , Catalin Marinas , Fenghua Yu , "H. Peter Anvin" , Ingo Molnar , Ivan Kokshaysky , James Hogan , Kees Cook , Matt Turner , Michael Ellerman , Paul Mackerras , Ralf Baechle , Richard Henderson , Rich Felker , Thomas Gleixner , Tony Luck , Will Deacon , x86@kernel.org, Yoshinori Sato Subject: [RFC PATCH 01/11] prctl: Support movement of arch prctls out of common code Date: Mon, 14 May 2018 18:14:17 +0100 Message-Id: <1526318067-4964-2-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The core framework for the prctl() syscall is unloved and looking rather crusty these days. It also relies on defining ancillary boilerplate macros for each prctl() in order to control conditional compilation of the different prctl calls. We have better ways to do this now, using Kconfig. This patch defines a new arch hook arch_syscall(). Architectures that implemement arch-specific syscalls can now select HAVE_ARCH_SYSCALL in their Kconfig and define this function appropriately. The core prctl() implementation now matches option against the list of common or legacy prctls, deferring to prctl_arch() if an unrecognised option is encountered. (arch_prctl() would have been a nicer name, but it conflicts with the pre-existing syscall of the same name on x86, particularly in the um code.) No functional change. Signed-off-by: Dave Martin Cc: Andrew Morton Cc: Benjamin Herrenschmidt Cc: Catalin Marinas Cc: Fenghua Yu Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Ivan Kokshaysky Cc: James Hogan Cc: Kees Cook Cc: Matt Turner Cc: Michael Ellerman Cc: Paul Mackerras Cc: Ralf Baechle Cc: Richard Henderson Cc: Rich Felker Cc: Thomas Gleixner Cc: Tony Luck Cc: Will Deacon Cc: x86@kernel.org Cc: Yoshinori Sato --- arch/Kconfig | 3 +++ include/linux/prctl.h | 19 +++++++++++++++++++ include/uapi/linux/prctl.h | 6 +++--- kernel/sys.c | 2 +- tools/include/uapi/linux/prctl.h | 6 +++--- 5 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 include/linux/prctl.h -- 2.1.4 Acked-by: Will Deacon diff --git a/arch/Kconfig b/arch/Kconfig index 8e0d665..b34b3e8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -969,4 +969,7 @@ config REFCOUNT_FULL against various use-after-free conditions that can be used in security flaw exploits. +config HAVE_PRCTL_ARCH + bool + source "kernel/gcov/Kconfig" diff --git a/include/linux/prctl.h b/include/linux/prctl.h new file mode 100644 index 0000000..5ce3713 --- /dev/null +++ b/include/linux/prctl.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_PRCTL_H +#define _LINUX_PRCTL_H + +#include +#include + +#ifdef CONFIG_HAVE_PRCTL_ARCH +extern int prctl_arch(int option, unsigned long arg2, + unsigned long arg3, unsigned long arg4, unsigned long arg5); +#else +static inline int prctl_arch(int option, unsigned long arg2, + unsigned long arg3, unsigned long arg4, unsigned long arg5) +{ + return -EINVAL; +} +#endif + +#endif /* ! _LINUX_PRCTL_H */ diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index af5f8c2..c911ff0 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_PRCTL_H -#define _LINUX_PRCTL_H +#ifndef _UAPI_LINUX_PRCTL_H +#define _UAPI_LINUX_PRCTL_H #include @@ -207,4 +207,4 @@ struct prctl_mm_map { # define PR_SVE_VL_LEN_MASK 0xffff # define PR_SVE_VL_INHERIT (1 << 17) /* inherit across exec */ -#endif /* _LINUX_PRCTL_H */ +#endif /* _UAPI_LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index ad69218..5077f1e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -2451,7 +2451,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, error = SVE_GET_VL(); break; default: - error = -EINVAL; + error = prctl_arch(option, arg2, arg3, arg4, arg5); break; } return error; diff --git a/tools/include/uapi/linux/prctl.h b/tools/include/uapi/linux/prctl.h index af5f8c2..c911ff0 100644 --- a/tools/include/uapi/linux/prctl.h +++ b/tools/include/uapi/linux/prctl.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_PRCTL_H -#define _LINUX_PRCTL_H +#ifndef _UAPI_LINUX_PRCTL_H +#define _UAPI_LINUX_PRCTL_H #include @@ -207,4 +207,4 @@ struct prctl_mm_map { # define PR_SVE_VL_LEN_MASK 0xffff # define PR_SVE_VL_INHERIT (1 << 17) /* inherit across exec */ -#endif /* _LINUX_PRCTL_H */ +#endif /* _UAPI_LINUX_PRCTL_H */ From patchwork Mon May 14 17:14:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135753 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2053998lji; Mon, 14 May 2018 10:19:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrUXMP3DeMNA1G3IEb8FEMnhQJYVpNO/fidZa5xEP/OL1LDebsE3ROXFLxCJAp2nlyamIce X-Received: by 2002:a62:a48:: with SMTP id s69-v6mr11427458pfi.134.1526318377672; Mon, 14 May 2018 10:19:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318377; cv=none; d=google.com; s=arc-20160816; b=vonnhaXm9nkYWorlNC47760UZlY3nnnuI92hZRKksAmMcMOVrNGhfx/9dXxk7wsOQP I88s8nibGRbSof7D3XyW9UOeykDtNuoVEejWb4oRWrHUe0fnS9QCSrLod/LdIf0CLC1j 8dZNVh++RfYyGAVyZnil80W41cmEIJwGwzA2AJkM3JRQWgG0nYCk0VUL7tvVdELto4+0 BU8Np7j3qPiBJPGSOq9mg9GTohehTejfW5KdoVBzqow2PdA3lqS7ptnwENwqVH5iW+AO SpQqVU3Ywp7DGyKyvlSLxj30uQz/29FqHRTiwp+UQEIwASgIAaVn83pbh65hLWglNoem 5Gbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=+bfe/I3v5lg4n6vqdw/d8FttfxrB9tL6F1tvKdrda8I=; b=e1/8tsojFHmKPO2eKKUFj+cQda2/5wdkvO3uJj72aOPxw4IpbW5Egx25EVQX6e4MSn PtJN5pzN5FypyyWPYejHt4hgPvMwUpmw62O4K4oSe/Sco8gK2l7aM8yMWS3cBHywe9su 3vjPYGXn++Lji1rJXk21DIPnomMi1MZ4cQTE2798dUfhszc3aSO+/jwdcCeGsBdP9aD+ A6MfRo/IHPYxOtRdUbnU9pHg7iA/xOi57ujOT70VywEcpf1jhquiRSGmFdDrYM47Bbaw vlqTqmdGao+pmjOy5lwDXrVywPA/uiuR6im2JZIfrXcO8bQW8Hx3wZBQbxfN6jHTOS50 1smw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a90-v6si9693975plc.329.2018.05.14.10.19.37; Mon, 14 May 2018 10:19:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752668AbeENRTe (ORCPT + 29 others); Mon, 14 May 2018 13:19:34 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46948 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753015AbeENRP0 (ORCPT ); Mon, 14 May 2018 13:15:26 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87F15165C; Mon, 14 May 2018 10:15:26 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C11043F59F; Mon, 14 May 2018 10:15:25 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Catalin Marinas , Will Deacon Subject: [RFC PATCH 02/11] arm64: Move arch-specific prctls out of core code Date: Mon, 14 May 2018 18:14:18 +0100 Message-Id: <1526318067-4964-3-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves the arm64-specific prctl call implementations out of core code and removes redundant boilerplate associated with them. No functional change. Signed-off-by: Dave Martin Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/processor.h | 4 ---- arch/arm64/kernel/sys.c | 15 +++++++++++++++ kernel/sys.c | 12 ------------ 4 files changed, 16 insertions(+), 16 deletions(-) -- 2.1.4 Acked-by: Will Deacon diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index eb2cf49..6b706af 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -123,6 +123,7 @@ config ARM64 select HAVE_PERF_EVENTS select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_PRCTL_ARCH select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RCU_TABLE_FREE select HAVE_SYSCALL_TRACEPOINTS diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 7675989..b1d262f 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -244,9 +244,5 @@ void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused); void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused); void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused); -/* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */ -#define SVE_SET_VL(arg) sve_set_current_vl(arg) -#define SVE_GET_VL() sve_get_current_vl() - #endif /* __ASSEMBLY__ */ #endif /* __ASM_PROCESSOR_H */ diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index 72981ba..597ff35 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -22,10 +22,12 @@ #include #include #include +#include #include #include #include #include +#include asmlinkage long sys_mmap(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, @@ -45,6 +47,19 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) return sys_personality(personality); } +int prctl_arch(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + switch (option) { + case PR_SVE_SET_VL: + return sve_set_current_vl(arg2); + case PR_SVE_GET_VL: + return sve_get_current_vl(); + default: + return -EINVAL; + } +} + /* * Wrappers to pass the pt_regs argument. */ diff --git a/kernel/sys.c b/kernel/sys.c index 5077f1e..f917d78 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -113,12 +113,6 @@ #ifndef SET_FP_MODE # define SET_FP_MODE(a,b) (-EINVAL) #endif -#ifndef SVE_SET_VL -# define SVE_SET_VL(a) (-EINVAL) -#endif -#ifndef SVE_GET_VL -# define SVE_GET_VL() (-EINVAL) -#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2444,12 +2438,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, case PR_GET_FP_MODE: error = GET_FP_MODE(me); break; - case PR_SVE_SET_VL: - error = SVE_SET_VL(arg2); - break; - case PR_SVE_GET_VL: - error = SVE_GET_VL(); - break; default: error = prctl_arch(option, arg2, arg3, arg4, arg5); break; From patchwork Mon May 14 17:14:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135751 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2052564lji; Mon, 14 May 2018 10:18:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoYH+0SdzuyknhyGl+B8FfVJy1E5LhccqUQkTu01KCt9ShXdYogTPRVO/wP/smLq5I47Lsr X-Received: by 2002:a17:902:1aa:: with SMTP id b39-v6mr10866364plb.120.1526318297761; Mon, 14 May 2018 10:18:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318297; cv=none; d=google.com; s=arc-20160816; b=VGV+VjGRmJJWplE4Nsb57iPCXeTKDmdQSPrdlQAsaAEbAXTXdKORkaIC1lC7qU9ODN Z8Rtu42NJaRhUDVMl/CGadJepbfvU1bZQa0MWDNt3DMEu4BCIJj7mKG09F3c53sd0mGs mNThF9c/2AOazJrWdXqRRJ8PMI68Ltqzj3+hW9CPRRkkTi7Eg4Va3HL/Y2julT5dfIkU uEJZekaJKtY+eein0gOQTVXxi5+oxeb2Zl0OSBl36Fv8uBaOHX/J8M8xf7wweKf0Vuof EVsjWJScFwy+QGiNe86gjlTNc7CrFsGfqKwFOPd36W9tev1wXLfXULCqI0fuEwXV9666 9JdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=TFXr8k0ZKvqKpvpe1KYTKPuyJbiYtmnUsfU2jgZR8K8=; b=k1Ufzhb4wxqsoh7/GNoFuSkaRRuov7bxZcOtPY5Ep1TrmYg4ERfrzk3CPGDnu5hALe GOzpsYl8zMu9DfIra+Rn9c05UNfu7vWiTvrz3q0NIDty+xnylF/bPNCrJg5GFKbcWp5l 8rz8ICLsZ+6sGVAftUrlRUhkZ+mHp9Da0m2z0izMBa2Ka+NMQY2kLhcz6wF72kSWDONZ ofb84+oT5pDyDQHH/6VfqoN5t0Kb+XioirTn8C42qzSvvodr48fiRYrqTkTIGCDnGRaY 6/vdHrt4cO1auLm4YnwTlBCgKiiPxdiVW4qeqgmgFu3VfNgdizLhwqDcsCp4ZuRvNpS4 pUvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g130-v6si9690780pfc.366.2018.05.14.10.18.17; Mon, 14 May 2018 10:18:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754472AbeENRSP (ORCPT + 29 others); Mon, 14 May 2018 13:18:15 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46952 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753995AbeENRP1 (ORCPT ); Mon, 14 May 2018 13:15:27 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8DD391688; Mon, 14 May 2018 10:15:27 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C70323F59F; Mon, 14 May 2018 10:15:26 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Ralf Baechle , James Hogan Subject: [RFC PATCH 03/11] MIPS: Remove unused task argument from prctl functions Date: Mon, 14 May 2018 18:14:19 +0100 Message-Id: <1526318067-4964-4-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some MIPS-specific prctl backends take a task argument that is redundant, since the only thing ever passed is "current". This patch gets rid of the redundant arguments. No functional change. Signed-off-by: Dave Martin Cc: Ralf Baechle Cc: James Hogan --- arch/mips/include/asm/processor.h | 4 ++-- arch/mips/kernel/process.c | 23 +++++++++++------------ arch/mips/kernel/syscall.c | 1 + kernel/sys.c | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) -- 2.1.4 diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index af34afb..8f06608 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h @@ -420,7 +420,7 @@ extern int mips_get_process_fp_mode(struct task_struct *task); extern int mips_set_process_fp_mode(struct task_struct *task, unsigned int value); -#define GET_FP_MODE(task) mips_get_process_fp_mode(task) -#define SET_FP_MODE(task,value) mips_set_process_fp_mode(task, value) +#define GET_FP_MODE() mips_get_process_fp_mode() +#define SET_FP_MODE(value) mips_set_process_fp_mode(value) #endif /* _ASM_PROCESSOR_H */ diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index b9e9bf6..7db1989 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -679,13 +679,13 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) put_cpu(); } -int mips_get_process_fp_mode(struct task_struct *task) +int mips_get_process_fp_mode(void) { int value = 0; - if (!test_tsk_thread_flag(task, TIF_32BIT_FPREGS)) + if (!test_thread_flag(TIF_32BIT_FPREGS)) value |= PR_FP_MODE_FR; - if (test_tsk_thread_flag(task, TIF_HYBRID_FPREGS)) + if (test_thread_flag(TIF_HYBRID_FPREGS)) value |= PR_FP_MODE_FRE; return value; @@ -699,14 +699,14 @@ static void prepare_for_fp_mode_switch(void *info) lose_fpu(1); } -int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) +int mips_set_process_fp_mode(unsigned int value) { const unsigned int known_bits = PR_FP_MODE_FR | PR_FP_MODE_FRE; struct task_struct *t; int max_users; /* If nothing to change, return right away, successfully. */ - if (value == mips_get_process_fp_mode(task)) + if (value == mips_get_process_fp_mode()) return 0; /* Only accept a mode change if 64-bit FP enabled for o32. */ @@ -736,11 +736,10 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) preempt_disable(); /* Save FP & vector context, then disable FPU & MSA */ - if (task->signal == current->signal) - lose_fpu(1); + lose_fpu(1); /* Prevent any threads from obtaining live FP context */ - atomic_set(&task->mm->context.fp_mode_switching, 1); + atomic_set(¤t->mm->context.fp_mode_switching, 1); smp_mb__after_atomic(); /* @@ -750,7 +749,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) */ if (num_online_cpus() > 1) { /* No need to send an IPI for the local CPU */ - max_users = (task->mm == current->mm) ? 1 : 0; + max_users = (current->mm == current->mm) ? 1 : 0; if (atomic_read(¤t->mm->mm_users) > max_users) smp_call_function(prepare_for_fp_mode_switch, @@ -761,7 +760,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) * There are now no threads of the process with live FP context, so it * is safe to proceed with the FP mode switch. */ - for_each_thread(task, t) { + for_each_thread(current, t) { /* Update desired FP register width */ if (value & PR_FP_MODE_FR) { clear_tsk_thread_flag(t, TIF_32BIT_FPREGS); @@ -778,10 +777,10 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value) } /* Allow threads to use FP again */ - atomic_set(&task->mm->context.fp_mode_switching, 0); + atomic_set(¤t->mm->context.fp_mode_switching, 0); preempt_enable(); - wake_up_var(&task->mm->context.fp_mode_switching); + wake_up_var(¤t->mm->context.fp_mode_switching); return 0; } diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index 69c17b5..15f33f0 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/kernel/sys.c b/kernel/sys.c index f917d78..520d2e8 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -108,10 +108,10 @@ # define MPX_DISABLE_MANAGEMENT() (-EINVAL) #endif #ifndef GET_FP_MODE -# define GET_FP_MODE(a) (-EINVAL) +# define GET_FP_MODE() (-EINVAL) #endif #ifndef SET_FP_MODE -# define SET_FP_MODE(a,b) (-EINVAL) +# define SET_FP_MODE(a) (-EINVAL) #endif /* @@ -2433,10 +2433,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, error = MPX_DISABLE_MANAGEMENT(); break; case PR_SET_FP_MODE: - error = SET_FP_MODE(me, arg2); + error = SET_FP_MODE(arg2); break; case PR_GET_FP_MODE: - error = GET_FP_MODE(me); + error = GET_FP_MODE(); break; default: error = prctl_arch(option, arg2, arg3, arg4, arg5); From patchwork Mon May 14 17:14:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135752 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2053638lji; Mon, 14 May 2018 10:19:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTIsXtiTWj4SITxX8gAPqYJet3l0QewVCFkjHWqoB4mjhSy+eJrzeKNkUYedDFg3CfeQnS X-Received: by 2002:a65:4301:: with SMTP id j1-v6mr9175777pgq.356.1526318356636; Mon, 14 May 2018 10:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318356; cv=none; d=google.com; s=arc-20160816; b=Hhl3MtnBi7UnnBkFGgXGfqfpZmXPsxmAxXS8i8uDnReu41s0aqJ0LHSuZy7WlfoJaS WVmsChfWjfCqaXFtLatNol5KDQ1mebmwmYjjBNaPC3sH/+Qd7xvTS9ZNJSj8bWd+3Q60 FKuuciY9hTGxrs++kfHHMkvI2IvvwNiveek0fllzSFZtuPRAkHuAFV93g3pgIjJ8pPQD T7hxfeNhrh3a2mH1HvH82D8kyMW9qHRrUcecTiK4wIWLO8mPDTk89vC8fPA6EKtuQTet 5CXCXIxCe33Ii1W9QAm3rbtmjUQlsOC9k+7/ixpnSyCrKfoo0Fm9oqA7L9IokWKKoEQQ EHhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=n4HPjnCwYTt/lqOJ8Taw2RpSvSmM3BkbtyHjlBNZSI0=; b=0CcMjsHctwLzotZKpp7f9vwaRzlbuIJTFbTUzECXz4kiyao16paBRE8HMv/KfL0pgM 7mD8aiq/XPbtYs2JSIeMGab8Bidd7MpgFn2qHj/KxYNVY7l/BsiYB4vliKPTGeuabyHw 5/obB3lHhvCUYvWP/gRknYYaO9F/EcHpaL3065fgBqzMI8+KgNn4PH5smlc/xSPt0hZK YHmyIrwZPW1M8HnwBjfhkSCiNirlGbcf3pgvtfzfaG1rwCb8l01vJXVSVEI16tkdHy6v vIlGb8F3iq6w5RlpLHeCHYnAnxszZv22f9VkaK4cFk5EN0AdOzDhBej9dKcl5771stYS lzBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba9-v6si10065590plb.110.2018.05.14.10.19.16; Mon, 14 May 2018 10:19:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754452AbeENRSO (ORCPT + 29 others); Mon, 14 May 2018 13:18:14 -0400 Received: from foss.arm.com ([217.140.101.70]:46960 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754004AbeENRP2 (ORCPT ); Mon, 14 May 2018 13:15:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 93DDC165C; Mon, 14 May 2018 10:15:28 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CCF413F59F; Mon, 14 May 2018 10:15:27 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Ralf Baechle , James Hogan Subject: [RFC PATCH 04/11] MIPS: Move arch-specific prctls out of core code Date: Mon, 14 May 2018 18:14:20 +0100 Message-Id: <1526318067-4964-5-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves the MIPS-specific prctl call implementations out of core code and removes redundant boilerplate associated with them. No functional change. Signed-off-by: Dave Martin Cc: Ralf Baechle Cc: James Hogan --- arch/mips/Kconfig | 1 + arch/mips/include/asm/processor.h | 3 --- arch/mips/kernel/syscall.c | 14 ++++++++++++++ kernel/sys.c | 12 ------------ 4 files changed, 15 insertions(+), 15 deletions(-) -- 2.1.4 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 225c95d..99eb2ef 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -61,6 +61,7 @@ config MIPS select HAVE_NMI select HAVE_OPROFILE select HAVE_PERF_EVENTS + select HAVE_PRCTL_ARCH select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index 8f06608..4a8079a 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h @@ -420,7 +420,4 @@ extern int mips_get_process_fp_mode(struct task_struct *task); extern int mips_set_process_fp_mode(struct task_struct *task, unsigned int value); -#define GET_FP_MODE() mips_get_process_fp_mode() -#define SET_FP_MODE(value) mips_set_process_fp_mode(value) - #endif /* _ASM_PROCESSOR_H */ diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c index 15f33f0..aa8157c 100644 --- a/arch/mips/kernel/syscall.c +++ b/arch/mips/kernel/syscall.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -237,6 +238,19 @@ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op) return -ENOSYS; } +int prctl_arch(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + switch (option) { + case PR_SET_FP_MODE: + return mips_set_process_fp_mode(arg2); + case PR_GET_FP_MODE: + return mips_get_process_fp_mode(); + default: + return -EINVAL; + } +} + /* * If we ever come here the user sp is bad. Zap the process right away. * Due to the bad stack signaling wouldn't work. diff --git a/kernel/sys.c b/kernel/sys.c index 520d2e8..63228e7 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -107,12 +107,6 @@ #ifndef MPX_DISABLE_MANAGEMENT # define MPX_DISABLE_MANAGEMENT() (-EINVAL) #endif -#ifndef GET_FP_MODE -# define GET_FP_MODE() (-EINVAL) -#endif -#ifndef SET_FP_MODE -# define SET_FP_MODE(a) (-EINVAL) -#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2432,12 +2426,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, return -EINVAL; error = MPX_DISABLE_MANAGEMENT(); break; - case PR_SET_FP_MODE: - error = SET_FP_MODE(arg2); - break; - case PR_GET_FP_MODE: - error = GET_FP_MODE(); - break; default: error = prctl_arch(option, arg2, arg3, arg4, arg5); break; From patchwork Mon May 14 17:14:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135744 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2049660lji; Mon, 14 May 2018 10:15:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrJR9XXc7sJ5FYLT2RdXUDHBdFkPzjRvdHm0L0Af4NlLFBP8KR1lFVhtTPxh2+S86HWDQBb X-Received: by 2002:a62:3f81:: with SMTP id z1-v6mr11403075pfj.216.1526318135522; Mon, 14 May 2018 10:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318135; cv=none; d=google.com; s=arc-20160816; b=S5O+NxZR/jEZIGdhdJSp8MUUzZjUdZDeg1j4/3MD+kDDHDIcMu0cIfvrMXZrkbzYnx GK2mW/E65u9yVQKgMlZFY/ECk3i7QeUEK3YGuejupusS7K9eBoS612soZIZ0dhFmUzXl LGp6Q5mn1RHn64qzyQA5W6yz8KuQYCpTPVptguWVv4OP8SNgr9uEyEiZYCy6KcMX3mlL ojSfHhlo34hK66uSF+CNAmgp0KXbGdeLaePFUtQZaRg1Xy+Isxmq1S9/M+QjY/0b5e2Y ZlJC2yKbZtjLMssCR3DY5+C3VdZawS43uzlUjmiJm9XL63kj1MOA0Bn2HCjMun0oxenC 32xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=/PQRwvAf6Q5S8qoEebt9jBSK2dTdG98XrTjHAUS5SPI=; b=aJJF0BrOIlSbT7bH9EDiTcVTWc+E40we85ohaYgKSmGZxCEzzErxdYp9vK7xnPhVcV KpV1E1GerbBcGtATb0OErmAJQnTl0PSc0Q0FfrEY1frBlfffQb8tVJhsVRjr2M/UdtVa CiN7rDTTxDIOxpgUPNcE2jXy3GJFsOazoygm30+c0ECI/qartP0YZHlWAnEWAaN35lKT 8N/0EDITQz3dFZijgMVOL0SJXihP4tFDumW858klcEa0RkTVOOesdGlaJFbZ5lTp9HzW tA2odvWnbOIonQx5G7TRU74w1GUlp2wlsXdEFmyCL+sFP6YK8mQ4y8ohv7YiZIjlYZvR PH2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1-v6si7866340pgp.10.2018.05.14.10.15.35; Mon, 14 May 2018 10:15:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbeENRPc (ORCPT + 29 others); Mon, 14 May 2018 13:15:32 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46972 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbeENRPa (ORCPT ); Mon, 14 May 2018 13:15:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0EF8169F; Mon, 14 May 2018 10:15:29 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D34D83F59F; Mon, 14 May 2018 10:15:28 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Subject: [RFC PATCH 05/11] x86: Move arch-specific prctls out of core code Date: Mon, 14 May 2018 18:14:21 +0100 Message-Id: <1526318067-4964-6-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves the x86-specific prctl call implementations out of core code and removes redundant boilerplate associated with them. No functional change. Signed-off-by: Dave Martin Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org --- arch/x86/Kconfig | 1 + arch/x86/include/asm/processor.h | 6 ------ arch/x86/kernel/Makefile | 1 + arch/x86/kernel/sys.c | 26 ++++++++++++++++++++++++++ kernel/sys.c | 28 ---------------------------- 5 files changed, 28 insertions(+), 34 deletions(-) create mode 100644 arch/x86/kernel/sys.c -- 2.1.4 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index c07f492..7bae36a 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -176,6 +176,7 @@ config X86 select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_PRCTL_ARCH select HAVE_RCU_TABLE_FREE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if X86_64 && UNWINDER_FRAME_POINTER && STACK_VALIDATION diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 21a1149..0ecdda4 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -924,18 +924,12 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip, #define KSTK_EIP(task) (task_pt_regs(task)->ip) /* Get/set a process' ability to use the timestamp counter instruction */ -#define GET_TSC_CTL(adr) get_tsc_mode((adr)) -#define SET_TSC_CTL(val) set_tsc_mode((val)) - extern int get_tsc_mode(unsigned long adr); extern int set_tsc_mode(unsigned int val); DECLARE_PER_CPU(u64, msr_misc_features_shadow); /* Register/unregister a process' MPX related resource */ -#define MPX_ENABLE_MANAGEMENT() mpx_enable_management() -#define MPX_DISABLE_MANAGEMENT() mpx_disable_management() - #ifdef CONFIG_X86_INTEL_MPX extern int mpx_enable_management(void); extern int mpx_disable_management(void); diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 02d6f5c..636e40d 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile @@ -52,6 +52,7 @@ obj-$(CONFIG_MODIFY_LDT_SYSCALL) += ldt.o obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o obj-$(CONFIG_IRQ_WORK) += irq_work.o obj-y += probe_roms.o +obj-y += sys.o obj-$(CONFIG_X86_64) += sys_x86_64.o obj-$(CONFIG_X86_ESPFIX64) += espfix_64.o obj-$(CONFIG_SYSFS) += ksysfs.o diff --git a/arch/x86/kernel/sys.c b/arch/x86/kernel/sys.c new file mode 100644 index 0000000..3be4d16 --- /dev/null +++ b/arch/x86/kernel/sys.c @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include + +int prctl_arch(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + switch (option) { + case PR_GET_TSC: + return get_tsc_mode(arg2); + case PR_SET_TSC: + return set_tsc_mode(arg2); + case PR_MPX_ENABLE_MANAGEMENT: + if (arg2 || arg3 || arg4 || arg5) + return -EINVAL; + return mpx_enable_management(); + case PR_MPX_DISABLE_MANAGEMENT: + if (arg2 || arg3 || arg4 || arg5) + return -EINVAL; + return mpx_disable_management(); + default: + return -EINVAL; + } +} diff --git a/kernel/sys.c b/kernel/sys.c index 63228e7..994b5711 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -95,18 +95,6 @@ #ifndef SET_ENDIAN # define SET_ENDIAN(a, b) (-EINVAL) #endif -#ifndef GET_TSC_CTL -# define GET_TSC_CTL(a) (-EINVAL) -#endif -#ifndef SET_TSC_CTL -# define SET_TSC_CTL(a) (-EINVAL) -#endif -#ifndef MPX_ENABLE_MANAGEMENT -# define MPX_ENABLE_MANAGEMENT() (-EINVAL) -#endif -#ifndef MPX_DISABLE_MANAGEMENT -# define MPX_DISABLE_MANAGEMENT() (-EINVAL) -#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2314,12 +2302,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, case PR_SET_SECCOMP: error = prctl_set_seccomp(arg2, (char __user *)arg3); break; - case PR_GET_TSC: - error = GET_TSC_CTL(arg2); - break; - case PR_SET_TSC: - error = SET_TSC_CTL(arg2); - break; case PR_TASK_PERF_EVENTS_DISABLE: error = perf_event_task_disable(); break; @@ -2416,16 +2398,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, clear_bit(MMF_DISABLE_THP, &me->mm->flags); up_write(&me->mm->mmap_sem); break; - case PR_MPX_ENABLE_MANAGEMENT: - if (arg2 || arg3 || arg4 || arg5) - return -EINVAL; - error = MPX_ENABLE_MANAGEMENT(); - break; - case PR_MPX_DISABLE_MANAGEMENT: - if (arg2 || arg3 || arg4 || arg5) - return -EINVAL; - error = MPX_DISABLE_MANAGEMENT(); - break; default: error = prctl_arch(option, arg2, arg3, arg4, arg5); break; From patchwork Mon May 14 17:14:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135750 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2052267lji; Mon, 14 May 2018 10:18:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrgFD+dr9C12jCDAZREmekN081BWfZVgaCNGJQUd5h8XT+nmnugwyqdHN0jejG8NyB50vMf X-Received: by 2002:a63:6945:: with SMTP id e66-v6mr9264905pgc.306.1526318281828; Mon, 14 May 2018 10:18:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318281; cv=none; d=google.com; s=arc-20160816; b=ysJKRsfPY9q+J7ZSWRONBnQN1fy6OshWGSeb9um+ZrypPnz1LoMmj9I4evzLmbUN5u F5YErV8QxLRx8phSr/Im2hgnegS0zDE+mliPJUV61d52PLIrSLYQgxDobdUb3DPs3H99 C+Tn61fCF1017qcJC5+fqI7O+25LMZOkxmWGSMnWGM7GyAc565opZaI5zvNSWdQlnSvH 02KCLE5QIGVdzYqKNvBFGdTdMw8h0gNNislkTdwKwjm8uEOluzXHR/Gow8bb8jegvL+I ACNGsvC8MuHT1LdtIDINKZOvLZ4cTpy6aZ+O7z/x/z5UG29l0bMA1CzrmVF2pQ1ycOAC ysEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=PHngfP9eriLpTGm3sS12Vaa3vwsW2kPmRa6YFhSizqU=; b=vgJMItPxIQ4zhIQClkQhg8uszVoVOUPrpjNvDo+ybpBWMNc59CAh/VpsatP2oW4hpG 7s191gp7HmJezDPGI139hgwmeKeXGmokzNZ69MmApyhODwZUNWRTmkE4DvpTOMg6LtSj GEF1bRlKrQzhLNyVBAzC2DJlmxl5XfvHZlZixK0nNvlymbk94a+NSvLNk1dX2CC5cGg8 kaW4chIUAD+pwsbaNj2uWS5x3YU/Nnu5Ht2P6mZLuTnl6prwt0Z1htUnH+hPMKbeDan/ PCLfJf0bFo3ahCf4oUesWJalro9N6v2BK7Tv93K9r0IdlMiIqZu/4H3DcT9Fhe5ryHcK KoVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g130-v6si9690780pfc.366.2018.05.14.10.18.01; Mon, 14 May 2018 10:18:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754437AbeENRR5 (ORCPT + 29 others); Mon, 14 May 2018 13:17:57 -0400 Received: from foss.arm.com ([217.140.101.70]:46980 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbeENRPb (ORCPT ); Mon, 14 May 2018 13:15:31 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1654516BA; Mon, 14 May 2018 10:15:31 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2BE1D3F59F; Mon, 14 May 2018 10:15:30 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: [RFC PATCH 06/11] powerpc: Remove unused task argument from prctl functions Date: Mon, 14 May 2018 18:14:22 +0100 Message-Id: <1526318067-4964-7-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some powerpc-specific prctl backends take a task argument that is redundant, since the only thing ever passed is "current". This patch gets rid of the redundant arguments. No functional change. Signed-off-by: Dave Martin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman --- arch/powerpc/include/asm/processor.h | 16 ++++++++-------- arch/powerpc/kernel/process.c | 30 +++++++++++++++--------------- kernel/sys.c | 12 ++++++------ 3 files changed, 29 insertions(+), 29 deletions(-) -- 2.1.4 Acked-by: Michael Ellerman diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index c4b36a4..313dec1 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -407,17 +407,17 @@ unsigned long get_wchan(struct task_struct *p); #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) /* Get/set floating-point exception mode */ -#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr)) -#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val)) +#define GET_FPEXC_CTL(adr) get_fpexc_mode((adr)) +#define SET_FPEXC_CTL(val) set_fpexc_mode((val)) -extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr); -extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val); +extern int get_fpexc_mode(unsigned long adr); +extern int set_fpexc_mode(unsigned int val); -#define GET_ENDIAN(tsk, adr) get_endian((tsk), (adr)) -#define SET_ENDIAN(tsk, val) set_endian((tsk), (val)) +#define GET_ENDIAN(adr) get_endian((adr)) +#define SET_ENDIAN(val) set_endian((val)) -extern int get_endian(struct task_struct *tsk, unsigned long adr); -extern int set_endian(struct task_struct *tsk, unsigned int val); +extern int get_endian(unsigned long adr); +extern int set_endian(unsigned int val); #define GET_UNALIGN_CTL(tsk, adr) get_unalign_ctl((tsk), (adr)) #define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val)) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 1237f13..0fcb2f5 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -1896,9 +1896,9 @@ EXPORT_SYMBOL(start_thread); #define PR_FP_ALL_EXCEPT (PR_FP_EXC_DIV | PR_FP_EXC_OVF | PR_FP_EXC_UND \ | PR_FP_EXC_RES | PR_FP_EXC_INV) -int set_fpexc_mode(struct task_struct *tsk, unsigned int val) +int set_fpexc_mode(unsigned int val) { - struct pt_regs *regs = tsk->thread.regs; + struct pt_regs *regs = current->thread.regs; /* This is a bit hairy. If we are an SPE enabled processor * (have embedded fp) we store the IEEE exception enable flags in @@ -1919,8 +1919,8 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val) * anyway to restore the prctl settings from * the saved environment. */ - tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR); - tsk->thread.fpexc_mode = val & + current->thread.spefscr_last = mfspr(SPRN_SPEFSCR); + current->thread.fpexc_mode = val & (PR_FP_EXC_SW_ENABLE | PR_FP_ALL_EXCEPT); return 0; } else { @@ -1938,18 +1938,18 @@ int set_fpexc_mode(struct task_struct *tsk, unsigned int val) * them does not change anything */ if (val > PR_FP_EXC_PRECISE) return -EINVAL; - tsk->thread.fpexc_mode = __pack_fe01(val); + current->thread.fpexc_mode = __pack_fe01(val); if (regs != NULL && (regs->msr & MSR_FP) != 0) regs->msr = (regs->msr & ~(MSR_FE0|MSR_FE1)) - | tsk->thread.fpexc_mode; + | current->thread.fpexc_mode; return 0; } -int get_fpexc_mode(struct task_struct *tsk, unsigned long adr) +int get_fpexc_mode(unsigned long adr) { unsigned int val; - if (tsk->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE) + if (current->thread.fpexc_mode & PR_FP_EXC_SW_ENABLE) #ifdef CONFIG_SPE if (cpu_has_feature(CPU_FTR_SPE)) { /* @@ -1964,21 +1964,21 @@ int get_fpexc_mode(struct task_struct *tsk, unsigned long adr) * anyway to restore the prctl settings from * the saved environment. */ - tsk->thread.spefscr_last = mfspr(SPRN_SPEFSCR); - val = tsk->thread.fpexc_mode; + current->thread.spefscr_last = mfspr(SPRN_SPEFSCR); + val = current->thread.fpexc_mode; } else return -EINVAL; #else return -EINVAL; #endif else - val = __unpack_fe01(tsk->thread.fpexc_mode); + val = __unpack_fe01(current->thread.fpexc_mode); return put_user(val, (unsigned int __user *) adr); } -int set_endian(struct task_struct *tsk, unsigned int val) +int set_endian(unsigned int val) { - struct pt_regs *regs = tsk->thread.regs; + struct pt_regs *regs = current->thread.regs; if ((val == PR_ENDIAN_LITTLE && !cpu_has_feature(CPU_FTR_REAL_LE)) || (val == PR_ENDIAN_PPC_LITTLE && !cpu_has_feature(CPU_FTR_PPC_LE))) @@ -1997,9 +1997,9 @@ int set_endian(struct task_struct *tsk, unsigned int val) return 0; } -int get_endian(struct task_struct *tsk, unsigned long adr) +int get_endian(unsigned long adr) { - struct pt_regs *regs = tsk->thread.regs; + struct pt_regs *regs = current->thread.regs; unsigned int val; if (!cpu_has_feature(CPU_FTR_PPC_LE) && diff --git a/kernel/sys.c b/kernel/sys.c index 994b5711..44e1c47 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -90,10 +90,10 @@ # define GET_FPEXC_CTL(a, b) (-EINVAL) #endif #ifndef GET_ENDIAN -# define GET_ENDIAN(a, b) (-EINVAL) +# define GET_ENDIAN(b) (-EINVAL) #endif #ifndef SET_ENDIAN -# define SET_ENDIAN(a, b) (-EINVAL) +# define SET_ENDIAN(b) (-EINVAL) #endif /* @@ -2265,10 +2265,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, error = GET_FPEMU_CTL(me, arg2); break; case PR_SET_FPEXC: - error = SET_FPEXC_CTL(me, arg2); + error = SET_FPEXC_CTL(arg2); break; case PR_GET_FPEXC: - error = GET_FPEXC_CTL(me, arg2); + error = GET_FPEXC_CTL(arg2); break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL; @@ -2291,10 +2291,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, return -EFAULT; break; case PR_GET_ENDIAN: - error = GET_ENDIAN(me, arg2); + error = GET_ENDIAN(arg2); break; case PR_SET_ENDIAN: - error = SET_ENDIAN(me, arg2); + error = SET_ENDIAN(arg2); break; case PR_GET_SECCOMP: error = prctl_get_seccomp(); From patchwork Mon May 14 17:14:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135745 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2049701lji; Mon, 14 May 2018 10:15:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxBlkdUXJARwrlk7jfllIUhkCkrN652d+oWdb/YbVGyiItN3m3NBVD5NcDWc0p0Nvi9bqi X-Received: by 2002:a17:902:7d8a:: with SMTP id a10-v6mr10664930plm.317.1526318138293; Mon, 14 May 2018 10:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318138; cv=none; d=google.com; s=arc-20160816; b=01QU8TLJKJdZIFsL/VgpcYQjPZOOqyL+Yj79i2WrBH7OBkVKmm9lqHYRVwTt9jJF4m VR2K4L55MAkl0v1hl8iiE/IzYvtauwKRHs68w7lGKpoyR1M6FZIbX18KaBiY0sY0IBBn 0ux96EAMWq563FC3Wwre4XMJORHNl3RVP8Tr/UXl03ITuTop7xPtjCrR1Q9nRXFbCBTo t8ptnyTo076rJe8fklsdmLxPwBeKehMPHJdbkgjDWjWvpG5IXZmnzn+sPBEQ3Tm5ALWp 80PXR8E2Yl+TDrqWAmwFeUutQbbHsE1Vrpxj1S76yP6J6WaJINSKgvEROdXa1XD6/kBZ PTwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1uyoZ6LVFVTjMU95I1EPVd6t5TZan6i3pI+UIACUj4M=; b=D4nP4wleUvlP0R7lxZ6GUbGceL4LxqVFLfqF50pS1qf38LrVlsjMa3Bbfl88ZYky+v w14se6QK6v/QGjhmSyMbuAqbhk8WDZFo26zrPyEplNkLCqyp2xV0nX/y8zZyFa9xe9ra BkloK/Xfe+XSeQYNyUALTZowxh8n2ApofOnBWp+aRletdECROQjt/x6IfsERIGJ4/YCC LP9payfhyxK78Z2Zz48kRsvYWqu14zmiEVuAwP/+9n1l/vebfgBqeMUWW6geOH/io+wk zlGeSHaL1vOWbD5b9VyBniZhMAjT8gw4Wd20Svge+5SFhGdQuT6Zj5Ik1sy4ZB4O4/Vb JDLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si10028099plv.323.2018.05.14.10.15.38; Mon, 14 May 2018 10:15:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932242AbeENRPg (ORCPT + 29 others); Mon, 14 May 2018 13:15:36 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46990 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752856AbeENRPc (ORCPT ); Mon, 14 May 2018 13:15:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3FDA016EA; Mon, 14 May 2018 10:15:32 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 559F23F59F; Mon, 14 May 2018 10:15:31 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Subject: [RFC PATCH 07/11] powerpc: Move arch-specific prctls out of core code Date: Mon, 14 May 2018 18:14:23 +0100 Message-Id: <1526318067-4964-8-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves the powerpc-specific prctl call implementations out of core code and removes redundant boilerplate associated with them. No functional change. Signed-off-by: Dave Martin Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman --- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/processor.h | 6 ------ arch/powerpc/kernel/syscalls.c | 17 +++++++++++++++++ kernel/sys.c | 24 ------------------------ 4 files changed, 18 insertions(+), 30 deletions(-) -- 2.1.4 Acked-by: Michael Ellerman diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index c32a181..b94323e 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -218,6 +218,7 @@ config PPC select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH select HAVE_PERF_REGS select HAVE_PERF_USER_STACK_DUMP + select HAVE_PRCTL_ARCH select HAVE_RCU_TABLE_FREE if SMP select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_SYSCALL_TRACEPOINTS diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index 313dec1..e1cd7ec 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -407,15 +407,9 @@ unsigned long get_wchan(struct task_struct *p); #define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0) /* Get/set floating-point exception mode */ -#define GET_FPEXC_CTL(adr) get_fpexc_mode((adr)) -#define SET_FPEXC_CTL(val) set_fpexc_mode((val)) - extern int get_fpexc_mode(unsigned long adr); extern int set_fpexc_mode(unsigned int val); -#define GET_ENDIAN(adr) get_endian((adr)) -#define SET_ENDIAN(val) set_endian((val)) - extern int get_endian(unsigned long adr); extern int set_endian(unsigned int val); diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c index 4662165..0d6a914 100644 --- a/arch/powerpc/kernel/syscalls.c +++ b/arch/powerpc/kernel/syscalls.c @@ -139,3 +139,20 @@ long sys_switch_endian(void) return 0; } + +int prctl_arch(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + switch (option) { + case PR_SET_FPEXC: + return set_fpexc_mode(arg2); + case PR_GET_FPEXC: + return get_fpexc_mode(arg2); + case PR_GET_ENDIAN: + return get_endian(arg2); + case PR_SET_ENDIAN: + return set_endian(arg2); + default: + return -EINVAL; + } +} diff --git a/kernel/sys.c b/kernel/sys.c index 44e1c47..b154561 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -83,18 +83,6 @@ #ifndef GET_FPEMU_CTL # define GET_FPEMU_CTL(a, b) (-EINVAL) #endif -#ifndef SET_FPEXC_CTL -# define SET_FPEXC_CTL(a, b) (-EINVAL) -#endif -#ifndef GET_FPEXC_CTL -# define GET_FPEXC_CTL(a, b) (-EINVAL) -#endif -#ifndef GET_ENDIAN -# define GET_ENDIAN(b) (-EINVAL) -#endif -#ifndef SET_ENDIAN -# define SET_ENDIAN(b) (-EINVAL) -#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2264,12 +2252,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, case PR_GET_FPEMU: error = GET_FPEMU_CTL(me, arg2); break; - case PR_SET_FPEXC: - error = SET_FPEXC_CTL(arg2); - break; - case PR_GET_FPEXC: - error = GET_FPEXC_CTL(arg2); - break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL; break; @@ -2290,12 +2272,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, if (copy_to_user((char __user *)arg2, comm, sizeof(comm))) return -EFAULT; break; - case PR_GET_ENDIAN: - error = GET_ENDIAN(arg2); - break; - case PR_SET_ENDIAN: - error = SET_ENDIAN(arg2); - break; case PR_GET_SECCOMP: error = prctl_get_seccomp(); break; From patchwork Mon May 14 17:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135746 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2049773lji; Mon, 14 May 2018 10:15:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrrYkJBncMWgUGvigcV5hGMrmAOBjqEYXqp6OKTrUfBgOkAk0lhfLRpYibIclNL8xhux0yS X-Received: by 2002:a62:1f03:: with SMTP id f3-v6mr11431225pff.213.1526318142837; Mon, 14 May 2018 10:15:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318142; cv=none; d=google.com; s=arc-20160816; b=HhNCbTFs9BIbiSLrlclACriI/ukMh4kf7CppIEd0w9Qp88E5JSxsaPWyEt1owXDIKG pIkvQKe2wMEMki0CpTLtbvSrRRhhDgcnXPpubRrx9b2R5kBz0lSq/sJ8ZyAV3NpY1u/Y EQ4V2SiccR+T0srGx9SNnnm7SjboYJRv70uZxpK16gZZ8E+Ijvj+vtd5ZyVnKaZtphJF Jr12g/3BwlOqUHDAIfRlbFauYZu827C5MwUNgIgF/5aWLXwBpYqXgCpPe1czksBcjlN2 cZCsoAuKahS92nQDGHrklePDdWyUDgOxoFRR4ThREw8ToKNySmIA/XFsZrdGEg/qTQHu MsKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KbNJaEQfFOc7ZgCLqtubU4MX3auzLPAFZgWrCo2576g=; b=TWvM7XV5/E/Sqfnn3PKqqSXvGB18edAR63n/sN4sZXcSzHSYljZ+a8/HvYMx1YhW8h sJYlH4UY3vHB1W1SOCFZrSAkktKS8T5W8VXDpCDZO49o82rdsiW3L048m4JK395tX0ow jt2Uv+2xlU3pU9IOcYqXOBHv0P4I2OGgw7hRjIp2G80EOF7o8PdTIpDs+99CS9pqs1P4 EBAzoAUK6C0oTNKTxH3xk62nkEROFgY9XsS2UQumjvW4qJKs7HyQdOU3pyTJk5Lb2j0r Wvi4X3WT3ZrPjwJT4T0p7b64zKZGQUKgik+bDVMcwMnsE0NnugMKYqxv29eGjmqteLYF UUPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17-v6si10028329plq.115.2018.05.14.10.15.42; Mon, 14 May 2018 10:15:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754183AbeENRPh (ORCPT + 29 others); Mon, 14 May 2018 13:15:37 -0400 Received: from foss.arm.com ([217.140.101.70]:47000 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754143AbeENRPd (ORCPT ); Mon, 14 May 2018 13:15:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 460A61713; Mon, 14 May 2018 10:15:33 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7F0F43F59F; Mon, 14 May 2018 10:15:32 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Tony Luck , Fenghua Yu Subject: [RFC PATCH 08/11] ia64: Remove unused task argument from prctl functions Date: Mon, 14 May 2018 18:14:24 +0100 Message-Id: <1526318067-4964-9-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some ia64-specific prctl backends take a task argument that is redundant, since the only thing ever passed is "current". This patch gets rid of the redundant arguments. No functional change. Signed-off-by: Dave Martin Cc: Tony Luck Cc: Fenghua Yu --- arch/ia64/include/asm/processor.h | 8 ++++---- kernel/sys.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) -- 2.1.4 diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h index 10061ccf..0489b80 100644 --- a/arch/ia64/include/asm/processor.h +++ b/arch/ia64/include/asm/processor.h @@ -259,15 +259,15 @@ typedef struct { (int __user *) (addr)); \ }) -#define SET_FPEMU_CTL(task,value) \ +#define SET_FPEMU_CTL(value) \ ({ \ - (task)->thread.flags = (((task)->thread.flags & ~IA64_THREAD_FPEMU_MASK) \ + current->thread.flags = ((current->thread.flags & ~IA64_THREAD_FPEMU_MASK) \ | (((value) << IA64_THREAD_FPEMU_SHIFT) & IA64_THREAD_FPEMU_MASK)); \ 0; \ }) -#define GET_FPEMU_CTL(task,addr) \ +#define GET_FPEMU_CTL(addr) \ ({ \ - put_user(((task)->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT, \ + put_user((current->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT, \ (int __user *) (addr)); \ }) diff --git a/kernel/sys.c b/kernel/sys.c index b154561..5549505 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -78,10 +78,10 @@ # define GET_UNALIGN_CTL(a, b) (-EINVAL) #endif #ifndef SET_FPEMU_CTL -# define SET_FPEMU_CTL(a, b) (-EINVAL) +# define SET_FPEMU_CTL(a) (-EINVAL) #endif #ifndef GET_FPEMU_CTL -# define GET_FPEMU_CTL(a, b) (-EINVAL) +# define GET_FPEMU_CTL(a) (-EINVAL) #endif /* @@ -2247,10 +2247,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, error = GET_UNALIGN_CTL(me, arg2); break; case PR_SET_FPEMU: - error = SET_FPEMU_CTL(me, arg2); + error = SET_FPEMU_CTL(arg2); break; case PR_GET_FPEMU: - error = GET_FPEMU_CTL(me, arg2); + error = GET_FPEMU_CTL(arg2); break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL; From patchwork Mon May 14 17:14:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135749 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2051118lji; Mon, 14 May 2018 10:16:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcHij/jAk2cC2sJWp2sJEPWS/XxgJL2bGlBTguGyQMSog43bLIt1f+86U04tWgA/iqdKX3 X-Received: by 2002:a17:902:6bc7:: with SMTP id m7-v6mr10504875plt.162.1526318214258; Mon, 14 May 2018 10:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318214; cv=none; d=google.com; s=arc-20160816; b=pPEZL9KiN+3IsnImZ3DY8fkGgM0yEpdhLxzDnvBCkIOwbqB8wBhgVDPovuvKgacEpX az34D2ebb7UhKzM9rqPE2xOo0aCjHPyNavQNJ1LZNdiSEDXB4+2dy4HO1pAi0iQMpGOk 2sCNaUxIIRYNfvoqx9JbHKNAoAzdW5cNrdRD8n6QUa7hmHVI82X2ygDWMxTunEukWrB5 OdTQIoJl6KqOal07B+O9NX2ERbzFdxGkhjJbUhBxsWcvuuQxWD30UPUtJFYEQVT5NeYf ky0L+h3EdCAS6Ro8yfxGk+mOrDuxqxQbxL6c31SNCem4qFcE3UBurKBZcPeo02jCMEFV JRyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=hXYABfY3tdiVegfc4bwFWHac0W0TBU0+H40kOFnAZA0=; b=AGCpX3qK9TukRhGI54wiRFjJODdlIFMzKtLd7Q1fUeUcMrxYmk0wsctP5ITz+wWrZ/ iexeJ7RNqr7ETu6k/AIc5eOg32WNiBZPymEeLux6u/fLPdH3gMU+HkytjmbKuZds3oBD 7yCRTnI4tZ0I63whvd8HCnMUQLTKL3KQjwzi3mlC/Mi2P7yulA2Aflj5amqsUWzHCQBc YEovsihKTZOXGMAjgu8/pKa4cMBY6V45x8cTfRsFDPXt/HgzOXIV6C5J5fxZT6+SMQdn Us7KqbX4HkTQyHqHoQVNIwLARbgzf3hpwXoNary58XAR+61RDEp+hV5gDTPRi6MmUBXD X4Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16-v6si6001933pli.53.2018.05.14.10.16.53; Mon, 14 May 2018 10:16:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754355AbeENRQv (ORCPT + 29 others); Mon, 14 May 2018 13:16:51 -0400 Received: from foss.arm.com ([217.140.101.70]:47006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754145AbeENRPe (ORCPT ); Mon, 14 May 2018 13:15:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4BFA61688; Mon, 14 May 2018 10:15:34 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 851953F59F; Mon, 14 May 2018 10:15:33 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Tony Luck , Fenghua Yu Subject: [RFC PATCH 09/11] ia64: Move arch-specific prctls out of core code Date: Mon, 14 May 2018 18:14:25 +0100 Message-Id: <1526318067-4964-10-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch moves the ia64-specific prctl call implementations out of core code and removes redundant boilerplate associated with them. No functional change. Signed-off-by: Dave Martin Cc: Tony Luck Cc: Fenghua Yu --- arch/ia64/Kconfig | 1 + arch/ia64/include/asm/processor.h | 12 ------------ arch/ia64/kernel/sys_ia64.c | 22 ++++++++++++++++++++++ kernel/sys.c | 12 ------------ 4 files changed, 23 insertions(+), 24 deletions(-) -- 2.1.4 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index bbe12a0..a673dd7 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -54,6 +54,7 @@ config IA64 select MODULES_USE_ELF_RELA select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_AUDITSYSCALL + select HAVE_PRCTL_ARCH default y help The Itanium Processor Family is Intel's 64-bit successor to diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h index 0489b80..e40242e 100644 --- a/arch/ia64/include/asm/processor.h +++ b/arch/ia64/include/asm/processor.h @@ -259,18 +259,6 @@ typedef struct { (int __user *) (addr)); \ }) -#define SET_FPEMU_CTL(value) \ -({ \ - current->thread.flags = ((current->thread.flags & ~IA64_THREAD_FPEMU_MASK) \ - | (((value) << IA64_THREAD_FPEMU_SHIFT) & IA64_THREAD_FPEMU_MASK)); \ - 0; \ -}) -#define GET_FPEMU_CTL(addr) \ -({ \ - put_user((current->thread.flags & IA64_THREAD_FPEMU_MASK) >> IA64_THREAD_FPEMU_SHIFT, \ - (int __user *) (addr)); \ -}) - struct thread_struct { __u32 flags; /* various thread flags (see IA64_THREAD_*) */ /* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */ diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c index 9ebe1d6..d996585 100644 --- a/arch/ia64/kernel/sys_ia64.c +++ b/arch/ia64/kernel/sys_ia64.c @@ -15,11 +15,13 @@ #include #include #include /* doh, must come after sched.h... */ +#include #include #include #include #include +#include #include #include @@ -184,3 +186,23 @@ sys_pciconfig_write (unsigned long bus, unsigned long dfn, unsigned long off, un } #endif /* CONFIG_PCI */ + +int prctl_arch(int option, unsigned long arg2, unsigned long arg3, + unsigned long arg4, unsigned long arg5) +{ + int res; + + switch (option) { + case PR_SET_FPEMU: + current->thread.flags &= ~IA64_THREAD_FPEMU_MASK; + current->thread.flags |= (arg2 << IA64_THREAD_FPEMU_SHIFT) & + IA64_THREAD_FPEMU_MASK; + return 0; + case PR_GET_FPEMU: + res = (current->thread.flags & IA64_THREAD_FPEMU_MASK) >> + IA64_THREAD_FPEMU_SHIFT; + return put_user(res, (int __user *)arg2); + default: + return -EINVAL; + } +} diff --git a/kernel/sys.c b/kernel/sys.c index 5549505..8111c0d 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -77,12 +77,6 @@ #ifndef GET_UNALIGN_CTL # define GET_UNALIGN_CTL(a, b) (-EINVAL) #endif -#ifndef SET_FPEMU_CTL -# define SET_FPEMU_CTL(a) (-EINVAL) -#endif -#ifndef GET_FPEMU_CTL -# define GET_FPEMU_CTL(a) (-EINVAL) -#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2246,12 +2240,6 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, case PR_GET_UNALIGN: error = GET_UNALIGN_CTL(me, arg2); break; - case PR_SET_FPEMU: - error = SET_FPEMU_CTL(arg2); - break; - case PR_GET_FPEMU: - error = GET_FPEMU_CTL(arg2); - break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL; break; From patchwork Mon May 14 17:14:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135747 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2049825lji; Mon, 14 May 2018 10:15:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpxb0py8ZLjeHaiDwWNOSYqXjDnDt9gR3XcHOSR30X3C+nNLLCHjEMhc7zMhbSq2Xj+4vCj X-Received: by 2002:a17:902:20e5:: with SMTP id v34-v6mr10798100plg.127.1526318146379; Mon, 14 May 2018 10:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318146; cv=none; d=google.com; s=arc-20160816; b=Ua2vAfIZlh1bUzgOt509dpGZ8wE/jOGExUa0tf5MNqLle5MvFB6VtXCWDO00cK3OSv dwWsXDfszkQAgBRrMfEW1FrWgAmv27ykasIk9N4AXHgg6YNYUPdkQ5tLtnTZkwaO21ag zu+EPD2r8Pi85b6NnjM8RvrMlJXloVTXZi1WUNc95B1wK+zidoxQ9ZrCHOpQzsr4suCf 0XYmGo99ZcMSAzsLgia2zuYtQ+0qaxKGi0cdD7M2LTZxqNKqM11hDZOQYhaAr4Yq/Sux U9ulQCeI3HM7touqr+tZaQmG+QLQw9ENTaXJ0dv6AKsxrOfT2DLTErNhdyjkw1vdijR4 3+DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ojGifDF5p4qJZMcRYXsx98pJ/O01Q5y8AWzXN0AKJ1Y=; b=HBm3lA6pKaHdZuMG1sxkeuouxo9OS6280YbCqFeWZaIqFHL0mUggtZi9bRJ9I4Dhls qqD05yt1HvkJh341834Tl8Kt/sT/RqjOe4jQCmwMMKxs4zNy5JvIIn/ImgxAN8Rndydz xUpstUgkKl5HHLirMcHeR8u2MEkh35+AszWXthgZg7MJSEbNloTaQycvhb6E1jVvv2ue mpzWxWRtEWyd5V/BOilAmYvZTPNvs0kiKoEkf1vmDd3KfZnlTS9ooF5938UbtoRZILD9 KbBEGPB6FBvzRdix0AoKJ2UIGHT4AJ9sv3EEOfBnTxo7SCT/SQXEFEpFwkqXKz55ksLP m9Gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17-v6si10028329plq.115.2018.05.14.10.15.46; Mon, 14 May 2018 10:15:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbeENRPn (ORCPT + 29 others); Mon, 14 May 2018 13:15:43 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47022 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754177AbeENRPh (ORCPT ); Mon, 14 May 2018 13:15:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5299165C; Mon, 14 May 2018 10:15:36 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8D5D23F59F; Mon, 14 May 2018 10:15:34 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Kees Cook , Andrew Morton , Ingo Molnar , Richard Henderson , Ivan Kokshaysky , Matt Turner , Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Yoshinori Sato , Rich Felker Subject: [RFC PATCH 10/11] prctl: Remove redundant task argument from PR_{SET, GET}_UNALIGN backends Date: Mon, 14 May 2018 18:14:26 +0100 Message-Id: <1526318067-4964-11-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Architecture backends for the PT_SET_UNALIGN and PR_GET_UNALIGN prctl() calls take a task argument that is redundant, since the only thing ever passed is "current". This patch gets rid of the redundant arguments. No functional change. Signed-off-by: Dave Martin Cc: Kees Cook Cc: Andrew Morton Cc: Ingo Molnar Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Tony Luck Cc: Fenghua Yu Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Yoshinori Sato Cc: Rich Felker --- arch/alpha/include/asm/thread_info.h | 10 +++++----- arch/ia64/include/asm/processor.h | 8 ++++---- arch/parisc/include/asm/processor.h | 8 ++++---- arch/powerpc/include/asm/processor.h | 8 ++++---- arch/powerpc/kernel/process.c | 8 ++++---- arch/sh/include/asm/processor.h | 8 ++++---- arch/sh/mm/alignment.c | 10 +++++----- kernel/sys.c | 8 ++++---- 8 files changed, 34 insertions(+), 34 deletions(-) -- 2.1.4 diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h index 807d7b9..403b3c8 100644 --- a/arch/alpha/include/asm/thread_info.h +++ b/arch/alpha/include/asm/thread_info.h @@ -85,19 +85,19 @@ register struct thread_info *__current_thread_info __asm__("$8"); #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */ #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */ -#define SET_UNALIGN_CTL(task,value) ({ \ - __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ +#define SET_UNALIGN_CTL(value) ({ \ + __u32 status = current_thread_info()->status & ~UAC_BITMASK; \ if (value & PR_UNALIGN_NOPRINT) \ status |= TS_UAC_NOPRINT; \ if (value & PR_UNALIGN_SIGBUS) \ status |= TS_UAC_SIGBUS; \ if (value & 4) /* alpha-specific */ \ status |= TS_UAC_NOFIX; \ - task_thread_info(task)->status = status; \ + current_thread_info()->status = status; \ 0; }) -#define GET_UNALIGN_CTL(task,value) ({ \ - __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ +#define GET_UNALIGN_CTL(value) ({ \ + __u32 status = current_thread_info()->status & ~UAC_BITMASK; \ __u32 res = 0; \ if (status & TS_UAC_NOPRINT) \ res |= PR_UNALIGN_NOPRINT; \ diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h index e40242e..8d5184f 100644 --- a/arch/ia64/include/asm/processor.h +++ b/arch/ia64/include/asm/processor.h @@ -247,15 +247,15 @@ typedef struct { unsigned long seg; } mm_segment_t; -#define SET_UNALIGN_CTL(task,value) \ +#define SET_UNALIGN_CTL(value) \ ({ \ - (task)->thread.flags = (((task)->thread.flags & ~IA64_THREAD_UAC_MASK) \ + current->thread.flags = ((current->thread.flags & ~IA64_THREAD_UAC_MASK) \ | (((value) << IA64_THREAD_UAC_SHIFT) & IA64_THREAD_UAC_MASK)); \ 0; \ }) -#define GET_UNALIGN_CTL(task,addr) \ +#define GET_UNALIGN_CTL(addr) \ ({ \ - put_user(((task)->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT, \ + put_user((current->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT, \ (int __user *) (addr)); \ }) diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h index 2dbe558..b59720f 100644 --- a/arch/parisc/include/asm/processor.h +++ b/arch/parisc/include/asm/processor.h @@ -139,17 +139,17 @@ struct thread_struct { #define PARISC_UAC_SHIFT 0 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS) -#define SET_UNALIGN_CTL(task,value) \ +#define SET_UNALIGN_CTL(value) \ ({ \ - (task)->thread.flags = (((task)->thread.flags & ~PARISC_UAC_MASK) \ + current->thread.flags = ((current->thread.flags & ~PARISC_UAC_MASK) \ | (((value) << PARISC_UAC_SHIFT) & \ PARISC_UAC_MASK)); \ 0; \ }) -#define GET_UNALIGN_CTL(task,addr) \ +#define GET_UNALIGN_CTL(addr) \ ({ \ - put_user(((task)->thread.flags & PARISC_UAC_MASK) \ + put_user((current->thread.flags & PARISC_UAC_MASK) \ >> PARISC_UAC_SHIFT, (int __user *) (addr)); \ }) diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index e1cd7ec..b8d9306 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -413,11 +413,11 @@ extern int set_fpexc_mode(unsigned int val); extern int get_endian(unsigned long adr); extern int set_endian(unsigned int val); -#define GET_UNALIGN_CTL(tsk, adr) get_unalign_ctl((tsk), (adr)) -#define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val)) +#define GET_UNALIGN_CTL(adr) get_unalign_ctl((adr)) +#define SET_UNALIGN_CTL(val) set_unalign_ctl((val)) -extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr); -extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val); +extern int get_unalign_ctl(unsigned long adr); +extern int set_unalign_ctl(unsigned int val); extern void load_fp_state(struct thread_fp_state *fp); extern void store_fp_state(struct thread_fp_state *fp); diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 0fcb2f5..17708b7 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -2020,15 +2020,15 @@ int get_endian(unsigned long adr) return put_user(val, (unsigned int __user *)adr); } -int set_unalign_ctl(struct task_struct *tsk, unsigned int val) +int set_unalign_ctl(unsigned int val) { - tsk->thread.align_ctl = val; + current->thread.align_ctl = val; return 0; } -int get_unalign_ctl(struct task_struct *tsk, unsigned long adr) +int get_unalign_ctl(unsigned long adr) { - return put_user(tsk->thread.align_ctl, (unsigned int __user *)adr); + return put_user(current->thread.align_ctl, (unsigned int __user *)adr); } static inline int valid_irq_stack(unsigned long sp, struct task_struct *p, diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h index 6fbf8c8..ce3d9f6 100644 --- a/arch/sh/include/asm/processor.h +++ b/arch/sh/include/asm/processor.h @@ -117,11 +117,11 @@ extern void free_thread_xstate(struct task_struct *); extern struct kmem_cache *task_xstate_cachep; /* arch/sh/mm/alignment.c */ -extern int get_unalign_ctl(struct task_struct *, unsigned long addr); -extern int set_unalign_ctl(struct task_struct *, unsigned int val); +extern int get_unalign_ctl(unsigned long addr); +extern int set_unalign_ctl(unsigned int val); -#define GET_UNALIGN_CTL(tsk, addr) get_unalign_ctl((tsk), (addr)) -#define SET_UNALIGN_CTL(tsk, val) set_unalign_ctl((tsk), (val)) +#define GET_UNALIGN_CTL(addr) get_unalign_ctl((addr)) +#define SET_UNALIGN_CTL(val) set_unalign_ctl((val)) /* arch/sh/mm/init.c */ extern unsigned int mem_init_done; diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c index ec2b253..bad2a31 100644 --- a/arch/sh/mm/alignment.c +++ b/arch/sh/mm/alignment.c @@ -80,16 +80,16 @@ unsigned int unaligned_user_action(void) return action; } -int get_unalign_ctl(struct task_struct *tsk, unsigned long addr) +int get_unalign_ctl(unsigned long addr) { - return put_user(tsk->thread.flags & SH_THREAD_UAC_MASK, + return put_user(current->thread.flags & SH_THREAD_UAC_MASK, (unsigned int __user *)addr); } -int set_unalign_ctl(struct task_struct *tsk, unsigned int val) +int set_unalign_ctl(unsigned int val) { - tsk->thread.flags = (tsk->thread.flags & ~SH_THREAD_UAC_MASK) | - (val & SH_THREAD_UAC_MASK); + current->thread.flags = (current->thread.flags & ~SH_THREAD_UAC_MASK) | + (val & SH_THREAD_UAC_MASK); return 0; } diff --git a/kernel/sys.c b/kernel/sys.c index 8111c0d..47cf999 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -72,10 +72,10 @@ #include "uid16.h" #ifndef SET_UNALIGN_CTL -# define SET_UNALIGN_CTL(a, b) (-EINVAL) +# define SET_UNALIGN_CTL(a) (-EINVAL) #endif #ifndef GET_UNALIGN_CTL -# define GET_UNALIGN_CTL(a, b) (-EINVAL) +# define GET_UNALIGN_CTL(a) (-EINVAL) #endif /* @@ -2235,10 +2235,10 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, break; case PR_SET_UNALIGN: - error = SET_UNALIGN_CTL(me, arg2); + error = SET_UNALIGN_CTL(arg2); break; case PR_GET_UNALIGN: - error = GET_UNALIGN_CTL(me, arg2); + error = GET_UNALIGN_CTL(arg2); break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL; From patchwork Mon May 14 17:14:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 135748 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2050104lji; Mon, 14 May 2018 10:15:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZreZE/zBDzMZFxIVARw8si3ZitOtl8tCt7VHJ8OKVIT0Cq0VXmzku36UEqlae6Z8MdeEML9 X-Received: by 2002:a17:902:7582:: with SMTP id j2-v6mr10780540pll.65.1526318158938; Mon, 14 May 2018 10:15:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526318158; cv=none; d=google.com; s=arc-20160816; b=CcwW8B6jwhHWbhkai00tY99peHCXxmzvN1GcBnUdCj+1ndO3TbvjRr0TXMeX+9KHLI NFnD7GpE8fGjW+vOebvO9id11hnN770mDcHQye3FLULrSCpPim1RyZZkFOqTu9hY2NvJ 5+HBFjng9Mrpy2Qfiz/cPdbrsjjopqOvvCTmMpcjnqcqm7LRlO3CUT9pgoxueVDy82yY SgblH2Bq0yNECUFLt+9bhwwNZW4eG/miMXVCHeCrpXjtbGHI4ah8GcPyjh8kaMyJM9Ya qXvnsrmwhn1I3ZiCAwwkyhIvDADFct4m83GpnyZuE3TOd7D5pAasLmVkSWhktvy4fddt OvPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=qj9cLBmDYXPQLpY47CcqDu9RIKBDBhFSOQC0skG+v7o=; b=qeqlWknaGts5KWvC8gkXRSI4oar26F47pfqyCrSMV2imfNh9tth004pVP/X9acSPtu 2/aUgR4Ht46zID7bS8qsKHn4yLhYEO1P6pu/23Kuu4FpLOgERZ0OdZZCzhvSc54mlnIw uCxBC7RSvxD9t51FMpL09a4T1w8VY4gZZcOBTSmcdz8v7Zy1LhZM/PlkwqxOI7xjnHx8 37rIFWunL9fpC9OvsJ2dQyBwfK6MLkH8Q/qyViu3miLwjdD8/z6tJUfGYiEFFAF0G0d1 McYkBis5SSG9dG/prfm9d7UxHm8stqYyKiJRIxpWN7fKWgO1aSsH00s1QoBy9R4kxS5G gezg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186-v6si9503560pfg.141.2018.05.14.10.15.58; Mon, 14 May 2018 10:15:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754241AbeENRP4 (ORCPT + 29 others); Mon, 14 May 2018 13:15:56 -0400 Received: from foss.arm.com ([217.140.101.70]:47052 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752852AbeENRPk (ORCPT ); Mon, 14 May 2018 13:15:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A3B41688; Mon, 14 May 2018 10:15:39 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 326633F59F; Mon, 14 May 2018 10:15:37 -0700 (PDT) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arch@vger.kernel.org, Kees Cook , Andrew Morton , Ingo Molnar , Richard Henderson , Ivan Kokshaysky , Matt Turner , Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Yoshinori Sato , Rich Felker Subject: [RFC PATCH 11/11] prctl: Refactor PR_{SET, GET}_UNALIGN to reduce boilerplate Date: Mon, 14 May 2018 18:14:27 +0100 Message-Id: <1526318067-4964-12-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> References: <1526318067-4964-1-git-send-email-Dave.Martin@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The PR_SET_UNALIGN and PR_GET_UNALIGN prctl() calls are implemented by five architectures today, but there is some irregularity and duplication in the way they are implemented. This patch moves the common put_user() operation to common code, since the user pointer type is the same in all cases. Because this is hardly hot-path code, there is no strong reason to inline the arch backends for these operations, so this patch also pushes them down into the arch trees as proper C functions, and regularises the style of the backends somewhat. Signed-off-by: Dave Martin Cc: Kees Cook Cc: Andrew Morton Cc: Ingo Molnar Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Tony Luck Cc: Fenghua Yu Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: Yoshinori Sato Cc: Rich Felker --- arch/Kconfig | 3 +++ arch/alpha/Kconfig | 1 + arch/alpha/include/asm/thread_info.h | 23 ----------------------- arch/alpha/kernel/Makefile | 2 +- arch/alpha/kernel/sys.c | 36 ++++++++++++++++++++++++++++++++++++ arch/ia64/Kconfig | 1 + arch/ia64/include/asm/processor.h | 12 ------------ arch/ia64/kernel/sys_ia64.c | 15 +++++++++++++++ arch/parisc/Kconfig | 1 + arch/parisc/include/asm/processor.h | 14 -------------- arch/parisc/kernel/sys_parisc.c | 15 +++++++++++++++ arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/processor.h | 6 ------ arch/powerpc/kernel/process.c | 6 +++--- arch/sh/Kconfig | 1 + arch/sh/include/asm/processor.h | 7 ------- arch/sh/mm/alignment.c | 8 ++++---- include/linux/prctl.h | 8 ++++++++ kernel/sys.c | 20 ++++++++++---------- 19 files changed, 100 insertions(+), 80 deletions(-) create mode 100644 arch/alpha/kernel/sys.c -- 2.1.4 diff --git a/arch/Kconfig b/arch/Kconfig index b34b3e8..a9195ffc 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -972,4 +972,7 @@ config REFCOUNT_FULL config HAVE_PRCTL_ARCH bool +config HAVE_ARCH_PR_SET_GET_UNALIGN + bool + source "kernel/gcov/Kconfig" diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig index b202288..afb9aaa 100644 --- a/arch/alpha/Kconfig +++ b/arch/alpha/Kconfig @@ -23,6 +23,7 @@ config ALPHA select GENERIC_STRNCPY_FROM_USER select GENERIC_STRNLEN_USER select HAVE_ARCH_AUDITSYSCALL + select HAVE_ARCH_PR_SET_GET_UNALIGN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA select ODD_RT_SIGACTION diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h index 403b3c8..7ba2099 100644 --- a/arch/alpha/include/asm/thread_info.h +++ b/arch/alpha/include/asm/thread_info.h @@ -85,28 +85,5 @@ register struct thread_info *__current_thread_info __asm__("$8"); #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */ #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */ -#define SET_UNALIGN_CTL(value) ({ \ - __u32 status = current_thread_info()->status & ~UAC_BITMASK; \ - if (value & PR_UNALIGN_NOPRINT) \ - status |= TS_UAC_NOPRINT; \ - if (value & PR_UNALIGN_SIGBUS) \ - status |= TS_UAC_SIGBUS; \ - if (value & 4) /* alpha-specific */ \ - status |= TS_UAC_NOFIX; \ - current_thread_info()->status = status; \ - 0; }) - -#define GET_UNALIGN_CTL(value) ({ \ - __u32 status = current_thread_info()->status & ~UAC_BITMASK; \ - __u32 res = 0; \ - if (status & TS_UAC_NOPRINT) \ - res |= PR_UNALIGN_NOPRINT; \ - if (status & TS_UAC_SIGBUS) \ - res |= PR_UNALIGN_SIGBUS; \ - if (status & TS_UAC_NOFIX) \ - res |= 4; \ - put_user(res, (int __user *)(value)); \ - }) - #endif /* __KERNEL__ */ #endif /* _ALPHA_THREAD_INFO_H */ diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile index 5a74581..e4b5294 100644 --- a/arch/alpha/kernel/Makefile +++ b/arch/alpha/kernel/Makefile @@ -9,7 +9,7 @@ ccflags-y := -Wno-sign-compare obj-y := entry.o traps.o process.o osf_sys.o irq.o \ irq_alpha.o signal.o setup.o ptrace.o time.o \ - systbls.o err_common.o io.o bugs.o + systbls.o err_common.o io.o bugs.o sys.o obj-$(CONFIG_VGA_HOSE) += console.o obj-$(CONFIG_SMP) += smp.o diff --git a/arch/alpha/kernel/sys.c b/arch/alpha/kernel/sys.c new file mode 100644 index 0000000..3dc454f --- /dev/null +++ b/arch/alpha/kernel/sys.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include + +int arch_set_unalign_ctl(unsigned int val) +{ + __u32 status = current_thread_info()->status & ~UAC_BITMASK; + + if (val & PR_UNALIGN_NOPRINT) + status |= TS_UAC_NOPRINT; + if (val & PR_UNALIGN_SIGBUS) + status |= TS_UAC_SIGBUS; + if (val & 4) /* alpha-specific */ + status |= TS_UAC_NOFIX; + + current_thread_info()->status = status; + + return 0; +} + +int arch_get_unalign_ctl(void) +{ + __u32 status = current_thread_info()->status & ~UAC_BITMASK; + int res = 0; + + if (status & TS_UAC_NOPRINT) + res |= PR_UNALIGN_NOPRINT; + if (status & TS_UAC_SIGBUS) + res |= PR_UNALIGN_SIGBUS; + if (status & TS_UAC_NOFIX) + res |= 4; + + return res; +} diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index a673dd7..ab62a57 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -55,6 +55,7 @@ config IA64 select ARCH_USE_CMPXCHG_LOCKREF select HAVE_ARCH_AUDITSYSCALL select HAVE_PRCTL_ARCH + select HAVE_ARCH_PR_SET_GET_UNALIGN default y help The Itanium Processor Family is Intel's 64-bit successor to diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h index 8d5184f..49f4ef9 100644 --- a/arch/ia64/include/asm/processor.h +++ b/arch/ia64/include/asm/processor.h @@ -247,18 +247,6 @@ typedef struct { unsigned long seg; } mm_segment_t; -#define SET_UNALIGN_CTL(value) \ -({ \ - current->thread.flags = ((current->thread.flags & ~IA64_THREAD_UAC_MASK) \ - | (((value) << IA64_THREAD_UAC_SHIFT) & IA64_THREAD_UAC_MASK)); \ - 0; \ -}) -#define GET_UNALIGN_CTL(addr) \ -({ \ - put_user((current->thread.flags & IA64_THREAD_UAC_MASK) >> IA64_THREAD_UAC_SHIFT, \ - (int __user *) (addr)); \ -}) - struct thread_struct { __u32 flags; /* various thread flags (see IA64_THREAD_*) */ /* writing on_ustack is performance-critical, so it's worth spending 8 bits on it... */ diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c index d996585..2c2fd65 100644 --- a/arch/ia64/kernel/sys_ia64.c +++ b/arch/ia64/kernel/sys_ia64.c @@ -206,3 +206,18 @@ int prctl_arch(int option, unsigned long arg2, unsigned long arg3, return -EINVAL; } } + +int arch_set_unalign_ctl(unsigned int val) +{ + current->thread.flags &= ~IA64_THREAD_UAC_MASK; + current->thread.flags |= (val << IA64_THREAD_UAC_SHIFT) & + IA64_THREAD_UAC_MASK; + + return 0; +} + +int arch_get_unalign_ctl(void) +{ + return (current->thread.flags & IA64_THREAD_UAC_MASK) >> + IA64_THREAD_UAC_SHIFT; +} diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index fc5a574..a2f0f0a 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -44,6 +44,7 @@ config PARISC select HAVE_DEBUG_STACKOVERFLOW select HAVE_ARCH_AUDITSYSCALL select HAVE_ARCH_HASH + select HAVE_ARCH_PR_SET_GET_UNALIGN select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK select GENERIC_SCHED_CLOCK diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h index b59720f..dbea6e9 100644 --- a/arch/parisc/include/asm/processor.h +++ b/arch/parisc/include/asm/processor.h @@ -139,20 +139,6 @@ struct thread_struct { #define PARISC_UAC_SHIFT 0 #define PARISC_UAC_MASK (PARISC_UAC_NOPRINT|PARISC_UAC_SIGBUS) -#define SET_UNALIGN_CTL(value) \ - ({ \ - current->thread.flags = ((current->thread.flags & ~PARISC_UAC_MASK) \ - | (((value) << PARISC_UAC_SHIFT) & \ - PARISC_UAC_MASK)); \ - 0; \ - }) - -#define GET_UNALIGN_CTL(addr) \ - ({ \ - put_user((current->thread.flags & PARISC_UAC_MASK) \ - >> PARISC_UAC_SHIFT, (int __user *) (addr)); \ - }) - #define INIT_THREAD { \ .regs = { .gr = { 0, }, \ .fr = { 0, }, \ diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c index 43b308c..e3a7f29 100644 --- a/arch/parisc/kernel/sys_parisc.c +++ b/arch/parisc/kernel/sys_parisc.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include /* we construct an artificial offset for the mapping based on the physical * address of the kernel mapping variable */ @@ -391,3 +393,16 @@ long parisc_personality(unsigned long personality) return err; } + +int arch_set_unalign_ctl(unsigned int val) +{ + current->thread.flags &= ~PARISC_UAC_MASK; + current->thread.flags |= (val << PARISC_UAC_SHIFT) & PARISC_UAC_MASK; + + return 0; +} + +int arch_get_unalign_ctl(void) +{ + return (current->thread.flags & PARISC_UAC_MASK) >> PARISC_UAC_SHIFT; +} diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index b94323e..68c31fb 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -181,6 +181,7 @@ config PPC select HAVE_ARCH_KGDB select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT + select HAVE_ARCH_PR_SET_GET_UNALIGN select HAVE_ARCH_SECCOMP_FILTER select HAVE_ARCH_TRACEHOOK select HAVE_CBPF_JIT if !PPC64 diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h index b8d9306..8bac2f6 100644 --- a/arch/powerpc/include/asm/processor.h +++ b/arch/powerpc/include/asm/processor.h @@ -413,12 +413,6 @@ extern int set_fpexc_mode(unsigned int val); extern int get_endian(unsigned long adr); extern int set_endian(unsigned int val); -#define GET_UNALIGN_CTL(adr) get_unalign_ctl((adr)) -#define SET_UNALIGN_CTL(val) set_unalign_ctl((val)) - -extern int get_unalign_ctl(unsigned long adr); -extern int set_unalign_ctl(unsigned int val); - extern void load_fp_state(struct thread_fp_state *fp); extern void store_fp_state(struct thread_fp_state *fp); extern void load_vr_state(struct thread_vr_state *vr); diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 17708b7..a623373 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -2020,15 +2020,15 @@ int get_endian(unsigned long adr) return put_user(val, (unsigned int __user *)adr); } -int set_unalign_ctl(unsigned int val) +int arch_set_unalign_ctl(unsigned int val) { current->thread.align_ctl = val; return 0; } -int get_unalign_ctl(unsigned long adr) +int arch_get_unalign_ctl(void) { - return put_user(current->thread.align_ctl, (unsigned int __user *)adr); + return current->thread.align_ctl; } static inline int valid_irq_stack(unsigned long sp, struct task_struct *p, diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 97fe293..f9631bf 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -48,6 +48,7 @@ config SUPERH select OLD_SIGSUSPEND select OLD_SIGACTION select HAVE_ARCH_AUDITSYSCALL + select HAVE_ARCH_PR_SET_GET_UNALIGN select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_NMI help diff --git a/arch/sh/include/asm/processor.h b/arch/sh/include/asm/processor.h index ce3d9f6..ff4d332 100644 --- a/arch/sh/include/asm/processor.h +++ b/arch/sh/include/asm/processor.h @@ -116,13 +116,6 @@ extern unsigned int xstate_size; extern void free_thread_xstate(struct task_struct *); extern struct kmem_cache *task_xstate_cachep; -/* arch/sh/mm/alignment.c */ -extern int get_unalign_ctl(unsigned long addr); -extern int set_unalign_ctl(unsigned int val); - -#define GET_UNALIGN_CTL(addr) get_unalign_ctl((addr)) -#define SET_UNALIGN_CTL(val) set_unalign_ctl((val)) - /* arch/sh/mm/init.c */ extern unsigned int mem_init_done; diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c index bad2a31..63fc963 100644 --- a/arch/sh/mm/alignment.c +++ b/arch/sh/mm/alignment.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -80,13 +81,12 @@ unsigned int unaligned_user_action(void) return action; } -int get_unalign_ctl(unsigned long addr) +int arch_get_unalign_ctl(void) { - return put_user(current->thread.flags & SH_THREAD_UAC_MASK, - (unsigned int __user *)addr); + return current->thread.flags & SH_THREAD_UAC_MASK; } -int set_unalign_ctl(unsigned int val) +int arch_set_unalign_ctl(unsigned int val) { current->thread.flags = (current->thread.flags & ~SH_THREAD_UAC_MASK) | (val & SH_THREAD_UAC_MASK); diff --git a/include/linux/prctl.h b/include/linux/prctl.h index 5ce3713..abc803e 100644 --- a/include/linux/prctl.h +++ b/include/linux/prctl.h @@ -16,4 +16,12 @@ static inline int prctl_arch(int option, unsigned long arg2, } #endif +#ifdef CONFIG_HAVE_ARCH_PR_SET_GET_UNALIGN +extern int arch_set_unalign_ctl(unsigned int val); +extern int arch_get_unalign_ctl(void); +#else +static inline int arch_set_unalign_ctl(unsigned int val) { return -EINVAL; } +static inline int arch_get_unalign_ctl(void) { return -EINVAL; } +#endif + #endif /* ! _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index 47cf999..562ffbe 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -71,13 +71,6 @@ #include "uid16.h" -#ifndef SET_UNALIGN_CTL -# define SET_UNALIGN_CTL(a) (-EINVAL) -#endif -#ifndef GET_UNALIGN_CTL -# define GET_UNALIGN_CTL(a) (-EINVAL) -#endif - /* * this is where the system-wide overflow UID and GID are defined, for * architectures that now have 32-bit UID/GID but didn't in the past @@ -2235,10 +2228,17 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, break; case PR_SET_UNALIGN: - error = SET_UNALIGN_CTL(arg2); + error = arch_set_unalign_ctl(arg2); break; - case PR_GET_UNALIGN: - error = GET_UNALIGN_CTL(arg2); + case PR_GET_UNALIGN: { + int res; + + res = arch_get_unalign_ctl(); + if (res >= 0) + error = put_user(res, (int __user *)arg2); + else + error = res; + } break; case PR_GET_TIMING: error = PR_TIMING_STATISTICAL;