From patchwork Wed Mar 22 14:50:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 9639199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 98F65602CB for ; Wed, 22 Mar 2017 15:09:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A66A2845C for ; Wed, 22 Mar 2017 15:09:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F2DC2846F; Wed, 22 Mar 2017 15:09:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66B032845C for ; Wed, 22 Mar 2017 15:09:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=k1LeTdP0LXazXxN/VcqMTHbS3rm0Rir2ZnVvG/EASSI=; b=W/TIGHkD2kPzlGBwf2xF8tSlTW L9enoUhzud6JjmVnhmEHD8S4BiRN39X7H8XRXxsHElV7eAVuMwz6LPhtg4k5yeP6quGWu/vzJ+BM/ y2t2lmufT9VwdvjmYAZkDAfP5xgFrTQm8oKkGCMB6GeXeazPwS5UxzaGsuLB3ZJKHZ7uawBWIPbIQ v2ghaiRR7l7CgKYH7Se9jMJRblX0CX5bBeYUfomW3Um1CfK1ZVmwiFl4sKNUpIhDoOtWIFoZkF9Ry 8V7wrXAI41ifWbQI2rpuJjXMl2iQwG9c2fWtzxrHfrvh1tfn+ahVingBlQ/mL+6j6bIAuSlcRhK2W ZccOuv5A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqht1-00069w-Th; Wed, 22 Mar 2017 15:09:19 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cqhrj-0004A1-L9 for linux-arm-kernel@bombadil.infradead.org; Wed, 22 Mar 2017 15:07:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s+a8D33qmKM51VlN0StfmHCNZ721WMXcY4S/3wgZ/is=; b=C547Vp2ziWgFweh+TlWrd9NAr A73f3KAPVZvjD6sUeCOLJ2uyuYBriXuFTwpnS6RiAtVe76xZ+xFEgvX5qEgYEFvdRQSX5uIpKTWLA bFaGFC40OLpVsl5NMdjcXJkZhmfOOckvJpA1KoQ5nSUl9jXLpHVEs9fW4lDNxMTx/aa8zGB7xAbne QbbKK8y3SQ0jm+IC4H4AWBloIw3AUJlakijbewzcYp/gyCJl7hMA1VNxxwCGoXNS5pRII7/AVYBOq 4PCqhnOzh/GmrOHpffAukbR0WMBC9xjgABThZX+zcQtiPbSnk/DRHw+f05nOtBO8TBHK92q7g/HiW UVoFK0t+A==; Received: from foss.arm.com ([217.140.101.70]) by casper.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cqheG-00021G-Gv for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2017 14:54:06 +0000 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 DDE001597; Wed, 22 Mar 2017 07:53:43 -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 08F683F575; Wed, 22 Mar 2017 07:53:41 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2 29/41] prctl: Add skeleton for PR_SVE_{SET, GET}_VL controls Date: Wed, 22 Mar 2017 14:50:59 +0000 Message-Id: <1490194274-30569-30-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1490194274-30569-1-git-send-email-Dave.Martin@arm.com> References: <1490194274-30569-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170322_145404_849593_FBA927E1 X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , Ard Biesheuvel , Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Szabolcs Nagy , Andrew Morton , Joseph Myers MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a do-nothing skeleton for the arm64 Scalable Vector Extension control prctls. These prctls are only avilable with CONFIG_ARM64=y CONFIG_ARM64_SVE=y Otherwise they will compile out and return -EINVAL if attempted from userspace. The backend functions sve_{set,get}_task_vl() will be fleshed out with actual functionality in subsequent patches. Signed-off-by: Dave Martin --- arch/arm64/include/asm/fpsimd.h | 16 ++++++++++++++++ arch/arm64/include/asm/processor.h | 4 ++++ arch/arm64/kernel/fpsimd.c | 13 +++++++++++++ include/uapi/linux/prctl.h | 4 ++++ kernel/sys.c | 12 ++++++++++++ 5 files changed, 49 insertions(+) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 71b94ee..7dba890 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -17,6 +17,7 @@ #define __ASM_FP_H #include +#include #ifndef __ASSEMBLY__ @@ -107,12 +108,27 @@ extern void fpsimd_sync_to_sve(struct task_struct *task); extern void sve_sync_to_fpsimd(struct task_struct *task); extern void sve_sync_from_fpsimd_zeropad(struct task_struct *task); +extern int sve_set_task_vl(struct task_struct *task, + unsigned long vector_length, unsigned long flags); +extern int sve_get_task_vl(struct task_struct *task); + #else /* ! CONFIG_ARM64_SVE */ static void __maybe_unused sve_sync_to_fpsimd(struct task_struct *task) { } static void __maybe_unused sve_sync_from_fpsimd_zeropad( struct task_struct *task) { } +static int __maybe_unused sve_set_task_vl(struct task_struct *task, + unsigned long vector_length, unsigned long flags) +{ + return -EINVAL; +} + +static int __maybe_unused sve_get_task_vl(struct task_struct *task) +{ + return -EINVAL; +} + #endif /* ! CONFIG_ARM64_SVE */ #endif diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index c97b8bd..865c279 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -189,4 +189,8 @@ static inline void spin_lock_prefetch(const void *ptr) int cpu_enable_pan(void *__unused); int cpu_enable_cache_maint_trap(void *__unused); +#define SVE_SET_VL(task, vector_length, flags) \ + sve_set_task_vl(task, vector_length, flags) +#define SVE_GET_VL(task) sve_get_task_vl(task) + #endif /* __ASM_PROCESSOR_H */ diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index ee59325..4102d13 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -204,6 +204,19 @@ void do_sve_acc(unsigned int esr, struct pt_regs *regs) task_fpsimd_load(current); } +/* PR_SVE_SET_VL */ +int sve_set_task_vl(struct task_struct *task, + unsigned long vector_length, unsigned long flags) +{ + return -EINVAL; +} + +/* PR_SVE_GET_VL */ +int sve_get_task_vl(struct task_struct *task) +{ + return -EINVAL; +} + #else /* ! CONFIG_ARM64_SVE */ /* Dummy declarations for usage protected with IS_ENABLED(CONFIG_ARM64_SVE): */ diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index a8d0759..e32e2da 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -197,4 +197,8 @@ struct prctl_mm_map { # define PR_CAP_AMBIENT_LOWER 3 # define PR_CAP_AMBIENT_CLEAR_ALL 4 +/* arm64 Scalable Vector Extension controls */ +#define PR_SVE_SET_VL 48 /* set task vector length */ +#define PR_SVE_GET_VL 49 /* get task vector length */ + #endif /* _LINUX_PRCTL_H */ diff --git a/kernel/sys.c b/kernel/sys.c index 7ff6d1b..ea5d37e 100644 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -110,6 +110,12 @@ #ifndef SET_FP_MODE # define SET_FP_MODE(a,b) (-EINVAL) #endif +#ifndef SVE_SET_VL +# define SVE_SET_VL(a,b,c) (-EINVAL) +#endif +#ifndef SVE_GET_VL +# define SVE_GET_VL(a) (-EINVAL) +#endif /* * this is where the system-wide overflow UID and GID are defined, for @@ -2290,6 +2296,12 @@ 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(me, arg2, arg3); + break; + case PR_SVE_GET_VL: + error = SVE_GET_VL(me); + break; default: error = -EINVAL; break;