aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHuang Tao <eric.huang@linux.alibaba.com>2024-03-25 10:16:54 +0800
committerAlistair Francis <alistair.francis@wdc.com>2024-06-03 11:12:12 +1000
commit75115d880c6d396f8a2d56aab8c12236d85a90e0 (patch)
treef59428661296352996f837aa0a5855330f785b86
parent4a90991234f003d8fe55919e84bf3ec7d542830e (diff)
downloadqemu-75115d880c6d396f8a2d56aab8c12236d85a90e0.zip
qemu-75115d880c6d396f8a2d56aab8c12236d85a90e0.tar.gz
qemu-75115d880c6d396f8a2d56aab8c12236d85a90e0.tar.bz2
target/riscv: Fix the element agnostic function problem
In RVV and vcrypto instructions, the masked and tail elements are set to 1s using vext_set_elems_1s function if the vma/vta bit is set. It is the element agnostic policy. However, this function can't deal the big endian situation. This patch fixes the problem by adding handling of such case. Signed-off-by: Huang Tao <eric.huang@linux.alibaba.com> Suggested-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com> Cc: qemu-stable <qemu-stable@nongnu.org> Message-ID: <20240325021654.6594-1-eric.huang@linux.alibaba.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
-rw-r--r--target/riscv/vector_internals.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internals.c
index 996c21e..05b2d01 100644
--- a/target/riscv/vector_internals.c
+++ b/target/riscv/vector_internals.c
@@ -30,6 +30,28 @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic, uint32_t cnt,
if (tot - cnt == 0) {
return ;
}
+
+ if (HOST_BIG_ENDIAN) {
+ /*
+ * Deal the situation when the elements are insdie
+ * only one uint64 block including setting the
+ * masked-off element.
+ */
+ if (((tot - 1) ^ cnt) < 8) {
+ memset(base + H1(tot - 1), -1, tot - cnt);
+ return;
+ }
+ /*
+ * Otherwise, at least cross two uint64_t blocks.
+ * Set first unaligned block.
+ */
+ if (cnt % 8 != 0) {
+ uint32_t j = ROUND_UP(cnt, 8);
+ memset(base + H1(j - 1), -1, j - cnt);
+ cnt = j;
+ }
+ /* Set other 64bit aligend blocks */
+ }
memset(base + cnt, -1, tot - cnt);
}