Skip to contentSkip to conversation

qtest: Remove uses of 'first_cpu'

PATCH In review Philippe Mathieu-Daudé 4 participants 10 messages Dec 11, 2024 – Jan 7, 2025

lore
Share & tools
lore
#0 lore raw

v2 cover qtest: Remove uses of 'first_cpu'

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
system/qtest: Remove uses of 'first_cpu'
qtest/fuzz: Remove uses of 'first_cpu'

 system/qtest.c                    | 53 ++++++++++++++++---------------
 tests/qtest/fuzz/generic_fuzz.c   |  3 +-
 tests/qtest/fuzz/qtest_wrappers.c | 53 ++++++++++++++++---------------
 3 files changed, 56 insertions(+), 53 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 1/2 system/qtest: Remove uses of 'first_cpu'

There is no vCPU within the QTest accelerator (well, they are stubs doing nothing, see dummy_cpu_thread_fn).

Directly access the global &address_space_memory to reduce access to the 'first_cpu' global (which is meaningless in a heterogeneous emulation setup).

Cast the returned value to (void) to explicit we don't care about invalid accesses.

---
We will likely remove &address_space_memory too, but one global at a time. first_cpu is more annoying so I'm starting with it.

---
 system/qtest.c | 53 +++++++++++++++++++++++++-------------------------
 1 file changed, 27 insertions(+), 26 deletions(-)
system/qtest.c +27 -26
index 12703a20455..cc26dd75bef 100644
@@ -16,6 +16,7 @@
 #include "sysemu/qtest.h"
 #include "sysemu/runstate.h"
 #include "chardev/char-fe.h"
+#include "exec/address-spaces.h"
 #include "exec/ioport.h"
 #include "exec/memory.h"
 #include "exec/tswap.h"
@@ -514,23 +515,23 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
 
         if (words[0][5] == 'b') {
             uint8_t data = value;
-            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                                &data, 1);
+            (void)address_space_write(&address_space_memory, addr,
+                                      MEMTXATTRS_UNSPECIFIED, &data, 1);
         } else if (words[0][5] == 'w') {
             uint16_t data = value;
             tswap16s(&data);
-            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                                &data, 2);
+            (void)address_space_write(&address_space_memory, addr,
+                                      MEMTXATTRS_UNSPECIFIED, &data, 2);
         } else if (words[0][5] == 'l') {
             uint32_t data = value;
             tswap32s(&data);
-            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                                &data, 4);
+            (void)address_space_write(&address_space_memory, addr,
+                                      MEMTXATTRS_UNSPECIFIED, &data, 4);
         } else if (words[0][5] == 'q') {
             uint64_t data = value;
             tswap64s(&data);
-            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                                &data, 8);
+            (void)address_space_write(&address_space_memory, addr,
+                                      MEMTXATTRS_UNSPECIFIED, &data, 8);
         }
         qtest_send_prefix(chr);
         qtest_send(chr, "OK\n");
@@ -548,22 +549,22 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
 
         if (words[0][4] == 'b') {
             uint8_t data;
-            address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                               &data, 1);
+            (void)address_space_read(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &data, 1);
             value = data;
         } else if (words[0][4] == 'w') {
             uint16_t data;
-            address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                               &data, 2);
+            (void)address_space_read(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &data, 2);
             value = tswap16(data);
         } else if (words[0][4] == 'l') {
             uint32_t data;
-            address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                               &data, 4);
+            (void)address_space_read(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &data, 4);
             value = tswap32(data);
         } else if (words[0][4] == 'q') {
-            address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                               &value, 8);
+            (void)address_space_read(&address_space_memory, addr,
+                                     MEMTXATTRS_UNSPECIFIED, &value, 8);
             tswap64s(&value);
         }
         qtest_send_prefix(chr);
@@ -583,8 +584,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         g_assert(len);
 
         data = g_malloc(len);
-        address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                           len);
+        (void)address_space_read(&address_space_memory, addr,
+                                 MEMTXATTRS_UNSPECIFIED, data, len);
 
         enc = qemu_hexdump_line(NULL, data, len, 0, 0);
 
@@ -605,8 +606,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         g_assert(ret == 0);
 
         data = g_malloc(len);
-        address_space_read(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                           len);
+        (void)address_space_read(&address_space_memory, addr,
+                                 MEMTXATTRS_UNSPECIFIED, data, len);
         b64_data = g_base64_encode(data, len);
         qtest_send_prefix(chr);
         qtest_sendf(chr, "OK %s\n", b64_data);
@@ -640,8 +641,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
                 data[i] = 0;
             }
         }
-        address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                            len);
+        (void)address_space_write(&address_space_memory, addr,
+                                  MEMTXATTRS_UNSPECIFIED, data, len);
         g_free(data);
 
         qtest_send_prefix(chr);
@@ -663,8 +664,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
         if (len) {
             data = g_malloc(len);
             memset(data, pattern, len);
-            address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED,
-                                data, len);
+            (void)address_space_write(&address_space_memory, addr,
+                                      MEMTXATTRS_UNSPECIFIED, data, len);
             g_free(data);
         }
 
@@ -697,8 +698,8 @@ static void qtest_process_command(CharBackend *chr, gchar **words)
             out_len = MIN(out_len, len);
         }
 
-        address_space_write(first_cpu->as, addr, MEMTXATTRS_UNSPECIFIED, data,
-                            len);
+        (void)address_space_write(&address_space_memory, addr,
+                                  MEMTXATTRS_UNSPECIFIED, data, len);
 
         qtest_send_prefix(chr);
         qtest_send(chr, "OK\n");
Signature · 1 line
2.45.2
#2 lore raw

PATCH v2 2/2 qtest/fuzz: Remove uses of 'first_cpu'

In reply to Philippe Mathieu-Daudé

There is no vCPU within the QTest accelerator (well, they are stubs doing nothing, see dummy_cpu_thread_fn).

Directly access the global &address_space_memory to reduce access to the 'first_cpu' global (which is meaningless in a heterogeneous emulation setup).

Cast the returned value to (void) to explicit we don't care about invalid accesses.

---
We will likely remove &address_space_memory too, but one global at a time. first_cpu is more annoying so I'm starting with it.

---
 tests/qtest/fuzz/generic_fuzz.c   |  3 +-
 tests/qtest/fuzz/qtest_wrappers.c | 53 ++++++++++++++++---------------
 2 files changed, 29 insertions(+), 27 deletions(-)
tests/qtest/fuzz/generic_fuzz.c +2 -1
index d107a496da6..a72a3e99f7d 100644
@@ -20,6 +20,7 @@
 #include "tests/qtest/libqos/pci-pc.h"
 #include "fuzz.h"
 #include "string.h"
+#include "exec/address-spaces.h"
 #include "exec/memory.h"
 #include "exec/ramblock.h"
 #include "hw/qdev-core.h"
@@ -239,7 +240,7 @@ void fuzz_dma_read_cb(size_t addr, size_t len, MemoryRegion *mr)
     MemoryRegion *mr1;
     while (len > 0) {
         l = len;
-        mr1 = address_space_translate(first_cpu->as,
+        mr1 = address_space_translate(&address_space_memory,
                                       addr, &addr1, &l, true,
                                       MEMTXATTRS_UNSPECIFIED);
 
tests/qtest/fuzz/qtest_wrappers.c +27 -26

137 lines not on this page · raw message

Signature · 1 line
2.45.2
Reviewed-by on the v2 series
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
system/qtest: Remove uses of 'first_cpu'
qtest/fuzz: Remove uses of 'first_cpu'

  system/qtest.c                    | 53 ++++++++++++++++---------------
  tests/qtest/fuzz/generic_fuzz.c   |  3 +-
  tests/qtest/fuzz/qtest_wrappers.c | 53 ++++++++++++++++---------------
  3 files changed, 56 insertions(+), 53 deletions(-)

r~

#4 lore raw
In reply to Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 10 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
system/qtest: Remove uses of 'first_cpu'
qtest/fuzz: Remove uses of 'first_cpu'

  system/qtest.c                    | 53 ++++++++++++++++---------------
  tests/qtest/fuzz/generic_fuzz.c   |  3 +-
  tests/qtest/fuzz/qtest_wrappers.c | 53 ++++++++++++++++---------------
  3 files changed, 56 insertions(+), 53 deletions(-)

Ping :)

Tell me if you prefer I merge these patch myself.

Regards,

Phil.

#5 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 6 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
system/qtest: Remove uses of 'first_cpu'
qtest/fuzz: Remove uses of 'first_cpu'

Quoted 6 lines
Quoted 4 lines
  system/qtest.c                    | 53 ++++++++++++++++---------------
  tests/qtest/fuzz/generic_fuzz.c   |  3 +-
  tests/qtest/fuzz/qtest_wrappers.c | 53 ++++++++++++++++---------------
  3 files changed, 56 insertions(+), 53 deletions(-)

Ping :)

Hi!

Good that you pinged, I thought you were looking into the test failures from v1. I copied you in this other thread that mentioned them as well:

https://lore.kernel.org/r/[email protected]

Applying this series on top of master just now:

Summary of Failures:

 10/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_usart-test               ERROR            1.40s   exit status 1
165/519 qemu:qtest+qtest-arm / qtest-arm/sse-timer-test                     ERROR            0.40s   killed by signal 6 SIGABRT
185/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_exti-test                ERROR            0.19s   exit status 1
187/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_rcc-test                 ERROR            0.19s   exit status 1
515/519 qemu:qtest+qtest-arm / qtest-arm/microbit-test                      TIMEOUT         60.01s   killed by signal 15 SIGTERM
Quoted 6 lines

Tell me if you prefer I merge these patch myself.

Regards,

Phil.

#6 lore raw
Quoted 22 lines · Fabiano Rosas
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 5 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
system/qtest: Remove uses of 'first_cpu'
qtest/fuzz: Remove uses of 'first_cpu'

Ping :)

Hi!

Good that you pinged, I thought you were looking into the test failures from v1. I copied you in this other thread that mentioned them as well:

https://lore.kernel.org/r/[email protected]

Applying this series on top of master just now:

Quoted 7 lines

Summary of Failures:

10/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_usart-test ERROR 1.40s exit status 1

165/519 qemu:qtest+qtest-arm / qtest-arm/sse-timer-test                     ERROR            0.40s   killed by signal 6 SIGABRT
185/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_exti-test                ERROR            0.19s   exit status 1
187/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_rcc-test                 ERROR            0.19s   exit status 1
515/519 qemu:qtest+qtest-arm / qtest-arm/microbit-test                      TIMEOUT         60.01s   killed by signal 15 SIGTERM

Hmm interesting, I have a "quick-before-posting-series" set of tests, and a "full-before-posting-pullreq" one. The quick is quite extensive, but only include Aarch64. I thought, since it contains the ARM targets, they would also be tested, but no...

All these tests use ARM Cortex-M cores, which have a particularity, the ARM cores are tied to architectural specific HW (NVIC). We model cores in target/arm/cpu, and HW part in hw/intc/armv7m_nvic.c.

NVIC is only 'visible' from vCPU address space, not the "main sysbus".

See this flatview diff of tcg/qtest:

@@ -1,11 +1,12 @@
FlatView #1
- AS "cpu-memory-0", root: armv7m-container
+ AS "memory", root: system
- Root memory region: armv7m-container
+ Root memory region: system 0000000000000000-00000000000fffff (prio 0, rom): flash 0000000008000000-00000000080fffff (prio 0, rom): flash 0000000010000000-0000000010007fff (prio 0, ram): SRAM2 0000000020000000-0000000020017fff (prio 0, ram): SRAM1
- 0000000022000000-0000000023ffffff (prio 0, i/o): bitband 0000000040000000-00000000400003ff (prio -1000, i/o): TIM2 0000000040000400-00000000400007ff (prio -1000, i/o): TIM3 0000000040000800-0000000040000bff (prio -1000, i/o): TIM4
@@ -52,7 +53,6 @@
0000000040022000-00000000400223ff (prio -1000, i/o): FLASH 0000000040023000-00000000400233ff (prio -1000, i/o): CRC 0000000040024000-00000000400243ff (prio -1000, i/o): TSC
- 0000000042000000-0000000043ffffff (prio 0, i/o): bitband 0000000048000000-00000000480003ff (prio 0, i/o): stm32l4x5-gpio 0000000048000400-00000000480007ff (prio 0, i/o): stm32l4x5-gpio 0000000048000800-0000000048000bff (prio 0, i/o): stm32l4x5-gpio
@@ -66,9 +66,4 @@
0000000050060800-0000000050060bff (prio -1000, i/o): RNG 00000000a0000000-00000000a0000fff (prio -1000, i/o): FMC 00000000a0001000-00000000a00013ff (prio -1000, i/o): QUADSPI

-  00000000e0000000-00000000e000dfff (prio -1, i/o): nvic-default
-  00000000e000e000-00000000e000e00f (prio 0, i/o): nvic_sysregs
-  00000000e000e010-00000000e000e0ef (prio 1, i/o): v7m_systick
-  00000000e000e0f0-00000000e000efff (prio 0, i/o): nvic_sysregs @00000000000000f0
-  00000000e000f000-00000000e00fffff (prio -1, i/o): nvic-default @000000000000f000

So under qtest with no vcpu, the nvic is not accessible without specifying a non-global address space.

And qtests access NVIC, see this function:

    #define NVIC_ISPR1 0XE000E204
    #define NVIC_ICPR1 0xE000E284
    #define USART1_IRQ 37

    static bool check_nvic_pending(QTestState *qts, unsigned int n)
    {
        /* No USART interrupts are less than 32 */
        assert(n > 32);
        n -= 32;
        return qtest_readl(qts, NVIC_ISPR1) & (1 << n);
    }

I tend to think the current situation works by luck, and this series is yet another example of sysbus abuses.

I'll give it some thoughts. Maybe we can discuss it at the next community call.

Regards,

Phil.

#7 lore raw
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Fabiano Rosas
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 5 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
    system/qtest: Remove uses of 'first_cpu'
    qtest/fuzz: Remove uses of 'first_cpu'

Ping :)

Hi!

Good that you pinged, I thought you were looking into the test failures from v1. I copied you in this other thread that mentioned them as well:

https://lore.kernel.org/r/[email protected]

Applying this series on top of master just now:

Quoted 7 lines

Summary of Failures:

  10/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_usart- test               ERROR            1.40s   exit status 1 165/519 qemu:qtest+qtest-arm / qtest-arm/sse-timer- test                     ERROR            0.40s   killed by signal 6 SIGABRT 185/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_exti- test                ERROR            0.19s   exit status 1 187/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_rcc- test                 ERROR            0.19s   exit status 1 515/519 qemu:qtest+qtest-arm / qtest-arm/microbit- test                      TIMEOUT         60.01s   killed by signal 15 SIGTERM

Quoted 5 lines

Hmm interesting, I have a "quick-before-posting-series" set of tests, and a "full-before-posting-pullreq" one. The quick is quite extensive, but only include Aarch64. I thought, since it contains the ARM targets, they would also be tested, but no...

IIRC this was a deliberate decision once in the past to avoid double testing: qtests_aarch64 in tests/qtest/meson.build does not include qtest_arm, it's a separate set of tests indeed.

IMHO it's a little bit unfortunate, since in a couple of spots in the CI, we are taking the shortcut of only adding aarch64-softmmu to the target list, but not arm-softmmu.

Maybe we should add some logic to tests/qtest/meson.build so that if arm-softmmu is not in target_dirs, we add the tests to qtests_aarch64 ?

Thomas

#8 lore raw
Quoted 38 lines · Thomas Huth
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Fabiano Rosas
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 5 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
    system/qtest: Remove uses of 'first_cpu'
    qtest/fuzz: Remove uses of 'first_cpu'

Ping :)

Hi!

Good that you pinged, I thought you were looking into the test failures from v1. I copied you in this other thread that mentioned them as well:

https://lore.kernel.org/r/[email protected]

Applying this series on top of master just now:

Quoted 7 lines

Summary of Failures:

  10/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_usart- test               ERROR            1.40s   exit status 1 165/519 qemu:qtest+qtest-arm / qtest-arm/sse-timer- test                     ERROR            0.40s   killed by signal 6 SIGABRT 185/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_exti- test                ERROR            0.19s   exit status 1 187/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_rcc- test                 ERROR            0.19s   exit status 1 515/519 qemu:qtest+qtest-arm / qtest-arm/microbit- test                      TIMEOUT         60.01s   killed by signal 15 SIGTERM

Quoted 5 lines

Hmm interesting, I have a "quick-before-posting-series" set of tests, and a "full-before-posting-pullreq" one. The quick is quite extensive, but only include Aarch64. I thought, since it contains the ARM targets, they would also be tested, but no...

Quoted 5 lines

IIRC this was a deliberate decision once in the past to avoid double testing: qtests_aarch64 in tests/qtest/meson.build does not include qtest_arm, it's a separate set of tests indeed.

IMHO it's a little bit unfortunate, since in a couple of spots in the CI, we are taking the shortcut of only adding aarch64-softmmu to the target list, but not arm-softmmu.

Maybe we should add some logic to tests/qtest/meson.build so that if arm-softmmu is not in target_dirs, we add the tests to qtests_aarch64 ?

I'm working in unifying both targets. With that in mind, optimizing CI coverage doesn't seem a good use of our time IMHO, because once I get there the CI will also be unified.

#9 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 96 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Fabiano Rosas
Quoted 10 lines · Philippe Mathieu-Daudé

Hi Fabiano,

Quoted 5 lines · Philippe Mathieu-Daudé

Replace first_cpu->as by address_space_memory.

Philippe Mathieu-Daudé (2):
    system/qtest: Remove uses of 'first_cpu'
    qtest/fuzz: Remove uses of 'first_cpu'

Ping :)

Hi!

Good that you pinged, I thought you were looking into the test failures from v1. I copied you in this other thread that mentioned them as well:

https://lore.kernel.org/r/[email protected]

Applying this series on top of master just now:

Quoted 7 lines

Summary of Failures:

  10/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_usart- test               ERROR            1.40s   exit status 1 165/519 qemu:qtest+qtest-arm / qtest-arm/sse-timer- test                     ERROR            0.40s   killed by signal 6 SIGABRT 185/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_exti- test                ERROR            0.19s   exit status 1 187/519 qemu:qtest+qtest-arm / qtest-arm/stm32l4x5_rcc- test                 ERROR            0.19s   exit status 1 515/519 qemu:qtest+qtest-arm / qtest-arm/microbit- test                      TIMEOUT         60.01s   killed by signal 15 SIGTERM

Hmm interesting, I have a "quick-before-posting-series" set of tests, and a "full-before-posting-pullreq" one. The quick is quite extensive, but only include Aarch64. I thought, since it contains the ARM targets, they would also be tested, but no...

All these tests use ARM Cortex-M cores, which have a particularity, the ARM cores are tied to architectural specific HW (NVIC). We model cores in target/arm/cpu, and HW part in hw/intc/armv7m_nvic.c.

NVIC is only 'visible' from vCPU address space, not the "main sysbus".

See this flatview diff of tcg/qtest:

(quoted diff) +2 -8
@@ -1,11 +1,12 @@
  FlatView #1
- AS "cpu-memory-0", root: armv7m-container
+ AS "memory", root: system
- Root memory region: armv7m-container
+ Root memory region: system
    0000000000000000-00000000000fffff (prio 0, rom): flash
    0000000008000000-00000000080fffff (prio 0, rom): flash
    0000000010000000-0000000010007fff (prio 0, ram): SRAM2
    0000000020000000-0000000020017fff (prio 0, ram): SRAM1
-  0000000022000000-0000000023ffffff (prio 0, i/o): bitband
    0000000040000000-00000000400003ff (prio -1000, i/o): TIM2
    0000000040000400-00000000400007ff (prio -1000, i/o): TIM3
    0000000040000800-0000000040000bff (prio -1000, i/o): TIM4
@@ -52,7 +53,6 @@
    0000000040022000-00000000400223ff (prio -1000, i/o): FLASH
    0000000040023000-00000000400233ff (prio -1000, i/o): CRC
    0000000040024000-00000000400243ff (prio -1000, i/o): TSC
-  0000000042000000-0000000043ffffff (prio 0, i/o): bitband
    0000000048000000-00000000480003ff (prio 0, i/o): stm32l4x5-gpio
    0000000048000400-00000000480007ff (prio 0, i/o): stm32l4x5-gpio
    0000000048000800-0000000048000bff (prio 0, i/o): stm32l4x5-gpio
@@ -66,9 +66,4 @@
    0000000050060800-0000000050060bff (prio -1000, i/o): RNG
    00000000a0000000-00000000a0000fff (prio -1000, i/o): FMC
    00000000a0001000-00000000a00013ff (prio -1000, i/o): QUADSPI
-  00000000e0000000-00000000e000dfff (prio -1, i/o): nvic-default
-  00000000e000e000-00000000e000e00f (prio 0, i/o): nvic_sysregs
-  00000000e000e010-00000000e000e0ef (prio 1, i/o): v7m_systick
-  00000000e000e0f0-00000000e000efff (prio 0, i/o): nvic_sysregs 

@00000000000000f0
-  00000000e000f000-00000000e00fffff (prio -1, i/o): nvic-default @000000000000f000

So under qtest with no vcpu, the nvic is not accessible without specifying a non-global address space.

And qtests access NVIC, see this function:

    #define NVIC_ISPR1 0XE000E204
    #define NVIC_ICPR1 0xE000E284
    #define USART1_IRQ 37

    static bool check_nvic_pending(QTestState *qts, unsigned int n) {
        /* No USART interrupts are less than 32 */ assert(n > 32);
        n -= 32;
        return qtest_readl(qts, NVIC_ISPR1) & (1 << n); }

Quoted 5 lines

I tend to think the current situation works by luck, and this series is yet another example of sysbus abuses.

I'll give it some thoughts. Maybe we can discuss it at the next community call.

Tentative fix after today's community call:
https://lore.kernel.org/qemu-devel/[email protected]/