9b1268f5 | 25-Jul-2022 |
Peter Maydell <peter.maydell@linaro.org> |
semihosting: Fix handling of buffer in TARGET_SYS_TMPNAM
The TARGET_SYS_TMPNAM implementation has two bugs spotted by Coverity: * confusion about whether 'len' has the length of the string inclu
semihosting: Fix handling of buffer in TARGET_SYS_TMPNAM
The TARGET_SYS_TMPNAM implementation has two bugs spotted by Coverity: * confusion about whether 'len' has the length of the string including or excluding the terminating NUL means we lock_user() len bytes of memory but memcpy() len + 1 bytes * In the error-exit cases we forget to free() the buffer that asprintf() returned to us
Resolves: Coverity CID 1490285, 1490289 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220719121110.225657-5-peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220725140520.515340-10-alex.bennee@linaro.org>
show more ...
|
fed49cdf | 25-Jul-2022 |
Peter Maydell <peter.maydell@linaro.org> |
semihosting: Check for errors on SET_ARG()
The SET_ARG() macro returns an error indication; we check this in the TARGET_SYS_GET_CMDLINE case but not when we use it in implementing TARGET_SYS_ELAPSED
semihosting: Check for errors on SET_ARG()
The SET_ARG() macro returns an error indication; we check this in the TARGET_SYS_GET_CMDLINE case but not when we use it in implementing TARGET_SYS_ELAPSED. Check for and handle the errors via the do_fault codepath, and update the comment documenting the SET_ARG() and GET_ARG() macros to note how they handle memory access errors.
Resolves: Coverity CID 1490287 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220719121110.225657-4-peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220725140520.515340-9-alex.bennee@linaro.org>
show more ...
|
45704e89 | 25-Jul-2022 |
Peter Maydell <peter.maydell@linaro.org> |
semihosting: Don't copy buffer after console_write()
The console_write() semihosting function outputs guest data from a buffer; it doesn't update that buffer. It therefore doesn't need to pass a le
semihosting: Don't copy buffer after console_write()
The console_write() semihosting function outputs guest data from a buffer; it doesn't update that buffer. It therefore doesn't need to pass a length value to unlock_user(), but can pass 0, meaning "do not copy any data back to the guest memory".
Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220719121110.225657-3-peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20220725140520.515340-8-alex.bennee@linaro.org>
show more ...
|
aed04e63 | 25-Jul-2022 |
Peter Maydell <peter.maydell@linaro.org> |
semihosting: Don't return negative values on qemu_semihosting_console_write() failure
The documentation comment for qemu_semihosting_console_write() says * Returns: number of bytes written -- this
semihosting: Don't return negative values on qemu_semihosting_console_write() failure
The documentation comment for qemu_semihosting_console_write() says * Returns: number of bytes written -- this should only ever be short * on some sort of i/o error.
and the callsites rely on this. However, the implementation code path which sends console output to a chardev doesn't honour this, and will return negative values on error. Bring it into line with the other implementation codepaths and the documentation, so that it returns 0 on error.
Spotted by Coverity, because console_write() passes the return value to unlock_user(), which doesn't accept a negative length.
Resolves: Coverity CID 1490288 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220719121110.225657-2-peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220725140520.515340-7-alex.bennee@linaro.org>
show more ...
|
938fcd74 | 28-Jun-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Remove qemu_semihosting_log_out
The function is no longer used.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Me
semihosting: Remove qemu_semihosting_log_out
The function is no longer used.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220628111701.677216-7-richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
show more ...
|
1b9177f7 | 02-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Create semihost_sys_poll_one
This will be used for implementing the xtensa select_one system call. Choose "poll" over "select" so that we can reuse Glib's g_poll constants and to avoid
semihosting: Create semihost_sys_poll_one
This will be used for implementing the xtensa select_one system call. Choose "poll" over "select" so that we can reuse Glib's g_poll constants and to avoid struct timeval.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
2d010c27 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Remove qemu_semihosting_console_outs
This function has been replaced by *_write.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-of
semihosting: Remove qemu_semihosting_console_outs
This function has been replaced by *_write.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
7281550c | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Use console_out_gf for SYS_WRITE0
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
004d2abe | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Remove qemu_semihosting_console_outc
This function has been replaced by *_write.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.
semihosting: Remove qemu_semihosting_console_outc
This function has been replaced by *_write.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
5d77289d | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Use console_out_gf for SYS_WRITEC
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
1577eec0 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Use console_in_gf for SYS_READC
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
e4a4aaa5 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Create qemu_semihosting_guestfd_init
For arm-compat, initialize console_{in,out}_gf; otherwise, initialize stdio file descriptors.
This will go some way to cleaning up arm-compat, and
semihosting: Create qemu_semihosting_guestfd_init
For arm-compat, initialize console_{in,out}_gf; otherwise, initialize stdio file descriptors.
This will go some way to cleaning up arm-compat, and will allow other semihosting to use normal stdio.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
008e1475 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Add GuestFDConsole
Add a GuestFDType for connecting to the semihosting console. Hook up to read, write, isatty, and fstat syscalls.
Note that the arm-specific syscall flen cannot be ap
semihosting: Add GuestFDConsole
Add a GuestFDType for connecting to the semihosting console. Hook up to read, write, isatty, and fstat syscalls.
Note that the arm-specific syscall flen cannot be applied to the console, because the console is not a descriptor exposed to the guest.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
cd66f20f | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Create qemu_semihosting_console_write
Will replace qemu_semihosting_console_{outs,outc}, but we need more plumbing first.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Ric
semihosting: Create qemu_semihosting_console_write
Will replace qemu_semihosting_console_{outs,outc}, but we need more plumbing first.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
fb08790b | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Cleanup chardev init
Rename qemu_semihosting_connect_chardevs to qemu_semihosting_chardev_init; pass the result directly to qemu_semihosting_console_init.
Store the chardev in Semihost
semihosting: Cleanup chardev init
Rename qemu_semihosting_connect_chardevs to qemu_semihosting_chardev_init; pass the result directly to qemu_semihosting_console_init.
Store the chardev in SemihostingConsole instead of SemihostingConfig, which lets us drop semihosting_get_chardev.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
e7fb6f32 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Expand qemu_semihosting_console_inc to read
Allow more than one character to be read at one time. Will be used by m68k and nios2 semihosting for stdio.
Reviewed-by: Luc Michel <lmichel
semihosting: Expand qemu_semihosting_console_inc to read
Allow more than one character to be read at one time. Will be used by m68k and nios2 semihosting for stdio.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
3367d452 | 01-May-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Pass CPUState to qemu_semihosting_console_inc
We don't need CPUArchState, and we do want the CPUState of the thread performing the operation -- use this instead of current_cpu.
Reviewe
semihosting: Pass CPUState to qemu_semihosting_console_inc
We don't need CPUArchState, and we do want the CPUState of the thread performing the operation -- use this instead of current_cpu.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
64c8c6a9 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
gdbstub: Adjust gdb_syscall_complete_cb declaration
Change 'ret' to uint64_t. This resolves a FIXME in the m68k and nios2 semihosting that we've lost data. Change 'err' to int. There is nothing ta
gdbstub: Adjust gdb_syscall_complete_cb declaration
Change 'ret' to uint64_t. This resolves a FIXME in the m68k and nios2 semihosting that we've lost data. Change 'err' to int. There is nothing target-specific about the width of the errno value.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
1875dab0 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Create semihost_sys_gettimeofday
This syscall will be used by m68k and nios2 semihosting.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderso
semihosting: Create semihost_sys_gettimeofday
This syscall will be used by m68k and nios2 semihosting.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
dffeb775 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Create semihost_sys_{stat,fstat}
These syscalls will be used by m68k and nios2 semihosting.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.hender
semihosting: Create semihost_sys_{stat,fstat}
These syscalls will be used by m68k and nios2 semihosting.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
90d8e0b0 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Split out semihost_sys_system
Split out the non-ARM specific portions of SYS_SYSTEM to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson
semihosting: Split out semihost_sys_system
Split out the non-ARM specific portions of SYS_SYSTEM to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
25a95da0 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Split out semihost_sys_rename
Split out the non-ARM specific portions of SYS_RENAME to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson
semihosting: Split out semihost_sys_rename
Split out the non-ARM specific portions of SYS_RENAME to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
d49e79b8 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Split out semihost_sys_remove
Split out the non-ARM specific portions of SYS_REMOVE to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson
semihosting: Split out semihost_sys_remove
Split out the non-ARM specific portions of SYS_REMOVE to a reusable function.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
a6300ed6 | 29-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Split out semihost_sys_flen
The ARM-specific SYS_FLEN isn't really something that can be reused by other semihosting apis, but there are parts that can reused for the implementation of
semihosting: Split out semihost_sys_flen
The ARM-specific SYS_FLEN isn't really something that can be reused by other semihosting apis, but there are parts that can reused for the implementation of semihost_sys_fstat.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
a2212474 | 28-Apr-2022 |
Richard Henderson <richard.henderson@linaro.org> |
semihosting: Split out semihost_sys_isatty
Split out the non-ARM specific portions of SYS_ISTTY to a reusable function. This handles all GuestFD.
Add a common_semi_istty_cb helper to translate the
semihosting: Split out semihost_sys_isatty
Split out the non-ARM specific portions of SYS_ISTTY to a reusable function. This handles all GuestFD.
Add a common_semi_istty_cb helper to translate the Posix error return, 0+ENOTTY, to the Arm semihosting not-a-file success result.
Reviewed-by: Luc Michel <lmichel@kalray.eu> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|