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 A771DC433EF for ; Mon, 11 Oct 2021 12:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8963660F3A for ; Mon, 11 Oct 2021 12:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236641AbhJKMkV (ORCPT ); Mon, 11 Oct 2021 08:40:21 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3961 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236688AbhJKMkU (ORCPT ); Mon, 11 Oct 2021 08:40:20 -0400 Received: from fraeml743-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HSdXs5TRbz689n8; Mon, 11 Oct 2021 20:34:53 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml743-chm.china.huawei.com (10.206.15.224) 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:38:18 +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:38:17 +0100 Date: Mon, 11 Oct 2021 13:37:59 +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 24/38] arm64/sme: Implement traps and syscall handling for SME Message-ID: <20211011133759.000042c4@Huawei.com> In-Reply-To: <20210930181144.10029-25-broonie@kernel.org> References: <20210930181144.10029-1-broonie@kernel.org> <20210930181144.10029-25-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:30 +0100 Mark Brown wrote: > By default all SME operations in userspace will trap. When this happens > we allocate storage space for the SME register state, set up the SVE > registers and disable traps. We do not need to initialize ZA since the > architecture guarantees that it will be zeroed when enabled and when we > trap ZA is disabled. > > On syscall we exit streaming mode if we were previously in it and ensure > that all but the lower 128 bits of the registers are zeroed while > preserving the state of ZA. This follows the aarch64 PCS for SME, ZA > state is preserved over a function call and streaming mode is exited. > Since the traps for SME do not distinguish between streaming mode SVE > and ZA usage if ZA is in use rather than reenabling traps we instead > zero the parts of the SVE registers not shared with FPSIMD and leave SME > enabled, this simplifies handling SME traps. If ZA is not in use then we > reenable SME traps and fall through to normal handling of SVE. > > Signed-off-by: Mark Brown ... continuing the trivial theme of my review today... > > /* > * task_fpsimd_load() won't be called to update CPACR_EL1 in > - * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which only > - * happens if a context switch or kernel_neon_begin() or context > - * modification (sigreturn, ptrace) intervenes. > - * So, ensure that CPACR_EL1 is already correct for the fast-path case. > + * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which > + * only happens if a context switch or kernel_neon_begin() or Why the rewrap here? > + * context modification (sigreturn, ptrace) intervenes. So, > + * ensure that CPACR_EL1 is already correct for the fast-path > + * case. > */ > sve_user_disable(); > } > > void do_el0_svc(struct pt_regs *regs) > { > - sve_user_discard(); > + fp_user_discard(); > el0_svc_common(regs, regs->regs[8], __NR_syscalls, sys_call_table); > } > 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 232EAC433F5 for ; Mon, 11 Oct 2021 12:40:07 +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 E56A060F3A for ; Mon, 11 Oct 2021 12:40:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E56A060F3A 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=4sYgQbGS+Cc//M4sTms74xrX43k84ZtPQXKIJrEcgMM=; b=LUy+zWQ6zet2kU fizHXLx0e9TngDBhvX6MADW119Jkmwtre4DmIEGHRrMwxwGsdX/D/OlM4NiHZzflonDKxIZbiQcDz H1K0z2k2rM6ZrFMjCsYoua/jLfFgke/uDat+1FgGOS+OC2EtCmUYqaiIDN27SbgHifuJQQUBkMGC3 NqMyvBUIrblKo03qKMCC/R3q20n1Ohr3/ziHCYi1DKHQQu30sFveOPRvkyofrBZLRCmAILkqbOqrI s6cPx2ScHQWl0/9k19IGqWjjIyR1NSYBrehr5WVOvojB90kdKIpJmf02nOeVCy9tFZ2jFSBgekRJs cycMg5oc2RCJLSOYMBVg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZuZV-009Mpd-R6; Mon, 11 Oct 2021 12:38:26 +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 1mZuZR-009Mo1-EW for linux-arm-kernel@lists.infradead.org; Mon, 11 Oct 2021 12:38:23 +0000 Received: from fraeml743-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4HSdXs5TRbz689n8; Mon, 11 Oct 2021 20:34:53 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml743-chm.china.huawei.com (10.206.15.224) 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:38:18 +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:38:17 +0100 Date: Mon, 11 Oct 2021 13:37:59 +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 24/38] arm64/sme: Implement traps and syscall handling for SME Message-ID: <20211011133759.000042c4@Huawei.com> In-Reply-To: <20210930181144.10029-25-broonie@kernel.org> References: <20210930181144.10029-1-broonie@kernel.org> <20210930181144.10029-25-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_053821_678484_570B3FD2 X-CRM114-Status: GOOD ( 17.75 ) 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:30 +0100 Mark Brown wrote: > By default all SME operations in userspace will trap. When this happens > we allocate storage space for the SME register state, set up the SVE > registers and disable traps. We do not need to initialize ZA since the > architecture guarantees that it will be zeroed when enabled and when we > trap ZA is disabled. > > On syscall we exit streaming mode if we were previously in it and ensure > that all but the lower 128 bits of the registers are zeroed while > preserving the state of ZA. This follows the aarch64 PCS for SME, ZA > state is preserved over a function call and streaming mode is exited. > Since the traps for SME do not distinguish between streaming mode SVE > and ZA usage if ZA is in use rather than reenabling traps we instead > zero the parts of the SVE registers not shared with FPSIMD and leave SME > enabled, this simplifies handling SME traps. If ZA is not in use then we > reenable SME traps and fall through to normal handling of SVE. > > Signed-off-by: Mark Brown ... continuing the trivial theme of my review today... > > /* > * task_fpsimd_load() won't be called to update CPACR_EL1 in > - * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which only > - * happens if a context switch or kernel_neon_begin() or context > - * modification (sigreturn, ptrace) intervenes. > - * So, ensure that CPACR_EL1 is already correct for the fast-path case. > + * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which > + * only happens if a context switch or kernel_neon_begin() or Why the rewrap here? > + * context modification (sigreturn, ptrace) intervenes. So, > + * ensure that CPACR_EL1 is already correct for the fast-path > + * case. > */ > sve_user_disable(); > } > > void do_el0_svc(struct pt_regs *regs) > { > - sve_user_discard(); > + fp_user_discard(); > el0_svc_common(regs, regs->regs[8], __NR_syscalls, sys_call_table); > } > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel