hexagon system emu, part 3/3
cover hexagon system emu, part 3/3
hexagon architecture system emulation: part 3/3
This series contains some initial machine definitions, an interrupt controller device and a test case. Hexagon "Standalone OS" is used by the Hexagon SDK to create simple baremetal bootable programs that can be run on QEMU or the instruction set simulator included with the Hexagon SDK. These programs generally depend on semihosting support, which will come later.
Brian Cain (6):
hw/hexagon: Add machine configs for sysemu
hw/hexagon: Add v68, sa8775-cdsp0 defs
hw/hexagon: Modify "Standalone" symbols
target/hexagon: add build config for softmmu
hw/hexagon: Define hexagon "virt" machine
tests/functional: Add a hexagon minivm test
Sid Manning (2):
hw/intc: Add l2vic interrupt controller
hw/hexagon: Add support for cfgbase
MAINTAINERS | 6 + docs/devel/hexagon-l2vic.rst | 59 +++ docs/devel/index-internals.rst | 1 + configs/devices/hexagon-softmmu/default.mak | 8 + configs/targets/hexagon-softmmu.mak | 7 + qapi/machine.json | 2 +- include/hw/hexagon/hexagon.h | 151 +++++++ include/hw/hexagon/virt.h | 41 ++ include/hw/intc/l2vic.h | 37 ++ target/hexagon/cpu.h | 1 + hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 64 +++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 +++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 65 +++ hw/hexagon/hexagon_dsp.c | 202 ++++++++++ hw/hexagon/virt.c | 395 ++++++++++++++++++ hw/intc/l2vic.c | 417 ++++++++++++++++++++ target/hexagon/cpu.c | 8 +- target/hexagon/machine.c | 1 - hw/Kconfig | 1 + hw/hexagon/Kconfig | 14 + hw/hexagon/meson.build | 7 + hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + hw/meson.build | 1 + target/Kconfig | 1 + target/hexagon/Kconfig | 2 + target/hexagon/meson.build | 9 + tests/functional/meson.build | 8 + tests/functional/test_hexagon_minivm.py | 42 ++ 30 files changed, 1620 insertions(+), 3 deletions(-) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 include/hw/hexagon/hexagon.h create mode 100644 include/hw/hexagon/virt.h create mode 100644 include/hw/intc/l2vic.h create mode 100644 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc create mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644 hw/hexagon/machine_cfg_v68n_1024.h.inc create mode 100644 hw/hexagon/hexagon_dsp.c create mode 100644 hw/hexagon/virt.c create mode 100644 hw/intc/l2vic.c create mode 100644 hw/hexagon/Kconfig create mode 100644 hw/hexagon/meson.build create mode 100644 target/hexagon/Kconfig create mode 100755 tests/functional/test_hexagon_minivm.py
Signature · 1 line
2.34.1
PATCH 1/8 hw/intc: Add l2vic interrupt controller
From: Sid Manning <[email protected]>
--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 37 +++ hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 8 files changed, 525 insertions(+) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644 include/hw/intc/l2vic.h create mode 100644 hw/intc/l2vic.c
MAINTAINERS +2 -0
@@ -232,6 +232,7 @@ Hexagon TCG CPUs M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/l2vic.[ch] X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
@@ -242,6 +243,7 @@ F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/devel/hexagon-sys.rst +F: docs/devel/hexagon-l2vic.rst T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parser
docs/devel/hexagon-l2vic.rst new file +59 -0
59 lines not on this page · raw message
docs/devel/index-internals.rst +1 -0
@@ -15,6 +15,7 @@ Details about QEMU's various subsystems including how to add features to them. clocks ebpf_rss hexagon-sys + hexagon-l2vic migration/index multi-process reset
include/hw/intc/l2vic.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#define L2VIC_VID_GRP_0 0x0/* Read */ +#define L2VIC_VID_GRP_1 0x4/* Read */ +#define L2VIC_VID_GRP_2 0x8/* Read */ +#define L2VIC_VID_GRP_3 0xC/* Read */ +#define L2VIC_VID_0 0x10/* Read SOFTWARE DEFINED */ +#define L2VIC_VID_1 0x14/* Read SOFTWARE DEFINED NOT YET USED */ +#define L2VIC_INT_ENABLEn 0x100/* Read/Write */ +#define L2VIC_INT_ENABLE_CLEARn 0x180/* Write */ +#define L2VIC_INT_ENABLE_SETn 0x200/* Write */ +#define L2VIC_INT_TYPEn 0x280/* Read/Write */ +#define L2VIC_INT_STATUSn 0x380/* Read */ +#define L2VIC_INT_CLEARn 0x400/* Write */ +#define L2VIC_SOFT_INTn 0x480/* Write */ +#define L2VIC_INT_PENDINGn 0x500/* Read */ +#define L2VIC_INT_GRPn_0 0x600/* Read/Write */ +#define L2VIC_INT_GRPn_1 0x680/* Read/Write */ +#define L2VIC_INT_GRPn_2 0x700/* Read/Write */ +#define L2VIC_INT_GRPn_3 0x780/* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +#define L2VIC_CIAD_INSTRUCTION -1 +/* +* Note about l2vic groups: +* Each interrupt to L2VIC can be configured to associate with one of +* four groups. +* Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) +* Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) +* Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) +* Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) +*/
hw/intc/l2vic.c new file +417 -0
417 lines not on this page · raw message
hw/intc/Kconfig +3 -0
@@ -8,6 +8,9 @@ config I8259 config PL190 bool +config L2VIC + bool + config IOAPIC bool select I8259
hw/intc/meson.build +2 -0
@@ -67,6 +67,8 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) + +specific_ss.add(when: 'CONFIG_L2VIC', if_true: files('l2vic.c')) specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI_COMMON', if_true: files('loongson_ipi_common.c')) specific_ss.add(when: 'CONFIG_LOONGSON_IPI', if_true: files('loongson_ipi.c'))
hw/intc/trace-events +4 -0
@@ -303,6 +303,10 @@ sh_intc_register(const char *s, int id, unsigned short v, int c, int m) "%s %u - sh_intc_read(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " -> 0x%lx" sh_intc_write(unsigned size, uint64_t offset, unsigned long val) "size %u 0x%" PRIx64 " <- 0x%lx" sh_intc_set(int id, int enable) "setting interrupt group %d to %d" +# l2vic.c +l2vic_reg_write(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +l2vic_reg_read(unsigned int addr, uint32_t value) "addr: 0x%03x value: 0x%08"PRIx32 +l2vic_delivered(int irq, int vid) "l2vic: delivered %d (vid %d)" # loongson_ipi.c loongson_ipi_read(unsigned size, uint64_t addr, uint64_t val) "size: %u addr: 0x%"PRIx64 "val: 0x%"PRIx64
Signature · 1 line
2.34.1
Re: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
Hi Brian and Sid,
Quoted 37 lines · Brian Cain
From: Sid Manning <[email protected]>
Co-authored-by Matheus Tavares Bernardino <[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 37 +++ hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 8 files changed, 525 insertions(+)create mode 100644
docs/devel/hexagon-l2vic.rst
create mode 100644include/hw/intc/l2vic.h
create mode 100644hw/intc/l2vic.chw/intc/l2vic.c new file +11
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference. +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h"
hw/intc/l2vic.c line 21
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h" +#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC)
Why not use OBJECT_DECLARE_SIMPLE_TYPE()?
Quoted 29 lines
hw/intc/l2vic.c new file +29
-0+ +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0; + /* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); + /* Enable interrupt source */ + uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); + /* Clear (set to 0) corresponding bit in int_enable */ + uint32_t int_enable_clear; + /* Set (to 1) corresponding bit in int_enable */ + uint32_t int_enable_set; + /* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16); + /* Generate an interrupt */ + uint32_t int_soft; + /* Which enabled interrupt is active */
hw/intc/l2vic.c line 60
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+ uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); +/* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); +/* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); +qemu_irq irq[8 ]; +} L2VICState;
OBJECT_DECLARE_SIMPLE_TYPE(L2VICState, L2VIC)
hw/intc/l2vic.c line 105
Quoted 6 lines
hw/intc/l2vic.c new file +6
-0+static inline bool vid_active (L2VICState *s) + +{ +/* scan all 1024 bits in int_status arrary */ +const int size =sizeof (s->int_status) *CHAR_BIT ; +const int active_irq =find_first_bit ((unsigned long *)s->int_status, size);
Maybe this file could leverage the 32-bit bitops.h API:
$ git grep bit32\( include/qemu/bitops.h include/qemu/bitops.h:38: * - Bits stored in an array of 'uint32_t': set_bit32(), clear_bit32(), etc include/qemu/bitops.h:270:static inline void set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:296:static inline void clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:322:static inline void change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:335:static inline int test_and_set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:350:static inline int test_and_clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:365:static inline int test_and_change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:380:static inline int test_bit32(long nr, const uint32_t *addr)
Quoted 28 lines
hw/intc/l2vic.c new file +28
-0+return ((active_irq != size)) ? true : false; +} + +static bool l2vic_update (L2VICState *s,int irq) +{ +if (vid_active (s)) { +return true; + } + +bool pending =test_bit (irq, (unsigned long *)s->int_pending); +bool enable =test_bit (irq, (unsigned long *)s->int_enable); +if (pending && enable) { +int vid =get_vid (s, irq); +set_bit (irq, (unsigned long *)s->int_status); +clear_bit (irq, (unsigned long *)s->int_pending); +clear_bit (irq, (unsigned long *)s->int_enable); +/* ensure the irq line goes low after going high */ + s->vid0 = irq; + s->vid_group[get_vid (s, irq)] = irq; + +/* already low: now call pulse */ +/* pulse: calls qemu_upper() and then qemu_lower()) */ +qemu_irq_pulse (s->irq[vid +2 ]); +trace_l2vic_delivered (irq, vid); +return true; + } +return false; +}
Re: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
Quoted 46 lines · Philippe Mathieu-Daudé
Hi Brian and Sid,
Quoted 43 lines · Brian Cain
From: Sid Manning <[email protected]>
Co-authored-by Matheus Tavares Bernardino <[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++docs/devel/index-internals.rst| 1 + include/hw/intc/l2vic.h | 37 +++
hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 +
hw/intc/meson.build | 2 + hw/intc/trace-events | 4 +8 files changed, 525 insertions(+)create mode 100644
docs/devel/hexagon-l2vic.rst
create mode 100644include/hw/intc/l2vic.h
create mode 100644hw/intc/l2vic.chw/intc/l2vic.c new file +4
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference.
+ * Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */hw/intc/l2vic.c new file +8
-0+ +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h"
Quoted 9 lines
hw/intc/l2vic.c line 21
Quoted 6 lines
hw/intc/l2vic.c new file +6
-0+#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC)Why not use
OBJECT_DECLARE_SIMPLE_TYPE()?
Will do, thanks.
Quoted 53 lines
Quoted 29 lines
hw/intc/l2vic.c new file +29
-0+ +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0; + /* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); + /* Enable interrupt source */ + uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); + /* Clear (set to 0) corresponding bit in int_enable */ + uint32_t int_enable_clear; + /* Set (to 1) corresponding bit in int_enable */ + uint32_t int_enable_set; + /* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16); + /* Generate an interrupt */ + uint32_t int_soft; + /* Which enabled interrupt is active */hw/intc/l2vic.c line 60
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+ uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); + /* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); + /* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); + qemu_irq irq[8]; +} L2VICState;
OBJECT_DECLARE_SIMPLE_TYPE(L2VICState, L2VIC)Quoted 7 lines
hw/intc/l2vic.c new file +6
-0+static inline bool vid_active (L2VICState *s) + +{ + /* scan all 1024 bits in int_status arrary */ + const int size = sizeof(s->int_status) * CHAR_BIT; + const int active_irq = find_first_bit((unsigned long*)s->int_status, size);
Maybe this file could leverage the 32-bit
bitops.hAPI:
Quoted 10 lines
$ git grep bit32\( include/qemu/bitops.h include/qemu/bitops.h:38: * - Bits stored in an array of 'uint32_t': set_bit32(), clear_bit32(), etc include/qemu/bitops.h:270:static inline void set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:296:static inline void clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:322:static inline void change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:335:static inline int test_and_set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:350:static inline int test_and_clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:365:static inline int test_and_change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:380:static inline int test_bit32(long nr, const uint32_t *addr)
I think your suggestion is based on the fact the state to hold the interrupt status (et al) were declared as uint32_t arrays. But in fact it might be clearer to take Taylor's suggestion from this thread and use DECLARE_BITMAP() instead?
In which case, perhaps the call to find_first_bit() could remain?
Quoted 29 lines
Quoted 28 lines
+ return ((
active_irq!= size)) ? true : false;hw/intc/l2vic.c new file +27
-0+} + +static bool l2vic_update (L2VICState *s,int irq) +{ + if (vid_active(s)) { + return true; + } + + bool pending = test_bit(irq, (unsigned long *)s->int_pending); + bool enable = test_bit(irq, (unsigned long *)s->int_enable); + if (pending && enable) { + int vid = get_vid(s, irq); + set_bit(irq, (unsigned long *)s->int_status); + clear_bit(irq, (unsigned long *)s->int_pending); + clear_bit(irq, (unsigned long *)s->int_enable); + /* ensure the irq line goes low after going high */ + s->vid0 = irq; + s->vid_group[get_vid(s, irq)] = irq; + + /* already low: now call pulse */ + /* pulse: calls qemu_upper() and then qemu_lower()) */ + qemu_irq_pulse(s->irq[vid + 2]); + trace_l2vic_delivered(irq, vid); + return true; + } + return false; +}
Re: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
In reply to Philippe Mathieu-DaudéQuoted 46 lines · Philippe Mathieu-Daudé
Hi Brian and Sid,
Quoted 43 lines · Brian Cain
From: Sid Manning <[email protected]>
Co-authored-by Matheus Tavares Bernardino <[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++docs/devel/index-internals.rst| 1 + include/hw/intc/l2vic.h | 37 +++
hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 +
hw/intc/meson.build | 2 + hw/intc/trace-events | 4 +8 files changed, 525 insertions(+)create mode 100644
docs/devel/hexagon-l2vic.rst
create mode 100644include/hw/intc/l2vic.h
create mode 100644hw/intc/l2vic.chw/intc/l2vic.c new file +4
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference.
+ * Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */hw/intc/l2vic.c new file +8
-0+ +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h"
Quoted 9 lines
hw/intc/l2vic.c line 21
Quoted 6 lines
hw/intc/l2vic.c new file +6
-0+#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC)Why not use
OBJECT_DECLARE_SIMPLE_TYPE()?
Great suggestion, ty. Will do.
Quoted 53 lines
Quoted 29 lines
hw/intc/l2vic.c new file +29
-0+ +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0; + /* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); + /* Enable interrupt source */ + uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); + /* Clear (set to 0) corresponding bit in int_enable */ + uint32_t int_enable_clear; + /* Set (to 1) corresponding bit in int_enable */ + uint32_t int_enable_set; + /* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16); + /* Generate an interrupt */ + uint32_t int_soft; + /* Which enabled interrupt is active */hw/intc/l2vic.c line 60
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+ uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); + /* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); + /* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); + qemu_irq irq[8]; +} L2VICState;
OBJECT_DECLARE_SIMPLE_TYPE(L2VICState, L2VIC)Quoted 7 lines
hw/intc/l2vic.c new file +6
-0+static inline bool vid_active (L2VICState *s) + +{ + /* scan all 1024 bits in int_status arrary */ + const int size = sizeof(s->int_status) * CHAR_BIT; + const int active_irq = find_first_bit((unsigned long*)s->int_status, size);
Maybe this file could leverage the 32-bit
bitops.hAPI:
Quoted 10 lines
$ git grep bit32\( include/qemu/bitops.h include/qemu/bitops.h:38: * - Bits stored in an array of 'uint32_t': set_bit32(), clear_bit32(), etc include/qemu/bitops.h:270:static inline void set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:296:static inline void clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:322:static inline void change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:335:static inline int test_and_set_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:350:static inline int test_and_clear_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:365:static inline int test_and_change_bit32(long nr, uint32_t *addr) include/qemu/bitops.h:380:static inline int test_bit32(long nr, const uint32_t *addr)
Okay - I will make this change.
There's several places in the code today where we do this L2VICA() macro to assign all of the bits to/from a single uint32_t word. And if we take your and Taylor's suggestion to use the DECLARE_BITMAP32, we can probably change these to use bitmap_copy_with_{src,dst}_offset() instead, I think?
Quoted 29 lines
Quoted 28 lines
+ return ((
active_irq!= size)) ? true : false;hw/intc/l2vic.c new file +27
-0+} + +static bool l2vic_update (L2VICState *s,int irq) +{ + if (vid_active(s)) { + return true; + } + + bool pending = test_bit(irq, (unsigned long *)s->int_pending); + bool enable = test_bit(irq, (unsigned long *)s->int_enable); + if (pending && enable) { + int vid = get_vid(s, irq); + set_bit(irq, (unsigned long *)s->int_status); + clear_bit(irq, (unsigned long *)s->int_pending); + clear_bit(irq, (unsigned long *)s->int_enable); + /* ensure the irq line goes low after going high */ + s->vid0 = irq; + s->vid_group[get_vid(s, irq)] = irq; + + /* already low: now call pulse */ + /* pulse: calls qemu_upper() and then qemu_lower()) */ + qemu_irq_pulse(s->irq[vid + 2]); + trace_l2vic_delivered(irq, vid); + return true; + } + return false; +}
RE: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
In reply to Brian CainQuoted 38 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Damien Hedde <[email protected]>; Paolo Bonzini <[email protected]>
Subject: [PATCH 1/8] hw/intc: Add l2vic interrupt controllerFrom: Sid Manning <[email protected]>
Co-authored-by: Matheus Tavares Bernardino
<[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 37 +++ hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 8 files changed, 525 insertions(+) create mode 100644 docs/devel/hexagon-l2vic.rst create mode 100644
include/hw/intc/l2vic.hcreate mode 100644hw/intc/l2vic.cMAINTAINERS +0
-0
MAINTAINERS Hexagon TCG CPUs · line 235
Quoted 4 lines
MAINTAINERS +1
-0@@ -232,6 +232,7 @@ Hexagon TCG CPUs M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/l2vic.[ch]
Consider naming all the files outside target/hexagon as hex_* or hexagon_*
That will make it clear they belong to hexagon and you can use an easy wild card in the MAINTAINERS file. Ditto for the docs files.
Quoted 86 lines
MAINTAINERS +0
-0X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/include/hw/intc/l2vic.h new file mode renamed from include/hw/intc/l2vic.h +0
-0100644 index 0000000000..ed8ccf33b1
include/hw/intc/l2vic.h new file +4
-0@@ -0,0 +1,37 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */include/hw/intc/l2vic.h new file +9
-0+ +#define L2VIC_VID_GRP_0 0x0/* Read */ +#define L2VIC_VID_GRP_1 0x4/* Read */ +#define L2VIC_VID_GRP_2 0x8/* Read */ +#define L2VIC_VID_GRP_3 0xC/* Read */ +#define L2VIC_VID_0 0x10/* Read SOFTWARE DEFINED */ #define +L2VIC_VID_1 0x14/* Read SOFTWARE DEFINED NOT YET USED */ #define +L2VIC_INT_ENABLEn 0x100 /* Read/Write */ #define +L2VIC_INT_ENABLE_CLEARn 0x180 /* Write */ #define
L2VIC_INT_ENABLE_SETn
+0x200 /* Write */ #defineL2VIC_INT_TYPEn0x280/* Read/Write */include/hw/intc/l2vic.h new file +3
-0+#define L2VIC_INT_STATUSn 0x380/* Read */ #define L2VIC_INT_CLEARn +0x400 /* Write */ #define L2VIC_SOFT_INTn 0x480 /* Write */ #define +L2VIC_INT_PENDINGn 0x500/* Read */ #define L2VIC_INT_GRPn_0 0x600/*
include/hw/intc/l2vic.h new file +2
-0+Read/Write */ #define L2VIC_INT_GRPn_1 0x680/* Read/Write */ #define +L2VIC_INT_GRPn_2 0x700/* Read/Write */ #define L2VIC_INT_GRPn_3
0x780include/hw/intc/l2vic.h new file +12
-0+/* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +#define L2VIC_CIAD_INSTRUCTION -1 +/* +* Note about l2vic groups: +* Each interrupt to L2VIC can be configured to associate with one of +* four groups. +* Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) +* Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) +* Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) +* Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) */ hw/intc/l2vic.c new file mode 100644 index renamed from hw/intc/l2vic.c +0
-00000000000..9df6575214
hw/intc/l2vic.c new file +5
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference. +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */hw/intc/l2vic.c new file +30
-0+ +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h" +#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC) + +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0;
hw/intc/l2vic.c line 47
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+/* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); +/* Enable interrupt source */ + uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); +/* Clear (set to 0) corresponding bit in int_enable */ +uint32_t int_enable_clear; +/* Set (to 1) corresponding bit in int_enable */ +uint32_t int_enable_set; +/* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16);
Consider using DECLARE_BITMAP32 since you use test_bit/set_bit/clear_bit. Are these alignments needed?
Quoted 13 lines
hw/intc/l2vic.c new file +13
-0+/* Generate an interrupt */ +uint32_t int_soft; +/* Which enabled interrupt is active */ + uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); +/* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); +/* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); +qemu_irq irq[8 ]; +} L2VICState;
hw/intc/l2vic.c
Quoted 10 lines
hw/intc/l2vic.c new file +7
-0+ + +static void l2vic_set_irq (void *opaque,int irq,int level) { +L2VICState *s = (L2VICState *)opaque; +if (level) { +qemu_mutex_lock (&s->active); +set_bit (irq, (unsigned long *)s->int_pending);
Here's an example of the set_bit mentioned above.
Quoted 9 lines
hw/intc/l2vic.c new file +9
-0+qemu_mutex_unlock (&s->active); + } +l2vic_update (s, irq); +} + +static void l2vic_reset_hold (Object *obj,G_GNUC_UNUSED ResetType +res_type) { +L2VICState *s =L2VIC (obj); +memset (s->int_clear,0 ,sizeof (s->int_clear));
hw/intc/l2vic.c line 334
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+memset (s->int_enable,0 ,sizeof (s->int_enable)); +memset (s->int_pending,0 ,sizeof (s->int_pending)); +memset (s->int_status,0 ,sizeof (s->int_status)); +memset (s->int_type,0 ,sizeof (s->int_type)); +memset (s->int_group_n0,0 ,sizeof (s->int_group_n0)); +memset (s->int_group_n1,0 ,sizeof (s->int_group_n1)); +memset (s->int_group_n2,0 ,sizeof (s->int_group_n2)); +memset (s->int_group_n3,0 ,sizeof (s->int_group_n3)); + s->int_soft =0 ; + s->vid0 =0 ;
How about a single memset(s, 0, sizeof(L2VICState))?
Quoted 3 lines
hw/intc/l2vic.c new file +3
-0+ +l2vic_update_all (s); +}
Re: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
Quoted 32 lines · On 3/24/2025 2:40 PM, [email protected] wrote:
Quoted 32 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Damien Hedde <[email protected]>; Paolo Bonzini <[email protected]>
Subject: [PATCH 1/8] hw/intc: Add l2vic interrupt controllerFrom: Sid Manning <[email protected]>
Co-authored-by: Matheus Tavares Bernardino
<[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 37 +++ hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 8 files changed, 525 insertions(+)create mode 100644
docs/devel/hexagon-l2vic.rstcreate mode 100644include/hw/intc/l2vic.hcreate mode 100644hw/intc/l2vic.c
Quoted 12 lines
MAINTAINERS Hexagon TCG CPUs · line 235
Quoted 9 lines
MAINTAINERS +1
-0@@ -232,6 +232,7 @@ Hexagon TCG CPUs M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/l2vic.[ch]Consider naming all the files outside target/hexagon as hex_* or hexagon_*
That will make it clear they belong to hexagon and you can use an easy wild card in theMAINTAINERSfile. Ditto for the docs files.
I'm not sure we can do this in all cases. Devices aren't necessarily bound to one particular architecture. Of course, for interrupt controllers in all practical terms they are bound to an architecture. So sure - we can make it hex_l2vic.*
But for example for the QTimer device (yet to be sent to the list for review), that wouldn't make sense IMO.
Quoted 147 lines
Quoted 86 lines
MAINTAINERS +0
-0X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/include/hw/intc/l2vic.h new file mode renamed from include/hw/intc/l2vic.h +0
-0100644 index 0000000000..ed8ccf33b1
include/hw/intc/l2vic.h new file +4
-0@@ -0,0 +1,37 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */include/hw/intc/l2vic.h new file +9
-0+ +#define L2VIC_VID_GRP_0 0x0/* Read */ +#define L2VIC_VID_GRP_1 0x4/* Read */ +#define L2VIC_VID_GRP_2 0x8/* Read */ +#define L2VIC_VID_GRP_3 0xC/* Read */ +#define L2VIC_VID_0 0x10/* Read SOFTWARE DEFINED */ #define +L2VIC_VID_1 0x14/* Read SOFTWARE DEFINED NOT YET USED */ #define +L2VIC_INT_ENABLEn 0x100 /* Read/Write */ #define +L2VIC_INT_ENABLE_CLEARn 0x180 /* Write */ #define
L2VIC_INT_ENABLE_SETn
+0x200 /* Write */ #defineL2VIC_INT_TYPEn0x280/* Read/Write */include/hw/intc/l2vic.h new file +3
-0+#define L2VIC_INT_STATUSn 0x380/* Read */ #define L2VIC_INT_CLEARn +0x400 /* Write */ #define L2VIC_SOFT_INTn 0x480 /* Write */ #define +L2VIC_INT_PENDINGn 0x500/* Read */ #define L2VIC_INT_GRPn_0 0x600/*
include/hw/intc/l2vic.h new file +2
-0+Read/Write */ #define L2VIC_INT_GRPn_1 0x680/* Read/Write */ #define +L2VIC_INT_GRPn_2 0x700/* Read/Write */ #define L2VIC_INT_GRPn_3
0x780include/hw/intc/l2vic.h new file +12
-0+/* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +#define L2VIC_CIAD_INSTRUCTION -1 +/* +* Note about l2vic groups: +* Each interrupt to L2VIC can be configured to associate with one of +* four groups. +* Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) +* Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) +* Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) +* Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) */ hw/intc/l2vic.c new file mode 100644 index renamed from hw/intc/l2vic.c +0
-00000000000..9df6575214
hw/intc/l2vic.c new file +5
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference. +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */hw/intc/l2vic.c new file +30
-0+ +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h" +#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC) + +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0;hw/intc/l2vic.c line 47
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+/* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); +/* Enable interrupt source */ + uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); +/* Clear (set to 0) corresponding bit in int_enable */ +uint32_t int_enable_clear; +/* Set (to 1) corresponding bit in int_enable */ +uint32_t int_enable_set; +/* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16);Consider using
DECLARE_BITMAP32since you use test_bit/set_bit/clear_bit. Are these alignments needed?Quoted 12 lines
hw/intc/l2vic.c new file +12
-0+/* Generate an interrupt */ +uint32_t int_soft; +/* Which enabled interrupt is active */ + uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); +/* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); +/* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); +qemu_irq irq[8 ];hw/intc/l2vic.c
Quoted 10 lines
hw/intc/l2vic.c new file +8
-0+} L2VICState; + + +static void l2vic_set_irq (void *opaque,int irq,int level) { +L2VICState *s = (L2VICState *)opaque; +if (level) { +qemu_mutex_lock (&s->active); +set_bit (irq, (unsigned long *)s->int_pending);Here's an example of the
set_bitmentioned above.Quoted 9 lines
hw/intc/l2vic.c new file +9
-0+qemu_mutex_unlock (&s->active); + } +l2vic_update (s, irq); +} + +static void l2vic_reset_hold (Object *obj,G_GNUC_UNUSED ResetType +res_type) { +L2VICState *s =L2VIC (obj); +memset (s->int_clear,0 ,sizeof (s->int_clear));hw/intc/l2vic.c line 334
Quoted 10 lines
hw/intc/l2vic.c new file +10
-0+memset (s->int_enable,0 ,sizeof (s->int_enable)); +memset (s->int_pending,0 ,sizeof (s->int_pending)); +memset (s->int_status,0 ,sizeof (s->int_status)); +memset (s->int_type,0 ,sizeof (s->int_type)); +memset (s->int_group_n0,0 ,sizeof (s->int_group_n0)); +memset (s->int_group_n1,0 ,sizeof (s->int_group_n1)); +memset (s->int_group_n2,0 ,sizeof (s->int_group_n2)); +memset (s->int_group_n3,0 ,sizeof (s->int_group_n3)); + s->int_soft =0 ; + s->vid0 =0 ;How about a single
memset(s, 0, sizeof(L2VICState))?Quoted 3 lines
hw/intc/l2vic.c new file +3
-0+ +l2vic_update_all (s); +}
Re: [PATCH 1/8] hw/intc: Add l2vic interrupt controller
In reply to [email protected]Quoted 32 lines · On 3/24/2025 2:40 PM, [email protected] wrote:
Quoted 32 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Damien Hedde <[email protected]>; Paolo Bonzini <[email protected]>
Subject: [PATCH 1/8] hw/intc: Add l2vic interrupt controllerFrom: Sid Manning <[email protected]>
Co-authored-by: Matheus Tavares Bernardino
<[email protected]>Co-authored-by Damien Hedde <[email protected]>Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 2 + docs/devel/hexagon-l2vic.rst | 59 +++++ docs/devel/index-internals.rst | 1 + include/hw/intc/l2vic.h | 37 +++ hw/intc/l2vic.c | 417 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 2 + hw/intc/trace-events | 4 + 8 files changed, 525 insertions(+)create mode 100644
docs/devel/hexagon-l2vic.rstcreate mode 100644include/hw/intc/l2vic.hcreate mode 100644hw/intc/l2vic.c
Quoted 12 lines
MAINTAINERS Hexagon TCG CPUs · line 235
Quoted 9 lines
MAINTAINERS +1
-0@@ -232,6 +232,7 @@ Hexagon TCG CPUs M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ +F: hw/intc/l2vic.[ch]Consider naming all the files outside target/hexagon as hex_* or hexagon_*
That will make it clear they belong to hexagon and you can use an easy wild card in theMAINTAINERSfile. Ditto for the docs files.
Ok - I will rename l2vic hex_l2vic in v3.
Quoted 89 lines
Quoted 89 lines
MAINTAINERS +0
-0X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/include/hw/intc/l2vic.h new file mode renamed from include/hw/intc/l2vic.h +0
-0100644 index 0000000000..ed8ccf33b1
include/hw/intc/l2vic.h new file +4
-0@@ -0,0 +1,37 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */include/hw/intc/l2vic.h new file +9
-0+ +#define L2VIC_VID_GRP_0 0x0/* Read */ +#define L2VIC_VID_GRP_1 0x4/* Read */ +#define L2VIC_VID_GRP_2 0x8/* Read */ +#define L2VIC_VID_GRP_3 0xC/* Read */ +#define L2VIC_VID_0 0x10/* Read SOFTWARE DEFINED */ #define +L2VIC_VID_1 0x14/* Read SOFTWARE DEFINED NOT YET USED */ #define +L2VIC_INT_ENABLEn 0x100 /* Read/Write */ #define +L2VIC_INT_ENABLE_CLEARn 0x180 /* Write */ #define
L2VIC_INT_ENABLE_SETn
+0x200 /* Write */ #defineL2VIC_INT_TYPEn0x280/* Read/Write */include/hw/intc/l2vic.h new file +3
-0+#define L2VIC_INT_STATUSn 0x380/* Read */ #define L2VIC_INT_CLEARn +0x400 /* Write */ #define L2VIC_SOFT_INTn 0x480 /* Write */ #define +L2VIC_INT_PENDINGn 0x500/* Read */ #define L2VIC_INT_GRPn_0 0x600/*
include/hw/intc/l2vic.h new file +2
-0+Read/Write */ #define L2VIC_INT_GRPn_1 0x680/* Read/Write */ #define +L2VIC_INT_GRPn_2 0x700/* Read/Write */ #define L2VIC_INT_GRPn_3
0x780include/hw/intc/l2vic.h new file +12
-0+/* Read/Write */ + +#define L2VIC_INTERRUPT_MAX 1024 +#define L2VIC_CIAD_INSTRUCTION -1 +/* +* Note about l2vic groups: +* Each interrupt to L2VIC can be configured to associate with one of +* four groups. +* Group 0 interrupts go to IRQ2 via VID 0 (SSR: 0xC2, the default) +* Group 1 interrupts go to IRQ3 via VID 1 (SSR: 0xC3) +* Group 2 interrupts go to IRQ4 via VID 2 (SSR: 0xC4) +* Group 3 interrupts go to IRQ5 via VID 3 (SSR: 0xC5) */ hw/intc/l2vic.c new file mode 100644 index renamed from hw/intc/l2vic.c +0
-00000000000..9df6575214
hw/intc/l2vic.c new file +5
-0@@ -0,0 +1,417 @@ +/* +* QEMU L2VIC Interrupt Controller +* +* Arm PrimeCell PL190 Vector Interrupt Controller was used as a reference. +* Copyright(c) 2020-2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
+ * SPDX-License-Identifier: GPL-2.0-or-later */hw/intc/l2vic.c new file +33
-0+ +#include "qemu/osdep.h" +#include "hw/irq.h" +#include "hw/sysbus.h" +#include "migration/vmstate.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "hw/intc/l2vic.h" +#include "trace.h" + +#define L2VICA (s, n) (s[(n) >> 2]) + +#define TYPE_L2VIC "l2vic" +#define L2VIC (obj) OBJECT_CHECK(L2VICState, (obj), TYPE_L2VIC) + +#define SLICE_MAX (L2VIC_INTERRUPT_MAX / 32) + +typedef struct L2VICState { + SysBusDevice parent_obj; + + QemuMutex active; + MemoryRegion iomem; + MemoryRegion fast_iomem; + uint32_t level; + /* + * offset 0:vid group 0 etc, 10 bits in each group + * are used: + */ + uint32_t vid_group[4]; + uint32_t vid0; + /* Clear Status of Active Edge interrupt, not used: */ + uint32_t int_clear[SLICE_MAX] QEMU_ALIGNED(16); + /* Enable interrupt source */
Quoted 8 lines
hw/intc/l2vic.c line 47
Quoted 7 lines
hw/intc/l2vic.c new file +7
-0+ uint32_t int_enable[SLICE_MAX] QEMU_ALIGNED(16); +/* Clear (set to 0) corresponding bit in int_enable */ +uint32_t int_enable_clear; +/* Set (to 1) corresponding bit in int_enable */ +uint32_t int_enable_set; +/* Present for debugging, not used */ + uint32_t int_pending[SLICE_MAX] QEMU_ALIGNED(16);Consider using
DECLARE_BITMAP32since you use test_bit/set_bit/clear_bit.
Ok, will be fixed in v3.
Quoted 1 line
Are these alignments needed?
The assignments below resulted in unaligned accesses which were flagged by UBSan. We'll revisit whether or not the alignments are necessary after making the other suggested changes for v3 and we'll ideally omit them.
Quoted 36 lines
Quoted 12 lines
hw/intc/l2vic.c new file +12
-0+/* Generate an interrupt */ +uint32_t int_soft; +/* Which enabled interrupt is active */ + uint32_t int_status[SLICE_MAX] QEMU_ALIGNED(16); +/* Edge or Level interrupt */ + uint32_t int_type[SLICE_MAX] QEMU_ALIGNED(16); +/* L2 interrupt group 0-3 0x600-0x7FF */ + uint32_t int_group_n0[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n1[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n2[SLICE_MAX] QEMU_ALIGNED(16); + uint32_t int_group_n3[SLICE_MAX] QEMU_ALIGNED(16); +qemu_irq irq[8 ];hw/intc/l2vic.c
Quoted 10 lines
hw/intc/l2vic.c new file +8
-0+} L2VICState; + + +static void l2vic_set_irq (void *opaque,int irq,int level) { +L2VICState *s = (L2VICState *)opaque; +if (level) { +qemu_mutex_lock (&s->active); +set_bit (irq, (unsigned long *)s->int_pending);Here's an example of the
set_bitmentioned above.Quoted 12 lines
hw/intc/l2vic.c new file +12
-0+qemu_mutex_unlock (&s->active); + } +l2vic_update (s, irq); +} + +static void l2vic_reset_hold (Object *obj,G_GNUC_UNUSED ResetType +res_type) { +L2VICState *s =L2VIC (obj); +memset (s->int_clear,0 ,sizeof (s->int_clear)); +memset (s->int_enable,0 ,sizeof (s->int_enable)); +memset (s->int_pending,0 ,sizeof (s->int_pending)); +memset (s->int_status,0 ,sizeof (s->int_status));
Quoted 8 lines
hw/intc/l2vic.c line 334
Quoted 7 lines
hw/intc/l2vic.c new file +7
-0+memset (s->int_type,0 ,sizeof (s->int_type)); +memset (s->int_group_n0,0 ,sizeof (s->int_group_n0)); +memset (s->int_group_n1,0 ,sizeof (s->int_group_n1)); +memset (s->int_group_n2,0 ,sizeof (s->int_group_n2)); +memset (s->int_group_n3,0 ,sizeof (s->int_group_n3)); + s->int_soft =0 ; + s->vid0 =0 ;How about a single
memset(s, 0, sizeof(L2VICState))?
Ok, will revisit this.
Quoted 3 lines
Quoted 3 lines
hw/intc/l2vic.c new file +3
-0+ +l2vic_update_all (s); +}
PATCH 2/8 hw/hexagon: Add machine configs for sysemu
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- MAINTAINERS | 2 + qapi/machine.json | 2 +- include/hw/hexagon/hexagon.h | 151 +++++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 +++++++++ hw/hexagon/hexagon_dsp.c | 177 +++++++++++++++++++++++++ target/hexagon/machine.c | 1 - hw/Kconfig | 1 + hw/hexagon/Kconfig | 6 + hw/hexagon/meson.build | 5 + hw/meson.build | 1 + 10 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 include/hw/hexagon/hexagon.h create mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644 hw/hexagon/hexagon_dsp.c create mode 100644 hw/hexagon/Kconfig create mode 100644 hw/hexagon/meson.build
MAINTAINERS +2 -0
@@ -233,6 +233,8 @@ M: Brian Cain <[email protected]> S: Supported F: target/hexagon/ F: hw/intc/l2vic.[ch] +F: hw/hexagon/ +F: include/hw/hexagon/ X: target/hexagon/idef-parser/ X: target/hexagon/gen_idef_parser_funcs.py F: linux-user/hexagon/
qapi/machine.json +1 -1
@@ -33,7 +33,7 @@ # Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hppa', 'i386', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386', 'loongarch64', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
include/hw/hexagon/hexagon.h new file +151 -0
151 lines not on this page · raw message
hw/hexagon/machine_cfg_v66g_1024.h.inc new file +64 -0
64 lines not on this page · raw message
hw/hexagon/hexagon_dsp.c new file +177 -0
177 lines not on this page · raw message
target/hexagon/machine.c +0 -1
@@ -79,7 +79,6 @@ const VMStateDescription vmstate_hexagon_cpu = { VMSTATE_UINT64(env.t_cycle_count, HexagonCPU), VMSTATE_POINTER(env.g_pcycle_base, HexagonCPU, 0, vmstate_info_uint64_ptr, uint64_t *), - VMSTATE_END_OF_LIST() }, };
hw/Kconfig +1 -0
@@ -65,6 +65,7 @@ source sparc/Kconfig source sparc64/Kconfig source tricore/Kconfig source xtensa/Kconfig +source hexagon/Kconfig # Symbols used by multiple targets config TEST_DEVICES
hw/hexagon/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +config HEX_DSP + bool + default y + depends on HEXAGON && TCG + imply PTIMER + select L2VIC # Vector PIC
hw/hexagon/meson.build new file +5 -0
@@ -0,0 +1,5 @@ +hexagon_ss = ss.source_set() +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c',)) + +hw_arch += {'hexagon': hexagon_ss} +
hw/meson.build +1 -0
@@ -64,3 +64,4 @@ subdir('sparc') subdir('sparc64') subdir('tricore') subdir('xtensa') +subdir('hexagon')
Signature · 1 line
2.34.1
Re: [PATCH 2/8] hw/hexagon: Add machine configs for sysemu
Quoted 5 lines · Brian Cain
From: Brian Cain <[email protected]>
Co-authored-by Mike Lambert <[email protected]>Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>
[...]
qapi/machine.json
Quoted 5 lines
qapi/machine.json +0
-0@@ -33,7 +33,7 @@
##
# @SysEmuTarget:
#
# The comprehensive enumeration of QEMU system emulation ("softmmu")
# targets. Run "./configure --help" in the project root directory, # and look for the \*-softmmu targets near the "--target-list" option. # The individual target constants are not documented here, for the # time being. # # @rx: since 5.0 # # @avr: since 5.1 # # @loongarch64: since 7.1 #
Please add a line "@hexagon: since 10.0".
# .. note:: The resulting QMP strings can be appended to the # "qemu-system-" prefix to produce the corresponding QEMU # executable name. This is true even for "qemu-system-x86_64". #
qapi/machine.json line 39
Quoted 8 lines
qapi/machine.json +1
-1# Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hppa', 'i386', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386', 'loongarch64', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',
[...]
With that doc fix
Re: [PATCH 2/8] hw/hexagon: Add machine configs for sysemu
Quoted 32 lines · Markus Armbruster
Quoted 5 lines · Brian Cain
From: Brian Cain <[email protected]>
Co-authored-by Mike Lambert <[email protected]>Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>[...]
qapi/machine.json
Quoted 5 lines
qapi/machine.json +0
-0@@ -33,7 +33,7 @@## # @SysEmuTarget: # # The comprehensive enumeration of QEMU system emulation ("softmmu") # targets. Run "./configure --help" in the project root directory, # and look for the \*-softmmu targets near the "--target-list" option. # The individual target constants are not documented here, for the # time being. # # @rx: since 5.0 # # @avr: since 5.1 # # @loongarch64: since 7.1 #
Quoted 1 line
Please add a line "@hexagon: since 10.0".
I don't think it will make the cutoff for 10.0. But ok, whichever one it's bound for. Thanks for catching it, the next revision will include this fix.
Quoted 17 lines
# .. note:: The resulting QMP strings can be appended to the # "qemu-system-" prefix to produce the corresponding QEMU # executable name. This is true even for "qemu-system-x86_64". #qapi/machine.json line 39
Quoted 8 lines
qapi/machine.json +1
-1# Since: 3.0 ## { 'enum' : 'SysEmuTarget', - 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hppa', 'i386', + 'data' : [ 'aarch64', 'alpha', 'arm', 'avr', 'hexagon', 'hppa', 'i386', 'loongarch64', 'm68k', 'microblaze', 'microblazeel', 'mips', 'mips64', 'mips64el', 'mipsel', 'or1k', 'ppc', 'ppc64', 'riscv32', 'riscv64', 'rx', 's390x', 'sh4',[...]
With that doc fix
RE: [PATCH 2/8] hw/hexagon: Add machine configs for sysemu
In reply to Brian CainQuoted 28 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Brian Cain <[email protected]>; Mike Lambert <[email protected]>; Paolo Bonzini <[email protected]>; Eduardo Habkost <[email protected]>; Marcel Apfelbaum <[email protected]>; Yanan Wang <[email protected]>; Zhao Liu <[email protected]>; Eric Blake <[email protected]>; Markus Armbruster <[email protected]>
Subject: [PATCH 2/8] hw/hexagon: Add machine configs for sysemuFrom: Brian Cain <[email protected]>
Co-authored-by Mike Lambert <[email protected]>Co-authored-by Sid Manning <[email protected]>Signed-off-by Brian Cain <[email protected]>hw/meson.build index renamed from hw/meson.build +0
-0
b827c82c5d..91969d6fec100644
hw/meson.build subdir('sparc') · line 67
Quoted 4 lines
hw/meson.build +1
-0@@ -64,3 +64,4 @@ subdir('sparc') subdir('sparc64') subdir('tricore') subdir('xtensa') +subdir('hexagon')
Keep this list in alphabetical order, move hexagon between avr and hppa.
Otherwise
PATCH 3/8 hw/hexagon: Add v68, sa8775-cdsp0 defs
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc | 64 ++++++++++++++++++++++ hw/hexagon/machine_cfg_v68n_1024.h.inc | 65 +++++++++++++++++++++++ 2 files changed, 129 insertions(+) create mode 100644 hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc create mode 100644 hw/hexagon/machine_cfg_v68n_1024.h.inc
hw/hexagon/machine_cfg_sa8775_cdsp0.h.inc new file +64 -0
@@ -0,0 +1,64 @@ + +static hexagon_machine_config SA8775P_cdsp0 = { + .cfgbase = 0x24000000 + 0x180000, + .l2tcm_size = 0x00000000, + .l2vic_base = 0x26300000 + 0x90000, + .l2vic_size = 0x00001000, + .csr_base = 0x26300000, + .qtmr_rg0 = 0x26300000 + 0xA1000, + .qtmr_rg1 = 0x26300000 + 0xA2000, + .cfgtable = { + .l2tcm_base = 0x00002400, + .reserved0 = 0x00000000, + .subsystem_base = 0x00002638, + .etm_base = 0x00002419, + .l2cfg_base = 0x0000241a, + .reserved1 = 0x0000241b, + .l1s0_base = 0x00002500, + .axi2_lowaddr = 0x00000000, + .streamer_base = 0x00000000, + .reserved2 = 0x00000000, + .fastl2vic_base = 0x0000241e, + .jtlb_size_entries = 0x00000080, + .coproc_present = 0x00000001, + .ext_contexts = 0x00000004, + .vtcm_base = 0x00002500, + .vtcm_size_kb = 0x00002000, + .l2tag_size = 0x00000400, + .l2ecomem_size = 0x00000000, + .thread_enable_mask = 0x0000003f, + .eccreg_base = 0x0000241f, + .l2line_size = 0x00000080, + .tiny_core = 0x00000000, + .l2itcm_size = 0x00000000, + .l2itcm_base = 0x00002400, + .reserved3 = 0x00000000, + .dtm_present = 0x00000000, + .dma_version = 0x00000003, + .hvx_vec_log_length = 0x00000007, + .core_id = 0x00000000, + .core_count = 0x00000000, + .coproc2_reg0 = 0x00000040, + .coproc2_reg1 = 0x00000020, + .v2x_mode = 0x00000001, + .coproc2_reg2 = 0x00000008, + .coproc2_reg3 = 0x00000020, + .coproc2_reg4 = 0x00000000, + .coproc2_reg5 = 0x00000002, + .coproc2_reg6 = 0x00000016, + .coproc2_reg7 = 0x00000006, + .acd_preset = 0x00000001, + .mnd_preset = 0x00000000, + .l1d_size_kb = 0x00000010, + .l1i_size_kb = 0x00000020, + .l1d_write_policy = 0x00000002, + .vtcm_bank_width = 0x00000080, + .reserved3 = 0x00000001, + .reserved4 = 0x00000000, + .reserved5 = 0x00000003, + .coproc2_cvt_mpy_size = 0x0000000a, + .consistency_domain = 0x000000e0, + .capacity_domain = 0x00000080, + .axi3_lowaddr = 0x00000000, + }, +};
hw/hexagon/machine_cfg_v68n_1024.h.inc new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.34.1
RE: [PATCH 3/8] hw/hexagon: Add v68, sa8775-cdsp0 defs
Quoted 13 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Brian Cain <[email protected]>
Subject: [PATCH 3/8] hw/hexagon: Add v68, sa8775-cdsp0 defs
Quoted 3 lines
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>
PATCH 4/8 hw/hexagon: Add support for cfgbase
In reply to Brian CainFrom: Sid Manning <[email protected]>
--- target/hexagon/cpu.h | 1 + hw/hexagon/hexagon_dsp.c | 10 ++++++++++ target/hexagon/cpu.c | 6 ++++++ 3 files changed, 17 insertions(+)
target/hexagon/cpu.h +1 -0
@@ -195,6 +195,7 @@ struct ArchCPU {uint32_t l2vic_base_addr;uint32_t hvx_contexts;uint32_t boot_addr; +uint64_t config_table_addr;#endif };
hw/hexagon/hexagon_dsp.c +10 -0
@@ -82,6 +82,12 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev,MemoryRegion *address_space =get_system_memory (); +MemoryRegion *config_table_rom =g_new (MemoryRegion,1 ); +memory_region_init_rom (config_table_rom,NULL ,"config_table.rom" , +sizeof (m_cfg->cfgtable), &error_fatal); +memory_region_add_subregion (address_space, m_cfg->cfgbase, + config_table_rom); +MemoryRegion *sram =g_new (MemoryRegion,1 );memory_region_init_ram (sram,NULL ,"ddr.ram" , machine->ram_size, &error_fatal);
@@ -130,6 +136,10 @@ static void hexagon_common_init(MachineState *machine, Rev_t rev, } } + +rom_add_blob_fixed_as ("config_table.rom" , &m_cfg->cfgtable, +sizeof (m_cfg->cfgtable), m_cfg->cfgbase, + &address_space_memory); }static void init_mc (MachineClass *mc)
target/hexagon/cpu.c +6 -0
@@ -67,6 +67,8 @@ static const Property hexagon_cpu_properties[] = { 0xffffffffULL),DEFINE_PROP_UINT32 ("hvx-contexts" , HexagonCPU, hvx_contexts,0 ),DEFINE_PROP_UINT32 ("exec-start-addr" , HexagonCPU, boot_addr,0xffffffffULL ), +DEFINE_PROP_UINT64 ("config-table-addr" , HexagonCPU, config_table_addr, +0xffffffffULL ), #endifDEFINE_PROP_BOOL ("lldb-compat" , HexagonCPU, lldb_compat, false), DEFINE_PROP_UNSIGNED("lldb-stack-adjust", HexagonCPU, lldb_stack_adjust, 0,
@@ -361,6 +363,8 @@ void hexagon_cpu_soft_reset(CPUHexagonState *env) }#endif + +#define HEXAGON_CFG_ADDR_BASE (addr) (((addr) >> 16) & 0x0fffff)static void hexagon_cpu_reset_hold (Object *obj,ResetType type) {CPUState *cs =CPU (obj);
@@ -401,6 +405,8 @@ static void hexagon_cpu_reset_hold(Object *obj, ResetType type) env->wait_next_pc =0 ; env->cause_code =-1 ;arch_set_thread_reg (env,HEX_REG_PC , cpu->boot_addr); +arch_set_system_reg (env,HEX_SREG_CFGBASE , +HEXAGON_CFG_ADDR_BASE (cpu->config_table_addr));#endif }
Signature · 1 line
2.34.1
RE: [PATCH 4/8] hw/hexagon: Add support for cfgbase
Quoted 13 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH 4/8] hw/hexagon: Add support for cfgbase
Quoted 3 lines
From: Sid Manning <[email protected]>
Signed-off-by Sid Manning <[email protected]>
PATCH 5/8 hw/hexagon: Modify "Standalone" symbols
In reply to Brian CainFrom: Brian Cain <[email protected]>
These symbols are used by Hexagon Standalone OS to indicate whether the program should halt and wait for interrupts at startup. For QEMU, we want these programs to just continue crt0 startup through to the user program's main().
--- hw/hexagon/hexagon_dsp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/hexagon/hexagon_dsp.c +15 -0
@@ -28,9 +28,17 @@#include "machine_cfg_v66g_1024.h.inc" +static hwaddr isdb_secure_flag; +static hwaddr isdb_trusted_flag;static void hex_symbol_callback (const char *st_name,int st_info,uint64_t st_value,uint64_t st_size) { +if (!g_strcmp0 ("isdb_secure_flag" , st_name)) { + isdb_secure_flag = st_value; + } +if (!g_strcmp0 ("isdb_trusted_flag" , st_name)) { + isdb_trusted_flag = st_value; + } }/* Board init. */
@@ -59,6 +67,13 @@ static void hexagon_init_bootstrap(MachineState *machine, HexagonCPU *cpu) {if (machine->kernel_filename) {hexagon_load_kernel (cpu); +uint32_t mem =1 ; +if (isdb_secure_flag) { +cpu_physical_memory_write (isdb_secure_flag, &mem,sizeof (mem)); + } +if (isdb_trusted_flag) { +cpu_physical_memory_write (isdb_trusted_flag, &mem,sizeof (mem)); + } } }
Signature · 1 line
2.34.1
RE: [PATCH 5/8] hw/hexagon: Modify "Standalone" symbols
Quoted 13 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Brian Cain <[email protected]>
Subject: [PATCH 5/8] hw/hexagon: Modify "Standalone" symbols
Quoted 8 lines
From: Brian Cain <[email protected]>
These symbols are used by Hexagon Standalone OS to indicate whether the program should halt and wait for interrupts at startup. For QEMU, we want these programs to just continue crt0 startup through to the user program's
main().Signed-off-by Brian Cain <[email protected]>
PATCH 6/8 target/hexagon: add build config for softmmu
In reply to Brian Cain--- MAINTAINERS | 1 + configs/devices/hexagon-softmmu/default.mak | 7 +++++++ configs/targets/hexagon-softmmu.mak | 6 ++++++ target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 9 +++++++++ 6 files changed, 26 insertions(+) create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 target/hexagon/Kconfig
MAINTAINERS +1 -0
@@ -241,6 +241,7 @@ F: linux-user/hexagon/ F: tests/tcg/hexagon/ F: disas/hexagon.c F: configs/targets/hexagon-linux-user/default.mak +F: configs/devices/hexagon-softmmu/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst
configs/devices/hexagon-softmmu/default.mak new file +7 -0
@@ -0,0 +1,7 @@ +# Default configuration for hexagon-softmmu + +# Uncomment the following lines to disable these optional devices: + +# Boards are selected by default, uncomment to keep out of the build. +# CONFIG_HEX_DSP=y +# CONFIG_L2VIC=y
configs/targets/hexagon-softmmu.mak new file +6 -0
@@ -0,0 +1,6 @@ +# Default configuration for hexagon-softmmu + +TARGET_ARCH=hexagon +TARGET_SUPPORTS_MTTCG=y +TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml +TARGET_LONG_BITS=32
target/Kconfig +1 -0
@@ -16,6 +16,7 @@ source sh4/Kconfig source sparc/Kconfig source tricore/Kconfig source xtensa/Kconfig +source hexagon/Kconfig config TARGET_BIG_ENDIAN bool
target/hexagon/Kconfig new file +2 -0
@@ -0,0 +1,2 @@ +config HEXAGON + bool
target/hexagon/meson.build +9 -0
@@ -245,6 +245,7 @@ decodetree_trans_funcs_generated = custom_target( command: [python, files('gen_trans_funcs.py'), semantics_generated, '@OUTPUT@'], ) hexagon_ss.add(decodetree_trans_funcs_generated) +hexagon_softmmu_ss = ss.source_set() hexagon_ss.add(files( 'cpu.c',
@@ -264,6 +265,13 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', )) +hexagon_softmmu_ss.add(files( + 'hex_mmu.c', + 'hex_interrupts.c', + 'hexswi.c', + 'machine.c', +)) + # # Step 4.5 # We use flex/bison based idef-parser to generate TCG code for a lot
@@ -401,3 +409,4 @@ analyze_funcs_generated = custom_target( hexagon_ss.add(analyze_funcs_generated) target_arch += {'hexagon': hexagon_ss} +target_system_arch += {'hexagon': hexagon_softmmu_ss}
Signature · 1 line
2.34.1
Re: [PATCH 6/8] target/hexagon: add build config for softmmu
Hi Brian,
Quoted 86 lines · Brian Cain
Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 1 + configs/devices/hexagon-softmmu/default.mak | 7 +++++++ configs/targets/hexagon-softmmu.mak | 6 ++++++ target/Kconfig | 1 + target/hexagon/Kconfig | 2 ++ target/hexagon/meson.build | 9 +++++++++ 6 files changed, 26 insertions(+)create mode 100644 configs/devices/hexagon-softmmu/default.mak create mode 100644 configs/targets/hexagon-softmmu.mak create mode 100644 target/hexagon/Kconfig
MAINTAINERS +1
-0@@ -241,6 +241,7 @@ F: linux-user/hexagon/ F: tests/tcg/hexagon/ F: disas/hexagon.c F: configs/targets/hexagon-linux-user/default.mak +F: configs/devices/hexagon-softmmu/default.mak F: docker/dockerfiles/debian-hexagon-cross.docker F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rstconfigs/devices/hexagon-softmmu/default.mak new file +7
-0@@ -0,0 +1,7 @@ +# Default configuration for hexagon-softmmu + +# Uncomment the following lines to disable these optional devices: + +# Boards are selected by default, uncomment to keep out of the build. +# CONFIG_HEX_DSP=y +# CONFIG_L2VIC=yconfigs/targets/hexagon-softmmu.mak new file +6
-0@@ -0,0 +1,6 @@ +# Default configuration for hexagon-softmmu + +TARGET_ARCH=hexagon +TARGET_SUPPORTS_MTTCG=y +TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml +TARGET_LONG_BITS=32target/Kconfig +1
-0@@ -16,6 +16,7 @@ source sh4/Kconfig source sparc/Kconfig source tricore/Kconfig source xtensa/Kconfig +source hexagon/Kconfig config TARGET_BIG_ENDIAN booltarget/hexagon/Kconfig new file +2
-0@@ -0,0 +1,2 @@ +config HEXAGON + booltarget/hexagon/meson.build +1
-0@@ -245,6 +245,7 @@ decodetree_trans_funcs_generated = custom_target( command: [python, files('gen_trans_funcs.py'), semantics_generated, '@OUTPUT@'], ) hexagon_ss.add(decodetree_trans_funcs_generated) +hexagon_softmmu_ss = ss.source_set() hexagon_ss.add(files( 'cpu.c',@@ -264,6 +265,13 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', ))
target/hexagon/meson.build hexagon_ss.add(files( · line 277
Quoted 10 lines
target/hexagon/meson.build +7
-0+hexagon_softmmu_ss.add(files( + 'hex_mmu.c', + 'hex_interrupts.c', + 'hexswi.c', + 'machine.c', +)) + # # Step 4.5 # We use flex/bison based idef-parser to generate TCG code for a lot
Expanding diff:
bison = generator(
find_program('bison', version: '>=3.0'),
output: ['@[email protected]', '@[email protected]'],
arguments: ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']
)On default macOS I get:
Program bison found: NO found 2.3 but need: '>=3.0' (/usr/bin/bison)
Fixed by installing via brew and:
export PATH=/opt/homebrew/opt/bison/bin:$PATH
target/hexagon/meson.build analyze_funcs_generated = custom_target( · line 412
Quoted 5 lines
target/hexagon/meson.build +1
-0@@ -401,3 +409,4 @@ analyze_funcs_generated = custom_target( hexagon_ss.add(analyze_funcs_generated) target_arch += {'hexagon': hexagon_ss} +target_system_arch += {'hexagon': hexagon_softmmu_ss}
But then I get:
[1/1980] Generating target/hexagon/idef_parser_input.preprocessed.h.inc with a custom command
FAILED: target/hexagon/idef_parser_input.preprocessed.h.inc
target/hexagon/idef-parser/prepare target/hexagon/idef_parser_input.h.inc -Itarget/hexagon/idef-parser -o target/hexagon/idef_parser_input.preprocessed.h.inc target/hexagon/idef_parser_input.h.inc:1:10: fatal error: 'macros.h.inc' file not found
1 | #include "macros.h.inc"
| ^~~~~~~~~~~~~~# 1 "target/hexagon/idef_parser_input.h.inc"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 423 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "target/hexagon/idef_parser_input.h.inc" 2
J4_hintjumpr(in RsV) {
{fHINTJR(RsV);}
}J2_loop0r(in RsV, riV) {
{ fIMMEXT(riV); fPCALIGN(riV); fWRITE_LOOP_REGS0( fREAD_PC()+riV,
RsV); fSET_LPCFG(0); }
}
[...]
$ find . -name macros.h.inc ./target/hexagon/idef-parser/macros.h.inc
$ cat target/hexagon/idef-parser/prepare #!/usr/bin/env bash ... # Run the preprocessor and drop comments cpp "$@"
$ which cpp /usr/bin/cpp
$ cpp --version Apple clang version 16.0.0 (clang-1600.0.26.6)
Since this works on Linux for user emulation, I suppose this is a macOS vs Linux issue with default cpp command line arguments...
Re: [PATCH 6/8] target/hexagon: add build config for softmmu
Quoted 53 lines · Philippe Mathieu-Daudé
On default macOS I get:
Program bison found: NO found 2.3 but need: '>=3.0' (
/usr/bin/bison)Fixed by installing via brew and:
export PATH=/opt/homebrew/opt/bison/bin:$PATH
target/hexagon/meson.build analyze_funcs_generated = custom_target( · line 411
Quoted 4 lines
target/hexagon/meson.build +1
-0@@ -401,3 +409,4 @@ analyze_funcs_generated = custom_target( hexagon_ss.add(analyze_funcs_generated) target_arch += {'hexagon': hexagon_ss} +target_system_arch += {'hexagon': hexagon_softmmu_ss}But then I get:
[1/1980] Generating target/hexagon/idef_parser_input.preprocessed.h.inc with a custom command
FAILED: target/hexagon/idef_parser_input.preprocessed.h.inc target/hexagon/idef-parser/prepare target/hexagon/idef_parser_input.h.inc -Itarget/hexagon/idef-parser -o target/hexagon/idef_parser_input.preprocessed.h.inc target/hexagon/idef_parser_input.h.inc:1:10: fatal error: 'macros.h.inc' file not found1 | #include "macros.h.inc" | ^~~~~~~~~~~~~~# 1 "target/hexagon/idef_parser_input.h.inc"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 423 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "target/hexagon/idef_parser_input.h.inc" 2J4_hintjumpr(in RsV) { {fHINTJR(RsV);} }J2_loop0r(in RsV, riV) { { fIMMEXT(riV); fPCALIGN(riV); fWRITE_LOOP_REGS0( fREAD_PC()+riV, RsV);
fSET_LPCFG(0); }
}
[...]$ find . -name macros.h.inc ./target/hexagon/idef-parser/macros.h.inc$ cat target/hexagon/idef-parser/prepare #!/usr/bin/env bash ... # Run the preprocessor and drop comments cpp "$@"
Quoted 8 lines
$ which cpp /usr/bin/cpp$ cpp --version Apple clang version 16.0.0 (clang-1600.0.26.6)Since this works on Linux for user emulation, I suppose this is a macOS vs Linux issue with default cpp command line arguments...
Hi Phil,
yes this is an issue of default arguments added by cpp on mac, I ran into this a little while ago on a downstream fork.
cpp on mac expands clang ... -traditional-cpp which alsos break macro concatenation..
I carry a patch which:
* Removes indent pass on idef-parser output, as indent is not available on mac;
* Replaces cpp with ${compiler} ... -E ... where compiler is gotten from meson.
I'm a bit sad about the default meson version being outdated though..:(
Signature · 2 lines
Anton Johansson rev.ng Labs Srl.
RE: [PATCH 6/8] target/hexagon: add build config for softmmu
In reply to Brian CainQuoted 13 lines
-----Original Message-----
From: Brian Cain <[email protected]>
Sent: Saturday, March 1, 2025 11:21 AM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Paolo Bonzini <[email protected]>
Subject: [PATCH 6/8] target/hexagon: add build config for softmmu
Quoted 1 line
Signed-off-by Brian Cain <[email protected]>
PATCH 7/8 hw/hexagon: Define hexagon "virt" machine
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- configs/devices/hexagon-softmmu/default.mak | 1 + configs/targets/hexagon-softmmu.mak | 1 + include/hw/hexagon/virt.h | 41 ++ hw/hexagon/virt.c | 395 ++++++++++++++++++++ target/hexagon/cpu.c | 2 +- hw/hexagon/Kconfig | 8 + hw/hexagon/meson.build | 2 + 7 files changed, 449 insertions(+), 1 deletion(-) create mode 100644 include/hw/hexagon/virt.h create mode 100644 hw/hexagon/virt.c
configs/devices/hexagon-softmmu/default.mak +1 -0
@@ -3,5 +3,6 @@ # Uncomment the following lines to disable these optional devices: # Boards are selected by default, uncomment to keep out of the build. +# CONFIG_HEX_VIRT=y # CONFIG_HEX_DSP=y # CONFIG_L2VIC=y
configs/targets/hexagon-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ TARGET_ARCH=hexagon TARGET_SUPPORTS_MTTCG=y TARGET_XML_FILES=gdb-xml/hexagon-core.xml gdb-xml/hexagon-hvx.xml gdb-xml/hexagon-sys.xml TARGET_LONG_BITS=32 +TARGET_NEED_FDT=y
include/hw/hexagon/virt.h new file +41 -0
41 lines not on this page · raw message
hw/hexagon/virt.c new file +395 -0
395 lines not on this page · raw message
target/hexagon/cpu.c +1 -1
@@ -1,5 +1,5 @@/* -* Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. +* Copyright(c) 2019-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
hw/hexagon/Kconfig +8 -0
@@ -4,3 +4,11 @@ config HEX_DSP depends on HEXAGON && TCG imply PTIMER select L2VIC # Vector PIC + +config HEX_VIRT + bool + default y + depends on HEX_DSP && FDT + select DEVICE_TREE + select VIRTIO_MMIO + select PL011
hw/hexagon/meson.build +2 -0
@@ -3,3 +3,5 @@ hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c',)) hw_arch += {'hexagon': hexagon_ss} +hexagon_ss.add(when: 'CONFIG_HEX_VIRT', if_true: files('virt.c',)) +
Signature · 1 line
2.34.1
Re: [PATCH 7/8] hw/hexagon: Define hexagon "virt" machine
Quoted 31 lines · Brian Cain
From: Brian Cain <[email protected]>
Signed-off-by Brian Cain <[email protected]>--- configs/devices/hexagon-softmmu/default.mak | 1 + configs/targets/hexagon-softmmu.mak | 1 + include/hw/hexagon/virt.h | 41 ++ hw/hexagon/virt.c | 395 ++++++++++++++++++++ target/hexagon/cpu.c | 2 +- hw/hexagon/Kconfig | 8 + hw/hexagon/meson.build | 2 + 7 files changed, 449 insertions(+), 1 deletion(-)create mode 100644
include/hw/hexagon/virt.h
create mode 100644hw/hexagon/virt.chw/hexagon/virt.c new file +15
-0+static void fdt_add_clocks (const HexagonVirtMachineState *vms) +{ +MachineState *ms =MACHINE (vms); + clock_phandle =qemu_fdt_alloc_phandle (ms->fdt); +qemu_fdt_add_subnode (ms->fdt,"/apb-pclk" ); +qemu_fdt_setprop_string (ms->fdt,"/apb-pclk" ,"compatible" ,"fixed-clock" ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"#clock-cells" ,0x0 ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"clock-frequency" ,24000000 ); +qemu_fdt_setprop_string (ms->fdt,"/apb-pclk" ,"clock-output-names" , +"clk24mhz" ); +qemu_fdt_setprop_cell (ms->fdt,"/apb-pclk" ,"phandle" , clock_phandle); +} + +static void fdt_add_uart (const HexagonVirtMachineState *vms,int uart) +{
hw/hexagon/virt.c line 177
Quoted 10 lines
hw/hexagon/virt.c new file +10
-0+char *nodename; +hwaddr base = base_memmap[uart].base; +hwaddr size = base_memmap[uart].size; +assert (uart ==0 ); +int irq = irqmap[VIRT_UART0 + uart]; +const char compat[] ="arm,pl011\0arm,primecell" ; +const char clocknames[] ="uartclk\0apb_pclk" ; +MachineState *ms =MACHINE (vms); + +pl011_create (base,qdev_get_gpio_in (vms->l2vic, irq),serial_hd (0 ));
pl011_create() seems an incomplete API since it let the UART with no clock connected. IIUC here you feed with a 24MHz from APB.
Quoted 21 lines
hw/hexagon/virt.c new file +21
-0+ + nodename =g_strdup_printf ("/pl011@%" PRIx64, base); +qemu_fdt_add_subnode (ms->fdt, nodename); + +/* Note that we can't use setprop_string because of the embedded NUL */ +qemu_fdt_setprop (ms->fdt, nodename,"compatible" , compat,sizeof (compat)); +qemu_fdt_setprop_cells (ms->fdt, nodename,"reg" ,0 , base, size); +qemu_fdt_setprop_cells (ms->fdt, nodename,"interrupts" ,32 + irq,0 ); +qemu_fdt_setprop_cells (ms->fdt, nodename,"clocks" , clock_phandle, + clock_phandle); +qemu_fdt_setprop (ms->fdt, nodename,"clock-names" , clocknames, +sizeof (clocknames)); +qemu_fdt_setprop_cell (ms->fdt, nodename,"interrupt-parent" , + irq_hvm_ic_phandle); + +qemu_fdt_setprop_string (ms->fdt,"/chosen" ,"stdout-path" , nodename); +qemu_fdt_add_subnode (ms->fdt,"/aliases" ); +qemu_fdt_setprop_string (ms->fdt,"/aliases" ,"serial0" , nodename); + +g_free (nodename); +}
PATCH 8/8 tests/functional: Add a hexagon minivm test
In reply to Brian CainFrom: Brian Cain <[email protected]>
--- MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++ tests/functional/test_hexagon_minivm.py | 42 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100755 tests/functional/test_hexagon_minivm.py
MAINTAINERS +1 -0
@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/devel/hexagon-sys.rst F: docs/devel/hexagon-l2vic.rst +F: tests/functional/test_hexagon_minivm.py T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parser
tests/functional/meson.build +8 -0
@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration', ] +test_timeouts += { + 'hexagon_minivm': 180, +} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] + tests_i386_system_thorough = [ 'i386_tuxrun', ]
tests/functional/test_hexagon_minivm.py new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Quoted 62 lines
Signed-off-by Brian Cain <[email protected]>--- MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++ tests/functional/test_hexagon_minivm.py | 42 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +1
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xml F: docs/system/target-hexagon.rst F: docs/devel/hexagon-sys.rst F: docs/devel/hexagon-l2vic.rst +F: tests/functional/test_hexagon_minivm.py T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +8
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration', ] +test_timeouts += { + 'hexagon_minivm': 180, +} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] + tests_i386_system_thorough = [ 'i386_tuxrun', ]tests/functional/test_hexagon_minivm.py new file +17
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. All Rights Reserved. +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): + + timeout = 180 + GUEST_ENTRY = 0xc0000000 + + REPO = 'https://artifacts.codelinaro.org/artifactory'
tests/functional/test_hexagon_minivm.py line 27
Quoted 10 lines
tests/functional/test_hexagon_minivm.py new file +10
-0+ ASSET_TARBALL = \ + Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz', + 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a') + + def test_minivm(self): + self.set_machine('virt') + self.archive_extract(self.ASSET_TARBALL) + rootfs_path = f'{self.workdir}/hexagon-unknown-linux-musl-rootfs' + kernel_path = f'{rootfs_path}/boot/minivm'
$ readelf -h hexagon-unknown-linux-musl-rootfs/boot/minivm Entry point address: 0xffff0000
I suppose this is a bootloader which runs guest code at GUEST_ENTRY = 0xc0000000.
tests/functional/test_hexagon_minivm.py line 31
Quoted 4 lines
tests/functional/test_hexagon_minivm.py new file +4
-0+ + assert(os.path.exists(kernel_path)) + for test_bin_path in glob(f'{rootfs_path}/boot/test_*'): + print(f'# Testing "{os.path.basename(test_bin_path)}"')
$ ls -1 hexagon-unknown-linux-musl-rootfs/boot/test_* hexagon-unknown-linux-musl-rootfs/boot/test_interrupts hexagon-unknown-linux-musl-rootfs/boot/test_mmu hexagon-unknown-linux-musl-rootfs/boot/test_processors
I'd rather 1 test per binary to easily see which one failed.
tests/functional/test_hexagon_minivm.py line 39
Quoted 8 lines
tests/functional/test_hexagon_minivm.py new file +8
-0+ + vm = self.get_vm() + vm.add_args('-kernel', kernel_path, + '-device', + f'loader,addr={hex(self.GUEST_ENTRY)},file={test_bin_path}') + vm.launch() + vm.wait() + self.assertEqual(vm.exitcode(), 0)
...
----------------
IN:
0xc0000000: 0x6a09c019 { R25 = C9/pc }
0xc0000004: 0x00004040 { immext(#0x1000)
0xc0000008: 0x7800c018 R24 = ##0x1000 }
0xc000000c: 0xf318d918 { R24 = add(R24,R25) }
0xc0000010: 0x00004000 { immext(#0x0)
0xc0000014: 0x7800c03a R26 = ##0x1 }
0xc0000018: 0x0c004000 { immext(#0xc0000000)
0xc000001c: 0x7800c001 R1 = ##0xc0000000 }
0xc0000020: 0x0ffc4000 { immext(#0xffc00000)
0xc0000024: 0x7601c001 R1 = and(R1,##0xffc00000) }
0xc0000028: 0x8c01d622 { R2 = lsr(R1,#0x16) }
0xc000002c: 0xc402d840 { R0 = addasl(R24,R2,#0x2) }
0xc0000030: 0xb0e1f8a1 { R1 = add(R1,#0xfc5) }
0xc0000034: 0x00044000 { immext(#0x400000)
0xc0000038: 0x7800c002 R2 = ##0x400000 }
0xc000003c: 0x601ac008 { loop0(PC+4,R26) }
0xc0000040: 0xab80c108 { memw(R0++#0x4) = R1 }
0xc0000044: 0xf3018201 { R1 = add(R1,R2)
0xc0000048: 0x7f00c000 nop } :endloop0...do_raise_exception: 0x00000002, @ 20000090
hexagon_cpu_do_interrupt: event 0x2:(null), cause 0x25(37)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)0x20000104: 0x5400c000 { trap0(#0x0) }
hexagon_cpu_do_interrupt: event 0x8:HEX_EVENT_TRAP0, cause 0x0(0)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)
0xc00002a0: 0x7060c002 { R2 = R0 } 0xc00002a4: 0x5480c20c { trap1(R0,#0x13) }
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x13(19)0xffff0518: 0x5800c02a { jump PC+84 }0xffff056c: 0x6460c000 { stop(R0) }
How can we be sure errors won't exit(0) or hang?
(qemu) info mtree
address-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system
0000000000000000-00000000ffffffff (prio 0, ram): ddr.ram
0000000010000000-0000000010000fff (prio 0, i/o): pl011
0000000011000000-00000000110001ff (prio 0, i/o): virtio-mmio
0000000012000000-00000000120001ff (prio 0, i/o): virtio-mmio
00000000d81e0000-00000000d81effff (prio 0, i/o): fast
00000000d8400000-00000000d87fffff (prio 0, ram): vtcm.ram
00000000de000000-00000000de0001ff (prio 0, rom): config_table.rom
00000000fc910000-00000000fc910fff (prio 0, i/o): l2vicCould we have minimal debug output on the console?
tests/functional/test_hexagon_minivm.py line 42
Quoted 3 lines
tests/functional/test_hexagon_minivm.py new file +3
-0+ +if __name__ == '__main__': + QemuSystemTest.main()
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
Quoted 7 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Whoops -- will fix it.
Quoted 76 lines
Quoted 70 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42 +++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
+test_timeouts += {
+ 'hexagon_minivm': 180,tests/functional/meson.build +6
-0+} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. All RightsReserved.
tests/functional/test_hexagon_minivm.py new file +23
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): + + timeout = 180 + GUEST_ENTRY = 0xc0000000 + + REPO = 'https://artifacts.codelinaro.org/artifactory' + ASSET_TARBALL = \ + Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz', + 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a') + + def test_minivm(self): + self.set_machine('virt') + self.archive_extract(self.ASSET_TARBALL) + rootfs_path =Quoted 2 lines
f'{self.workdir}/hexagon-unknown-linux-musl-rootfs' +
kernel_path= f'{rootfs_path}/boot/minivm'$ readelf -h hexagon-unknown-linux-musl-rootfs/boot/minivm Entry point address: 0xffff0000
Quoted 3 lines
I suppose this is a bootloader which runs guest code at
GUEST_ENTRY=0xc0000000.
Yes, this is indeed the case. The source for minivm and the test cases is found at https://github.com/quic/hexagonMVM
Quoted 5 lines
Quoted 4 lines
+
+ assert(os.path.exists(kernel_path))
+ fortest_bin_pathinglob(f'{rootfs_path}/boot/test_*'):
+print(f'# Testing "{os.path.basename(test_bin_path)}"')
Quoted 7 lines
$ ls -1 hexagon-unknown-linux-musl-rootfs/boot/test_* hexagon-unknown-linux-musl-rootfs/boot/test_interrupts hexagon-unknown-linux-musl-rootfs/boot/test_mmu hexagon-unknown-linux-musl-rootfs/boot/test_processorsI'd rather 1 test per binary to easily see which one failed.
Okay, I'll make that change.
Quoted 40 lines
Quoted 8 lines
+
+ vm =self.get_vm()
+ vm.add_args('-kernel',kernel_path,
+ '-device',
+ f'loader,addr={hex(self.GUEST_ENTRY)},file={test_bin_path}') +vm.launch()
+vm.wait()
+self.assertEqual(vm.exitcode(), 0)...
----------------
IN:
0xc0000000:0x6a09c019{ R25 = C9/pc }
0xc0000004:0x00004040{ immext(#0x1000)
0xc0000008: 0x7800c018 R24 = ##0x1000 }
0xc000000c:0xf318d918{ R24 =add(R24,R25)} 0xc0000010:0x00004000{ immext(#0x0)
0xc0000014: 0x7800c03a R26 = ##0x1 }
0xc0000018:0x0c004000{ immext(#0xc0000000) 0xc000001c: 0x7800c001 R1 = ##0xc0000000 } 0xc0000020:0x0ffc4000{ immext(#0xffc00000) 0xc0000024: 0x7601c001 R1 =and(R1,##0xffc00000)} 0xc0000028:0x8c01d622{ R2 =lsr(R1,#0x16)} 0xc000002c:0xc402d840{ R0 =addasl(R24,R2,#0x2)} 0xc0000030:0xb0e1f8a1{ R1 =add(R1,#0xfc5)} 0xc0000034:0x00044000{ immext(#0x400000)
0xc0000038: 0x7800c002 R2 = ##0x400000 }
0xc000003c:0x601ac008{loop0(PC+4,R26)}
0xc0000040:0xab80c108{ memw(R0++#0x4) = R1 } 0xc0000044:0xf3018201{ R1 =add(R1,R2)
0xc0000048: 0x7f00c000 nop } :endloop0
...do_raise_exception:0x00000002, @ 20000090
hexagon_cpu_do_interrupt: event 0x2:(null), cause 0x25(37)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1) 0x20000104:0x5400c000{ trap0(#0x0) }hexagon_cpu_do_interrupt: event 0x8:HEX_EVENT_TRAP0, cause 0x0(0)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)
Quoted 9 lines
0xc00002a0:
0x7060c002{ R2 = R0 } 0xc00002a4:0x5480c20c{trap1(R0,#0x13)}hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x13(19) 0xffff0518:
0x5800c02a{ jump PC+84 }
0xffff056c:0x6460c000{ stop(R0) }How can we be sure errors won't exit(0) or hang?
The most likely failure mode for errors seems like a hang to me. Which is good that it's at least detected but I would agree that it would be preferable to
Quoted 12 lines
(qemu) info mtree
address-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-00000000ffffffff (prio 0, ram): ddr.ram 0000000010000000-0000000010000fff (prio 0, i/o): pl011 0000000011000000-00000000110001ff (prio 0, i/o): virtio-mmio 0000000012000000-00000000120001ff (prio 0, i/o): virtio-mmio 00000000d81e0000-00000000d81effff (prio 0, i/o): fast 00000000d8400000-00000000d87fffff (prio 0, ram): vtcm.ram 00000000de000000-00000000de0001ff (prio 0, rom): config_table.rom 00000000fc910000-00000000fc910fff (prio 0, i/o): l2vic
Quoted 2 lines
Could we have minimal debug output on the console?
Hmm - there's no UART support in minivm nor its tests. But it is easy enough to add debug output via semihosting. Since semihosting spec is still under review, I've omitted that from these initial series.
How about we revise the minivm tests to emit some debug output and we can also use that kind of thing to verify correctness? But would it suffice to land the test design as-is and follow up after semihosting lands? Or would you prefer to see semihosting be included here before this test is enabled?
Quoted 6 lines
tests/functional/test_hexagon_minivm.py line 42
Quoted 3 lines
tests/functional/test_hexagon_minivm.py new file +3
-0+ +if __name__ == '__main__': + QemuSystemTest.main()
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Whoops -- will fix it.
Quoted 76 lines
Quoted 70 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42 +++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
+test_timeouts += {
+ 'hexagon_minivm': 180,tests/functional/meson.build +6
-0+} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. All RightsReserved.
tests/functional/test_hexagon_minivm.py new file +23
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): + + timeout = 180 + GUEST_ENTRY = 0xc0000000 + + REPO = 'https://artifacts.codelinaro.org/artifactory' + ASSET_TARBALL = \ + Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz', + 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a') + + def test_minivm(self): + self.set_machine('virt') + self.archive_extract(self.ASSET_TARBALL) + rootfs_path =Quoted 2 lines
f'{self.workdir}/hexagon-unknown-linux-musl-rootfs' +
kernel_path= f'{rootfs_path}/boot/minivm'$ readelf -h hexagon-unknown-linux-musl-rootfs/boot/minivm Entry point address: 0xffff0000
Quoted 3 lines
I suppose this is a bootloader which runs guest code at
GUEST_ENTRY=0xc0000000.
Yes, this is indeed the case. The source for minivm and the test cases is found at https://github.com/quic/hexagonMVM
Quoted 5 lines
Quoted 4 lines
+
+ assert(os.path.exists(kernel_path))
+ fortest_bin_pathinglob(f'{rootfs_path}/boot/test_*'):
+print(f'# Testing "{os.path.basename(test_bin_path)}"')
Quoted 7 lines
$ ls -1 hexagon-unknown-linux-musl-rootfs/boot/test_* hexagon-unknown-linux-musl-rootfs/boot/test_interrupts hexagon-unknown-linux-musl-rootfs/boot/test_mmu hexagon-unknown-linux-musl-rootfs/boot/test_processorsI'd rather 1 test per binary to easily see which one failed.
Okay, I'll make that change.
Quoted 40 lines
Quoted 8 lines
+
+ vm =self.get_vm()
+ vm.add_args('-kernel',kernel_path,
+ '-device',
+ f'loader,addr={hex(self.GUEST_ENTRY)},file={test_bin_path}') +vm.launch()
+vm.wait()
+self.assertEqual(vm.exitcode(), 0)...
----------------
IN:
0xc0000000:0x6a09c019{ R25 = C9/pc }
0xc0000004:0x00004040{ immext(#0x1000)
0xc0000008: 0x7800c018 R24 = ##0x1000 }
0xc000000c:0xf318d918{ R24 =add(R24,R25)} 0xc0000010:0x00004000{ immext(#0x0)
0xc0000014: 0x7800c03a R26 = ##0x1 }
0xc0000018:0x0c004000{ immext(#0xc0000000) 0xc000001c: 0x7800c001 R1 = ##0xc0000000 } 0xc0000020:0x0ffc4000{ immext(#0xffc00000) 0xc0000024: 0x7601c001 R1 =and(R1,##0xffc00000)} 0xc0000028:0x8c01d622{ R2 =lsr(R1,#0x16)} 0xc000002c:0xc402d840{ R0 =addasl(R24,R2,#0x2)} 0xc0000030:0xb0e1f8a1{ R1 =add(R1,#0xfc5)} 0xc0000034:0x00044000{ immext(#0x400000)
0xc0000038: 0x7800c002 R2 = ##0x400000 }
0xc000003c:0x601ac008{loop0(PC+4,R26)}
0xc0000040:0xab80c108{ memw(R0++#0x4) = R1 } 0xc0000044:0xf3018201{ R1 =add(R1,R2)
0xc0000048: 0x7f00c000 nop } :endloop0
...do_raise_exception:0x00000002, @ 20000090
hexagon_cpu_do_interrupt: event 0x2:(null), cause 0x25(37)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1) 0x20000104:0x5400c000{ trap0(#0x0) }hexagon_cpu_do_interrupt: event 0x8:HEX_EVENT_TRAP0, cause 0x0(0)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)
Quoted 9 lines
0xc00002a0:
0x7060c002{ R2 = R0 } 0xc00002a4:0x5480c20c{trap1(R0,#0x13)}hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x13(19) 0xffff0518:
0x5800c02a{ jump PC+84 }
0xffff056c:0x6460c000{ stop(R0) }How can we be sure errors won't exit(0) or hang?
The most likely failure mode for errors seems like a hang to me. Which is good that it's at least detected but I would agree that it would be preferable to
Quoted 12 lines
(qemu) info mtree
address-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-00000000ffffffff (prio 0, ram): ddr.ram 0000000010000000-0000000010000fff (prio 0, i/o): pl011 0000000011000000-00000000110001ff (prio 0, i/o): virtio-mmio 0000000012000000-00000000120001ff (prio 0, i/o): virtio-mmio 00000000d81e0000-00000000d81effff (prio 0, i/o): fast 00000000d8400000-00000000d87fffff (prio 0, ram): vtcm.ram 00000000de000000-00000000de0001ff (prio 0, rom): config_table.rom 00000000fc910000-00000000fc910fff (prio 0, i/o): l2vic
Quoted 2 lines
Could we have minimal debug output on the console?
Hmm - there's no UART support in minivm nor its tests. But it is easy enough to add debug output via semihosting. Since semihosting spec is still under review, I've omitted that from these initial series.
How about we revise the minivm tests to emit some debug output and we can also use that kind of thing to verify correctness? But would it suffice to land the test design as-is and follow up after semihosting lands? Or would you prefer to see semihosting be included
Quoted 6 lines
tests/functional/test_hexagon_minivm.py line 42
Quoted 3 lines
tests/functional/test_hexagon_minivm.py new file +3
-0+ +if __name__ == '__main__': + QemuSystemTest.main()
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
Quoted 166 lines · Brian Cain
Quoted 7 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Whoops -- will fix it.
Quoted 77 lines
Quoted 71 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42
+++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
+test_timeouts += {
+ 'hexagon_minivm': 180,tests/functional/meson.build +6
-0+} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. AllRights Reserved.
tests/functional/test_hexagon_minivm.py new file +23
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): + + timeout = 180 + GUEST_ENTRY = 0xc0000000 + + REPO = 'https://artifacts.codelinaro.org/artifactory' + ASSET_TARBALL = \ + Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz', + 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a') + + def test_minivm(self): + self.set_machine('virt') + self.archive_extract(self.ASSET_TARBALL) + rootfs_path =Quoted 2 lines
f'{self.workdir}/hexagon-unknown-linux-musl-rootfs' +
kernel_path= f'{rootfs_path}/boot/minivm'$ readelf -h hexagon-unknown-linux-musl-rootfs/boot/minivm Entry point address: 0xffff0000Quoted 3 lines
I suppose this is a bootloader which runs guest code at
GUEST_ENTRY=0xc0000000.Yes, this is indeed the case. The source for minivm and the test cases is found at https://github.com/quic/hexagonMVM
Quoted 5 lines
Quoted 4 lines
+
+ assert(os.path.exists(kernel_path))
+ fortest_bin_pathinglob(f'{rootfs_path}/boot/test_*'):
+print(f'# Testing "{os.path.basename(test_bin_path)}"')Quoted 7 lines
$ ls -1 hexagon-unknown-linux-musl-rootfs/boot/test_* hexagon-unknown-linux-musl-rootfs/boot/test_interrupts hexagon-unknown-linux-musl-rootfs/boot/test_mmu hexagon-unknown-linux-musl-rootfs/boot/test_processorsI'd rather 1 test per binary to easily see which one failed.
Okay, I'll make that change.
Quoted 40 lines
Quoted 8 lines
+
+ vm =self.get_vm()
+ vm.add_args('-kernel',kernel_path,
+ '-device',
+ f'loader,addr={hex(self.GUEST_ENTRY)},file={test_bin_path}') +vm.launch()
+vm.wait()
+self.assertEqual(vm.exitcode(), 0)...
----------------
IN:
0xc0000000:0x6a09c019{ R25 = C9/pc }
0xc0000004:0x00004040{ immext(#0x1000)
0xc0000008: 0x7800c018 R24 = ##0x1000 }
0xc000000c:0xf318d918{ R24 =add(R24,R25)} 0xc0000010:0x00004000{ immext(#0x0)
0xc0000014: 0x7800c03a R26 = ##0x1 }
0xc0000018:0x0c004000{ immext(#0xc0000000) 0xc000001c: 0x7800c001 R1 = ##0xc0000000 } 0xc0000020:0x0ffc4000{ immext(#0xffc00000) 0xc0000024: 0x7601c001 R1 =and(R1,##0xffc00000)} 0xc0000028:0x8c01d622{ R2 =lsr(R1,#0x16)} 0xc000002c:0xc402d840{ R0 =addasl(R24,R2,#0x2)} 0xc0000030:0xb0e1f8a1{ R1 =add(R1,#0xfc5)} 0xc0000034:0x00044000{ immext(#0x400000)
0xc0000038: 0x7800c002 R2 = ##0x400000 }
0xc000003c:0x601ac008{loop0(PC+4,R26)}
0xc0000040:0xab80c108{ memw(R0++#0x4) = R1 } 0xc0000044:0xf3018201{ R1 =add(R1,R2)
0xc0000048: 0x7f00c000 nop } :endloop0
...do_raise_exception:0x00000002, @ 20000090
hexagon_cpu_do_interrupt: event 0x2:(null), cause 0x25(37)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1) 0x20000104:0x5400c000{ trap0(#0x0) }hexagon_cpu_do_interrupt: event 0x8:HEX_EVENT_TRAP0, cause 0x0(0)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)Quoted 9 lines
0xc00002a0:
0x7060c002{ R2 = R0 } 0xc00002a4:0x5480c20c{trap1(R0,#0x13)}hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x13(19) 0xffff0518:
0x5800c02a{ jump PC+84 }
0xffff056c:0x6460c000{ stop(R0) }How can we be sure errors won't exit(0) or hang?
The most likely failure mode for errors seems like a hang to me. Which is good that it's at least detected but I would agree that it would be preferable to
Quoted 12 lines
(qemu) info mtree
address-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-00000000ffffffff (prio 0, ram): ddr.ram 0000000010000000-0000000010000fff (prio 0, i/o): pl011 0000000011000000-00000000110001ff (prio 0, i/o): virtio-mmio 0000000012000000-00000000120001ff (prio 0, i/o): virtio-mmio 00000000d81e0000-00000000d81effff (prio 0, i/o): fast 00000000d8400000-00000000d87fffff (prio 0, ram): vtcm.ram 00000000de000000-00000000de0001ff (prio 0, rom): config_table.rom 00000000fc910000-00000000fc910fff (prio 0, i/o): l2vic
Quoted 7 lines
Quoted 2 lines
Could we have minimal debug output on the console?
Hmm - there's no UART support in minivm nor its tests. But it is easy enough to add debug output via semihosting. Since semihosting spec is still under review, I've omitted that from these initial series.
How about we revise the minivm tests to emit some debug output and we can also use that kind of thing to verify correctness? But would it suffice to land the test design as-is and follow up after semihosting lands? Or would you prefer to see semihosting be included
Oh - I see these tests do already emit PASS or FAIL via semihosting. See https://github.com/quic/hexagonMVM/blob/ca5704e8fd7aa0b856c947933fca045ff7a9dadd/tests/test_processors.S#L109-L116 for an example.
Would it be okay to just check for this output after that semihosting lands? And do you prefer more detailed debug output beyond PASS/FAIL?
Quoted 6 lines
Quoted 6 lines
tests/functional/test_hexagon_minivm.py line 42
Quoted 3 lines
tests/functional/test_hexagon_minivm.py new file +3
-0+ +if __name__ == '__main__': + QemuSystemTest.main()
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
In reply to Philippe Mathieu-DaudéQuoted 64 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Quoted 57 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42 +++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
tests/functional/meson.build +8
-0+test_timeouts += { + 'hexagon_minivm': 180, +} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. All RightsReserved.
tests/functional/test_hexagon_minivm.py new file +10
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): +
Quoted 8 lines
Quoted 8 lines
+ timeout = 180
+GUEST_ENTRY=0xc0000000
+
+ REPO = 'https://artifacts.codelinaro.org/artifactory'
+ASSET_TARBALL= \
+ Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/'
+ '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz',
+ 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a')
Tests that download assets should go into the "thorough" category, not into the quick one, so please replace tests_hexagon_system_quick with tests_hexagon_system_thorough in the meson.build file.
(yes, I know, it's a little bit confusing that tests that finish quickly should still go into the thorough category instead ... but we needed a way to distinguish the tests that download assets and the ones that can run without downloads, see also the description in docs/devel/testing/functional.rst)
Thomas
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
Quoted 77 lines · Thomas Huth
Quoted 65 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Quoted 58 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42
+++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
tests/functional/meson.build +8
-0+test_timeouts += { + 'hexagon_minivm': 180, +} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. AllRights Reserved.
tests/functional/test_hexagon_minivm.py new file +10
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): +Quoted 8 lines
Quoted 8 lines
+ timeout = 180
+GUEST_ENTRY=0xc0000000
+
+ REPO = 'https://artifacts.codelinaro.org/artifactory' +ASSET_TARBALL= \
+ Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz',
+ 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a')Tests that download assets should go into the "thorough" category, not into the quick one, so please replace
tests_hexagon_system_quickwithtests_hexagon_system_thoroughin the meson.build file.
Quoted 1 line
(yes, I know, it's a little bit confusing that tests that finish quickly should still go into the thorough category instead ... but we needed a way to distinguish the tests that download assets and the ones that can run without downloads, see also the description in
docs/devel/testing/functional.rst)
Thanks -- I'll fix this.
Quoted 3 lines
Thomas
Re: [PATCH 8/8] tests/functional: Add a hexagon minivm test
In reply to Philippe Mathieu-DaudéQuoted 159 lines · Philippe Mathieu-Daudé
Hi Brian,
Quoted 1 line · Brian Cain
From: Brian Cain <[email protected]>
A bit opaque...
Quoted 70 lines
Signed-off-by Brian Cain <[email protected]>---
MAINTAINERS | 1 + tests/functional/meson.build | 8 +++++tests/functional/test_hexagon_minivm.py| 42 +++++++++++++++++++++++++3 files changed, 51 insertions(+)create mode 100755
tests/functional/test_hexagon_minivm.pyMAINTAINERS +0
-0@@ -247,6 +247,7 @@ F: gdb-xml/hexagon*.xmlF:
docs/system/target-hexagon.rst
F:docs/devel/hexagon-sys.rst
F:docs/devel/hexagon-l2vic.rst
+F:tests/functional/test_hexagon_minivm.py
T: git https://github.com/quic/qemu.git hex-next Hexagon idef-parsertests/functional/meson.build +0
-0@@ -135,6 +135,14 @@ tests_i386_system_quick = [ 'migration',]
+test_timeouts += {
+ 'hexagon_minivm': 180,tests/functional/meson.build +6
-0+} + +tests_hexagon_system_quick = [ + 'hexagon_minivm', +] +
tests_i386_system_thorough= [
'i386_tuxrun',
]tests/functional/test_hexagon_minivm.py new file +3
-0@@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# +# Copyright(c) 2024-2025 Qualcomm Innovation Center, Inc. All RightsReserved.
tests/functional/test_hexagon_minivm.py new file +23
-0+# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os +from glob import glob +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern + +class MiniVMTest(QemuSystemTest): + + timeout = 180 + GUEST_ENTRY = 0xc0000000 + + REPO = 'https://artifacts.codelinaro.org/artifactory' + ASSET_TARBALL = \ + Asset(f'{REPO}/codelinaro-toolchain-for-hexagon/' + '19.1.5/hexagon_minivm_2024_Dec_15.tar.gz', + 'd7920b5ff14bed5a10b23ada7d4eb927ede08635281f25067e0d5711feee2c2a') + + def test_minivm(self): + self.set_machine('virt') + self.archive_extract(self.ASSET_TARBALL) + rootfs_path =Quoted 2 lines
f'{self.workdir}/hexagon-unknown-linux-musl-rootfs' +
kernel_path= f'{rootfs_path}/boot/minivm'$ readelf -h hexagon-unknown-linux-musl-rootfs/boot/minivm Entry point address: 0xffff0000I suppose this is a bootloader which runs guest code at
GUEST_ENTRY=0xc0000000.Quoted 4 lines
+
+ assert(os.path.exists(kernel_path))
+ fortest_bin_pathinglob(f'{rootfs_path}/boot/test_*'):
+print(f'# Testing "{os.path.basename(test_bin_path)}"')$ ls -1 hexagon-unknown-linux-musl-rootfs/boot/test_* hexagon-unknown-linux-musl-rootfs/boot/test_interrupts hexagon-unknown-linux-musl-rootfs/boot/test_mmu hexagon-unknown-linux-musl-rootfs/boot/test_processorsI'd rather 1 test per binary to easily see which one failed.
Quoted 8 lines
+
+ vm =self.get_vm()
+ vm.add_args('-kernel',kernel_path,
+ '-device',
+ f'loader,addr={hex(self.GUEST_ENTRY)},file={test_bin_path}') +vm.launch()
+vm.wait()
+self.assertEqual(vm.exitcode(), 0)...
----------------
IN:
0xc0000000:0x6a09c019{ R25 = C9/pc }
0xc0000004:0x00004040{ immext(#0x1000)
0xc0000008: 0x7800c018 R24 = ##0x1000 }
0xc000000c:0xf318d918{ R24 =add(R24,R25)} 0xc0000010:0x00004000{ immext(#0x0)
0xc0000014: 0x7800c03a R26 = ##0x1 }
0xc0000018:0x0c004000{ immext(#0xc0000000) 0xc000001c: 0x7800c001 R1 = ##0xc0000000 } 0xc0000020:0x0ffc4000{ immext(#0xffc00000) 0xc0000024: 0x7601c001 R1 =and(R1,##0xffc00000)} 0xc0000028:0x8c01d622{ R2 =lsr(R1,#0x16)} 0xc000002c:0xc402d840{ R0 =addasl(R24,R2,#0x2)} 0xc0000030:0xb0e1f8a1{ R1 =add(R1,#0xfc5)} 0xc0000034:0x00044000{ immext(#0x400000)
0xc0000038: 0x7800c002 R2 = ##0x400000 }
0xc000003c:0x601ac008{loop0(PC+4,R26)}
0xc0000040:0xab80c108{ memw(R0++#0x4) = R1 } 0xc0000044:0xf3018201{ R1 =add(R1,R2)
0xc0000048: 0x7f00c000 nop } :endloop0
...do_raise_exception:0x00000002, @ 20000090
hexagon_cpu_do_interrupt: event 0x2:(null), cause 0x25(37)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1) 0x20000104:0x5400c000{ trap0(#0x0) }hexagon_cpu_do_interrupt: event 0x8:HEX_EVENT_TRAP0, cause 0x0(0)
hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x1(1)0xc00002a0:
0x7060c002{ R2 = R0 } 0xc00002a4:0x5480c20c{trap1(R0,#0x13)}hexagon_cpu_do_interrupt: event 0x9:HEX_EVENT_TRAP1, cause 0x13(19) 0xffff0518:
0x5800c02a{ jump PC+84 }
0xffff056c:0x6460c000{ stop(R0) }How can we be sure errors won't exit(0) or hang?
(qemu) info mtree
address-space: memory
0000000000000000-ffffffffffffffff (prio 0, i/o): system 0000000000000000-00000000ffffffff (prio 0, ram): ddr.ram 0000000010000000-0000000010000fff (prio 0, i/o): pl011 0000000011000000-00000000110001ff (prio 0, i/o): virtio-mmio 0000000012000000-00000000120001ff (prio 0, i/o): virtio-mmio 00000000d81e0000-00000000d81effff (prio 0, i/o): fast 00000000d8400000-00000000d87fffff (prio 0, ram): vtcm.ram 00000000de000000-00000000de0001ff (prio 0, rom): config_table.rom 00000000fc910000-00000000fc910fff (prio 0, i/o): l2vic
Quoted 2 lines
Could we have minimal debug output on the console?
For now minivm relies on semihosting, which is convenient. So I can postpone this test until after that's introduced if it helps. We have the boot-serial-test in this patch series now, so perhaps that's adequate?
Otherwise, I think the above suggestions other than console output have been addressed in v2.
Quoted 6 lines
tests/functional/test_hexagon_minivm.py line 42
Quoted 3 lines
tests/functional/test_hexagon_minivm.py new file +3
-0+ +if __name__ == '__main__': + QemuSystemTest.main()