From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 848B9C46467 for ; Mon, 16 Jan 2023 16:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uGswB6Nm4a6SSf/dtidIpSYpQnEu0ZQHOyK+BCP6XuU=; b=Eg8ow3gyT/Y8jO MTCGMi+d7qnqXWFI++k9CpVWsCn0vVq0kZoqiXnyUWtd7/8LcSzUCN5YQ79lZaoSUjCDAAx4dULbA bTCHCGGk++w8U/a/Yc5IBYFyHMTs7IcbaUcU5Ag91+HlnOkW83MJdtW9NyK0++GekVPsgxqwIyp0g IWb3B2o2IWfRr//HNUa+LDcG31uQLLUuAP7c2xgViCgKq2fsFAdj4bm0HhtBXSAH2Uebu0wRfC26n /ma1I9XhuxjSk2fuRmm+XOOXZYIC3VqctoBPy1vuIZF2Q8k3A1KHGvrLL2sDSDg+298fwG2ksoL2F HEDk+9Gt8SXvHmbiN3zQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHS2L-00BDll-6z; Mon, 16 Jan 2023 16:08:41 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHRzw-00BCXg-K8 for linux-arm-kernel@lists.infradead.org; Mon, 16 Jan 2023 16:06:14 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4694AB8107D; Mon, 16 Jan 2023 16:06:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E90ABC433F0; Mon, 16 Jan 2023 16:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673885171; bh=Z9m1L9CCYmsUckq6Ug10yYsoeGBftC2rqgGXdm+qGnI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C41zsSd4TYcbQ/935ulv95zqpnpesewkagwrYKczcMlSez6jk/ucsSXMpyNfdWg/L Hp89tkV1UC8uklvTDKSGCcsiAjEE7XbmE8oCM81Lx4qkAFSO0JoCSqPJaZvWrbAWhV VacOuPCg1tvNoKLkcx/Dv9ybTR9NZP5iQ3nmKe6/QA/6jFBajZckfXKrkH7d99fEXW smH9isCoOCw62Ahd0DTceEBNGEzGp3AGMGNgJTCaE3BawnIOeP5tiuoDZFYAIG9xgq akzdHPKxDas3bci0raQtWWrggAFxvL4Cw8FYgOJz3xoOiridNKLmA4ZDJfd9VdFC3T w089dqoyYzFPA== From: Mark Brown Date: Mon, 16 Jan 2023 16:04:44 +0000 Subject: [PATCH v4 09/21] arm64/sme: Provide storage for ZT0 MIME-Version: 1.0 Message-Id: <20221208-arm64-sme2-v4-9-f2fa0aef982f@kernel.org> References: <20221208-arm64-sme2-v4-0-f2fa0aef982f@kernel.org> In-Reply-To: <20221208-arm64-sme2-v4-0-f2fa0aef982f@kernel.org> To: Catalin Marinas , Will Deacon , Oleg Nesterov , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Shuah Khan Cc: Alan Hayward , Luis Machado , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org, Mark Brown X-Mailer: b4 0.12-dev-77e06 X-Developer-Signature: v=1; a=openpgp-sha256; l=3010; i=broonie@kernel.org; h=from:subject:message-id; bh=Z9m1L9CCYmsUckq6Ug10yYsoeGBftC2rqgGXdm+qGnI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBjxXWo3OFkxngCoQuoGUymajWBKPQe+b4/Y5YeZMaF G5BAmLuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCY8V1qAAKCRAk1otyXVSH0Jt3B/ 4u0a0q7OQe2DN6lWm1akjYOBoPvsGVRUWLjHsm6PNJSSsIew/4ir0mg5ltnWtPZEwWNDp67WzYDxWj OsyiXKkIQE2OH1copHrOJH5u0h4khkod8z9dYwMIzRZ6OE2WmbIbFG7da3hRD8OiLruEmFUVveNxeY purfXEwumoy0j17TcQANEII7T4eVOSOYmSz97FBaUtHwa9RueFMqmOUT1co14auOdgcEtre1vvleRt kALejXM1nw9yfIGhVC1yukSRxsRyZWg8yagPUcFKvvLBk55oKvAJXE/nltfbk+PaAfBzQX4YDWRX25 AWq8IfA0Ta/sgfFekz/K7hy4VvJ5W5 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230116_080613_013401_2B2BBEBF X-CRM114-Status: GOOD ( 20.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When the system supports SME2 there is an additional register ZT0 which we must store when the task is using SME. Since ZT0 is accessible only when PSTATE.ZA is set just like ZA we allocate storage for it along with ZA, increasing the allocation size for the memory region where we store ZA and storing the data for ZT after that for ZA. Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimd.h | 13 +++++++++++++ arch/arm64/kernel/process.c | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 2a66e3b94553..8df769c20677 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -105,6 +105,13 @@ static inline void *sve_pffr(struct thread_struct *thread) return (char *)thread->sve_state + sve_ffr_offset(vl); } +static inline void *thread_zt_state(struct thread_struct *thread) +{ + /* The ZT register state is stored immediately after the ZA state */ + unsigned int sme_vq = sve_vq_from_vl(thread_get_sme_vl(thread)); + return thread->sme_state + ZA_SIG_REGS_SIZE(sme_vq); +} + extern void sve_save_state(void *state, u32 *pfpsr, int save_ffr); extern void sve_load_state(void const *state, u32 const *pfpsr, int restore_ffr); @@ -354,6 +361,9 @@ extern unsigned int sme_get_vl(void); extern int sme_set_current_vl(unsigned long arg); extern int sme_get_current_vl(void); +/* Will move with signal support */ +#define ZT_SIG_REG_SIZE 512 + /* * Return how many bytes of memory are required to store the full SME * specific state for task, given task's currently configured vector @@ -366,6 +376,9 @@ static inline size_t sme_state_size(struct task_struct const *task) size = ZA_SIG_REGS_SIZE(sve_vq_from_vl(vl)); + if (system_supports_sme2()) + size += ZT_SIG_REG_SIZE; + return size; } diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 4ce0c4313ec6..71d59b5abede 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -307,11 +307,11 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) /* * In the unlikely event that we create a new thread with ZA - * enabled we should retain the ZA state so duplicate it here. - * This may be shortly freed if we exec() or if CLONE_SETTLS - * but it's simpler to do it here. To avoid confusing the rest - * of the code ensure that we have a sve_state allocated - * whenever sme_state is allocated. + * enabled we should retain the ZA and ZT state so duplicate + * it here. This may be shortly freed if we exec() or if + * CLONE_SETTLS but it's simpler to do it here. To avoid + * confusing the rest of the code ensure that we have a + * sve_state allocated whenever sme_state is allocated. */ if (thread_za_enabled(&src->thread)) { dst->thread.sve_state = kzalloc(sve_state_size(src), -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel