From: Paul Iannetta <piannetta@kalrayinc.com>
To: Alan Modra <amodra@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] kvx: fix kvx_reassemble_bundle index 8 out of bounds
Date: Thu, 7 Sep 2023 17:27:31 +0200 [thread overview]
Message-ID: <20230907152731.xwxadzbezswvewsx@ws2202.lin.mbt.kalray.eu> (raw)
In-Reply-To: <ZPnGJL+ME8wO1ZGG@squeak.grove.modra.org>
On Thu, Sep 07, 2023 at 10:16:28PM +0930, Alan Modra wrote:
> On Thu, Aug 24, 2023 at 11:26:49AM +0200, Paul Iannetta wrote:
> > > > * kvx-dis.c (print_insn_kvx): Change the loop condition so that
> > > > wordcount is always less than KVXMAXBUNDLEWORDS.
>
> Hi Paul,
> Does the following patch look good to you, and can you please craft a
> testcase that exercises a maximum size bundle?
>
> While the patch already committed for pr30793 prevents the asan error,
> there is a problem: Now the last element of bundle_words never gets
> written. That's very likely wrong, or KVXMAXBUNDLEWORDS is too big.
> So this patch rearranges things a little to support writing of all of
> bundle_words and does the parallel bit checking only when filling
> bundle_words. In the normal case, kvx_reassemble_bundle will see
> bundle_words[word_count-1] with the parallel bit clear and all other
> words having it set. In the error case where all words in
> bundle_words have the parallel bit set, kvx_reassemble_bundle will be
> passed a wordcount of KVXMAXBUNDLEWORDS + 1. I've also made
> kvx_reassemble_bundle return true for success rather than zero, and
> removed the unnecessary check for zero wordcount.
Hi Alan,
Thank you for catching this, your patch looks good to me. Below is a
patch which adds a test case, you can merge it with yours if you want.
Thanks,
--
Paul
Kalray
commit 8dbb32052cb0e1e5ea1569e3fb708582f8158290
Author: Paul Iannetta <piannetta@kalrayinc.com>
Date: Thu Sep 7 17:10:01 2023 +0200
kvx: Add a testcase for bundles with KVXMAXBUNDLEWORDS syllables
The previous fix (f1917fc) for pr30793 introduced a bug when dealing
with bundles of with KVXMAXBUNDLEWORDS syllables. This adds a test case
to ensure that such bundle are correctly disassembled.
gas/ChangeLog:
2023-09-07 Paul Iannetta <piannetta@kalrayinc.com>
* testsuite/gas/kvx/fat-bundles.s: New test.
* testsuite/gas/kvx/kv3-1-fat-bundles.d: New test.
* testsuite/gas/kvx/kv3-2-fat-bundles.d: New test.
diff --git a/gas/testsuite/gas/kvx/fat-bundles.s b/gas/testsuite/gas/kvx/fat-bundles.s
new file mode 100644
index 00000000000..8119c6043de
--- /dev/null
+++ b/gas/testsuite/gas/kvx/fat-bundles.s
@@ -0,0 +1,13 @@
+# The bundles in this file all have 8 syllables.
+
+ addd $r0 = $r0, 123456789010 # 1 ALU + 2 Immediate Extensions
+ addd $r0 = $r0, 123456789010 # 1 ALU + 2 Immediate Extensions
+ addd $r1 = $r2, 1234 # 1 ALU + 1 Immediate Extension
+ ;;
+ igoto $r0 # 1 BCU
+ xmt44d $a0a1a2a3 = $a0a1a2a3 # 1 TCA
+ addd $r0 = $r0, 1234 # 1 ALU + 1 Immediate Extension
+ addd $r0 = $r0, 12345678901 # 1 ALU + 1 Immediate Extension
+ fmuld $r1 = $r2, $r3 # 1 MAU
+ lwz $r0 = 0[$r0] # 1 LSU
+ ;;
diff --git a/gas/testsuite/gas/kvx/kv3-1-fat-bundles.d b/gas/testsuite/gas/kvx/kv3-1-fat-bundles.d
new file mode 100644
index 00000000000..1f80e0444fd
--- /dev/null
+++ b/gas/testsuite/gas/kvx/kv3-1-fat-bundles.d
@@ -0,0 +1,20 @@
+#as: -march=kv3-1
+#objdump: -d
+#source: fat-bundles.s
+.*\/fat-bundles.o: file format elf64-kvx
+
+
+Disassembly of section .text:
+
+0000000000000000 <.text>:
+ 0: 82 34 04 e1 80 84 00 e1 addd \$r1 = \$r2, 1234 \(0x4d2\)
+ 8: 80 84 00 e1 01 00 00 80 46 a6 2f 8f addd \$r0 = \$r0, 123456789010 \(0x1cbe991a12\)
+ 14: 00 00 00 88 46 a6 2f 97 00 00 00 10 addd \$r0 = \$r0, 123456789010 \(0x1cbe991a12\);;
+
+ 20: 00 00 d8 8f igoto \$r0
+ 24: 00 00 0c 84 xmt44d \$a0a1a2a3 = \$a0a1a2a3
+ 28: 80 34 00 e1 40 0d 00 e1 addd \$r0 = \$r0, 1234 \(0x4d2\)
+ 30: c2 70 05 d8 00 00 00 b0 addd \$r0 = \$r0, 12345678901 \(0x2dfdc1c35\)
+ 38: 01 00 00 80 fmuld \$r1 = \$r2, \$r3
+ 3c: 07 f7 b7 08 lwz \$r0 = 0 \(0x0\)\[\$r0\];;
+
diff --git a/gas/testsuite/gas/kvx/kv3-2-fat-bundles.d b/gas/testsuite/gas/kvx/kv3-2-fat-bundles.d
new file mode 100644
index 00000000000..54717eb55b4
--- /dev/null
+++ b/gas/testsuite/gas/kvx/kv3-2-fat-bundles.d
@@ -0,0 +1,20 @@
+#as: -march=kv3-2
+#objdump: -d
+#source: fat-bundles.s
+.*\/fat-bundles.o: file format elf64-kvx
+
+
+Disassembly of section .text:
+
+0000000000000000 <.text>:
+ 0: 82 34 04 e2 80 84 00 e2 addd \$r1 = \$r2, 1234 \(0x4d2\)
+ 8: 80 84 00 e2 01 00 00 80 46 a6 2f 8f addd \$r0 = \$r0, 123456789010 \(0x1cbe991a12\)
+ 14: 00 00 00 88 46 a6 2f 97 00 00 00 10 addd \$r0 = \$r0, 123456789010 \(0x1cbe991a12\);;
+
+ 20: 00 00 d8 8f igoto \$r0
+ 24: 00 10 05 87 xcopyv.td \$a0a1a2a3 = \$a0a1a2a3
+ 28: 80 34 00 e2 40 0d 00 e2 addd \$r0 = \$r0, 1234 \(0x4d2\)
+ 30: c2 70 05 d8 00 00 00 b0 addd \$r0 = \$r0, 12345678901 \(0x2dfdc1c35\)
+ 38: 01 00 00 80 fmuld \$r1 = \$r2, \$r3
+ 3c: 07 f7 b7 08 lwz \$r0 = 0 \(0x0\)\[\$r0\];;
+
next prev parent reply other threads:[~2023-09-07 15:27 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 16:01 [PATCH] kvx: fix 32-bit build and validation Paul Iannetta
2023-08-23 0:27 ` Alan Modra
2023-08-23 7:44 ` Paul Iannetta
2023-08-23 12:14 ` Alan Modra
2023-08-23 14:39 ` [PATCH 0/4] kvx: various fixes Paul Iannetta
2023-08-23 14:39 ` [PATCH 1/4] kvx: remove kvx_elf64_linux_vec Paul Iannetta
2023-08-23 14:39 ` [PATCH 2/4] kvx: fix handling of STB_GNU_UNIQUE symbols Paul Iannetta
2023-08-23 14:39 ` [PATCH 3/4] kvx: use {u,}int32_t and {u,}int64_t Paul Iannetta
2023-08-23 14:39 ` [PATCH 4/4] kvx: bfd/config.bfd & ld/configure.tgt Paul Iannetta
2023-08-24 3:12 ` [PATCH 0/4] kvx: various fixes Alan Modra
2023-08-24 6:26 ` Paul Iannetta
2023-08-24 8:49 ` [PATCH] kvx: fix kvx_reassemble_bundle index 8 out of bounds Paul Iannetta
2023-08-24 9:08 ` Alan Modra
2023-08-24 9:26 ` Paul Iannetta
2023-09-07 12:46 ` Alan Modra
2023-09-07 15:27 ` Paul Iannetta [this message]
2023-08-23 14:40 ` [PATCH] kvx: fix 32-bit build and validation Paul Iannetta
2023-08-23 3:16 ` Alan Modra
2023-08-23 13:39 ` Luis Machado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230907152731.xwxadzbezswvewsx@ws2202.lin.mbt.kalray.eu \
--to=piannetta@kalrayinc.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).