From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Nelson Chu <nelson.chu@sifive.com>,
Kito Cheng <kito.cheng@sifive.com>
Cc: binutils@sourceware.org
Subject: [RFC PATCH 0/3] RISC-V: Check shift amount against XLEN (disassembler)
Date: Mon, 23 May 2022 19:06:22 +0900 [thread overview]
Message-ID: <cover.1653300374.git.research_trasio@irq.a4lg.com> (raw)
** Note **
This patch is not compatible with my previous Zfinx fixes. Actual PATCH
v1 is going to be submitted after this patchset is reviewed and Zfinx
fixes (relatively high priority) are applied.
Certain shift instructions have a constraint: shift amount must be less
than current XLEN. This constraint is checked on assembler and
simulator, but not on disassembler. It causes GDB to print wrong (and
invalid) instructions and can be a problem while ... for instance,
checking for invalid build configuration.
We have several methods to deal with it:
- Add `xlen' argument to match_func to test XLEN
- Split shift instructions to per-XLEN variants
Because shift instructions are so basic and XLEN-checking is so simple,
I chose the former. The latter is used on my Zfinx fixes but this is
because register pair checking involves relatively complex per-operand
constraints. Complex solution for simple problem can be a new problem.
But...
- Is it okay to add an argument anyway?
- Which is better extra argument?
1. unsigned xlen
2. const riscv_parse_subset_t * subset
which contains ISA version, XLEN and extensions
... but a part of BFD, not opcodes.
I also (slightly) changed the assembler to suppress extra error message
just like I did on Zicbop instructions:
<https://sourceware.org/pipermail/binutils/2021-December/118910.html>
<https://sourceware.org/pipermail/binutils/2021-December/118938.html>
Tsukasa OI (3):
RISC-V: Add xlen to match_func
RISC-V: Check shift amount against XLEN
RISC-V: Add disassembler tests for shift amount
gas/config/tc-riscv.c | 8 +-
gas/testsuite/gas/riscv/shamt-dis-32.d | 34 +++++++
gas/testsuite/gas/riscv/shamt-dis-64.d | 34 +++++++
gas/testsuite/gas/riscv/shamt-dis.s | 45 +++++++++
include/opcode/riscv.h | 3 +-
opcodes/riscv-dis.c | 2 +-
opcodes/riscv-opc.c | 122 +++++++++++++++----------
sim/riscv/sim-main.c | 2 +-
8 files changed, 195 insertions(+), 55 deletions(-)
create mode 100644 gas/testsuite/gas/riscv/shamt-dis-32.d
create mode 100644 gas/testsuite/gas/riscv/shamt-dis-64.d
create mode 100644 gas/testsuite/gas/riscv/shamt-dis.s
base-commit: cb0d58bf4d274cfb1ae11b75bd2b3ba81c8d371d
--
2.34.1
next reply other threads:[~2022-05-23 10:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-23 10:06 Tsukasa OI [this message]
2022-05-23 10:06 ` [RFC PATCH 1/3] RISC-V: Add xlen to match_func Tsukasa OI
2022-05-23 10:06 ` [RFC PATCH 2/3] RISC-V: Check shift amount against XLEN Tsukasa OI
2022-05-23 10:06 ` [RFC PATCH 3/3] RISC-V: Add disassembler tests for shift amount Tsukasa OI
2022-07-30 3:47 ` [RFC PATCH 0/3] RISC-V: Check shift amount against XLEN (disassembler) Tsukasa OI
2022-07-30 3:51 ` [PATCH 0/1] " Tsukasa OI
2022-07-30 3:51 ` [PATCH 1/1] RISC-V: Check shift amount against XLEN (disasm) Tsukasa OI
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=cover.1653300374.git.research_trasio@irq.a4lg.com \
--to=research_trasio@irq.a4lg.com \
--cc=binutils@sourceware.org \
--cc=kito.cheng@sifive.com \
--cc=nelson.chu@sifive.com \
--cc=palmer@dabbelt.com \
/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).