qemu/target/xtensa
Peter Maydell 5202861b20 semihosting: Allow optional use of semihosting from userspace
Currently our semihosting implementations generally prohibit use of
semihosting calls in system emulation from the guest userspace.  This
is a very long standing behaviour justified originally "to provide
some semblance of security" (since code with access to the
semihosting ABI can do things like read and write arbitrary files on
the host system).  However, it is sometimes useful to be able to run
trusted guest code which performs semihosting calls from guest
userspace, notably for test code.  Add a command line suboption to
the existing semihosting-config option group so that you can
explicitly opt in to semihosting from guest userspace with
 -semihosting-config userspace=on

(There is no equivalent option for the user-mode emulator, because
there by definition all code runs in userspace and has access to
semihosting already.)

This commit adds the infrastructure for the command line option and
adds a bool 'is_user' parameter to the function
semihosting_userspace_enabled() that target code can use to check
whether it should be permitting the semihosting call for userspace.
It mechanically makes all the callsites pass 'false', so they
continue checking "is semihosting enabled in general".  Subsequent
commits will make each target that implements semihosting honour the
userspace=on option by passing the correct value and removing
whatever "don't do this for userspace" checking they were doing by
hand.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Acked-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220822141230.3658237-2-peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2022-09-13 17:18:21 +01:00
..
core-dc232b meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-dc233c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-de212 meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-de233_fpu Clean up decorations and whitespace around header guards 2022-05-11 16:50:32 +02:00
core-dsp3400 Clean up decorations and whitespace around header guards 2022-05-11 16:50:32 +02:00
core-fsf meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-lx106 target/xtensa: import core lx106 2022-05-06 15:27:40 -07:00
core-sample_controller meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-test_kc705_be meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-test_mmuhifi_c3 meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-dc232b.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-dc233c.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-de212.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-de233_fpu.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
core-dsp3400.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
core-fsf.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-lx106.c target/xtensa: import core lx106 2022-05-06 15:27:40 -07:00
core-sample_controller.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-test_kc705_be.c meson: rename included C source files to .c.inc 2020-08-21 06:18:30 -04:00
core-test_mmuhifi_c3.c Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
cores.list target/xtensa: import core lx106 2022-05-06 15:27:40 -07:00
cpu-param.h Normalize header guard symbol definition 2022-05-11 16:50:26 +02:00
cpu-qom.h target: Introduce and use OBJECT_DECLARE_CPU_TYPE() macro 2022-03-06 22:23:09 +01:00
cpu.c target/xtensa: add clock input to xtensa CPU 2022-05-06 15:27:40 -07:00
cpu.h target/xtensa: add clock input to xtensa CPU 2022-05-06 15:27:40 -07:00
dbg_helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
exc_helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
fpu_helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
gdbstub.c xtensa tcg cpus: Fix Lesser GPL version number 2020-11-15 16:40:15 +01:00
helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
helper.h target/xtensa: implement FPU division and square root 2020-08-21 12:48:15 -07:00
import_core.sh Remove qemu-common.h include from most units 2022-04-06 14:31:55 +02:00
Kconfig meson: Introduce target-specific Kconfig 2021-07-09 18:21:34 +02:00
meson.build target/xtensa: list cores in a text file 2021-10-05 13:10:29 +02:00
mmu_helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
monitor.c hmp: Pass monitor to mon_get_cpu_env() 2020-11-13 12:45:51 +00:00
op_helper.c target/xtensa: add clock input to xtensa CPU 2022-05-06 15:27:40 -07:00
overlay_tool.h Replace TARGET_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
translate.c semihosting: Allow optional use of semihosting from userspace 2022-09-13 17:18:21 +01:00
win_helper.c exec/exec-all: Move 'qemu/log.h' include in units requiring it 2022-02-21 10:18:06 +01:00
xtensa-isa-internal.h Clean up decorations and whitespace around header guards 2019-05-13 08:58:55 +02:00
xtensa-isa.c Clean up includes 2018-02-09 05:05:11 +01:00
xtensa-isa.h Use #include "..." for our own headers, <...> for others 2018-02-09 05:05:11 +01:00
xtensa-semi.c target/xtensa/xtensa-semi: Fix compilation problem on Haiku 2021-07-09 18:42:46 +02:00