qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/8] semihosting: Restrict to TCG
@ 2024-07-17 10:57 Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 1/8] semihosting: Include missing 'gdbstub/syscalls.h' header Philippe Mathieu-Daudé
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe =?unknown-8bit?q?Mathieu-Daud=C3=A9?=

v4: Address Paolo's comment
v3: Address Anton's comment
v2: Address Paolo's comment

Semihosting currently uses the TCG probe_access API,
so it is pointless to have it in the binary when TCG
isn't.

It could be implemented for other accelerators, but
work need to be done. Meanwhile, do not enable it
unless TCG is available.

Philippe Mathieu-Daudé (8):
  semihosting: Include missing 'gdbstub/syscalls.h' header
  target/m68k: Add semihosting stub
  target/mips: Add semihosting stub
  target/m68k: Restrict semihosting to TCG
  target/mips: Restrict semihosting to TCG
  target/riscv: Restrict semihosting to TCG
  target/xtensa: Restrict semihosting to TCG
  semihosting: Restrict to TCG

 include/semihosting/syscalls.h            |  2 ++
 target/m68k/semihosting-stub.c            | 15 +++++++++++++++
 target/mips/tcg/sysemu/semihosting-stub.c | 15 +++++++++++++++
 semihosting/Kconfig                       |  1 +
 target/m68k/Kconfig                       |  2 +-
 target/m68k/meson.build                   |  5 ++++-
 target/mips/Kconfig                       |  2 +-
 target/mips/tcg/sysemu/meson.build        |  6 ++++--
 target/riscv/Kconfig                      |  4 ++--
 target/xtensa/Kconfig                     |  2 +-
 10 files changed, 46 insertions(+), 8 deletions(-)
 create mode 100644 target/m68k/semihosting-stub.c
 create mode 100644 target/mips/tcg/sysemu/semihosting-stub.c

-- 
2.41.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v4 1/8] semihosting: Include missing 'gdbstub/syscalls.h' header
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 2/8] target/m68k: Add semihosting stub Philippe Mathieu-Daudé
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

"semihosting/syscalls.h" requires definitions from
"gdbstub/syscalls.h", include it in order to avoid:

  include/semihosting/syscalls.h:23:38: error: unknown type name 'gdb_syscall_complete_cb'
  void semihost_sys_open(CPUState *cs, gdb_syscall_complete_cb complete,
                                       ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/semihosting/syscalls.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/semihosting/syscalls.h b/include/semihosting/syscalls.h
index 3a5ec229eb..b5937c619a 100644
--- a/include/semihosting/syscalls.h
+++ b/include/semihosting/syscalls.h
@@ -9,6 +9,8 @@
 #ifndef SEMIHOSTING_SYSCALLS_H
 #define SEMIHOSTING_SYSCALLS_H
 
+#include "gdbstub/syscalls.h"
+
 /*
  * Argument loading from the guest is performed by the caller;
  * results are returned via the 'complete' callback.
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 2/8] target/m68k: Add semihosting stub
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 1/8] semihosting: Include missing 'gdbstub/syscalls.h' header Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 3/8] target/mips: " Philippe Mathieu-Daudé
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

Since the SEMIHOSTING feature is optional, we need
a stub to link when it is disabled.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/m68k/semihosting-stub.c | 15 +++++++++++++++
 target/m68k/meson.build        |  5 ++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 target/m68k/semihosting-stub.c

diff --git a/target/m68k/semihosting-stub.c b/target/m68k/semihosting-stub.c
new file mode 100644
index 0000000000..d6a5965e29
--- /dev/null
+++ b/target/m68k/semihosting-stub.c
@@ -0,0 +1,15 @@
+/*
+ *  m68k/ColdFire semihosting stub
+ *
+ * SPDX-FileContributor: Philippe Mathieu-Daudé <philmd@linaro.org>
+ * SPDX-FileCopyrightText: 2024 Linaro Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+void do_m68k_semihosting(CPUM68KState *env, int nr)
+{
+    g_assert_not_reached();
+}
diff --git a/target/m68k/meson.build b/target/m68k/meson.build
index 8d3f9ce288..4d213daaf6 100644
--- a/target/m68k/meson.build
+++ b/target/m68k/meson.build
@@ -11,9 +11,12 @@ m68k_ss.add(files(
 
 m68k_system_ss = ss.source_set()
 m68k_system_ss.add(files(
-  'm68k-semi.c',
   'monitor.c'
 ))
+m68k_system_ss.add(when: ['CONFIG_SEMIHOSTING'],
+  if_true: files('m68k-semi.c'),
+  if_false: files('semihosting-stub.c')
+)
 
 target_arch += {'m68k': m68k_ss}
 target_system_arch += {'m68k': m68k_system_ss}
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 3/8] target/mips: Add semihosting stub
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 1/8] semihosting: Include missing 'gdbstub/syscalls.h' header Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 2/8] target/m68k: Add semihosting stub Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 4/8] target/m68k: Restrict semihosting to TCG Philippe Mathieu-Daudé
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

Since the SEMIHOSTING feature is optional, we need
a stub to link when it is disabled.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/mips/tcg/sysemu/semihosting-stub.c | 15 +++++++++++++++
 target/mips/tcg/sysemu/meson.build        |  6 ++++--
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 target/mips/tcg/sysemu/semihosting-stub.c

diff --git a/target/mips/tcg/sysemu/semihosting-stub.c b/target/mips/tcg/sysemu/semihosting-stub.c
new file mode 100644
index 0000000000..7ae27d746f
--- /dev/null
+++ b/target/mips/tcg/sysemu/semihosting-stub.c
@@ -0,0 +1,15 @@
+/*
+ *  MIPS semihosting stub
+ *
+ * SPDX-FileContributor: Philippe Mathieu-Daudé <philmd@linaro.org>
+ * SPDX-FileCopyrightText: 2024 Linaro Ltd.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "internal.h"
+
+void mips_semihosting(CPUMIPSState *env)
+{
+    g_assert_not_reached();
+}
diff --git a/target/mips/tcg/sysemu/meson.build b/target/mips/tcg/sysemu/meson.build
index ec665a4b1e..911341ac37 100644
--- a/target/mips/tcg/sysemu/meson.build
+++ b/target/mips/tcg/sysemu/meson.build
@@ -1,10 +1,12 @@
 mips_system_ss.add(files(
   'cp0_helper.c',
-  'mips-semi.c',
   'special_helper.c',
   'tlb_helper.c',
 ))
-
+mips_system_ss.add(when: ['CONFIG_SEMIHOSTING'],
+  if_true: files('mips-semi.c'),
+  if_false: files('semihosting-stub.c')
+)
 mips_system_ss.add(when: 'TARGET_MIPS64', if_true: files(
   'lcsr_helper.c',
 ))
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 4/8] target/m68k: Restrict semihosting to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 3/8] target/mips: " Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 5/8] target/mips: " Philippe Mathieu-Daudé
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

The semihosting feature depends on TCG (due to the probe_access
API access). Although TCG is the single accelerator currently
available for the m68k target, use the Kconfig "imply" directive
which is more correct (if we were to support a different accel).

Reported-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/m68k/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/m68k/Kconfig b/target/m68k/Kconfig
index 9eae71486f..23aae24ebe 100644
--- a/target/m68k/Kconfig
+++ b/target/m68k/Kconfig
@@ -1,3 +1,3 @@
 config M68K
     bool
-    select SEMIHOSTING
+    imply SEMIHOSTING if TCG
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 5/8] target/mips: Restrict semihosting to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 4/8] target/m68k: Restrict semihosting to TCG Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 6/8] target/riscv: " Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

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.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
---
 target/mips/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/mips/Kconfig b/target/mips/Kconfig
index eb19c94c7d..876048b150 100644
--- a/target/mips/Kconfig
+++ b/target/mips/Kconfig
@@ -1,6 +1,6 @@
 config MIPS
     bool
-    select SEMIHOSTING
+    imply SEMIHOSTING if TCG
 
 config MIPS64
     bool
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 6/8] target/riscv: Restrict semihosting to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (4 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 5/8] target/mips: " Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 7/8] target/xtensa: " Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

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.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Anton Johansson <anjo@rev.ng>
---
 target/riscv/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/riscv/Kconfig b/target/riscv/Kconfig
index 5f30df22f2..c332616d36 100644
--- a/target/riscv/Kconfig
+++ b/target/riscv/Kconfig
@@ -1,9 +1,9 @@
 config RISCV32
     bool
-    select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting()
+    imply ARM_COMPATIBLE_SEMIHOSTING if TCG
     select DEVICE_TREE # needed by boot.c
 
 config RISCV64
     bool
-    select ARM_COMPATIBLE_SEMIHOSTING # for do_common_semihosting()
+    imply ARM_COMPATIBLE_SEMIHOSTING if TCG
     select DEVICE_TREE # needed by boot.c
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 7/8] target/xtensa: Restrict semihosting to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (5 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 6/8] target/riscv: " Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 10:57 ` [PATCH v4 8/8] semihosting: Restrict " Philippe Mathieu-Daudé
  2024-07-17 18:21 ` [PATCH v4 0/8] " Alex Bennée
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

The semihosting feature depends on TCG (due to the probe_access
API access). Although TCG is the single accelerator currently
available for the xtensa target, use the Kconfig "imply" directive
which is more correct (if we were to support a different accel).

Reported-by: Anton Johansson <anjo@rev.ng>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/xtensa/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/xtensa/Kconfig b/target/xtensa/Kconfig
index 5e46049262..e8c2598c4d 100644
--- a/target/xtensa/Kconfig
+++ b/target/xtensa/Kconfig
@@ -1,3 +1,3 @@
 config XTENSA
     bool
-    select SEMIHOSTING
+    imply SEMIHOSTING if TCG
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 8/8] semihosting: Restrict to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (6 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 7/8] target/xtensa: " Philippe Mathieu-Daudé
@ 2024-07-17 10:57 ` Philippe Mathieu-Daudé
  2024-07-17 18:21 ` [PATCH v4 0/8] " Alex Bennée
  8 siblings, 0 replies; 10+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-17 10:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Richard Henderson, Alex Bennée, Anton Johansson, qemu-riscv,
	Paolo Bonzini, Philippe Mathieu-Daudé

Semihosting currently uses the TCG probe_access API.
It is pointless to have it in the binary when TCG isn't.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 semihosting/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/semihosting/Kconfig b/semihosting/Kconfig
index eaf3a20ef5..fbe6ac87f9 100644
--- a/semihosting/Kconfig
+++ b/semihosting/Kconfig
@@ -1,6 +1,7 @@
 
 config SEMIHOSTING
        bool
+       depends on TCG
 
 config ARM_COMPATIBLE_SEMIHOSTING
        bool
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 0/8] semihosting: Restrict to TCG
  2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
                   ` (7 preceding siblings ...)
  2024-07-17 10:57 ` [PATCH v4 8/8] semihosting: Restrict " Philippe Mathieu-Daudé
@ 2024-07-17 18:21 ` Alex Bennée
  8 siblings, 0 replies; 10+ messages in thread
From: Alex Bennée @ 2024-07-17 18:21 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: qemu-devel, Richard Henderson, Anton Johansson, qemu-riscv,
	Paolo Bonzini

Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> v4: Address Paolo's comment
> v3: Address Anton's comment
> v2: Address Paolo's comment
>
> Semihosting currently uses the TCG probe_access API,
> so it is pointless to have it in the binary when TCG
> isn't.
>
> It could be implemented for other accelerators, but
> work need to be done. Meanwhile, do not enable it
> unless TCG is available.

Queued to semihosting/next, thanks.
<snip>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-07-17 18:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17 10:57 [PATCH v4 0/8] semihosting: Restrict to TCG Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 1/8] semihosting: Include missing 'gdbstub/syscalls.h' header Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 2/8] target/m68k: Add semihosting stub Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 3/8] target/mips: " Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 4/8] target/m68k: Restrict semihosting to TCG Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 5/8] target/mips: " Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 6/8] target/riscv: " Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 7/8] target/xtensa: " Philippe Mathieu-Daudé
2024-07-17 10:57 ` [PATCH v4 8/8] semihosting: Restrict " Philippe Mathieu-Daudé
2024-07-17 18:21 ` [PATCH v4 0/8] " Alex Bennée

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 NNTP newsgroup(s).