Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1565163lqm; Thu, 2 May 2024 21:50:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUY66YIVokr6z4MUh2x1sqYQO7gsK7Zt9NQeMctSOmug85vExT1vp8dVLP6HoNLXR00eU9wm9pt/amEh7zSUZ4EIJIfpsYWJJlEcwJvKg== X-Google-Smtp-Source: AGHT+IH2I2tQEhJmlVqrKR8qruPnqBxDF/YWUWOC7Rjnw7kZ7wKmBofPDb3CrTpMHBd/zYlbFovs X-Received: by 2002:a17:906:341a:b0:a58:ff5a:ac38 with SMTP id c26-20020a170906341a00b00a58ff5aac38mr750475ejb.25.1714711835382; Thu, 02 May 2024 21:50:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714711835; cv=pass; d=google.com; s=arc-20160816; b=Qc80AVVZWA/NoDdF5iSSa914e6nCLRRxzTUOa3tT7PHXUizCcm2+UvX860C/TXiPbU ODpmc++NgvXfRYMIGO0FY3PyrWjFOyikuWdU1paizr3VXzEfvm6Lzc8N0AKhQzErdAag wpPyeAjUdG0pU0/0uo8hlLaemM+naSO3CJAShNMahbOlBmnzUd2b5oygdCOF6jXIR0JE HtMf3T5Gq2aBozNJFfXOIQaakvuDhxD7ZZOYt3Y988MdPukYkLdz69DerlWLFBzXfh/N G7XxRyZBa34drYZjI/GGtPc+pHxHQO0ku9tnHrpBCn6yLK3Qtb+vsLZT4/R8XkQQZrSF bgPg== 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=jf1hWKv5iRKQgJYWo2LhnlOpuQs0nxTmZHoGVxbNLLY=; b=mDvzMOCe6TTpRa5yEb2GLWeY6FcWks4rjW4+0Xp9EjKG9xwy+iJ9oINVGtyqD6x9OZ UXExcysg0XcFOy2DFWGoMg4vyTpc9N2jdjdNHeIen+ALLokX+38+Y97hm/SE/D19yBoZ 8vUXZlni+L1ACabgNTIDR60JTzjEMuXASBh+X9CSPuLbkZ4JFuoID6e2AqiGvZ3RZMo3 QAshWpDnpHiF0dTytrRzD8IHnw4s83J5l43giufSGH/Z6BdK357sQbbUUZ//Z3yhEU98 q36Ta1pjSBMc2r2sbTR24Kordso4q7zuidTWISbL1y3biZBCm41f3qWiTDFZVawHw24q TdYw==; 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=10mQQFFM; 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-167243-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167243-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 mf23-20020a170906cb9700b00a5991a547a2si257763ejb.163.2024.05.02.21.50.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 21:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167243-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=10mQQFFM; 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-167243-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167243-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 EC71B1F21677 for ; Fri, 3 May 2024 04:50:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D2788139CEC; Fri, 3 May 2024 04:47:13 +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="10mQQFFM" Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 2B5D413C3F4 for ; Fri, 3 May 2024 04:47:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714711633; cv=none; b=Gu9SBD7YFMJLM71z5nFX94WpzAhBwzvTTcFAcDZqzCGYohjJw/urgeVO2Es7ywXEPfMaL1QVXxn/JnmZBHSXmJIa+mldELzKW5o7cfvYHSlHmHcFheyZz1WckVcH+6VagnItTxeDUrIFg8azD5/jePir1UxvboiXK0J4PEuYPQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714711633; c=relaxed/simple; bh=fwxPC9e5acCJKXfvxD0QuLfngnuG8uQUjT/zUUS4iJ0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DCDlIj7/vOrpI1Kx29V9Ouk2uM8uzeJ7pMXKe4GvkaKvqdNuVUOHlYxUhMfq9Etc6ERcOu1/ouImWugeA33gvQ+oQs4VBtAp7uy3vPgSHQ+aDDuvhKOv72DqjCzIsA1i1L6MU5S3ned8NYNnG/9cj5yf9liiWELPrhLwMzLs7wQ= 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=10mQQFFM; arc=none smtp.client-ip=209.85.215.172 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-f172.google.com with SMTP id 41be03b00d2f7-61bbb208ea5so693899a12.0 for ; Thu, 02 May 2024 21:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714711629; x=1715316429; 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=10mQQFFMyj93hRzub9RVw4aNnbISIkROmNpjpbbIY3RtakFodyjR2+p3C03tXle4GL W0yuDfe9JnjqC6dJSg6FENFVWHIHPC6Eu4O0wgbwBKfZ/7MTbw4Q1whbsxGQvvHDFJ4n ag9dZfo8QxHvO5Qcqylbz2XUn96yuHMum3m9oySQ/EwZXfnqlukI5ykN5VonxDzRycv+ qKd8xSb+2Jt/uhUrwgEHE+j6PKSrgYzHmhkkiYYUlZ7RipAw6gl3GZRKk4MOzHzG+NGJ yxPkWSh3kCZKqQrzsENfWqysDWgVGbKYFyt76VShVaGDwFAzNkJGC3xdEzvEge/dAyEG HpMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714711629; x=1715316429; 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=hDSBaphP4Y7k0n4qHIjdfaL2PDV5CREi49cepgXz2cgZAlJPQYMpDynSvjAalP2O6V 25wL6xtbdW/mq4bhCfS9SDEG+zwHMc1qQ31aAUC7BG+Y2s+t/LZ+K9zn3jtvWc6z8e4Q 854oIY/QaubRpslSRLag8v1jEKdLp7FPWVlvbtieiTujxJnT4EmlHS+8bMKS7ATcspxB K4U5zWsF2rB+0sB55K56e6DpyaVW4HlMd18t+OHvvzpwqUxNOyJMMuejr3n4u38C7XV2 dC0l5P1xvzbkWIomlAGi4fzxhemjEd+3vVNzh3tnGnssZfr64N5RoIKlZICZhLoqmc9x FrjA== X-Forwarded-Encrypted: i=1; AJvYcCV694sHTf257ecSlYJodgQO9N0MQLh5o5KtG6YBt+uz72w6GQ7q/A7ed9RJDjrzVvlSiGXynqSKpeidZ1KIHSwtOC9D7pDWuqbyLyhG X-Gm-Message-State: AOJu0YzHNphIr5jfrss8uyt1arsi6s7ZDIxeqS0pKi9mXuzEH2VOLSeW 9KWK2gYmZ4h6PSsOHKNAl9Q7cvrnrxNQ1NJttziVePRqxIBbcqnCfyo3QE6hJmo= X-Received: by 2002:a05:6a20:f393:b0:1a7:4b40:96db with SMTP id qr19-20020a056a20f39300b001a74b4096dbmr1617087pzb.10.1714711629443; Thu, 02 May 2024 21:47:09 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id e8-20020a17090301c800b001e2bb03893dsm2240411plh.198.2024.05.02.21.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 21:47:08 -0700 (PDT) From: Charlie Jenkins Date: Thu, 02 May 2024 21:46:47 -0700 Subject: [PATCH v5 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: <20240502-dev-charlie-support_thead_vector_6_9-v5-12-d1b5c013a966@rivosinc.com> References: <20240502-dev-charlie-support_thead_vector_6_9-v5-0-d1b5c013a966@rivosinc.com> In-Reply-To: <20240502-dev-charlie-support_thead_vector_6_9-v5-0-d1b5c013a966@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=1714711602; l=1908; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=fwxPC9e5acCJKXfvxD0QuLfngnuG8uQUjT/zUUS4iJ0=; b=tsASdWZ+V/WOtznPM1nvcKllla4Vt62mCeqqf/9/oDU2uch8BE2mc33Z26RL6fLgWnEC8I0+Q 8mBe6EQvsFnBS9sgIxF6SaL2+IQ9ituhuA3C9zxt/NwfJ3n0ZomxMIP 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