From nobody Thu Dec 18 22:14:49 2025 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 D0167171640 for ; Wed, 24 Jul 2024 19:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721848460; cv=none; b=LSi16iSK5HVuggJvbhQbHt/LtKUpADkajyLY9h6v/N5LOx4wjVUJi44gSegh4FOmOUv5j1dGIITzRIOUoCACqwAs3b5GTf1Hqivo8ZsUOdKqTTsgnGOlPE5DK2PeiihqAK76yqLmiejUfSgivG4U/Ra/yL0vESSs4zhakwLx1IU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721848460; c=relaxed/simple; bh=L3aaRS2j1B7ly0GhgM86XDS3MRCOslmFg/ArzwGxzO0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FredJwwcXSqBRoyqDBIFE8XqQaz0G3Et4FevE/QyQXogYIUpMemyAYiBhQrgcgJPDw2wqsHmH3s2xCNu6zLRu0S2yaNFrDy92G02DFOQoR1R9G75VDat8nhfgukgvyrQ8SC9BBq7XFy1jv836w6YuBOojeu8dj9ZugEWjlamK3c= 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=PgI2DQF+; arc=none smtp.client-ip=209.85.216.48 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="PgI2DQF+" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-2cb57e25387so136518a91.3 for ; Wed, 24 Jul 2024 12:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1721848458; x=1722453258; 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=UhITSSlteAMwmsPUv9TpJ8KEJQbK1ok0BXYvmwnIXKY=; b=PgI2DQF+HMBwBW+mI3AqoAvYMx5Z+oD4fdBzDzkpdM60ELWH2dr6XGuH0X8dq8pVie coqSSJDffp/qKQJd7dfQn5QpREPCNR1FhqiKhert5ezHb0pOAwtj+Oj5aUmlB5ExdNSk OCG+oaXimnjBcSjkOvX0p5bC2YKe3td7EM2YIhUn8vCfKwB2cFPo2UgzDoz3c44+/pKN Xo0mD1pHVNuxfav3Q8QvNDymFd2TxShAv1QCrpT4I10B4tJlfxrg8lIDxZc36WuWnlDB gDLkC1Bc6UUODKfEdt5IUFj22lMIgd9iDOvD1zc3uRzRD851Le7T4Azs8WZp1xHdLORQ tMcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721848458; x=1722453258; 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=UhITSSlteAMwmsPUv9TpJ8KEJQbK1ok0BXYvmwnIXKY=; b=WcKCR9PuMZQKbIR/1oZPeMWXRTRBAx++lVnHqxcnyY9xxwFotCHS0HojvQZRg8PGQY v0M0PukeE07KmNJ0JBR2Hh/elYd7Ek/CqmWvGXTYJAMoe78XRJyQgF0aLnas7+MkWPUp YR7ED4WCi0k0/O90R/NsDhq4zOP5t22VCvw5C6dYX4rn7mECDhQvtRGYDK65YCg5+L7Q GTh76rcwh8Dtd8aeiWl3SD67xyLstkb/Je+AdsLzvJO6gKRUb1rFi4oNeY/QzmkTlnSC tASLFWj0cUrJaulmBxqNzF/mN/44PWXCdu/wUo4J2LHaHJJXTA/CWK65pvqrPF7G1hi6 kGXg== X-Forwarded-Encrypted: i=1; AJvYcCXATTScohxqli0uQklQt4BzZLDNaSVDPdf0q7yW6maHIXVTHvt2aQkV3ibVTJUikM2J3pOX0mE7WaQ1JhFW/MswIHwqfL3NJC/5kWD8 X-Gm-Message-State: AOJu0Yx0G6LA31x6gIWWmfcsdZYv29JiPz9a3wr0eJ2eG0x0WVqhHyyp uLsSIi1Xb2QjJVTVZOuX29AKbQhHKTP0Zh3kz8piDuuEkDAjrWQYnZXfGZeLkkM= X-Google-Smtp-Source: AGHT+IHLgTiDpT0TMNqD3LFvvYBX3c1KdokyNuKeNMfxvuG27WJVcwSBAHwFUVZPvOemuokht7oTaQ== X-Received: by 2002:a17:90a:e7d1:b0:2cb:4f14:2a70 with SMTP id 98e67ed59e1d1-2cf238ccd81mr501393a91.30.1721848458166; Wed, 24 Jul 2024 12:14:18 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2cdb73edecesm2022359a91.32.2024.07.24.12.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 12:14:17 -0700 (PDT) From: Charlie Jenkins Date: Wed, 24 Jul 2024 12:13:59 -0700 Subject: [PATCH v7 08/13] 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: quoted-printable Message-Id: <20240724-xtheadvector-v7-8-b741910ada3e@rivosinc.com> References: <20240724-xtheadvector-v7-0-b741910ada3e@rivosinc.com> In-Reply-To: <20240724-xtheadvector-v7-0-b741910ada3e@rivosinc.com> To: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Palmer Dabbelt , Albert Ou , Jisheng Zhang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Samuel Holland , Jonathan Corbet , Shuah Khan , Guo Ren , Evan Green , Andy Chiu , Jessica Clarke , Andrew Jones 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=1721848437; l=1957; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=L3aaRS2j1B7ly0GhgM86XDS3MRCOslmFg/ArzwGxzO0=; b=3LgSk8+xNOEkZSklUaLgaL0zXyg2NuVF6QG/VGVzyxO0+a7OwCZfLqM9BaJCg9XbiSiB+JCPx JnjuUUBisCLD2JPnzki/otPZkOgTMX9XCCpSt9dVrgF2YyvXZb/x1MR 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 @@ =20 extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_the= ad; =20 +/* 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 --=20 2.44.0