From patchwork Fri Jun 1 11:24:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 137525 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp809505lji; Fri, 1 Jun 2018 04:29:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIlLHMb0NNZk2hDoPOVNxzARdzYuKVCV17jIuwQTsS+1jc7lTBxqUZYCNz+KjGAt2gjB7bU X-Received: by 2002:a62:d1a:: with SMTP id v26-v6mr10631917pfi.90.1527852577356; Fri, 01 Jun 2018 04:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527852577; cv=none; d=google.com; s=arc-20160816; b=MP3XaQ/CmnTKumrG+6sLvUZL5TOaxtbUL5Sjk21iZ4wcAJko67gDmj0kAZM8xoe1Un iD+t25mbskQx10nOXuTpz780aB7EG4D7IwG6FZD2y9FLFWZW6dYaffcdkSxq+E876QhJ B8HdYYOhp7I6MV5SRIFOGBfJqbCsZXRBCks9fqw+AS9X4JJXZCihKbppa/bDL3ylcXMJ vu6t0XqOwefpBcokqPbExf9f5KDaIweH2j037mhYsNuOePCl9713CVJxM6m2f5H1nPNz bVubDPMCpsE4aycRS+A3Fqe9Xz7AljBDdZ288XBvr9BXMMc2o+Au42YcCo74HfInnhqZ Vasg== 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=pAych2jz+ukQvzoxRHKQ6tZmUbp1nac25vFeKRGFesw=; b=arkpRw1td72KYbbzjSLSk0OuQgBItWUMXbb1Pwt84VFagZocn9XAsIKmSKs/mUyiB1 K2Sy4fftu2E10sp+K+PAU2Igth6n1osv2Pa+GN4x6xgs0b67ZElm8zhKmh0Y1bBzF1Y/ ABzfGAa6TU5eIleifCFXOfgeyw1LAGbv94i4G8kCeJ5xx5xwfJG8DI9GYuJ2iwT/lJZE APidBDPzpUdVoTlRRyF0Kz3nrs0rQQa4+WyvUCAvmwCD8W8jdyXt/neolm5RaUFXTtig VFzAaT1F9qCrnKpf27iXAeAd6MpDb89Jitw/jsUUmdXbwuxA6i7B4Wxw8wr+oOm1coNM QgqA== 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 m27-v6si38408617pfj.192.2018.06.01.04.29.37; Fri, 01 Jun 2018 04:29: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 S1752126AbeFAL3f (ORCPT + 30 others); Fri, 1 Jun 2018 07:29:35 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50300 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751788AbeFALZC (ORCPT ); Fri, 1 Jun 2018 07:25:02 -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 F3CF6164F; Fri, 1 Jun 2018 04:25:01 -0700 (PDT) Received: from lakrids.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 C31EF3F25D; Fri, 1 Jun 2018 04:25:00 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com, catalin.marinas@arm.com Cc: Mark Rutland , Dave Martin Subject: [PATCHv2 06/19] arm64: move sve_user_{enable, disable} to Date: Fri, 1 Jun 2018 12:24:28 +0100 Message-Id: <20180601112441.37810-7-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180601112441.37810-1-mark.rutland@arm.com> References: <20180601112441.37810-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In subsequent patches, we'll want to make use of sve_user_enable() and sve_user_disable() outside of kernel/fpsimd.c. Let's move these to where we can make use of them. To avoid ifdeffery in sequences like: if (system_supports_sve() && some_condition sve_user_disable(); ... empty stubs are provided when support for SVE is not enabled. Note that system_supports_sve() contains as IS_ENABLED(CONFIG_ARM64_SVE), so the sve_user_disable() call should be optimized away entirely when CONFIG_ARM64_SVE is not selected. To ensure that this is the case, the stub definitions contain a BUILD_BUG(), as we do for other stubs for which calls should always be optimized away when the relevant config option is not selected. At the same time, the include list of is sorted while adding . Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Dave Martin Cc: Will Deacon --- arch/arm64/include/asm/fpsimd.h | 17 ++++++++++++++++- arch/arm64/kernel/fpsimd.c | 10 ---------- 2 files changed, 16 insertions(+), 11 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index aa7162ae93e3..c9acc6ad9b75 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -16,11 +16,13 @@ #ifndef __ASM_FP_H #define __ASM_FP_H -#include #include +#include +#include #ifndef __ASSEMBLY__ +#include #include #include #include @@ -81,6 +83,16 @@ extern int sve_set_vector_length(struct task_struct *task, extern int sve_set_current_vl(unsigned long arg); extern int sve_get_current_vl(void); +static inline void sve_user_disable(void) +{ + sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0); +} + +static inline void sve_user_enable(void) +{ + sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); +} + /* * Probing and setup functions. * Calls to these functions must be serialised with one another. @@ -107,6 +119,9 @@ static inline int sve_get_current_vl(void) return -EINVAL; } +static inline void sve_user_disable(void) { BUILD_BUG(); } +static inline void sve_user_enable(void) { BUILD_BUG(); } + static inline void sve_init_vq_map(void) { } static inline void sve_update_vq_map(void) { } static inline int sve_verify_vq_map(void) { return 0; } diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index c135cff8f882..86f2eef428e0 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -171,16 +171,6 @@ static void *sve_pffr(struct task_struct *task) sve_ffr_offset(task->thread.sve_vl); } -static void sve_user_disable(void) -{ - sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0); -} - -static void sve_user_enable(void) -{ - sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); -} - /* * TIF_SVE controls whether a task can use SVE without trapping while * in userspace, and also the way a task's FPSIMD/SVE state is stored