Skip to contentSkip to conversation

target-arm queue

GIT PULL Applied Peter Maydell 2 participants 11 messages Jun 16, 2025 – Jun 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi; small pullreq with mostly just minor bug fixes in it this week.

thanks
-- PMM

The following changes since commit d9ce74873a6a5a7c504379857461e4ae64fcf0cd:

Merge tag 'pull-vfio-20250611' of https://github.com/legoater/qemu into staging (2025-06-11 11:39:53 -0400)

are available in the Git repository at:

https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20250616

for you to fetch changes up to 5ad2b1f443a96444cf3e7a2fbe17aae696201012:

linux-user/arm: Fix return value of SYS_cacheflush (2025-06-16 11:26:25 +0100)

----------------------------------------------------------------
target-arm queue:
* hw/arm/virt: Check bypass iommu is not set for iommu-map DT property
* tests/functional: Add a test for the realview-eb-mpcore machine
* qemu-options.hx: Fix reversed description of icount sleep behavior
* target/arm: Define raw write for PMU CLR registers
* docs/interop: convert qed_spec.txt to reStructuredText format
* hw/arm: make cpu targeted by arm_load_kernel the primary CPU.
* hw/intc/arm_gic: introduce a first-cpu-index property
* hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions
* linux-user/arm: Fix return value of SYS_cacheflush

----------------------------------------------------------------
Akihiko Odaki (1):
target/arm: Define raw write for PMU CLR registers

Clément Chigot (1):
hw/arm: make cpu targeted by arm_load_kernel the primary CPU.

Ethan Chen (1):
qemu-options.hx: Fix reversed description of icount sleep behavior

Frederic Konrad (1):
hw/intc/arm_gic: introduce a first-cpu-index property

J. Neuschäfer (1):
linux-user/arm: Fix return value of SYS_cacheflush

Peter Maydell (1):
hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions

Shameer Kolothum (1):
hw/arm/virt: Check bypass iommu is not set for iommu-map DT property

Souleymane Conte (1):
docs/interop: convert qed_spec.txt to reStructuredText format

Thomas Huth (1):
tests/functional: Add a test for the realview-eb-mpcore machine

 MAINTAINERS                           |   2 +
 docs/interop/index.rst                |   1 +
 docs/interop/qed_spec.rst             | 219 ++++++++++++++++++++++++++++++++++
 docs/interop/qed_spec.txt             | 138 ---------------------
 include/hw/arm/boot.h                 |   3 +
 include/hw/intc/arm_gic.h             |   3 +
 include/hw/intc/arm_gic_common.h      |   2 +
 hw/arm/boot.c                         |  15 ++-
 hw/arm/mps2.c                         |   4 +
 hw/arm/virt.c                         |  15 ++-
 hw/intc/arm_gic.c                     |   2 +-
 hw/intc/arm_gic_common.c              |   1 +
 linux-user/arm/cpu_loop.c             |   1 +
 target/arm/helper.c                   |  12 +-
 qemu-options.hx                       |   8 +-
 tests/functional/meson.build          |   1 +
 tests/functional/test_arm_realview.py |  47 ++++++++
 17 files changed, 312 insertions(+), 162 deletions(-)
 create mode 100644 docs/interop/qed_spec.rst
 delete mode 100644 docs/interop/qed_spec.txt
 create mode 100755 tests/functional/test_arm_realview.py
#1 lore raw

[PULL 5/9] docs/interop: convert qed_spec.txt to reStructuredText format

From: Souleymane Conte <[email protected]>

Convert the qed_spec.txt file to reStructuredText and include it in the manual.

Message-id: [email protected]

[PMM: adjusted position of doc in the table of contents;
bulked up commit message; added file to MAINTAINERS section for QED; made 'Consistency checking' a higher level section; fixed one preexisting grammar nit (s/by from/from/)]

---
 MAINTAINERS               |   1 +
 docs/interop/index.rst    |   1 +
 docs/interop/qed_spec.rst | 219 ++++++++++++++++++++++++++++++++++++++
 docs/interop/qed_spec.txt | 138 ------------------------
 4 files changed, 221 insertions(+), 138 deletions(-)
 create mode 100644 docs/interop/qed_spec.rst
 delete mode 100644 docs/interop/qed_spec.txt
MAINTAINERS +1 -0
index 84cfef835eb..94c40761278 100644
@@ -4117,6 +4117,7 @@ M: Stefan Hajnoczi <[email protected]>
 L: [email protected]
 S: Supported
 F: block/qed.c
+F: docs/interop/qed_spec.rst
 
 raw
 M: Kevin Wolf <[email protected]>
docs/interop/index.rst +1 -0
index 4b951ae4162..972f3e49ce9 100644
@@ -18,6 +18,7 @@ are useful for making QEMU interoperate with other software.
    parallels
    prl-xml
    qcow2
+   qed_spec
    pr-helper
    qmp-spec
    qemu-ga
docs/interop/qed_spec.rst new file +219 -0

219 lines not on this page · raw message

docs/interop/qed_spec.txt deleted +0 -138

138 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

[PULL 6/9] hw/arm: make cpu targeted by arm_load_kernel the primary CPU.

In reply to Peter Maydell

From: Clément Chigot <[email protected]>

Currently, arm booting processus assumes that the first_cpu is the CPU that will boot: arm_load_kernel is powering off all but the first_cpu; do_cpu_reset is setting the loader address only for this first_cpu.

For most of the boards, this isn't an issue as the kernel is loaded and booted on the first CPU anyway. However, for zynqmp, the option "boot-cpu" allows to choose any CPUs.

Create a new arm_boot_info entry primary_cpu recording which CPU will be boot first. This one is set when arm_boot_kernel is called.

Message-id: [email protected]

---
 include/hw/arm/boot.h |  3 +++
 hw/arm/boot.c         | 15 +++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)
include/hw/arm/boot.h +3 -0
index b12bf61ca81..a2e22bda8a5 100644
@@ -132,6 +132,9 @@ struct arm_boot_info {
     bool secure_board_setup;
 
     arm_endianness endianness;
+
+    /* CPU having load the kernel and that should be the first to boot.  */
+    ARMCPU *primary_cpu;
 };
 
 /**
hw/arm/boot.c +7 -8
index 79afb51b8a5..3c93d879857 100644
@@ -744,7 +744,7 @@ static void do_cpu_reset(void *opaque)
             } else {
                 if (arm_feature(env, ARM_FEATURE_EL3) &&
                     (info->secure_boot ||
-                     (info->secure_board_setup && cs == first_cpu))) {
+                     (info->secure_board_setup && cpu == info->primary_cpu))) {
                     /* Start this CPU in Secure SVC */
                     target_el = 3;
                 }
@@ -752,7 +752,7 @@ static void do_cpu_reset(void *opaque)
 
             arm_emulate_firmware_reset(cs, target_el);
 
-            if (cs == first_cpu) {
+            if (cpu == info->primary_cpu) {
                 AddressSpace *as = arm_boot_address_space(cpu, info);
 
                 cpu_set_pc(cs, info->loader_start);
@@ -1239,6 +1239,9 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info)
     info->dtb_filename = ms->dtb;
     info->dtb_limit = 0;
 
+    /* We assume the CPU passed as argument is the primary CPU.  */
+    info->primary_cpu = cpu;
+
     /* Load the kernel.  */
     if (!info->kernel_filename || info->firmware_loaded) {
         arm_setup_firmware_boot(cpu, info);
@@ -1288,12 +1291,8 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info)
 
             object_property_set_int(cpuobj, "psci-conduit", info->psci_conduit,
                                     &error_abort);
-            /*
-             * Secondary CPUs start in PSCI powered-down state. Like the
-             * code in do_cpu_reset(), we assume first_cpu is the primary
-             * CPU.
-             */
-            if (cs != first_cpu) {
+            /* Secondary CPUs start in PSCI powered-down state.  */
+            if (ARM_CPU(cs) != info->primary_cpu) {
                 object_property_set_bool(cpuobj, "start-powered-off", true,
                                          &error_abort);
             }
Signature · 1 line
2.43.0
#3 lore raw

[PULL 4/9] target/arm: Define raw write for PMU CLR registers

In reply to Peter Maydell

From: Akihiko Odaki <[email protected]>

Raw writes to PMCNTENCLR and PMCNTENCLR_EL0 incorrectly used their default write function, which clears written bits instead of writes the raw value.

PMINTENCLR and PMINTENCLR_EL1 are similar registers, but they instead had ARM_CP_NO_RAW. Commit 7a0e58fa6487 ("target-arm: Split NO_MIGRATE into ALIAS and NO_RAW") sugguests ARM_CP_ALIAS should be used instead of ARM_CP_NO_RAW in such a case:

Quoted 9 lines

We currently mark ARM coprocessor/system register definitions with the flag ARM_CP_NO_MIGRATE for two different reasons:
1) register is an alias on to state that's also visible via some other register, and that other register is the one responsible for migrating the state
2) register is not actually state at all (for instance the TLB or cache maintenance operation "registers") and it makes no sense to attempt to migrate it or otherwise access the raw state

Quoted 8 lines

This works fine for identifying which registers should be ignored when performing migration, but we also use the same functions for synchronizing system register state between QEMU and the kernel when using KVM. In this case we don't want to try to sync state into registers in category 2, but we do want to sync into registers in category 1, because the kernel might have picked a different one of the aliases as its choice for which one to expose for migration.

These registers fall in category 1 (ARM_CP_ALIAS), not category 2 (ARM_CP_NO_RAW).

ARM_CP_NO_RAW also has another undesired side effect that hides registers from GDB.

Properly set raw write functions and drop the ARM_CP_NO_RAW flag from PMINTENCLR and PMINTENCLR_EL1; this fixes GDB/KVM state synchronization of PMCNTENCLR and PMCNTENCLR_EL0, and exposes all these four registers to GDB.

It is not necessary to add ARM_CP_ALIAS to these registers because the flag is already set.

Message-id: [email protected]

---
 target/arm/helper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
target/arm/helper.c +6 -6
index 76312102879..889d3088079 100644
@@ -1904,7 +1904,7 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
       .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmcnten),
       .accessfn = pmreg_access,
       .fgt = FGT_PMCNTEN,
-      .writefn = pmcntenclr_write,
+      .writefn = pmcntenclr_write, .raw_writefn = raw_write,
       .type = ARM_CP_ALIAS | ARM_CP_IO },
     { .name = "PMCNTENCLR_EL0", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 12, .opc2 = 2,
@@ -1912,7 +1912,7 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
       .fgt = FGT_PMCNTEN,
       .type = ARM_CP_ALIAS | ARM_CP_IO,
       .fieldoffset = offsetof(CPUARMState, cp15.c9_pmcnten),
-      .writefn = pmcntenclr_write },
+      .writefn = pmcntenclr_write, .raw_writefn = raw_write },
     { .name = "PMOVSR", .cp = 15, .crn = 9, .crm = 12, .opc1 = 0, .opc2 = 3,
       .access = PL0_RW, .type = ARM_CP_IO,
       .fieldoffset = offsetoflow32(CPUARMState, cp15.c9_pmovsr),
@@ -2029,16 +2029,16 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
     { .name = "PMINTENCLR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 2,
       .access = PL1_RW, .accessfn = access_tpm,
       .fgt = FGT_PMINTEN,
-      .type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW,
+      .type = ARM_CP_ALIAS | ARM_CP_IO,
       .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten),
-      .writefn = pmintenclr_write, },
+      .writefn = pmintenclr_write, .raw_writefn = raw_write },
     { .name = "PMINTENCLR_EL1", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 2,
       .access = PL1_RW, .accessfn = access_tpm,
       .fgt = FGT_PMINTEN,
-      .type = ARM_CP_ALIAS | ARM_CP_IO | ARM_CP_NO_RAW,
+      .type = ARM_CP_ALIAS | ARM_CP_IO,
       .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten),
-      .writefn = pmintenclr_write },
+      .writefn = pmintenclr_write, .raw_writefn = raw_write },
     { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH,
       .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0,
       .access = PL1_R,
Signature · 1 line
2.43.0
#4 lore raw

[PULL 8/9] hw/arm/mps2: Configure the AN500 CPU with 16 MPU regions

In reply to Peter Maydell

The AN500 application note documents that it configures the Cortex-M7 CPU to have 16 MPU regions. We weren't doing this in our emulation, so the CPU had only the default 8 MPU regions. Set the mpu-ns-regions property to 16 for this board.

This bug doesn't affect any of the other board types we model in this source file, because they all use either the Cortex-M3 or Cortex-M4. Those CPUs do not have an RTL configurable number of MPU regions, and always provide 8 regions if the MPU is built in.

Message-id: [email protected]

---
 hw/arm/mps2.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/mps2.c +4 -0
index 58efb41e6db..bd378e360b0 100644
@@ -224,7 +224,11 @@ static void mps2_common_init(MachineState *machine)
     switch (mmc->fpga_type) {
     case FPGA_AN385:
     case FPGA_AN386:
+        qdev_prop_set_uint32(armv7m, "num-irq", 32);
+        break;
     case FPGA_AN500:
+        /* The AN500 configures its Cortex-M7 with 16 MPU regions */
+        qdev_prop_set_uint32(armv7m, "mpu-ns-regions", 16);
         qdev_prop_set_uint32(armv7m, "num-irq", 32);
         break;
     case FPGA_AN511:
Signature · 1 line
2.43.0
#5 lore raw

[PULL 9/9] linux-user/arm: Fix return value of SYS_cacheflush

In reply to Peter Maydell

From: J. Neuschäfer <[email protected]>

Although the emulated cacheflush syscall does nothing, it still needs to return zero to indicate success.

Message-id: [email protected]

---
 linux-user/arm/cpu_loop.c | 1 +
 1 file changed, 1 insertion(+)
linux-user/arm/cpu_loop.c +1 -0
index e8417d04069..33f63951a95 100644
@@ -363,6 +363,7 @@ void cpu_loop(CPUARMState *env)
                     switch (n) {
                     case ARM_NR_cacheflush:
                         /* nop */
+                        env->regs[0] = 0;
                         break;
                     case ARM_NR_set_tls:
                         cpu_set_tls(env, env->regs[0]);
Signature · 1 line
2.43.0
#6 lore raw

[PULL 2/9] tests/functional: Add a test for the realview-eb-mpcore machine

In reply to Peter Maydell

From: Thomas Huth <[email protected]>

Check that we can boot a Linux kernel here and that we can at least send one ping network packet.

Message-id: [email protected]

---
 MAINTAINERS                           |  1 +
 tests/functional/meson.build          |  1 +
 tests/functional/test_arm_realview.py | 47 +++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)
 create mode 100755 tests/functional/test_arm_realview.py
MAINTAINERS +1 -0
index 28b3dd2684b..84cfef835eb 100644
@@ -955,6 +955,7 @@ F: hw/cpu/realview_mpcore.c
 F: hw/intc/realview_gic.c
 F: include/hw/intc/realview_gic.h
 F: docs/system/arm/realview.rst
+F: tests/functional/test_arm_realview.py
 
 SABRELITE / i.MX6
 M: Peter Maydell <[email protected]>
tests/functional/meson.build +1 -0
index 7faa2b6e3c0..e7e051ef3c8 100644
@@ -135,6 +135,7 @@ tests_arm_system_thorough = [
   'arm_orangepi',
   'arm_quanta_gsj',
   'arm_raspi2',
+  'arm_realview',
   'arm_replay',
   'arm_smdkc210',
   'arm_stellaris',
tests/functional/test_arm_realview.py new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.43.0
#7 lore raw

[PULL 7/9] hw/intc/arm_gic: introduce a first-cpu-index property

In reply to Peter Maydell

From: Frederic Konrad <[email protected]>

This introduces a first-cpu-index property to the arm-gic, as some SOCs could have two separate GIC (ie: the zynqmp).

Message-id: [email protected]

[PMM: slightly expanded comment documenting GIC property]
---
 include/hw/intc/arm_gic.h        | 3 +++
 include/hw/intc/arm_gic_common.h | 2 ++
 hw/intc/arm_gic.c                | 2 +-
 hw/intc/arm_gic_common.c         | 1 +
 4 files changed, 7 insertions(+), 1 deletion(-)
include/hw/intc/arm_gic.h +3 -0
index 48f6a51a70a..be923f7ed88 100644
@@ -27,6 +27,9 @@
  *    implement the security extensions
  *  + QOM property "has-virtualization-extensions": set true if the GIC should
  *    implement the virtualization extensions
+ *  + QOM property "first-cpu-index": index of the first cpu attached to the
+ *    GIC (default 0). The CPUs connected to the GIC are assumed to be
+ *    first-cpu-index, first-cpu-index + 1, ... first-cpu-index + num-cpu - 1.
  *  + unnamed GPIO inputs: (where P is number of SPIs, i.e. num-irq - 32)
  *    [0..P-1]  SPIs
  *    [P..P+31] PPIs for CPU 0
include/hw/intc/arm_gic_common.h +2 -0
index 97fea4102d3..93a3cc2bf81 100644
@@ -129,6 +129,8 @@ struct GICState {
     uint32_t num_lrs;
 
     uint32_t num_cpu;
+    /* cpu_index of the first CPU, attached to this GIC.  */
+    uint32_t first_cpu_index;
 
     MemoryRegion iomem; /* Distributor */
     /* This is just so we can have an opaque pointer which identifies
hw/intc/arm_gic.c +1 -1
index d18bef40fcc..899f1333633 100644
@@ -59,7 +59,7 @@ static const uint8_t gic_id_gicv2[] = {
 static inline int gic_get_current_cpu(GICState *s)
 {
     if (!qtest_enabled() && s->num_cpu > 1) {
-        return current_cpu->cpu_index;
+        return current_cpu->cpu_index - s->first_cpu_index;
     }
     return 0;
 }
hw/intc/arm_gic_common.c +1 -0
index 0f0c48d89ab..ed5be056452 100644
@@ -350,6 +350,7 @@ static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,
 
 static const Property arm_gic_common_properties[] = {
     DEFINE_PROP_UINT32("num-cpu", GICState, num_cpu, 1),
+    DEFINE_PROP_UINT32("first-cpu-index", GICState, first_cpu_index, 0),
     DEFINE_PROP_UINT32("num-irq", GICState, num_irq, 32),
     /* Revision can be 1 or 2 for GIC architecture specification
      * versions 1 or 2, or 0 to indicate the legacy 11MPCore GIC.
Signature · 1 line
2.43.0
#8 lore raw

[PULL 1/9] hw/arm/virt: Check bypass iommu is not set for iommu-map DT property

In reply to Peter Maydell

From: Shameer Kolothum <[email protected]>

default_bus_bypass_iommu tells us whether the bypass_iommu is set for the default PCIe root bus. Make sure we check that before adding the "iommu-map" DT property.

Fixes 6d7a85483a06 ("hw/arm/virt: Add default_bus_bypass_iommu machine option")

Message-id: [email protected]

---
 hw/arm/virt.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
hw/arm/virt.c +10 -5
index 9a6cd085a37..99fde5836c9 100644
@@ -1487,9 +1487,12 @@ static void create_virtio_iommu_dt_bindings(VirtMachineState *vms)
     qemu_fdt_setprop_cell(ms->fdt, node, "phandle", vms->iommu_phandle);
     g_free(node);
 
-    qemu_fdt_setprop_cells(ms->fdt, vms->pciehb_nodename, "iommu-map",
-                           0x0, vms->iommu_phandle, 0x0, bdf,
-                           bdf + 1, vms->iommu_phandle, bdf + 1, 0xffff - bdf);
+    if (!vms->default_bus_bypass_iommu) {
+        qemu_fdt_setprop_cells(ms->fdt, vms->pciehb_nodename, "iommu-map",
+                               0x0, vms->iommu_phandle, 0x0, bdf,
+                               bdf + 1, vms->iommu_phandle, bdf + 1,
+                               0xffff - bdf);
+    }
 }
 
 static void create_pcie(VirtMachineState *vms)
@@ -1612,8 +1615,10 @@ static void create_pcie(VirtMachineState *vms)
         switch (vms->iommu) {
         case VIRT_IOMMU_SMMUV3:
             create_smmu(vms, vms->bus);
-            qemu_fdt_setprop_cells(ms->fdt, nodename, "iommu-map",
-                                   0x0, vms->iommu_phandle, 0x0, 0x10000);
+            if (!vms->default_bus_bypass_iommu) {
+                qemu_fdt_setprop_cells(ms->fdt, nodename, "iommu-map",
+                                       0x0, vms->iommu_phandle, 0x0, 0x10000);
+            }
             break;
         default:
             g_assert_not_reached();
Signature · 1 line
2.43.0
#9 lore raw

[PULL 3/9] qemu-options.hx: Fix reversed description of icount sleep behavior

In reply to Peter Maydell

From: Ethan Chen <[email protected]>

The documentation for the -icount option incorrectly describes the behavior of the sleep suboption. Based on the actual implementation and system behavior, the effects of sleep=on and sleep=off were inadvertently reversed. This commit updates the description to reflect their intended functionality.

Fixes fa647905e6ba ("qemu-options.hx: Fix minor issues in icount documentation")

Message-id: [email protected]

---
 qemu-options.hx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
qemu-options.hx +4 -4
index 7eb8e02b4b9..1f862b19a67 100644
@@ -4936,13 +4936,13 @@ SRST
     with actual performance.
 
     When the virtual cpu is sleeping, the virtual time will advance at
-    default speed unless ``sleep=on`` is specified. With
-    ``sleep=on``, the virtual time will jump to the next timer
+    default speed unless ``sleep=off`` is specified. With
+    ``sleep=off``, the virtual time will jump to the next timer
     deadline instantly whenever the virtual cpu goes to sleep mode and
     will not advance if no timer is enabled. This behavior gives
     deterministic execution times from the guest point of view.
-    The default if icount is enabled is ``sleep=off``.
-    ``sleep=on`` cannot be used together with either ``shift=auto``
+    The default if icount is enabled is ``sleep=on``.
+    ``sleep=off`` cannot be used together with either ``shift=auto``
     or ``align=on``.
 
     ``align=on`` will activate the delay algorithm which will try to
Signature · 1 line
2.43.0