On 20/8/25 14:16, Philippe Mathieu-Daudé wrote:
Hi Luc,
On 20/8/25 10:25, Luc Michel wrote:
Refactor the CPU cluster creation using the VersalMap structure. There
is no functional change. The clusters properties are now described in
the VersalMap structure. For now only the APU is converted. The RPU will
be taken care of by next commits.
Signed-off-by: Luc Michel <luc.mic...@amd.com>
Reviewed-by: Francisco Iglesias <francisco.igles...@amd.com>
---
include/hw/arm/xlnx-versal.h | 11 +-
hw/arm/xlnx-versal-virt.c | 80 +-------
hw/arm/xlnx-versal.c | 346 ++++++++++++++++++++++++++---------
3 files changed, 269 insertions(+), 168 deletions(-)
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
index af47acb288f..ba5719d80f5 100644
--- a/include/hw/arm/xlnx-versal.h
+++ b/include/hw/arm/xlnx-versal.h
@@ -41,19 +40,10 @@ OBJECT_DECLARE_TYPE(Versal, VersalClass,
XLNX_VERSAL_BASE)
struct Versal {
/*< private >*/
SysBusDevice parent_obj;
/*< public >*/
- struct {
- struct {
- MemoryRegion mr;
- CPUClusterState cluster;
- ARMCPU cpu[XLNX_VERSAL_NR_ACPUS];
- GICv3State gic;
- } apu;
- } fpd;
@@ -427,11 +359,11 @@ static void versal_virt_init(MachineState *machine)
/* Some boot-loaders (e.g u-boot) don't like blobs at
address 0 (NULL).
* Offset things by 4K. */
s->binfo.loader_start = 0x1000;
s->binfo.dtb_limit = 0x1000000;
}
- arm_load_kernel(&s->soc.fpd.apu.cpu[0], machine, &s->binfo);
+ arm_load_kernel(ARM_CPU(qemu_get_cpu(0)), machine, &s->binfo);
We'd like to restrict qemu_get_cpu() to generic accelerator code, where
what type of scheduled vCPU doesn't matter. And forbid this API under
hw/, because it triggers odd bugs in heterogenous context (we can
instanciate vCPU in random order, and hot[un]plug them, changing their
id). Besides hw/ normally have knowledge of how to directly address a
CPU (how/where it is wired). So I'm not really keen on adding another
qemu_get_cpu() call here. Can't we keep references in VersalVirt (at
least for the booting cpu)?
Otherwise simpler to use the constant QOM path:
booting_cpu = ARM_CPU(object_resolve_path("/machine/fpd/apu/cpu[0]"));
for (i = 0; i < XLNX_VERSAL_NUM_OSPI_FLASH; i++) {
ObjectClass *flash_klass;
DriveInfo *dinfo = drive_get(IF_MTD, 0, i);
BlockBackend *blk;
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
index fe2c789a557..5a08ad07b28 100644
--- a/hw/arm/xlnx-versal.c
+++ b/hw/arm/xlnx-versal.c
@@ -41,10 +41,11 @@
#include "hw/rtc/xlnx-zynqmp-rtc.h"
#include "hw/misc/xlnx-versal-cfu.h"
#include "hw/misc/xlnx-versal-cframe-reg.h"
#include "hw/or-irq.h"
#include "hw/misc/xlnx-versal-crl.h"
+#include "hw/intc/arm_gicv3_common.h"
#define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72")
#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f")
#define GEM_REVISION 0x40070106
@@ -65,11 +66,38 @@ FIELD(VERSAL_IRQ, OR_IDX, 19, 4) /* input index on
the IRQ OR gate */
typedef struct VersalSimplePeriphMap {
uint64_t addr;
int irq;
} VersalSimplePeriphMap;
+typedef struct VersalGicMap {
+ int version;
+ uint64_t dist;
+ uint64_t redist;
+ size_t num_irq;
+} VersalGicMap;
+
+enum StartPoweredOffMode {
+ SPO_SECONDARIES,
+ SPO_ALL,
+};
+
+typedef struct VersalCpuClusterMap {
+ VersalGicMap gic;
+
+ const char *name;
+ const char *cpu_model;
+ size_t num_core;
+ size_t num_cluster;
+ uint32_t qemu_cluster_id;
+ bool dtb_expose;
+
+ enum StartPoweredOffMode start_powered_off;
+} VersalCpuClusterMap;
+
typedef struct VersalMap {
+ VersalCpuClusterMap apu;
+
VersalSimplePeriphMap uart[2];
size_t num_uart;