Skip to contentSkip to conversation

hw/arm/virt: Add a user option to disallow ITS instantiation

PATCH Superseded Eric Auger 2 participants 2 messages Feb 17, 2017 – Feb 20, 2017

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH v2 1/1 hw/arm/virt: Add a user option to disallow ITS instantiation

In 2.9 ITS will block save/restore and migration use cases. As such let's introduce a user option that disallows its instantiation along with the GICv3. With no-its option turned true, migration will be possible, obviously at the expense of MSI support (with GICv3).

---

v1 -> v2: fix omitted coma in object_property_set_description

With this patch the option also is added in virt 2.8. I don't know if it is acceptable.

---
 hw/arm/virt.c         | 28 +++++++++++++++++++++++++++-
 include/hw/arm/virt.h |  1 +
 2 files changed, 28 insertions(+), 1 deletion(-)
hw/arm/virt.c +27 -1
index f3440f2..c08deb0 100644
@@ -605,7 +605,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic)
 
     fdt_add_gic_node(vms);
 
-    if (type == 3 && !vmc->no_its) {
+    if (type == 3 && !vmc->no_its && !vms->no_its) {
         create_its(vms, gicdev);
     } else if (type == 2) {
         create_v2m(vms, pic);
@@ -1480,6 +1480,21 @@ static void virt_set_highmem(Object *obj, bool value, Error **errp)
     vms->highmem = value;
 }
 
+static bool virt_get_no_its(Object *obj, Error **errp)
+{
+    VirtMachineState *vms = VIRT_MACHINE(obj);
+
+    return vms->no_its;
+}
+
+static void virt_set_no_its(Object *obj, bool value, Error **errp)
+{
+    VirtMachineState *vms = VIRT_MACHINE(obj);
+
+    vms->no_its = value;
+}
+
+
 static char *virt_get_gic_version(Object *obj, Error **errp)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -1540,6 +1555,7 @@ type_init(machvirt_machine_init);
 static void virt_2_9_instance_init(Object *obj)
 {
     VirtMachineState *vms = VIRT_MACHINE(obj);
+    VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
 
     /* EL3 is disabled by default on virt: this makes us consistent
      * between KVM and TCG for this board, and it also allows us to
@@ -1579,6 +1595,16 @@ static void virt_2_9_instance_init(Object *obj)
                                     "Set GIC version. "
                                     "Valid values are 2, 3 and host", NULL);
 
+    /* Default allows ITS instantiation */
+    if (!vmc->no_its) {
+        object_property_add_bool(obj, "no-its", virt_get_no_its,
+                                 virt_set_no_its, NULL);
+        vms->no_its = false;
+        object_property_set_description(obj, "no-its",
+                                        "Disallow the ITS instantiation",
+                                        NULL);
+    }
+
     vms->memmap = a15memmap;
     vms->irqmap = a15irqmap;
 }
include/hw/arm/virt.h +1 -0
index 58ce74e..5e73be9 100644
@@ -93,6 +93,7 @@ typedef struct {
     FWCfgState *fw_cfg;
     bool secure;
     bool highmem;
+    bool no_its;
     bool virt;
     int32_t gic_version;
     struct arm_boot_info bootinfo;
Signature · 1 line
2.5.5
#1 lore raw
Quoted 5 lines · Eric Auger

In 2.9 ITS will block save/restore and migration use cases. As such let's introduce a user option that disallows its instantiation along with the GICv3. With no-its option turned true, migration will be possible, obviously at the expense of MSI support (with GICv3).

Quoted 8 lines

---

v1 -> v2: fix omitted coma in object_property_set_description

With this patch the option also is added in virt 2.8. I don't know if it is acceptable.

I think that's OK.

Quoted 10 lines
---
 hw/arm/virt.c         | 28 +++++++++++++++++++++++++++-
 include/hw/arm/virt.h |  1 +
 2 files changed, 28 insertions(+), 1 deletion(-)
hw/arm/virt.c +0 -0
index f3440f2..c08deb0 100644

hw/arm/virt.c static void create_gic(VirtMachineState *vms, qemu_irq *pic) · line 608

Quoted 5 lines
hw/arm/virt.c +1 -1
@@ -605,7 +605,7 @@ static void create_gic(VirtMachineState *vms, qemu_irq *pic)
 
     fdt_add_gic_node(vms);
 
-    if (type == 3 && !vmc->no_its) {
+    if (type == 3 && !vmc->no_its && !vms->no_its) {

Making the board creation code check both a vmc field and a vms field seems a bit awkward...

hw/arm/virt.c static void virt_2_9_instance_init(Object *obj) · line 1605

Quoted 8 lines
hw/arm/virt.c +8 -0
+    /* Default allows ITS instantiation */
+    if (!vmc->no_its) {
+        object_property_add_bool(obj, "no-its", virt_get_no_its,
+                                 virt_set_no_its, NULL);
+        vms->no_its = false;
+        object_property_set_description(obj, "no-its",
+                                        "Disallow the ITS instantiation",
+                                        NULL);

Can we have the property be "its" with true-for-enabled, rather than "no-its", please? (See later for rationale.)

Quoted 1 line

+ }

...if we have this code have an else {} clause we can make it set the vms field appropriately, and then the board creation code only needs to check the vms field.

include/hw/arm/virt.h typedef struct { · line 96

Quoted 13 lines
hw/arm/virt.c +1 -0
+
     vms->memmap = a15memmap;
     vms->irqmap = a15irqmap;
 }
include/hw/arm/virt.h +1 -0
index 58ce74e..5e73be9 100644
@@ -93,6 +93,7 @@ typedef struct {
     FWCfgState *fw_cfg;
     bool secure;
     bool highmem;
+    bool no_its;

Can we make this "bool its" where true means "has an ITS", please? The fields in VirtMachineClass are all "no_foo" because we require the "false" case to be the "new modern behaviour" and the "true" case to be "legacy like old boards" for convenience of the virt_machine_*_options() function chain, but we don't need to do this for VirtMachineState fields. (So VMS 'secure', 'highmem' and 'virt' are all true-for-feature-enabled.)
The user-facing property should also be "its" for the same reason.

An alternative to having the property be always default true and only existing on newer boards would be to have the VMC field be "no_default_its", expose the "its" property in all cases and just have its default value be different for old virt-* machine versions. I have no opinion here about which would be better.

include/hw/arm/virt.h typedef struct { · line 99

Quoted 3 lines
include/hw/arm/virt.h +0 -0
     bool virt;
     int32_t gic_version;
     struct arm_boot_info bootinfo;

thanks
-- PMM