Skip to contentSkip to conversation

current testing/next queue

PATCH In review Alex Bennée 4 participants 45 messages May 23, 2019 – May 28, 2019 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover current testing/next queue

Hi,

This is the current status of my testing/next tree. I had to delay sending a PR as I refactored the semihosting changes (used by softmmu tests) to be more generic. I've also addressed comments and merged in Kevin's tweaks to the iotest check script.

The following patches still need review
patch 0003/semihosting implement a semihosting console.patch patch 0004/semihosting enable chardev backed output for cons.patch patch 0006/target arm use the common interface for WRITE0 WR.patch patch 0017/tests tcg aarch64 add system boot.S.patch patch 0027/tests qemu iotests re format output to for make c.patch

Alex Bennée (23):
semihosting: move semihosting configuration into its own directory
semihosting: introduce CONFIG_SEMIHOSTING
semihosting: implement a semihosting console
semihosting: enable chardev backed output for console target/arm: fixup some of the commentary for arm-semi target/arm: use the common interface for WRITE0/WRITEC in arm-semi target/arm: add LOG_UNIMP messages to arm-semi target/arm: correct return values for WRITE/READ in arm-semi target/mips: only build mips-semi for softmmu target/mips: convert UHI_plog to use common semihosting code
MAINTAINERS: update for semihostings new home tests/tcg/multiarch: add support for multiarch system tests tests/tcg/multiarch: add hello world system test
editorconfig: add settings for .s/.S files tests/tcg/aarch64: add system boot.S tests/tcg/multiarch: move the system memory test tests/tcg/minilib: support %c format char tests/tcg/multiarch: expand system memory test to cover more .travis.yml: enable aarch64-softmmu and alpha-softmmu tcg tests
Makefile: fix coverage-report reference to BUILD_DIR
Makefile: include per-target build directories in coverage report Makefile.target: support per-target coverage reports tests/qemu-iotests: re-format output to for make check-block

Gerd Hoffmann (1):
tests/docker: add ubuntu 18.04

Philippe Mathieu-Daudé (1):
tests/docker: Test more components on the Fedora default image

Richard Henderson (1):
tests/tcg/alpha: add system boot.S

Thomas Huth (2):
tests/qemu-iotests/group: Re-use the "auto" group for tests that can
always run
tests: Run the iotests during "make check" again

 .editorconfig                                 |   5 +
 .travis.yml                                   |   2 +-
 MAINTAINERS                                   |   8 +
 Makefile                                      |   4 +-
 Makefile.target                               |  16 +
 default-configs/arm-softmmu.mak               |   1 +
 default-configs/lm32-softmmu.mak              |   2 +
 default-configs/m68k-softmmu.mak              |   2 +
 default-configs/mips-softmmu-common.mak       |   1 +
 default-configs/nios2-softmmu.mak             |   2 +
 default-configs/xtensa-softmmu.mak            |   2 +
 gdbstub.c                                     |   7 +-
 hw/Kconfig                                    |   1 +
 hw/Makefile.objs                              |   1 +
 hw/mips/mips_malta.c                          |   2 +-
 hw/semihosting/Kconfig                        |   3 +
 hw/semihosting/Makefile.objs                  |   2 +
 hw/semihosting/config.c                       | 186 +++++++
 hw/semihosting/console.c                      |  77 +++
 include/exec/gdbstub.h                        |  11 +
 include/hw/semihosting/console.h              |  38 ++
 include/{exec => hw/semihosting}/semihost.h   |  17 +-
 include/sysemu/sysemu.h                       |   1 +
 linux-user/Makefile.objs                      |   2 +
 linux-user/arm/semihost.c                     |  24 +
 qemu-options.hx                               |   6 +-
 stubs/Makefile.objs                           |   1 +
 stubs/semihost.c                              |  70 +++
 target/arm/arm-semi.c                         |  98 ++--
 target/arm/helper.c                           |   2 +-
 target/arm/translate-a64.c                    |   2 +-
 target/arm/translate.c                        |   2 +-
 target/lm32/helper.c                          |   2 +-
 target/m68k/op_helper.c                       |   2 +-
 target/mips/Makefile.objs                     |   3 +-
 target/mips/helper.h                          |   2 +
 target/mips/mips-semi.c                       |  14 +-
 target/mips/translate.c                       |  10 +-
 target/nios2/helper.c                         |   2 +-
 target/xtensa/translate.c                     |   2 +-
 target/xtensa/xtensa-semi.c                   |   2 +-
 tests/Makefile.include                        |   8 +-
 tests/check-block.sh                          |  44 +-
 tests/docker/dockerfiles/fedora.docker        |   7 +
 tests/docker/dockerfiles/ubuntu1804.docker    |  57 ++
 tests/qemu-iotests-quick.sh                   |   8 -
 tests/qemu-iotests/check                      | 179 +++---
 tests/qemu-iotests/group                      | 177 +++---
 tests/tcg/Makefile                            |   1 +
 tests/tcg/aarch64/Makefile.softmmu-target     |  34 ++
 tests/tcg/aarch64/system/boot.S               | 239 ++++++++
 tests/tcg/aarch64/system/kernel.ld            |  24 +
 tests/tcg/alpha/Makefile.softmmu-target       |  34 ++
 tests/tcg/alpha/system/boot.S                 | 511 ++++++++++++++++++
 tests/tcg/alpha/system/kernel.ld              |  30 +
 tests/tcg/i386/Makefile.softmmu-target        |   4 +-
 tests/tcg/i386/system/memory.c                | 243 ---------
 tests/tcg/minilib/printf.c                    |   3 +
 .../multiarch/system/Makefile.softmmu-target  |  14 +
 tests/tcg/{i386 => multiarch}/system/hello.c  |   0
 tests/tcg/multiarch/system/memory.c           | 449 +++++++++++++++
 vl.c                                          | 128 +----
 62 files changed, 2226 insertions(+), 605 deletions(-)
 create mode 100644 hw/semihosting/Kconfig
 create mode 100644 hw/semihosting/Makefile.objs
 create mode 100644 hw/semihosting/config.c
 create mode 100644 hw/semihosting/console.c
 create mode 100644 include/hw/semihosting/console.h
 rename include/{exec => hw/semihosting}/semihost.h (78%)
 create mode 100644 linux-user/arm/semihost.c
 create mode 100644 stubs/semihost.c
 create mode 100644 tests/docker/dockerfiles/ubuntu1804.docker
 delete mode 100755 tests/qemu-iotests-quick.sh
 create mode 100644 tests/tcg/aarch64/Makefile.softmmu-target
 create mode 100644 tests/tcg/aarch64/system/boot.S
 create mode 100644 tests/tcg/aarch64/system/kernel.ld
 create mode 100644 tests/tcg/alpha/Makefile.softmmu-target
 create mode 100644 tests/tcg/alpha/system/boot.S
 create mode 100644 tests/tcg/alpha/system/kernel.ld
 delete mode 100644 tests/tcg/i386/system/memory.c
 create mode 100644 tests/tcg/multiarch/system/Makefile.softmmu-target
 rename tests/tcg/{i386 => multiarch}/system/hello.c (100%)
 create mode 100644 tests/tcg/multiarch/system/memory.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/28 semihosting: move semihosting configuration into its own directory

In preparation for having some more common semihosting code let's excise the current config magic from vl.c into its own file. We shall later add more conditionals to the build configurations so we can avoid building this if we don't need it.

---
 gdbstub.c                                   |   2 +-
 hw/Makefile.objs                            |   1 +
 hw/mips/mips_malta.c                        |   2 +-
 hw/semihosting/Makefile.objs                |   1 +
 hw/semihosting/config.c                     | 160 ++++++++++++++++++++
 include/{exec => hw/semihosting}/semihost.h |  10 +-
 include/sysemu/sysemu.h                     |   1 +
 target/arm/arm-semi.c                       |   2 +-
 target/arm/helper.c                         |   2 +-
 target/arm/translate-a64.c                  |   2 +-
 target/arm/translate.c                      |   2 +-
 target/lm32/helper.c                        |   2 +-
 target/m68k/op_helper.c                     |   2 +-
 target/mips/mips-semi.c                     |   2 +-
 target/mips/translate.c                     |   2 +-
 target/nios2/helper.c                       |   2 +-
 target/xtensa/translate.c                   |   2 +-
 target/xtensa/xtensa-semi.c                 |   2 +-
 vl.c                                        | 126 +--------------
 19 files changed, 186 insertions(+), 139 deletions(-)
 create mode 100644 hw/semihosting/Makefile.objs
 create mode 100644 hw/semihosting/config.c
 rename include/{exec => hw/semihosting}/semihost.h (85%)
gdbstub.c +1 -1
index d54abd17cc2..793218bb43a 100644
@@ -37,7 +37,7 @@
 #include "qemu/sockets.h"
 #include "sysemu/hw_accel.h"
 #include "sysemu/kvm.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "exec/exec-all.h"
 
 #ifdef CONFIG_USER_ONLY
hw/Makefile.objs +1 -0
index 82aa7fab8e4..d770926ba96 100644
@@ -36,6 +36,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += watchdog/
 devices-dirs-$(CONFIG_SOFTMMU) += xen/
 devices-dirs-$(CONFIG_MEM_DEVICE) += mem/
 devices-dirs-$(CONFIG_SOFTMMU) += smbios/
+devices-dirs-y += semihosting/
 devices-dirs-y += core/
 common-obj-y += $(devices-dirs-y)
 obj-y += $(devices-dirs-y)
hw/mips/mips_malta.c +1 -1
index 439665ab45e..3b009fda25f 100644
@@ -55,7 +55,7 @@
 #include "qemu/error-report.h"
 #include "hw/empty_slot.h"
 #include "sysemu/kvm.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "hw/mips/cps.h"
 
 #define ENVP_ADDR		0x80002000l
hw/semihosting/Makefile.objs new file +1 -0
new file mode 100644
index 00000000000..546954f4ff4
@@ -0,0 +1 @@
+common-obj-$(CONFIG_SOFTMMU) += config.o
hw/semihosting/config.c new file +160 -0

160 lines not on this page · raw message

include/hw/semihosting/semihost.h renamed from include/exec/semihost.h +7 -3
similarity index 85%
rename from include/exec/semihost.h
rename to include/hw/semihosting/semihost.h
index 5980939c7b8..07ea40a322f 100644
@@ -51,12 +51,16 @@ static inline const char *semihosting_get_cmdline(void)
 {
     return NULL;
 }
-#else
+#else /* !CONFIG_USER_ONLY */
 bool semihosting_enabled(void);
 SemihostingTarget semihosting_get_target(void);
 const char *semihosting_get_arg(int i);
 int semihosting_get_argc(void);
 const char *semihosting_get_cmdline(void);
-#endif
+void semihosting_arg_fallback(const char *file, const char *cmd);
+/* for vl.c hooks */
+void qemu_semihosting_enable(void);
+int qemu_semihosting_config_options(const char *opt);
+#endif /* CONFIG_USER_ONLY */
 
-#endif
+#endif /* SEMIHOST_H */
include/sysemu/sysemu.h +1 -0
index 5f133cae837..61579ae71ef 100644
@@ -193,5 +193,6 @@ extern QemuOptsList qemu_nic_opts;
 extern QemuOptsList qemu_net_opts;
 extern QemuOptsList qemu_global_opts;
 extern QemuOptsList qemu_mon_opts;
+extern QemuOptsList qemu_semihosting_config_opts;
 
 #endif
target/arm/arm-semi.c +1 -1
index 8b5fd7bc6e3..3273306c8ea 100644
@@ -21,7 +21,7 @@
 #include "qemu/osdep.h"
 
 #include "cpu.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
target/arm/helper.c +1 -1
index e2d5c8e34fe..c1f0a07efd8 100644
@@ -16,7 +16,7 @@
 #include "exec/cpu_ldst.h"
 #include "arm_ldst.h"
 #include <zlib.h> /* For crc32 */
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "sysemu/cpus.h"
 #include "sysemu/kvm.h"
 #include "fpu/softfloat.h"
target/arm/translate-a64.c +1 -1
index b7c5a928b4a..8844a75e53d 100644
@@ -29,7 +29,7 @@
 #include "qemu/host-utils.h"
 #include "qemu/qemu-print.h"
 
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "exec/gen-icount.h"
 
 #include "exec/helper-proto.h"
target/arm/translate.c +1 -1
index dd053c80d62..f2a65c0b5b0 100644
@@ -30,7 +30,7 @@
 #include "qemu/bitops.h"
 #include "qemu/qemu-print.h"
 #include "arm_ldst.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
target/lm32/helper.c +1 -1
index 20ea17ba23c..8cd48400521 100644
@@ -22,7 +22,7 @@
 #include "exec/exec-all.h"
 #include "qemu/host-utils.h"
 #include "sysemu/sysemu.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "exec/log.h"
 
 bool lm32_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
target/m68k/op_helper.c +1 -1
index 1ecc772b5cb..bde2d551ff6 100644
@@ -21,7 +21,7 @@
 #include "exec/helper-proto.h"
 #include "exec/exec-all.h"
 #include "exec/cpu_ldst.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 
 #if defined(CONFIG_USER_ONLY)
 
target/mips/mips-semi.c +1 -1
index a7aefbaefc8..eac8374fb34 100644
@@ -22,7 +22,7 @@
 #include "qemu/log.h"
 #include "exec/helper-proto.h"
 #include "exec/softmmu-semi.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 
 typedef enum UHIOp {
     UHI_exit = 1,
target/mips/translate.c +1 -1
index f96c0d01ef1..3cd5b11b16b 100644
@@ -32,7 +32,7 @@
 
 #include "exec/helper-proto.h"
 #include "exec/helper-gen.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 
 #include "target/mips/trace.h"
 #include "trace-tcg.h"
target/nios2/helper.c +1 -1
index ffb83fc1045..57c97bde3c6 100644
@@ -26,7 +26,7 @@
 #include "exec/cpu_ldst.h"
 #include "exec/log.h"
 #include "exec/helper-proto.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 
 #if defined(CONFIG_USER_ONLY)
 
target/xtensa/translate.c +1 -1
index 53dce470c17..6f1da878752 100644
@@ -38,7 +38,7 @@
 #include "qemu/qemu-print.h"
 #include "sysemu/sysemu.h"
 #include "exec/cpu_ldst.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "exec/translator.h"
 
 #include "exec/helper-proto.h"
target/xtensa/xtensa-semi.c +1 -1
index 5f5ce4f344c..38efa3485af 100644
@@ -29,7 +29,7 @@
 #include "cpu.h"
 #include "chardev/char-fe.h"
 #include "exec/helper-proto.h"
-#include "exec/semihost.h"
+#include "hw/semihosting/semihost.h"
 #include "qapi/error.h"
 #include "qemu/log.h"
 #include "sysemu/sysemu.h"
vl.c +3 -123

152 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v2 1/28
#2 lore raw

Re: [Qemu-devel] [PATCH v2 01/28] semihosting: move semihosting configuration into its own directory

Quoted 9 lines · Alex Bennée

In preparation for having some more common semihosting code let's excise the current config magic from vl.c into its own file. We shall later add more conditionals to the build configurations so we can avoid building this if we don't need it.

---

r~

#3 lore raw

PATCH v2 2/28 semihosting: introduce CONFIG_SEMIHOSTING

In reply to Alex Bennée

There isn't much point building semihosting for platforms that don't support it. Introduce a new symbol and enable it only for the softmmu targets that need it.

---
 default-configs/arm-softmmu.mak         |  1 +
 default-configs/lm32-softmmu.mak        |  2 +
 default-configs/m68k-softmmu.mak        |  2 +
 default-configs/mips-softmmu-common.mak |  1 +
 default-configs/nios2-softmmu.mak       |  2 +
 default-configs/xtensa-softmmu.mak      |  2 +
 hw/Kconfig                              |  1 +
 hw/semihosting/Kconfig                  |  3 ++
 hw/semihosting/Makefile.objs            |  2 +-
 stubs/Makefile.objs                     |  1 +
 stubs/semihost.c                        | 66 +++++++++++++++++++++++++
 11 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 hw/semihosting/Kconfig
 create mode 100644 stubs/semihost.c
default-configs/arm-softmmu.mak +1 -0
index f23ecfd5c58..1f2e0e7fdeb 100644
@@ -39,3 +39,4 @@ CONFIG_MICROBIT=y
 CONFIG_FSL_IMX25=y
 CONFIG_FSL_IMX7=y
 CONFIG_FSL_IMX6UL=y
+CONFIG_SEMIHOSTING=y
default-configs/lm32-softmmu.mak +2 -0
index 6d259665d60..115b3e34c98 100644
@@ -4,6 +4,8 @@
 #
 #CONFIG_MILKYMIST_TMU2=n        # disabling it actually causes compile-time failures
 
+CONFIG_SEMIHOSTING=y
+
 # Boards:
 #
 CONFIG_LM32=y
default-configs/m68k-softmmu.mak +2 -0
index e17495e2a0b..4049a8f2ba9 100644
@@ -1,5 +1,7 @@
 # Default configuration for m68k-softmmu
 
+CONFIG_SEMIHOSTING=y
+
 # Boards:
 #
 CONFIG_AN5206=y
default-configs/mips-softmmu-common.mak +1 -0
index 8e54a74b7a5..e10ac4b20c0 100644
@@ -35,6 +35,7 @@ CONFIG_MIPS_CPS=y
 CONFIG_MIPS_ITU=y
 CONFIG_R4K=y
 CONFIG_MALTA=y
+CONFIG_SEMIHOSTING=y
 CONFIG_PCNET_PCI=y
 CONFIG_MIPSSIM=y
 CONFIG_ACPI_SMBUS=y
default-configs/nios2-softmmu.mak +2 -0
index e130d024e62..1bc4082ea99 100644
@@ -1,5 +1,7 @@
 # Default configuration for nios2-softmmu
 
+CONFIG_SEMIHOSTING=y
+
 # Boards:
 #
 CONFIG_NIOS2_10M50=y
default-configs/xtensa-softmmu.mak +2 -0
index 7e4d1cc0979..3aa20a47a7f 100644
@@ -1,5 +1,7 @@
 # Default configuration for Xtensa
 
+CONFIG_SEMIHOSTING=y
+
 # Boards:
 #
 CONFIG_XTENSA_SIM=y
hw/Kconfig +1 -0
index 88b9f150070..195f541e50c 100644
@@ -29,6 +29,7 @@ source pci/Kconfig
 source rdma/Kconfig
 source scsi/Kconfig
 source sd/Kconfig
+source semihosting/Kconfig
 source smbios/Kconfig
 source ssi/Kconfig
 source timer/Kconfig
hw/semihosting/Kconfig new file +3 -0
new file mode 100644
index 00000000000..efe0a30734c
@@ -0,0 +1,3 @@
+
+config SEMIHOSTING
+       bool
hw/semihosting/Makefile.objs +1 -1
index 546954f4ff4..09c19bf19ed 100644
@@ -1 +1 @@
-common-obj-$(CONFIG_SOFTMMU) += config.o
+obj-$(CONFIG_SEMIHOSTING) += config.o
stubs/Makefile.objs +1 -0
index 269dfa58326..e0d4f11b348 100644
@@ -39,3 +39,4 @@ stub-obj-y += xen-hvm.o
 stub-obj-y += pci-host-piix.o
 stub-obj-y += ram-block.o
 stub-obj-y += ramfb.o
+stub-obj-$(CONFIG_SOFTMMU) += semihost.o
stubs/semihost.c new file +66 -0

66 lines not on this page · raw message

Signature · 1 line
2.20.1
Reviewed-by on v2 2/28
#4 lore raw

Re: [Qemu-devel] [PATCH v2 02/28] semihosting: introduce CONFIG_SEMIHOSTING

Quoted 7 lines · Alex Bennée

There isn't much point building semihosting for platforms that don't support it. Introduce a new symbol and enable it only for the softmmu targets that need it.

Quoted 15 lines
---
 default-configs/arm-softmmu.mak         |  1 +
 default-configs/lm32-softmmu.mak        |  2 +
 default-configs/m68k-softmmu.mak        |  2 +
 default-configs/mips-softmmu-common.mak |  1 +
 default-configs/nios2-softmmu.mak       |  2 +
 default-configs/xtensa-softmmu.mak      |  2 +
 hw/Kconfig                              |  1 +
 hw/semihosting/Kconfig                  |  3 ++
 hw/semihosting/Makefile.objs            |  2 +-
 stubs/Makefile.objs                     |  1 +
 stubs/semihost.c                        | 66 +++++++++++++++++++++++++
 11 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 hw/semihosting/Kconfig
 create mode 100644 stubs/semihost.c

r~

#5 lore raw

PATCH v2 3/28 semihosting: implement a semihosting console

In reply to Alex Bennée

This provides two functions for handling console output that handle the common backend behaviour for semihosting.

---
 gdbstub.c                        |  5 +++
 hw/semihosting/Makefile.objs     |  1 +
 hw/semihosting/console.c         | 70 ++++++++++++++++++++++++++++++++
 include/exec/gdbstub.h           | 11 +++++
 include/hw/semihosting/console.h | 38 +++++++++++++++++
 5 files changed, 125 insertions(+)
 create mode 100644 hw/semihosting/console.c
 create mode 100644 include/hw/semihosting/console.h
gdbstub.c +5 -0
index 793218bb43a..b4334014373 100644
@@ -1987,6 +1987,11 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...)
     va_end(va);
 }
 
+void gdb_do_console_out(target_ulong s, int len)
+{
+    gdb_do_syscall(NULL, "write,2,%x,1", s, len);
+}
+
 static void gdb_read_byte(GDBState *s, int ch)
 {
     uint8_t reply;
hw/semihosting/Makefile.objs +1 -0
index 09c19bf19ed..4ad47c05c06 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_SEMIHOSTING) += config.o
+obj-$(CONFIG_SEMIHOSTING) += console.o
hw/semihosting/console.c new file +70 -0

70 lines not on this page · raw message

include/exec/gdbstub.h +11 -0
index 08363969c14..b2963547c48 100644
@@ -44,6 +44,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
  * argument list.
  */
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
+/**
+ * gdb_do_console_out:
+ * @gs: guest address of string to send
+ * @len: length of string
+ *
+ * Sends a string to gdb console. Unlike the system call interface
+ * there is no callback and we assume the system call always
+ * succeeds.
+ */
+void gdb_do_console_out(target_ulong s, int len);
+
 int use_gdb_syscalls(void);
 void gdb_set_stop_cpu(CPUState *cpu);
 void gdb_exit(CPUArchState *, int);
include/hw/semihosting/console.h new file +38 -0
new file mode 100644
index 00000000000..30e66ae20aa
@@ -0,0 +1,38 @@
+/*
+ * Semihosting Console
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef _SEMIHOST_CONSOLE_H_
+#define _SEMIHOST_CONSOLE_H_
+
+/**
+ * qemu_semihosting_console_out:
+ * @env: CPUArchState
+ * @s: host address of guest string
+ * @len: length of string or 0 (string is null terminated)
+ *
+ * Send a guest string to the debug console. This may be the remote
+ * gdb session if a softmmu guest is currently being debugged.
+ *
+ * Returns: number of bytes written.
+ */
+int qemu_semihosting_console_out(CPUArchState *env, target_ulong s, int len);
+
+/**
+ * qemu_semihosting_log_out:
+ * @s: pointer to string
+ * @len: length of string
+ *
+ * Send a string to the debug output. Unlike console_out these strings
+ * can't be sent to a remote gdb instance as they don't exist in guest
+ * memory.
+ *
+ * Returns: number of bytes written
+ */
+int qemu_semihosting_log_out(const char *s, int len);
+
+#endif /* _SEMIHOST_CONSOLE_H_ */
Signature · 1 line
2.20.1
#6 lore raw

Re: [Qemu-devel] [PATCH v2 03/28] semihosting: implement a semihosting console

Quoted 14 lines · Alex Bennée

This provides two functions for handling console output that handle the common backend behaviour for semihosting.

include/exec/gdbstub.h +0 -0
index 08363969c14..b2963547c48 100644
@@ -44,6 +44,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
  * argument list.
  */
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);

include/exec/gdbstub.h void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); · line 56

Quoted 10 lines
include/exec/gdbstub.h +10 -0
+/**
+ * gdb_do_console_out:
+ * @gs: guest address of string to send
+ * @len: length of string
+ *
+ * Sends a string to gdb console. Unlike the system call interface
+ * there is no callback and we assume the system call always
+ * succeeds.
+ */
+void gdb_do_console_out(target_ulong s, int len);

I'm not sure about the "no callback" part of this API. The operation here is genuinely asynchronous and providing no mechanism for the caller to be able to say "ok, now wait til it completes" doesn't seem like a good plan.

thanks
-- PMM

#7 lore raw

Re: [Qemu-devel] [PATCH v2 03/28] semihosting: implement a semihosting console

Quoted 22 lines · Peter Maydell
Quoted 21 lines · Alex Bennée

This provides two functions for handling console output that handle the common backend behaviour for semihosting.

include/exec/gdbstub.h +7 -0
index 08363969c14..b2963547c48 100644
@@ -44,6 +44,17 @@ void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
  * argument list.
  */
 void gdb_do_syscallv(gdb_syscall_complete_cb cb, const char *fmt, va_list va);
+/**
+ * gdb_do_console_out:
+ * @gs: guest address of string to send
+ * @len: length of string
+ *
+ * Sends a string to gdb console. Unlike the system call interface
+ * there is no callback and we assume the system call always
Quoted 8 lines

include/exec/gdbstub.h void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...); · line 56

Quoted 3 lines
include/exec/gdbstub.h +3 -0
+ * succeeds.
+ */
+void gdb_do_console_out(target_ulong s, int len);

I'm not sure about the "no callback" part of this API. The operation here is genuinely asynchronous and providing no mechanism for the caller to be able to say "ok, now wait til it completes" doesn't seem like a good plan.

Well the caller doesn't really get a choice. At least in system mode gdbstub does a vm_stop(RUN_STATE_DEBUG) and brings everything to a halt anyway. All we've removed is the ability to tack on a callback (which can get run in all sorts of contexts) when we restart.

I could just drop the API here and allow the semihosting API to call gdb_do_syscallv directly?

--
Alex Bennée

#8 lore raw

Re: [Qemu-devel] [PATCH v2 03/28] semihosting: implement a semihosting console

Quoted 10 lines · Alex Bennée
Quoted 5 lines · Peter Maydell

On Thu, 23 May 2019 at 11:39, Alex Bennée <[email protected]> wrote:
I'm not sure about the "no callback" part of this API. The operation here is genuinely asynchronous and providing no mechanism for the caller to be able to say "ok, now wait til it completes" doesn't seem like a good plan.

Quoted 4 lines

Well the caller doesn't really get a choice. At least in system mode gdbstub does a vm_stop(RUN_STATE_DEBUG) and brings everything to a halt anyway. All we've removed is the ability to tack on a callback (which can get run in all sorts of contexts) when we restart.

gdb_do_syscall() is asynchronous -- it arranges for the syscall to happen, but makes no guarantee about when it will finish. At the moment the gdb_do_syscall() API allows the caller to cope with this asynchronousness, because when the callback is called the syscall has definitely finished. As it happens the callers are buggy in that they don't actually do the sync that they need to do, but we could fix that bug (ie post a semaphore in the callback function, and wait on it after the gdb_do_syscall() call). The API for this new function doesn't allow us to do that.

Quoted 2 lines

I could just drop the API here and allow the semihosting API to call gdb_do_syscallv directly?

I think we should either make the implementation of the function properly synchronous (ie do the post-semaphore-in-callback, wait-on-it-after-gdb_do_syscallv thing in the implementation, or have an API that lets callers do it.

Perhaps we should just make gdb_do_syscall really be synchronous (ie have it do the semaphore stuff)? We only actually use it in semihosting, and I think all those cases require that the operation completes before we can resume execution of the guest CPU. So doing the synchronization in one place in the gdb code would be simpler than doing it separately in all the callers...

thanks
-- PMM

#9 lore raw

Re: [Qemu-devel] [PATCH v2 03/28] semihosting: implement a semihosting console

Quoted 16 lines · Peter Maydell
Quoted 10 lines · Alex Bennée
Quoted 5 lines · Peter Maydell

On Thu, 23 May 2019 at 11:39, Alex Bennée <[email protected]> wrote:
I'm not sure about the "no callback" part of this API. The operation here is genuinely asynchronous and providing no mechanism for the caller to be able to say "ok, now wait til it completes" doesn't seem like a good plan.

Quoted 4 lines

Well the caller doesn't really get a choice. At least in system mode gdbstub does a vm_stop(RUN_STATE_DEBUG) and brings everything to a halt anyway. All we've removed is the ability to tack on a callback (which can get run in all sorts of contexts) when we restart.

Quoted 10 lines

gdb_do_syscall() is asynchronous -- it arranges for the syscall to happen, but makes no guarantee about when it will finish. At the moment the gdb_do_syscall() API allows the caller to cope with this asynchronousness, because when the callback is called the syscall has definitely finished. As it happens the callers are buggy in that they don't actually do the sync that they need to do, but we could fix that bug (ie post a semaphore in the callback function, and wait on it after the gdb_do_syscall() call). The API for this new function doesn't allow us to do that.

So for the ARM semi side the console writes are treated as always successful so the return value is correct (it doesn't matter for writec) and no syncing to the guest is required. However I ran into a problem because in gdbstub we have:

    /* Is there a GDB syscall waiting to be sent?  */
    if (s->current_syscall_cb) {
        put_packet(s, s->syscall_buf);
        return;
    }

which means it can't accept NULL for the callback. So I've removed the gdb_console_out and done:

  static void semihosting_cb(CPUState *cs, target_ulong ret, target_ulong err)
  {
      if (ret == (target_ulong) -1) {
          qemu_log("%s: gdb console output failed (%s)", __func__, strerror(-err));
      }
  }

  int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr, int len)
  {
      GString *s = copy_user_string(env, addr, len);
      int out = s->len;
      if (use_gdb_syscalls()) {
          gdb_do_syscall(semihosting_cb, "write,2,%x,%x", addr, s->len);
      } else {
          out = qemu_semihosting_log_out(s->str, s->len);
      }

      g_string_free(s, true);
      return out;

}

for now.

Quoted 8 lines
Quoted 2 lines

I could just drop the API here and allow the semihosting API to call gdb_do_syscallv directly?

I think we should either make the implementation of the function properly synchronous (ie do the post-semaphore-in-callback, wait-on-it-after-gdb_do_syscallv thing in the implementation, or have an API that lets callers do it.

Quoted 7 lines

Perhaps we should just make gdb_do_syscall really be synchronous (ie have it do the semaphore stuff)? We only actually use it in semihosting, and I think all those cases require that the operation completes before we can resume execution of the guest CPU. So doing the synchronization in one place in the gdb code would be simpler than doing it separately in all the callers...

Maybe.. this seems like a bigger clean-up to do that properly. Maybe that would be worth tackling after the gdbstub refactor stuff goes in?

--
Alex Bennée

#10 lore raw

PATCH v2 4/28 semihosting: enable chardev backed output for console

In reply to Alex Bennée

It will be useful for a number of use-cases to be able to re-direct output to a file like we do with serial output. This does the wiring to allow us to treat then semihosting console like just another character output device.

---
 hw/semihosting/config.c           | 26 ++++++++++++++++++++++++++
 hw/semihosting/console.c          |  9 ++++++++-
 include/hw/semihosting/semihost.h |  7 +++++++
 qemu-options.hx                   |  6 ++++--
 stubs/semihost.c                  |  4 ++++
 vl.c                              |  2 ++
 6 files changed, 51 insertions(+), 3 deletions(-)
hw/semihosting/config.c +26 -0
index f1d3fe1e4c6..2a8e7e1045a 100644
@@ -23,6 +23,7 @@
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
 #include "hw/semihosting/semihost.h"
+#include "chardev/char.h"
 
 QemuOptsList qemu_semihosting_config_opts = {
     .name = "semihosting-config",
@@ -35,6 +36,9 @@ QemuOptsList qemu_semihosting_config_opts = {
         }, {
             .name = "target",
             .type = QEMU_OPT_STRING,
+        }, {
+            .name = "chardev",
+            .type = QEMU_OPT_STRING,
         }, {
             .name = "arg",
             .type = QEMU_OPT_STRING,
@@ -46,12 +50,14 @@ QemuOptsList qemu_semihosting_config_opts = {
 typedef struct SemihostingConfig {
     bool enabled;
     SemihostingTarget target;
+    Chardev *chardev;
     const char **argv;
     int argc;
     const char *cmdline; /* concatenated argv */
 } SemihostingConfig;
 
 static SemihostingConfig semihosting;
+static const char *semihost_chardev;
 
 bool semihosting_enabled(void)
 {
@@ -115,6 +121,11 @@ void semihosting_arg_fallback(const char *file, const char *cmd)
     }
 }
 
+Chardev *semihosting_get_chardev(void)
+{
+    return semihosting.chardev;
+}
+
 void qemu_semihosting_enable(void)
 {
     semihosting.enabled = true;
@@ -132,6 +143,8 @@ int qemu_semihosting_config_options(const char *optarg)
         semihosting.enabled = qemu_opt_get_bool(opts, "enable",
                                                 true);
         const char *target = qemu_opt_get(opts, "target");
+        /* setup of chardev is deferred until they are initialised */
+        semihost_chardev = qemu_opt_get(opts, "chardev");
         if (target != NULL) {
             if (strcmp("native", target) == 0) {
                 semihosting.target = SEMIHOSTING_TARGET_NATIVE;
@@ -158,3 +171,16 @@ int qemu_semihosting_config_options(const char *optarg)
     return 0;
 }
 
+void qemu_semihosting_connect_chardevs(void)
+{
+    /* We had to defer this until chardevs were created */
+    if (semihost_chardev) {
+        Chardev *chr = qemu_chr_find(semihost_chardev);
+        if (chr == NULL) {
+            error_report("semihosting chardev '%s' not found",
+                         semihost_chardev);
+            exit(1);
+        }
+        semihosting.chardev = chr;
+    }
+}
hw/semihosting/console.c +8 -1
index ad6f67ecc71..2fa440eb32a 100644
@@ -17,13 +17,20 @@
 
 #include "qemu/osdep.h"
 #include "cpu.h"
+#include "hw/semihosting/semihost.h"
 #include "hw/semihosting/console.h"
 #include "exec/gdbstub.h"
 #include "qemu/log.h"
+#include "chardev/char.h"
 
 int qemu_semihosting_log_out(const char *s, int len)
 {
-    return write(STDERR_FILENO, s, len);
+    Chardev *chardev = semihosting_get_chardev();
+    if (chardev) {
+        return qemu_chr_write_all(chardev, (uint8_t *) s, len);
+    } else {
+        return write(STDERR_FILENO, s, len);
+    }
 }
 
 /*
include/hw/semihosting/semihost.h +7 -0
index 07ea40a322f..60fc42d851e 100644
@@ -51,6 +51,11 @@ static inline const char *semihosting_get_cmdline(void)
 {
     return NULL;
 }
+
+static inline Chardev *semihosting_get_chardev(void)
+{
+    return NULL;
+}
 #else /* !CONFIG_USER_ONLY */
 bool semihosting_enabled(void);
 SemihostingTarget semihosting_get_target(void);
@@ -58,9 +63,11 @@ const char *semihosting_get_arg(int i);
 int semihosting_get_argc(void);
 const char *semihosting_get_cmdline(void);
 void semihosting_arg_fallback(const char *file, const char *cmd);
+Chardev *semihosting_get_chardev(void);
 /* for vl.c hooks */
 void qemu_semihosting_enable(void);
 int qemu_semihosting_config_options(const char *opt);
+void qemu_semihosting_connect_chardevs(void);
 #endif /* CONFIG_USER_ONLY */
 
 #endif /* SEMIHOST_H */
qemu-options.hx +4 -2
index 5daa5a8fb0a..ce36048ef31 100644
@@ -4015,12 +4015,12 @@ STEXI
 Enable semihosting mode (ARM, M68K, Xtensa, MIPS, Nios II only).
 ETEXI
 DEF("semihosting-config", HAS_ARG, QEMU_OPTION_semihosting_config,
-    "-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]\n" \
+    "-semihosting-config [enable=on|off][,target=native|gdb|auto][,chardev=id][,arg=str[,...]]\n" \
     "                semihosting configuration\n",
 QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 |
 QEMU_ARCH_MIPS | QEMU_ARCH_NIOS2)
 STEXI
-@item -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]
+@item -semihosting-config [enable=on|off][,target=native|gdb|auto][,chardev=id][,arg=str[,...]]
 @findex -semihosting-config
 Enable and configure semihosting (ARM, M68K, Xtensa, MIPS, Nios II only).
 @table @option
@@ -4028,6 +4028,8 @@ Enable and configure semihosting (ARM, M68K, Xtensa, MIPS, Nios II only).
 Defines where the semihosting calls will be addressed, to QEMU (@code{native})
 or to GDB (@code{gdb}). The default is @code{auto}, which means @code{gdb}
 during debug sessions and @code{native} otherwise.
+@item chardev=@var{str1}
+Send the output to a chardev backend output for native or auto output when not in gdb
 @item arg=@var{str1},arg=@var{str2},...
 Allows the user to pass input arguments, and can be used multiple times to build
 up a list. The old-style @code{-kernel}/@code{-append} method of passing a
stubs/semihost.c +4 -0
index 1a4e88e5326..4d5b3c06530 100644
@@ -64,3 +64,7 @@ const char *semihosting_get_cmdline(void)
 void semihosting_arg_fallback(const char *file, const char *cmd)
 {
 }
+
+void qemu_semihosting_connect_chardevs(void)
+{
+}
vl.c +2 -0
index 6b19ea42bfe..17f912166ce 100644
@@ -4166,6 +4166,8 @@ int main(int argc, char **argv, char **envp)
 
     qemu_opts_foreach(qemu_find_opts("chardev"),
                       chardev_init_func, NULL, &error_fatal);
+    /* now chardevs have been created we may have semihosting to connect */
+    qemu_semihosting_connect_chardevs();
 
 #ifdef CONFIG_VIRTFS
     qemu_opts_foreach(qemu_find_opts("fsdev"),
Signature · 1 line
2.20.1
#11 lore raw

Re: [Qemu-devel] [PATCH v2 04/28] semihosting: enable chardev backed output for console

hw/semihosting/console.c line 34

Quoted 10 lines · Alex Bennée

int qemu_semihosting_log_out(const char *s, int len) {

hw/semihosting/console.c +6 -1
-    return write(STDERR_FILENO, s, len);
+    Chardev *chardev = semihosting_get_chardev();
+    if (chardev) {
+        return qemu_chr_write_all(chardev, (uint8_t *) s, len);
+    } else {
+        return write(STDERR_FILENO, s, len);
+    }
 }

Can we not create a default chardev that outputs to stderr, so that the conditional is not required? Or does that somehow interfere with how this connects up for linux-user/?

r~

#12 lore raw

Re: [Qemu-devel] [PATCH v2 04/28] semihosting: enable chardev backed output for console

Quoted 12 lines · Richard Henderson

hw/semihosting/console.c line 34

Quoted 10 lines · Alex Bennée

int qemu_semihosting_log_out(const char *s, int len) {

hw/semihosting/console.c +6 -1
-    return write(STDERR_FILENO, s, len);
+    Chardev *chardev = semihosting_get_chardev();
+    if (chardev) {
+        return qemu_chr_write_all(chardev, (uint8_t *) s, len);
+    } else {
+        return write(STDERR_FILENO, s, len);
+    }
 }
Quoted 3 lines

Can we not create a default chardev that outputs to stderr, so that the conditional is not required? Or does that somehow interfere with how this connects up for linux-user/?

The one linux-user case does it's own thing which uses the same API but has a dumb implementation without a chardev. I'm unsure how you go about creating a plain chardev backend programatically although I'll probably want to do that for the plugins as well so I'll look into it.

I'll merge this as is for now though.

--
Alex Bennée

#13 lore raw

PATCH v2 5/28 target/arm: fixup some of the commentary for arm-semi

In reply to Alex Bennée

This cleans up a number of the block comments to fit the proper style. While we are at it we also reference the official specification and document what the return register value can be.

---
 target/arm/arm-semi.c | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)
target/arm/arm-semi.c +31 -9
index 3273306c8ea..9e5a414dd89 100644
@@ -2,6 +2,7 @@
  *  Arm "Angel" semihosting syscalls
  *
  *  Copyright (c) 2005, 2007 CodeSourcery.
+ *  Copyright (c) 2019 Linaro
  *  Written by Paul Brook.
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -16,6 +17,10 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *  ARM Semihosting is documented in:
+ *     Semihosting for AArch32 and AArch64 Release 2.0
+ *     https://static.docs.arm.com/100863/0200/semihosting.pdf
  */
 
 #include "qemu/osdep.h"
@@ -240,6 +245,15 @@ static target_ulong arm_gdb_syscall(ARMCPU *cpu, gdb_syscall_complete_cb cb,
      put_user_u64(val, args + (n) * 8) :                \
      put_user_u32(val, args + (n) * 4))
 
+/*
+ * Do a semihosting call.
+ *
+ * The specification always says that the "return register" either
+ * returns a specific value or is corrupted, so we don't need to
+ * report to our caller whether we are returning a value or trying to
+ * leave the register unchanged. We use 0xdeadbeef as the return value
+ * when there isn't a defined return value for the call.
+ */
 target_ulong do_arm_semihosting(CPUARMState *env)
 {
     ARMCPU *cpu = arm_env_get_cpu(env);
@@ -510,14 +524,16 @@ target_ulong do_arm_semihosting(CPUARMState *env)
 
             output_size = ts->info->arg_end - ts->info->arg_start;
             if (!output_size) {
-                /* We special-case the "empty command line" case (argc==0).
-                   Just provide the terminating 0. */
+                /*
+                 * We special-case the "empty command line" case (argc==0).
+                 * Just provide the terminating 0.
+                 */
                 output_size = 1;
             }
 #endif
 
             if (output_size > input_size) {
-                 /* Not enough space to store command-line arguments.  */
+                /* Not enough space to store command-line arguments.  */
                 return -1;
             }
 
@@ -571,8 +587,10 @@ target_ulong do_arm_semihosting(CPUARMState *env)
             GET_ARG(0);
 
 #ifdef CONFIG_USER_ONLY
-            /* Some C libraries assume the heap immediately follows .bss, so
-               allocate it using sbrk.  */
+            /*
+             * Some C libraries assume the heap immediately follows .bss, so
+             * allocate it using sbrk.
+             */
             if (!ts->heap_limit) {
                 abi_ulong ret;
 
@@ -620,7 +638,8 @@ target_ulong do_arm_semihosting(CPUARMState *env)
         }
     case TARGET_SYS_EXIT:
         if (is_a64(env)) {
-            /* The A64 version of this call takes a parameter block,
+            /*
+             * The A64 version of this call takes a parameter block,
              * so the application-exit type can return a subcode which
              * is the exit status code from the application.
              */
@@ -633,14 +652,17 @@ target_ulong do_arm_semihosting(CPUARMState *env)
                 ret = 1;
             }
         } else {
-            /* ARM specifies only Stopped_ApplicationExit as normal
-             * exit, everything else is considered an error */
+            /*
+             * ARM specifies only Stopped_ApplicationExit as normal
+             * exit, everything else is considered an error
+             */
             ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1;
         }
         gdb_exit(env, ret);
         exit(ret);
     case TARGET_SYS_SYNCCACHE:
-        /* Clean the D-cache and invalidate the I-cache for the specified
+        /*
+         * Clean the D-cache and invalidate the I-cache for the specified
          * virtual address range. This is a nop for us since we don't
          * implement caches. This is only present on A64.
          */
Signature · 1 line
2.20.1
#14 lore raw

PATCH v2 6/28 target/arm: use the common interface for WRITE0/WRITEC in arm-semi

In reply to Alex Bennée

Now we have a common semihosting console interface use that for our string output. However ARM is currently unique in also supporting semihosting for linux-user so we need to replicate the API in linux-user. If other architectures gain this support we can move the file later.

---
 linux-user/Makefile.objs  |  2 ++
 linux-user/arm/semihost.c | 24 ++++++++++++++++++++++++
 target/arm/arm-semi.c     | 31 ++++++-------------------------
 3 files changed, 32 insertions(+), 25 deletions(-)
 create mode 100644 linux-user/arm/semihost.c
linux-user/Makefile.objs +2 -0
index 769b8d83362..285c5dfa17a 100644
@@ -6,4 +6,6 @@ obj-y = main.o syscall.o strace.o mmap.o signal.o \
 obj-$(TARGET_HAS_BFLT) += flatload.o
 obj-$(TARGET_I386) += vm86.o
 obj-$(TARGET_ARM) += arm/nwfpe/
+obj-$(TARGET_ARM) += arm/semihost.o
+obj-$(TARGET_AARCH64) += arm/semihost.o
 obj-$(TARGET_M68K) += m68k-sim.o
linux-user/arm/semihost.c new file +24 -0
new file mode 100644
index 00000000000..9554102a855
@@ -0,0 +1,24 @@
+/*
+ * ARM Semihosting Console Support
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ * Currently ARM is unique in having support for semihosting support
+ * in linux-user. So for now we implement the common console API but
+ * just for arm linux-user.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "cpu.h"
+#include "hw/semihosting/console.h"
+#include "qemu.h"
+
+int qemu_semihosting_console_out(CPUArchState *env, target_ulong addr, int len)
+{
+    void *s = lock_user_string(addr);
+    len = write(STDERR_FILENO, s, len ? len : strlen(s));
+    unlock_user(s, addr, 0);
+    return len;
+}
target/arm/arm-semi.c +6 -25
index 9e5a414dd89..253c66b172a 100644
@@ -27,6 +27,7 @@
 
 #include "cpu.h"
 #include "hw/semihosting/semihost.h"
+#include "hw/semihosting/console.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
@@ -314,32 +315,12 @@ target_ulong do_arm_semihosting(CPUARMState *env)
             return set_swi_errno(ts, close(arg0));
         }
     case TARGET_SYS_WRITEC:
-        {
-          char c;
-
-          if (get_user_u8(c, args))
-              /* FIXME - should this error code be -TARGET_EFAULT ? */
-              return (uint32_t)-1;
-          /* Write to debug console.  stderr is near enough.  */
-          if (use_gdb_syscalls()) {
-                return arm_gdb_syscall(cpu, arm_semi_cb, "write,2,%x,1", args);
-          } else {
-                return write(STDERR_FILENO, &c, 1);
-          }
-        }
+    {
+        qemu_semihosting_console_out(env, args, 1);
+        return 0xdeadbeef;
+    }
     case TARGET_SYS_WRITE0:
-        if (!(s = lock_user_string(args)))
-            /* FIXME - should this error code be -TARGET_EFAULT ? */
-            return (uint32_t)-1;
-        len = strlen(s);
-        if (use_gdb_syscalls()) {
-            return arm_gdb_syscall(cpu, arm_semi_cb, "write,2,%x,%x",
-                                   args, len);
-        } else {
-            ret = write(STDERR_FILENO, s, len);
-        }
-        unlock_user(s, args, 0);
-        return ret;
+        return qemu_semihosting_console_out(env, args, 0);
     case TARGET_SYS_WRITE:
         GET_ARG(0);
         GET_ARG(1);
Signature · 1 line
2.20.1
Reviewed-by on v2 6/28
#15 lore raw

Re: [Qemu-devel] [PATCH v2 06/28] target/arm: use the common interface for WRITE0/WRITEC in arm-semi

Quoted 9 lines · Alex Bennée

case TARGET_SYS_WRITEC:

target/arm/arm-semi.c +0 -8
-        {
-          char c;
-
-          if (get_user_u8(c, args))
-              /* FIXME - should this error code be -TARGET_EFAULT ? */
-              return (uint32_t)-1;
-          /* Write to debug console.  stderr is near enough.  */
-          if (use_gdb_syscalls()) {

target/arm/arm-semi.c target_ulong do_arm_semihosting(CPUARMState *env) · line 322

Quoted 10 lines
target/arm/arm-semi.c +4 -5
-                return arm_gdb_syscall(cpu, arm_semi_cb, "write,2,%x,1", args);
-          } else {
-                return write(STDERR_FILENO, &c, 1);
-          }
-        }
+    {
+        qemu_semihosting_console_out(env, args, 1);
+        return 0xdeadbeef;
+    }
     case TARGET_SYS_WRITE0:

You can drop the braces now that "char c" is gone, which will then fix the indentation.

Otherwise,

r~

#16 lore raw

PATCH v2 7/28 target/arm: add LOG_UNIMP messages to arm-semi

In reply to Alex Bennée

Clean-up our unimplemented bits with a proper message.

---
 target/arm/arm-semi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
target/arm/arm-semi.c +3 -2
index 253c66b172a..a3bbef18ef7 100644
@@ -28,6 +28,7 @@
 #include "cpu.h"
 #include "hw/semihosting/semihost.h"
 #include "hw/semihosting/console.h"
+#include "qemu/log.h"
 #ifdef CONFIG_USER_ONLY
 #include "qemu.h"
 
@@ -366,7 +367,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
             return len - ret;
         }
     case TARGET_SYS_READC:
-       /* XXX: Read from debug console. Not implemented.  */
+        qemu_log_mask(LOG_UNIMP, "%s: SYS_READC not implemented", __func__);
         return 0;
     case TARGET_SYS_ISTTY:
         GET_ARG(0);
@@ -400,7 +401,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
             return buf.st_size;
         }
     case TARGET_SYS_TMPNAM:
-        /* XXX: Not implemented.  */
+        qemu_log_mask(LOG_UNIMP, "%s: SYS_TMPNAM not implemented", __func__);
         return -1;
     case TARGET_SYS_REMOVE:
         GET_ARG(0);
Signature · 1 line
2.20.1
#18 lore raw

PATCH v2 8/28 target/arm: correct return values for WRITE/READ in arm-semi

In reply to Alex Bennée

The documentation says the write should return the number of bytes not written on an error (0 means everything was written). Read provides a buffer length and the return value should be the buffer length - bytes actually read. Remove the incorrect FIXME's and return the correct values.

---
 target/arm/arm-semi.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
target/arm/arm-semi.c +12 -8
index a3bbef18ef7..3ae8f05d51b 100644
@@ -334,13 +334,15 @@ target_ulong do_arm_semihosting(CPUARMState *env)
         } else {
             s = lock_user(VERIFY_READ, arg1, len, 1);
             if (!s) {
-                /* FIXME - should this error code be -TARGET_EFAULT ? */
-                return (uint32_t)-1;
+                /* Return bytes not written on error */
+                return len;
             }
             ret = set_swi_errno(ts, write(arg0, s, len));
             unlock_user(s, arg1, 0);
-            if (ret == (uint32_t)-1)
-                return -1;
+            if (ret == (uint32_t)-1) {
+                ret = 0;
+            }
+            /* Return bytes not written */
             return len - ret;
         }
     case TARGET_SYS_READ:
@@ -355,15 +357,17 @@ target_ulong do_arm_semihosting(CPUARMState *env)
         } else {
             s = lock_user(VERIFY_WRITE, arg1, len, 0);
             if (!s) {
-                /* FIXME - should this error code be -TARGET_EFAULT ? */
-                return (uint32_t)-1;
+                /* return bytes not read */
+                return len;
             }
             do {
                 ret = set_swi_errno(ts, read(arg0, s, len));
             } while (ret == -1 && errno == EINTR);
             unlock_user(s, arg1, len);
-            if (ret == (uint32_t)-1)
-                return -1;
+            if (ret == (uint32_t)-1) {
+                ret = 0;
+            }
+            /* Return bytes not read */
             return len - ret;
         }
     case TARGET_SYS_READC:
Signature · 1 line
2.20.1
#19 lore raw

PATCH v2 9/28 target/mips: only build mips-semi for softmmu

In reply to Alex Bennée

The is_uhi gates all semihosting calls and always returns false for CONFIG_USER_ONLY builds. There is no reason to build and link mips-semi for these builds so lets fix that.

---
 target/mips/Makefile.objs | 3 ++-
 target/mips/helper.h      | 2 ++
 target/mips/translate.c   | 8 ++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)
target/mips/Makefile.objs +2 -1
index 651f36f5176..3448ad5e193 100644
@@ -1,4 +1,5 @@
 obj-y += translate.o dsp_helper.o op_helper.o lmi_helper.o helper.o cpu.o
-obj-y += gdbstub.o msa_helper.o mips-semi.o
+obj-y += gdbstub.o msa_helper.o
+obj-$(CONFIG_SOFTMMU) += mips-semi.o
 obj-$(CONFIG_SOFTMMU) += machine.o cp0_timer.o
 obj-$(CONFIG_KVM) += kvm.o
target/mips/helper.h +2 -0
index a6d687e3405..90ab03b76e3 100644
@@ -2,7 +2,9 @@ DEF_HELPER_3(raise_exception_err, noreturn, env, i32, int)
 DEF_HELPER_2(raise_exception, noreturn, env, i32)
 DEF_HELPER_1(raise_exception_debug, noreturn, env)
 
+#ifndef CONFIG_USER_ONLY
 DEF_HELPER_1(do_semihosting, void, env)
+#endif
 
 #ifdef TARGET_MIPS64
 DEF_HELPER_4(sdl, void, env, tl, tl, int)
target/mips/translate.c +8 -0
index 3cd5b11b16b..fb905c88b57 100644
@@ -13726,6 +13726,14 @@ static inline bool is_uhi(int sdbbp_code)
 #endif
 }
 
+#ifdef CONFIG_USER_ONLY
+/* The above should dead-code away any calls to this..*/
+static inline void gen_helper_do_semihosting(void *env)
+{
+    g_assert_not_reached();
+}
+#endif
+
 static int decode_mips16_opc (CPUMIPSState *env, DisasContext *ctx)
 {
     int rx, ry;
Signature · 1 line
2.20.1
Reviewed-by on v2 9/28
#20 lore raw

Re: [Qemu-devel] [PATCH v2 09/28] target/mips: only build mips-semi for softmmu

Quoted 4 lines · Alex Bennée

The is_uhi gates all semihosting calls and always returns false for CONFIG_USER_ONLY builds. There is no reason to build and link mips-semi for these builds so lets fix that.

Quoted 8 lines
---
 target/mips/Makefile.objs | 3 ++-
 target/mips/helper.h      | 2 ++
 target/mips/translate.c   | 8 ++++++++
 3 files changed, 12 insertions(+), 1 deletion(-)

r~

#21 lore raw

PATCH v2 10/28 target/mips: convert UHI_plog to use common semihosting code

In reply to Alex Bennée

Rather than printing directly to stdout lets use our common semihosting code. There is one minor difference in that the output currently defaults to stderr instead of stdout however this can be controlled by connecting semihosting to a chardev.

---
 target/mips/mips-semi.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
target/mips/mips-semi.c +6 -6
index eac8374fb34..35bdfd7c77e 100644
@@ -23,6 +23,7 @@
 #include "exec/helper-proto.h"
 #include "exec/softmmu-semi.h"
 #include "hw/semihosting/semihost.h"
+#include "hw/semihosting/console.h"
 
 typedef enum UHIOp {
     UHI_exit = 1,
@@ -329,13 +330,12 @@ void helper_do_semihosting(CPUMIPSState *env)
         p2 = strstr(p, "%d");
         if (p2) {
             int char_num = p2 - p;
-            char *buf = g_malloc(char_num + 1);
-            strncpy(buf, p, char_num);
-            buf[char_num] = '\0';
-            gpr[2] = printf("%s%d%s", buf, (int)gpr[5], p2 + 2);
-            g_free(buf);
+            GString *s = g_string_new_len(p, char_num);
+            g_string_append_printf(s, "%d%s", (int)gpr[5], p2 + 2);
+            gpr[2] = qemu_semihosting_log_out(s->str, s->len);
+            g_string_free(s, true);
         } else {
-            gpr[2] = printf("%s", p);
+            gpr[2] = qemu_semihosting_log_out(p, strlen(p));
         }
         FREE_TARGET_STRING(p, gpr[4]);
         break;
Signature · 1 line
2.20.1
#22 lore raw

PATCH v2 11/28 MAINTAINERS: update for semihostings new home

In reply to Alex Bennée

Seeing as I touched it I should at least keep an eye on it.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index a6948ebc63b..c4f209898a9 100644
@@ -2560,6 +2560,13 @@ F: docs/pvrdma.txt
 F: contrib/rdmacm-mux/*
 F: qapi/rdma.json
 
+Semihosting
+M: Alex Bennée <[email protected]>
+L: [email protected]
+S: Maintained
+F: hw/semihosting/
+F: include/hw/semihosting/
+
 Build and test automation
 -------------------------
 Build and test automation
Signature · 1 line
2.20.1
#24 lore raw

PATCH v2 12/28 tests/docker: add ubuntu 18.04

In reply to Alex Bennée

From: Gerd Hoffmann <[email protected]>

Based on the ubuntu.docker file.
Used to reproduce the build failure Peter was seeing. Others might find this useful too ;)

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/ubuntu1804.docker | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 tests/docker/dockerfiles/ubuntu1804.docker
tests/docker/dockerfiles/ubuntu1804.docker new file +57 -0
new file mode 100644
index 00000000000..2e2900150b0
@@ -0,0 +1,57 @@
+FROM ubuntu:18.04
+ENV PACKAGES flex bison \
+    ccache \
+    clang \
+    gcc \
+    gettext \
+    git \
+    glusterfs-common \
+    libaio-dev \
+    libattr1-dev \
+    libbluetooth-dev \
+    libbrlapi-dev \
+    libbz2-dev \
+    libcacard-dev \
+    libcap-dev \
+    libcap-ng-dev \
+    libcurl4-gnutls-dev \
+    libdrm-dev \
+    libepoxy-dev \
+    libfdt-dev \
+    libgbm-dev \
+    libgtk-3-dev \
+    libibverbs-dev \
+    libiscsi-dev \
+    libjemalloc-dev \
+    libjpeg-turbo8-dev \
+    liblzo2-dev \
+    libncurses5-dev \
+    libncursesw5-dev \
+    libnfs-dev \
+    libnss3-dev \
+    libnuma-dev \
+    libpixman-1-dev \
+    librados-dev \
+    librbd-dev \
+    librdmacm-dev \
+    libsasl2-dev \
+    libsdl2-dev \
+    libseccomp-dev \
+    libsnappy-dev \
+    libspice-protocol-dev \
+    libspice-server-dev \
+    libssh2-1-dev \
+    libusb-1.0-0-dev \
+    libusbredirhost-dev \
+    libvdeplug-dev \
+    libvte-2.91-dev \
+    libxen-dev \
+    make \
+    python-yaml \
+    sparse \
+    texinfo \
+    xfslibs-dev
+RUN apt-get update && \
+    apt-get -y install $PACKAGES
+RUN dpkg -l $PACKAGES | sort > /packages.txt
+ENV FEATURES clang pyyaml sdl2
Signature · 1 line
2.20.1
#25 lore raw

PATCH v2 13/28 tests/docker: Test more components on the Fedora default image

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

Install optional dependencies of QEMU to get better coverage.

The following components are now enabled:

  $ ./configure
  ...
  Multipath support yes
  VNC SASL support  yes
  RDMA support      yes
  PVRDMA support    yes
  libiscsi support  yes
  seccomp support   yes
  libpmem support   yes
  libudev           yes

Note: The udev-devel package is provided by systemd-devel.

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/fedora.docker | 7 +++++++
 1 file changed, 7 insertions(+)
tests/docker/dockerfiles/fedora.docker +7 -0
index 69d4a7f5d75..afbba29adaa 100644
@@ -8,6 +8,7 @@ ENV PACKAGES \
     bzip2-devel \
     ccache \
     clang \
+    cyrus-sasl-devel \
     device-mapper-multipath-devel \
     findutils \
     flex \
@@ -23,13 +24,17 @@ ENV PACKAGES \
     libaio-devel \
     libasan \
     libattr-devel \
+    libblockdev-mpath-devel \
     libcap-devel \
     libcap-ng-devel \
     libcurl-devel \
     libfdt-devel \
+    libiscsi-devel \
     libjpeg-devel \
+    libpmem-devel \
     libpng-devel \
     librbd-devel \
+    libseccomp-devel \
     libssh2-devel \
     libubsan \
     libusbx-devel \
@@ -74,10 +79,12 @@ ENV PACKAGES \
     pixman-devel \
     python3 \
     PyYAML \
+    rdma-core-devel \
     SDL2-devel \
     snappy-devel \
     sparse \
     spice-server-devel \
+    systemd-devel \
     systemtap-sdt-devel \
     tar \
     usbredir-devel \
Signature · 1 line
2.20.1
#26 lore raw

PATCH v2 14/28 tests/tcg/multiarch: add support for multiarch system tests

In reply to Alex Bennée

We can certainly support some common tests for system emulation that make use of our minimal defined boot.S support. It will still be up to individual architectures to ensure they build so we provide a MULTIARCH_TESTS variable that they can tack onto TESTS themselves.

---
 tests/tcg/Makefile                                 |  1 +
 tests/tcg/multiarch/system/Makefile.softmmu-target | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 tests/tcg/multiarch/system/Makefile.softmmu-target
tests/tcg/Makefile +1 -0
index 1cdd628e96f..6fa63cc8d53 100644
@@ -96,6 +96,7 @@ else
 # build options for bare programs are usually pretty different. They
 # are expected to provide their own build recipes.
 -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
+-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
 -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target
 ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
tests/tcg/multiarch/system/Makefile.softmmu-target new file +14 -0
new file mode 100644
index 00000000000..db4bbeda44c
@@ -0,0 +1,14 @@
+# -*- Mode: makefile -*-
+#
+# Multiarch system tests
+#
+# We just collect the tests together here and rely on the actual guest
+# architecture to add to the test dependancies and deal with the
+# complications of building.
+#
+
+MULTIARCH_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/multiarch/system
+VPATH+=$(MULTIARCH_SYSTEM_SRC)
+
+MULTIARCH_TEST_SRCS=$(wildcard $(MULTIARCH_SYSTEM_SRC)/*.c)
+MULTIARCH_TESTS = $(patsubst $(MULTIARCH_SYSTEM_SRC)/%.c, %, $(MULTIARCH_TEST_SRCS))
Signature · 1 line
2.20.1
#27 lore raw

PATCH v2 15/28 tests/tcg/multiarch: add hello world system test

In reply to Alex Bennée

This is not really i386 only, we can have the same test for all architectures supporting system tests.

---
 tests/tcg/i386/Makefile.softmmu-target       | 2 +-
 tests/tcg/{i386 => multiarch}/system/hello.c | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename tests/tcg/{i386 => multiarch}/system/hello.c (100%)
tests/tcg/i386/Makefile.softmmu-target +1 -1
index 53c9c5ece06..c31bbbf39a7 100644
@@ -27,7 +27,7 @@ CFLAGS+=-m32
 LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
 LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
 # FIXME: move to common once x86_64 is bootstrapped
-TESTS+=$(X86_TESTS)
+TESTS+=$(X86_TESTS) $(MULTIARCH_TESTS)
 endif
 CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
 LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
tests/tcg/multiarch/system/hello.c renamed from tests/tcg/i386/system/hello.c +0 -0
similarity index 100%
rename from tests/tcg/i386/system/hello.c
rename to tests/tcg/multiarch/system/hello.c
Signature · 1 line
2.20.1
#28 lore raw

PATCH v2 16/28 editorconfig: add settings for .s/.S files

In reply to Alex Bennée

We are starting to add assembler foe tests/tcg so lets make sure we get the mode right.

---
 .editorconfig | 5 +++++
 1 file changed, 5 insertions(+)
.editorconfig +5 -0
index 15828833938..df6db65531d 100644
@@ -26,6 +26,11 @@ file_type_emacs = makefile
 indent_style = space
 indent_size = 4
 
+[*.{s,S}]
+indent_style = tab
+indent_size = 8
+file_type_emacs = asm
+
 [*.{vert,frag}]
 file_type_emacs = glsl
 
Signature · 1 line
2.20.1
#29 lore raw

PATCH v2 17/28 tests/tcg/aarch64: add system boot.S

In reply to Alex Bennée

This provides the bootstrap and low level helper functions for an aarch64 kernel. We use semihosting to handle test output and exiting the emulation. semihosting's parameter passing is a little funky so we end up using the stack and pointing to that as the parameter block.

---
v2
- fix tabs
- 2 stage table lookup with ro and nx sections
- set stack to back
- moar comments

---
 tests/tcg/aarch64/Makefile.softmmu-target |  32 +++
 tests/tcg/aarch64/system/boot.S           | 239 ++++++++++++++++++++++
 tests/tcg/aarch64/system/kernel.ld        |  24 +++
 3 files changed, 295 insertions(+)
 create mode 100644 tests/tcg/aarch64/Makefile.softmmu-target
 create mode 100644 tests/tcg/aarch64/system/boot.S
 create mode 100644 tests/tcg/aarch64/system/kernel.ld
tests/tcg/aarch64/Makefile.softmmu-target new file +32 -0
new file mode 100644
index 00000000000..cdb836f7e1e
@@ -0,0 +1,32 @@
+#
+# Aarch64 system tests
+#
+
+AARCH64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/aarch64/system
+VPATH+=$(AARCH64_SYSTEM_SRC)
+
+# These objects provide the basic boot code and helper functions for all tests
+CRT_OBJS=boot.o
+
+AARCH64_TEST_SRCS=$(wildcard $(AARCH64_SYSTEM_SRC)/*.c)
+AARCH64_TESTS = $(patsubst $(AARCH64_SYSTEM_SRC)/%.c, %, $(AARCH64_TEST_SRCS))
+
+CRT_PATH=$(AARCH64_SYSTEM_SRC)
+LINK_SCRIPT=$(AARCH64_SYSTEM_SRC)/kernel.ld
+LDFLAGS=-Wl,-T$(LINK_SCRIPT)
+TESTS+=$(AARCH64_TESTS) $(MULTIARCH_TESTS)
+CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
+LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
+
+# building head blobs
+.PRECIOUS: $(CRT_OBJS)
+
+%.o: $(CRT_PATH)/%.S
+	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
+
+# Build and link the tests
+%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
+	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+
+# Running
+QEMU_OPTS+=-M virt -cpu max -display none -semihosting-config enable=on,target=native,chardev=output -kernel
tests/tcg/aarch64/system/boot.S new file +239 -0

239 lines not on this page · raw message

tests/tcg/aarch64/system/kernel.ld new file +24 -0
new file mode 100644
index 00000000000..7b3a76dcbf3
@@ -0,0 +1,24 @@
+ENTRY(__start)
+
+SECTIONS
+{
+    /* virt machine, RAM starts at 1gb */
+    . = (1 << 30);
+    .text : {
+        *(.text)
+    }
+    .rodata : {
+        *(.rodata)
+    }
+    /* align r/w section to next 2mb */
+    . = ALIGN(1 << 21);
+    .data : {
+        *(.data)
+    }
+    .bss : {
+        *(.bss)
+    }
+    /DISCARD/ : {
+        *(.ARM.attributes)
+    }
+}
Signature · 1 line
2.20.1
Reviewed-by on v2 17/28
#30 lore raw

Re: [Qemu-devel] [PATCH v2 17/28] tests/tcg/aarch64: add system boot.S

Quoted 13 lines · Alex Bennée

This provides the bootstrap and low level helper functions for an aarch64 kernel. We use semihosting to handle test output and exiting the emulation. semihosting's parameter passing is a little funky so we end up using the stack and pointing to that as the parameter block.

---
v2
- fix tabs
- 2 stage table lookup with ro and nx sections
- set stack to back
- moar comments

Quoted 8 lines
---
 tests/tcg/aarch64/Makefile.softmmu-target |  32 +++
 tests/tcg/aarch64/system/boot.S           | 239 ++++++++++++++++++++++
 tests/tcg/aarch64/system/kernel.ld        |  24 +++
 3 files changed, 295 insertions(+)
 create mode 100644 tests/tcg/aarch64/Makefile.softmmu-target
 create mode 100644 tests/tcg/aarch64/system/boot.S
 create mode 100644 tests/tcg/aarch64/system/kernel.ld

r~

#31 lore raw

PATCH v2 18/28 tests/tcg/multiarch: move the system memory test

In reply to Alex Bennée

There is nothing inherently architecture specific about the memory test although we may have to manage different restrictions of unaligned access across architectures.

---
 tests/tcg/{i386 => multiarch}/system/memory.c | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename tests/tcg/{i386 => multiarch}/system/memory.c (100%)
tests/tcg/multiarch/system/memory.c renamed from tests/tcg/i386/system/memory.c +0 -0
similarity index 100%
rename from tests/tcg/i386/system/memory.c
rename to tests/tcg/multiarch/system/memory.c
Signature · 1 line
2.20.1
#32 lore raw

PATCH v2 19/28 tests/tcg/minilib: support %c format char

In reply to Alex Bennée
---
 tests/tcg/minilib/printf.c | 3 +++
 1 file changed, 3 insertions(+)
tests/tcg/minilib/printf.c +3 -0
index 121620cb162..10472b4f585 100644
@@ -119,6 +119,9 @@ void ml_printf(const char *fmt, ...)
             str = va_arg(ap, char*);
             print_str(str);
             break;
+        case 'c':
+            __sys_outc(va_arg(ap, int));
+            break;
         case '%':
             __sys_outc(*fmt);
             break;
Signature · 1 line
2.20.1
#33 lore raw

PATCH v2 20/28 tests/tcg/multiarch: expand system memory test to cover more

In reply to Alex Bennée

Expand the memory test to cover move of the softmmu code. Specifically we:

- improve commentary
- add some helpers (for later BE support)
- reduce boiler plate into helpers
- add signed reads at various sizes/offsets
- required -DCHECK_UNALIGNED

---
 tests/tcg/aarch64/Makefile.softmmu-target |   2 +
 tests/tcg/i386/Makefile.softmmu-target    |   2 +
 tests/tcg/multiarch/system/memory.c       | 350 +++++++++++++++++-----
 3 files changed, 282 insertions(+), 72 deletions(-)
tests/tcg/aarch64/Makefile.softmmu-target +2 -0
index cdb836f7e1e..2e560e4d08e 100644
@@ -28,5 +28,7 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
 	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
 
+memory: CFLAGS+=-DCHECK_UNALIGNED=1
+
 # Running
 QEMU_OPTS+=-M virt -cpu max -display none -semihosting-config enable=on,target=native,chardev=output -kernel
tests/tcg/i386/Makefile.softmmu-target +2 -0
index c31bbbf39a7..e1f98177aa5 100644
@@ -42,5 +42,7 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 %: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
 	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
 
+memory: CFLAGS+=-DCHECK_UNALIGNED=1
+
 # Running
 QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
tests/tcg/multiarch/system/memory.c +278 -72

468 lines not on this page · raw message

Signature · 1 line
2.20.1
#34 lore raw

PATCH v2 21/28 tests/tcg/alpha: add system boot.S

In reply to Alex Bennée

From: Richard Henderson <[email protected]>

This provides the bootstrap and low level helper functions for an alpha kernel. We use direct access to the DP264 serial port for test output, and hard machine halt to exit the emulation.

Message-Id: <[email protected]>

---
 MAINTAINERS                             |   1 +
 tests/tcg/alpha/Makefile.softmmu-target |  34 ++
 tests/tcg/alpha/system/boot.S           | 511 ++++++++++++++++++++++++
 tests/tcg/alpha/system/kernel.ld        |  30 ++
 4 files changed, 576 insertions(+)
 create mode 100644 tests/tcg/alpha/Makefile.softmmu-target
 create mode 100644 tests/tcg/alpha/system/boot.S
 create mode 100644 tests/tcg/alpha/system/kernel.ld
MAINTAINERS +1 -0
index c4f209898a9..546a1431ea3 100644
@@ -470,6 +470,7 @@ M: Richard Henderson <[email protected]>
 S: Maintained
 F: hw/alpha/
 F: hw/isa/smc37c669-superio.c
+F: tests/tcg/alpha/system/
 
 ARM Machines
 ------------
tests/tcg/alpha/Makefile.softmmu-target new file +34 -0
new file mode 100644
index 00000000000..3c0f34cc692
@@ -0,0 +1,34 @@
+#
+# Alpha system tests
+#
+
+ALPHA_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/alpha/system
+VPATH+=$(ALPHA_SYSTEM_SRC)
+
+# These objects provide the basic boot code and helper functions for all tests
+CRT_OBJS=boot.o
+
+ALPHA_TEST_SRCS=$(wildcard $(ALPHA_SYSTEM_SRC)/*.c)
+ALPHA_TESTS = $(patsubst $(ALPHA_SYSTEM_SRC)/%.c, %, $(ALPHA_TEST_SRCS))
+
+CRT_PATH=$(ALPHA_SYSTEM_SRC)
+LINK_SCRIPT=$(ALPHA_SYSTEM_SRC)/kernel.ld
+LDFLAGS=-Wl,-T$(LINK_SCRIPT)
+TESTS+=$(ALPHA_TESTS) $(MULTIARCH_TESTS)
+CFLAGS+=-nostdlib -g -O1 -mcpu=ev6 $(MINILIB_INC)
+LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
+
+# building head blobs
+.PRECIOUS: $(CRT_OBJS)
+
+%.o: $(CRT_PATH)/%.S
+	$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
+
+# Build and link the tests
+%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
+	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
+
+memory: CFLAGS+=-DCHECK_UNALIGNED=0
+
+# Running
+QEMU_OPTS+=-serial chardev:output -kernel
tests/tcg/alpha/system/boot.S new file +511 -0

511 lines not on this page · raw message

tests/tcg/alpha/system/kernel.ld new file +30 -0
new file mode 100644
index 00000000000..d2ac6ecfeb8
@@ -0,0 +1,30 @@
+ENTRY(_start)
+
+SECTIONS
+{
+    /* Linux kernel legacy start address.  */
+    . = 0xfffffc0000310000;
+    _text = .;
+    .text : {
+        *(.text)
+    }
+    .rodata : {
+        *(.rodata)
+    }
+    _etext = .;
+
+    . = ALIGN(8192);
+    _data = .;
+    .got : {
+        *(.got)
+    }
+    .data : {
+	*(.sdata)
+        *(.data)
+    }
+    _edata = .;
+    .bss : {
+        *(.bss)
+    }
+    _end = .;
+}
Signature · 1 line
2.20.1
#35 lore raw

PATCH v2 22/28 .travis.yml: enable aarch64-softmmu and alpha-softmmu tcg tests

In reply to Alex Bennée
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.travis.yml +1 -1
index 6fd89b3d915..b053a836a32 100644
@@ -284,5 +284,5 @@ matrix:
 
     # Run check-tcg against softmmu targets
     - env:
-        - CONFIG="--target-list=xtensa-softmmu,arm-softmmu"
+        - CONFIG="--target-list=xtensa-softmmu,arm-softmmu,aarch64-softmmu,alpha-softmmu"
         - TEST_CMD="make -j3 check-tcg V=1"
Signature · 1 line
2.20.1
#36 lore raw

PATCH v2 23/28 Makefile: fix coverage-report reference to BUILD_DIR

In reply to Alex Bennée

Commit 337f2311f actually claimed to do this in the commit log but didn't actually. Oops.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 155f066a206..40561993c40 100644
@@ -998,7 +998,7 @@ $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
 %/coverage-report.html:
 	@mkdir -p $*
 	$(call quiet-command,\
-		gcovr -r $(SRC_PATH) --object-directory $(BUILD_PATH) \
+		gcovr -r $(SRC_PATH) --object-directory $(BUILD_DIR) \
 		-p --html --html-details -o $@, \
 		"GEN", "coverage-report.html")
 
Signature · 1 line
2.20.1
#37 lore raw

PATCH v2 24/28 Makefile: include per-target build directories in coverage report

In reply to Alex Bennée
---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 40561993c40..e8a886aac79 100644
@@ -998,7 +998,9 @@ $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
 %/coverage-report.html:
 	@mkdir -p $*
 	$(call quiet-command,\
-		gcovr -r $(SRC_PATH) --object-directory $(BUILD_DIR) \
+		gcovr -r $(SRC_PATH) \
+		$(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
+		 --object-directory $(BUILD_DIR) \
 		-p --html --html-details -o $@, \
 		"GEN", "coverage-report.html")
 
Signature · 1 line
2.20.1
#38 lore raw

PATCH v2 25/28 Makefile.target: support per-target coverage reports

In reply to Alex Bennée

Add support for generating a single targets coverage report. Execute:

make coverage-report

In the target build directory. This coverage report only cares about target specific blobs so only searches the target build subdirectory.

---
 Makefile.target | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Makefile.target +16 -0
index fdbe7c89f4a..328c37902ea 100644
@@ -238,3 +238,19 @@ endif
 
 generated-files-y += config-target.h
 Makefile: $(generated-files-y)
+
+# Reports/Analysis
+#
+# The target specific coverage report only cares about target specific
+# blobs and not the shared code.
+#
+
+%/coverage-report.html:
+	@mkdir -p $*
+	$(call quiet-command,\
+		gcovr -r $(SRC_PATH) --object-directory $(CURDIR) \
+		-p --html --html-details -o $@, \
+		"GEN", "coverage-report.html")
+
+.PHONY: coverage-report
+coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
Signature · 1 line
2.20.1
#39 lore raw

PATCH v2 26/28 tests/qemu-iotests/group: Re-use the "auto" group for tests that can always run

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

Currently, all tests are in the "auto" group. This is a little bit pointless. OTOH, we need a group for the tests that we can automatically run during "make check" each time, too. Tests in this new group are supposed to run with every possible QEMU configuration, for example they must run with every QEMU binary (also non-x86), without failing when an optional features is missing (but reporting "skip" is ok), and be able to run on all kind of host filesystems and users (i.e. also as "nobody" or "root").
So let's use the "auto" group for this class of tests now. The initial list has been determined by running the iotests with non-x86 QEMU targets and with our CI pipelines on Gitlab, Cirrus-CI and Travis (i.e. including macOS and FreeBSD).

Message-Id: <[email protected]>

---
 tests/qemu-iotests/group | 177 +++++++++++++++++++++------------------
 1 file changed, 95 insertions(+), 82 deletions(-)
tests/qemu-iotests/group +95 -82
index 52b7c16e155..2c74deec00e 100644
@@ -1,8 +1,21 @@
 #
 # QA groups control file
 # Defines test groups
+#
+# Some notes about the groups:
+#
 # - do not start group names with a digit
 #
+# - quick : Tests in this group should finish within some few seconds.
+#
+# - img : Tests in this group can be used to excercise the qemu-img tool.
+#
+# - auto : Tests in this group are used during "make check" and should be
+#   runnable in any case. That means they should run with every QEMU binary
+#   (also non-x86), with every QEMU configuration (i.e. must not fail if
+#   an optional feature is not compiled in - but reporting a "skip" is ok),
+#   and work all kind of host filesystems and users (e.g. "nobody" or "root").
+#
 
 #
 # test-group association ... one line per test
@@ -32,11 +45,11 @@
 023 rw auto
 024 rw backing auto quick
 025 rw auto quick
-026 rw blkdbg auto
+026 rw blkdbg
 027 rw auto quick
-028 rw backing auto quick
+028 rw backing quick
 029 rw auto quick
-030 rw auto backing
+030 rw backing
 031 rw auto quick
 032 rw auto quick
 033 rw auto quick
@@ -46,35 +59,35 @@
 037 rw auto backing quick
 038 rw auto backing quick
 039 rw auto quick
-040 rw auto
-041 rw auto backing
+040 rw
+041 rw backing
 042 rw auto quick
 043 rw auto backing
-044 rw auto
-045 rw auto quick
+044 rw
+045 rw quick
 046 rw auto aio quick
 047 rw auto quick
 048 img auto quick
 049 rw auto
 050 rw auto backing quick
-051 rw auto
+051 rw
 052 rw auto backing quick
 053 rw auto quick
 054 rw auto quick
-055 rw auto
-056 rw auto backing
-057 rw auto
-058 rw auto quick
+055 rw
+056 rw backing
+057 rw
+058 rw quick
 059 rw auto quick
 060 rw auto quick
 061 rw auto
 062 rw auto quick
 063 rw auto quick
 064 rw auto quick
-065 rw auto quick
+065 rw quick
 066 rw auto quick
-067 rw auto quick
-068 rw auto quick
+067 rw quick
+068 rw quick
 069 rw auto quick
 070 rw auto quick
 071 rw auto quick
@@ -91,18 +104,18 @@
 082 rw auto quick
 083 rw auto
 084 img auto quick
-085 rw auto
+085 rw
 086 rw auto quick
-087 rw auto quick
+087 rw quick
 088 rw auto quick
 089 rw auto quick
 090 rw auto quick
 091 rw auto migration
 092 rw auto quick
-093 auto
+093 throttle
 094 rw auto quick
-095 rw auto quick
-096 rw auto quick
+095 rw quick
+096 rw quick
 097 rw auto backing
 098 rw auto backing quick
 099 rw auto quick
@@ -118,60 +131,60 @@
 109 rw auto
 110 rw auto backing quick
 111 rw auto quick
-112 rw auto
+112 rw
 113 rw auto quick
 114 rw auto quick
-115 rw auto
+115 rw
 116 rw auto quick
 117 rw auto
-118 rw auto
+118 rw
 119 rw auto quick
 120 rw auto quick
-121 rw auto
+121 rw
 122 rw auto
 123 rw auto quick
-124 rw auto backing
-125 rw auto
+124 rw backing
+125 rw
 126 rw auto backing
-127 rw auto backing quick
+127 rw backing quick
 128 rw auto quick
-129 rw auto quick
+129 rw quick
 130 rw auto quick
 131 rw auto quick
-132 rw auto quick
+132 rw quick
 133 auto quick
 134 rw auto quick
 135 rw auto
-136 rw auto
+136 rw
 137 rw auto
 138 rw auto quick
-139 rw auto quick
+139 rw quick
 140 rw auto quick
 141 rw auto quick
 142 auto
 143 auto quick
-144 rw auto quick
-145 auto quick
+144 rw quick
+145 quick
 146 auto quick
-147 auto
-148 rw auto quick
-149 rw auto sudo
+147 img
+148 rw quick
+149 rw sudo
 150 rw auto quick
-151 rw auto
-152 rw auto quick
-153 rw auto quick
+151 rw
+152 rw quick
+153 rw quick
 154 rw auto backing quick
-155 rw auto
+155 rw
 156 rw auto quick
-157 auto
+157 quick
 158 rw auto quick
 159 rw auto quick
 160 rw auto quick
 161 rw auto quick
-162 auto quick
-163 rw auto
-165 rw auto quick
-169 rw auto quick migration
+162 quick
+163 rw
+165 rw quick
+169 rw quick migration
 170 rw auto quick
 171 rw auto quick
 172 auto
@@ -180,74 +193,74 @@
 175 auto quick
 176 rw auto backing
 177 rw auto quick
-178 auto
+178 img
 179 rw auto quick
 181 rw auto migration
-182 rw auto quick
-183 rw auto migration
+182 rw quick
+183 rw migration
 184 rw auto quick
-185 rw auto
+185 rw
 186 rw auto
 187 rw auto
-188 rw auto quick
-189 rw auto
+188 rw quick
+189 rw
 190 rw auto quick
 191 rw auto
 192 rw auto quick
-194 rw auto migration quick
+194 rw migration quick
 195 rw auto quick
-196 rw auto quick migration
+196 rw quick migration
 197 rw auto quick
-198 rw auto
-199 rw auto migration
-200 rw auto
+198 rw
+199 rw migration
+200 rw
 201 rw auto migration
-202 rw auto quick
-203 rw auto migration
-204 rw auto quick
-205 rw auto quick
-206 rw auto
+202 rw quick
+203 rw migration
+204 rw quick
+205 rw quick
+206 rw
 207 rw auto
-208 rw auto quick
-209 rw auto quick
+208 rw quick
+209 rw quick
 210 rw auto
 211 rw auto quick
 212 rw auto quick
 213 rw auto quick
 214 rw auto
 215 rw auto quick
-216 rw auto quick
+216 rw quick
 217 rw auto quick
-218 rw auto quick
-219 rw auto
+218 rw quick
+219 rw
 220 rw auto
 221 rw auto quick
-222 rw auto quick
-223 rw auto quick
-224 rw auto quick
+222 rw quick
+223 rw quick
+224 rw quick
 225 rw auto quick
 226 auto quick
-227 auto quick
-228 rw auto quick
+227 quick
+228 rw quick
 229 auto quick
 231 auto quick
-232 auto quick
+232 quick
 233 auto quick
-234 auto quick migration
-235 auto quick
-236 auto quick
+234 quick migration
+235 quick
+236 quick
 237 rw auto quick
-238 auto quick
+238 quick
 239 rw auto quick
-240 auto quick
+240 quick
 241 rw auto quick
-242 rw auto quick
+242 rw quick
 243 rw auto quick
 244 rw auto quick
-245 rw auto
-246 rw auto quick
-247 rw auto quick
-248 rw auto quick
+245 rw
+246 rw quick
+247 rw quick
+248 rw quick
 249 rw auto quick
 252 rw auto backing quick
 253 rw auto quick
Signature · 1 line
2.20.1
#40 lore raw

PATCH v2 27/28 tests/qemu-iotests: re-format output to for make check-block

In reply to Alex Bennée

This attempts to clean-up the output to better match the output of the rest of the QEMU check system when called with -makecheck. This includes:

- formatting as " TEST iotest-FMT: nnn"
- only dumping config on failure (when -makecheck enabled)

The non-make check output has been cleaned up as well:

- line re-displayed (\r) at the end
- fancy colours for pass/fail/skip
- timestamps always printed (option removed)

Message-Id: <[email protected]>

---
v3
- revert echo to printf
- add _report_test_start
v4
- -pretty -> -makecheck
- keep all output together for makecheck
v5
- merged in kwolf's pretty printing
- timestamps always printed in non-makecheck mode

---
 tests/qemu-iotests/check | 179 +++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 63 deletions(-)
tests/qemu-iotests/check +116 -63
index 922c5d1d3d3..f46b90dbbf4 100755
@@ -27,9 +27,7 @@ bad=""
 notrun=""
 casenotrun=""
 interrupt=true
-
-# by default don't output timestamps
-timestamp=${TIMESTAMP:=false}
+makecheck=false
 
 _init_error()
 {
@@ -88,6 +86,22 @@ _full_platform_details()
     echo "$os/$platform $host $kernel"
 }
 
+_full_env_details()
+{
+    cat <<EOF
+QEMU          -- "$QEMU_PROG" $QEMU_OPTIONS
+QEMU_IMG      -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
+QEMU_IO       -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
+QEMU_NBD      -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
+IMGFMT        -- $FULL_IMGFMT_DETAILS
+IMGPROTO      -- $IMGPROTO
+PLATFORM      -- $FULL_HOST_DETAILS
+TEST_DIR      -- $TEST_DIR
+SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
+
+EOF
+}
+
 # $1 = prog to look for
 set_prog_path()
 {
@@ -254,8 +268,8 @@ other options
     -misalign           misalign memory allocations
     -n                  show me, do not run tests
     -o options          -o options to pass to qemu-img create/convert
-    -T                  output timestamps
     -c mode             cache mode
+    -makecheck          pretty print output for make check
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -403,7 +417,10 @@ testlist options
                 command -v xxdiff >/dev/null 2>&1 && diff=xxdiff
             fi
             ;;
-
+        -makecheck)   # makecheck friendly output
+            makecheck=true
+            xpand=false
+            ;;
         -n)        # show me, don't do it
             showme=true
             xpand=false
@@ -416,11 +433,6 @@ testlist options
             cachemode=true
             xpand=false
             ;;
-        -T)        # turn on timestamp output
-            timestamp=true
-            xpand=false
-            ;;
-
         -v)
             verbose=true
             xpand=false
@@ -633,12 +645,6 @@ _wallclock()
     date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
 }
 
-_timestamp()
-{
-    now=$(date "+%T")
-    printf %s " [$now]"
-}
-
 _wrapup()
 {
     if $showme
@@ -704,23 +710,54 @@ END        { if (NR > 0) {
 
 trap "_wrapup; exit \$status" 0 1 2 3 15
 
+# Report the test start and results. For makecheck we want to pretty
+# print the whole report at the end of the execution.
+# args: $seq, $starttime, $lasttime
+_report_test_start()
+{
+    if ! $makecheck; then
+        if [ -n "$3" ]; then
+            local lasttime=" (last: $3s)"
+        fi
+        printf "%-8s %-10s [%s]            %4s%-14s\r" "$1" "..." "$2" "..." "$lasttime"
+    fi
+}
+# args:$seq $status $starttime $lasttime $thistime $details
+_report_test_result()
+{
+    local status lasttime thistime
+    if $makecheck; then
+        if [ -n "$2" ] && [ "$2" != "pass" ]; then
+            status=" [$2]"
+        fi
+        printf "  TEST    iotest-$IMGFMT: %s%s\n" "$1" "$status"
+        return
+    fi
+
+    if [ -n "$4" ]; then
+        lasttime=" (last: $4s)"
+    fi
+    if [ -n "$5" ]; then
+        thistime=" $5s"
+    fi
+    case "$2" in
+        "pass")     status=$(printf "\e[32m%-10s\e[0m" "$2") ;;
+        "fail")     status=$(printf "\e[1m\e[31m%-10s\e[0m" "$2") ;;
+        "not run")  status=$(printf "\e[33m%-10s\e[0m" "$2") ;;
+        *)          status=$(printf "%-10s" "$2") ;;
+    esac
+
+    printf "%-8s %s [%s] [%s] %4s%-14s %s\n" "$1" "$status" "$3" "$(date '+%T')" "$thistime" "$lasttime" "$6"
+}
+
 [ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE
 
 FULL_IMGFMT_DETAILS=$(_full_imgfmt_details)
 FULL_HOST_DETAILS=$(_full_platform_details)
 
-cat <<EOF
-QEMU          -- "$QEMU_PROG" $QEMU_OPTIONS
-QEMU_IMG      -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
-QEMU_IO       -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
-QEMU_NBD      -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
-IMGFMT        -- $FULL_IMGFMT_DETAILS
-IMGPROTO      -- $IMGPROTO
-PLATFORM      -- $FULL_HOST_DETAILS
-TEST_DIR      -- $TEST_DIR
-SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER
-
-EOF
+if ! $makecheck; then
+    _full_env_details
+fi
 
 seq="check"
 
@@ -728,42 +765,43 @@ seq="check"
 
 for seq in $list
 do
-    err=false
-    printf %s "$seq"
+    err=false       # error flag
+    printdiff=false # show diff to reference output?
+    status=""       # test result summary
+    results=""      # test result details
+
     if [ -n "$TESTS_REMAINING_LOG" ] ; then
         sed -e "s/$seq//" -e 's/  / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
         mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
         sync
     fi
 
+    lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
+    starttime=$(date "+%T")
+    _report_test_start $seq $starttime $lasttime
+
     if $showme
     then
-        echo
-        continue
+        status="not run"
     elif [ -f expunged ] && $expunge && egrep "^$seq([         ]|\$)" expunged >/dev/null
     then
-        echo " - expunged"
+        status="not run"
+        results="expunged"
         rm -f $seq.out.bad
         echo "/^$seq\$/d" >>$tmp.expunged
     elif [ ! -f "$source_iotests/$seq" ]
     then
-        echo " - no such test?"
+        status="not run"
+        results="no such test?"
         echo "/^$seq\$/d" >>$tmp.expunged
     else
         # really going to try and run this one
         #
         rm -f $seq.out.bad
-        lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE)
-        if [ "X$lasttime" != X ]; then
-                printf %s " ${lasttime}s ..."
-        else
-                printf "        "        # prettier output with timestamps.
-        fi
         rm -f core $seq.notrun
         rm -f $seq.casenotrun
 
         start=$(_wallclock)
-        $timestamp && printf %s "        [$(date "+%T")]"
 
         if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python" ]; then
             run_command="$PYTHON $seq"
@@ -781,26 +819,26 @@ do
                     $run_command >$tmp.out 2>&1)
         fi
         sts=$?
-        $timestamp && _timestamp
         stop=$(_wallclock)
 
         if [ -f core ]
         then
-            printf " [dumped core]"
             mv core $seq.core
+            status="fail"
+            results="[dumped core] $seq.core"
             err=true
         fi
 
         if [ -f $seq.notrun ]
         then
-            $timestamp || printf " [not run] "
-            $timestamp && echo " [not run]" && printf %s "        $seq -- "
-            cat $seq.notrun
-            notrun="$notrun $seq"
+            # overwrites timestamp output
+            status="not run"
+            results="$(cat $seq.notrun)"
         else
             if [ $sts -ne 0 ]
             then
-                printf %s " [failed, exit status $sts]"
+                status="fail"
+                results=$(printf %s "[failed, exit status $sts]")
                 err=true
             fi
 
@@ -821,22 +859,23 @@ do
 
             if [ ! -f "$reference" ]
             then
-                echo " - no qualified output"
+                status="fail"
+                reason="no qualified output"
                 err=true
             else
                 if diff -w "$reference" $tmp.out >/dev/null 2>&1
                 then
-                    echo ""
-                    if $err
-                    then
-                        :
-                    else
-                        echo "$seq $(expr $stop - $start)" >>$tmp.time
+                    if ! $err; then
+                        status="pass"
+                        thistime=$(expr $stop - $start)
+                        echo "$seq $thistime" >>$tmp.time
                     fi
                 else
-                    echo " - output mismatch (see $seq.out.bad)"
                     mv $tmp.out $seq.out.bad
                     $diff -w "$reference" "$PWD"/$seq.out.bad
+                    status="fail"
+                    results="output mismatch (see $seq.out.bad)"
+                    printdiff=true
                     err=true
                 fi
             fi
@@ -850,13 +889,27 @@ do
 
     # come here for each test, except when $showme is true
     #
-    if $err
-    then
-        bad="$bad $seq"
-        n_bad=$(expr $n_bad + 1)
-        quick=false
-    fi
-    [ -f $seq.notrun ] || try=$(expr $try + 1)
+    _report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results"
+    case "$status" in
+        "pass")
+            try=$(expr $try + 1)
+            ;;
+        "fail")
+            try=$(expr $try + 1)
+            if $makecheck; then
+                _full_env_details
+            fi
+            if $printdiff; then
+                $diff -w "$reference" "$PWD"/$seq.out.bad
+            fi
+            bad="$bad $seq"
+            n_bad=$(expr $n_bad + 1)
+            quick=false
+            ;;
+        "not run")
+            notrun="$notrun $seq"
+            ;;
+    esac
 
     seq="after_$seq"
 done
Signature · 1 line
2.20.1
#41 lore raw

Re: [PATCH v2 27/28] tests/qemu-iotests: re-format output to for make check-block

Quoted 26 lines · Alex Bennée

This attempts to clean-up the output to better match the output of the rest of the QEMU check system when called with -makecheck. This includes:

- formatting as " TEST iotest-FMT: nnn"
- only dumping config on failure (when -makecheck enabled)

The non-make check output has been cleaned up as well:

- line re-displayed (\r) at the end
- fancy colours for pass/fail/skip
- timestamps always printed (option removed)

Message-Id: <[email protected]>

---
v3
- revert echo to printf
- add _report_test_start
v4
- -pretty -> -makecheck
- keep all output together for makecheck
v5
- merged in kwolf's pretty printing
- timestamps always printed in non-makecheck mode

Quoted 3 lines
---
 tests/qemu-iotests/check | 179 +++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 63 deletions(-)

Unless I missed something, this breaks ./check:

$ ./check -T -qcow2
000 - unknown test, ignored
QEMU          -- "build/x86_64-softmmu/qemu-system-x86_64" -nodefaults
-machine accel=qtest
QEMU_IMG      -- "build/qemu-img"
QEMU_IO       -- "build/qemu-io"  --cache writeback -f qcow2
QEMU_NBD      -- "build/qemu-nbd"
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 dresden 5.0.14-300.fc30.x86_64
TEST_DIR      -- build/tests/qemu-iotests/scratch
SOCKET_SCM_HELPER -- build/tests/qemu-iotests/socket_scm_helper

Passed all 0 tests

Max

#42 lore raw

Re: [PATCH v2 27/28] tests/qemu-iotests: re-format output to for make check-block

Quoted 31 lines · Max Reitz
Quoted 26 lines · Alex Bennée

This attempts to clean-up the output to better match the output of the rest of the QEMU check system when called with -makecheck. This includes:

- formatting as " TEST iotest-FMT: nnn"
- only dumping config on failure (when -makecheck enabled)

The non-make check output has been cleaned up as well:

- line re-displayed (\r) at the end
- fancy colours for pass/fail/skip
- timestamps always printed (option removed)

Message-Id: <[email protected]>

---
v3
- revert echo to printf
- add _report_test_start
v4
- -pretty -> -makecheck
- keep all output together for makecheck
v5
- merged in kwolf's pretty printing
- timestamps always printed in non-makecheck mode

Quoted 3 lines
---
 tests/qemu-iotests/check | 179 +++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 63 deletions(-)
Quoted 4 lines

Unless I missed something, this breaks ./check:

$ ./check -T -qcow2
000 - unknown test, ignored

Because -T has been dropped (timestamps are always shown). Of course removing from the opts passing falls through. Should I just do:

modified tests/qemu-iotests/check
@@ -433,6 +433,11 @@ testlist options

             cachemode=true
             xpand=false
             ;;
+        -T)
+            echo "-T no longer needed"
+            exit -1
+            ;;
+
         -v)
             verbose=true
Quoted 9 lines

QEMU -- "build/x86_64-softmmu/qemu-system-x86_64" -nodefaults
-machine accel=qtest

QEMU_IMG      -- "build/qemu-img"
QEMU_IO       -- "build/qemu-io"  --cache writeback -f qcow2
QEMU_NBD      -- "build/qemu-nbd"
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 dresden 5.0.14-300.fc30.x86_64
TEST_DIR      -- build/tests/qemu-iotests/scratch
Quoted 6 lines

SOCKET_SCM_HELPER -- build/tests/qemu-iotests/socket_scm_helper

Passed all 0 tests

Max

--
Alex Bennée

#43 lore raw

Re: [PATCH v2 27/28] tests/qemu-iotests: re-format output to for make check-block

Quoted 34 lines · Alex Bennée
Quoted 31 lines · Max Reitz
Quoted 29 lines · Alex Bennée

This attempts to clean-up the output to better match the output of the rest of the QEMU check system when called with -makecheck. This includes:

- formatting as " TEST iotest-FMT: nnn"
- only dumping config on failure (when -makecheck enabled)

The non-make check output has been cleaned up as well:

- line re-displayed (\r) at the end
- fancy colours for pass/fail/skip
- timestamps always printed (option removed)

Message-Id: <[email protected]>

---
v3
- revert echo to printf
- add _report_test_start
v4
- -pretty -> -makecheck
- keep all output together for makecheck
v5
- merged in kwolf's pretty printing
- timestamps always printed in non-makecheck mode

---
 tests/qemu-iotests/check | 179 +++++++++++++++++++++++++--------------
 1 file changed, 116 insertions(+), 63 deletions(-)
Quoted 7 lines
Quoted 4 lines

Unless I missed something, this breaks ./check:

$ ./check -T -qcow2
000 - unknown test, ignored

Because -T has been dropped (timestamps are always shown). Of course removing from the opts passing falls through. Should I just do:

Ah, OK.

tests/qemu-iotests/check testlist options · line 442

Quoted 12 lines

modified tests/qemu-iotests/check

tests/qemu-iotests/check +5 -0
@@ -433,6 +433,11 @@ testlist options
             cachemode=true
             xpand=false
             ;;
+        -T)
+            echo "-T no longer needed"
+            exit -1
+            ;;
+
         -v)
             verbose=true

Hm, why not just ignore it?

Max

#44 lore raw

PATCH v2 28/28 tests: Run the iotests during "make check" again

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

People often forget to run the iotests before submitting patches or pull requests - this is likely due to the fact that we do not run the tests during our mandatory "make check" tests yet. Now that we've got a proper "auto" group of iotests that should be fine to run in every environment, we can enable the iotests during "make check" again by running the "auto" tests by default from the check-block.sh script.

Some cases still need to be checked first, though: iotests need bash and GNU sed (otherwise they fail), and if gprof is enabled, it spoils the output of some test cases causing them to fail. So if we detect that one of the required programs is missing or that gprof is enabled, we still have to skip the iotests to avoid failures.

And finally, since we are using check-block.sh now again, this patch also removes the qemu-iotests-quick.sh script since we do not need that anymore (and having two shell wrapper scripts around the block tests seem rather confusing than helpful).

Message-Id: <[email protected]>

[AJB: -makecheck to check-block.sh, move check-block to start&gate it]
---
 tests/Makefile.include      |  8 +++----
 tests/check-block.sh        | 44 ++++++++++++++++++++++++++++---------
 tests/qemu-iotests-quick.sh |  8 -------
 3 files changed, 38 insertions(+), 22 deletions(-)
 delete mode 100755 tests/qemu-iotests-quick.sh
tests/Makefile.include +4 -4
index 1865f6b3222..0c6d8c75941 100644
@@ -140,7 +140,7 @@ check-unit-y += tests/test-uuid$(EXESUF)
 check-unit-y += tests/ptimer-test$(EXESUF)
 check-unit-y += tests/test-qapi-util$(EXESUF)
 
-check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
+check-block-$(call land,$(CONFIG_POSIX),$(CONFIG_SOFTMMU)) += tests/check-block.sh
 
 # All QTests for now are POSIX-only, but the dependencies are
 # really in libqtest, not in the testcases themselves.
@@ -1077,8 +1077,8 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 
 QEMU_IOTESTS_HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
 
-.PHONY: check-tests/qemu-iotests-quick.sh
-check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
+.PHONY: check-tests/check-block.sh
+check-tests/check-block.sh: tests/check-block.sh qemu-img$(EXESUF) qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
 	$<
 
 .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
@@ -1152,7 +1152,7 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR)
 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y)) check-tests/qapi-schema/doc-good.texi
 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
 check-block: $(patsubst %,check-%, $(check-block-y))
-check: check-qapi-schema check-unit check-softfloat check-qtest check-decodetree
+check: check-block check-qapi-schema check-unit check-softfloat check-qtest check-decodetree
 check-clean:
 	rm -rf $(check-unit-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
 	rm -rf $(sort $(foreach target,$(SYSEMU_TARGET_LIST), $(check-qtest-$(target)-y)) $(check-qtest-generic-y))
tests/check-block.sh +34 -10

58 lines not on this page · raw message

tests/qemu-iotests-quick.sh deleted +0 -8
deleted file mode 100755
index 0e554bb9724..00000000000
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-cd tests/qemu-iotests
-
-ret=0
-TEST_DIR=${TEST_DIR:-/tmp/qemu-iotests-quick-$$} ./check -T -qcow2 -g quick || ret=1
-
-exit $ret
Signature · 1 line
2.20.1