Skip to contentSkip to conversation

target-arm queue

GIT PULL Applied Peter Maydell 5 participants 38 messages Nov 2, 2018 – Jan 30, 2022 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

This is a respin of my pull request from earlier this week:
* versal board compile failure fixed
* a few new patches:
- MAINTAINERS file fix
- use ARRAY_SIZE macro in xilinx_zynq
- avoid an array overrun in strongarm GPIO irq handling
- fix an assert running KVM on an aarch64-only host

The following changes since commit 69e2d03843412b9c076515b3aa9a71db161b6a1a:

Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-sf1' into staging (2018-11-02 13:16:13 +0000)

are available in the Git repository at:

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

for you to fetch changes up to 6f16da53ffe4567c0353f85055df04860eb4e6fc:

hw/arm: versal: Add a virtual Xilinx Versal board (2018-11-02 14:11:31 +0000)

----------------------------------------------------------------
target-arm queue:
* microbit: Add the UART to our nRF51 SoC model
* Add a virtual Xilinx Versal board "xlnx-versal-virt"
* hw/arm/virt: Set VIRT_COMPAT_3_0 compat
* MAINTAINERS: Remove bouncing email in ARM ACPI
* strongarm: mask off high[31:28] bits from dir and state registers
* target/arm: Conditionalize some asserts on aarch32 support
* hw/arm/xilinx_zynq: Use the ARRAY_SIZE macro

----------------------------------------------------------------
Edgar E. Iglesias (2):
hw/arm: versal: Add a model of Xilinx Versal SoC hw/arm: versal: Add a virtual Xilinx Versal board

Eric Auger (1):
hw/arm/virt: Set VIRT_COMPAT_3_0 compat

Julia Suvorova (3):
hw/char: Implement nRF51 SoC UART hw/arm/nrf51_soc: Connect UART to nRF51 SoC tests/boot-serial-test: Add microbit board testcase

Philippe Mathieu-Daudé (2):
MAINTAINERS: Remove bouncing email in ARM ACPI hw/arm/xilinx_zynq: Use the ARRAY_SIZE macro

Prasad J Pandit (1):
strongarm: mask off high[31:28] bits from dir and state registers

Richard Henderson (1):
target/arm: Conditionalize some asserts on aarch32 support

 hw/arm/Makefile.objs                |   1 +
 hw/char/Makefile.objs               |   1 +
 include/hw/arm/nrf51_soc.h          |   3 +
 include/hw/arm/xlnx-versal.h        | 122 +++++++++
 include/hw/char/nrf51_uart.h        |  78 ++++++
 target/arm/cpu.h                    |   5 +
 hw/arm/microbit.c                   |   2 +
 hw/arm/nrf51_soc.c                  |  20 ++
 hw/arm/strongarm.c                  |   4 +-
 hw/arm/virt.c                       |   4 +
 hw/arm/xilinx_zynq.c                |   2 +-
 hw/arm/xlnx-versal-virt.c           | 494 ++++++++++++++++++++++++++++++++++++
 hw/arm/xlnx-versal.c                | 323 +++++++++++++++++++++++
 hw/char/nrf51_uart.c                | 330 ++++++++++++++++++++++++
 target/arm/cpu.c                    |  15 +-
 tests/boot-serial-test.c            |  19 ++
 MAINTAINERS                         |   1 -
 default-configs/aarch64-softmmu.mak |   1 +
 hw/char/trace-events                |   4 +
 19 files changed, 1423 insertions(+), 6 deletions(-)
 create mode 100644 include/hw/arm/xlnx-versal.h
 create mode 100644 include/hw/char/nrf51_uart.h
 create mode 100644 hw/arm/xlnx-versal-virt.c
 create mode 100644 hw/arm/xlnx-versal.c
 create mode 100644 hw/char/nrf51_uart.c
#1 lore raw

[Qemu-devel] [PULL 10/10] hw/arm: versal: Add a virtual Xilinx Versal board

From: "Edgar E. Iglesias" <[email protected]>

Add a virtual Xilinx Versal board.

This board is based on the Xilinx Versal SoC. The exact details of what peripherals are attached to this board will remain in control of QEMU. QEMU will generate an FDT on the fly for Linux and other software to auto-discover peripherals.

Message-id: [email protected]

---
 hw/arm/Makefile.objs      |   2 +-
 hw/arm/xlnx-versal-virt.c | 494 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 495 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/xlnx-versal-virt.c
hw/arm/Makefile.objs +1 -1
index ec21d9bc1f0..50c7b4a927d 100644
@@ -26,7 +26,7 @@ obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o
 obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o
 obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zynqmp.o xlnx-zcu102.o
-obj-$(CONFIG_XLNX_VERSAL) += xlnx-versal.o
+obj-$(CONFIG_XLNX_VERSAL) += xlnx-versal.o xlnx-versal-virt.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
 obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
hw/arm/xlnx-versal-virt.c new file +494 -0

494 lines not on this page · raw message

Signature · 1 line
2.19.1
#2 lore raw

Re: [Qemu-devel] [PULL 10/10] hw/arm: versal: Add a virtual Xilinx Versal board

Quoted 11 lines · Peter Maydell

From: "Edgar E. Iglesias" <[email protected]>

Add a virtual Xilinx Versal board.

This board is based on the Xilinx Versal SoC. The exact details of what peripherals are attached to this board will remain in control of QEMU. QEMU will generate an FDT on the fly for Linux and other software to auto-discover peripherals.

Quoted 4 lines

Message-id: [email protected]

Hi Edgar -- I've been running the clang-7 leak sanitizer on "make check", and it spotted a couple of minor memory leaks in the versal board code:

Quoted 8 lines
hw/arm/xlnx-versal-virt.c new file +8 -0
+static void fdt_add_gic_nodes(VersalVirt *s)
+{
+    char *nodename;
+
+    nodename = g_strdup_printf("/gic@%x", MM_GIC_APU_DIST_MAIN);
+    qemu_fdt_add_subnode(s->fdt, nodename);
+    qemu_fdt_setprop_cell(s->fdt, nodename, "phandle", s->phandle.gic);
+    qemu_fdt_setprop_cells(s->fdt, nodename, "interrupts",

hw/arm/xlnx-versal-virt.c line 132

Quoted 10 lines
hw/arm/xlnx-versal-virt.c new file +10 -0
+                           GIC_FDT_IRQ_TYPE_PPI, VERSAL_GIC_MAINT_IRQ,
+                           GIC_FDT_IRQ_FLAGS_LEVEL_HI);
+    qemu_fdt_setprop(s->fdt, nodename, "interrupt-controller", NULL, 0);
+    qemu_fdt_setprop_sized_cells(s->fdt, nodename, "reg",
+                                 2, MM_GIC_APU_DIST_MAIN,
+                                 2, MM_GIC_APU_DIST_MAIN_SIZE,
+                                 2, MM_GIC_APU_REDIST_0,
+                                 2, MM_GIC_APU_REDIST_0_SIZE);
+    qemu_fdt_setprop_cell(s->fdt, nodename, "#interrupt-cells", 3);
+    qemu_fdt_setprop_string(s->fdt, nodename, "compatible", "arm,gic-v3");

nodename is allocated but never freed here.

Quoted 16 lines
hw/arm/xlnx-versal-virt.c new file +14 -0
+}
 
 
+#define NUM_VIRTIO_TRANSPORT 32
+static void create_virtio_regions(VersalVirt *s)
+{
+    int virtio_mmio_size = 0x200;
+    int i;
+
+    for (i = 0; i < NUM_VIRTIO_TRANSPORT; i++) {
+        char *name = g_strdup_printf("virtio%d", i);;
+        hwaddr base = MM_TOP_RSVD + i * virtio_mmio_size;
+        int irq = VERSAL_RSVD_HIGH_IRQ_FIRST + i;
+        MemoryRegion *mr;
+        DeviceState *dev;
+        qemu_irq pic_irq;

hw/arm/xlnx-versal-virt.c line 367

Quoted 10 lines
hw/arm/xlnx-versal-virt.c new file +10 -0
+
+        pic_irq = qdev_get_gpio_in(DEVICE(&s->soc.fpd.apu.gic), irq);
+        dev = qdev_create(NULL, "virtio-mmio");
+        object_property_add_child(OBJECT(&s->soc), name, OBJECT(dev),
+                                  &error_fatal);
+        qdev_init_nofail(dev);
+        sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic_irq);
+        mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
+        memory_region_add_subregion(&s->soc.mr_ps, base, mr);
+        sysbus_create_simple("virtio-mmio", base, pic_irq);

The body of this loop allocates name but forgets to free it.

Quoted 1 line

+ }

thanks
-- PMM

#3 lore raw

Re: [Qemu-devel] [PULL 10/10] hw/arm: versal: Add a virtual Xilinx Versal board

Hi Peter,

Thanks for pointing this out. I'll post patches soon unless someone beats me to it. I'm travelling, hence the slow and top posted reply....

Cheers,
Edgar
---
Sent from my phone

Quoted 78 lines · On Tue, Dec 4, 2018, 11:28 Peter Maydell <[email protected] wrote:
Quoted 11 lines · Peter Maydell

From: "Edgar E. Iglesias" <[email protected]>

Add a virtual Xilinx Versal board.

This board is based on the Xilinx Versal SoC. The exact details of what peripherals are attached to this board will remain in control of QEMU. QEMU will generate an FDT on the fly for Linux and other software to auto-discover peripherals.

Quoted 4 lines

Message-id: [email protected]

Hi Edgar -- I've been running the clang-7 leak sanitizer on "make check", and it spotted a couple of minor memory leaks in the versal board code:

Quoted 8 lines
hw/arm/xlnx-versal-virt.c new file +8 -0
+static void fdt_add_gic_nodes(VersalVirt *s)
+{
+    char *nodename;
+
+    nodename = g_strdup_printf("/gic@%x", MM_GIC_APU_DIST_MAIN);
+    qemu_fdt_add_subnode(s->fdt, nodename);
+    qemu_fdt_setprop_cell(s->fdt, nodename, "phandle", s->phandle.gic);
+    qemu_fdt_setprop_cells(s->fdt, nodename, "interrupts",

hw/arm/xlnx-versal-virt.c

Quoted 10 lines
hw/arm/xlnx-versal-virt.c new file +10 -0
+                           GIC_FDT_IRQ_TYPE_PPI, VERSAL_GIC_MAINT_IRQ,
+                           GIC_FDT_IRQ_FLAGS_LEVEL_HI);
+    qemu_fdt_setprop(s->fdt, nodename, "interrupt-controller", NULL, 0);
+    qemu_fdt_setprop_sized_cells(s->fdt, nodename, "reg",
+                                 2, MM_GIC_APU_DIST_MAIN,
+                                 2, MM_GIC_APU_DIST_MAIN_SIZE,
+                                 2, MM_GIC_APU_REDIST_0,
+                                 2, MM_GIC_APU_REDIST_0_SIZE);
+    qemu_fdt_setprop_cell(s->fdt, nodename, "#interrupt-cells", 3);
+    qemu_fdt_setprop_string(s->fdt, nodename, "compatible",

"arm,gic-v3");

nodename is allocated but never freed here.

Quoted 16 lines
hw/arm/xlnx-versal-virt.c new file +14 -0
+}
 
 
+#define NUM_VIRTIO_TRANSPORT 32
+static void create_virtio_regions(VersalVirt *s)
+{
+    int virtio_mmio_size = 0x200;
+    int i;
+
+    for (i = 0; i < NUM_VIRTIO_TRANSPORT; i++) {
+        char *name = g_strdup_printf("virtio%d", i);;
+        hwaddr base = MM_TOP_RSVD + i * virtio_mmio_size;
+        int irq = VERSAL_RSVD_HIGH_IRQ_FIRST + i;
+        MemoryRegion *mr;
+        DeviceState *dev;
+        qemu_irq pic_irq;

hw/arm/xlnx-versal-virt.c line 367

Quoted 10 lines
hw/arm/xlnx-versal-virt.c new file +10 -0
+
+        pic_irq = qdev_get_gpio_in(DEVICE(&s->soc.fpd.apu.gic), irq);
+        dev = qdev_create(NULL, "virtio-mmio");
+        object_property_add_child(OBJECT(&s->soc), name, OBJECT(dev),
+                                  &error_fatal);
+        qdev_init_nofail(dev);
+        sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic_irq);
+        mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0);
+        memory_region_add_subregion(&s->soc.mr_ps, base, mr);
+        sysbus_create_simple("virtio-mmio", base, pic_irq);

The body of this loop allocates name but forgets to free it.

Quoted 1 line

+ }

thanks
-- PMM

#4 lore raw

Re: [Qemu-devel] [PULL 10/10] hw/arm: versal: Add a virtual Xilinx Versal board

In reply to Peter Maydell
Quoted 10 lines · Peter Maydell

From: "Edgar E. Iglesias" <[email protected]>

Add a virtual Xilinx Versal board.

This board is based on the Xilinx Versal SoC. The exact details of what peripherals are attached to this board will remain in control of QEMU. QEMU will generate an FDT on the fly for Linux and other software to auto-discover peripherals.

Hi Edgar; I was just looking at the Versal board code for something else I was working on, and I noticed a bug that's been there since it was added in this patch:

Quoted 11 lines
hw/arm/xlnx-versal-virt.c new file +11 -0
+    s->binfo.ram_size = machine->ram_size;
+    s->binfo.kernel_filename = machine->kernel_filename;
+    s->binfo.kernel_cmdline = machine->kernel_cmdline;
+    s->binfo.initrd_filename = machine->initrd_filename;
+    s->binfo.loader_start = 0x0;
+    s->binfo.get_dtb = versal_virt_get_dtb;
+    s->binfo.modify_dtb = versal_virt_modify_dtb;
+    if (machine->kernel_filename) {
+        arm_load_kernel(s->soc.fpd.apu.cpu[0], &s->binfo);
+    } else {
+        AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0],

hw/arm/xlnx-versal-virt.c line 462

Quoted 10 lines
hw/arm/xlnx-versal-virt.c new file +10 -0
+                                                  &s->binfo);
+        /* Some boot-loaders (e.g u-boot) don't like blobs at address 0 (NULL).
+         * Offset things by 4K.  */
+        s->binfo.loader_start = 0x1000;
+        s->binfo.dtb_limit = 0x1000000;
+        if (arm_load_dtb(s->binfo.loader_start,
+                         &s->binfo, s->binfo.dtb_limit, as) < 0) {
+            exit(EXIT_FAILURE);
+        }
+    }

The board init code only calls arm_load_kernel() if machine->kernel_filename is set. This is a bug, because calling arm_load_kernel() is mandatory for board code -- it is the place where we set up the reset handler that resets the CPUs, so if you don't call it the CPU objects don't get reset.

thanks
-- PMM

#5 lore raw

Re: [Qemu-devel] [PULL 10/10] hw/arm: versal: Add a virtual Xilinx Versal board

Quoted 47 lines · Peter Maydell
Quoted 10 lines · Peter Maydell

From: "Edgar E. Iglesias" <[email protected]>

Add a virtual Xilinx Versal board.

This board is based on the Xilinx Versal SoC. The exact details of what peripherals are attached to this board will remain in control of QEMU. QEMU will generate an FDT on the fly for Linux and other software to auto-discover peripherals.

Hi Edgar; I was just looking at the Versal board code for something else I was working on, and I noticed a bug that's been there since it was added in this patch:

hw/arm/xlnx-versal-virt.c

Quoted 13 lines
hw/arm/xlnx-versal-virt.c new file +13 -0
+    s->binfo.ram_size = machine->ram_size;
+    s->binfo.kernel_filename = machine->kernel_filename;
+    s->binfo.kernel_cmdline = machine->kernel_cmdline;
+    s->binfo.initrd_filename = machine->initrd_filename;
+    s->binfo.loader_start = 0x0;
+    s->binfo.get_dtb = versal_virt_get_dtb;
+    s->binfo.modify_dtb = versal_virt_modify_dtb;
+    if (machine->kernel_filename) {
+        arm_load_kernel(s->soc.fpd.apu.cpu[0], &s->binfo);
+    } else {
+        AddressSpace *as = arm_boot_address_space(s->soc.fpd.apu.cpu[0],
+                                                  &s->binfo);
+        /* Some boot-loaders (e.g u-boot) don't like blobs at address 0

(NULL).

hw/arm/xlnx-versal-virt.c line 462

Quoted 8 lines
hw/arm/xlnx-versal-virt.c new file +8 -0
+         * Offset things by 4K.  */
+        s->binfo.loader_start = 0x1000;
+        s->binfo.dtb_limit = 0x1000000;
+        if (arm_load_dtb(s->binfo.loader_start,
+                         &s->binfo, s->binfo.dtb_limit, as) < 0) {
+            exit(EXIT_FAILURE);
+        }
+    }

The board init code only calls arm_load_kernel() if machine->kernel_filename
is set. This is a bug, because calling arm_load_kernel() is mandatory for board code -- it is the place where we set up the reset handler that resets the CPUs, so if you don't call it the CPU objects don't get reset.

Quoted 3 lines

thanks
-- PMM

Thanks Peter,

I'll send a patch shortly.

Cheers,
Edgar

#6 lore raw

[Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Peter Maydell

From: Richard Henderson <[email protected]>

When populating id registers from kvm, on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either.

Message-id: [email protected]

---
 target/arm/cpu.h |  5 +++++
 target/arm/cpu.c | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
target/arm/cpu.h +5 -0
index 8e6779936eb..b5eff79f73b 100644
@@ -3296,6 +3296,11 @@ static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
 }
 
+static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id)
+{
+    return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2;
+}
+
 static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
target/arm/cpu.c +13 -2
index 8f16e96b6c8..784a4c2dfcc 100644
@@ -774,6 +774,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     CPUARMState *env = &cpu->env;
     int pagebits;
     Error *local_err = NULL;
+    bool no_aa32 = false;
 
     /* If we needed to query the host kernel for the CPU features
      * then it's possible that might have failed in the initfn, but
@@ -820,6 +821,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
             set_feature(env, ARM_FEATURE_V7VE);
         }
     }
+
+    /*
+     * There exist AArch64 cpus without AArch32 support.  When KVM
+     * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
+     * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
+     */
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
+    }
+
     if (arm_feature(env, ARM_FEATURE_V7VE)) {
         /* v7 Virtualization Extensions. In real hardware this implies
          * EL2 and also the presence of the Security Extensions.
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }
@@ -855,7 +866,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     if (arm_feature(env, ARM_FEATURE_V6)) {
         set_feature(env, ARM_FEATURE_V5);
         if (!arm_feature(env, ARM_FEATURE_M)) {
-            assert(cpu_isar_feature(jazelle, cpu));
+            assert(no_aa32 || cpu_isar_feature(jazelle, cpu));
             set_feature(env, ARM_FEATURE_AUXCR);
         }
     }
Signature · 1 line
2.19.1
#7 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Hi,

Quoted 62 lines · Peter Maydell

From: Richard Henderson <[email protected]>

When populating id registers from kvm, on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either.

Message-id: [email protected]

---
 target/arm/cpu.h |  5 +++++
 target/arm/cpu.c | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
target/arm/cpu.h +5 -0
index 8e6779936eb..b5eff79f73b 100644
@@ -3296,6 +3296,11 @@ static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
 }
 
+static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id)
+{
+    return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2;
+}
+
 static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
target/arm/cpu.c +11 -0
index 8f16e96b6c8..784a4c2dfcc 100644
@@ -774,6 +774,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     CPUARMState *env = &cpu->env;
     int pagebits;
     Error *local_err = NULL;
+    bool no_aa32 = false;
 
     /* If we needed to query the host kernel for the CPU features
      * then it's possible that might have failed in the initfn, but
@@ -820,6 +821,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
             set_feature(env, ARM_FEATURE_V7VE);
         }
     }
+
+    /*
+     * There exist AArch64 cpus without AArch32 support.  When KVM
+     * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
+     * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
+     */
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
+    }
+
     if (arm_feature(env, ARM_FEATURE_V7VE)) {
         /* v7 Virtualization Extensions. In real hardware this implies
          * EL2 and also the presence of the Security Extensions.

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 843

Quoted 5 lines
target/arm/cpu.c +1 -1
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));

The assertion above fails on my AArch64 host (APM Mustang A3). Meaning that my host CPU supports AArch32, but lacks "arm_div".

(My understanding is that this commit, i.e., 0f8d06f16c9d, relaxed the assert originally added in commit 7e0cf8b47f0e ("target/arm: Convert division from feature bits to isar0 tests", 2018-10-24). Can we relax it even further?

Better yet: can we rework the code to emit a warning, rather than aborting QEMU? Assertions are not the best tool IMHO for catching unusual (or slightly non-conformant / early) hardware.)

Thanks,
Laszlo

Quoted 13 lines
target/arm/cpu.c +1 -1
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }
@@ -855,7 +866,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     if (arm_feature(env, ARM_FEATURE_V6)) {
         set_feature(env, ARM_FEATURE_V5);
         if (!arm_feature(env, ARM_FEATURE_M)) {
-            assert(cpu_isar_feature(jazelle, cpu));
+            assert(no_aa32 || cpu_isar_feature(jazelle, cpu));
             set_feature(env, ARM_FEATURE_AUXCR);
         }
     }
#8 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 74 lines · Laszlo Ersek

Hi,

Quoted 62 lines · Peter Maydell

From: Richard Henderson <[email protected]>

When populating id registers from kvm, on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either.

Message-id: [email protected]

---
 target/arm/cpu.h |  5 +++++
 target/arm/cpu.c | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
target/arm/cpu.h +5 -0
index 8e6779936eb..b5eff79f73b 100644
@@ -3296,6 +3296,11 @@ static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
 }
 
+static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id)
+{
+    return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2;
+}
+
 static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
target/arm/cpu.c +11 -0
index 8f16e96b6c8..784a4c2dfcc 100644
@@ -774,6 +774,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     CPUARMState *env = &cpu->env;
     int pagebits;
     Error *local_err = NULL;
+    bool no_aa32 = false;
 
     /* If we needed to query the host kernel for the CPU features
      * then it's possible that might have failed in the initfn, but
@@ -820,6 +821,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
             set_feature(env, ARM_FEATURE_V7VE);
         }
     }
+
+    /*
+     * There exist AArch64 cpus without AArch32 support.  When KVM
+     * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.
+     * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
+     */
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
+    }
+
     if (arm_feature(env, ARM_FEATURE_V7VE)) {
         /* v7 Virtualization Extensions. In real hardware this implies
          * EL2 and also the presence of the Security Extensions.

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 843

Quoted 5 lines
target/arm/cpu.c +1 -1
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));

The assertion above fails on my AArch64 host (APM Mustang A3). Meaning that my host CPU supports AArch32, but lacks "arm_div".

Quoted 8 lines

(My understanding is that this commit, i.e., 0f8d06f16c9d, relaxed the assert originally added in commit 7e0cf8b47f0e ("target/arm: Convert division from feature bits to isar0 tests", 2018-10-24). Can we relax it even further?

Better yet: can we rework the code to emit a warning, rather than aborting QEMU? Assertions are not the best tool IMHO for catching unusual (or slightly non-conformant / early) hardware.)

To clarify, I intended to launch a 32-bit ARM guest (with KVM acceleration) on my AArch64 host.

Libvirt generated the following QEMU command line:

LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin \
QEMU_AUDIO_DRV=none \
/opt/qemu-installed-optimized/bin/qemu-system-aarch64 \
-name guest=f28.32bit,debug-threads=on \
-S \
-object secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-2-f28.32bit/master-key.aes \
-machine virt-4.1,accel=kvm,usb=off,dump-guest-core=off,gic-version=2 \
-cpu host,aarch64=off \
-drive file=/root/QEMU_EFI.fd.padded,if=pflash,format=raw,unit=0,readonly=on \
-drive file=/var/lib/libvirt/qemu/nvram/f28.32bit_VARS.fd,if=pflash,format=raw,unit=1 \
-m 8192 \
-realtime mlock=off \
-smp 8,sockets=8,cores=1,threads=1 \
-uuid d525042e-1b37-4058-86ca-c6a2086e8485 \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=27,server,nowait \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc \
-no-shutdown \
-boot strict=on \
-device pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x1 \
-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
-device pcie-root-port,port=0xa,chassis=3,id=pci.3,bus=pcie.0,addr=0x1.0x2 \
-device pcie-root-port,port=0xb,chassis=4,id=pci.4,bus=pcie.0,addr=0x1.0x3 \
-device pcie-root-port,port=0xc,chassis=5,id=pci.5,bus=pcie.0,addr=0x1.0x4 \
-device pcie-root-port,port=0xd,chassis=6,id=pci.6,bus=pcie.0,addr=0x1.0x5 \
-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
-device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x0 \
-device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \
-drive file=/var/lib/libvirt/images/f28.32bit.root.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-0,werror=enospc,cache=writeback,discard=unmap \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,bootindex=1,write-cache=on \
-drive file=/var/lib/libvirt/images/f28.32bit.home.qcow2,format=qcow2,if=none,id=drive-scsi0-0-0-1,werror=enospc,cache=writeback,discard=unmap \
-device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1,write-cache=on \
-netdev tap,fd=29,id=hostnet0,vhost=on,vhostfd=30 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:6f:d1:c8,bus=pci.4,addr=0x0,romfile= \
-chardev pty,id=charserial0 \
-serial chardev:charserial0 \
-chardev socket,id=charchannel0,fd=31,server,nowait \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-device usb-tablet,id=input0,bus=usb.0,port=1 \
-device usb-kbd,id=input1,bus=usb.0,port=2 \
-vnc 127.0.0.1:0 \
-device virtio-gpu-pci,id=video0,max_outputs=1,bus=pci.5,addr=0x0 \
-object rng-random,id=objrng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=objrng0,id=rng0,max-bytes=1048576,period=1000,bus=pci.6,addr=0x0 \
-msg timestamp=on

and then I got:

Quoted 3 lines

qemu-system-aarch64: /root/src/upstream/qemu/target/arm/cpu.c:986:
arm_cpu_realizefn: Assertion `no_aa32 || ({ ARMCPU *cpu_ = (cpu); isar_feature_arm_div(&cpu_->isar); })' failed.

QEMU was built at commit 8dc7fd56dd4f ("Merge remote-tracking branch 'remotes/philmd-gitlab/tags/fw_cfg-20190523-pull-request' into staging", 2019-05-23).

Thanks
Laszlo

#9 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 27 lines · Laszlo Ersek

Hi,

Quoted 24 lines · Peter Maydell

From: Richard Henderson <[email protected]>

When populating id registers from kvm, on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either.

Message-id: [email protected]

---
 target/arm/cpu.h |  5 +++++
 target/arm/cpu.c | 15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
target/arm/cpu.h +0 -0
index 8e6779936eb..b5eff79f73b 100644
@@ -3296,6 +3296,11 @@ static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, FP) == 1;
 }
 
Quoted 3 lines

target/arm/cpu.h static inline bool isar_feature_aa64_fp16(const ARMISARegisters *id) · line 3301

Quoted 3 lines
target/arm/cpu.h +3 -0
+static inline bool isar_feature_aa64_aa32(const ARMISARegisters *id)
+{
+    return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, EL0) >= 2;

FWIW here we check EL0, ...

Quoted 15 lines
Quoted 15 lines
target/arm/cpu.h +2 -0
+}
+
 static inline bool isar_feature_aa64_sve(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, SVE) != 0;
target/arm/cpu.c +1 -0
index 8f16e96b6c8..784a4c2dfcc 100644
@@ -774,6 +774,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     CPUARMState *env = &cpu->env;
     int pagebits;
     Error *local_err = NULL;
+    bool no_aa32 = false;
 
Quoted 10 lines

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 827

Quoted 10 lines
target/arm/cpu.c +4 -0
     /* If we needed to query the host kernel for the CPU features
      * then it's possible that might have failed in the initfn, but
@@ -820,6 +821,16 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
             set_feature(env, ARM_FEATURE_V7VE);
         }
     }
+
+    /*
+     * There exist AArch64 cpus without AArch32 support.  When KVM
+     * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN.

... then here the comment is about EL1.

Quoted 45 lines
Quoted 10 lines
target/arm/cpu.c +6 -0
+     * Similarly, we cannot check ID_AA64PFR0 without AArch64 support.
+     */
+    if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        no_aa32 = !cpu_isar_feature(aa64_aa32, cpu);
+    }
+
     if (arm_feature(env, ARM_FEATURE_V7VE)) {
         /* v7 Virtualization Extensions. In real hardware this implies
          * EL2 and also the presence of the Security Extensions.

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 843

Quoted 5 lines
target/arm/cpu.c +1 -1
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));

The assertion above fails on my AArch64 host (APM Mustang A3). Meaning that my host CPU supports AArch32, but lacks "arm_div".

(My understanding is that this commit, i.e., 0f8d06f16c9d, relaxed the assert originally added in commit 7e0cf8b47f0e ("target/arm: Convert division from feature bits to isar0 tests", 2018-10-24). Can we relax it even further?

Better yet: can we rework the code to emit a warning, rather than aborting QEMU? Assertions are not the best tool IMHO for catching unusual (or slightly non-conformant / early) hardware.)

Thanks,
Laszlo

Quoted 13 lines
target/arm/cpu.c +1 -1
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }
@@ -855,7 +866,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
     if (arm_feature(env, ARM_FEATURE_V6)) {
         set_feature(env, ARM_FEATURE_V5);
         if (!arm_feature(env, ARM_FEATURE_M)) {
-            assert(cpu_isar_feature(jazelle, cpu));
+            assert(no_aa32 || cpu_isar_feature(jazelle, cpu));
             set_feature(env, ARM_FEATURE_AUXCR);
         }
     }
#10 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 10 lines · Laszlo Ersek

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 843

Quoted 6 lines · Peter Maydell
target/arm/cpu.c +1 -1
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));

The assertion above fails on my AArch64 host (APM Mustang A3). Meaning that my host CPU supports AArch32, but lacks "arm_div".

Hi; I just realized we left this assertion-failure bug report unaddressed, so I had a look at it.

I tried to repro on my Mustang, but this works for me. A CPU with AArch32 but without the Arm-mode division instructions would be non-compliant (and very obviously so if tested), so I suspect the actual problem is not with the hardware but with the kernel not correctly reporting the ID registers to QEMU. What kernel version are you using?

Quoted 3 lines

Better yet: can we rework the code to emit a warning, rather than aborting QEMU? Assertions are not the best tool IMHO for catching unusual (or slightly non-conformant / early) hardware.)

The intention of the assertion really is to catch QEMU bugs where we got the ID register values wrong in our emulated CPUs. Perhaps we should relax all these assertions to only testing if we're using TCG, not KVM ?

thanks
-- PMM

#11 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 4 lines · Peter Maydell

The intention of the assertion really is to catch QEMU bugs where we got the ID register values wrong in our emulated CPUs. Perhaps we should relax all these assertions to only testing if we're using TCG, not KVM ?

Perhaps. In some instances if ID register values are wrong we would then not migrate properly, but none of the checks we're currently doing of this sort would catch those particular cases.

r~

#12 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 10 lines · Richard Henderson
Quoted 4 lines · Peter Maydell

The intention of the assertion really is to catch QEMU bugs where we got the ID register values wrong in our emulated CPUs. Perhaps we should relax all these assertions to only testing if we're using TCG, not KVM ?

Perhaps. In some instances if ID register values are wrong we would then not migrate properly, but none of the checks we're currently doing of this sort would catch those particular cases.

In those cases we should probably print a warning and install a migration-blocker, rather than asserting...

thanks
-- PMM

#13 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 9 lines · Peter Maydell
Quoted 7 lines · Richard Henderson
Quoted 4 lines · Peter Maydell

The intention of the assertion really is to catch QEMU bugs where we got the ID register values wrong in our emulated CPUs. Perhaps we should relax all these assertions to only testing if we're using TCG, not KVM ?

Quoted 6 lines
Quoted 3 lines

Perhaps. In some instances if ID register values are wrong we would then not migrate properly, but none of the checks we're currently doing of this sort would catch those particular cases.

In those cases we should probably print a warning and install a migration-blocker, rather than asserting...

Ok, but I'm saying we don't assert for those either, at the moment.

r~

#14 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Peter Maydell
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Laszlo Ersek

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 843

Quoted 6 lines · Peter Maydell
target/arm/cpu.c +1 -1
@@ -829,7 +840,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
          */
-        assert(cpu_isar_feature(arm_div, cpu));
+        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));

The assertion above fails on my AArch64 host (APM Mustang A3). Meaning that my host CPU supports AArch32, but lacks "arm_div".

Quoted 2 lines

Hi; I just realized we left this assertion-failure bug report unaddressed, so I had a look at it.

Yes, it's also tracked under LP#1830864; thanks for looking into it.

Quoted 7 lines

I tried to repro on my Mustang, but this works for me. A CPU with AArch32 but without the Arm-mode division instructions would be non-compliant (and very obviously so if tested), so I suspect the actual problem is not with the hardware but with the kernel not correctly reporting the ID registers to QEMU. What kernel version are you using?

So, I've just retested, with the QEMU binary I've left around from last time. (This QEMU binary was built at upstream commit d247c8e7f4fc, with Phil's v2 series applied on top, for regression testing:

[PATCH v2 0/9] hw/block/pflash_cfi01: Add DeviceReset() handler

http://mid.mail-archive.com/[email protected]
)

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Thanks!
Laszlo

Quoted 12 lines
Quoted 3 lines

Better yet: can we rework the code to emit a warning, rather than aborting QEMU? Assertions are not the best tool IMHO for catching unusual (or slightly non-conformant / early) hardware.)

The intention of the assertion really is to catch QEMU bugs where we got the ID register values wrong in our emulated CPUs. Perhaps we should relax all these assertions to only testing if we're using TCG, not KVM ?

thanks
-- PMM

#15 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

thanks
-- PMM

#16 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 10 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

Thanks!
Laszlo

#17 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 29 lines · Laszlo Ersek
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159
Quoted 7 lines

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

For ISAR0, DIVIDE=0

so cpu_isar_feature(arm_div, cpu)=false

For AA64PFR0, EL0=1, EL1=1.

EL0 = 1: EL0 can be executed in AArch64 state only. EL1 = 1: EL1 can be executed in AArch64 state only.

so cpu_isar_feature(aa64_aa32, cpu)=false
then no_aa32=true

The commit description is "on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either."

Shouldn't we use a slighly different logic? Such:

- assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+ assert(no_aa32 && !cpu_isar_feature(arm_div, cpu));

#18 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 29 lines · Laszlo Ersek
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159
Quoted 7 lines

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

For ISAR0, DIVIDE=0

so cpu_isar_feature(arm_div, cpu)=false

For AA64PFR0, EL0=1, EL1=1.

EL0 = 1: EL0 can be executed in AArch64 state only. EL1 = 1: EL1 can be executed in AArch64 state only.

so cpu_isar_feature(aa64_aa32, cpu)=false
then no_aa32=true

The commit description is "on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either."

Shouldn't we use a slighly different logic? Such:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+    assert(no_aa32 && !cpu_isar_feature(arm_div, cpu));

I'm unsure. The current formula seems to match the commit description. Implication -- that is, "A implies B", (A-->B) -- is equivalent to (!A || B).

We have "no_aa32 || arm_div", which corresponds to "aa32 implies arm_div" (aa32-->arm_div). And that seems to match exactly what Peter said.

The assert you suggest would fire on a host that supports at least one of aa32 and arm_div (= the assertion would fail if (aa32 || arm_div)). That would break on my host (hw+kernel) just the same, in the end. To substitute the boolean values:

- assert(false || false)
+ assert(false && true)

Thanks
Laszlo

#19 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 74 lines · Laszlo Ersek
Quoted 57 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Laszlo Ersek
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159
Quoted 7 lines

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

For ISAR0, DIVIDE=0

so cpu_isar_feature(arm_div, cpu)=false

For AA64PFR0, EL0=1, EL1=1.

EL0 = 1: EL0 can be executed in AArch64 state only. EL1 = 1: EL1 can be executed in AArch64 state only.

so cpu_isar_feature(aa64_aa32, cpu)=false
then no_aa32=true

The commit description is "on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either."

Shouldn't we use a slighly different logic? Such:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+    assert(no_aa32 && !cpu_isar_feature(arm_div, cpu));

I'm unsure. The current formula seems to match the commit description. Implication -- that is, "A implies B", (A-->B) -- is equivalent to (!A || B).

We have "no_aa32 || arm_div", which corresponds to "aa32 implies arm_div" (aa32-->arm_div). And that seems to match exactly what Peter said.

The assert you suggest would fire on a host that supports at least one of aa32 and arm_div (= the assertion would fail if (aa32 || arm_div)). That would break on my host (hw+kernel) just the same, in the end. To substitute the boolean values:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(false || false)
+    assert(false && true)

Hmmm wait a second. The ARMv8 ARM says, about ID_ISAR0_EL1:

Quoted 9 lines

Divide, bits [27:24]

Indicates the implemented Divide instructions. Permitted values are:
0000 None implemented.
0001 Adds SDIV and UDIV in the T32 instruction set. 0010 As for 0b0001, and adds SDIV and UDIV in the A32 instruction
set.
All other values are reserved.

So this means that (aa32 && !arm_div) *does* conform to the architecture manual! And then, I understand where the bug is.

As I wrote above, the current C expression stands for:

aa32 --> arm_div

which -- we see from the ARMv8 ARM -- is wrong.

Upon re-reading the commit message more carefully:

on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either

it's clear that the intent was *not* the implication encoded in the source. Instead, the intent was the *reverse* implication, namely:

!aa32 --> !arm_div [1]

Or, equivalently (because, (A --> B) === (!A --> !B)):

arm_div --> aa32 [2]

Now, if you encode any one of these (equivalent) formulae in C, with the logical OR operator, you get:

- Starting from [1]:

  (A     --> B)        === (!A   || B)
  (!aa32 --> !arm_div) === (aa32 || !arm_div) === (!no_aa32 || !arm_div)

- Starting from [2]:

  (A       --> B)    === (!A       || B)
  (arm_div --> aa32) === (!arm_div || aa32) === (!arm_div || !no_aa32)

You can see that, regardless of whether we start with [1], or equivalently, [2], we end up with the exact same predicate, logically speaking. The final expressions only differ in C with regard to the order of evaluation / shortcut behavior. We can pick whichever we prefer (for whatever other reason).

FWIW, the language of the original commit message corresponds to [1]. So, if we want to stick with that, then the patch we need is:

Quoted 9 lines
target/arm/cpu.c +1 -0
index e75a64a25a4b..ea84a3e11abb 100644
@@ -1382,8 +1382,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * include the various other features that V7VE implies.
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
+         *

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1394

Quoted 10 lines
target/arm/cpu.c +5 -1
+         * Lack of aa32 support excludes arm_div support:
+         *   no_aa32 --> !arm_div
+         * Using the logical OR operator, the same is expressed as:
+         *   !no_aa32 || !arm_div
          */
-        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+        assert(!no_aa32 || !cpu_isar_feature(arm_div, cpu));
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }

If you guys agree, I can formally submit this patch.

Thanks
Laszlo

#20 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 148 lines · Laszlo Ersek
Quoted 74 lines · Laszlo Ersek
Quoted 57 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Laszlo Ersek
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159
Quoted 7 lines

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

For ISAR0, DIVIDE=0

so cpu_isar_feature(arm_div, cpu)=false

For AA64PFR0, EL0=1, EL1=1.

EL0 = 1: EL0 can be executed in AArch64 state only. EL1 = 1: EL1 can be executed in AArch64 state only.

so cpu_isar_feature(aa64_aa32, cpu)=false
then no_aa32=true

The commit description is "on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either."

Shouldn't we use a slighly different logic? Such:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+    assert(no_aa32 && !cpu_isar_feature(arm_div, cpu));

I'm unsure. The current formula seems to match the commit description. Implication -- that is, "A implies B", (A-->B) -- is equivalent to (!A || B).

We have "no_aa32 || arm_div", which corresponds to "aa32 implies arm_div" (aa32-->arm_div). And that seems to match exactly what Peter said.

The assert you suggest would fire on a host that supports at least one of aa32 and arm_div (= the assertion would fail if (aa32 || arm_div)). That would break on my host (hw+kernel) just the same, in the end. To substitute the boolean values:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(false || false)
+    assert(false && true)

Hmmm wait a second. The ARMv8 ARM says, about ID_ISAR0_EL1:

Quoted 9 lines

Divide, bits [27:24]

Indicates the implemented Divide instructions. Permitted values are:
0000 None implemented.
0001 Adds SDIV and UDIV in the T32 instruction set. 0010 As for 0b0001, and adds SDIV and UDIV in the A32 instruction
set.
All other values are reserved.

So this means that (aa32 && !arm_div) *does* conform to the architecture manual! And then, I understand where the bug is.

As I wrote above, the current C expression stands for:

aa32 --> arm_div

which -- we see from the ARMv8 ARM -- is wrong.

Upon re-reading the commit message more carefully:

on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either

it's clear that the intent was *not* the implication encoded in the source. Instead, the intent was the *reverse* implication, namely:

!aa32 --> !arm_div [1]

Or, equivalently (because, (A --> B) === (!A --> !B)):

arm_div --> aa32 [2]

Now, if you encode any one of these (equivalent) formulae in C, with the logical OR operator, you get:

- Starting from [1]:

  (A     --> B)        === (!A   || B)
  (!aa32 --> !arm_div) === (aa32 || !arm_div) === (!no_aa32 || !arm_div)

- Starting from [2]:

  (A       --> B)    === (!A       || B)
  (arm_div --> aa32) === (!arm_div || aa32) === (!arm_div || !no_aa32)

You can see that, regardless of whether we start with [1], or equivalently, [2], we end up with the exact same predicate, logically speaking. The final expressions only differ in C with regard to the order of evaluation / shortcut behavior. We can pick whichever we prefer (for whatever other reason).

FWIW, the language of the original commit message corresponds to [1]. So, if we want to stick with that, then the patch we need is:

Quoted 13 lines
target/arm/cpu.c +5 -0
index e75a64a25a4b..ea84a3e11abb 100644
@@ -1382,8 +1382,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * include the various other features that V7VE implies.
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
+         *
+         * Lack of aa32 support excludes arm_div support:
+         *   no_aa32 --> !arm_div
+         * Using the logical OR operator, the same is expressed as:
+         *   !no_aa32 || !arm_div
Quoted 8 lines

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1394

Quoted 6 lines
target/arm/cpu.c +1 -1
          */
-        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+        assert(!no_aa32 || !cpu_isar_feature(arm_div, cpu));
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }

If you guys agree, I can formally submit this patch.

NB: the same might apply to the "jazelle" feature; I didn't check.

Thanks
Laszlo

#21 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 1 line · Laszlo Ersek

because, (A --> B) === (!A --> !B)

Obviously, it is impossible for me to write an email containing logical formulae without at least one *crucial* typo.

The correct form of the above equivalence is:

(A --> B) === (!B --> !A)

This typo does not affect the rest of my previous message -- while I quoted the equivalence incorrectly, I did use it correctly.

Thanks & sorry
Laszlo

#22 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 4 lines · Laszlo Ersek

Review

Quoted 2 lines · Laszlo Ersek
(quoted diff) +1 -1
-        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+        assert(!no_aa32 || !cpu_isar_feature(arm_div, cpu));

BTW this can be pronounced in natural language as follows: "we either have aa32 support, or if we don't, then we lack arm_div support too".

Thanks
Laszlo

#23 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 104 lines · Laszlo Ersek
Quoted 74 lines · Laszlo Ersek
Quoted 57 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Laszlo Ersek
Quoted 11 lines · Peter Maydell
Quoted 8 lines · Laszlo Ersek

The issue still reproduces, so it makes sense for me to look at the host kernel version... Well, I'm afraid it won't help much, for an upstream investigation:

4.14.0-115.8.2.el7a.aarch64

This is the latest released kernel from "Red Hat Enterprise Linux for ARM 64 7".

Quoted 8 lines

OK. (I'm using 4.15.0-51-generic from ubuntu).

Could you run with QEMU under gdb, and when it hits the assertion go back up a stack frame to the arm_cpu_realizefn() frame, and then "print /x cpu->isar" ? That should show us what we think we've got as ID registers from the kernel. (You might need to build QEMU with --enable-debug to get useful enough debug info to do that, not sure.)

(My qemu build script always builds QEMU in two configs, the difference being --prefix and --enable-debug.)

This is what I got:

(gdb) frame 4
#4 0x00000000006a063c in arm_cpu_realizefn (dev=0x1761140,

    errp=0xffffffffe540)
    at .../qemu/target/arm/cpu.c:1159
Quoted 7 lines

1159 assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
(gdb) print /x cpu->isar
$1 = {id_isar0 = 0x0, id_isar1 = 0x0, id_isar2 = 0x0, id_isar3 = 0x0,
id_isar4 = 0x0, id_isar5 = 0x0, id_isar6 = 0x0, mvfr0 = 0x0, mvfr1 = 0x0, mvfr2 = 0x0, id_aa64isar0 = 0x0, id_aa64isar1 = 0x0, id_aa64pfr0 = 0x11, id_aa64pfr1 = 0x0, id_aa64mmfr0 = 0x0, id_aa64mmfr1 = 0x0}

For ISAR0, DIVIDE=0

so cpu_isar_feature(arm_div, cpu)=false

For AA64PFR0, EL0=1, EL1=1.

EL0 = 1: EL0 can be executed in AArch64 state only. EL1 = 1: EL1 can be executed in AArch64 state only.

so cpu_isar_feature(aa64_aa32, cpu)=false
then no_aa32=true

The commit description is "on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either."

Shouldn't we use a slighly different logic? Such:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+    assert(no_aa32 && !cpu_isar_feature(arm_div, cpu));

I'm unsure. The current formula seems to match the commit description. Implication -- that is, "A implies B", (A-->B) -- is equivalent to (!A || B).

We have "no_aa32 || arm_div", which corresponds to "aa32 implies arm_div" (aa32-->arm_div). And that seems to match exactly what Peter said.

The assert you suggest would fire on a host that supports at least one of aa32 and arm_div (= the assertion would fail if (aa32 || arm_div)). That would break on my host (hw+kernel) just the same, in the end. To substitute the boolean values:

Review

Quoted 2 lines
(quoted diff) +1 -1
-    assert(false || false)
+    assert(false && true)

Hmmm wait a second. The ARMv8 ARM says, about ID_ISAR0_EL1:

Quoted 9 lines

Divide, bits [27:24]

Indicates the implemented Divide instructions. Permitted values are:
0000 None implemented.
0001 Adds SDIV and UDIV in the T32 instruction set. 0010 As for 0b0001, and adds SDIV and UDIV in the A32 instruction
set.
All other values are reserved.

So this means that (aa32 && !arm_div) *does* conform to the architecture manual! And then, I understand where the bug is.

As I wrote above, the current C expression stands for:

aa32 --> arm_div

which -- we see from the ARMv8 ARM -- is wrong.

Upon re-reading the commit message more carefully:

on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either

Quoted 6 lines

it's clear that the intent was *not* the implication encoded in the source. Instead, the intent was the *reverse* implication, namely:

!aa32 --> !arm_div [1]

Or, equivalently (because, (A --> B) === (!A --> !B)):

[Laszlo corrected this as: (A --> B) === (!B --> !A)]

Quoted 12 lines

arm_div --> aa32 [2]

Now, if you encode any one of these (equivalent) formulae in C, with the logical OR operator, you get:

- Starting from [1]:

  (A     --> B)        === (!A   || B)
  (!aa32 --> !arm_div) === (aa32 || !arm_div) === (!no_aa32 || !arm_div)

- Starting from [2]:

Quoted 8 lines
  (A       --> B)    === (!A       || B)
  (arm_div --> aa32) === (!arm_div || aa32) === (!arm_div || !no_aa32)

You can see that, regardless of whether we start with [1], or equivalently, [2], we end up with the exact same predicate, logically speaking. The final expressions only differ in C with regard to the order of evaluation / shortcut behavior. We can pick whichever we prefer (for whatever other reason).

This makes sense.

I still wonder why this didn't assert on Peter's setup.

Quoted 17 lines

FWIW, the language of the original commit message corresponds to [1]. So, if we want to stick with that, then the patch we need is:

Quoted 13 lines
target/arm/cpu.c +5 -0
index e75a64a25a4b..ea84a3e11abb 100644
@@ -1382,8 +1382,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * include the various other features that V7VE implies.
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
+         *
+         * Lack of aa32 support excludes arm_div support:
+         *   no_aa32 --> !arm_div
+         * Using the logical OR operator, the same is expressed as:
+         *   !no_aa32 || !arm_div
Quoted 8 lines

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1394

Quoted 6 lines
target/arm/cpu.c +1 -1
          */
-        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+        assert(!no_aa32 || !cpu_isar_feature(arm_div, cpu));
         set_feature(env, ARM_FEATURE_LPAE);
         set_feature(env, ARM_FEATURE_V7);
     }

If you guys agree, I can formally submit this patch.

Worthwhile, so it could get in for the next release.

Regards,

Phil.

#24 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 1 line · Philippe Mathieu-Daudé

I still wonder why this didn't assert on Peter's setup.

My setup does not assert because my host kernel correctly provides the ID register values to QEMU. Laszlo's appears to be providing all-zeroes, which then obviously breaks assertions being made about the sanity of those ID register values...

thanks
-- PMM

#25 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 8 lines · Peter Maydell
Quoted 1 line · Philippe Mathieu-Daudé

I still wonder why this didn't assert on Peter's setup.

My setup does not assert because my host kernel correctly provides the ID register values to QEMU. Laszlo's appears to be providing all-zeroes, which then obviously breaks assertions being made about the sanity of those ID register values...

OK. Can you suggest a location that I should check in the host kernel?

Thanks!
Laszlo

#26 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 5 lines · Laszlo Ersek
Quoted 3 lines · Peter Maydell
Quoted 1 line · Philippe Mathieu-Daudé

I still wonder why this didn't assert on Peter's setup.

Quoted 7 lines
Quoted 5 lines

My setup does not assert because my host kernel correctly provides the ID register values to QEMU. Laszlo's appears to be providing all-zeroes, which then obviously breaks assertions being made about the sanity of those ID register values...

OK. Can you suggest a location that I should check in the host kernel?

I was about to write out the process of how we get these values from the kernel, but as the first step of that I read through QEMU's target/arm/kvm64.c:kvm_arm_get_host_cpu_features(), which is the function which reads these values using the KVM_GET_ONE_REG ioctl. It starts with an attempt to read ID_AA64PFR0, and has a comment for the error-handling case:

/*
* Before v4.15, the kernel only exposed a limited number of system
* registers, not including any of the interesting AArch64 ID regs.
* For the most part we could leave these fields as zero with minimal
* effect, since this does not affect the values seen by the guest. *
* However, it could cause problems down the line for QEMU,
* so provide a minimal v8.0 default.
*
* ??? Could read MIDR and use knowledge from cpu64.c.
* ??? Could map a page of memory into our temp guest and
* run the tiniest of hand-crafted kernels to extract
* the values seen by the guest.
* ??? Either of these sounds like too much effort just
* to work around running a modern host kernel.
*/

I have 4.15, and don't hit this assert; you have 4.14 and do, so I think you're going to be going through this codepath which currently sets only ahcf->isar.id_aa64pfr0 and none of the other ID register fields in the isar struct.

I'm not sure exactly which kernel commits added the ID register reading support. (The relevant kernel code is in arch/arm64/kvm/sys_regs.c I think.)

Anyway, I think we need to do at least one of:
* enhance the "provide a minimal v8.0 default" code in this condition in kvm_arm_get_host_cpu_features() so that it populates the ID registers sufficiently to avoid asserts and other bad things
* make the asserts on ID register oddnesses be only for TCG (ie where QEMU controls the values) and not for KVM

thanks
-- PMM

#27 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

Quoted 38 lines · Peter Maydell
Quoted 5 lines · Laszlo Ersek
Quoted 3 lines · Peter Maydell
Quoted 1 line · Philippe Mathieu-Daudé

I still wonder why this didn't assert on Peter's setup.

Quoted 7 lines
Quoted 5 lines

My setup does not assert because my host kernel correctly provides the ID register values to QEMU. Laszlo's appears to be providing all-zeroes, which then obviously breaks assertions being made about the sanity of those ID register values...

OK. Can you suggest a location that I should check in the host kernel?

I was about to write out the process of how we get these values from the kernel, but as the first step of that I read through QEMU's target/arm/kvm64.c:kvm_arm_get_host_cpu_features(), which is the function which reads these values using the KVM_GET_ONE_REG ioctl. It starts with an attempt to read ID_AA64PFR0, and has a comment for the error-handling case:

/*
* Before v4.15, the kernel only exposed a limited number of system
* registers, not including any of the interesting AArch64 ID regs.
* For the most part we could leave these fields as zero with minimal
* effect, since this does not affect the values seen by the guest. *
* However, it could cause problems down the line for QEMU,
* so provide a minimal v8.0 default.
*
* ??? Could read MIDR and use knowledge from cpu64.c.
* ??? Could map a page of memory into our temp guest and
* run the tiniest of hand-crafted kernels to extract
* the values seen by the guest.
* ??? Either of these sounds like too much effort just
* to work around running a modern host kernel.
*/

Quoted 8 lines

I have 4.15, and don't hit this assert; you have 4.14 and do, so I think you're going to be going through this codepath which currently sets only ahcf->isar.id_aa64pfr0 and none of the other ID register fields in the isar struct.

I'm not sure exactly which kernel commits added the ID register reading support. (The relevant kernel code is in arch/arm64/kvm/sys_regs.c I think.)

I compared that file between the downstream kernel source and upstream v4.15, and it looks like the following series (indeed released as part of v4.15) is what's missing down-stream, for this particular use case:

     1  27e64b4be4b8 regset: Add support for dynamically sized regsets
     2  94ef7ecbdf6f arm64: fpsimd: Correctly annotate exception helpers called from asm
     3  abf73988a7c2 arm64: signal: Verify extra data is user-readable in sys_rt_sigreturn
     4  93390c0a1b20 arm64: KVM: Hide unsupported AArch64 CPU features from guests
     5  b472db6cf8c6 arm64: efi: Add missing Kconfig dependency on KERNEL_MODE_NEON
     6  38b9aeb32fa7 arm64: Port deprecated instruction emulation to new sysctl interface
     7  9cf5b54fafed arm64: fpsimd: Simplify uses of {set,clear}_ti_thread_flag()
     8  672365649cca arm64/sve: System register and exception syndrome definitions
     9  1fc5dce78ad1 arm64/sve: Low-level SVE architectural state manipulation functions
    10  ddd25ad1fde8 arm64/sve: Kconfig update and conditional compilation support
    11  d0b8cd318788 arm64/sve: Signal frame and context structure definition
    12  22043a3c082a arm64/sve: Low-level CPU setup
    13  bc0ee4760364 arm64/sve: Core task context handling
    14  79ab047c75d6 arm64/sve: Support vector length resetting for new processes
    15  8cd969d28fd2 arm64/sve: Signal handling support
    16  7582e22038a2 arm64/sve: Backend logic for setting the vector length
    17  8f1eec57cdcc arm64: cpufeature: Move sys_caps_initialised declarations
    18  2e0f2478ea37 arm64/sve: Probe SVE capabilities and usable vector lengths
    19  1bd3f93641ec arm64/sve: Preserve SVE registers around kernel-mode NEON use
    20  fdfa976cae5c arm64/sve: Preserve SVE registers around EFI runtime service calls
    21  43d4da2c45b2 arm64/sve: ptrace and ELF coredump support
    22  2d2123bc7c7f arm64/sve: Add prctl controls for userspace vector length management
    23  4ffa09a939ab arm64/sve: Add sysctl to set the default vector length for new processes
    24  17eed27b02da arm64/sve: KVM: Prevent guests from using SVE
    25  aac45ffd1f8e arm64/sve: KVM: Treat guest SVE use as undefined instruction execution
    26  07d79fe7c223 arm64/sve: KVM: Hide SVE from CPU features exposed to guests
    27  43994d824e84 arm64/sve: Detect SVE and activate runtime support
    28  ce6990813f15 arm64/sve: Add documentation

The differences found by the simple "diff" that I mention above are mainly due to commit #4 (93390c0a1b20, "arm64: KVM: Hide unsupported AArch64 CPU features from guests", 2017-11-03).

I found a (likely non-final) version of the cover letter too, here: https://www.spinics.net/lists/arm-kernel/msg599528.html

I guess I should convince myself to install RHEL8 on the Mustang sometime...

Thanks!
Laszlo

Quoted 11 lines

Anyway, I think we need to do at least one of:
* enhance the "provide a minimal v8.0 default" code in this condition in kvm_arm_get_host_cpu_features() so that it populates the ID registers sufficiently to avoid asserts and other bad things
* make the asserts on ID register oddnesses be only for TCG (ie where QEMU controls the values) and not for KVM

thanks
-- PMM

#28 lore raw

Re: [Qemu-devel] [PULL 08/10] target/arm: Conditionalize some asserts on aarch32 support

In reply to Laszlo Ersek
Quoted 12 lines · Laszlo Ersek

Hmmm wait a second. The ARMv8 ARM says, about ID_ISAR0_EL1:

Quoted 9 lines

Divide, bits [27:24]

Indicates the implemented Divide instructions. Permitted values are:
0000 None implemented.
0001 Adds SDIV and UDIV in the T32 instruction set. 0010 As for 0b0001, and adds SDIV and UDIV in the A32 instruction
set.
All other values are reserved.

Quoted 2 lines

So this means that (aa32 && !arm_div) *does* conform to the architecture manual!

The architecture manual also says
"In ARMv8-A the only permitted value is 0010.", and in earlier versions of the manual it says also that ARMv7VE implies that we must have all the integer divide instructions. And this assert is guarded by "if (arm_feature(env, ARM_FEATURE_V7VE))". (This is what we're trying to test, really: something that's providing AArch32 v7VE-or-better must include the divide insns.)

Quoted 4 lines

Upon re-reading the commit message more carefully:

on a host that doesn't support aarch32 mode at all, neither arm_div nor jazelle will be supported either

The point of this text is that "v8 AArch64 with no AArch32" is an exception to the previous version of the check, which was just "v7VE must mean we have the divide insns".

Similarly with Jazelle: what we were testing before commit 0f8d06f was "v6 must imply Jazelle", which is true for everything except the special case of "an AArch64 CPU with no AArch32 support" (which can only happen for a KVM setup), and the test we are trying to check after the commit is "v6 aarch32 must imply Jazelle".

Quoted 8 lines
Quoted 8 lines
target/arm/cpu.c +0 -0
index e75a64a25a4b..ea84a3e11abb 100644
@@ -1382,8 +1382,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
          * include the various other features that V7VE implies.
          * Presence of EL2 itself is ARM_FEATURE_EL2, and of the
          * Security Extensions is ARM_FEATURE_EL3.
Quoted 8 lines

target/arm/cpu.c static void arm_cpu_realizefn(DeviceState *dev, Error **errp) · line 1391

Quoted 8 lines
target/arm/cpu.c +6 -1
+         *
+         * Lack of aa32 support excludes arm_div support:
+         *   no_aa32 --> !arm_div
+         * Using the logical OR operator, the same is expressed as:
+         *   !no_aa32 || !arm_div
          */
-        assert(no_aa32 || cpu_isar_feature(arm_div, cpu));
+        assert(!no_aa32 || !cpu_isar_feature(arm_div, cpu));

This now fails to test what we wanted, because it will allow an incorrect set of ID registers that define a v7VE CPU without the arm_div feature to pass.

thanks
-- PMM

#29 lore raw

[Qemu-devel] [PULL 09/10] hw/arm: versal: Add a model of Xilinx Versal SoC

In reply to Peter Maydell

From: "Edgar E. Iglesias" <[email protected]>

Add a model of Xilinx Versal SoC.

Message-id: [email protected]

---
 hw/arm/Makefile.objs                |   1 +
 include/hw/arm/xlnx-versal.h        | 122 +++++++++++
 hw/arm/xlnx-versal.c                | 323 ++++++++++++++++++++++++++++
 default-configs/aarch64-softmmu.mak |   1 +
 4 files changed, 447 insertions(+)
 create mode 100644 include/hw/arm/xlnx-versal.h
 create mode 100644 hw/arm/xlnx-versal.c
hw/arm/Makefile.objs +1 -0
index 5f88062c666..ec21d9bc1f0 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o
 obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o
 obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zynqmp.o xlnx-zcu102.o
+obj-$(CONFIG_XLNX_VERSAL) += xlnx-versal.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
 obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
include/hw/arm/xlnx-versal.h new file +122 -0

122 lines not on this page · raw message

hw/arm/xlnx-versal.c new file +323 -0

323 lines not on this page · raw message

default-configs/aarch64-softmmu.mak +1 -0
index 6f790f061a1..4ea9add0034 100644
@@ -8,4 +8,5 @@ CONFIG_DDC=y
 CONFIG_DPCD=y
 CONFIG_XLNX_ZYNQMP=y
 CONFIG_XLNX_ZYNQMP_ARM=y
+CONFIG_XLNX_VERSAL=y
 CONFIG_ARM_SMMUV3=y
Signature · 1 line
2.19.1
#30 lore raw

[Qemu-devel] [PULL 07/10] hw/arm/xilinx_zynq: Use the ARRAY_SIZE macro

In reply to Peter Maydell

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

---
 hw/arm/xilinx_zynq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/xilinx_zynq.c +1 -1
index f1496d29273..57497b0c4d3 100644
@@ -294,7 +294,7 @@ static void zynq_init(MachineState *machine)
     busdev = SYS_BUS_DEVICE(dev);
     sysbus_mmio_map(busdev, 0, 0xF8003000);
     sysbus_connect_irq(busdev, 0, pic[45-IRQ_OFFSET]); /* abort irq line */
-    for (n = 0; n < 8; ++n) { /* event irqs */
+    for (n = 0; n < ARRAY_SIZE(dma_irqs); ++n) { /* event irqs */
         sysbus_connect_irq(busdev, n + 1, pic[dma_irqs[n] - IRQ_OFFSET]);
     }
 
Signature · 1 line
2.19.1
#31 lore raw

[Qemu-devel] [PULL 06/10] strongarm: mask off high[31:28] bits from dir and state registers

In reply to Peter Maydell

From: Prasad J Pandit <[email protected]>

The high[31:28] bits of 'direction' and 'state' registers of SA-1100/SA-1110 device are reserved. Setting them may lead to OOB 's->handler[]' array access issue. Mask off [31:28] bits to avoid it.

Message-id: [email protected]

---
 hw/arm/strongarm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/strongarm.c +2 -2
index ec2627374d0..644a9c45b4e 100644
@@ -587,12 +587,12 @@ static void strongarm_gpio_write(void *opaque, hwaddr offset,
 
     switch (offset) {
     case GPDR:        /* GPIO Pin-Direction registers */
-        s->dir = value;
+        s->dir = value & 0x0fffffff;
         strongarm_gpio_handler_update(s);
         break;
 
     case GPSR:        /* GPIO Pin-Output Set registers */
-        s->olevel |= value;
+        s->olevel |= value & 0x0fffffff;
         strongarm_gpio_handler_update(s);
         break;
 
Signature · 1 line
2.19.1
#32 lore raw

[Qemu-devel] [PULL 05/10] MAINTAINERS: Remove bouncing email in ARM ACPI

In reply to Peter Maydell

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

Shannon Zhao's email at Huawei is bouncing: remove it.

X-Failed-Recipients: [email protected]
** Address not found **
Your message wasn't delivered to [email protected] because the address couldn't be found, or is unable to receive mail.

Note that the section still contains his personal email (see e59f13d76bb).

Message-id: [email protected]

---
 MAINTAINERS | 1 -
 1 file changed, 1 deletion(-)
MAINTAINERS +0 -1
index 85f19f569ff..98a1856afc0 100644
@@ -627,7 +627,6 @@ F: hw/*/xlnx*.c
 F: include/hw/*/xlnx*.h
 
 ARM ACPI Subsystem
-M: Shannon Zhao <[email protected]>
 M: Shannon Zhao <[email protected]>
 L: [email protected]
 S: Maintained
Signature · 1 line
2.19.1
#33 lore raw

[Qemu-devel] [PULL 04/10] tests/boot-serial-test: Add microbit board testcase

In reply to Peter Maydell

From: Julia Suvorova <[email protected]>

New mini-kernel test for nRF51 SoC UART.

---
 tests/boot-serial-test.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tests/boot-serial-test.c +19 -0
index f865822e32f..8ec6aed35d2 100644
@@ -62,6 +62,24 @@ static const uint8_t kernel_aarch64[] = {
     0xfd, 0xff, 0xff, 0x17,                 /* b       -12 (loop) */
 };
 
+static const uint8_t kernel_nrf51[] = {
+    0x00, 0x00, 0x00, 0x00,                 /* Stack top address */
+    0x09, 0x00, 0x00, 0x00,                 /* Reset handler address */
+    0x04, 0x4a,                             /* ldr  r2, [pc, #16] Get ENABLE */
+    0x04, 0x21,                             /* movs r1, #4 */
+    0x11, 0x60,                             /* str  r1, [r2] */
+    0x04, 0x4a,                             /* ldr  r2, [pc, #16] Get STARTTX */
+    0x01, 0x21,                             /* movs r1, #1 */
+    0x11, 0x60,                             /* str  r1, [r2] */
+    0x03, 0x4a,                             /* ldr  r2, [pc, #12] Get TXD */
+    0x54, 0x21,                             /* movs r1, 'T' */
+    0x11, 0x60,                             /* str  r1, [r2] */
+    0xfe, 0xe7,                             /* b    . */
+    0x00, 0x25, 0x00, 0x40,                 /* 0x40002500 = UART ENABLE */
+    0x08, 0x20, 0x00, 0x40,                 /* 0x40002008 = UART STARTTX */
+    0x1c, 0x25, 0x00, 0x40                  /* 0x4000251c = UART TXD */
+};
+
 typedef struct testdef {
     const char *arch;       /* Target architecture */
     const char *machine;    /* Name of the machine */
@@ -105,6 +123,7 @@ static testdef_t tests[] = {
     { "hppa", "hppa", "", "SeaBIOS wants SYSTEM HALT" },
     { "aarch64", "virt", "-cpu cortex-a57", "TT", sizeof(kernel_aarch64),
       kernel_aarch64 },
+    { "arm", "microbit", "", "T", sizeof(kernel_nrf51), kernel_nrf51 },
 
     { NULL }
 };
Signature · 1 line
2.19.1
#34 lore raw

[Qemu-devel] [PULL 03/10] hw/arm/nrf51_soc: Connect UART to nRF51 SoC

In reply to Peter Maydell

From: Julia Suvorova <[email protected]>

Wire up nRF51 UART in the corresponding SoC.

---
 include/hw/arm/nrf51_soc.h |  3 +++
 hw/arm/microbit.c          |  2 ++
 hw/arm/nrf51_soc.c         | 20 ++++++++++++++++++++
 3 files changed, 25 insertions(+)
include/hw/arm/nrf51_soc.h +3 -0
index f4e092b554e..73fc92e9a8d 100644
@@ -12,6 +12,7 @@
 
 #include "hw/sysbus.h"
 #include "hw/arm/armv7m.h"
+#include "hw/char/nrf51_uart.h"
 
 #define TYPE_NRF51_SOC "nrf51-soc"
 #define NRF51_SOC(obj) \
@@ -24,6 +25,8 @@ typedef struct NRF51State {
     /*< public >*/
     ARMv7MState cpu;
 
+    NRF51UARTState uart;
+
     MemoryRegion iomem;
     MemoryRegion sram;
     MemoryRegion flash;
hw/arm/microbit.c +2 -0
index e7d74116a50..a734e7f650e 100644
@@ -12,6 +12,7 @@
 #include "qapi/error.h"
 #include "hw/boards.h"
 #include "hw/arm/arm.h"
+#include "sysemu/sysemu.h"
 #include "exec/address-spaces.h"
 
 #include "hw/arm/nrf51_soc.h"
@@ -35,6 +36,7 @@ static void microbit_init(MachineState *machine)
 
     sysbus_init_child_obj(OBJECT(machine), "nrf51", soc, sizeof(s->nrf51),
                           TYPE_NRF51_SOC);
+    qdev_prop_set_chr(DEVICE(&s->nrf51), "serial0", serial_hd(0));
     object_property_set_link(soc, OBJECT(system_memory), "memory",
                              &error_fatal);
     object_property_set_bool(soc, true, "realized", &error_fatal);
hw/arm/nrf51_soc.c +20 -0
index 1a59ef45525..b89c1bdea08 100644
@@ -43,9 +43,12 @@
 #define NRF51822_FLASH_SIZE     (256 * 1024)
 #define NRF51822_SRAM_SIZE      (16 * 1024)
 
+#define BASE_TO_IRQ(base) ((base >> 12) & 0x1F)
+
 static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
 {
     NRF51State *s = NRF51_SOC(dev_soc);
+    MemoryRegion *mr;
     Error *err = NULL;
 
     if (!s->board_memory) {
@@ -82,6 +85,18 @@ static void nrf51_soc_realize(DeviceState *dev_soc, Error **errp)
     }
     memory_region_add_subregion(&s->container, SRAM_BASE, &s->sram);
 
+    /* UART */
+    object_property_set_bool(OBJECT(&s->uart), true, "realized", &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+    mr = sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->uart), 0);
+    memory_region_add_subregion_overlap(&s->container, UART_BASE, mr, 0);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart), 0,
+                       qdev_get_gpio_in(DEVICE(&s->cpu),
+                       BASE_TO_IRQ(UART_BASE)));
+
     create_unimplemented_device("nrf51_soc.io", IOMEM_BASE, IOMEM_SIZE);
     create_unimplemented_device("nrf51_soc.ficr", FICR_BASE, FICR_SIZE);
     create_unimplemented_device("nrf51_soc.private",
@@ -99,6 +114,11 @@ static void nrf51_soc_init(Object *obj)
     qdev_prop_set_string(DEVICE(&s->cpu), "cpu-type",
                          ARM_CPU_TYPE_NAME("cortex-m0"));
     qdev_prop_set_uint32(DEVICE(&s->cpu), "num-irq", 32);
+
+    sysbus_init_child_obj(obj, "uart", &s->uart, sizeof(s->uart),
+                           TYPE_NRF51_UART);
+    object_property_add_alias(obj, "serial0", OBJECT(&s->uart), "chardev",
+                              &error_abort);
 }
 
 static Property nrf51_soc_properties[] = {
Signature · 1 line
2.19.1
#35 lore raw

[Qemu-devel] [PULL 01/10] hw/arm/virt: Set VIRT_COMPAT_3_0 compat

In reply to Peter Maydell

From: Eric Auger <[email protected]>

We are missing the VIRT_COMPAT_3_0 definition and setting. Let's add them.

Message-id: [email protected]

---
 hw/arm/virt.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/arm/virt.c +4 -0
index 9f677825f9f..a2b8d8f7c2c 100644
@@ -1871,6 +1871,9 @@ static void virt_machine_3_1_options(MachineClass *mc)
 }
 DEFINE_VIRT_MACHINE_AS_LATEST(3, 1)
 
+#define VIRT_COMPAT_3_0 \
+    HW_COMPAT_3_0
+
 static void virt_3_0_instance_init(Object *obj)
 {
     virt_3_1_instance_init(obj);
@@ -1879,6 +1882,7 @@ static void virt_3_0_instance_init(Object *obj)
 static void virt_machine_3_0_options(MachineClass *mc)
 {
     virt_machine_3_1_options(mc);
+    SET_MACHINE_COMPAT(mc, VIRT_COMPAT_3_0);
 }
 DEFINE_VIRT_MACHINE(3, 0)
 
Signature · 1 line
2.19.1
#36 lore raw

[Qemu-devel] [PULL 02/10] hw/char: Implement nRF51 SoC UART

In reply to Peter Maydell

From: Julia Suvorova <[email protected]>

Not implemented: CTS/NCTS, PSEL*.

---
 hw/char/Makefile.objs        |   1 +
 include/hw/char/nrf51_uart.h |  78 +++++++++
 hw/char/nrf51_uart.c         | 330 +++++++++++++++++++++++++++++++++++
 hw/char/trace-events         |   4 +
 4 files changed, 413 insertions(+)
 create mode 100644 include/hw/char/nrf51_uart.h
 create mode 100644 hw/char/nrf51_uart.c
hw/char/Makefile.objs +1 -0
index b5705312910..c4947d7ae7b 100644
@@ -1,5 +1,6 @@
 common-obj-$(CONFIG_IPACK) += ipoctal232.o
 common-obj-$(CONFIG_ESCC) += escc.o
+common-obj-$(CONFIG_NRF51_SOC) += nrf51_uart.o
 common-obj-$(CONFIG_PARALLEL) += parallel.o
 common-obj-$(CONFIG_PARALLEL) += parallel-isa.o
 common-obj-$(CONFIG_PL011) += pl011.o
include/hw/char/nrf51_uart.h new file +78 -0

78 lines not on this page · raw message

hw/char/nrf51_uart.c new file +330 -0

330 lines not on this page · raw message

hw/char/trace-events +4 -0
index b64213d4dd1..de34a74399b 100644
@@ -73,3 +73,7 @@ cmsdk_apb_uart_receive(uint8_t c) "CMSDK APB UART: got character 0x%x from backe
 cmsdk_apb_uart_tx_pending(void) "CMSDK APB UART: character send to backend pending"
 cmsdk_apb_uart_tx(uint8_t c) "CMSDK APB UART: character 0x%x sent to backend"
 cmsdk_apb_uart_set_params(int speed) "CMSDK APB UART: params set to %d 8N1"
+
+# hw/char/nrf51_uart.c
+nrf51_uart_read(uint64_t addr, uint64_t r, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u"
+nrf51_uart_write(uint64_t addr, uint64_t value, unsigned int size) "addr 0x%" PRIx64 " value 0x%" PRIx64 " size %u"
Signature · 1 line
2.19.1
author Applied
#37 lore raw
In reply to Peter Maydell
Quoted 30 lines · Peter Maydell

This is a respin of my pull request from earlier this week:
* versal board compile failure fixed
* a few new patches:
- MAINTAINERS file fix
- use ARRAY_SIZE macro in xilinx_zynq
- avoid an array overrun in strongarm GPIO irq handling
- fix an assert running KVM on an aarch64-only host

The following changes since commit 69e2d03843412b9c076515b3aa9a71db161b6a1a:

Merge remote-tracking branch 'remotes/riscv/tags/riscv-for-master-3.1-sf1' into staging (2018-11-02 13:16:13 +0000)

are available in the Git repository at:

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

for you to fetch changes up to 6f16da53ffe4567c0353f85055df04860eb4e6fc:

hw/arm: versal: Add a virtual Xilinx Versal board (2018-11-02 14:11:31 +0000)

----------------------------------------------------------------
target-arm queue:
* microbit: Add the UART to our nRF51 SoC model
* Add a virtual Xilinx Versal board "xlnx-versal-virt"
* hw/arm/virt: Set VIRT_COMPAT_3_0 compat
* MAINTAINERS: Remove bouncing email in ARM ACPI
* strongarm: mask off high[31:28] bits from dir and state registers
* target/arm: Conditionalize some asserts on aarch32 support
* hw/arm/xilinx_zynq: Use the ARRAY_SIZE macro

Quoted 1 line

----------------------------------------------------------------

Applied, thanks.

-- PMM