All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
@ 2015-05-08 13:09 Pavel Fedin
  2015-05-11 11:30 ` Shlomo Pongratz
  2015-05-12  9:20 ` Daniel P. Berrange
  0 siblings, 2 replies; 15+ messages in thread
From: Pavel Fedin @ 2015-05-08 13:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: 'Shlomo Pongratz'

 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.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
---
 hw/arm/virt.c       | 155 +++++++++++++++++++++++++++++++++++++++++++---------
 include/hw/boards.h |   1 +
 2 files changed, 130 insertions(+), 26 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 565f573..f8f0119 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -66,6 +66,10 @@ enum {
     VIRT_CPUPERIPHS,
     VIRT_GIC_DIST,
     VIRT_GIC_CPU,
+    VIRT_GIC_DIST_SPI = VIRT_GIC_CPU,
+    VIRT_ITS_CONTROL,
+    VIRT_ITS_TRANSLATION,
+    VIRT_LPI,
     VIRT_UART,
     VIRT_MMIO,
     VIRT_RTC,
@@ -107,6 +111,8 @@ typedef struct {
 #define VIRT_MACHINE_CLASS(klass) \
     OBJECT_CLASS_CHECK(VirtMachineClass, klass, TYPE_VIRT_MACHINE)
 
+#define TYPE_VIRTV3_MACHINE   "virt-v3"
+
 /* Addresses and sizes of our components.
  * 0..128MB is space for a flash device so we can run bootrom code such as UEFI.
  * 128MB..256MB is used for miscellaneous device I/O.
@@ -121,25 +127,29 @@ typedef struct {
  */
 static const MemMapEntry a15memmap[] = {
     /* Space up to 0x8000000 is reserved for a boot ROM */
-    [VIRT_FLASH] =      {          0, 0x08000000 },
-    [VIRT_CPUPERIPHS] = { 0x08000000, 0x00020000 },
+    [VIRT_FLASH] =           {          0, 0x08000000 },
+    [VIRT_CPUPERIPHS] =      { 0x08000000, 0x00020000 },
     /* GIC distributor and CPU interfaces sit inside the CPU peripheral space */
-    [VIRT_GIC_DIST] =   { 0x08000000, 0x00010000 },
-    [VIRT_GIC_CPU] =    { 0x08010000, 0x00010000 },
-    [VIRT_UART] =       { 0x09000000, 0x00001000 },
-    [VIRT_RTC] =        { 0x09010000, 0x00001000 },
-    [VIRT_FW_CFG] =     { 0x09020000, 0x0000000a },
-    [VIRT_MMIO] =       { 0x0a000000, 0x00000200 },
+    [VIRT_GIC_DIST] =        { 0x08000000, 0x00010000 },
+    [VIRT_GIC_CPU] =         { 0x08010000, 0x00010000 },
+    /* On v3 VIRT_GIC_DIST_SPI takes place of VIRT_GIC_CPU */
+    [VIRT_ITS_CONTROL] =     { 0x08020000, 0x00001000 },
+    [VIRT_ITS_TRANSLATION] = { 0x08030000, 0x00010000 },
+    [VIRT_LPI] =             { 0x08040000, 0x00800000 },
+    [VIRT_UART] =            { 0x09000000, 0x00001000 },
+    [VIRT_RTC] =             { 0x09010000, 0x00001000 },
+    [VIRT_FW_CFG] =          { 0x09020000, 0x0000000a },
+    [VIRT_MMIO] =            { 0x0a000000, 0x00000200 },
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
     /*
      * PCIE verbose map:
      *
-     * MMIO window      { 0x10000000, 0x2eff0000 },
-     * PIO window       { 0x3eff0000, 0x00010000 },
-     * ECAM             { 0x3f000000, 0x01000000 },
+     * MMIO window           { 0x10000000, 0x2eff0000 },
+     * PIO window            { 0x3eff0000, 0x00010000 },
+     * ECAM                  { 0x3f000000, 0x01000000 },
      */
-    [VIRT_PCIE] =       { 0x10000000, 0x30000000 },
-    [VIRT_MEM] =        { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
+    [VIRT_PCIE] =            { 0x10000000, 0x30000000 },
+    [VIRT_MEM] =             { 0x40000000, 30ULL * 1024 * 1024 * 1024 },
 };
 
 static const int a15irqmap[] = {
@@ -299,11 +309,24 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
 {
     int cpu;
 
+    /*
+     * From Documentation/devicetree/bindings/arm/cpus.txt
+     *  On ARM v8 64-bit systems value should be set to 2,
+     *  that corresponds to the MPIDR_EL1 register size.
+     *  If MPIDR_EL1[63:32] value is equal to 0 on all CPUs
+     *  in the system, #address-cells can be set to 1, since
+     *  MPIDR_EL1[63:32] bits are not used for CPUs
+     *  identification.
+     *
+     *  Now GIC500 doesn't support affinities 2 & 3 so currently
+     *  #address-cells can stay 1 until future GIC
+     */
     qemu_fdt_add_subnode(vbi->fdt, "/cpus");
     qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#address-cells", 0x1);
     qemu_fdt_setprop_cell(vbi->fdt, "/cpus", "#size-cells", 0x0);
 
     for (cpu = vbi->smp_cpus - 1; cpu >= 0; cpu--) {
+        int Aff1, Aff0;
         char *nodename = g_strdup_printf("/cpus/cpu@%d", cpu);
         ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
 
@@ -317,12 +340,20 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
                                         "enable-method", "psci");
         }
 
-        qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", cpu);
+        /*
+         * If cpus node's #address-cells property is set to 1
+         * The reg cell bits [23:0] must be set to bits [23:0] of MPIDR_EL1.
+         * Currently we support simple affinity scheme e.g. we can have
+         * 1 cluster with 8 cores but we can't have 8 clusters wit 1 core each.
+         */
+        Aff1 = cpu / 8;
+        Aff0 = cpu % 8;
+        qemu_fdt_setprop_cell(vbi->fdt, nodename, "reg", (Aff1 << 8) | Aff0);
         g_free(nodename);
     }
 }
 
-static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi)
+static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi, int type)
 {
     uint32_t gic_phandle;
 
@@ -330,35 +361,65 @@ static uint32_t fdt_add_gic_node(const VirtBoardInfo *vbi)
     qemu_fdt_setprop_cell(vbi->fdt, "/", "interrupt-parent", gic_phandle);
 
     qemu_fdt_add_subnode(vbi->fdt, "/intc");
-    /* 'cortex-a15-gic' means 'GIC v2' */
-    qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible",
-                            "arm,cortex-a15-gic");
     qemu_fdt_setprop_cell(vbi->fdt, "/intc", "#interrupt-cells", 3);
     qemu_fdt_setprop(vbi->fdt, "/intc", "interrupt-controller", NULL, 0);
-    qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg",
+    if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {
+        qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible",
+                                "arm,gic-v3");
+        qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg",
+                                     2, vbi->memmap[VIRT_GIC_DIST].base,
+                                     2, vbi->memmap[VIRT_GIC_DIST].size,
+#if 0                                /* Currently no need for SPI & ITS */
+                                     2, vbi->memmap[VIRT_GIC_DIST_SPI].base,
+                                     2, vbi->memmap[VIRT_GIC_DIST_SPI].size,
+                                     2, vbi->memmap[VIRT_ITS_CONTROL].base,
+                                     2, vbi->memmap[VIRT_ITS_CONTROL].size,
+                                     2, vbi->memmap[VIRT_ITS_TRANSLATION].base,
+                                     2, vbi->memmap[VIRT_ITS_TRANSLATION].size,
+#endif
+                                     2, vbi->memmap[VIRT_LPI].base,
+                                     2, vbi->memmap[VIRT_LPI].size);
+    } else {
+        /* 'cortex-a15-gic' means 'GIC v2' */
+        qemu_fdt_setprop_string(vbi->fdt, "/intc", "compatible",
+                                "arm,cortex-a15-gic");
+        qemu_fdt_setprop_sized_cells(vbi->fdt, "/intc", "reg",
                                      2, vbi->memmap[VIRT_GIC_DIST].base,
                                      2, vbi->memmap[VIRT_GIC_DIST].size,
                                      2, vbi->memmap[VIRT_GIC_CPU].base,
                                      2, vbi->memmap[VIRT_GIC_CPU].size);
+    }
     qemu_fdt_setprop_cell(vbi->fdt, "/intc", "phandle", gic_phandle);
 
     return gic_phandle;
 }
 
-static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
+static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic, int type)
 {
     /* We create a standalone GIC v2 */
     DeviceState *gicdev;
     SysBusDevice *gicbusdev;
-    const char *gictype = "arm_gic";
+    const char *gictype;
     int i;
 
-    if (kvm_irqchip_in_kernel()) {
+    if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {
+        gictype = "arm_gicv3";
+    } else if (kvm_irqchip_in_kernel()) {
         gictype = "kvm-arm-gic";
+    } else {
+        gictype = "arm_gic";
     }
 
     gicdev = qdev_create(NULL, gictype);
-    qdev_prop_set_uint32(gicdev, "revision", 2);
+
+    for (i = 0; i < vbi->smp_cpus; i++) {
+        CPUState *cpu = qemu_get_cpu(i);
+        CPUARMState *env = cpu->env_ptr;
+        env->nvic = gicdev;
+    }
+
+    qdev_prop_set_uint32(gicdev, "revision",
+                         type == KVM_DEV_TYPE_ARM_VGIC_V3 ? 3 : 2);
     qdev_prop_set_uint32(gicdev, "num-cpu", smp_cpus);
     /* Note that the num-irq property counts both internal and external
      * interrupts; there are always 32 of the former (mandated by GIC spec).
@@ -368,6 +429,11 @@ static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
     gicbusdev = SYS_BUS_DEVICE(gicdev);
     sysbus_mmio_map(gicbusdev, 0, vbi->memmap[VIRT_GIC_DIST].base);
     sysbus_mmio_map(gicbusdev, 1, vbi->memmap[VIRT_GIC_CPU].base);
+    if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {
+        sysbus_mmio_map(gicbusdev, 2, vbi->memmap[VIRT_ITS_CONTROL].base);
+        sysbus_mmio_map(gicbusdev, 3, vbi->memmap[VIRT_ITS_TRANSLATION].base);
+        sysbus_mmio_map(gicbusdev, 4, vbi->memmap[VIRT_LPI].base);
+    }
 
     /* Wire the outputs from each CPU's generic timer to the
      * appropriate GIC PPI inputs, and the GIC's IRQ output to
@@ -392,7 +458,7 @@ static uint32_t create_gic(const VirtBoardInfo *vbi, qemu_irq *pic)
         pic[i] = qdev_get_gpio_in(gicdev, i);
     }
 
-    return fdt_add_gic_node(vbi);
+    return fdt_add_gic_node(vbi, type);
 }
 
 static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic)
@@ -811,7 +877,7 @@ static void machvirt_init(MachineState *machine)
 
     create_flash(vbi);
 
-    gic_phandle = create_gic(vbi, pic);
+    gic_phandle = create_gic(vbi, pic, machine->kernel_irqchip_type);
 
     create_uart(vbi, pic);
 
@@ -853,7 +919,7 @@ static void virt_set_secure(Object *obj, bool value, Error **errp)
     vms->secure = value;
 }
 
-static void virt_instance_init(Object *obj)
+static void virt_instance_init_common(Object *obj)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
 
@@ -867,6 +933,14 @@ static void virt_instance_init(Object *obj)
                                     NULL);
 }
 
+static void virt_instance_init(Object *obj)
+{
+    MachineState *ms = MACHINE(obj);
+
+    ms->kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V2;
+    virt_instance_init_common(obj);
+}
+
 static void virt_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -886,9 +960,38 @@ static const TypeInfo machvirt_info = {
     .class_init = virt_class_init,
 };
 
+static void virtv3_instance_init(Object *obj)
+{
+    MachineState *ms = MACHINE(obj);
+
+    ms->kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V3;
+    virt_instance_init_common(obj);
+}
+
+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);
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 1f11881..3eb32f2 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -138,6 +138,7 @@ struct MachineState {
     char *accel;
     bool kernel_irqchip_allowed;
     bool kernel_irqchip_required;
+    int kernel_irqchip_type;
     int kvm_shadow_mem;
     char *dtb;
     char *dumpdtb;
-- 
1.9.5.msysgit.0

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-08 13:09 [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500 Pavel Fedin
@ 2015-05-11 11:30 ` Shlomo Pongratz
  2015-05-12  9:05   ` Pavel Fedin
  2015-05-12  9:11   ` Pavel Fedin
  2015-05-12  9:20 ` Daniel P. Berrange
  1 sibling, 2 replies; 15+ messages in thread
From: Shlomo Pongratz @ 2015-05-11 11:30 UTC (permalink / raw)
  To: Pavel Fedin, qemu-devel


Hi Pavel,

Thank you,

I just pulled last git and git am-ed your patch on-top of my first 3 patches and got this error:
/home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c: In function ‘fdt_add_gic_node’:
/home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c:366:17: error: ‘KVM_DEV_TYPE_ARM_VGIC_V3’ undeclared (first use in this function)
     if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {

Best regards,

S.P.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-11 11:30 ` Shlomo Pongratz
@ 2015-05-12  9:05   ` Pavel Fedin
  2015-05-12 11:29     ` Shlomo Pongratz
  2015-05-12  9:11   ` Pavel Fedin
  1 sibling, 1 reply; 15+ messages in thread
From: Pavel Fedin @ 2015-05-12  9:05 UTC (permalink / raw)
  To: 'Shlomo Pongratz', qemu-devel

 Hello!

> I just pulled last git and git am-ed your patch on-top of my first 3 patches and got
this error:
> /home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c: In function 'fdt_add_gic_node':
> /home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c:366:17: error:
> 'KVM_DEV_TYPE_ARM_VGIC_V3' undeclared (first use in this function)
>      if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {

 Very strange. Check your source tree. This value is declared in
linux-headers/linux/kvm.h. Try to #include it directly maybe ? OTOH it perfectly works for
me, i have just verified, i have no extra #include's which could be missing from the
patch.
 But, may be something has changed in master over the last three days? Actually my base
tree is from friday.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-11 11:30 ` Shlomo Pongratz
  2015-05-12  9:05   ` Pavel Fedin
@ 2015-05-12  9:11   ` Pavel Fedin
  1 sibling, 0 replies; 15+ messages in thread
From: Pavel Fedin @ 2015-05-12  9:11 UTC (permalink / raw)
  To: 'Shlomo Pongratz', qemu-devel

 And one more small note... I have noticed a typo.
--- cut ---
    [VIRT_ITS_CONTROL] =     { 0x08020000, 0x00001000 },
--- cut ---
 The size should actually be 0x00010000. It worked because we don't use ITS. Please fix it
for the next merge attempt.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-08 13:09 [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500 Pavel Fedin
  2015-05-11 11:30 ` Shlomo Pongratz
@ 2015-05-12  9:20 ` Daniel P. Berrange
  2015-05-12  9:32   ` Pavel Fedin
  2015-05-12  9:56   ` Peter Maydell
  1 sibling, 2 replies; 15+ messages in thread
From: Daniel P. Berrange @ 2015-05-12  9:20 UTC (permalink / raw)
  To: Pavel Fedin; +Cc: 'Shlomo Pongratz', qemu-devel

On Fri, May 08, 2015 at 04:09:01PM +0300, Pavel Fedin wrote:
>  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.
> 
> Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
> ---
>  hw/arm/virt.c       | 155 +++++++++++++++++++++++++++++++++++++++++++---------
>  include/hw/boards.h |   1 +
>  2 files changed, 130 insertions(+), 26 deletions(-)

> +#define TYPE_VIRTV3_MACHINE   "virt-v3"

[snip]

> +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);
>  }

If we're going to start adding new machine types for aarch64 with
version numbers, then I think we should we be using a versioning
scheme that matches what we do on x86. ie, define versioned
machine types based on the QEMU release numbers

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12  9:20 ` Daniel P. Berrange
@ 2015-05-12  9:32   ` Pavel Fedin
  2015-05-12  9:56   ` Peter Maydell
  1 sibling, 0 replies; 15+ messages in thread
From: Pavel Fedin @ 2015-05-12  9:32 UTC (permalink / raw)
  To: 'Daniel P. Berrange'; +Cc: 'Shlomo Pongratz', qemu-devel

 Hello!

> If we're going to start adding new machine types for aarch64 with
> version numbers, then I think we should we be using a versioning
> scheme that matches what we do on x86. ie, define versioned
> machine types based on the QEMU release numbers

 As i wrote in v1 patch message, i am perfectly OK with any name change. I just decided that "v3" would stand for "GICv3". If you have such a policy, let it be. No objections.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12  9:20 ` Daniel P. Berrange
  2015-05-12  9:32   ` Pavel Fedin
@ 2015-05-12  9:56   ` Peter Maydell
  2015-05-12 11:15     ` Pavel Fedin
  1 sibling, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2015-05-12  9:56 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Shlomo Pongratz, Pavel Fedin, QEMU Developers

On 12 May 2015 at 10:20, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Fri, May 08, 2015 at 04:09:01PM +0300, Pavel Fedin wrote:
>>  static void machvirt_machine_init(void)
>>  {
>>      type_register_static(&machvirt_info);
>> +    type_register_static(&machvirtv3_info);
>>  }
>
> If we're going to start adding new machine types for aarch64 with
> version numbers

We are not. Support for GICv2 vs v3 should be dealt with
by suitable machine properties (and by figuring out how
we handle probing for which of the two the host kernel
can provide us).

>, then I think we should we be using a versioning
> scheme that matches what we do on x86. ie, define versioned
> machine types based on the QEMU release numbers

And we're not doing that until we absolutely have to, ie we
have somebody demanding cross-version migration support and
willing to back it up with the necessary battery of testing.
That day will come, but I don't think we're ready for it yet.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12  9:56   ` Peter Maydell
@ 2015-05-12 11:15     ` Pavel Fedin
  2015-05-12 11:20       ` Daniel P. Berrange
  0 siblings, 1 reply; 15+ messages in thread
From: Pavel Fedin @ 2015-05-12 11:15 UTC (permalink / raw)
  To: 'Peter Maydell', 'Daniel P. Berrange'
  Cc: 'Shlomo Pongratz', 'QEMU Developers'

 Hello!

> We are not. Support for GICv2 vs v3 should be dealt with
> by suitable machine properties

 I don't remember whether i clearly wrote about it... First i added a property, like -machine virt,gicv3=on. But then i decided to stick back to different machine name because libvirt does not have mechanism for passing machine options.

> (and by figuring out how
> we handle probing for which of the two the host kernel
> can provide us).

 This is tricky. I thought about it.
 Kernel offers us only KVM_CAP_IRQCHIP Boolean. But it does not tell us which irqchip. Possible variants are:
a) Host with GICv2 - this can only be v2.
b) Host with GICv3 with backwards compatibility option - this can be both
b) Host with GICv3 without compatibility option - this can only be v3.
 Perhaps we could do a probe in  kvm_arch_irqchip_create(), however i'm not sure what happens in the kernel when this is called. This call actually instantiates the device, but drops its fd. I suggest, the device is still created, and next attempt to do it will just return the same fd. And i don't know what happens if we create both GICs (i cannot test because i don't have machine capable of doing it).
 OTOH, if we don't have in-kernel acceleration, perhaps the good idea is stick to what the user wants, and use emulation. Yes, i know about problems with generic timer in this case, but this if different issue which can also be fixed.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12 11:15     ` Pavel Fedin
@ 2015-05-12 11:20       ` Daniel P. Berrange
  0 siblings, 0 replies; 15+ messages in thread
From: Daniel P. Berrange @ 2015-05-12 11:20 UTC (permalink / raw)
  To: Pavel Fedin
  Cc: 'Peter Maydell', 'QEMU Developers',
	'Shlomo Pongratz'

On Tue, May 12, 2015 at 02:15:46PM +0300, Pavel Fedin wrote:
>  Hello!
> 
> > We are not. Support for GICv2 vs v3 should be dealt with
> > by suitable machine properties
> 
>  I don't remember whether i clearly wrote about it... First i added a
> property, like -machine virt,gicv3=on. But then i decided to stick back
> to different machine name because libvirt does not have mechanism for
> passing machine options.

Actually there was a enhancement done to libvirt a week or two ago to
support enablment of the GIC and choice of versions.

<domain type='kvm'>
  ....
  <features>
     <gic version='3'/>
  </features>
  ...
</domain>

commit 921c52b0db3ac898d5cc4eda19fb861ad58d9a9e
Author: Michal Privoznik <mprivozn@redhat.com>
Date:   Mon Apr 27 14:03:19 2015 +0200

    Introduce GIC feature
    
    Some platforms, like aarch64, don't have APIC but GIC. So there's
    no reason to have <apic/> feature turned on. However, we are
    still missing <gic/> feature. This commit introduces the feature
    to XML parser and formatter, adds documentation and updates RNG
    schema.
    
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12  9:05   ` Pavel Fedin
@ 2015-05-12 11:29     ` Shlomo Pongratz
  2015-05-12 12:33       ` Pavel Fedin
  0 siblings, 1 reply; 15+ messages in thread
From: Shlomo Pongratz @ 2015-05-12 11:29 UTC (permalink / raw)
  To: Pavel Fedin, qemu-devel

> -----Original Message-----
> From: Pavel Fedin [mailto:p.fedin@samsung.com]
> Sent: Tuesday, 12 May, 2015 12:06 PM
> To: Shlomo Pongratz; qemu-devel@nongnu.org
> Subject: RE: [PATCH v2] Add virt-v3 machine that uses GIC-500
> 
>  Hello!
> 
> > I just pulled last git and git am-ed your patch on-top of my first 3
> > patches and got
> this error:
> > /home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c: In function
> 'fdt_add_gic_node':
> > /home/shlomo/qemu-new.git/qemu-64/hw/arm/virt.c:366:17: error:
> > 'KVM_DEV_TYPE_ARM_VGIC_V3' undeclared (first use in this function)
> >      if (type == KVM_DEV_TYPE_ARM_VGIC_V3) {
> 
>  Very strange. Check your source tree. This value is declared in linux-
> headers/linux/kvm.h. Try to #include it directly maybe ? OTOH it perfectly
> works for me, i have just verified, i have no extra #include's which could be
> missing from the patch.
>  But, may be something has changed in master over the last three days?
> Actually my base tree is from friday.
> 
> Kind regards,
> Pavel Fedin
> Expert Engineer
> Samsung Electronics Research center Russia
> 

Hi Pavel,

I did include "linux/kvm.h" which fixed the issue.
But as I wrote I did "git pull" before applying the patches, so it is strange.

BTW did you try going beyond 16 cores I had problems with 32 and 64 cores.

Best regards,

S.P.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12 11:29     ` Shlomo Pongratz
@ 2015-05-12 12:33       ` Pavel Fedin
  2015-05-13 10:34         ` Shlomo Pongratz
  0 siblings, 1 reply; 15+ messages in thread
From: Pavel Fedin @ 2015-05-12 12:33 UTC (permalink / raw)
  To: 'Shlomo Pongratz', qemu-devel

 Hello!

> BTW did you try going beyond 16 cores I had problems with 32 and 64 cores.

 Just tried it. Works fine, except qemu takes incredibly long time to start up with so
many cores. 64 cores took something like 2 minutes. Indeed, looks like freeze, but if
you're patient enough, you'll see it running. I believe it's interpretation mode flaw.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-12 12:33       ` Pavel Fedin
@ 2015-05-13 10:34         ` Shlomo Pongratz
  2015-05-13 13:57           ` Pavel Fedin
  0 siblings, 1 reply; 15+ messages in thread
From: Shlomo Pongratz @ 2015-05-13 10:34 UTC (permalink / raw)
  To: Pavel Fedin, qemu-devel

> -----Original Message-----
> From: Pavel Fedin [mailto:p.fedin@samsung.com]
> Sent: Tuesday, 12 May, 2015 3:33 PM
> To: Shlomo Pongratz; qemu-devel@nongnu.org
> Subject: RE: [PATCH v2] Add virt-v3 machine that uses GIC-500
> 
>  Hello!
> 
> > BTW did you try going beyond 16 cores I had problems with 32 and 64 cores.
> 
>  Just tried it. Works fine, except qemu takes incredibly long time to start up
> with so many cores. 64 cores took something like 2 minutes. Indeed, looks
> like freeze, but if you're patient enough, you'll see it running. I believe it's
> interpretation mode flaw.
> 
> Kind regards,
> Pavel Fedin
> Expert Engineer
> Samsung Electronics Research center Russia
> 


Hi Pavel,

With your patch I can work up to 16 cores it gets stuck at 24 cores.

I have two questions regarding your changes.
1. In fdt_add_timer why you didn't used the 24 bit limit I posed on the irqflags? Please note that the argument is 32 bits wide an 8 bits are for flags.
2. In machvirt_init, I used TYPE_AARCH64_CPU while you reverted it to TYPE_ARM_CPU, I assume this is because you want to support cortex-a15. Don't you think It should be according to the cortex type? (BTW you removed cortex-a53).

Best regards,

S.P.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-13 10:34         ` Shlomo Pongratz
@ 2015-05-13 13:57           ` Pavel Fedin
  2015-05-14 12:01             ` Shlomo Pongratz
  0 siblings, 1 reply; 15+ messages in thread
From: Pavel Fedin @ 2015-05-13 13:57 UTC (permalink / raw)
  To: 'Shlomo Pongratz', qemu-devel

 Hello!

> 1. In fdt_add_timer why you didn't used the 24 bit limit I posed on the irqflags? Please
note that
> the argument is 32 bits wide and 8 bits are for flags.

  Simply missed it when checking for differences. Please fix. :) Perhaps it is the reason
why >=24 CPUs fail for you.

> 2. In machvirt_init, I used TYPE_AARCH64_CPU while you reverted it to TYPE_ARM_CPU, I
> assume this is because you want to support cortex-a15. Don't you think It should be
according
> to the cortex type?

 Yes, i just left it as it was because it already works fine with ARM64. Actually,
TYPE_AARCH64_CPU is a subclass of TYPE_ARM_CPU.

> (BTW you removed cortex-a53).

 Yes, because i didn't see how it is different from a57 (or a15). I tried to follow
minimal intervention principle.
 But perhaps i was wrong because there was real support for a53 added recently:
http://lists.nongnu.org/archive/html/qemu-devel/2015-05/msg01304.html, so feel free to
re-add it back.

 BTW, just for interest, have you tried to do anything with KVM support of vGICv3? I have
some code but it's inherently unstable and lock up for unknown (yet) reason.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-13 13:57           ` Pavel Fedin
@ 2015-05-14 12:01             ` Shlomo Pongratz
  2015-05-14 15:27               ` Pavel Fedin
  0 siblings, 1 reply; 15+ messages in thread
From: Shlomo Pongratz @ 2015-05-14 12:01 UTC (permalink / raw)
  To: Pavel Fedin, qemu-devel
  Cc: Peter Maydell, Claudio Fontana, Shannon Zhao, christoffer.dall

Hi Pavel,

Please see in-line.
Best regards,

S.P.

________________________________________
From: Pavel Fedin [p.fedin@samsung.com]
Sent: Wednesday, May 13, 2015 4:57 PM
To: Shlomo Pongratz; qemu-devel@nongnu.org
Subject: RE: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500

 Hello!

> 1. In fdt_add_timer why you didn't used the 24 bit limit I posed on the irqflags? Please
note that
> the argument is 32 bits wide and 8 bits are for flags.

  Simply missed it when checking for differences. Please fix. :) Perhaps it is the reason
why >=24 CPUs fail for you.

I wonder how it works for you. Do you aware of an alternative way to configure the clock irqflags for more then 24 cores, or is it just ignored. According to Linux documentation this fdt field sets the clock IRQ affinity.

My current status is as follows:
With 64 cores there is no printouts what so ever.  
With 32 cores the boot usually get stuck after the message "[   45.719102] SCSI subsystem initialized"
With 24 cores the system noontimes complete the boot and sometimes get stuck like the 32 cores system.

> 2. In machvirt_init, I used TYPE_AARCH64_CPU while you reverted it to TYPE_ARM_CPU, I
> assume this is because you want to support cortex-a15. Don't you think It should be
according
> to the cortex type?

 Yes, i just left it as it was because it already works fine with ARM64. Actually,
TYPE_AARCH64_CPU is a subclass of TYPE_ARM_CPU.

I see but I guess that I want aarch64_cpu_initfn to be called and not arm_cpu_initfn.

> (BTW you removed cortex-a53).

 Yes, because i didn't see how it is different from a57 (or a15). I tried to follow
minimal intervention principle.
 But perhaps i was wrong because there was real support for a53 added recently:
http://lists.nongnu.org/archive/html/qemu-devel/2015-05/msg01304.html, so feel free to
re-add it back.

I agree with you I think this should wait for the patch you mentioned above to be integrated.

 BTW, just for interest, have you tried to do anything with KVM support of vGICv3? I have
some code but it's inherently unstable and lock up for unknown (yet) reason.

No, this is because I don't have an ARM64 based server needed for running KVM for ARM64.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia



^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500
  2015-05-14 12:01             ` Shlomo Pongratz
@ 2015-05-14 15:27               ` Pavel Fedin
  0 siblings, 0 replies; 15+ messages in thread
From: Pavel Fedin @ 2015-05-14 15:27 UTC (permalink / raw)
  To: 'Shlomo Pongratz', qemu-devel
  Cc: 'Peter Maydell', 'Claudio Fontana',
	'Shannon Zhao',
	christoffer.dall

 Hello!

> I wonder how it works for you. Do you aware of an alternative way to configure the clock
> irqflags for more then 24 cores, or is it just ignored.

 Unfortunately i don't know how it works. 

> My current status is as follows:
> With 64 cores there is no printouts what so ever.
> With 32 cores the boot usually get stuck after the message "[   45.719102] SCSI
subsystem
> initialized"
> With 24 cores the system noontimes complete the boot and sometimes get stuck like the 32
> cores system.

 I will recheck later when i get back to qemu. I will pull the latest HEAD and fix IRQ
affinity specification. But, i think that most likely you'll have to debug this yourself.
Because i suggest it will work. :)

>>  Yes, i just left it as it was because it already works fine with ARM64. Actually,
>> TYPE_AARCH64_CPU is a subclass of TYPE_ARM_CPU.
> 
> I see but I guess that I want aarch64_cpu_initfn to be called and not arm_cpu_initfn.

 I guess that the correct class will be returned. Otherwise it would not work at all. You
can check this if you want to.

>>  BTW, just for interest, have you tried to do anything with KVM support of vGICv3? I
have
>> some code but it's inherently unstable and lock up for unknown (yet) reason.
> 
> No, this is because I don't have an ARM64 based server needed for running KVM for ARM64.

 Ok. Then it looks like i'm going to be the first to do this. I hope you'll complete the
integration soon because vGICv3 has to be based upon your work.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-05-14 15:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 13:09 [Qemu-devel] [PATCH v2] Add virt-v3 machine that uses GIC-500 Pavel Fedin
2015-05-11 11:30 ` Shlomo Pongratz
2015-05-12  9:05   ` Pavel Fedin
2015-05-12 11:29     ` Shlomo Pongratz
2015-05-12 12:33       ` Pavel Fedin
2015-05-13 10:34         ` Shlomo Pongratz
2015-05-13 13:57           ` Pavel Fedin
2015-05-14 12:01             ` Shlomo Pongratz
2015-05-14 15:27               ` Pavel Fedin
2015-05-12  9:11   ` Pavel Fedin
2015-05-12  9:20 ` Daniel P. Berrange
2015-05-12  9:32   ` Pavel Fedin
2015-05-12  9:56   ` Peter Maydell
2015-05-12 11:15     ` Pavel Fedin
2015-05-12 11:20       ` Daniel P. Berrange

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.