From patchwork Fri Apr 26 21:37:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Jenkins X-Patchwork-Id: 792991 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 2AC4E36AE4 for ; Fri, 26 Apr 2024 21:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714167438; cv=none; b=tTX8AO5uc9BjyZRP2P5rO6j+fCDBuDPfG0zwIH38M4fAre9fiW4Uh1J0V68PlBb8BrxTz/syb2hDApst0brv7y5gEsyIqkL7LnpGbqN5x/+UyD78FCFpCxlTmYC5eFxir3rMj3gNnAhOQGcyJvY6uc/O7q69mL1WHrU2HX5sRU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714167438; c=relaxed/simple; bh=/S5mXvNckx5pf6RsnXH2juTR+JzZCbCosBXwMflqUFg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E83X3gzJ5s0zUG7yvJQa4l3+qKRawCUCD6aVRo8aPyZmmv2hyBeillCLvxxjzOnyn19xnWOwATsDUWZyAUtTb5wJrqCbHTsvYl7to8Db+hh00UFUPaIsVpNPIoUqSy1iuIvHkG6ymvUm1NpW+ChDC++tpHpFE1ONYsQ6RvgubEk= 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=0XUhqxWv; arc=none smtp.client-ip=209.85.215.169 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="0XUhqxWv" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5e4f79007ffso1688700a12.2 for ; Fri, 26 Apr 2024 14:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1714167436; x=1714772236; 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=0XUhqxWvzfP59c5G/Z/QLaMp3WKLC84k6GjapRQhHt0b0e7Gp8mFL/hdIO5ZSet6mr zm/tjE0aRsDln33DLcuE0PksXvAkXw2vAwOIp4etGK0h0/7W7I96XmC49mOk9jYuSelk OqfZjAZgi4t2DOQIn9kjcx/KGOn+gp1edxmt/3nXXC9JyrWNXB/ztTLTfRAhAzF89cse dZMwDBN0L0UsUYVyIoM04KNBCEOYIpB2NUVMRkzrWtB5dam5H/bF+gUYZFRQzLhR2S5n wAl7mO+7JNlVZ6GEPcm0XW6XVmMQTbqnWWSxbXPxh6J7FgEy1GH70mj0ayBNQpqGzEy/ 682w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714167436; x=1714772236; 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=dpuHHo+r7x0oHe2vIUXrhdcdXfB4Xb3KH762TB9USjnv3xKvybiYx6lEqezcnhcsFt elfsVY7hMqRrg7BsP77TDAUU3rM/eWgwzYAn3rFQC4yqVA+9tOx5TPG8IwVh2mwYachH Dzm8wVLBaV5kLBMogQo6QzSA1BKcXN6ZTCHdTxqYVfBEz+0ir4btHuGd7v2iqrbyhyMT iPWj8H8DA8YTVPxN4QO4lPMtXDySZC0aswfRmRsqpHQMu5yzR78vAUGUkSi+PkGIuWPb y24lhSlQAHVulEYgXsX6BRH/Lxa1u+Yg3YPsiFGUuk4xdBs2pb4hNDsh6+xFJ7yOfJZM pwuw== X-Forwarded-Encrypted: i=1; AJvYcCWbvIQNaqXCxj01Hj6YGN6zcnDScwu6MPX4KMzlIWeuY+fV3PA26tF+irJ8mgKznSuBK2Hwj3nwzT2MCym+/r8MmmUwSENHpL6eY5UxgZKv X-Gm-Message-State: AOJu0Ywp9K0hKjZiNbbUGL369P65Ab5wvHL/Dl+GVoNwsC4pqbNW99S1 Ey4KBf1Xkvr3+bJ0VmZinlQuq5ZWFNq8koAAtZf4BA890wfNU2uUG00bYdguI0o= X-Google-Smtp-Source: AGHT+IEmTz6F3urwdNc3upHPp7xuNjToyMXKR0+MXW/PS19so8SBqwqQD842Cobd1kOR7Dc18se9dw== X-Received: by 2002:a17:903:1208:b0:1e3:dfdc:6972 with SMTP id l8-20020a170903120800b001e3dfdc6972mr5045246plh.9.1714167436618; Fri, 26 Apr 2024 14:37:16 -0700 (PDT) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id k4-20020a170902760400b001e2936705b4sm15935701pll.243.2024.04.26.14.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 14:37:14 -0700 (PDT) From: Charlie Jenkins Date: Fri, 26 Apr 2024 14:37:06 -0700 Subject: [PATCH v4 11/16] riscv: Add xtheadvector instruction definitions Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240426-dev-charlie-support_thead_vector_6_9-v4-11-5cf53b5bc492@rivosinc.com> References: <20240426-dev-charlie-support_thead_vector_6_9-v4-0-5cf53b5bc492@rivosinc.com> In-Reply-To: <20240426-dev-charlie-support_thead_vector_6_9-v4-0-5cf53b5bc492@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?b?Q2zDqW1lbnQgTMOpZ2Vy?= , 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=1714167425; l=1914; i=charlie@rivosinc.com; s=20231120; h=from:subject:message-id; bh=/S5mXvNckx5pf6RsnXH2juTR+JzZCbCosBXwMflqUFg=; b=PCrymv44Z3fiRwZ4pYJZPOoFnaXXtTTpJLu/OUgNMcdouUs0msGnlr9zseM1KUD6drfrqa5Xy APyv+dooJWrBYOFJl5QFRlu8s4tC+mzcad1gaHapng5GB3Q7qMS3fwV 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