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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1078C433F5 for ; Mon, 11 Oct 2021 12:27:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BB9860E9C for ; Mon, 11 Oct 2021 12:27:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234752AbhJKM3q (ORCPT ); Mon, 11 Oct 2021 08:29:46 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3960 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbhJKM3q (ORCPT ); Mon, 11 Oct 2021 08:29:46 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HSdJg6v6Hz689Qs; Mon, 11 Oct 2021 20:24:19 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 11 Oct 2021 14:27:44 +0200 Received: from localhost (10.52.122.204) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 11 Oct 2021 13:27:43 +0100 Date: Mon, 11 Oct 2021 13:27:25 +0100 From: Jonathan Cameron To: Mark Brown CC: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan , "Alan Hayward" , Luis Machado , "Salil Akerkar" , Basant Kumar Dwivedi , Szabolcs Nagy , , Subject: Re: [PATCH v1 23/38] arm64/sme: Implement ZA context switching Message-ID: <20211011132725.00000f47@Huawei.com> In-Reply-To: <20210930181144.10029-24-broonie@kernel.org> References: <20210930181144.10029-1-broonie@kernel.org> <20210930181144.10029-24-broonie@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.52.122.204] X-ClientProxiedBy: lhreml723-chm.china.huawei.com (10.201.108.74) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Thu, 30 Sep 2021 19:11:29 +0100 Mark Brown wrote: > Allocate space for storing ZA on first access to SME and use that to save > and restore ZA state when context switching. We do this by using the vector > form of the LDR and STR ZA instructions, these do not require streaming > mode and have implementation recommendations that they avoid contention > issues in shared SMCU implementations. > > Since ZA is architecturally guaranteed to be zeroed when enabled we do not > need to explicitly zero ZA, either we will be restoring from a saved copy > or trapping on first use of SME so we know that ZA must be disabled. > > Signed-off-by: Mark Brown sme_alloc() forwards definition should be in the next patch. > --- > arch/arm64/include/asm/fpsimd.h | 5 ++++- > arch/arm64/include/asm/fpsimdmacros.h | 22 ++++++++++++++++++++++ > arch/arm64/include/asm/processor.h | 1 + > arch/arm64/kernel/entry-fpsimd.S | 22 ++++++++++++++++++++++ > arch/arm64/kernel/fpsimd.c | 16 ++++++++++------ > arch/arm64/kvm/fpsimd.c | 2 +- > 6 files changed, 60 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h > index 43737ca91f1a..45f7153067bb 100644 > --- a/arch/arm64/include/asm/fpsimd.h > +++ b/arch/arm64/include/asm/fpsimd.h > @@ -47,7 +47,7 @@ extern void fpsimd_update_current_state(struct user_fpsimd_state const *state); > > extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state, > void *sve_state, unsigned int sve_vl, > - unsigned int sme_vl); > + void *za_state, unsigned int sme_vl); > > extern void fpsimd_flush_task_state(struct task_struct *target); > extern void fpsimd_save_and_flush_cpu_state(void); > @@ -90,6 +90,8 @@ extern void sve_flush_live(bool flush_ffr, unsigned long vq_minus_1); > extern unsigned int sve_get_vl(void); > extern void sve_set_vq(unsigned long vq_minus_1); > extern void sme_set_vq(unsigned long vq_minus_1); > +extern void sme_save_state(void *state, unsigned int vq_minus_1); > +extern void sme_load_state(void const *state, unsigned int vq_minus_1); > > struct arm64_cpu_capabilities; > extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused); > @@ -119,6 +121,7 @@ static inline unsigned int __bit_to_vq(unsigned int bit) > extern size_t sve_state_size(struct task_struct const *task); > > extern void sve_alloc(struct task_struct *task); > +extern void sme_alloc(struct task_struct *task); Should be in the next patch where this function is introduced. > extern void fpsimd_release_task(struct task_struct *task); > extern void fpsimd_sync_to_sve(struct task_struct *task); > extern void sve_sync_to_fpsimd(struct task_struct *task); 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A326C433EF for ; Mon, 11 Oct 2021 12:30:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5DDCB60E9C for ; Mon, 11 Oct 2021 12:30:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5DDCB60E9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=Huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VStv9bXkKs+OH9jttENoj5gfyv9hXgFKpncaI+MPRUM=; b=X4v3H6/jDKr+kB rElNmXWo1CLkotURJavE/DXVXYgo/YuQXvq2+zj2M7AfhbzEsMU2B+mLKcjPIJXKcsHa5B3wZSMlK zlv6i7UsZNAalV7s3o1PKx3rnsAYCkcmLr8iTZBe/1xPErIv4Vbnl2kKuKNHR5SwiIPiVfXESGV9X xkZ+Wb1P5FYgALq5ejCVTQnaJMF6OU+a0rdDrd99lj1ZJ0YD+PCq3oZS0tqYAWUe4a+fZydtbXfkp wWvvIVR1DpwEDSv7MDtgyq3DxuMomcOGZdi8R+YGLd7EcK0GqUApT5vIcXp7glFT4vCvxAzXsIx4S /1e1f39D94XjHnqnMhdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZuPI-009K9t-Ct; Mon, 11 Oct 2021 12:27:52 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZuPD-009K8t-La for linux-arm-kernel@lists.infradead.org; Mon, 11 Oct 2021 12:27:49 +0000 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HSdJg6v6Hz689Qs; Mon, 11 Oct 2021 20:24:19 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 11 Oct 2021 14:27:44 +0200 Received: from localhost (10.52.122.204) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Mon, 11 Oct 2021 13:27:43 +0100 Date: Mon, 11 Oct 2021 13:27:25 +0100 From: Jonathan Cameron To: Mark Brown CC: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan , "Alan Hayward" , Luis Machado , "Salil Akerkar" , Basant Kumar Dwivedi , Szabolcs Nagy , , Subject: Re: [PATCH v1 23/38] arm64/sme: Implement ZA context switching Message-ID: <20211011132725.00000f47@Huawei.com> In-Reply-To: <20210930181144.10029-24-broonie@kernel.org> References: <20210930181144.10029-1-broonie@kernel.org> <20210930181144.10029-24-broonie@kernel.org> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.52.122.204] X-ClientProxiedBy: lhreml723-chm.china.huawei.com (10.201.108.74) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211011_052748_038051_CA5D2FA4 X-CRM114-Status: GOOD ( 17.77 ) 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 On Thu, 30 Sep 2021 19:11:29 +0100 Mark Brown wrote: > Allocate space for storing ZA on first access to SME and use that to save > and restore ZA state when context switching. We do this by using the vector > form of the LDR and STR ZA instructions, these do not require streaming > mode and have implementation recommendations that they avoid contention > issues in shared SMCU implementations. > > Since ZA is architecturally guaranteed to be zeroed when enabled we do not > need to explicitly zero ZA, either we will be restoring from a saved copy > or trapping on first use of SME so we know that ZA must be disabled. > > Signed-off-by: Mark Brown sme_alloc() forwards definition should be in the next patch. > --- > arch/arm64/include/asm/fpsimd.h | 5 ++++- > arch/arm64/include/asm/fpsimdmacros.h | 22 ++++++++++++++++++++++ > arch/arm64/include/asm/processor.h | 1 + > arch/arm64/kernel/entry-fpsimd.S | 22 ++++++++++++++++++++++ > arch/arm64/kernel/fpsimd.c | 16 ++++++++++------ > arch/arm64/kvm/fpsimd.c | 2 +- > 6 files changed, 60 insertions(+), 8 deletions(-) > > diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h > index 43737ca91f1a..45f7153067bb 100644 > --- a/arch/arm64/include/asm/fpsimd.h > +++ b/arch/arm64/include/asm/fpsimd.h > @@ -47,7 +47,7 @@ extern void fpsimd_update_current_state(struct user_fpsimd_state const *state); > > extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state, > void *sve_state, unsigned int sve_vl, > - unsigned int sme_vl); > + void *za_state, unsigned int sme_vl); > > extern void fpsimd_flush_task_state(struct task_struct *target); > extern void fpsimd_save_and_flush_cpu_state(void); > @@ -90,6 +90,8 @@ extern void sve_flush_live(bool flush_ffr, unsigned long vq_minus_1); > extern unsigned int sve_get_vl(void); > extern void sve_set_vq(unsigned long vq_minus_1); > extern void sme_set_vq(unsigned long vq_minus_1); > +extern void sme_save_state(void *state, unsigned int vq_minus_1); > +extern void sme_load_state(void const *state, unsigned int vq_minus_1); > > struct arm64_cpu_capabilities; > extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused); > @@ -119,6 +121,7 @@ static inline unsigned int __bit_to_vq(unsigned int bit) > extern size_t sve_state_size(struct task_struct const *task); > > extern void sve_alloc(struct task_struct *task); > +extern void sme_alloc(struct task_struct *task); Should be in the next patch where this function is introduced. > extern void fpsimd_release_task(struct task_struct *task); > extern void fpsimd_sync_to_sve(struct task_struct *task); > extern void sve_sync_to_fpsimd(struct task_struct *task); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel