Skip to contentSkip to conversation

testing fixes and semihosting console support

GIT PULL Applied Alex Bennée 3 participants 18 messages Jan 9, 2020 – Jan 24, 2020

lore
Share & tools
lore
#0 lore raw

The following changes since commit 035eed4c0d257c905a556fa0f4865a0c077b4e7f:

Merge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' into staging (2020-01-07 17:08:21 +0000)

are available in the Git repository at:

https://github.com/stsquad/qemu.git tags/pull-testing-and-semihosting-090120-2

for you to fetch changes up to 486e58b188c1b093a8f64d4b5cd11ff5c3514cb2:

tests/tcg: add user version of dumb-as-bricks semiconsole test (2020-01-09 11:41:29 +0000)

----------------------------------------------------------------
Testing fixes and semiconsole support:

- build fix (missing x86-iommu stubs)
- python fixes for freebsd and OSX
- nicer reporting of acceptance failures
- fix build nesting of fp-test (breaks bsds)
- semihosting clean-ups
- support for blocking semihosting console

----------------------------------------------------------------
Alex Bennée (8):
travis.yml: duplicate before_script for MacOSX travis.yml: install homebrew python for OS X
testing: don't nest build for fp-test
target/arm: remove unused EXCP_SEMIHOST leg target/arm: only update pc after semihosting completes tests/tcg: add a dumb-as-bricks semihosting console test tests/tcg: extract __semi_call into a header and expand tests/tcg: add user version of dumb-as-bricks semiconsole test

Gerd Hoffmann (2):
tests/vm: update openbsd to release 6.6
freebsd: use python37

Keith Packard (1):
semihosting: add qemu_semihosting_console_inc for SYS_READC

Philippe Mathieu-Daudé (1):
hw/i386/x86-iommu: Add missing stubs

Wainer dos Santos Moschetta (2):
travis.yml: avocado: Print logs of non-pass tests only travis.yml: Detach build and test steps

 include/hw/semihosting/console.h          | 16 +++++++
 include/hw/semihosting/semihost.h         |  4 ++
 tests/tcg/arm/semicall.h                  | 35 ++++++++++++++
 hw/i386/x86-iommu-stub.c                  |  9 ++++
 hw/semihosting/console.c                  | 79 +++++++++++++++++++++++++++++++
 linux-user/aarch64/cpu_loop.c             |  1 +
 linux-user/arm/cpu_loop.c                 |  1 +
 linux-user/arm/semihost.c                 | 27 +++++++++++
 stubs/semihost.c                          |  4 ++
 target/arm/arm-semi.c                     |  3 +-
 target/arm/helper.c                       |  8 +---
 target/arm/m_helper.c                     |  1 +
 target/arm/translate-a64.c                |  2 +-
 target/arm/translate.c                    |  6 +--
 tests/tcg/aarch64/system/semiconsole.c    | 38 +++++++++++++++
 tests/tcg/arm/semiconsole.c               | 27 +++++++++++
 tests/tcg/arm/semihosting.c               | 21 +-------
 vl.c                                      |  3 ++
 .travis.yml                               | 30 +++++++-----
 tests/Makefile.include                    |  2 +-
 tests/fp/Makefile                         | 14 +++---
 tests/tcg/aarch64/Makefile.softmmu-target | 11 ++++-
 tests/tcg/aarch64/Makefile.target         |  7 +++
 tests/tcg/arm/Makefile.target             | 28 +++++++++++
 tests/vm/freebsd                          |  3 +-
 tests/vm/openbsd                          |  4 +-
 26 files changed, 328 insertions(+), 56 deletions(-)
 create mode 100644 tests/tcg/arm/semicall.h
 create mode 100644 tests/tcg/aarch64/system/semiconsole.c
 create mode 100644 tests/tcg/arm/semiconsole.c
Signature · 1 line
2.20.1
#1 lore raw

[PULL v2 09/14] target/arm: remove unused EXCP_SEMIHOST leg

All semihosting exceptions are dealt with earlier in the common code so we should never get here.

target/arm/helper.c +0 -6
index b6bec42f48e..da22c198006 100644
@@ -8566,12 +8566,6 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
     case EXCP_VFIQ:
         addr += 0x100;
         break;
-    case EXCP_SEMIHOST:
-        qemu_log_mask(CPU_LOG_INT,
-                      "...handling as semihosting call 0x%" PRIx64 "\n",
-                      env->xregs[0]);
-        env->xregs[0] = do_arm_semihosting(env);
-        return;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }
Signature · 1 line
2.20.1
#2 lore raw

[PULL v2 10/14] target/arm: only update pc after semihosting completes

In reply to Alex Bennée

Before we introduce blocking semihosting calls we need to ensure we can restart the system on semi hosting exception. To be able to do this the EXCP_SEMIHOST operation should be idempotent until it finally completes. Practically this means ensureing we only update the pc after the semihosting call has completed.

linux-user/aarch64/cpu_loop.c +1 -0
index 31c845a70d4..bbe9fefca81 100644
@@ -130,6 +130,7 @@ void cpu_loop(CPUARMState *env)
             break;
         case EXCP_SEMIHOST:
             env->xregs[0] = do_arm_semihosting(env);
+            env->pc += 4;
             break;
         case EXCP_YIELD:
             /* nothing to do here for user-mode, just resume guest code */
linux-user/arm/cpu_loop.c +1 -0
index 7be40717518..1fae90c6dfc 100644
@@ -377,6 +377,7 @@ void cpu_loop(CPUARMState *env)
             break;
         case EXCP_SEMIHOST:
             env->regs[0] = do_arm_semihosting(env);
+            env->regs[15] += env->thumb ? 2 : 4;
             break;
         case EXCP_INTERRUPT:
             /* just indicate that signals should be handled asap */
target/arm/helper.c +2 -0
index da22c198006..19a57a17da5 100644
@@ -8614,11 +8614,13 @@ static void handle_semihosting(CPUState *cs)
                       "...handling as semihosting call 0x%" PRIx64 "\n",
                       env->xregs[0]);
         env->xregs[0] = do_arm_semihosting(env);
+        env->pc += 4;
     } else {
         qemu_log_mask(CPU_LOG_INT,
                       "...handling as semihosting call 0x%x\n",
                       env->regs[0]);
         env->regs[0] = do_arm_semihosting(env);
+        env->regs[15] += env->thumb ? 2 : 4;
     }
 }
 #endif
target/arm/m_helper.c +1 -0
index 76de317e6af..33d414a684b 100644
@@ -2185,6 +2185,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
                       "...handling as semihosting call 0x%x\n",
                       env->regs[0]);
         env->regs[0] = do_arm_semihosting(env);
+        env->regs[15] += env->thumb ? 2 : 4;
         return;
     case EXCP_BKPT:
         armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
target/arm/translate-a64.c +1 -1
index d4bebbe6295..972c28c3c95 100644
@@ -1937,7 +1937,7 @@ static void disas_exc(DisasContext *s, uint32_t insn)
                 break;
             }
 #endif
-            gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST);
+            gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST);
         } else {
             unsupported_encoding(s, insn);
         }
target/arm/translate.c +3 -3
index 2b6c1f91bf9..5185e08641b 100644
@@ -1124,7 +1124,7 @@ static inline void gen_hlt(DisasContext *s, int imm)
         s->current_el != 0 &&
 #endif
         (imm == (s->thumb ? 0x3c : 0xf000))) {
-        gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST);
+        gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST);
         return;
     }
 
@@ -8457,7 +8457,7 @@ static bool trans_BKPT(DisasContext *s, arg_BKPT *a)
         !IS_USER(s) &&
 #endif
         (a->imm == 0xab)) {
-        gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST);
+        gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST);
     } else {
         gen_exception_bkpt_insn(s, syn_aa32_bkpt(a->imm, false));
     }
@@ -10266,7 +10266,7 @@ static bool trans_SVC(DisasContext *s, arg_SVC *a)
         !IS_USER(s) &&
 #endif
         (a->imm == semihost_imm)) {
-        gen_exception_internal_insn(s, s->base.pc_next, EXCP_SEMIHOST);
+        gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST);
     } else {
         gen_set_pc_im(s, s->base.pc_next);
         s->svc_imm = a->imm;
Signature · 1 line
2.20.1
#3 lore raw

[PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC

In reply to Alex Bennée

From: Keith Packard <[email protected]>

Provides a blocking call to read a character from the console using semihosting.chardev, if specified. This takes some careful command line options to use stdio successfully as the serial ports, monitor and semihost all want to use stdio. Here's a sample set of command line options which share stdio between semihost, monitor and serial ports:

	qemu \
	-chardev stdio,mux=on,id=stdio0 \
	-serial chardev:stdio0 \
	-semihosting-config enable=on,chardev=stdio0 \
	-mon chardev=stdio0,mode=readline

This creates a chardev hooked to stdio and then connects all of the subsystems to it. A shorter mechanism would be good to hear about.

Message-Id: <[email protected]>

[AJB: fixed up deadlock, minor commit title reword]
Cc Paolo Bonzini <[email protected]>
include/hw/semihosting/console.h +16 -0
index 9be9754bcdf..0238f540f4b 100644
@@ -37,6 +37,22 @@ int qemu_semihosting_console_outs(CPUArchState *env, target_ulong s);
  */
 void qemu_semihosting_console_outc(CPUArchState *env, target_ulong c);
 
+/**
+ * qemu_semihosting_console_inc:
+ * @env: CPUArchState
+ *
+ * Receive single character from debug console. This may be the remote
+ * gdb session if a softmmu guest is currently being debugged. As this
+ * call may block if no data is available we suspend the CPU and will
+ * re-execute the instruction when data is there. Therefore two
+ * conditions must be met:
+ *   - CPUState is synchronized before calling this function
+ *   - pc is only updated once the character is successfully returned
+ *
+ * Returns: character read OR cpu_loop_exit!
+ */
+target_ulong qemu_semihosting_console_inc(CPUArchState *env);
+
 /**
  * qemu_semihosting_log_out:
  * @s: pointer to string
include/hw/semihosting/semihost.h +4 -0
index 60fc42d851e..b8ce5117ae0 100644
@@ -56,6 +56,9 @@ static inline Chardev *semihosting_get_chardev(void)
 {
     return NULL;
 }
+static inline void qemu_semihosting_console_init(void)
+{
+}
 #else /* !CONFIG_USER_ONLY */
 bool semihosting_enabled(void);
 SemihostingTarget semihosting_get_target(void);
@@ -68,6 +71,7 @@ Chardev *semihosting_get_chardev(void);
 void qemu_semihosting_enable(void);
 int qemu_semihosting_config_options(const char *opt);
 void qemu_semihosting_connect_chardevs(void);
+void qemu_semihosting_console_init(void);
 #endif /* CONFIG_USER_ONLY */
 
 #endif /* SEMIHOST_H */
hw/semihosting/console.c +79 -0

90 lines not on this page · raw message

linux-user/arm/semihost.c +27 -0
index a16b525eec0..a1f0f6050ea 100644
@@ -14,6 +14,7 @@
 #include "cpu.h"
 #include "hw/semihosting/console.h"
 #include "qemu.h"
+#include <termios.h>
 
 int qemu_semihosting_console_outs(CPUArchState *env, target_ulong addr)
 {
@@ -47,3 +48,29 @@ void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr)
         }
     }
 }
+
+/*
+ * For linux-user we can safely block. However as we want to return as
+ * soon as a character is read we need to tweak the termio to disable
+ * line buffering. We restore the old mode afterwards in case the
+ * program is expecting more normal behaviour. This is slow but
+ * nothing using semihosting console reading is expecting to be fast.
+ */
+target_ulong qemu_semihosting_console_inc(CPUArchState *env)
+{
+    uint8_t c;
+    struct termios old_tio, new_tio;
+
+    /* Disable line-buffering and echo */
+    tcgetattr(STDIN_FILENO, &old_tio);
+    new_tio = old_tio;
+    new_tio.c_lflag &= (~ICANON & ~ECHO);
+    tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
+
+    c = getchar();
+
+    /* restore config */
+    tcsetattr(STDIN_FILENO, TCSANOW, &old_tio);
+
+    return (target_ulong) c;
+}
stubs/semihost.c +4 -0
index f90589259c0..1d8b37f7b2f 100644
@@ -69,3 +69,7 @@ void semihosting_arg_fallback(const char *file, const char *cmd)
 void qemu_semihosting_connect_chardevs(void)
 {
 }
+
+void qemu_semihosting_console_init(void)
+{
+}
target/arm/arm-semi.c +1 -2
index 6f7b6d801bf..47d61f6fe1f 100644
@@ -802,8 +802,7 @@ target_ulong do_arm_semihosting(CPUARMState *env)
 
         return guestfd_fns[gf->type].readfn(cpu, gf, arg1, len);
     case TARGET_SYS_READC:
-        qemu_log_mask(LOG_UNIMP, "%s: SYS_READC not implemented", __func__);
-        return 0;
+        return qemu_semihosting_console_inc(env);
     case TARGET_SYS_ISTTY:
         GET_ARG(0);
 
vl.c +3 -0
index 86474a55c9e..b2119212587 100644
@@ -4238,6 +4238,9 @@ int main(int argc, char **argv, char **envp)
     qemu_opts_foreach(qemu_find_opts("mon"),
                       mon_init_func, NULL, &error_fatal);
 
+    /* connect semihosting console input if requested */
+    qemu_semihosting_console_init();
+
     if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
         exit(1);
     if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
Signature · 1 line
2.20.1
#4 lore raw

Re: [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC

Quoted 9 lines · Alex Bennée

From: Keith Packard <[email protected]>

Provides a blocking call to read a character from the console using semihosting.chardev, if specified. This takes some careful command line options to use stdio successfully as the serial ports, monitor and semihost all want to use stdio. Here's a sample set of command line options which share stdio between semihost, monitor and serial ports:

Hi; Coverity has some complaints about this code, and specifically the use of getchar():

Quoted 9 lines
linux-user/arm/semihost.c +9 -0
+/*
+ * For linux-user we can safely block. However as we want to return as
+ * soon as a character is read we need to tweak the termio to disable
+ * line buffering. We restore the old mode afterwards in case the
+ * program is expecting more normal behaviour. This is slow but
+ * nothing using semihosting console reading is expecting to be fast.
+ */
+target_ulong qemu_semihosting_console_inc(CPUArchState *env)
+{

linux-user/arm/semihost.c void qemu_semihosting_console_outc(CPUArchState *env, target_ulong addr) · line 70

Quoted 10 lines
linux-user/arm/semihost.c +10 -0
+    uint8_t c;
+    struct termios old_tio, new_tio;
+
+    /* Disable line-buffering and echo */
+    tcgetattr(STDIN_FILENO, &old_tio);
+    new_tio = old_tio;
+    new_tio.c_lflag &= (~ICANON & ~ECHO);
+    tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
+
+    c = getchar();

CID 1412794 points out that this assigns the result of getchar() to a uint8_t, which drops the distinction between EOF and a legitimate byte.
CID 1412795 is then kind of a run-on error from that, complaining that the int result from getchar() is truncated before returning it.

I'm not sure what we should do with EOF, but presumably we should handle it in some way.

thanks
-- PMM

#5 lore raw

Re: [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC

Quoted 2 lines · Peter Maydell

I'm not sure what we should do with EOF, but presumably we should handle it in some way.

There's no correct answer here, which is why the current implementation just ignores it. Here are a couple of options:

1. Just return whatever getchar() provides; if it returns EOF, we'll pass that on to the application. Semihost-aware applications may learn about this 'special' value.

2. Return some ASCII control code (0x04?) in an attempt to tell the application what has happened.

3. Block forever. This would at least keep the application from spinning.

Signature · 1 line
-keith
#6 lore raw

[PULL v2 13/14] tests/tcg: extract __semi_call into a header and expand

In reply to Alex Bennée

There are two types of ARM semicall - lets test them both. Putting the logic in a header will make re-using the functions easier later.

tests/tcg/arm/semicall.h new file +35 -0
new file mode 100644
index 00000000000..d4f6818192d
@@ -0,0 +1,35 @@
+/*
+ * Semihosting Tests
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#define SYS_WRITE0      0x04
+#define SYS_READC       0x07
+#define SYS_REPORTEXC   0x18
+
+uintptr_t __semi_call(uintptr_t type, uintptr_t arg0)
+{
+#if defined(__arm__)
+    register uintptr_t t asm("r0") = type;
+    register uintptr_t a0 asm("r1") = arg0;
+#ifdef __thumb__
+#  define SVC  "svc 0xab"
+#else
+#  define SVC  "svc 0x123456"
+#endif
+    asm(SVC : "=r" (t)
+        : "r" (t), "r" (a0));
+#else
+    register uintptr_t t asm("x0") = type;
+    register uintptr_t a0 asm("x1") = arg0;
+    asm("hlt 0xf000"
+        : "=r" (t)
+        : "r" (t), "r" (a0));
+#endif
+
+    return t;
+}
tests/tcg/arm/semihosting.c +1 -20
index 09c89cb481a..33faac9916e 100644
@@ -8,26 +8,7 @@
  */
 
 #include <stdint.h>
-
-#define SYS_WRITE0      0x04
-#define SYS_REPORTEXC   0x18
-
-void __semi_call(uintptr_t type, uintptr_t arg0)
-{
-#if defined(__arm__)
-    register uintptr_t t asm("r0") = type;
-    register uintptr_t a0 asm("r1") = arg0;
-    asm("svc 0xab"
-        : /* no return */
-        : "r" (t), "r" (a0));
-#else
-    register uintptr_t t asm("x0") = type;
-    register uintptr_t a0 asm("x1") = arg0;
-    asm("hlt 0xf000"
-        : /* no return */
-        : "r" (t), "r" (a0));
-#endif
-}
+#include "semicall.h"
 
 int main(int argc, char *argv[argc])
 {
tests/tcg/arm/Makefile.target +9 -0
index 0765f37ff04..41aa26f4e17 100644
@@ -31,9 +31,18 @@ run-fcvt: fcvt
 
 # Semihosting smoke test for linux-user
 ARM_TESTS += semihosting
+semihosting: CFLAGS += -mthumb
 run-semihosting: semihosting
 	$(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)")
 
+ARM_TESTS += semihosting-arm
+semihosting-arm: CFLAGS += -marm
+semihosting-arm: semihosting.c
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+
+run-semihosting-arm: semihosting-arm
+	$(call run-test,$<,$(QEMU) $< 2> $<.err, "$< on $(TARGET_NAME)")
+
 run-plugin-semihosting-with-%:
 	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
 		-plugin $(PLUGIN_DIR)/$(call extract-plugin,$@) \
Signature · 1 line
2.20.1
#7 lore raw

[PULL v2 14/14] tests/tcg: add user version of dumb-as-bricks semiconsole test

In reply to Alex Bennée

There are linux-user users of semihosting so we'd better check things work for them as well.

tests/tcg/arm/semiconsole.c new file +27 -0
new file mode 100644
index 00000000000..6ef0bd24500
@@ -0,0 +1,27 @@
+/*
+ * linux-user semihosting console
+ *
+ * Copyright (c) 2019
+ * Written by Alex Bennée <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include "semicall.h"
+
+int main(void)
+{
+    char c;
+
+    printf("Semihosting Console Test\n");
+    printf("hit X to exit:");
+
+    do {
+        c = __semi_call(SYS_READC, 0);
+        printf("got '%c'\n", c);
+    } while (c != 'X');
+
+    return 0;
+}
tests/tcg/aarch64/Makefile.target +7 -0
index 96d2321045a..df3fe8032c3 100644
@@ -32,4 +32,11 @@ run-plugin-semihosting-with-%:
 		 $(call strip-plugin,$<) 2> $<.err, \
 		"$< on $(TARGET_NAME) with $*")
 
+AARCH64_TESTS += semiconsole
+run-semiconsole: semiconsole
+	$(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-with-%:
+	$(call skip-test, $<, "MANUAL ONLY")
+
 TESTS += $(AARCH64_TESTS)
tests/tcg/arm/Makefile.target +19 -0
index 41aa26f4e17..11c39c601ea 100644
@@ -49,6 +49,25 @@ run-plugin-semihosting-with-%:
 		 $(call strip-plugin,$<) 2> $<.err, \
 		"$< on $(TARGET_NAME) with $*")
 
+ARM_TESTS += semiconsole semiconsole-arm
+
+semiconsole: CFLAGS += -mthumb
+run-semiconsole: semiconsole
+	$(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-with-%:
+	$(call skip-test, $<, "MANUAL ONLY")
+
+semiconsole-arm: CFLAGS += -marm
+semiconsole-arm: semiconsole.c
+	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+
+run-semiconsole-arm: semiconsole-arm
+	$(call skip-test, $<, "MANUAL ONLY")
+
+run-plugin-semiconsole-arm-with-%:
+	$(call skip-test, $<, "MANUAL ONLY")
+
 TESTS += $(ARM_TESTS)
 
 # On ARM Linux only supports 4k pages
Signature · 1 line
2.20.1
#8 lore raw

[PULL v2 02/14] tests/vm: update openbsd to release 6.6

In reply to Alex Bennée

From: Gerd Hoffmann <[email protected]>

Message-Id: <[email protected]>

tests/vm/openbsd +2 -2
index 6df5162dbf4..d6173506f78 100755
@@ -22,8 +22,8 @@ class OpenBSDVM(basevm.BaseVM):
     name = "openbsd"
     arch = "x86_64"
 
-    link = "https://cdn.openbsd.org/pub/OpenBSD/6.5/amd64/install65.iso"
-    csum = "38d1f8cadd502f1c27bf05c5abde6cc505dd28f3f34f8a941048ff9a54f9f608"
+    link = "https://cdn.openbsd.org/pub/OpenBSD/6.6/amd64/install66.iso"
+    csum = "b22e63df56e6266de6bbeed8e9be0fbe9ee2291551c5bc03f3cc2e4ab9436ee3"
     size = "20G"
     pkgs = [
         # tools
Signature · 1 line
2.20.1
#9 lore raw

[PULL v2 01/14] hw/i386/x86-iommu: Add missing stubs

In reply to Alex Bennée

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

In commit 6c730e4af9 we introduced a stub to build the MicroVM machine without Intel IOMMU. This stub is incomplete for the other PC machines. Add the missing stubs.

Message-Id: <[email protected]>

hw/i386/x86-iommu-stub.c +9 -0
index 03576cdccb4..c5ba077f9d1 100644
@@ -32,3 +32,12 @@ X86IOMMUState *x86_iommu_get_default(void)
     return NULL;
 }
 
+bool x86_iommu_ir_supported(X86IOMMUState *s)
+{
+    return false;
+}
+
+IommuType x86_iommu_get_type(void)
+{
+    abort();
+}
Signature · 1 line
2.20.1
#10 lore raw

[PULL v2 03/14] freebsd: use python37

In reply to Alex Bennée

From: Gerd Hoffmann <[email protected]>

FreeBSD seems to use python37 by default now, which breaks the build script. Add python to the package list, to explicitly pick the version, and also adapt the configure command line.

Message-Id: <[email protected]>

tests/vm/freebsd +2 -1
index 1825cc58218..33a736298a9 100755
@@ -32,6 +32,7 @@ class FreeBSDVM(basevm.BaseVM):
         "git",
         "pkgconf",
         "bzip2",
+        "python37",
 
         # gnu tools
         "bash",
@@ -63,7 +64,7 @@ class FreeBSDVM(basevm.BaseVM):
         mkdir src build; cd src;
         tar -xf /dev/vtbd1;
         cd ../build
-        ../src/configure --python=python3.6 {configure_opts};
+        ../src/configure --python=python3.7 {configure_opts};
         gmake --output-sync -j{jobs} {target} {verbose};
     """
 
Signature · 1 line
2.20.1
#11 lore raw

[PULL v2 04/14] travis.yml: avocado: Print logs of non-pass tests only

In reply to Alex Bennée

From: Wainer dos Santos Moschetta <[email protected]>

The acceptance tests build on Travis is configured to print the entire Avocado's job log in case any test fail. Usually one is interested on failed tests only though. So this change the Travis configuration in order to show the log of tests which status is different from 'PASS' and 'SKIP' only. Note that 'CANCEL'-ed tests will have the log printed too because it can help to debug some condition on CI environment which is not being fulfilled.

Message-Id: <[email protected]>

.travis.yml +2 -2
index 638fba4799a..93838bf0f8b 100644
@@ -262,8 +262,8 @@ matrix:
     - env:
         - CONFIG="--python=/usr/bin/python3 --target-list=x86_64-softmmu,mips-softmmu,mips64el-softmmu,aarch64-softmmu,arm-softmmu,s390x-softmmu,alpha-softmmu,ppc-softmmu,ppc64-softmmu,m68k-softmmu,sparc-softmmu"
         - TEST_CMD="make check-acceptance"
-      after_failure:
-        - cat tests/results/latest/job.log
+      after_script:
+        - python3 -c 'import json; r = json.load(open("tests/results/latest/results.json")); [print(t["logfile"]) for t in r["tests"] if t["status"] not in ("PASS", "SKIP")]' | xargs cat
       addons:
         apt:
           packages:
Signature · 1 line
2.20.1
#12 lore raw

[PULL v2 08/14] testing: don't nest build for fp-test

In reply to Alex Bennée

Re-calling the main make is counter-productive and really messes up with parallel builds. Just ensure we have built the pre-requisites before we build the fp-test bits. If the user builds manually just complain if the parent build hasn't got the bits we need.

tests/Makefile.include +1 -1
index 49e3b0d3194..7a767bf1148 100644
@@ -969,7 +969,7 @@ FP_TEST_BIN=$(BUILD_DIR)/tests/fp/fp-test
 
 # the build dir is created by configure
 .PHONY: $(FP_TEST_BIN)
-$(FP_TEST_BIN):
+$(FP_TEST_BIN): config-host.h $(test-util-obj-y)
 	$(call quiet-command, \
 	 	$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" $(notdir $@), \
 	         "BUILD", "$(notdir $@)")
tests/fp/Makefile +6 -8
index 5a35e7c2109..56768ecfd2f 100644
@@ -554,15 +554,13 @@ TF_OBJS_LIB += $(TF_OBJS_TEST)
 
 BINARIES := fp-test$(EXESUF) fp-bench$(EXESUF)
 
-# everything depends on config-host.h because platform.h includes it
-all: $(BUILD_DIR)/config-host.h
-	$(MAKE) $(BINARIES)
+# We require artefacts from the main build including config-host.h
+# because platform.h includes it. Rather than re-invoking the main
+# build we just error out if things aren't there.
+$(LIBQEMUUTIL) $(BUILD_DIR)/config-host.h:
+	$(error $@ missing, re-run parent build)
 
-$(LIBQEMUUTIL):
-	$(MAKE) -C $(BUILD_DIR) libqemuutil.a
-
-$(BUILD_DIR)/config-host.h:
-	$(MAKE) -C $(BUILD_DIR) config-host.h
+all: $(BUILD_DIR)/config-host.h $(BINARIES)
 
 # libtestfloat.a depends on libsoftfloat.a, so specify it first
 FP_TEST_LIBS := libtestfloat.a libsoftfloat.a $(LIBQEMUUTIL)
Signature · 1 line
2.20.1
#13 lore raw

[PULL v2 06/14] travis.yml: duplicate before_script for MacOSX

In reply to Alex Bennée

Rather than keep the hack in the global code lets "Think Different" and have a special copy for MacOSX.

.travis.yml +5 -1
index 848a2714efe..6826618ea81 100644
@@ -89,7 +89,6 @@ git:
 
 
 before_script:
-  - if [ "$TRAVIS_OS_NAME" == "osx" ] ; then export PATH="/usr/local/opt/ccache/libexec:$PATH" ; fi
   - if command -v ccache ; then ccache --zero-stats ; fi
   - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
   - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
@@ -240,6 +239,11 @@ matrix:
       os: osx
       osx_image: xcode10.3
       compiler: clang
+      before_script:
+        - export PATH="/usr/local/opt/ccache/libexec:$PATH"
+        - if command -v ccache ; then ccache --zero-stats ; fi
+        - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
+        - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
 
 
     # Python builds
Signature · 1 line
2.20.1
#14 lore raw

[PULL v2 07/14] travis.yml: install homebrew python for OS X

In reply to Alex Bennée

Our python3 requirements now outstrip those of the build. While we are at it we can move more of the special casing for Mac into the one build we have.

.travis.yml +10 -7
index 6826618ea81..6c1038a0f1a 100644
@@ -51,13 +51,6 @@ addons:
       - sparse
       - uuid-dev
       - gcovr
-  homebrew:
-    packages:
-      - ccache
-      - glib
-      - pixman
-      - gnu-sed
-    update: true
 
 
 # The channel name "irc.oftc.net#qemu" is encrypted against qemu/qemu
@@ -239,7 +232,17 @@ matrix:
       os: osx
       osx_image: xcode10.3
       compiler: clang
+      addons:
+        homebrew:
+          packages:
+            - ccache
+            - glib
+            - pixman
+            - gnu-sed
+            - python
+          update: true
       before_script:
+        - brew link --overwrite python
         - export PATH="/usr/local/opt/ccache/libexec:$PATH"
         - if command -v ccache ; then ccache --zero-stats ; fi
         - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
Signature · 1 line
2.20.1
#15 lore raw

[PULL v2 05/14] travis.yml: Detach build and test steps

In reply to Alex Bennée

From: Wainer dos Santos Moschetta <[email protected]>

Currently build and test commands are a single step in a Travis's script block. In order to see the output of the tests one needs to scroll down the log to find where the build messages ended and the limit is not clear. If they were in different steps then Travis would print the result build command, which can be easily grep'ed.

So this change is made to detach those commands
to ease the visualization of the output.

Note that all steps on the script block is executed regardless if one previous has failed. To overcome it, let's save the return code of the build then check whether succeed or failed on the test step.

Message-Id: <[email protected]>

.travis.yml +2 -1
index 93838bf0f8b..848a2714efe 100644
@@ -94,7 +94,8 @@ before_script:
   - mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
   - ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
 script:
-  - make -j3 && travis_retry ${TEST_CMD}
+  - BUILD_RC=0 && make -j3 || BUILD_RC=$?
+  - if [ "$BUILD_RC" -eq 0 ] ; then travis_retry ${TEST_CMD} ; else $(exit $BUILD_RC); fi
 after_script:
   - if command -v ccache ; then ccache --show-stats ; fi
 
Signature · 1 line
2.20.1
#16 lore raw

[PULL v2 12/14] tests/tcg: add a dumb-as-bricks semihosting console test

In reply to Alex Bennée

We don't run this during check-tcg as we would need to check stuff is echoed back. However we can still build the binary so people can test it manually.

tests/tcg/aarch64/system/semiconsole.c new file +38 -0
new file mode 100644
index 00000000000..bfe7c9e26b4
@@ -0,0 +1,38 @@
+/*
+ * Semihosting Console Test
+ *
+ * Copyright (c) 2019 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <inttypes.h>
+#include <minilib.h>
+
+#define SYS_READC 0x7
+
+uintptr_t __semi_call(uintptr_t type, uintptr_t arg0)
+{
+    register uintptr_t t asm("x0") = type;
+    register uintptr_t a0 asm("x1") = arg0;
+    asm("hlt 0xf000"
+        : "=r" (t)
+        : "r" (t), "r" (a0));
+
+    return t;
+}
+
+int main(void)
+{
+    char c;
+
+    ml_printf("Semihosting Console Test\n");
+    ml_printf("hit X to exit:");
+
+    do {
+        c = __semi_call(SYS_READC, 0);
+        __sys_outc(c);
+    } while (c != 'X');
+
+    return 0;
+}
tests/tcg/aarch64/Makefile.softmmu-target +10 -1
index 950dbb4bac2..7b4eede3f07 100644
@@ -31,7 +31,16 @@ LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
 memory: CFLAGS+=-DCHECK_UNALIGNED=1
 
 # Running
-QEMU_OPTS+=-M virt -cpu max -display none -semihosting-config enable=on,target=native,chardev=output -kernel
+QEMU_BASE_MACHINE=-M virt -cpu max -display none
+QEMU_OPTS+=$(QEMU_BASE_MACHINE) -semihosting-config enable=on,target=native,chardev=output -kernel
+
+# console test is manual only
+QEMU_SEMIHOST=-chardev stdio,mux=on,id=stdio0 -semihosting-config enable=on,chardev=stdio0 -mon chardev=stdio0,mode=readline
+run-semiconsole: QEMU_OPTS=$(QEMU_BASE_MACHINE) $(QEMU_SEMIHOST)  -kernel
+run-semiconsole: semiconsole
+	$(call skip-test, $<, "MANUAL ONLY")
+run-plugin-semiconsole-with-%: semiconsole
+	$(call skip-test, $<, "MANUAL ONLY")
 
 # Simple Record/Replay Test
 .PHONY: memory-record
Signature · 1 line
2.20.1
#17 lore raw
In reply to Alex Bennée
Quoted 16 lines · Alex Bennée

The following changes since commit 035eed4c0d257c905a556fa0f4865a0c077b4e7f:

Merge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' into staging (2020-01-07 17:08:21 +0000)

are available in the Git repository at:

https://github.com/stsquad/qemu.git tags/pull-testing-and-semihosting-090120-2

for you to fetch changes up to 486e58b188c1b093a8f64d4b5cd11ff5c3514cb2:

tests/tcg: add user version of dumb-as-bricks semiconsole test (2020-01-09 11:41:29 +0000)

----------------------------------------------------------------
Testing fixes and semiconsole support:

Quoted 7 lines

- build fix (missing x86-iommu stubs)
- python fixes for freebsd and OSX
- nicer reporting of acceptance failures
- fix build nesting of fp-test (breaks bsds)
- semihosting clean-ups
- support for blocking semihosting console

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.

-- PMM