Skip to contentSkip to conversation

target: Build with CONFIG_SEMIHOSTING disabled

RFC PATCH Superseded Philippe Mathieu-Daudé 7 participants 17 messages May 31, 2019 – Jun 18, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover target: Build with CONFIG_SEMIHOSTING disabled

Amusingly Miroslav and myself hit this issue at the same time.

Currently there is no way to pass a CONFIG_X to sources in target/, except via a Makefile rule (and filling with stubs).

Paolo says this is on purpose, CONFIG_X selectors are meant for devices and we try to avoid having config-devices.mak in config-target.h.

Some know (arch-specific) limitations are:

- MIPS ITU is accessed by coprocessor instr (ISA feature)
- MIPS timer is accessed by coprocessor instr (ISA feature)
- MIPS semihosting (ISA feature?)
- ARM semihosting (ISA feature?)
- ARMv7 NVIC (device)

This series attempt to fix this the most trivial way, adding stubs for unreachable code.

Philippe Mathieu-Daudé (2):
target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled target/mips: Add stubs to build with CONFIG_SEMIHOSTING disabled

 target/arm/Makefile.objs      |  3 ++-
 target/arm/arm-semi-stubs.c   | 21 +++++++++++++++++++++
 target/mips/Makefile.objs     |  3 ++-
 target/mips/mips-semi-stubs.c | 23 +++++++++++++++++++++++
 4 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 target/arm/arm-semi-stubs.c
 create mode 100644 target/mips/mips-semi-stubs.c
Signature · 1 line
2.20.1
#1 lore raw

RFC PATCH 1/2 target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled

If a distribution wants to build QEMU without semihosting support, it currently gets this build failure:

  $ ./configure --target-list=aarch64-softmmu --without-default-devices
  $ sed -i s/CONFIG_SEMIHOSTING=y/CONFIG_SEMIHOSTING=n/ default-configs/arm-softmmu.mak
  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: target/arm/arm-semi.o: in function `do_arm_semihosting':
  ./target/arm/arm-semi.c:321: undefined reference to `qemu_semihosting_console_out'
  /usr/bin/ld: ./target/arm/arm-semi.c:318: undefined reference to `qemu_semihosting_console_out'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:204: qemu-system-aarch64] Error 1
  make: *** [Makefile:472: subdir-aarch64-softmmu] Error 2

Fix it by providing a stub when semihosting is disabled.

---
 target/arm/Makefile.objs    |  3 ++-
 target/arm/arm-semi-stubs.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 target/arm/arm-semi-stubs.c
target/arm/Makefile.objs +2 -1
index 6bdcc65c2c..39b02b1fa4 100644
@@ -1,4 +1,5 @@
-obj-y += arm-semi.o
+obj-$(CONFIG_SEMIHOSTING) += arm-semi.o
+obj-$(call lnot,$(CONFIG_SEMIHOSTING)) += arm-semi-stubs.o
 obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
target/arm/arm-semi-stubs.c new file +21 -0
new file mode 100644
index 0000000000..a91ecbd9d5
@@ -0,0 +1,21 @@
+/*
+ *  Arm "Angel" semihosting stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+target_ulong do_arm_semihosting(CPUARMState *env)
+{
+    g_assert_not_reached();
+}
Signature · 1 line
2.20.1
#2 lore raw

Re: [RFC PATCH 1/2] target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled

Quoted 5 lines · Philippe Mathieu-Daudé

If a distribution wants to build QEMU without semihosting support, it currently gets this build failure:

  $ ./configure --target-list=aarch64-softmmu --without-default-devices
  $ sed -i s/CONFIG_SEMIHOSTING=y/CONFIG_SEMIHOSTING=n/default-configs/arm-softmmu.mak

I'm still not convinced we should be adding support for stuff being done outside the normal build process... that said...

Quoted 48 lines
  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: target/arm/arm-semi.o: in function `do_arm_semihosting':
  ./target/arm/arm-semi.c:321: undefined reference to `qemu_semihosting_console_out'
  /usr/bin/ld: ./target/arm/arm-semi.c:318: undefined reference to `qemu_semihosting_console_out'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:204: qemu-system-aarch64] Error 1
  make: *** [Makefile:472: subdir-aarch64-softmmu] Error 2

Fix it by providing a stub when semihosting is disabled.

---
 target/arm/Makefile.objs    |  3 ++-
 target/arm/arm-semi-stubs.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 target/arm/arm-semi-stubs.c
target/arm/Makefile.objs +2 -1
index 6bdcc65c2c..39b02b1fa4 100644
@@ -1,4 +1,5 @@
-obj-y += arm-semi.o
+obj-$(CONFIG_SEMIHOSTING) += arm-semi.o
+obj-$(call lnot,$(CONFIG_SEMIHOSTING)) += arm-semi-stubs.o
 obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
target/arm/arm-semi-stubs.c new file +11 -0
new file mode 100644
index 0000000000..a91ecbd9d5
@@ -0,0 +1,21 @@
+/*
+ *  Arm "Angel" semihosting stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.

target/arm/arm-semi-stubs.c line 21

Quoted 10 lines
target/arm/arm-semi-stubs.c new file +10 -0
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+target_ulong do_arm_semihosting(CPUARMState *env)
+{
+    g_assert_not_reached();
+}

Could this not just be added to arm-semi.c in an

  #ifndef CONFIG_SEMIHOSTING
  target_ulong do_arm_semihosting(CPUARMState *env)
  {
      g_assert_not_reached();
  }
  #else
  ... rest of arm-semi.c....
  #endif

--
Alex Bennée

#3 lore raw

Re: [RFC PATCH 1/2] target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled

Quoted 10 lines · Alex Bennée
Quoted 5 lines · Philippe Mathieu-Daudé

If a distribution wants to build QEMU without semihosting support, it currently gets this build failure:

  $ ./configure --target-list=aarch64-softmmu --without-default-devices
  $ sed -i s/CONFIG_SEMIHOSTING=y/CONFIG_SEMIHOSTING=n/default-configs/arm-softmmu.mak

I'm still not convinced we should be adding support for stuff being done outside the normal build process...

If the "KVM/TCG split" series is accepted, then we can add a --disable-tcg job in the list of "normal builds" and we don't need this particular patch.

Quoted 63 lines

that said...

Quoted 48 lines
  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: target/arm/arm-semi.o: in function `do_arm_semihosting':
  ./target/arm/arm-semi.c:321: undefined reference to `qemu_semihosting_console_out'
  /usr/bin/ld: ./target/arm/arm-semi.c:318: undefined reference to `qemu_semihosting_console_out'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:204: qemu-system-aarch64] Error 1
  make: *** [Makefile:472: subdir-aarch64-softmmu] Error 2

Fix it by providing a stub when semihosting is disabled.

---
 target/arm/Makefile.objs    |  3 ++-
 target/arm/arm-semi-stubs.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 target/arm/arm-semi-stubs.c
target/arm/Makefile.objs +2 -1
index 6bdcc65c2c..39b02b1fa4 100644
@@ -1,4 +1,5 @@
-obj-y += arm-semi.o
+obj-$(CONFIG_SEMIHOSTING) += arm-semi.o
+obj-$(call lnot,$(CONFIG_SEMIHOSTING)) += arm-semi-stubs.o
 obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
target/arm/arm-semi-stubs.c new file +11 -0
new file mode 100644
index 0000000000..a91ecbd9d5
@@ -0,0 +1,21 @@
+/*
+ *  Arm "Angel" semihosting stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.

target/arm/arm-semi-stubs.c line 21

Quoted 10 lines
target/arm/arm-semi-stubs.c new file +10 -0
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+target_ulong do_arm_semihosting(CPUARMState *env)
+{
+    g_assert_not_reached();
+}

Could this not just be added to arm-semi.c in an

Quoted 8 lines
  #ifndef CONFIG_SEMIHOSTING
  target_ulong do_arm_semihosting(CPUARMState *env)
  {
      g_assert_not_reached();
  }
  #else
  ... rest of arm-semi.c....
  #endif

OK, thanks for your reviews!

Phil.

#4 lore raw

Re: [RFC PATCH 1/2] target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled

Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Alex Bennée
Quoted 5 lines · Philippe Mathieu-Daudé

If a distribution wants to build QEMU without semihosting support, it currently gets this build failure:

  $ ./configure --target-list=aarch64-softmmu --without-default-devices
  $ sed -i s/CONFIG_SEMIHOSTING=y/CONFIG_SEMIHOSTING=n/default-configs/arm-softmmu.mak
Quoted 78 lines
Quoted 2 lines

I'm still not convinced we should be adding support for stuff being done outside the normal build process...

If the "KVM/TCG split" series is accepted, then we can add a --disable-tcg job in the list of "normal builds" and we don't need this particular patch.

Quoted 71 lines

that said...

Quoted 48 lines
  $ make subdir-aarch64-softmmu
  [...]
    LINK    aarch64-softmmu/qemu-system-aarch64
  /usr/bin/ld: target/arm/arm-semi.o: in function `do_arm_semihosting':
  ./target/arm/arm-semi.c:321: undefined reference to `qemu_semihosting_console_out'
  /usr/bin/ld: ./target/arm/arm-semi.c:318: undefined reference to `qemu_semihosting_console_out'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:204: qemu-system-aarch64] Error 1
  make: *** [Makefile:472: subdir-aarch64-softmmu] Error 2

Fix it by providing a stub when semihosting is disabled.

---
 target/arm/Makefile.objs    |  3 ++-
 target/arm/arm-semi-stubs.c | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 target/arm/arm-semi-stubs.c
target/arm/Makefile.objs +2 -1
index 6bdcc65c2c..39b02b1fa4 100644
@@ -1,4 +1,5 @@
-obj-y += arm-semi.o
+obj-$(CONFIG_SEMIHOSTING) += arm-semi.o
+obj-$(call lnot,$(CONFIG_SEMIHOSTING)) += arm-semi-stubs.o
 obj-$(CONFIG_SOFTMMU) += machine.o psci.o arch_dump.o monitor.o
 obj-$(CONFIG_KVM) += kvm.o
 obj-$(call land,$(CONFIG_KVM),$(call lnot,$(TARGET_AARCH64))) += kvm32.o
target/arm/arm-semi-stubs.c new file +11 -0
new file mode 100644
index 0000000000..a91ecbd9d5
@@ -0,0 +1,21 @@
+/*
+ *  Arm "Angel" semihosting stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.

target/arm/arm-semi-stubs.c line 21

Quoted 10 lines
target/arm/arm-semi-stubs.c new file +10 -0
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+target_ulong do_arm_semihosting(CPUARMState *env)
+{
+    g_assert_not_reached();
+}

Could this not just be added to arm-semi.c in an

  #ifndef CONFIG_SEMIHOSTING
  target_ulong do_arm_semihosting(CPUARMState *env)
  {
      g_assert_not_reached();
  }
  #else
  ... rest of arm-semi.c....
  #endif

Note that CONFIG_SEMIHOSTING is a Make definition, not a CPP one, and it doesn't look straight forward to get it added to config-target.h...

#5 lore raw

RFC PATCH 2/2 target/mips: Add stubs to build with CONFIG_SEMIHOSTING disabled

In reply to Philippe Mathieu-Daudé

If a distribution wants to build QEMU without semihosting support, it currently gets this build failure:

  $ ./configure --target-list=mips64el-softmmu --without-default-devices
  $ sed -i s/CONFIG_SEMIHOSTING=y/CONFIG_SEMIHOSTING=n/ default-configs/mips-softmmu-common.mak
  $ make subdir-mips64el-softmmu
  [...]
    LINK    mips64el-softmmu/qemu-system-mips64el
  /usr/bin/ld: target/mips/mips-semi.o: in function `helper_do_semihosting':
  ./target/mips/mips-semi.c:335: undefined reference to `qemu_semihosting_log_out'
  /usr/bin/ld: ./target/mips/mips-semi.c:338: undefined reference to `qemu_semihosting_log_out'
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:204: qemu-system-mips64el] Error 1
  make: *** [Makefile:472: subdir-mips64el-softmmu] Error 2

Fix it by providing a stub when semihosting is disabled.

---
checkpatch ERROR: externs should be avoided in .c files

---
 target/mips/Makefile.objs     |  3 ++-
 target/mips/mips-semi-stubs.c | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 target/mips/mips-semi-stubs.c
target/mips/Makefile.objs +2 -1
index 3448ad5e19..3f4d566a35 100644
@@ -1,5 +1,6 @@
 obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o
 obj-y += gdbstub.o msa_helper.o
-obj-$(CONFIG_SOFTMMU) += mips-semi.o
+obj-$(CONFIG_SEMIHOSTING) += mips-semi.o
+obj-$(call lnot,$(CONFIG_SEMIHOSTING)) += mips-semi-stubs.o
 obj-$(CONFIG_SOFTMMU) += machine.o cp0_timer.o
 obj-$(CONFIG_KVM) += kvm.o
target/mips/mips-semi-stubs.c new file +23 -0
new file mode 100644
index 0000000000..f5b13b9153
@@ -0,0 +1,23 @@
+/*
+ * Unified Hosting Interface syscalls stubs
+ *
+ * Copyright (c) 2019 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+
+extern void helper_do_semihosting(CPUMIPSState *env);
+
+void helper_do_semihosting(CPUMIPSState *env)
+{
+    g_assert_not_reached();
+}
Signature · 1 line
2.20.1
#6 lore raw
In reply to Philippe Mathieu-Daudé
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Subject: [Qemu-devel] [RFC PATCH 0/2] target: Build with CONFIG_SEMIHOSTING disabled
Type: series
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
303fbc811f target/mips: Add stubs to build with CONFIG_SEMIHOSTING disabled aad1bd85e1 target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled

=== OUTPUT BEGIN ===
1/2 Checking commit aad1bd85e1e5 (target/arm: Add stubs to build with CONFIG_SEMIHOSTING disabled)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#40:
new file mode 100644

total: 0 errors, 1 warnings, 27 lines checked

Patch 1/2 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/2 Checking commit 303fbc811f24 (target/mips: Add stubs to build with CONFIG_SEMIHOSTING disabled)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#40:
new file mode 100644

ERROR: externs should be avoided in .c files #62: FILE: target/mips/mips-semi-stubs.c:18:
+extern void helper_do_semihosting(CPUMIPSState *env);

total: 1 errors, 1 warnings, 30 lines checked

Patch 2/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#7 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Amusingly Miroslav and myself hit this issue at the same time.

Currently there is no way to pass a CONFIG_X to sources in target/, except via a Makefile rule (and filling with stubs).

Paolo says this is on purpose, CONFIG_X selectors are meant for devices and we try to avoid having config-devices.mak in config-target.h.

...but some things in target/ are devices (like the Arm CPUs, which inherit from TYPE_DEVICE).

Is there a way we can have a Kconfig fragment that expresses "if you asked for an Arm CPU then this should 'select SEMIHOSTING'" ?

thanks
-- PMM

#8 lore raw
Quoted 11 lines · Peter Maydell
Quoted 9 lines · Philippe Mathieu-Daudé

Amusingly Miroslav and myself hit this issue at the same time.

Currently there is no way to pass a CONFIG_X to sources in target/, except via a Makefile rule (and filling with stubs).

Paolo says this is on purpose, CONFIG_X selectors are meant for devices and we try to avoid having config-devices.mak in config-target.h.

Quoted 5 lines

...but some things in target/ are devices (like the Arm CPUs, which inherit from TYPE_DEVICE).

Is there a way we can have a Kconfig fragment that expresses "if you asked for an Arm CPU then this should 'select SEMIHOSTING'" ?

Yes, but inversely, we can also deselect a feature, and all features that requires it get deselected. My guess is Miroslav is building a KVM-only QEMU, but upstream does not allow to build ARM without TCG.

I'll see what happened to Samuel series "Support disabling TCG on ARM" and see if it can be salvaged:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html

I suppose in this thread:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05641.html
you refer to this series (not yet merged):
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg03137.html

I'll try to figure what "KVM injection of interrupts" is.

#9 lore raw

----- Original Message -----

Quoted 37 lines

From: "Philippe Mathieu-Daudé" <[email protected]>
To: "Peter Maydell" <[email protected]>
Cc: "QEMU Developers" <[email protected]>, "Paolo Bonzini" <[email protected]>, "Miroslav Rezanina" <[email protected]>, "Richard Henderson" <[email protected]>, "Aleksandar Rikalo" <[email protected]>, "qemu-arm" <[email protected]>, "Aleksandar Markovic" <[email protected]>, "Aurelien Jarno" <[email protected]>, "Alex Bennée" <[email protected]>, "Samuel Ortiz" <[email protected]>, "Rob Bradford" <[email protected]>
Sent: Friday, May 31, 2019 6:40:30 PM
Subject: Re: [RFC PATCH 0/2] target: Build with CONFIG_SEMIHOSTING disabled

Quoted 12 lines · Peter Maydell
Quoted 9 lines · Philippe Mathieu-Daudé

Amusingly Miroslav and myself hit this issue at the same time.

Currently there is no way to pass a CONFIG_X to sources in target/, except via a Makefile rule (and filling with stubs).

Paolo says this is on purpose, CONFIG_X selectors are meant for devices and we try to avoid having config-devices.mak in config-target.h.

Quoted 5 lines

...but some things in target/ are devices (like the Arm CPUs, which inherit from TYPE_DEVICE).

Is there a way we can have a Kconfig fragment that expresses "if you asked for an Arm CPU then this should 'select SEMIHOSTING'" ?

Yes, but inversely, we can also deselect a feature, and all features that requires it get deselected. My guess is Miroslav is building a KVM-only QEMU, but upstream does not allow to build ARM without TCG.

I'll see what happened to Samuel series "Support disabling TCG on ARM" and see if it can be salvaged:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html

Quoted 7 lines

I suppose in this thread:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05641.html
you refer to this series (not yet merged):
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg03137.html

I'll try to figure what "KVM injection of interrupts" is.

What about CONFIG_ARM_VIRT - can we use it to introduce dependency on CONFIG_SEMIHOSTING or is there valid scenario of qemu build with CONFIG_ARM_VIRT enabled and CONFIG_SEMIHOSTING disabled?

Mirek

Signature · 2 lines
Miroslav Rezanina
Software Engineer - Virtualization Team Maintainer
#10 lore raw
Quoted 3 lines · Miroslav Rezanina

What about CONFIG_ARM_VIRT - can we use it to introduce dependency on CONFIG_SEMIHOSTING or is there valid scenario of qemu build with CONFIG_ARM_VIRT enabled and CONFIG_SEMIHOSTING disabled?

Semihosting is a feature that works on all Arm CPUs regardless of which machine model you're using (or whether you're using softmmu or linux-user), so I think the machine's Kconfig fragment is the wrong place to try to pull it in.

thanks
-- PMM

#11 lore raw
Quoted 10 lines · Peter Maydell
Quoted 3 lines · Miroslav Rezanina

What about CONFIG_ARM_VIRT - can we use it to introduce dependency on CONFIG_SEMIHOSTING or is there valid scenario of qemu build with CONFIG_ARM_VIRT enabled and CONFIG_SEMIHOSTING disabled?

Semihosting is a feature that works on all Arm CPUs regardless of which machine model you're using (or whether you're using softmmu or linux-user), so I think the machine's Kconfig fragment is the wrong place to try to pull it in.

Although amusingly it doesn't work in kvm but perhaps it should?

Quoted 3 lines

thanks
-- PMM

--
Alex Bennée

#12 lore raw
Quoted 10 lines · Alex Bennée
Quoted 5 lines · Peter Maydell

Semihosting is a feature that works on all Arm CPUs regardless of which machine model you're using (or whether you're using softmmu or linux-user), so I think the machine's Kconfig fragment is the wrong place to try to pull it in.

Although amusingly it doesn't work in kvm but perhaps it should?

It would be nice if it did, but the problem IIRC is that semihosting hooks either SVC or HLT instructions, and inside KVM both of those go to EL1, ie to the guest, and can't be trapped to KVM.

thanks
-- PMM

#13 lore raw
In reply to Miroslav Rezanina
Quoted 3 lines · Miroslav Rezanina

What about CONFIG_ARM_VIRT - can we use it to introduce dependency on CONFIG_SEMIHOSTING or is there valid scenario of qemu build with CONFIG_ARM_VIRT enabled and CONFIG_SEMIHOSTING disabled?

If you are not really going to use TCG, disabling SEMIHOSTING makes sense.

I think Philippe's patch are the right way to do it.

Perhaps CONFIG_SEMIHOSTING should be made "default y" and added as "#CONFIG_SEMIHOSTING=n" to default-configs/, but that's just cosmetic.

Paolo

#14 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 3 lines · Miroslav Rezanina

What about CONFIG_ARM_VIRT - can we use it to introduce dependency on CONFIG_SEMIHOSTING or is there valid scenario of qemu build with CONFIG_ARM_VIRT enabled and CONFIG_SEMIHOSTING disabled?

If you are not really going to use TCG, disabling SEMIHOSTING makes sense.

I think Philippe's patch are the right way to do it.

Perhaps CONFIG_SEMIHOSTING should be made "default y" and added as "#CONFIG_SEMIHOSTING=n" to default-configs/, but that's just cosmetic.

But then it is compiled/linked on target that don't care...

Oh, but this is also true currently:

$ fgrep -r qemu_semihosting_log_out
Binary file ppc-softmmu/qemu-system-ppc matches
...

What about:

config SEMIHOSTING
bool
default n
depends on !KVM

and keep specific targets using SEMIHOSTING=y

Using "default y" or "default y if !KVM" we have to add SEMIHOSTING=n on all targets that don't care, which seems an incorrect use of Kconfig.

Aleksandar: Can we use SEMIHOSTING on KVM MIPS?

For ARM Peter said:

"semihosting hooks either SVC or HLT instructions, and inside
KVM both of those go to EL1, ie to the guest, and can't be trapped to KVM."

Thanks,

Phil.

#15 lore raw
Quoted 2 lines

Aleksandar: Can we use SEMIHOSTING on KVM MIPS?

You can assume the answer is no, we can't. But James Hogan, who maintains MIPS KVM, may have different view, and his answer would override mine.

Yours,
Aleksandar

Quoted 10 lines

For ARM Peter said:

"semihosting hooks either SVC or HLT instructions, and inside
KVM both of those go to EL1, ie to the guest, and can't be trapped to KVM."

Thanks,

Phil.

#16 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 3 lines · Philippe Mathieu-Daudé

I'll see what happened to Samuel series "Support disabling TCG on ARM" and see if it can be salvaged:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg02451.html

That would certainly be useful.

Quoted 6 lines

I suppose in this thread:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05641.html
you refer to this series (not yet merged):
https://lists.gnu.org/archive/html/qemu-devel/2019-05/msg03137.html

I'll try to figure what "KVM injection of interrupts" is.

This is about some (rare) cases where userspace QEMU in a KVM setup determines that it needs to deliver an exception to the guest, and does that by adjusting the CPU state appropriately (changing PC, PSTATE, ESR_EL1, etc etc) before telling KVM to KVM_RUN again. Currently we only need that for some places where we're doing debugging of the guest, but there is that pending patchset that would also like to do it in case of a detected hardware memory error. (Most of the time when the guest takes an exception it's because the host kernel/KVM have determined that it's necessary and done the relevant messing with the guest CPU state.)

thanks
-- PMM