Implement GIC-500 from GICv3 family for arm64
v4 cover Implement GIC-500 from GICv3 family for arm64
From: Shlomo Pongratz <[email protected]>
This patch is a first step toward 128 cores support for arm64.
At first only 64 cores are supported.
This is because largest integer type has the size of 64 bits and modifying essential data structures in order to support 128 cores will require the usage of bitops.
Things left to do:
Support SPI, note that this patch porpose is to enable running 64 cores using the "virt" virtual machine.
Add support for 128 cores. This requires the usage of bitops which requires a major rewrite.
Special thanks to Peter Crostwaite whose patch to th Linux (kernel) i.e. Implement cpu_relax as yield solved the problem of the boot process getting stuck for 24 cores and more.
V3->V4:
- Rebase the patch series on Pavel Feding's "vGICv3 support" V14 patch series.
- Replace the usage of vnic/irqchip in the CPU structure to keep the gic object for the system instructions with the usage of the routine define_arm_cp_regs_with_opaque() as suggested by Peter Maydell in his mail from August the 3rd.
V2->V3:
- Replace my original 1 & 4 patches with Pavel's patches.
- Add groups support to complies with new GICv2 addtions
- Cosmetic changes.
V1->V2:
- Split the original patch to 4 patches
- Add SRE API to the GIC code.
- Add call to gicv3_update to armv8_gicv3_set_priority_mask.
- Cosmetic changes.
- Fix number of irq when reading GICD_TYPER.
Pavel Fedin (1):
Add virt-v3 machine that uses GIC-500
Shlomo Pongratz (3):
hw/intc: Implement GIC-500 support files hw/intc: Implment GIC-500
target-arm/cpu64 GICv3 system instructions support
hw/arm/virt.c | 72 +- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3.c | 2044 ++++++++++++++++++++++++++++++++++++ hw/intc/arm_gicv3_common.c | 120 ++- hw/intc/gicv3_internal.h | 161 +++ include/hw/arm/fdt.h | 2 + include/hw/arm/virt.h | 1 + include/hw/intc/arm_gicv3.h | 44 + include/hw/intc/arm_gicv3_common.h | 56 +- target-arm/cpu-qom.h | 1 + target-arm/cpu.h | 12 + target-arm/cpu64.c | 118 +++ target-arm/machine.c | 7 +- 13 files changed, 2627 insertions(+), 12 deletions(-) create mode 100644 hw/intc/arm_gicv3.c create mode 100644 hw/intc/gicv3_internal.h create mode 100644 include/hw/intc/arm_gicv3.h
Signature · 1 line
1.9.1
RFC PATCH v4 1/4 hw/intc: Implement GIC-500 support files
From: Shlomo Pongratz <[email protected]>
Add files need to maintain the GIC-500 state.
--- hw/intc/arm_gicv3_common.c | 120 ++++++++++++++++++++++++++- hw/intc/gicv3_internal.h | 161 +++++++++++++++++++++++++++++++++++++ include/hw/intc/arm_gicv3.h | 44 ++++++++++ include/hw/intc/arm_gicv3_common.h | 56 ++++++++++++- 4 files changed, 378 insertions(+), 3 deletions(-) create mode 100644 hw/intc/gicv3_internal.h create mode 100644 include/hw/intc/arm_gicv3.h
hw/intc/arm_gicv3_common.c +118 -2
@@ -21,6 +21,7 @@*/ #include "hw/intc/arm_gicv3_common.h" +#include "gicv3_internal.h" static void gicv3_pre_save (void *opaque) {
@@ -43,11 +44,52 @@ static int gicv3_post_load(void *opaque, int version_id)return 0 ; } +static const VMStateDescription vmstate_gicv3_irq_state = { + .name ="arm_gicv3_irq_state" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64 (pending, gicv3_irq_state), +VMSTATE_UINT64 (active, gicv3_irq_state), +VMSTATE_UINT64 (level, gicv3_irq_state), +VMSTATE_UINT64 (group, gicv3_irq_state), +VMSTATE_BOOL (edge_trigger, gicv3_irq_state), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_gicv3_sgi_state = { + .name ="arm_gicv3_sgi_state" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64_ARRAY (pending, gicv3_sgi_state,GICV3_NCPU ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_gicv3 = { .name ="arm_gicv3" , .unmigratable =1 , .pre_save = gicv3_pre_save, .post_load = gicv3_post_load, + .fields = (VMStateField []) { +VMSTATE_UINT32 (ctlr, GICv3State), +VMSTATE_UINT32_ARRAY (cpu_ctlr, GICv3State,GICV3_NCPU ), +VMSTATE_STRUCT_ARRAY (irq_state, GICv3State,GICV3_MAXIRQ ,1 , + vmstate_gicv3_irq_state, gicv3_irq_state), +VMSTATE_UINT64_ARRAY (irq_target, GICv3State,GICV3_MAXIRQ ), +VMSTATE_UINT8_2DARRAY (priority1, GICv3State,GICV3_INTERNAL ,GICV3_NCPU ), +VMSTATE_UINT8_ARRAY (priority2, GICv3State,GICV3_MAXIRQ -GICV3_INTERNAL ), +VMSTATE_UINT16_2DARRAY (last_active, GICv3State,GICV3_MAXIRQ ,GICV3_NCPU ), +VMSTATE_STRUCT_ARRAY (sgi_state, GICv3State,GICV3_NR_SGIS ,1 , + vmstate_gicv3_sgi_state, gicv3_sgi_state), +VMSTATE_UINT16_ARRAY (priority_mask, GICv3State,GICV3_NCPU ), +VMSTATE_UINT16_ARRAY (running_irq, GICv3State,GICV3_NCPU ), +VMSTATE_UINT16_ARRAY (running_priority, GICv3State,GICV3_NCPU ), +VMSTATE_UINT16_ARRAY (current_pending, GICv3State,GICV3_NCPU ), +VMSTATE_END_OF_LIST () + } }; void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,
@@ -88,6 +130,7 @@ void gicv3_init_irqs_and_mmio(GICv3State *s, qemu_irq_handler handler,static void arm_gicv3_common_realize (DeviceState *dev,Error **errp) {GICv3State *s =ARM_GICV3_COMMON (dev); +int num_irq = s->num_irq;/* revision property is actually reserved and currently used only in order * to keep the interface compatible with GICv2 code, avoiding extra
@@ -98,18 +141,91 @@ static void arm_gicv3_common_realize(DeviceState *dev, Error **errp)error_setg (errp,"unsupported GIC revision %d" , s->revision);return ; } +if (s->num_cpu >GICV3_NCPU ) { +error_setg (errp,"requested %u CPUs exceeds GIC maximum %d" , + s->num_cpu,GICV3_NCPU ); +return ; + } + s->num_irq +=GICV3_BASE_IRQ ; +if (s->num_irq >GICV3_MAXIRQ ) { +error_setg (errp, +"requested %u interrupt lines exceeds GIC maximum %d" , + num_irq,GICV3_MAXIRQ ); +return ; + } +/* ITLinesNumber is represented as (N / 32) - 1 (see +* gic_dist_readb) so this is an implementation imposed +* restriction, not an architectural one: +*/ +if (s->num_irq <32 || (s->num_irq %32 )) { +error_setg (errp, +"%d interrupt lines unsupported: not divisible by 32" , + num_irq); +return ; + } }static void arm_gicv3_common_reset (DeviceState *dev) { -/* TODO */ +GICv3State *s =ARM_GICV3_COMMON (dev); +int i; + +/* Note num_cpu and num_irq are properties */ + +/* Don't reset anything assigned in arm_gic_realize or any property */ + +/* No GICv2 backwards computability support */ +for (i =0 ; i < s->num_cpu; i++) { + s->priority_mask[i] =0 ; + s->current_pending[i] =1023 ; + s->running_irq[i] =1023 ; + s->running_priority[i] =0x100 ; + s->cpu_ctlr[i] =0 ; + } + +memset (s->irq_state,0 ,sizeof (s->irq_state)); +/* GIC-500 comment 'j' SGI are always enabled */ +for (i =0 ; i <GICV3_NR_SGIS ; i++) { +GIC_SET_ENABLED (i,ALL_CPU_MASK ); +GIC_SET_EDGE_TRIGGER (i); + } +memset (s->sgi_state,0 ,sizeof (s->sgi_state)); +memset (s->irq_target,0 ,sizeof (s->irq_target)); +if (s->num_cpu ==1 ) { +/* For uniprocessor GICs all interrupts always target the sole CPU */ +for (i =0 ; i <GICV3_MAXIRQ ; i++) { + s->irq_target[i] =1 ; + } + } +memset (s->priority1,0 ,sizeof (s->priority1)); +memset (s->priority2,0 ,sizeof (s->priority2)); +memset (s->last_active,0 ,sizeof (s->last_active)); + +/* With all configuration we don't support GICv2 backwards computability */ +if (s->security_levels >1 ) { +/* GICv3 5.3.20 With two security So DS is RAZ/WI ARE_NS is RAO/WI +* and ARE_S is RAO/WI +*/ + s->ctlr =GICD_CTLR_ARE_S |GICD_CTLR_ARE_NS ; + }else { +/* GICv3 5.3.20 With one security So DS is RAO/WI ARE is RAO/WI +*/ + s->ctlr =GICD_CTLR_DS |GICD_CTLR_ARE ; + } +/* Workaround! +* Linux (drivers/irqchip/irq-gic-v3.c) is enabling only group one, +* in gic_cpu_sys_reg_init it calls gic_write_grpen1(1); +* but it doesn't conigure any interrupt to be in group one +*/ +for (i =0 ; i < s->num_irq; i++) +GIC_SET_GROUP (i,ALL_CPU_MASK ); }static Property arm_gicv3_common_properties[] = {DEFINE_PROP_UINT32 ("num-cpu" , GICv3State, num_cpu,1 ),DEFINE_PROP_UINT32 ("num-irq" , GICv3State, num_irq,32 ),DEFINE_PROP_UINT32 ("revision" , GICv3State, revision,3 ), -DEFINE_PROP_BOOL ("has-security-extensions" , GICv3State, security_extn,0 ), +DEFINE_PROP_UINT8 ("security-levels" , GICv3State, security_levels,0 ),DEFINE_PROP_END_OF_LIST (), };
hw/intc/gicv3_internal.h new file +161 -0
161 lines not on this page · raw message
include/hw/intc/arm_gicv3.h new file +44 -0
44 lines not on this page · raw message
include/hw/intc/arm_gicv3_common.h +55 -1
75 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC PATCH v4 2/4 hw/intc: Implment GIC-500
In reply to Shlomo PongratzFrom: Shlomo Pongratz <[email protected]>
Implement GIC-500 from GICv3 family for arm64
This patch is a first step toward 128 cores support for arm64.
At first only 64 cores are supported.
This is because the largest integer type has the size of 64 bits and modifying essential data structures in order to support 128 cores will require the usage of bitops.
Currently SPI are not supported. This patch implements only what is necessary in order to run the hw/arm/virt.c board with 64 cores.
Things left to do:
Add support to 128 cores.
Implement SPI.
--- hw/intc/Makefile.objs | 1 + hw/intc/arm_gicv3.c | 2044 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2045 insertions(+) create mode 100644 hw/intc/arm_gicv3.c
hw/intc/Makefile.objs +1 -0
@@ -13,6 +13,7 @@ common-obj-$(CONFIG_ARM_GIC) += arm_gic_common.o common-obj-$(CONFIG_ARM_GIC) += arm_gic.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv2m.o common-obj-$(CONFIG_ARM_GIC) += arm_gicv3_common.o +common-obj-$(CONFIG_ARM_GIC) += arm_gicv3.o common-obj-$(CONFIG_OPENPIC) += openpic.o obj-$(CONFIG_APIC) += apic.o apic_common.o
hw/intc/arm_gicv3.c new file +2044 -0
2,044 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC PATCH v4 3/4 target-arm/cpu64 GICv3 system instructions support
In reply to Shlomo PongratzFrom: Shlomo Pongratz <[email protected]>
Add system instructions used by the Linux (kernel) GICv3 device driver
--- target-arm/cpu-qom.h | 1 + target-arm/cpu.h | 12 ++++++ target-arm/cpu64.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+)
target-arm/cpu-qom.h +1 -0
@@ -220,6 +220,7 @@ hwaddr arm_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);int arm_cpu_gdb_read_register (CPUState *cpu,uint8_t *buf,int reg);int arm_cpu_gdb_write_register (CPUState *cpu,uint8_t *buf,int reg); +void aatch64_registers_with_opaque_set (Object *obj,void *opaque);/* Callback functions for the generic timer's timers. */ void arm_gt_ptimer_cb (void *opaque);
target-arm/cpu.h +12 -0
@@ -1033,6 +1033,18 @@ void armv7m_nvic_set_pending(void *opaque, int irq);int armv7m_nvic_acknowledge_irq (void *opaque);void armv7m_nvic_complete_irq (void *opaque,int irq); +void armv8_gicv3_set_sgi (void *opaque,int cpuindex,uint64_t value); +uint64_t armv8_gicv3_acknowledge_irq (void *opaque,int cpuindex, +MemTxAttrs attrs); +void armv8_gicv3_complete_irq (void *opaque,int cpuindex,int irq, +MemTxAttrs attrs); +uint64_t armv8_gicv3_get_priority_mask (void *opaque,int cpuindex); +void armv8_gicv3_set_priority_mask (void *opaque,int cpuindex,uint32_t mask); +uint64_t armv8_gicv3_get_sre (void *opaque); +void armv8_gicv3_set_sre (void *opaque,uint64_t sre); +uint64_t armv8_gicv3_get_igrpen1 (void *opaque,int cpuindex); +void armv8_gicv3_set_igrpen1 (void *opaque,int cpuindex,uint64_t igrpen1); +/* Interface for defining coprocessor registers. * Registers are defined in tables of arm_cp_reginfo structs * which are passed to define_arm_cp_regs().
target-arm/cpu64.c +118 -0
130 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC PATCH v4 4/4 Add virt-v3 machine that uses GIC-500
In reply to Shlomo PongratzFrom: Pavel Fedin <[email protected]>
I would like to offer this, slightly improved implementation. The key thing is a new kernel_irqchip_type member in Machine class. Currently it it used only by virt machine for its internal purposes, however in future it is to be passed to KVM in kvm_irqchip_create(). The variable is defined as int in order to be architecture agnostic, for potential future users.
--- hw/arm/virt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++------ include/hw/arm/fdt.h | 2 ++ include/hw/arm/virt.h | 1 + target-arm/machine.c | 7 ++++- 4 files changed, 73 insertions(+), 9 deletions(-)
hw/arm/virt.c +64 -8
@@ -71,6 +71,7 @@ typedef struct VirtBoardInfo {uint32_t clock_phandle;uint32_t gic_phandle;uint32_t v2m_phandle; +const char *class_name; } VirtBoardInfo; typedef struct {
@@ -86,6 +87,7 @@ typedef struct { } VirtMachineState;#define TYPE_VIRT_MACHINE "virt" +#define TYPE_VIRTV3_MACHINE "virt-v3"#define VIRT_MACHINE (obj) \ OBJECT_CHECK(VirtMachineState, (obj), TYPE_VIRT_MACHINE)#define VIRT_MACHINE_GET_CLASS (obj) \
@@ -111,6 +113,7 @@ static const MemMapEntry a15memmap[] = { [VIRT_CPUPERIPHS] = { 0x08000000, 0x00020000 }, /* GIC distributor and CPU interfaces sit inside the CPU peripheral space */ [VIRT_GIC_DIST] = { 0x08000000, 0x00010000 }, + /* Note on GICv3 VIRT_GIC_DIST_SPI takes place of VIRT_GIC_CPU */ [VIRT_GIC_CPU] = { 0x08010000, 0x00010000 }, [VIRT_GIC_V2M] = { 0x08020000, 0x00001000 }, /* The space in between here is reserved for GICv3 CPU/vCPU/HYP */
@@ -145,21 +148,26 @@ static VirtBoardInfo machines[] = { .cpu_model = "cortex-a15", .memmap = a15memmap, .irqmap = a15irqmap, + .class_name = TYPE_ARM_CPU, + }, { .cpu_model = "cortex-a53", .memmap = a15memmap, .irqmap = a15irqmap, + .class_name = TYPE_AARCH64_CPU, }, { .cpu_model = "cortex-a57", .memmap = a15memmap, .irqmap = a15irqmap, + .class_name = TYPE_AARCH64_CPU, }, { .cpu_model = "host", .memmap = a15memmap, .irqmap = a15irqmap, + .class_name = TYPE_ARM_CPU, }, };
@@ -228,7 +236,6 @@ static void fdt_add_psci_node(const VirtBoardInfo *vbi)if (armcpu->psci_version ==2 ) {const char comp[] ="arm,psci-0.2\0arm,psci" ;qemu_fdt_setprop (fdt,"/psci" ,"compatible" , comp,sizeof (comp)); - cpu_off_fn =QEMU_PSCI_0_2_FN_CPU_OFF ;if (arm_feature (&armcpu->env,ARM_FEATURE_AARCH64 )) { cpu_suspend_fn =QEMU_PSCI_0_2_FN64_CPU_SUSPEND ;
@@ -241,7 +248,6 @@ static void fdt_add_psci_node(const VirtBoardInfo *vbi) } }else {qemu_fdt_setprop_string (fdt,"/psci" ,"compatible" ,"arm,psci" ); - cpu_suspend_fn =QEMU_PSCI_0_1_FN_CPU_SUSPEND ; cpu_off_fn =QEMU_PSCI_0_1_FN_CPU_OFF ; cpu_on_fn =QEMU_PSCI_0_1_FN_CPU_ON ;
@@ -274,6 +280,12 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi, int gictype) irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START ,GIC_FDT_IRQ_PPI_CPU_WIDTH , (1 << vbi->smp_cpus) -1 ); + }else if (gictype ==3 ) { +uint32_t max; +/* Argument is 32 bit but 8 bits are reserved for flags */ + max = (vbi->smp_cpus >=24 ) ?24 : vbi->smp_cpus; + irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START , +GICV3_FDT_IRQ_PPI_CPU_WIDTH , (1 << max) -1 ); }qemu_fdt_add_subnode (vbi->fdt,"/timer" );
@@ -434,7 +446,12 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)*/ qdev_prop_set_uint32 (gicdev,"num-irq" ,NUM_IRQS +32 );if (!kvm_irqchip_in_kernel ()) { -qdev_prop_set_bit (gicdev,"has-security-extensions" , secure); +if (type ==3 ) { +/* AARCH64 has 4 security levels */ +qdev_prop_set_uint8 (gicdev,"security-levels" , secure ?1 :0 ); + }else { +qdev_prop_set_bit (gicdev,"has-security-extensions" , secure); + } }qdev_init_nofail (gicdev); gicbusdev =SYS_BUS_DEVICE (gicdev);
@@ -445,6 +462,14 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)sysbus_mmio_map (gicbusdev,1 , vbi->memmap[VIRT_GIC_CPU ].base); } +if (type ==3 ) { +/* Connect GIC to CPU */ +for (i =0 ; i < smp_cpus; i++) { +CPUState *cpu =qemu_get_cpu (i); +aatch64_registers_with_opaque_set (OBJECT (cpu), (void *)gicdev); + } + } +/* Wire the outputs from each CPU's generic timer to the * appropriate GIC PPI inputs, and the GIC's IRQ output to * the CPU's IRQ input.
@@ -466,7 +491,7 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)for (irq =0 ; irq <ARRAY_SIZE (timer_irq); irq++) {qdev_connect_gpio_out (cpudev, irq,qdev_get_gpio_in (gicdev, - ppibase + timer_irq[irq])); + ppibase + timer_irq[irq])); }sysbus_connect_irq (gicbusdev, i,qdev_get_gpio_in (cpudev,ARM_CPU_IRQ ));
@@ -962,7 +987,7 @@ static void machvirt_init(MachineState *machine)create_fdt (vbi);for (n =0 ; n < smp_cpus; n++) { -ObjectClass *oc =cpu_class_by_name (TYPE_ARM_CPU , cpustr[0 ]); +ObjectClass *oc =cpu_class_by_name (vbi->class_name, cpustr[0 ]);CPUClass *cc =CPU_CLASS (oc);Object *cpuobj;Error *err =NULL ;
@@ -1111,7 +1136,7 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp) } } -static void virt_instance_init (Object *obj) +static void virt_instance_init_common (Object *obj,int32_t version) {VirtMachineState *vms =VIRT_MACHINE (obj);
@@ -1135,8 +1160,7 @@ static void virt_instance_init(Object *obj)"Set on/off to enable/disable using " "physical address space above 32 bits" , NULL); -/* Default GIC type is v2 */ - vms->gic_version =2 ; + vms->gic_version = version;object_property_add_str (obj,"gic-version" , virt_get_gic_version, virt_set_gic_version,NULL ); object_property_set_description(obj, "gic-version",
@@ -1144,6 +1168,12 @@ static void virt_instance_init(Object *obj) "Valid values are 2, 3 and host", NULL); } +static void virt_instance_init (Object *obj) +{ +/* Default GIC type is v2 */ +virt_instance_init_common (obj,2 ); +} +static void virt_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -1169,9 +1199,35 @@ static const TypeInfo machvirt_info = { .class_init = virt_class_init, }; +static void virtv3_instance_init (Object *obj) +{ +virt_instance_init_common (obj,3 ); +} + +static void virtv3_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->name =TYPE_VIRTV3_MACHINE ; + mc->desc ="ARM Virtual Machine with GICv3" , + mc->init = machvirt_init; +/* With gic3 full implementation (with bitops) rase the lmit to 128 */ + mc->max_cpus =64 ; +} + +static const TypeInfo machvirtv3_info = { + .name =TYPE_VIRTV3_MACHINE , + .parent =TYPE_VIRT_MACHINE , + .instance_size =sizeof (VirtMachineState), + .instance_init = virtv3_instance_init, + .class_size =sizeof (VirtMachineClass), + .class_init = virtv3_class_init, +}; +static void machvirt_machine_init (void ) {type_register_static (&machvirt_info); +type_register_static (&machvirtv3_info); }machine_init (machvirt_machine_init);
include/hw/arm/fdt.h +2 -0
@@ -30,5 +30,7 @@#define GIC_FDT_IRQ_PPI_CPU_START 8#define GIC_FDT_IRQ_PPI_CPU_WIDTH 8 +#define GICV3_FDT_IRQ_PPI_CPU_WIDTH 24 +#endif
include/hw/arm/virt.h +1 -0
@@ -46,6 +46,7 @@ enum {VIRT_CPUPERIPHS ,VIRT_GIC_DIST ,VIRT_GIC_CPU , +VIRT_GIC_DIST_SPI =VIRT_GIC_CPU ,VIRT_GIC_V2M ,VIRT_GIC_ITS , VIRT_GIC_REDIST,
target-arm/machine.c +6 -1
@@ -341,7 +341,12 @@ const char *gicv3_class_name(void)#endif }else {/* TODO: Software emulation is not implemented yet */ -error_report ("KVM is currently required for GICv3 emulation\n" ); +#ifdef TARGET_AARCH64 +return "arm_gicv3" ; +#else +error_report ("KVM GICv3 acceleration is not supported on this " +"platform\n" ); +#endif }exit (1 );
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PATCH RFC V4 4/4] Add virt-v3 machine that uses GIC-500
Hi,
Quoted 22 lines · Shlomo Pongratz
From: Pavel Fedin <[email protected]>
I would like to offer this, slightly improved implementation. The key thing is a new
kernel_irqchip_typemember in Machine class. Currently it it used only by virt machine for its internal purposes, however in future it is to be passed to KVM inkvm_irqchip_create(). The variable is defined as int in order to be architecture agnostic, for potential future users.Signed-off-by Pavel Fedin <[email protected]>--- hw/arm/virt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++------ include/hw/arm/fdt.h | 2 ++ include/hw/arm/virt.h | 1 + target-arm/machine.c | 7 ++++- 4 files changed, 73 insertions(+), 9 deletions(-)hw/arm/virt.c +0
-0
hw/arm/virt.c static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure) · line 469
Quoted 8 lines
hw/arm/virt.c +5
-0@@ -445,6 +462,14 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)sysbus_mmio_map (gicbusdev,1 , vbi->memmap[VIRT_GIC_CPU ].base); } +if (type ==3 ) { +/* Connect GIC to CPU */ +for (i =0 ; i < smp_cpus; i++) { +CPUState *cpu =qemu_get_cpu (i); +aatch64_registers_with_opaque_set (OBJECT (cpu), (void *)gicdev);
Typo--should be "aarch64".
With that, feel free to add the following if it's any use:
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [Qemu-devel] [PATCH RFC V4 4/4] Add virt-v3 machine that uses GIC-500
Quoted 36 lines · Christopher Covington
Hi,
Quoted 22 lines · Shlomo Pongratz
From: Pavel Fedin <[email protected]>
I would like to offer this, slightly improved implementation. The key thing is a new
kernel_irqchip_typemember in Machine class. Currently it it used only by virt machine for its internal purposes, however in future it is to be passed to KVM inkvm_irqchip_create(). The variable is defined as int in order to be architecture agnostic, for potential future users.Signed-off-by Pavel Fedin <[email protected]>--- hw/arm/virt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++------ include/hw/arm/fdt.h | 2 ++ include/hw/arm/virt.h | 1 + target-arm/machine.c | 7 ++++- 4 files changed, 73 insertions(+), 9 deletions(-)hw/arm/virt.c +0
-0hw/arm/virt.c static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure) · line 469
Quoted 8 lines
hw/arm/virt.c +5
-0@@ -445,6 +462,14 @@ static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)sysbus_mmio_map (gicbusdev,1 , vbi->memmap[VIRT_GIC_CPU ].base); } +if (type ==3 ) { +/* Connect GIC to CPU */ +for (i =0 ; i < smp_cpus; i++) { +CPUState *cpu =qemu_get_cpu (i); +aatch64_registers_with_opaque_set (OBJECT (cpu), (void *)gicdev);Typo--should be "aarch64".
Quoted 3 lines
With that, feel free to add the following if it's any use:
I originally tested building only for aarch64-softmmu, but I've now noticed a build issue with arm-softmmu.
Christopher Covington
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [Qemu-devel] [PATCH RFC V4 4/4] Add virt-v3 machine that uses GIC-500
Thanks,
I'll fix it and submit together with with the changes required by Peter.
Best regards,
S.P.
Quoted 58 lines · Christopher Covington
Quoted 6 lines · Christopher Covington
Hi,
Quoted 3 lines · Shlomo Pongratz
From: Pavel Fedin <[email protected] <javascript:;>>
I would like to offer this, slightly improved implementation. The key
thing is a new
Quoted 1 line
Quoted 1 line
kernel_irqchip_typemember in Machine class. Currently it it used onlyby virt machine for
Quoted 2 lines
Quoted 2 lines
its internal purposes, however in future it is to be passed to KVM in
kvm_irqchip_create(). The variable is defined as int in order to bearchitecture agnostic,
Quoted 5 lines
Quoted 5 lines
for potential future users.
Signed-off-by Pavel Fedin <[email protected] <javascript:;>>--- hw/arm/virt.c | 72+++++++++++++++++++++++++++++++++++++++++++++------
Quoted 11 lines
hw/arm/virt.c static void create_gic(VirtBoardInfo *vbi,
Quoted 11 lines
include/hw/arm/fdt.h | 2 ++ include/hw/arm/virt.h | 1 + target-arm/machine.c | 7 ++++- 4 files changed, 73 insertions(+), 9 deletions(-)hw/arm/virt.c +0
-0@@ -445,6 +462,14 @@ static void create_gic(VirtBoardInfo *vbi,
qemu_irq*pic, int type, bool secure)Quoted 8 lines
hw/arm/virt.c static void create_gic(VirtBoardInfo *vbi, qemu_irq *pic, int type, bool secure)
Quoted 8 lines
hw/arm/virt.c +5
-0sysbus_mmio_map (gicbusdev,1 , vbi->memmap[VIRT_GIC_CPU ].base); } +if (type ==3 ) { +/* Connect GIC to CPU */ +for (i =0 ; i < smp_cpus; i++) { +CPUState *cpu =qemu_get_cpu (i); + aatch64_registers_with_opaque_set(OBJECT(cpu), (void*)gicdev);
Quoted 6 lines
Typo--should be "aarch64".
With that, feel free to add the following if it's any use:
Tested-by Christopher Covington <[email protected] <javascript:;>>I originally tested building only for aarch64-softmmu, but I've now noticed a
build issue with arm-softmmu.Christopher Covington
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 14 lines · Shlomo Pongratz
From: Shlomo Pongratz <[email protected]>
This patch is a first step toward 128 cores support for arm64.
At first only 64 cores are supported.
This is because largest integer type has the size of 64 bits and modifying essential data structures in order to support 128 cores will require the usage of bitops.Things left to do:
Support SPI, note that this patch porpose is to enable running 64 cores using the "virt" virtual machine.
Quoted 6 lines
Add support for 128 cores. This requires the usage of bitops which requires a major rewrite.
Special thanks to Peter Crostwaite whose patch to th Linux (kernel) i.e. Implement
cpu_relaxas yield solved the problem of the boot process getting stuck for 24 cores and more.
This still seems to have the same issues as were noted in previous rounds:
* you need to get rid of the limitation on number of cores. There should be no hard limit imposed by the GIC emulation code: not 64, not 128, not anything.
* patch 2 is over 2000 lines, which is far too big to review. It needs to be split up. Aim for 200 lines per patch at maximum; smaller is better.
Also, patch 4 looks like it's an older version of one of Pavel's; you probably want to rebase on top of Pavel's recent v14 series, which is nearly ready to go into master.
thanks
-- PMM
Thanks
Please see inline
Best regards,
S.P.
Quoted 23 lines · Peter Maydell
Quoted 6 lines · On 17 September 2015 at 18:38, Shlomo Pongratz <[email protected]…
From: Shlomo Pongratz <[email protected] <javascript:;>>
This patch is a first step toward 128 cores support for arm64.
At first only 64 cores are supported.
This is because largest integer type has the size of 64 bits andmodifying
Quoted 6 lines
essential data structures in order to support 128 cores will require the usage of bitops.
Things left to do:
Support SPI, note that this patch porpose is to enable running 64 cores
using
Quoted 7 lines
the "virt" virtual machine.
Add support for 128 cores. This requires the usage of bitops which requires a major rewrite.
Special thanks to Peter Crostwaite whose patch to th Linux (kernel) i.e. Implement
cpu_relaxas yield solved the problem of the boot process
Quoted 9 lines
getting
Quoted 1 line
stuck for 24 cores and more.
This still seems to have the same issues as were noted in previous rounds:
* you need to get rid of the limitation on number of cores. There should be no hard limit imposed by the GIC emulation code: not 64, not 128, not anything.
The GICv3 spec limits the number of cores to 128. I assume you don't expect GICv2 to support more than 8 cores.
As I wrote since the largest "atomic" type is 64 bit supporting more than 64 cores requires major rewrite using bitops. This can be done but I think this can wait for future versions.
I wonder how can I remove the limit and not crash is someone tries an arbitrary large number.
How can I protect from wrong usage?
* patch 2 is over 2000 lines, which is far too big to review. It
Quoted 3 lines
needs to be split up. Aim for 200 lines per patch at maximum; smaller is better.
I'm open to suggestions. This is actually a single file (with the necessary Makefile addition). Do you suggest that I'll break it for example to distributer part an redistributer part e.t.c.?
Please advice.
Quoted 5 lines
Also, patch 4 looks like it's an older version of one of Pavel's; you probably want to rebase on top of Pavel's recent v14 series, which is nearly ready to go into master.
Patch #4 is based on Pavel's V14 5/5 patch but adds GICv3 to it.
Quoted 4 lines
thanks
-- PMM
Quoted 9 lines · Shlomo Pongratz
On Thursday, September 17, 2015, Peter Maydell <[email protected]>
Quoted 5 lines
This still seems to have the same issues as were noted in previous rounds:
* you need to get rid of the limitation on number of cores. There should be no hard limit imposed by the GIC emulation code: not 64, not 128, not anything.The GICv3 spec limits the number of cores to 128.
I don't believe it does (the only limit is the affinity fields which have a limit up in the millions). Can you point me to the part of the spec that you think imposes a lower limit?
Quoted 5 lines
I assume you don't expect
GICv2 to support more than 8 cores.
As I wrote since the largest "atomic" type is 64 bit supporting more than 64 cores requires major rewrite using bitops. This can be done but I think this can wait for future versions.
No, I don't want to accept a version with a limitation.
Data structures are important and we should get them right from the start. Don't look at the GICv2 to figure out what data structures you should have and how they should be arranged, look at the GICv3 spec.
(In particular, you probably want a data structure layout that says "this GIC has an array of N redistributors, and each redistributor has such-and-such state", rather than the QEMU GICv2 model's approach of having a struct per interrupt that tries to track per-CPU state within that struct.)
Quoted 3 lines
I wonder how can I remove the limit and not crash is someone tries an arbitrary large number.
How can I protect from wrong usage?
You need to allocate your data structures based on the number of CPUs which the user passes in to you. (We do this in Pavel's patchset for irq lines, for instance.) If the user passes in something that's so large we can't allocate memory, then QEMU's memory allocation functions will fail cleanly.
Quoted 9 lines
Quoted 3 lines
* patch 2 is over 2000 lines, which is far too big to review. It needs to be split up. Aim for 200 lines per patch at maximum; smaller is better.
I'm open to suggestions. This is actually a single file (with the necessary
Makefileaddition). Do you suggest that I'll break it for example to distributer part an redistributer parte.t.c.?
Please advice.
Yes, you need to split it up into logical subsections that each add a small but coherent piece of functionality. The purpose of splitting up into patches is to make the code easier to review for correctness. It's impossible to read a single 2000 line patch and keep it all in your head at once. So a split into multiple patches is about presenting the changes in a way that allows the reader to assess it in a logical order and not too much at once.
thanks
-- PMM
See inline.
Quoted 11 lines · Peter Maydell
Quoted 1 line · On 17 September 2015 at 19:18, Shlomo Pongratz <[email protected]…
On Thursday, September 17, 2015, Peter Maydell <[email protected]
<javascript:;>>
Quoted 7 lines
Quoted 5 lines
This still seems to have the same issues as were noted in previous rounds:
* you need to get rid of the limitation on number of cores. There should be no hard limit imposed by the GIC emulation code: not 64, not 128, not anything.
Quoted 7 lines
Quoted 1 line
The GICv3 spec limits the number of cores to 128.
I don't believe it does (the only limit is the affinity fields which have a limit up in the millions). Can you point me to the part of the spec that you think imposes a lower limit?
I don't have the GICv3 spec at home only the GIC 500 which is based on it and is what implemented also in HW and it states:
1.1 About the GIC-500 The GIC-500 is a build-time configurable interrupt controller that supports up to 128 cores.
I'll send the GICv3 reference next week when I'll come back to work (I have it only at work).
Quoted 52 lines
I assume you don't expect
Quoted 2 lines
GICv2 to support more than 8 cores.
As I wrote since the largest "atomic" type is 64 bit supporting morethan 64
Quoted 1 line
cores requires major rewrite using bitops. This can be done but I think
this
Quoted 1 line
can wait for future versions.
No, I don't want to accept a version with a limitation.
Data structures are important and we should get them right from the start. Don't look at the GICv2 to figure out what data structures you should have and how they should be arranged, look at the GICv3 spec.(In particular, you probably want a data structure layout that says "this GIC has an array of N redistributors, and each redistributor has such-and-such state", rather than the QEMU GICv2 model's approach of having a struct per interrupt that tries to track per-CPU state within that struct.)
Quoted 3 lines
I wonder how can I remove the limit and not crash is someone tries an arbitrary large number.
How can I protect from wrong usage?You need to allocate your data structures based on the number of CPUs which the user passes in to you. (We do this in Pavel's patchset for irq lines, for instance.) If the user passes in something that's so large we can't allocate memory, then QEMU's memory allocation functions will fail cleanly.
Quoted 6 lines
Quoted 3 lines
* patch 2 is over 2000 lines, which is far too big to review. It needs to be split up. Aim for 200 lines per patch at maximum; smaller is better.
I'm open to suggestions. This is actually a single file (with the
necessary
Quoted 3 lines
Makefileaddition). Do you suggest that I'll break it for example to distributer part an redistributer parte.t.c.?
Please advice.Yes, you need to split it up into logical subsections that each add a small but coherent piece of functionality. The purpose of splitting up into patches is to make the code easier to review for correctness. It's impossible to read a single 2000 line patch and keep it all in your head at once. So a split into multiple patches is about presenting the changes in a way that allows the reader to assess it in a logical order and not too much at once.
thanks
-- PMM
Quoted 1 line · Shlomo Pongratz
See inline.
(You don't need to keep saying this, by the way -- inline quoting and response is the usual form of email on this list.)
Quoted 12 lines
Quoted 9 lines · Peter Maydell
Quoted 1 line · Shlomo Pongratz
The GICv3 spec limits the number of cores to 128.
I don't believe it does (the only limit is the affinity fields which have a limit up in the millions). Can you point me to the part of the spec that you think imposes a lower limit?
Quoted 5 lines
I don't have the GICv3 spec at home only the GIC 500 which is based on it and is what implemented also in HW and it states:
1.1 About the GIC-500 The GIC-500 is a build-time configurable interrupt controller that supports up to 128 cores.
That's just a limit of a particular implementation, not of the architecture.
Quoted 2 lines
I'll send the GICv3 reference next week when I'll come back to work (I have it only at work).
Yes, that's the document which you need for architecture-level questions.
thanks
-- PMM
Hello!
Nice to see things moving on. I am waiting for PULL to be applied to master, and after this i'll be able to proceed with other things, including live migration. As part of it, i already rewrote state structure using bitops, so that it's free of CPU number restrictions. Would be nice if we upstream this too. I will post my patches as RFC as soon as master gets updated. RFC only because kernel API isn't there yet.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia