From patchwork Fri May 3 18:18:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 13653383 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 B7528C25B5C for ; Fri, 3 May 2024 19:31: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=MVN2vx+c6BPOsFEJR+92PTq7JRIeiBBYJbwaTeacLp4=; b=iRu3oiUO8c/LET JvkSR1KUtV4VeB7KJHb9IecWN7d19z8/WbFz/A6Hy7zbVdYa5HSlglFemkCZGggxSUypM+1fOXM3C UXkvDpeQb4Mff2g13EjtMI3I2MzMC98EaezCM1LhSgibj+mG0KnaJZ8TGg6yeDyV2KwXkQ5/0//Y/ b+0KWPRHVkmx2mhgs4BgbB9VqMzj9wAcinPPIgUn6MKNyLj3kSH/0LTz+UmXOzyn5Zm6NfahUwjDn a7azujWnsxzJrPRaNttExFXDyI4fNq+I7dFTQIuLbFiKduY7/hCq8sqKCdFRyuBvOr3I2lmY+ncpa Ox8GfCWP9az7ur9Wq6ow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2ydJ-00000000Awq-3v20; Fri, 03 May 2024 19:31:49 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2xUz-0000000HX4o-47oX for linux-arm-kernel@lists.infradead.org; Fri, 03 May 2024 18:19:22 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6f44b5e7f07so2567b3a.2 for ; Fri, 03 May 2024 11:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714760348; x=1715365148; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=XLBLJWgoI5ONq0p19OcZNiSMS9NNG1Jn9M7ZhOPyPpg=; b=q+H8YrJcGBsNa7HLvjFazfJ4ucis4rncGZtoONBx+r6cBGouzxjB/2FDe/hQW8MoPW 62jMrdhyqNHiOm77oCLHYpQKP26+evFKMna6kXQnnQ+54WgqcShdfj6YJrc7a0psSO1G d9ZNQlUiSbOfjn425NKAQX0fLhPW19pzsFeTrat1Cm965+5rkcd/6siYrGZwi2fxt3Qj ak+dtZxE3CDpaxB022oC8GFaQ1FqwYBLrdkfJtOvjr8SAJWRqAfrU17Kc6d17m0aiWK7 BChlOYo8d4M0g1CsVgidw+w8d8DiT0v2968JH1T5Hho73NMF8eFMBoWxzo5CFyMPlUZp QFwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714760348; x=1715365148; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XLBLJWgoI5ONq0p19OcZNiSMS9NNG1Jn9M7ZhOPyPpg=; b=xMNZyd7ixdfB2UXLXlg8m9yOSBppi/Ez6555doRsUWe+gmHpd+/pg3xUEOAypTGzQv 7ZP3f4+rAOhOX3P20fMoCLeDu25egzmiGFi0h2SPhgGv6Lm/BZLQXXZhqn0hCPqCurCe WEfCmJj2AVEIuJRMh8RNPxyQZJC6e0EJ9XB0d0FaJjKcAzvO/yca2lvIKesgtTlSLP9b O5jGbMXFDHwolJAu/vEKLXDRqSAY5UFku7XIGXneHj1arpKA2XggUfgjOywqH3IVakL7 SZVCFhqed4QtcqdOVKLy7ipooQ3VIHJgSOy6yJbi0JiOkbZP+GX2Fh9p0xaByruGVV2b Ag2g== X-Forwarded-Encrypted: i=1; AJvYcCVej3hKiHVWdjaBRbiLUnshPCmqPglaaHtSrU0DNtRjXaM+3+tzjkZvYdYafWrb6M4OXeEfpehCcJbCBvL5LIg2tDRZgNKcLRF1zkD3PjRXjHA+ylE= X-Gm-Message-State: AOJu0YwUIrYOkjLQ2Lr7TtkdXvFgyBUHIT8eHSZm2R/17/6npvjTzq3p URmMByst/SBn09Y6AIuQoOiIxGGyBdIrwlsV/PaKq16RmoEG+Erv5chbI5TnpoU= X-Google-Smtp-Source: AGHT+IFpd0GjwjtDFrGFdOgb28GX7E5A84WrU9nww/Fc6oikSNFplYSG78IpCN90Vvy5bJGvfi7P+Q== X-Received: by 2002:a05:6a00:8c4:b0:6e6:89ad:1233 with SMTP id s4-20020a056a0008c400b006e689ad1233mr4026532pfu.2.1714760347890; Fri, 03 May 2024 11:19:07 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id fu6-20020a056a00610600b006f3f5d3595fsm3355421pfb.80.2024.05.03.11.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:19:07 -0700 (PDT) From: Charlie Jenkins Date: Fri, 03 May 2024 11:18:27 -0700 Subject: [PATCH v6 12/17] riscv: Add xtheadvector instruction definitions MIME-Version: 1.0 Message-Id: <20240503-dev-charlie-support_thead_vector_6_9-v6-12-cb7624e65d82@rivosinc.com> References: <20240503-dev-charlie-support_thead_vector_6_9-v6-0-cb7624e65d82@rivosinc.com> In-Reply-To: <20240503-dev-charlie-support_thead_vector_6_9-v6-0-cb7624e65d82@rivosinc.com> To: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Guo Ren , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Conor Dooley , Evan Green , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Jonathan Corbet , Shuah Khan Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Charlie Jenkins , Heiko Stuebner X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714760319; l=1908; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=fwxPC9e5acCJKXfvxD0QuLfngnuG8uQUjT/zUUS4iJ0=; b=Onr8XJTzFkGHOux99DIgUZXs1b9d+YcK226SmnBPnkCifc4zEA/CelPcAWTyhcOig7svSCUUI loL72CiVW4xBpDmLkunPNu4gWtqd89zT8YDIgri2Nv/sOqXqJzDCf47 X-Developer-Key: i=charlie@rivosinc.com; a=ed25519; pk=t4RSWpMV1q5lf/NWIeR9z58bcje60/dbtxxmoSfBEcs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240503_111910_197463_E74F581F X-CRM114-Status: GOOD ( 12.11 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org xtheadvector uses different encodings than standard vector for vsetvli and vector loads/stores. Write the instruction formats to be used in assembly code. Co-developed-by: Heiko Stuebner Signed-off-by: Charlie Jenkins --- arch/riscv/include/asm/vendor_extensions/thead.h | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/riscv/include/asm/vendor_extensions/thead.h b/arch/riscv/include/asm/vendor_extensions/thead.h index 48421d1553ad..27a253a20ab8 100644 --- a/arch/riscv/include/asm/vendor_extensions/thead.h +++ b/arch/riscv/include/asm/vendor_extensions/thead.h @@ -13,4 +13,30 @@ extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_thead; +/* Extension specific helpers */ + +/* + * Vector 0.7.1 as used for example on T-Head Xuantie cores, uses an older + * encoding for vsetvli (ta, ma vs. d1), so provide an instruction for + * vsetvli t4, x0, e8, m8, d1 + */ +#define THEAD_VSETVLI_T4X0E8M8D1 ".long 0x00307ed7\n\t" +#define THEAD_VSETVLI_X0X0E8M8D1 ".long 0x00307057\n\t" + +/* + * While in theory, the vector-0.7.1 vsb.v and vlb.v result in the same + * encoding as the standard vse8.v and vle8.v, compilers seem to optimize + * the call resulting in a different encoding and then using a value for + * the "mop" field that is not part of vector-0.7.1 + * So encode specific variants for vstate_save and _restore. + */ +#define THEAD_VSB_V_V0T0 ".long 0x02028027\n\t" +#define THEAD_VSB_V_V8T0 ".long 0x02028427\n\t" +#define THEAD_VSB_V_V16T0 ".long 0x02028827\n\t" +#define THEAD_VSB_V_V24T0 ".long 0x02028c27\n\t" +#define THEAD_VLB_V_V0T0 ".long 0x012028007\n\t" +#define THEAD_VLB_V_V8T0 ".long 0x012028407\n\t" +#define THEAD_VLB_V_V16T0 ".long 0x012028807\n\t" +#define THEAD_VLB_V_V24T0 ".long 0x012028c07\n\t" + #endif