semihosting: Restrict to TCG
Subsystems (2)
cover semihosting: Restrict to TCG
It is pointless to build semihosting when TCG is not available.
Philippe Mathieu-Daudé (3):
target/mips: Restrict semihosting to TCG
target/riscv: Restrict semihosting to TCG
semihosting: Restrict to TCG
semihosting/Kconfig | 1 + target/mips/Kconfig | 2 +- target/riscv/Kconfig | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/3 target/mips: Restrict semihosting to TCG
It is pointless to build semihosting when TCG is not available.
--- target/mips/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/mips/Kconfig +1 -1
@@ -1,6 +1,6 @@ config MIPS bool - select SEMIHOSTING + select SEMIHOSTING if TCG config MIPS64 bool
Signature · 1 line
2.41.0
PATCH 2/3 target/riscv: Restrict semihosting to TCG
In reply to Philippe Mathieu-DaudéIt is pointless to build semihosting when TCG is not available.
--- target/riscv/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/riscv/Kconfig +2 -2
@@ -1,9 +1,9 @@ config RISCV32 bool - select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() + select ARM_COMPATIBLE_SEMIHOSTING if TCG # for do_common_semihosting() select DEVICE_TREE # needed by boot.c config RISCV64 bool - select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting() + select ARM_COMPATIBLE_SEMIHOSTING if TCG # for do_common_semihosting() select DEVICE_TREE # needed by boot.c
Signature · 1 line
2.41.0
PATCH 3/3 semihosting: Restrict to TCG
In reply to Philippe Mathieu-DaudéIt is pointless to build semihosting when TCG is not available.
--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)
semihosting/Kconfig +1 -0
@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool
Signature · 1 line
2.41.0
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Paolo
Quoted 20 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)semihosting/Kconfig +1
-1@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool --2.41.0
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG probe_access API, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).
Quoted 23 lines
Paolo
Quoted 20 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)semihosting/Kconfig +1
-1@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool --2.41.0
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).
Ok, that goes in the commit message though.
"Semihosting currently uses the TCG probe_access API. It is pointless to have it in the binary when TCG isn't".
and in the first two patches:
"Semihosting currently uses the TCG probe_access API. To prepare for encoding the TCG dependency in Kconfig, do not enable it unless TCG is available".
But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select ARM_COMPATIBLE_SEMIHOSTING if TCG".
Paolo
Quoted 24 lines
Quoted 23 lines
Paolo
Quoted 20 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)semihosting/Kconfig +1
-1@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool --2.41.0
Quoted 28 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).Ok, that goes in the commit message though.
"Semihosting currently uses the TCG
probe_accessAPI. It is pointless to have it in the binary when TCG isn't".and in the first two patches:
Quoted 7 lines
"Semihosting currently uses the TCG
probe_accessAPI. To prepare for encoding the TCG dependency inKconfig, do not enable it unless TCG is available".But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select
ARM_COMPATIBLE_SEMIHOSTINGif TCG".
You are right. Thanks for reminding me Kconfig "imply" :)
Regards,
Phil.
Hi Paolo,
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).Ok, that goes in the commit message though.
"Semihosting currently uses the TCG
probe_accessAPI. It is pointless to have it in the binary when TCG isn't".and in the first two patches:
Quoted 7 lines
Quoted 7 lines
"Semihosting currently uses the TCG
probe_accessAPI. To prepare for encoding the TCG dependency inKconfig, do not enable it unless TCG is available".But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select
ARM_COMPATIBLE_SEMIHOSTINGif TCG".
Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o
"_semihost_sys_close", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_strlen_user", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o
...
So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from:
_do_m68k_semihosting in target_m68k_m68k-semi.c.o
...
I can link m68k using semihosting stubs but I'm not sure it is right:
-- >8 --
semihosting/stubs-target-all.c new file +97 -0
@@ -0,0 +1,97 @@ +/* +* Semihosting Stubs +* +* Copyright (c) 2024 Linaro Ltd +* +* Stubs for semihosting targets that don't actually do semihosting. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "exec/exec-all.h" +#include "semihosting/syscalls.h" + +void semihost_sys_open (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong fname,target_ulong fname_len, +int gdb_flags,int mode) +{ +} + +void semihost_sys_close (CPUState *cs,gdb_syscall_complete_cb complete,int fd) +{ +} + +void semihost_sys_read_gf (CPUState *cs,gdb_syscall_complete_cb complete, +GuestFD *gf,target_ulong buf,target_ulong len) +{ +} + +void semihost_sys_read (CPUState *cs,gdb_syscall_complete_cb complete, +int fd,target_ulong buf,target_ulong len) +{ +} + +void semihost_sys_write_gf (CPUState *cs,gdb_syscall_complete_cb complete, +GuestFD *gf,target_ulong buf,target_ulong len) +{ +} + +void semihost_sys_write (CPUState *cs,gdb_syscall_complete_cb complete, +int fd,target_ulong buf,target_ulong len) +{ +} + +void semihost_sys_lseek (CPUState *cs,gdb_syscall_complete_cb complete, +int fd,int64_t off,int gdb_whence) +{ +} + +void semihost_sys_isatty (CPUState *cs,gdb_syscall_complete_cb complete,int fd) +{ +} + +void semihost_sys_flen (CPUState *cs,gdb_syscall_complete_cb fstat_cb, +gdb_syscall_complete_cb flen_cb,int fd, +target_ulong fstat_addr) +{ +} + +void semihost_sys_fstat (CPUState *cs,gdb_syscall_complete_cb complete, +int fd,target_ulong addr) +{ +} + +void semihost_sys_stat (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong fname,target_ulong fname_len, +target_ulong addr) +{ +} + +void semihost_sys_remove (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong fname,target_ulong fname_len) +{ +} + +void semihost_sys_rename (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong oname,target_ulong oname_len, +target_ulong nname,target_ulong nname_len) +{ +} + +void semihost_sys_system (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong cmd,target_ulong cmd_len) +{ +} + +void semihost_sys_gettimeofday (CPUState *cs,gdb_syscall_complete_cb complete, +target_ulong tv_addr,target_ulong tz_addr) +{ +} + +#ifndef CONFIG_USER_ONLY +void semihost_sys_poll_one (CPUState *cs,gdb_syscall_complete_cb complete, +int fd,GIOCondition cond,int timeout) +{ +} +#endif
semihosting/meson.build +1 -1
@@ -7,7 +7,7 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'], if_true: fil 'config.c', 'console.c', 'uaccess.c', -)) +), if_false: files('stubs-target-all.c')) common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'],
if_false: files('stubs-all.c'))
system_ss.add(when: ['CONFIG_SEMIHOSTING'], if_false:
files('stubs-system.c'))
---
For mips more stubs are needed:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_lock_user", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _uhi_fstat_cb in target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_lock_user_string", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_strlen_user", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_unlock_user", referenced from:
_mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting in target_mips_tcg_sysemu_mips-semi.c.o _uhi_fstat_cb in target_mips_tcg_sysemu_mips-semi.c.o
...
ping :)
Quoted 214 lines · Philippe Mathieu-Daudé
Hi Paolo,
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).Ok, that goes in the commit message though.
"Semihosting currently uses the TCG
probe_accessAPI. It is pointless to have it in the binary when TCG isn't".and in the first two patches:
Quoted 7 lines
Quoted 7 lines
"Semihosting currently uses the TCG
probe_accessAPI. To prepare for encoding the TCG dependency inKconfig, do not enable it unless TCG is available".But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select
ARM_COMPATIBLE_SEMIHOSTINGif TCG".Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_semihost_sys_close", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
...So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from:
_do_m68k_semihostingin target_m68k_m68k-semi.c.o
...I can link m68k using semihosting stubs but I'm not sure it is right:
-- >8 --
semihosting/stubs-target-all.c new file +21
-0@@ -0,0 +1,97 @@ +/* +* Semihosting Stubs +* +* Copyright (c) 2024 Linaro Ltd +* +* Stubs for semihosting targets that don't actually do semihosting. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "exec/exec-all.h" +#include "semihosting/syscalls.h" + +void semihost_sys_open (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + int gdb_flags, int mode) +{ +} + +void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cb complete,int fd)
semihosting/stubs-target-all.c new file +15
-0+{ +} + +void semihost_sys_read_gf (CPUState *cs,gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_read (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_write_gf (CPUState *cs,gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf, target_ulonglen)
semihosting/stubs-target-all.c new file +14
-0+{ +} + +void semihost_sys_write (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_lseek (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, int64_t off, int gdb_whence) +{ +} + +void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cbcomplete, int fd)
semihosting/stubs-target-all.c new file +37
-0+{ +} + +void semihost_sys_flen (CPUState *cs,gdb_syscall_complete_cb fstat_cb, + gdb_syscall_complete_cb flen_cb, int fd, + target_ulong fstat_addr) +{ +} + +void semihost_sys_fstat (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong addr) +{ +} + +void semihost_sys_stat (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + target_ulong addr) +{ +} + +void semihost_sys_remove (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len) +{ +} + +void semihost_sys_rename (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong oname, target_ulong oname_len, + target_ulong nname, target_ulong nname_len) +{ +} + +void semihost_sys_system (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong cmd, target_ulong cmd_len) +{ +} + +void semihost_sys_gettimeofday(CPUState *cs, gdb_syscall_complete_cbcomplete,
+target_ulongtv_addr,target_ulongtz_addr)semihosting/stubs-target-all.c new file +9
-0+{ +} + +#ifndef CONFIG_USER_ONLY +void semihost_sys_poll_one (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, GIOCondition cond, int timeout) +{ +} +#endif semihosting/meson.build +0
-0@@ -7,7 +7,7 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING','
CONFIG_SYSTEM_ONLY'],if_true: fil
'config.c',
'console.c',
'uaccess.c',semihosting/meson.build +1
-1-)) +), if_false: files('stubs-target-all.c')) common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'],
if_false: files('stubs-all.c'))
system_ss.add(when: ['CONFIG_SEMIHOSTING'],if_false:
files('stubs-system.c'))
---For mips more stubs are needed:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user_string", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_unlock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o
...
Quoted 200 lines · Philippe Mathieu-Daudé
ping :)
Quoted 197 lines · Philippe Mathieu-Daudé
Hi Paolo,
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).Ok, that goes in the commit message though.
"Semihosting currently uses the TCG
probe_accessAPI. It is pointless to have it in the binary when TCG isn't".and in the first two patches:
Quoted 7 lines
Quoted 7 lines
"Semihosting currently uses the TCG
probe_accessAPI. To prepare for encoding the TCG dependency inKconfig, do not enable it unless TCG is available".But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select
ARM_COMPATIBLE_SEMIHOSTINGif TCG".Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_semihost_sys_close", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
...
So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from:
_do_m68k_semihostingin target_m68k_m68k-semi.c.o
...
I can link m68k using semihosting stubs but I'm not sure it is right:
-- >8 --semihosting/stubs-target-all.c new file +21
-0@@ -0,0 +1,97 @@ +/* +* Semihosting Stubs +* +* Copyright (c) 2024 Linaro Ltd +* +* Stubs for semihosting targets that don't actually do semihosting. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "exec/exec-all.h" +#include "semihosting/syscalls.h" + +void semihost_sys_open (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + int gdb_flags, int mode) +{ +} + +void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cbcomplete, int fd)
semihosting/stubs-target-all.c new file +15
-0+{ +} + +void semihost_sys_read_gf (CPUState *cs,gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_read (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf,
target_ulonglen)semihosting/stubs-target-all.c new file +14
-0+{ +} + +void semihost_sys_write (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_lseek (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, int64_t off, int gdb_whence) +{ +} + +void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cbcomplete, int fd)
semihosting/stubs-target-all.c new file +37
-0+{ +} + +void semihost_sys_flen (CPUState *cs,gdb_syscall_complete_cb fstat_cb, + gdb_syscall_complete_cb flen_cb, int fd, + target_ulong fstat_addr) +{ +} + +void semihost_sys_fstat (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong addr) +{ +} + +void semihost_sys_stat (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + target_ulong addr) +{ +} + +void semihost_sys_remove (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len) +{ +} + +void semihost_sys_rename (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong oname, target_ulong oname_len, + target_ulong nname, target_ulong nname_len) +{ +} + +void semihost_sys_system (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong cmd, target_ulong cmd_len) +{ +} + +void semihost_sys_gettimeofday(CPUState *cs,
gdb_syscall_complete_cbcomplete,
+target_ulongtv_addr,target_ulongtz_addr)semihosting/stubs-target-all.c new file +9
-0+{ +} + +#ifndef CONFIG_USER_ONLY +void semihost_sys_poll_one (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, GIOCondition cond, int timeout) +{ +} +#endif semihosting/meson.build +0
-0@@ -7,7 +7,7 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING','
CONFIG_SYSTEM_ONLY'],if_true: fil
'config.c',
'console.c',
'uaccess.c',semihosting/meson.build +1
-1-)) +), if_false: files('stubs-target-all.c')) common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'],
if_false: files('stubs-all.c'))
system_ss.add(when: ['CONFIG_SEMIHOSTING'],if_false:
files('stubs-system.c'))
---
For mips more stubs are needed:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user_string", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_unlock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
Quoted 8 lines
Quoted 8 lines
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o
...
Oh sorry I was waiting for a re-spin. I should just apply the above to 3/3?
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 205 lines · Alex Bennée
Quoted 203 lines · Philippe Mathieu-Daudé
ping :)
Quoted 200 lines · Philippe Mathieu-Daudé
Hi Paolo,
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 28 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
Quoted 7 lines
I wasn't sure where semihosting could be used so asked on IRC and Alex told me TCG only. Maybe the current implementation is TCG only, and I can reword. It certainly need some refactor to work on KVM, because currently semihosting end calling the TCG
probe_accessAPI, which I'm trying to restrict to TCG in order to ease linking multiple libtcg for the single binary (see
https://lore.kernel.org/qemu-devel/[email protected]/).Ok, that goes in the commit message though.
"Semihosting currently uses the TCG
probe_accessAPI. It is pointless to have it in the binary when TCG isn't".and in the first two patches:
Quoted 7 lines
Quoted 7 lines
"Semihosting currently uses the TCG
probe_accessAPI. To prepare for encoding the TCG dependency inKconfig, do not enable it unless TCG is available".But then, "select FOO if TCG" mean that it can be compiled out; so perhaps "imply SEMIHOSTING if TCG" is better? Same for RISC-V's "select
ARM_COMPATIBLE_SEMIHOSTINGif TCG".Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_semihost_sys_close", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
...
So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from:
_do_m68k_semihostingin target_m68k_m68k-semi.c.o
...
I can link m68k using semihosting stubs but I'm not sure it is right:
-- >8 --semihosting/stubs-target-all.c new file +21
-0@@ -0,0 +1,97 @@ +/* +* Semihosting Stubs +* +* Copyright (c) 2024 Linaro Ltd +* +* Stubs for semihosting targets that don't actually do semihosting. +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "exec/exec-all.h" +#include "semihosting/syscalls.h" + +void semihost_sys_open (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + int gdb_flags, int mode) +{ +} + +void semihost_sys_close(CPUState *cs, gdb_syscall_complete_cbcomplete, int fd)
semihosting/stubs-target-all.c new file +15
-0+{ +} + +void semihost_sys_read_gf (CPUState *cs,gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_read (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_write_gf(CPUState *cs, gdb_syscall_complete_cb complete, + GuestFD *gf, target_ulong buf,
target_ulonglen)semihosting/stubs-target-all.c new file +14
-0+{ +} + +void semihost_sys_write (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong buf, target_ulong len) +{ +} + +void semihost_sys_lseek (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, int64_t off, int gdb_whence) +{ +} + +void semihost_sys_isatty(CPUState *cs, gdb_syscall_complete_cbcomplete, int fd)
semihosting/stubs-target-all.c new file +37
-0+{ +} + +void semihost_sys_flen (CPUState *cs,gdb_syscall_complete_cb fstat_cb, + gdb_syscall_complete_cb flen_cb, int fd, + target_ulong fstat_addr) +{ +} + +void semihost_sys_fstat (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, target_ulong addr) +{ +} + +void semihost_sys_stat (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len, + target_ulong addr) +{ +} + +void semihost_sys_remove (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong fname, target_ulong fname_len) +{ +} + +void semihost_sys_rename (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong oname, target_ulong oname_len, + target_ulong nname, target_ulong nname_len) +{ +} + +void semihost_sys_system (CPUState *cs,gdb_syscall_complete_cb complete, + target_ulong cmd, target_ulong cmd_len) +{ +} + +void semihost_sys_gettimeofday(CPUState *cs,
gdb_syscall_complete_cbcomplete,
+target_ulongtv_addr,target_ulongtz_addr)semihosting/stubs-target-all.c new file +9
-0+{ +} + +#ifndef CONFIG_USER_ONLY +void semihost_sys_poll_one (CPUState *cs,gdb_syscall_complete_cb complete, + int fd, GIOCondition cond, int timeout) +{ +} +#endif semihosting/meson.build +0
-0@@ -7,7 +7,7 @@ specific_ss.add(when: ['CONFIG_SEMIHOSTING','
CONFIG_SYSTEM_ONLY'],if_true: fil
'config.c',
'console.c',
'uaccess.c',semihosting/meson.build +1
-1-)) +), if_false: files('stubs-target-all.c')) common_ss.add(when: ['CONFIG_SEMIHOSTING', 'CONFIG_SYSTEM_ONLY'],
if_false: files('stubs-all.c'))
system_ss.add(when: ['CONFIG_SEMIHOSTING'],if_false:
files('stubs-system.c'))
---
For mips more stubs are needed:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_lock_user_string", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o _mips_semihosting.cold.6 in target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o "_uaccess_unlock_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o_uhi_fstat_cbin target_mips_tcg_sysemu_mips-semi.c.o
...Oh sorry I was waiting for a re-spin. I should just apply the above to 3/3?
No, this is still unresolved :/ (this is a ping for Paolo :p)
Quoted 11 lines · Philippe Mathieu-Daudé
Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
"_semihost_sys_close", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
...
Quoted 8 lines
So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from: _do_m68k_semihosting in target_m68k_m68k-semi.c.o ...
Go ahead and use "select" for these. The file to be stubbed would have to be target/m68k/m68k-semi.c (for do_m68k_semihosting) and target/mips/tcg/sysemu/mips-semi.c (for mips_semihosting), not the common code.
Paolo
Quoted 23 lines · Paolo Bonzini
Quoted 11 lines · Philippe Mathieu-Daudé
Building qemu-system-mips configured with --without-default-devices:
Undefined symbols for architecture arm64:
"_qemu_semihosting_console_write", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
"_semihost_sys_close", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
"_uaccess_strlen_user", referenced from:
_mips_semihostingin target_mips_tcg_sysemu_mips-semi.c.o
...Quoted 8 lines
So this one has to use "select".
Similarly m68k:
Undefined symbols for architecture arm64:
"_semihost_sys_close", referenced from: _do_m68k_semihosting in target_m68k_m68k-semi.c.o ...
Quoted 4 lines
The file to be stubbed would have
to betarget/m68k/m68k-semi.c(fordo_m68k_semihosting) andtarget/mips/tcg/sysemu/mips-semi.c(formips_semihosting), not the common code.
Yes! Thank you, I'm was to blind to realize that...
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Why? I would have naively assumed that a suitable semihosting API could be implemented by KVM. The justification (and thus the commit message) needs to be different for each architecture if it's a matter of instruction set or insufficient KVM userspace API.
For Arm at least the HLT instruction is an external debug feature and as such not trappable by KVM.
Quoted 23 lines
Paolo
Quoted 20 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- semihosting/Kconfig | 1 + 1 file changed, 1 insertion(+)semihosting/Kconfig +1
-1@@ -1,6 +1,7 @@ config SEMIHOSTING bool + depends on TCG config ARM_COMPATIBLE_SEMIHOSTING bool --2.41.0
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 4 lines · Philippe Mathieu-Daudé
Philippe Mathieu-Daudé (3):
target/mips: Restrict semihosting to TCG
target/riscv: Restrict semihosting to TCG
semihosting: Restrict to TCG
r~
Alex Bennée
AppliedQuoted 6 lines · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Philippe Mathieu-Daudé (3):
target/mips: Restrict semihosting to TCG
target/riscv: Restrict semihosting to TCG
semihosting: Restrict to TCG
Queued to semihosting/next, thanks.
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 11 lines · Alex Bennée
Quoted 6 lines · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Philippe Mathieu-Daudé (3):
target/mips: Restrict semihosting to TCG
target/riscv: Restrict semihosting to TCG
semihosting: Restrict to TCGQueued to semihosting/next, thanks.
Please don't, at least not in the current form. These are jokes, not commit messages...
Paolo
Quoted 11 lines · Paolo Bonzini
Quoted 10 lines · Alex Bennée
Quoted 6 lines · Philippe Mathieu-Daudé
It is pointless to build semihosting when TCG is not available.
Philippe Mathieu-Daudé (3):
target/mips: Restrict semihosting to TCG
target/riscv: Restrict semihosting to TCG
semihosting: Restrict to TCG
Quoted 4 lines
Quoted 1 line
Queued to semihosting/next, thanks.
Please don't, at least not in the current form. These are jokes, not commit messages...
Sorry if it appears to you as a joke, I thought it would be something trivial :(