xlnx-zynqmp: add support to boot on RPUs
v2 cover xlnx-zynqmp: add support to boot on RPUs
This series enhances Xilinx ZynqMP support to allow booting on RPUs and ease gdb connections to them.
It was validated with home-made binaries. FreeRTOS was tested but without
success: outputs/IRQ seems broken. AFAICT, FreeRTOS is expecting Xilinx's QEMU thus I didn't investigate further, but I'd still like advice on the 3rd patch ("wire a second GIC") since it could be related to it.
Changes since v1:
- add doc for "first-cpu-index" new property in arm_gic.h.
Clément Chigot (2):
hw/arm: make cpu targeted by arm_load_kernel the primary CPU. hw/arm/xlnx-zynqmp: adapt cluster-id based on the boot cpu
Frederic Konrad (2):
hw/intc/arm_gic: introduce a first-cpu-index property hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5
hw/arm/boot.c | 15 +++-- hw/arm/xlnx-zynqmp.c | 104 ++++++++++++++++++++++++++++--- hw/intc/arm_gic.c | 2 +- hw/intc/arm_gic_common.c | 1 + include/hw/arm/boot.h | 3 + include/hw/arm/xlnx-zynqmp.h | 6 ++ include/hw/intc/arm_gic.h | 2 + include/hw/intc/arm_gic_common.h | 2 + 8 files changed, 117 insertions(+), 18 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 hw/arm: make cpu targeted by arm_load_kernel the primary CPU.
Currently, arm booting processus assumes that the first_cpu is the CPU that will boot: arm_load_kernel is powering off all but the first_cpu; do_cpu_reset is setting the loader address only for this first_cpu.
For most of the boards, this isn't an issue as the kernel is loaded and booted on the first CPU anyway. However, for zynqmp, the option "boot-cpu" allows to choose any CPUs.
Create a new arm_boot_info entry primary_cpu recording which CPU will be boot first. This one is set when arm_boot_kernel is called.
--- hw/arm/boot.c | 15 +++++++-------- include/hw/arm/boot.h | 3 +++ 2 files changed, 10 insertions(+), 8 deletions(-)
hw/arm/boot.c +7 -8
@@ -743,7 +743,7 @@ static void do_cpu_reset(void *opaque) }else {if (arm_feature (env,ARM_FEATURE_EL3 ) && (info->secure_boot || - (info->secure_board_setup && cs == first_cpu))) { + (info->secure_board_setup && cpu == info->primary_cpu))) {/* Start this CPU in Secure SVC */ target_el =3 ; }
@@ -751,7 +751,7 @@ static void do_cpu_reset(void *opaque)arm_emulate_firmware_reset (cs, target_el); -if (cs == first_cpu) { +if (cpu == info->primary_cpu) {AddressSpace *as =arm_boot_address_space (cpu, info);cpu_set_pc (cs, info->loader_start);
@@ -1238,6 +1238,9 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info) info->dtb_filename = ms->dtb; info->dtb_limit =0 ; +/* We assume the CPU passed as argument is the primary CPU. */ + info->primary_cpu = cpu; +/* Load the kernel. */ if (!info->kernel_filename || info->firmware_loaded) {arm_setup_firmware_boot (cpu, info);
@@ -1287,12 +1290,8 @@ void arm_load_kernel(ARMCPU *cpu, MachineState *ms, struct arm_boot_info *info)object_property_set_int (cpuobj,"psci-conduit" , info->psci_conduit, &error_abort); -/* -* Secondary CPUs start in PSCI powered-down state. Like the -* code in do_cpu_reset(), we assume first_cpu is the primary -* CPU. -*/ -if (cs != first_cpu) { +/* Secondary CPUs start in PSCI powered-down state. */ +if (ARM_CPU (cs) != info->primary_cpu) {object_property_set_bool (cpuobj,"start-powered-off" , true, &error_abort); }
include/hw/arm/boot.h +3 -0
@@ -132,6 +132,9 @@ struct arm_boot_info {bool secure_board_setup;arm_endianness endianness; + +/* CPU having load the kernel and that should be the first to boot. */ +ARMCPU *primary_cpu; };/**
Signature · 1 line
2.34.1
PATCH v2 2/4 hw/intc/arm_gic: introduce a first-cpu-index property
In reply to Clément ChigotFrom: Frederic Konrad <[email protected]>
This introduces a first-cpu-index property to the arm-gic, as some SOCs could have two separate GIC (ie: the zynqmp).
--- hw/intc/arm_gic.c | 2 +- hw/intc/arm_gic_common.c | 1 + include/hw/intc/arm_gic.h | 2 ++ include/hw/intc/arm_gic_common.h | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-)
hw/intc/arm_gic.c +1 -1
@@ -59,7 +59,7 @@ static const uint8_t gic_id_gicv2[] = {static inline int gic_get_current_cpu (GICState *s) {if (!qtest_enabled () && s->num_cpu >1 ) { -return current_cpu->cpu_index; +return current_cpu->cpu_index - s->first_cpu_index; }return 0 ; }
hw/intc/arm_gic_common.c +1 -0
@@ -350,6 +350,7 @@ static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,static const Property arm_gic_common_properties[] = {DEFINE_PROP_UINT32 ("num-cpu" , GICState, num_cpu,1 ), +DEFINE_PROP_UINT32 ("first-cpu-index" , GICState, first_cpu_index,0 ),DEFINE_PROP_UINT32 ("num-irq" , GICState, num_irq,32 ),/* Revision can be 1 or 2 for GIC architecture specification * versions 1 or 2, or 0 to indicate the legacy 11MPCore GIC.
include/hw/intc/arm_gic.h +2 -0
@@ -27,6 +27,8 @@* implement the security extensions * + QOM property "has-virtualization-extensions": set true if the GIC should * implement the virtualization extensions +* + QOM property "first-cpu-index": index of the first cpu attached to the +* GIC. * + unnamed GPIO inputs: (where P is number of SPIs, i.e. num-irq - 32) * [0..P-1] SPIs * [P..P+31] PPIs for CPU 0
include/hw/intc/arm_gic_common.h +2 -0
@@ -129,6 +129,8 @@ struct GICState {uint32_t num_lrs;uint32_t num_cpu; +/* cpu_index of the first CPU, attached to this GIC. */ +uint32_t first_cpu_index;MemoryRegion iomem;/* Distributor */ /* This is just so we can have an opaque pointer which identifies
Signature · 1 line
2.34.1
Re: [PATCH v2 2/4] hw/intc/arm_gic: introduce a first-cpu-index property
Quoted 8 lines · Clément Chigot
From: Frederic Konrad <[email protected]>
This introduces a first-cpu-index property to the arm-gic, as some SOCs could have two separate GIC (ie: the zynqmp).
Signed-off-by Clément Chigot <[email protected]>---
thanks
-- PMM
PATCH v2 3/4 hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5
In reply to Clément ChigotFrom: Frederic Konrad <[email protected]>
This wires a second GIC for the Cortex-R5, all the IRQs are split when there is an RPU instanciated.
--- hw/arm/xlnx-zynqmp.c | 88 +++++++++++++++++++++++++++++++++--- include/hw/arm/xlnx-zynqmp.h | 6 +++ 2 files changed, 87 insertions(+), 7 deletions(-)
hw/arm/xlnx-zynqmp.c +81 -7
@@ -26,8 +26,6 @@#include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h" -#define GIC_NUM_SPI_INTR 160 -#define ARM_PHYS_TIMER_PPI 30#define ARM_VIRT_TIMER_PPI 27#define ARM_HYP_TIMER_PPI 26
@@ -206,7 +204,7 @@ static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] = {static inline int arm_gic_ppi_index (int cpu_nr,int ppi_index) { -return GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index; +return XLXN_ZYNQMP_GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index; } static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
@@ -377,6 +375,8 @@ static void xlnx_zynqmp_init(Object *obj)XlnxZynqMPState *s =XLNX_ZYNQMP (obj);int i;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN ((int )(ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS ), +XLNX_ZYNQMP_NUM_RPU_CPUS );object_initialize_child (obj,"apu-cluster" , &s->apu_cluster,TYPE_CPU_CLUSTER );
@@ -390,6 +390,12 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize_child (obj,"gic" , &s->gic,gic_class_name ()); +if (num_rpus >0 ) { +/* Do not create the rpu_gic in case we don't have rpus.. */ +object_initialize_child (obj,"rpu_gic" , &s->rpu_gic, +gic_class_name ()); + } +for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {object_initialize_child (obj,"gem[*]" , &s->gem[i],TYPE_CADENCE_GEM ); object_initialize_child(obj, "gem-irq-orgate[*]",
@@ -439,6 +445,13 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize_child (obj,"qspi-irq-orgate" , &s->qspi_irq_orgate,TYPE_OR_IRQ ); +for (i =0 ; i <ARRAY_SIZE (s->splitter); i++) { + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); +object_initialize_child (obj, name, &s->splitter[i],TYPE_SPLIT_IRQ ); + } + + +for (i =0 ; i <XLNX_ZYNQMP_NUM_USB ; i++) {object_initialize_child (obj,"usb[*]" , &s->usb[i],TYPE_USB_DWC3 ); }
@@ -452,10 +465,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)uint8_t i;uint64_t ram_size;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN ((int )(ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS ), +XLNX_ZYNQMP_NUM_RPU_CPUS );const char *boot_cpu = s->boot_cpu ? s->boot_cpu :"apu-cpu[0]" ;ram_addr_t ddr_low_size, ddr_high_size; -qemu_irq gic_spi[GIC_NUM_SPI_INTR ]; +qemu_irq gic_spi[XLXN_ZYNQMP_GIC_NUM_SPI_INTR ];Error *err =NULL ; +DeviceState *splitter; ram_size =memory_region_size (s->ddr_ram);
@@ -502,13 +518,21 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)g_free (ocm_name); } -qdev_prop_set_uint32 (DEVICE (&s->gic),"num-irq" ,GIC_NUM_SPI_INTR +32 ); +qdev_prop_set_uint32 (DEVICE (&s->gic),"num-irq" ,XLXN_ZYNQMP_GIC_NUM_SPI_INTR +32 );qdev_prop_set_uint32 (DEVICE (&s->gic),"revision" ,2 );qdev_prop_set_uint32 (DEVICE (&s->gic),"num-cpu" , num_apus);qdev_prop_set_bit (DEVICE (&s->gic),"has-security-extensions" , s->secure);qdev_prop_set_bit (DEVICE (&s->gic),"has-virtualization-extensions" , s->virt); +if (num_rpus >0 ) { +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"num-irq" , +XLXN_ZYNQMP_GIC_NUM_SPI_INTR +32 ); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"revision" ,1 ); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"num-cpu" , num_rpus); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"first-cpu-index" ,4 ); + } +qdev_realize (DEVICE (&s->apu_cluster),NULL , &error_fatal);/* Realize APUs before realizing the GIC. KVM requires this. */
@@ -608,13 +632,63 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)return ; } +if (num_rpus >0 ) { +if (!sysbus_realize (SYS_BUS_DEVICE (&s->rpu_gic), errp)) { +return ; + } + +for (i =0 ; i < num_rpus; i++) { +qemu_irq irq; + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->rpu_gic), i +1 , +GIC_BASE_ADDR + i *0x1000 ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->rpu_gic), i, +qdev_get_gpio_in (DEVICE (&s->rpu_cpu[i]), +ARM_CPU_IRQ )); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->rpu_gic), i + num_rpus, +qdev_get_gpio_in (DEVICE (&s->rpu_cpu[i]), +ARM_CPU_FIQ )); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->rpu_gic), i + num_rpus *2 , +qdev_get_gpio_in (DEVICE (&s->rpu_cpu[i]), +ARM_CPU_VIRQ )); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->rpu_gic), i + num_rpus *3 , +qdev_get_gpio_in (DEVICE (&s->rpu_cpu[i]), +ARM_CPU_VFIQ )); + irq =qdev_get_gpio_in (DEVICE (&s->rpu_gic), +arm_gic_ppi_index (i,ARM_PHYS_TIMER_PPI )); +qdev_connect_gpio_out (DEVICE (&s->rpu_cpu[i]),GTIMER_PHYS , irq); + irq =qdev_get_gpio_in (DEVICE (&s->rpu_gic), +arm_gic_ppi_index (i,ARM_VIRT_TIMER_PPI )); +qdev_connect_gpio_out (DEVICE (&s->rpu_cpu[i]),GTIMER_VIRT , irq); + irq =qdev_get_gpio_in (DEVICE (&s->rpu_gic), +arm_gic_ppi_index (i,ARM_HYP_TIMER_PPI )); +qdev_connect_gpio_out (DEVICE (&s->rpu_cpu[i]),GTIMER_HYP , irq); + irq =qdev_get_gpio_in (DEVICE (&s->rpu_gic), +arm_gic_ppi_index (i,ARM_SEC_TIMER_PPI )); +qdev_connect_gpio_out (DEVICE (&s->rpu_cpu[i]),GTIMER_SEC , irq); + } + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->rpu_gic),0 ,GIC_BASE_ADDR ); + } +if (!s->boot_cpu_ptr) {error_setg (errp,"ZynqMP Boot cpu %s not found" , boot_cpu);return ; } -for (i =0 ; i <GIC_NUM_SPI_INTR ; i++) { - gic_spi[i] =qdev_get_gpio_in (DEVICE (&s->gic), i); +for (i =0 ; i <XLXN_ZYNQMP_GIC_NUM_SPI_INTR ; i++) { + splitter =DEVICE (&s->splitter[i]); +qdev_prop_set_uint16 (splitter,"num-lines" ,2 ); +qdev_realize (splitter,NULL , &error_abort); +if (num_rpus >0 ) { + gic_spi[i] =qdev_get_gpio_in (splitter,0 ); +qdev_connect_gpio_out (splitter,0 , +qdev_get_gpio_in (DEVICE (&s->gic), i)); +qdev_connect_gpio_out (splitter,1 , +qdev_get_gpio_in (DEVICE (&s->rpu_gic), i)); + }else { + gic_spi[i] =qdev_get_gpio_in (DEVICE (&s->gic), i); + } }for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {
include/hw/arm/xlnx-zynqmp.h +6 -0
@@ -42,6 +42,7 @@#include "hw/misc/xlnx-zynqmp-crf.h" #include "hw/timer/cadence_ttc.h" #include "hw/usb/hcd-dwc3.h" +#include "hw/core/split-irq.h" #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )
@@ -87,12 +88,14 @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE)#define XLNX_ZYNQMP_NUM_TTC 4 +#define XLXN_ZYNQMP_GIC_NUM_SPI_INTR 160/* * Unimplemented mmio regions needed to boot some images. */ #define XLNX_ZYNQMP_NUM_UNIMP_AREAS 1 +struct XlnxZynqMPState {/*< private >*/ DeviceState parent_obj;
@@ -105,6 +108,9 @@ struct XlnxZynqMPState {GICState gic;MemoryRegion gic_mr[XLNX_ZYNQMP_GIC_REGIONS ][XLNX_ZYNQMP_GIC_ALIASES ]; +GICState rpu_gic; +SplitIRQ splitter[XLXN_ZYNQMP_GIC_NUM_SPI_INTR ]; +MemoryRegion ocm_ram[XLNX_ZYNQMP_NUM_OCM_BANKS ];MemoryRegion *ddr_ram;
Signature · 1 line
2.34.1
Re: [PATCH v2 3/4] hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5
Quoted 7 lines · Clément Chigot
From: Frederic Konrad <[email protected]>
This wires a second GIC for the Cortex-R5, all the IRQs are split when there is an RPU instanciated.
Signed-off-by Clément Chigot <[email protected]>
Some review of this from the Xilinx folks would be helpful.
Quoted 19 lines
--- hw/arm/xlnx-zynqmp.c | 88 +++++++++++++++++++++++++++++++++--- include/hw/arm/xlnx-zynqmp.h | 6 +++ 2 files changed, 87 insertions(+), 7 deletions(-)hw/arm/xlnx-zynqmp.c +0
-2@@ -26,8 +26,6 @@#include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h" -#define GIC_NUM_SPI_INTR 160 -#define ARM_PHYS_TIMER_PPI 30#define ARM_VIRT_TIMER_PPI 27#define ARM_HYP_TIMER_PPI 26
hw/arm/xlnx-zynqmp.c static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] = { · line 207
Quoted 5 lines
hw/arm/xlnx-zynqmp.c +1
-1@@ -206,7 +204,7 @@ static const XlnxZynqMPGICRegion xlnx_zynqmp_gic_regions[] = {static inline int arm_gic_ppi_index (int cpu_nr,int ppi_index) { -return GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index; +return XLXN_ZYNQMP_GIC_NUM_SPI_INTR + cpu_nr *GIC_INTERNAL + ppi_index;
Typo in your new constant name: should be XLNX_.
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_init(Object *obj) · line 379
Quoted 9 lines
hw/arm/xlnx-zynqmp.c +2
-0} static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,@@ -377,6 +375,8 @@ static void xlnx_zynqmp_init(Object *obj)XlnxZynqMPState *s =XLNX_ZYNQMP (obj);int i;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN ((int )(ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS ), +XLNX_ZYNQMP_NUM_RPU_CPUS );
This is kind of a complicated expression that we use twice, and I think it would be worth abstracting out into a function.
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_init(Object *obj) · line 394
Quoted 8 lines
hw/arm/xlnx-zynqmp.c +2
-0object_initialize_child (obj,"apu-cluster" , &s->apu_cluster,TYPE_CPU_CLUSTER );@@ -390,6 +390,12 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize_child (obj,"gic" , &s->gic,gic_class_name ()); +if (num_rpus >0 ) { +/* Do not create the rpu_gic in case we don't have rpus.. */
stray ".." at end. Also I would say "if", rather than "in case".
Quoted 8 lines
hw/arm/xlnx-zynqmp.c +4
-0+object_initialize_child (obj,"rpu_gic" , &s->rpu_gic, +gic_class_name ()); + } +for (i =0 ; i <XLNX_ZYNQMP_NUM_GEMS ; i++) {object_initialize_child (obj,"gem[*]" , &s->gem[i],TYPE_CADENCE_GEM ); object_initialize_child(obj, "gem-irq-orgate[*]",
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_init(Object *obj) · line 451
Quoted 7 lines
hw/arm/xlnx-zynqmp.c +4
-0@@ -439,6 +445,13 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize_child (obj,"qspi-irq-orgate" , &s->qspi_irq_orgate,TYPE_OR_IRQ ); +for (i =0 ; i <ARRAY_SIZE (s->splitter); i++) { + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); +object_initialize_child (obj, name, &s->splitter[i],TYPE_SPLIT_IRQ ); + }
We don't need the splitters unless num_rpus > 0, so I think it would be neater not to create/realize/use them.
Quoted 8 lines
hw/arm/xlnx-zynqmp.c +3
-0+ + +for (i =0 ; i <XLNX_ZYNQMP_NUM_USB ; i++) {object_initialize_child (obj,"usb[*]" , &s->usb[i],TYPE_USB_DWC3 ); }@@ -452,10 +465,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)uint8_t i;
hw/arm/xlnx-zynqmp.c static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) · line 474
Quoted 10 lines
hw/arm/xlnx-zynqmp.c +4
-1uint64_t ram_size;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS ); +int num_rpus =MIN ((int )(ms->smp.cpus -XLNX_ZYNQMP_NUM_APU_CPUS ), +XLNX_ZYNQMP_NUM_RPU_CPUS );const char *boot_cpu = s->boot_cpu ? s->boot_cpu :"apu-cpu[0]" ;ram_addr_t ddr_low_size, ddr_high_size; -qemu_irq gic_spi[GIC_NUM_SPI_INTR ]; +qemu_irq gic_spi[XLXN_ZYNQMP_GIC_NUM_SPI_INTR ];Error *err =NULL ; +DeviceState *splitter;
I think you can put this variable declaration inside the loop where it is used, so it has a much smaller scope.
Quoted 40 lines
hw/arm/xlnx-zynqmp.c +9
-1ram_size =memory_region_size (s->ddr_ram);@@ -502,13 +518,21 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)g_free (ocm_name); } -qdev_prop_set_uint32 (DEVICE (&s->gic),"num-irq" ,GIC_NUM_SPI_INTR +32 ); +qdev_prop_set_uint32 (DEVICE (&s->gic),"num-irq" ,XLXN_ZYNQMP_GIC_NUM_SPI_INTR +32 );qdev_prop_set_uint32 (DEVICE (&s->gic),"revision" ,2 );qdev_prop_set_uint32 (DEVICE (&s->gic),"num-cpu" , num_apus);qdev_prop_set_bit (DEVICE (&s->gic),"has-security-extensions" , s->secure);qdev_prop_set_bit (DEVICE (&s->gic),"has-virtualization-extensions" , s->virt); +if (num_rpus >0 ) { +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"num-irq" , +XLXN_ZYNQMP_GIC_NUM_SPI_INTR +32 ); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"revision" ,1 ); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"num-cpu" , num_rpus); +qdev_prop_set_uint32 (DEVICE (&s->rpu_gic),"first-cpu-index" ,4 ); + } +qdev_realize (DEVICE (&s->apu_cluster),NULL , &error_fatal);/* Realize APUs before realizing the GIC. KVM requires this. */ include/hw/arm/xlnx-zynqmp.h +1
-0@@ -42,6 +42,7 @@#include "hw/misc/xlnx-zynqmp-crf.h" #include "hw/timer/cadence_ttc.h" #include "hw/usb/hcd-dwc3.h" +#include "hw/core/split-irq.h" #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp"OBJECT_DECLARE_SIMPLE_TYPE (XlnxZynqMPState,XLNX_ZYNQMP )@@ -87,12 +88,14 @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE)
include/hw/arm/xlnx-zynqmp.h OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) · line 98
Quoted 10 lines
include/hw/arm/xlnx-zynqmp.h +2
-0#define XLNX_ZYNQMP_NUM_TTC 4 +#define XLXN_ZYNQMP_GIC_NUM_SPI_INTR 160/* * Unimplemented mmio regions needed to boot some images. */ #define XLNX_ZYNQMP_NUM_UNIMP_AREAS 1 +
Stray extra whitespace change.
include/hw/arm/xlnx-zynqmp.h struct XlnxZynqMPState { · line 116
Quoted 13 lines
include/hw/arm/xlnx-zynqmp.h +3
-0struct XlnxZynqMPState {/*< private >*/ DeviceState parent_obj;@@ -105,6 +108,9 @@ struct XlnxZynqMPState {GICState gic;MemoryRegion gic_mr[XLNX_ZYNQMP_GIC_REGIONS ][XLNX_ZYNQMP_GIC_ALIASES ]; +GICState rpu_gic; +SplitIRQ splitter[XLXN_ZYNQMP_GIC_NUM_SPI_INTR ]; +MemoryRegion ocm_ram[XLNX_ZYNQMP_NUM_OCM_BANKS ];MemoryRegion *ddr_ram;
thanks
-- PMM
PATCH v2 4/4 hw/arm/xlnx-zynqmp: adapt cluster-id based on the boot cpu
In reply to Clément ChigotWhen gdb is being connected to QEMU, it will be attached to the first CPU cluster. However, the ZynqMP board has two clusters, those being of two different architectures.
Therefore, when gdb is connecting to the ZynqMP, it receives the target descriptor of the first CPU cluster. Up to now, it was always the APU cluster, which is AARCH64.
When booting on a RPU, gdb will still connect to the APU. If gdb is supporting only ARM32, it will receive the APU target descriptor, resulting in:
| (gdb) target remote :1234 | warning: while parsing target description (at line 1): Target | description specified unknown architecture "aarch64"
Adjust the cluster-id based on the boot cpu will resolve the above issue; allowing a pure ARM32 toolchain to debug programs running on RPUs.
--- hw/arm/xlnx-zynqmp.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
hw/arm/xlnx-zynqmp.c +14 -2
@@ -221,7 +221,13 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,object_initialize_child (OBJECT (s),"rpu-cluster" , &s->rpu_cluster,TYPE_CPU_CLUSTER ); -qdev_prop_set_uint32 (DEVICE (&s->rpu_cluster),"cluster-id" ,1 ); + +/* In order to connect gdb to the boot cpu, adjust the cluster-id. */ +if (!strncmp (boot_cpu,"rpu-cpu" ,7 )) { +qdev_prop_set_uint32 (DEVICE (&s->rpu_cluster),"cluster-id" ,0 ); + }else { +qdev_prop_set_uint32 (DEVICE (&s->rpu_cluster),"cluster-id" ,1 ); + }for (i =0 ; i < num_rpus; i++) {const char *name;
@@ -380,7 +386,6 @@ static void xlnx_zynqmp_init(Object *obj)object_initialize_child (obj,"apu-cluster" , &s->apu_cluster,TYPE_CPU_CLUSTER ); -qdev_prop_set_uint32 (DEVICE (&s->apu_cluster),"cluster-id" ,0 );for (i =0 ; i < num_apus; i++) { object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
@@ -475,6 +480,13 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) ram_size =memory_region_size (s->ddr_ram); +/* In order to connect gdb to the boot cpu, adjust the cluster-id. */ +if (!strncmp (boot_cpu,"apu-cpu" ,7 )) { +qdev_prop_set_uint32 (DEVICE (&s->apu_cluster),"cluster-id" ,0 ); + }else { +qdev_prop_set_uint32 (DEVICE (&s->apu_cluster),"cluster-id" ,1 ); + } +/* * Create the DDR Memory Regions. User friendly checks should happen at * the board level
Signature · 1 line
2.34.1
Quoted 12 lines · Clément Chigot
This series enhances Xilinx ZynqMP support to allow booting on RPUs and ease gdb connections to them.
It was validated with home-made binaries. FreeRTOS was tested but without
success: outputs/IRQ seems broken. AFAICT, FreeRTOS is expecting Xilinx's QEMU thus I didn't investigate further, but I'd still like advice on the 3rd patch ("wire a second GIC") since it could be related to it.Changes since v1:
- add doc for "first-cpu-index" new property inarm_gic.h.
Quoted 7 lines
Clément Chigot (2):
hw/arm: make cpu targeted byarm_load_kernelthe primary CPU. hw/arm/xlnx-zynqmp: adapt cluster-id based on the boot cpuFrederic Konrad (2):
hw/intc/arm_gic: introduce a first-cpu-index property hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5
Hi; I've taken the first 2 patches in this series into target-arm.next. I left some review comments on patch 3. For patch 4, I still feel this is something that should be dealt with at the gdb end (e.g. gdb should support "connect to this target and connect to remote-inferior 2, not inferior 1, and don't fall over just because you don't know the architecture of inferior 1").
thanks
-- PMM
Quoted 18 lines · Peter Maydell
Quoted 16 lines · Clément Chigot
This series enhances Xilinx ZynqMP support to allow booting on RPUs and ease gdb connections to them.
It was validated with home-made binaries. FreeRTOS was tested but without
success: outputs/IRQ seems broken. AFAICT, FreeRTOS is expecting Xilinx's QEMU thus I didn't investigate further, but I'd still like advice on the 3rd patch ("wire a second GIC") since it could be related to it.Changes since v1:
- add doc for "first-cpu-index" new property inarm_gic.h.Clément Chigot (2):
hw/arm: make cpu targeted byarm_load_kernelthe primary CPU. hw/arm/xlnx-zynqmp: adapt cluster-id based on the boot cpu
Quoted 6 lines
Quoted 3 lines
Frederic Konrad (2):
hw/intc/arm_gic: introduce a first-cpu-index property hw/arm/xlnx-zynqmp: wire a second GIC for the Cortex-R5Hi; I've taken the first 2 patches in this series into target-arm.next. I left some review comments on patch 3.
Thanks a lot. I've just sent a v3 addressing them.
Quoted 5 lines
For patch 4, I still feel this is something that should be dealt with at the gdb end (e.g. gdb should support "connect to this target and connect to remote-inferior 2, not inferior 1, and don't fall over just because you don't know the architecture of inferior 1").
Yeah, I'm totally fine with that, I've removed it from v3.
PS: I'll be off for a few weeks but should be able to make a v4 if needed before 10.1 soft freeze.
Thanks, Clément