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;