From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 6F33315CD40 for ; Wed, 19 Jun 2024 23:57:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718841463; cv=none; b=lo8duXF5ODMw1+B1eOl1NpTJXf71nbb/uA1Xye0/iBGuuJm0mw4W6kMaBbYwzNJ98BFfc0/0gx3RUISJ4RHY9QO/FMz29GI9tuRdmd/yv10MfOaDzczmKNmFkDCrUqd4oVQ5mk3Mr2tt+GwTZSxUeAXq+BAqaAFmG+anDAQzBO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718841463; c=relaxed/simple; bh=xBHaFe7VLcuLpxsCjlsn/XmzjfLlJdrvGHOT1OyfrwA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kvgljPPCE3YZKbr7s/mwof2tQbXvpzg1OMQlztQ6Un49U9i/upL3+0ziH4ZkLbVyFafKYTkiY/9vxIkkTh45oN6HXADlgBSM9p7m+iFpi+JvRsQZMgu34W+gl0RSN7KQL5r1WSDiOreMqxyXb69s7+g4bxddI0acGq5g4JISXCg= 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=loGtKFEb; arc=none smtp.client-ip=209.85.214.176 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 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="loGtKFEb" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1f480624d10so2560055ad.1 for ; Wed, 19 Jun 2024 16:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718841462; x=1719446262; darn=lists.linux.dev; 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=Px8N27AOqmnwl/KnT17601Vv0G3wj5EYnZpDzUGAj0Q=; b=loGtKFEbFXgHVFIUKbbTuqSmrxWGBcsIdGwR8jTm30WP0M1Br60q31fM7BRlocZpXm WFjE5+7cxGovWez7SYvImXY0pyqzqLMRIxk0trHGwIi5LtTICO3cCnXJnh/e/zGoESRY SRcl8nvhGC1dQ9Tm94POLB/hE/tFBFK/axDwQzpzJJ2/MN95v8IweOG//b3+0mm32Mm4 oBdN0QmUhSvnpX9aRTnFUa54pJq+zpFW/db1VBySUb3tSQvyHCITrU9LgwlC8z3ambjA fMmNhlfs491AmziFsS+U754+mo4VFn04opGGCBpXzz2U5KtJkRDzpAo5Vxh01/pYfJNQ 6V+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718841462; x=1719446262; 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=Px8N27AOqmnwl/KnT17601Vv0G3wj5EYnZpDzUGAj0Q=; b=NUE4GUYtvwl9oAku7IGCeNrIerKLcms23HFK87sUzz9JfkA8Wi22xGMtD0kt2nzJAi GEuW2qvLSH7FILLxnqTjARIwVLm3KmY5/aTFbfHAmHjzYQ4nzPbBBmtcQKtQNDATZt+p ddTEXtidRlJEx8O/KKXaKWeCSyt66KAsqF974Jet6fu7rBhp98+Zw6LLLmPUvwktRPJh zVS3gZjM4qikX89TCFZA2OwmzrnjUUCtzOWUDOQS27y+uufy/o7QZifgOXNpaJPBImJx p/gXnbqCzkrssuyNXnh8VQE8JU8Sfq/cowD83NIFlJLhBXG33UJOHSi0E+KFVmpvDEqy Djhw== X-Forwarded-Encrypted: i=1; AJvYcCXL/OBdOoSC07TNfRHF/VXvnu8Q0b0JlC+9gWyBbggkUVDXSJk0xrw7fAupVOJP5O0+a/YaNBymitVi2eh2/Q59oD5/K1W+JEKN338= X-Gm-Message-State: AOJu0YyC5P5xZZ1B+yxLMGr0hWdW3fUSoYTSRs4MBygLMtx10VpkWz7F JHVVpaE5hRi/JV7YjfCYIHvjvdbzxDVAv0sdc+CRzpfT4AzdwwvTW3uRqT1Z/rk= X-Google-Smtp-Source: AGHT+IFURITgIHUXPIWfZmHbHQG5F2+TL0ewnmECwvcXqCwzHJzZyz8b56abtJ31GhWKd7wdcoVjcg== X-Received: by 2002:a17:902:dac6:b0:1f6:fbc2:526f with SMTP id d9443c01a7336-1f9aa3e74a9mr33490725ad.32.1718841461778; Wed, 19 Jun 2024 16:57:41 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855e70ae6sm123620745ad.71.2024.06.19.16.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jun 2024 16:57:41 -0700 (PDT) From: Charlie Jenkins Date: Wed, 19 Jun 2024 16:57:21 -0700 Subject: [PATCH v3 08/13] riscv: Add xtheadvector instruction definitions Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240619-xtheadvector-v3-8-bff39eb9668e@rivosinc.com> References: <20240619-xtheadvector-v3-0-bff39eb9668e@rivosinc.com> In-Reply-To: <20240619-xtheadvector-v3-0-bff39eb9668e@rivosinc.com> To: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Corbet , Shuah Khan , Guo Ren , Evan Green , Andy Chiu , Jessica Clarke Cc: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.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=1718841444; l=1957; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=xBHaFe7VLcuLpxsCjlsn/XmzjfLlJdrvGHOT1OyfrwA=; b=U7tzWwho/N+CYyjv6ycLZuv3v/0Gxvil3l+cEZQaFfxVErRfFZmSmrZhbTwGPZz2eqVP4HVTg hIdYdYDPg0oBDxYwrCdKYnpW+bmBtpNSw9zJjs1RETRdIys5x98rJY/ 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: 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.34.1