qemu-riscv64 -strace gives 32-bit buffer address for read() or write()
<!--
This is the upstream QEMU issue tracker.
If you are able to, it will greatly facilitate bug triage if you attempt
to reproduce the problem with the latest qemu.git master built from
source. See https://www.qemu.org/download/#source for instructions on
how to do this.
QEMU generally supports the last two releases advertised on
https://www.qemu.org/. Problems with distro-packaged versions of QEMU
older than this should be reported to the distribution instead.
See https://www.qemu.org/contribute/report-a-bug/ for additional
guidance.
If this is a security issue, please consult
https://www.qemu.org/contribute/security-process/
-->
## Host environment
- Operating system: Linux <!-- Windows 10 21H1, Fedora 37, etc. -->
- OS/kernel version: Linux host 6.14.0-36-generic #36~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 15 15:45:17 UTC 2 x86_64 x86_64 x86_64 GNU/Linux <!-- For POSIX hosts, use `uname -a` -->
- Architecture: x86_64 <!-- x86, ARM, s390x, etc. -->
- QEMU flavor: qemu-riscv64 <!-- qemu-system-x86_64, qemu-aarch64, qemu-img, etc. -->
- QEMU version: 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.10)
<!-- e.g. `qemu-system-x86_64 --version` -->
- QEMU command line: qemu-riscv64 -strace ./bug-qemu
<!--
Give the smallest, complete command line that exhibits the problem.
If you are using libvirt, virsh, or vmm, you can likely find the QEMU
command line arguments in /var/log/libvirt/qemu/$GUEST.log.
-->
## Description of problem
<!-- Describe the problem, including any error/crash messages seen. -->
For qemu-riscv64, the printout for strace system call read() and write() gives only 32 bits for the second argument (the buffer address), but the actual address is 64 bits wide.
## Steps to reproduce
1. Compile this short program into a binary executable:
```
_start: .globl _start
li a2,4
mv a1,sp
li a0,-1
li a7,63 # read
ecall
li a2,4
mv a1,sp
li a0,-1
li a7,64 # write
ecall
li a7,93 # exit
ecall
```
using build utilities such as:
```
/usr/bin/riscv64-linux-gnu-as bug-qemu.S -o bug-qemu.o
/usr/bin/riscv64-linux-gnu-ld bug-qemu.o -o bug-qemu
```
2. Execute:
```
$ qemu-riscv64 -strace ./bug-qemu
5268 read(-1,0xab2aaef0,4) = -1 errno=9 (Bad file descriptor)
5268 write(-1,0xab2aaef0,4) = -1 errno=9 (Bad file descriptor)
5268 exit(-9)
```
3. Note that qemu-riscv64 prints only 32 bits of the 64-bit stack pointer passed as the buffer address in register a1.
issue