Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp1479661lqt; Sat, 20 Apr 2024 18:16:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtWb4mA4Yk2/KN7XD3IlSGTrZcIoPXalhX9BZAXJXb6erXqN1sM8/qsE2NKm0TtTT4aCx1bQ7lVLY15f0hmirisL2dr1KqLbEn+tQA4A== X-Google-Smtp-Source: AGHT+IGMv/uf4b/QbpQI5wC9NIBsgSkcH8GVWNiiIV7kNQ7hftmb35iAjIKuFslkKyTlHBXJy6TW X-Received: by 2002:a50:d715:0:b0:56e:33fe:5e88 with SMTP id t21-20020a50d715000000b0056e33fe5e88mr3675945edi.34.1713662217785; Sat, 20 Apr 2024 18:16:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713662217; cv=pass; d=google.com; s=arc-20160816; b=sCcXGU7j5F9bky1Mq0/9/u3Q3x2XaRJIQnK6Ui6SoKuBO/8/PK78D9gfbVLUzbUJC+ wFkzaOdxcJFAcBJXk5AYkGAOW4SvzYhftSq20wJzp574uknRWjOqlQ690ZYtNdDrtRlN 0DOZfeNFxH+D3cCr4eIwUScC86CKwwZVzhppKjLikaORgc2bg0PZ5RWvxdhscpRic523 KFhGtRXElCRaGq0Ns6lnfXxUa91MOHXQtvA92c4lNaZCEQJB58OUfYTMGE/Opm+ve/F3 LyzwqHioBIdReJPh+GXTqD9YsKjjnGDheqBNRRcD48bxO2klY+WVoGKX5OIIX8O9eQLy UOVw== 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=A7WZZ9B05w7yOdiDdmOf8xUgYc+IvuHvU5nr8Ugv9mw=; fh=YBC5kIOrM4cUWa04zWHpB3BeUfDE+kp4Ugq5WxrQCdY=; b=we5e6ttgGVWwyBa2uqpOa/hb6hw50neWgzjwDdm2Xr+vFriT5oxQivsCbtWwLbK5uh n261Bym8KK8gDn+GpFzyacTzsAfOtGgusFeh1tePfBXMKYXC9bonrAMVpDREaHiLiEmU IhGwuHu69Vc15NyJb2myzc2lSw3yf12SLtv5k1nC0SEHCstREbVIBSG4Qv4dG+XtLXHo HKODbLdTl4NwrPVaJ+G8q9V52Fh+5AS8/Uko+Jzp/Ra4r+yuYeAhZrYRQP+1I9lRNBCW iZBMjGKdrPkekF3S+a0rLT4lBlRzlNOtJe0bVctbwvSQtANOuS99ZKr4dmXP2//NjAi+ f/2A==; 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="oH/lYKXp"; 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-152415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152415-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f15-20020a056402354f00b00572024ec570si186234edd.529.2024.04.20.18.16.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 18:16:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="oH/lYKXp"; 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-152415-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152415-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 E39781F23BE3 for ; Sun, 21 Apr 2024 01:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C356A22EE3; Sun, 21 Apr 2024 01:05:12 +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="oH/lYKXp" Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.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 4F6931CF87 for ; Sun, 21 Apr 2024 01:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713661511; cv=none; b=Np/nW9i/C6NhC9iM23Ycou3RfE0qgnOfLKVTWENWTjJuwMHM8fCy/vkTW2s84Pp4cydw6SewtjrKMXpY7x/34ZvWBlrfjQzBV/IWOULKSa1TqEaXcyQJUoEOeq2B02C3NQHf+THRPVBq6KkDe8PKSC+C7m1f8j6iYvQdfP9iB/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713661511; c=relaxed/simple; bh=/S5mXvNckx5pf6RsnXH2juTR+JzZCbCosBXwMflqUFg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XAj/GvVg9Q1bIHGXpJ7rRUg1iTMtb+snYATsqziUGL82fqadX7Q/V2QwIjdtF17wueItBxdc/Cxo8p8bFcCMbygbOcC98YQwro3DeBxF4mSyTRRUdz5gBOCh49fj7owaKMAO17eFb4BFISUJ9fKvyIgxr+Nk9GTejdAFgjssRM0= 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=oH/lYKXp; arc=none smtp.client-ip=209.85.215.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 Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-517ab9a4a13so2445738a12.1 for ; Sat, 20 Apr 2024 18:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713661510; x=1714266310; 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=A7WZZ9B05w7yOdiDdmOf8xUgYc+IvuHvU5nr8Ugv9mw=; b=oH/lYKXpgM6cv3VphP4XrY99Q8cFj5o+7jf6i54euI5SJRweqmGLCLHmzqZssc1bAt nOJKaGYGiUdh+lAZxYtnFCfjea16iht70Z20u/8lGWDB/utTR0IBNZ8Fy//XMIUJupSd 9Bm3FR4uzqrwhMnVZsUOenZDiZUPnPdFQxiZU7p9yCnTJgTMBknskA15VFjFHah0cqIK s4emPjNa3Pvkqytft5vi0pbg10FzizOnF3QD2wq23Qn+BGCFDi0LP8A2bt1SvHip7kfb vDsH9JGmPqENDQTA93Epip2feiR4brRa/lZboYr/FiamGHYe75SyT9gZDN0Cbi7VLsLe 7GpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713661510; x=1714266310; 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=A7WZZ9B05w7yOdiDdmOf8xUgYc+IvuHvU5nr8Ugv9mw=; b=LLBDacpiaBAw9Sm/hVebKmiMOjetUukqSuk5EFhPlNBAVN/K1lC5Xg84ZD069/6VfQ FkJVN9k2149Lp+YKLgTBoR1P+rZBRcv/ugenDOb4mDlLPQ5DPmDoFjFbrdHOKeaPUN0j zIlVuqfPAwdCeBDN5yQVFtbfWfv75iytzJ6X69dP5zRtquopMj+ZQ6s0zrPdHvWstgVp ckVeHm4D1tn89DweGPFo6Xhvhykz9X86Lso6zKfybX6M+NvCV4bjlL+SiwmO5ezDo26S 4mHMjtBSat80ahtOiCRalXRuMYS8/mebudPXitng1vldFtX2RfAtNfh7UFDbiORKm2vY 2WEw== X-Forwarded-Encrypted: i=1; AJvYcCXP0/aSS3WP+4deaI4uvd9GD7pyZkqTaRhYXllaa0s5dYyqLCcP8OTTFLwlYyRTJpaDyNtXMgCra2KWchejB5BBCPCoi+Q0kjDaidd4 X-Gm-Message-State: AOJu0YzjVjbi8iZ0vO67cSHWf/Y6osubr38L0p/NXuLE6VzQgYcgpx1K bC8nCyyamaBQbxMPi6BSZYM9hKC+zj8BShneF6oovRGJvhulJn0OFk/HyUvFF34= X-Received: by 2002:a05:6a20:561b:b0:1a9:3e7a:b0fc with SMTP id ir27-20020a056a20561b00b001a93e7ab0fcmr6650092pzc.51.1713661509732; Sat, 20 Apr 2024 18:05:09 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d6-20020a63d646000000b005dc8702f0a9sm5249627pgj.1.2024.04.20.18.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Apr 2024 18:05:08 -0700 (PDT) From: Charlie Jenkins Date: Sat, 20 Apr 2024 18:04:44 -0700 Subject: [PATCH v3 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: <20240420-dev-charlie-support_thead_vector_6_9-v3-12-67cff4271d1d@rivosinc.com> References: <20240420-dev-charlie-support_thead_vector_6_9-v3-0-67cff4271d1d@rivosinc.com> In-Reply-To: <20240420-dev-charlie-support_thead_vector_6_9-v3-0-67cff4271d1d@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=1713661481; l=1914; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=/S5mXvNckx5pf6RsnXH2juTR+JzZCbCosBXwMflqUFg=; b=1kn8f9MgXWKJKmQlrV30BpZBvgJ52FS2fVV9itSClPiV/9gnAsAa8aFVH+g1I31umjB1dO4bk q2h7E0sCJbKDEMlRKHZpHo7aqc4t3bXxPYgHr6Zitugls9OvOjNuxGR 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 92eec729888d..6e3c85351f82 100644 --- a/arch/riscv/include/asm/vendor_extensions/thead.h +++ b/arch/riscv/include/asm/vendor_extensions/thead.h @@ -16,4 +16,30 @@ extern const 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