From patchwork Mon Jul 2 11:04:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 140726 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3854173ljj; Mon, 2 Jul 2018 04:04:42 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdDcPyIzEN2s99uiqapgyQgZJYvf3bCq5tv4iGKnx2xJAIJDzU2m+yugSGXv8iBSmGvKbzP X-Received: by 2002:a63:7007:: with SMTP id l7-v6mr15918934pgc.206.1530529482693; Mon, 02 Jul 2018 04:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530529482; cv=none; d=google.com; s=arc-20160816; b=vkchgWdFb1ViWwGVsuVPpoWWe2EWcU+Qdjy1uSbrhVEvmeK3cji2P9zoXVE9nYQ4Uv aW1dO0YboYhRatzo5A8sODrrl/xpiSk8J7382v8LF02F96gG9QTniqKuJfcJoGCHBueX dFRPYbSRAbPcbaZMhGFdY17HRb98ZEab2yYcelQ59dKSnAgu8FdRmRF5dEXbD2w+zkxV qxp63rWV4CBUVZsGnUydVajNlyZrWOIcNBIMMhSfG7EMs6ceTF3qUveA+AZ0gcNuMRkE oGDQvtsmzXn13erPi2fz2Yjpmx+HA+0go4U9Ax6NG0oX8tFtuGz8rSxCb3WE4L1a08gQ dD6g== 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=UiyU8iaUkqT4Z3X/mybfGktVPp2I94YgbXLg2VKEndM=; b=yW15KdnEva7ccBbSn15RvtIx2eLPg3Wkal7DQilv0/UK3dc3EwvvL9IpTbRV7L8VpI Ok1Wq9N91Wwwl53TSO6sPnYe7asUhEVuwy6nvtyHxIy2ABCqbH2oyCz6ie0XHHPxcF3i +6zEdlx6kNx++oFcWQ/Bc8Arte50i3xJFk+y2zG6bW+zJwbx/cnof8mgK3gwAihbEFns WtG5CSYQpX15vO6D9gXiwFFkAjqf+HjoUk1NiM4CRcFx66WfU43yqRRlBceaMDE5nT0d we8UFaSNz98Wjw/D2cX0BbaG7qCmxt73MQCpA2IOfM89ysXWWZS/9xsC+zKZnTmfm78n j1lQ== 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 g6-v6si6756237pgq.240.2018.07.02.04.04.42; Mon, 02 Jul 2018 04:04: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 S1030350AbeGBLEk (ORCPT + 31 others); Mon, 2 Jul 2018 07:04:40 -0400 Received: from foss.arm.com ([217.140.101.70]:57490 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030288AbeGBLEg (ORCPT ); Mon, 2 Jul 2018 07:04:36 -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 D4F421688; Mon, 2 Jul 2018 04:04:35 -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 C466C3F5BA; Mon, 2 Jul 2018 04:04:33 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, hch@infradead.org, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk Subject: [PATCHv4 05/19] arm64: move sve_user_{enable, disable} to Date: Mon, 2 Jul 2018 12:04:01 +0100 Message-Id: <20180702110415.10465-6-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180702110415.10465-1-mark.rutland@arm.com> References: <20180702110415.10465-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 Acked-by: Catalin Marinas Reviewed-by: 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 fa92747a49c8..dd1ad3950ef5 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -16,13 +16,15 @@ #ifndef __ASM_FP_H #define __ASM_FP_H -#include #include +#include #include #include +#include #ifndef __ASSEMBLY__ +#include #include #include #include @@ -102,6 +104,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. @@ -128,6 +140,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 a98a7f96aff1..58c53bc96928 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -159,16 +159,6 @@ static void sve_free(struct task_struct *task) __sve_free(task); } -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