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 E2591C433EF for ; Tue, 19 Oct 2021 17:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB76361212 for ; Tue, 19 Oct 2021 17:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234594AbhJSR0h (ORCPT ); Tue, 19 Oct 2021 13:26:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:54638 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbhJSR0g (ORCPT ); Tue, 19 Oct 2021 13:26:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F1ED46135F; Tue, 19 Oct 2021 17:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634664263; bh=/s17ACmwQy08kqs9COdIwwDs64OctXotUwEPO09KCro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHM6k8V6uh3p0aS2ITnxe94wc3DfitjvXTzaH4s6C98WFpXR3s4JbDSTDrGlt98KN rpPit20ihKd0RD0H1/5nxx5+3UZNUfkKAGa5heWs3ojT1U5Dh3TittyPT6HLBr6Cs9 2yAAViXZqzUCLJuMFQ3DgNprldXJ4B5rh8YqqSsaIOshs1q3UFMVWl384HnAZoWWdn te6iDpkvwbAjikIhhlKPOxZJ3DK318CI2RCU9/bTjGJBeFJSni5x9JPwzODcZedhAg IDZol07+eHrfwU9mmYX+vQPa9N59mItxDFR2GqfBkMWLdcTPstvlJU2OYmxxpT78gW Uz5TH6jtbdL4g== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: Alan Hayward , Luis Machado , Salil Akerkar , Basant Kumar Dwivedi , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v3 17/42] arm64/sme: Define macros for manually encoding SME instructions Date: Tue, 19 Oct 2021 18:22:22 +0100 Message-Id: <20211019172247.3045838-18-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211019172247.3045838-1-broonie@kernel.org> References: <20211019172247.3045838-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2142; h=from:subject; bh=/s17ACmwQy08kqs9COdIwwDs64OctXotUwEPO09KCro=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhbv7Rrw5kle1YF8ZEm/3MKeZcjPjoYvDoDW0KkPN4 lZQMlOuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYW7+0QAKCRAk1otyXVSH0HfOB/ 0Rgc7fa9tFv+YSzyepuBgXH0tiMxdWPT+cpkhNSrw4txBPVU3A8wjvxeFLiIdrzFam2ebTVfJ5KeZw xcnrQ4VEEUdAcdWB9b1LpgF539xgwkK1ziirm1a3UCcCd0ZOgdJVPbX8LXSK48+o9HlC0MbJG0OVCj esEvJgTCzC9qX7KnOQJSzyqB8J7dB2WtaCWCqz8Yjy/Zx5PmHXdwhAFCA+sT92z5QfRnLglf5/TIwa g7lykWjd1ZQOwfRiVfwimyCUsnzJzNhplFIhceZRVVly9eobyNOiR5Enx7kDtlpKrIxxnYdz7zkzhx pFqHPKCX6gaUm1fjcb9E3LETbv5ex1 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org As with SVE rather than impose ambitious toolchain requirements for SME we manually encode the few instructions which we require in order to perform the work the kernel needs to do. That is currently: - Vector store and load for the ZA array. - Zeroing of the whole ZA array. This does not include the SMSTART and SMSTOP instructions which are single instructions and only used from C code, a later patch will define them as inline assembly. Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimdmacros.h | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h index 2509d7dde55a..f9fb5f111758 100644 --- a/arch/arm64/include/asm/fpsimdmacros.h +++ b/arch/arm64/include/asm/fpsimdmacros.h @@ -93,6 +93,12 @@ .endif .endm +.macro _sme_check_wv v + .if (\v) < 12 || (\v) > 15 + .error "Bad vector select register \v." + .endif +.endm + /* SVE instruction encodings for non-SVE-capable assemblers */ /* (pre binutils 2.28, all kernel capable clang versions support SVE) */ @@ -174,6 +180,44 @@ | (\np) .endm +/* SME instruction encodings for non-SME-capable assemblers */ + +/* + * STR (vector from ZA array): + * STR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL] + */ +.macro _sme_str_zav nw, nxbase, offset=0 + _sme_check_wv \nw + _check_general_reg \nxbase + _check_num (\offset), -0x100, 0xff + .inst 0xe1200000 \ + | (((\nw) & 3) << 13) \ + | ((\nxbase) << 5) \ + | ((\offset) & 7) +.endm + +/* + * LDR (vector to ZA array): + * LDR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL] + */ +.macro _sme_ldr_zav nw, nxbase, offset=0 + _sme_check_wv \nw + _check_general_reg \nxbase + _check_num (\offset), -0x100, 0xff + .inst 0xe1000000 \ + | (((\nw) & 3) << 13) \ + | ((\nxbase) << 5) \ + | ((\offset) & 7) +.endm + +/* + * Zero the entire ZA array + * ZERO ZA + */ +.macro zero_za + .inst 0xc00800ff +.endm + .macro __for from:req, to:req .if (\from) == (\to) _for__body %\from -- 2.30.2 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 DA1D6C433F5 for ; Tue, 19 Oct 2021 17:35:35 +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 9DA4C61355 for ; Tue, 19 Oct 2021 17:35:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9DA4C61355 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9a0mesp1o4QCt3xy7VLMZHvtq/QiokTJZugVcWexKdo=; b=vitO3/7FN8ufxm ghTUHcNx+HL7EhtsJp9nEkqmB9bFh1G4LsK6a2aVsHaG+uAkj/CifUY+o+sCsqGWirTo68CpEc2yf +RpTnyeG/1NQ3RSaryHIgMHq+QmPyM7RuwyGVzL+wR75+B1x/ZOzdYWatcG1lUToIzyywiH/0pWKN 0JA+UpSV/qFEybSIsL+KwYXjYp7ccaSIOixRbCYt2pBXSnXrgPM6TFn6naVAiaeKC3rOzd4kEbFoE lBAM+OLGsqGxg9US3v08KKzj+8x5gUpiiZamSu0OAogm/7LClR7W3e6U2wttE8+g7BgRBd/JbZuR7 CtERaIV0UVxtj1oYgMlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcszT-00294c-03; Tue, 19 Oct 2021 17:33:31 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcsqd-0025Bx-RI for linux-arm-kernel@lists.infradead.org; Tue, 19 Oct 2021 17:24:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id F1ED46135F; Tue, 19 Oct 2021 17:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634664263; bh=/s17ACmwQy08kqs9COdIwwDs64OctXotUwEPO09KCro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHM6k8V6uh3p0aS2ITnxe94wc3DfitjvXTzaH4s6C98WFpXR3s4JbDSTDrGlt98KN rpPit20ihKd0RD0H1/5nxx5+3UZNUfkKAGa5heWs3ojT1U5Dh3TittyPT6HLBr6Cs9 2yAAViXZqzUCLJuMFQ3DgNprldXJ4B5rh8YqqSsaIOshs1q3UFMVWl384HnAZoWWdn te6iDpkvwbAjikIhhlKPOxZJ3DK318CI2RCU9/bTjGJBeFJSni5x9JPwzODcZedhAg IDZol07+eHrfwU9mmYX+vQPa9N59mItxDFR2GqfBkMWLdcTPstvlJU2OYmxxpT78gW Uz5TH6jtbdL4g== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: Alan Hayward , Luis Machado , Salil Akerkar , Basant Kumar Dwivedi , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v3 17/42] arm64/sme: Define macros for manually encoding SME instructions Date: Tue, 19 Oct 2021 18:22:22 +0100 Message-Id: <20211019172247.3045838-18-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211019172247.3045838-1-broonie@kernel.org> References: <20211019172247.3045838-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2142; h=from:subject; bh=/s17ACmwQy08kqs9COdIwwDs64OctXotUwEPO09KCro=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhbv7Rrw5kle1YF8ZEm/3MKeZcjPjoYvDoDW0KkPN4 lZQMlOuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYW7+0QAKCRAk1otyXVSH0HfOB/ 0Rgc7fa9tFv+YSzyepuBgXH0tiMxdWPT+cpkhNSrw4txBPVU3A8wjvxeFLiIdrzFam2ebTVfJ5KeZw xcnrQ4VEEUdAcdWB9b1LpgF539xgwkK1ziirm1a3UCcCd0ZOgdJVPbX8LXSK48+o9HlC0MbJG0OVCj esEvJgTCzC9qX7KnOQJSzyqB8J7dB2WtaCWCqz8Yjy/Zx5PmHXdwhAFCA+sT92z5QfRnLglf5/TIwa g7lykWjd1ZQOwfRiVfwimyCUsnzJzNhplFIhceZRVVly9eobyNOiR5Enx7kDtlpKrIxxnYdz7zkzhx pFqHPKCX6gaUm1fjcb9E3LETbv5ex1 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-20211019_102423_962575_ADF34DBD X-CRM114-Status: GOOD ( 11.25 ) 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 As with SVE rather than impose ambitious toolchain requirements for SME we manually encode the few instructions which we require in order to perform the work the kernel needs to do. That is currently: - Vector store and load for the ZA array. - Zeroing of the whole ZA array. This does not include the SMSTART and SMSTOP instructions which are single instructions and only used from C code, a later patch will define them as inline assembly. Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimdmacros.h | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/arm64/include/asm/fpsimdmacros.h b/arch/arm64/include/asm/fpsimdmacros.h index 2509d7dde55a..f9fb5f111758 100644 --- a/arch/arm64/include/asm/fpsimdmacros.h +++ b/arch/arm64/include/asm/fpsimdmacros.h @@ -93,6 +93,12 @@ .endif .endm +.macro _sme_check_wv v + .if (\v) < 12 || (\v) > 15 + .error "Bad vector select register \v." + .endif +.endm + /* SVE instruction encodings for non-SVE-capable assemblers */ /* (pre binutils 2.28, all kernel capable clang versions support SVE) */ @@ -174,6 +180,44 @@ | (\np) .endm +/* SME instruction encodings for non-SME-capable assemblers */ + +/* + * STR (vector from ZA array): + * STR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL] + */ +.macro _sme_str_zav nw, nxbase, offset=0 + _sme_check_wv \nw + _check_general_reg \nxbase + _check_num (\offset), -0x100, 0xff + .inst 0xe1200000 \ + | (((\nw) & 3) << 13) \ + | ((\nxbase) << 5) \ + | ((\offset) & 7) +.endm + +/* + * LDR (vector to ZA array): + * LDR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL] + */ +.macro _sme_ldr_zav nw, nxbase, offset=0 + _sme_check_wv \nw + _check_general_reg \nxbase + _check_num (\offset), -0x100, 0xff + .inst 0xe1000000 \ + | (((\nw) & 3) << 13) \ + | ((\nxbase) << 5) \ + | ((\offset) & 7) +.endm + +/* + * Zero the entire ZA array + * ZERO ZA + */ +.macro zero_za + .inst 0xc00800ff +.endm + .macro __for from:req, to:req .if (\from) == (\to) _for__body %\from -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel