Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp2425lqh; Fri, 3 May 2024 11:23:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbJotPas+kf196/QkCtZVE0V7bO/F1Qf5XgnNVqn/NfBPJxcdC+Ghd+Ovpdf8kX66tjr71toD618OlRJSwgV0hH/Li92Ns5Qk1mzRWsQ== X-Google-Smtp-Source: AGHT+IGs9qMsFGGFRTeRXdpDgIT0o8FDxPd/w0tdQ57tjNe6Vdxxj0PDISgzJJkFUDU5A7UFTCEg X-Received: by 2002:a17:906:4ecf:b0:a55:77fd:17ff with SMTP id i15-20020a1709064ecf00b00a5577fd17ffmr2094480ejv.32.1714760627791; Fri, 03 May 2024 11:23:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714760627; cv=pass; d=google.com; s=arc-20160816; b=XoSmyy2E9PS3xaWTetqkSi0el5cjx23tGL8r0lbzmZZzd9qQzh3NFSp8o+QbJ/m1gu KD/Gp7SvFuekwgrQx82SsJay1ZoaXNrtsiKhaKdcgTY5LF9zbbbJ41zD+EgiAwQXLjmh tGlqPcGp4p46C1lUlM/S7CXYoQCLCsCSDEilEkTYVEYM6hEVBw/8Amct1KBohyLHjKac 6ZwhkR8pDa6C3MkxZVRC7EADclOaKpFkAMjnXfV/VX57espJOghr6APBflWAHlHAHa7b m8JXgqS9rrffDdqJJveXZ7bxAjzG7Bs1JVadlL7vwCDU8XKE7U/PLo7RJujYSxbQvXXc WFCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=XLBLJWgoI5ONq0p19OcZNiSMS9NNG1Jn9M7ZhOPyPpg=; fh=E69t8PWGROdfIulhAiz/ZVl1Xjerr+lrAErDQjZotU8=; b=uWpby36SP8FI4+usSnyhqQSECMJwnmYmuvpvAZa3d5Tkco1cz2YqrVz8ge9sDzscr5 wVAAorT3gl0cdvWlGiHwvsYFEQ0oQYP6Loovu5rMDKP1N3XEjItvnXA1hu1KpVt6gL8P J+b4ie5FarggsARVgxHKAbtQvFimcZAmw86bBYbgDdsTXw4EpryJcHcAWk7uHJyPOcYR gboIzeiAoCUc9eW2ZS9UbgRXmaUYCUR4vYcH9MQbf2kMqtffa+e2pZvuWQ1EfYUxlJib WEphzmdVaMygzI/WGu6///LVqdyHcIdEPHjwG66ZbbEcM90XaPXJjoFkXdLNwjq5hZ7q pI4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=XNypQBxw; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-168041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168041-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id j23-20020a170906831700b00a593fb9c72bsi1806669ejx.455.2024.05.03.11.23.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 11:23:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=XNypQBxw; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-168041-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168041-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5DE451F2210D for ; Fri, 3 May 2024 18:23:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B95F315B56B; Fri, 3 May 2024 18:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="XNypQBxw" Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7ACD615B140 for ; Fri, 3 May 2024 18:19:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714760349; cv=none; b=FTkviod924Wzv+x1O1nJxZUcHmgwpOpkeSrhjBbmqJkWk2+P6fRQB+ONnVMyW7fBfDDhI5ICy/A0dm1xqmAz2u0M2yOljxwAAzgocUsalyQkmOev1lw0dfjbqCa21Osm598+uVpPRuG75JrxB/9wUPgfes2Q8ft0qBnVLOhy/0c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714760349; c=relaxed/simple; bh=fwxPC9e5acCJKXfvxD0QuLfngnuG8uQUjT/zUUS4iJ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SCNM52IMHXQ3MLYxlYJ+qCgK3yvO/Rye7WS2BbD03z8v8wkP6p1eDwyLdCk4iXZvr5jrWUh+preCJHyB6klNrlM7TJiLmm6s93ckzGEpan9FMLmeauB8O5Du+5L5TL9nxB19ihO5HltHdJgBl7eInpMmIIIPEmSgPasp2rqcjsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=XNypQBxw; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6f450f43971so923b3a.3 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=vger.kernel.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=XNypQBxwAjt1JQAyrYHb6fr1InxLSxJEzQnFFcrdICmoxXIVwvjMEqdcx87Dxb5LD8 JqgMdHf0Ag4vH6LkKj63zDq+uBsxVqJTRBuX/TcWpI32CWok/kIRi4P9IXZ6MhiYipTB ikGpiMWof8IBWqEzoVoyUz1ZW4aGmc4z3skhxvpbBDaXoYV2jPQQ0zi73llygBDq5ITB S8aPNajRPf+fvuQQz342WMRiXKd0KrvkUO0ETaQPGk5M2s4vf+dRMejV7+ct1Cmr4+NJ I9bqvCXwulOR5pmBI2Y2ZOxgKal+c2iW3ZCZWKJ9/rG3LAFwvbVciqlHYA3fA/Vbxjqc +6/g== 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=wuqqopaI+WqkzqBONBLulse4Us7AoOgtXzfZY4VonEZ3qNV/IM5N5QveRYtnbqSHKM ohnNymi3ExZv/PZfH+I4tjEmoN2CIkJNvzJoDGkR0EiHFXmlPW+PeE2qpE7Lmh91OcWh JpdyXlWs2IBE/MU+GiPf9rzFXR7gRhVmb8JPgt3/C1Zo9xh/gQfdxCrvGOZB6Xe7tHes XAFnPblZW6nnlwBirYk/t09ovUipt4/opeWHsD0VMAKEWwrd9PhEkovqqDBBAM4MUHjh sWy8+VIlDw4V7s91fugLJVAjNFfUztRCxbNyy3QiTBx8Q389x1SLi3xupf8QD0NQQ81d broQ== X-Forwarded-Encrypted: i=1; AJvYcCXcUSTwe8cw8Hl+jxqbuFjkbvwUfqM4PAd+0s5V4/WOHX9FZxpXf+xo7r9XJcpYEIU+qf4J7x2TpIg1OJeovH1C1Qrw2gJwRcOx9WjW X-Gm-Message-State: AOJu0YzZ6R1vTmcyZk34/QrhrDnuuc9Gl0WK99DzJNMfrsE8tLfGId4U vpmcYli7+smH1uo9aLKOJhoXivP5hfB6za48NUo7x6VpLC34hQKph6osvmQCdxY= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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?q?Cl=C3=A9ment_L=C3=A9ger?= , 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= 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 -- 2.44.0