Skip to contentSkip to conversation

hw/intc/arm_gicv3_kvm: Check KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS in reset

PATCH Superseded Eric Auger 3 participants 5 messages Mar 28, 2017 – Mar 30, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH 1/1 hw/intc/arm_gicv3_kvm: Check KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS in reset

KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS needs to be checked before attempting to read ICC_CTLR_EL1; otherwise kernel versions not exposing this kvm device group will be incompatible with qemu 2.9.

Fixes 07a5628 ("hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers")

---

I understand the ICC_CTLR_EL1 state only is used in the put() function which is used for migration

---
 hw/intc/arm_gicv3_kvm.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
hw/intc/arm_gicv3_kvm.c +11 -6
index 81f0403..4c3a88e 100644
@@ -614,12 +614,6 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     s = c->gic;
     cpu = ARM_CPU(c->cpu);
 
-    /* Initialize to actual HW supported configuration */
-    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
-                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
-                      &c->icc_ctlr_el1[GICV3_NS], false);
-
-    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
     c->icc_pmr_el1 = 0;
     c->icc_bpr[GICV3_G0] = GIC_MIN_BPR;
     c->icc_bpr[GICV3_G1] = GIC_MIN_BPR;
@@ -628,6 +622,17 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     c->icc_sre_el1 = 0x7;
     memset(c->icc_apr, 0, sizeof(c->icc_apr));
     memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen));
+
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                              KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity))) {
+        return;
+    }
+    /* Initialize to actual HW supported configuration */
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
+                      &c->icc_ctlr_el1[GICV3_NS], false);
+
+    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
 }
 
 static void kvm_arm_gicv3_reset(DeviceState *dev)
Signature · 1 line
2.5.5
author
#1 lore raw

Adding Prakash B in cc too, sorry.

Vijaya, please let me know if I missed something in your original patch.

I tested GICv3 KVM save/restore with v4.11-rc4 and Prakash B use case with 4.10 kernel.

Thanks

Eric

Quoted 52 lines · Eric Auger

KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS needs to be checked before attempting to read ICC_CTLR_EL1; otherwise kernel versions not exposing this kvm device group will be incompatible with qemu 2.9.

Fixes 07a5628 ("hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers")

---

I understand the ICC_CTLR_EL1 state only is used in the put() function which is used for migration

---
 hw/intc/arm_gicv3_kvm.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
hw/intc/arm_gicv3_kvm.c +11 -6
index 81f0403..4c3a88e 100644
@@ -614,12 +614,6 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     s = c->gic;
     cpu = ARM_CPU(c->cpu);
 
-    /* Initialize to actual HW supported configuration */
-    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
-                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
-                      &c->icc_ctlr_el1[GICV3_NS], false);
-
-    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
     c->icc_pmr_el1 = 0;
     c->icc_bpr[GICV3_G0] = GIC_MIN_BPR;
     c->icc_bpr[GICV3_G1] = GIC_MIN_BPR;
@@ -628,6 +622,17 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     c->icc_sre_el1 = 0x7;
     memset(c->icc_apr, 0, sizeof(c->icc_apr));
     memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen));
+
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                              KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity))) {
+        return;
+    }
+    /* Initialize to actual HW supported configuration */
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
+                      &c->icc_ctlr_el1[GICV3_NS], false);
+
+    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
 }
 
 static void kvm_arm_gicv3_reset(DeviceState *dev)
#2 lore raw
In reply to Eric Auger

Hi Eric,

Quoted 34 lines · Eric Auger

KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS needs to be checked before attempting to read ICC_CTLR_EL1; otherwise kernel versions not exposing this kvm device group will be incompatible with qemu 2.9.

Fixes 07a5628 ("hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers")

---

I understand the ICC_CTLR_EL1 state only is used in the put() function which is used for migration

---
 hw/intc/arm_gicv3_kvm.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
hw/intc/arm_gicv3_kvm.c +0 -6
index 81f0403..4c3a88e 100644
@@ -614,12 +614,6 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     s = c->gic;
     cpu = ARM_CPU(c->cpu);
 
-    /* Initialize to actual HW supported configuration */
-    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
-                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
-                      &c->icc_ctlr_el1[GICV3_NS], false);
-
-    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
     c->icc_pmr_el1 = 0;
     c->icc_bpr[GICV3_G0] = GIC_MIN_BPR;
     c->icc_bpr[GICV3_G1] = GIC_MIN_BPR;

hw/intc/arm_gicv3_kvm.c static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) · line 629

Quoted 8 lines
hw/intc/arm_gicv3_kvm.c +5 -0
@@ -628,6 +622,17 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     c->icc_sre_el1 = 0x7;
     memset(c->icc_apr, 0, sizeof(c->icc_apr));
     memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen));
+
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                              KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity))) {
+        return;
+    }

Can't we use gicv3 migration blocker provided if it is set before this reset.

Quoted 12 lines
hw/intc/arm_gicv3_kvm.c +6 -1
+    /* Initialize to actual HW supported configuration */
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
+                      &c->icc_ctlr_el1[GICV3_NS], false);
+
+    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
 }
 
 static void kvm_arm_gicv3_reset(DeviceState *dev)
--

2.5.5

author
#3 lore raw

Hi Vijay,

Quoted 39 lines · Vijay Kilari

Hi Eric,

Quoted 36 lines · Eric Auger

KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS needs to be checked before attempting to read ICC_CTLR_EL1; otherwise kernel versions not exposing this kvm device group will be incompatible with qemu 2.9.

Fixes 07a5628 ("hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers")

---

I understand the ICC_CTLR_EL1 state only is used in the put() function which is used for migration

---
 hw/intc/arm_gicv3_kvm.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
hw/intc/arm_gicv3_kvm.c +0 -6
index 81f0403..4c3a88e 100644
@@ -614,12 +614,6 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     s = c->gic;
     cpu = ARM_CPU(c->cpu);
 
-    /* Initialize to actual HW supported configuration */
-    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
-                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
-                      &c->icc_ctlr_el1[GICV3_NS], false);
-
-    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
     c->icc_pmr_el1 = 0;
     c->icc_bpr[GICV3_G0] = GIC_MIN_BPR;
     c->icc_bpr[GICV3_G1] = GIC_MIN_BPR;
@@ -628,6 +622,17 @@ static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri)
     c->icc_sre_el1 = 0x7;
     memset(c->icc_apr, 0, sizeof(c->icc_apr));
Quoted 8 lines

hw/intc/arm_gicv3_kvm.c static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) · line 629

Quoted 6 lines
hw/intc/arm_gicv3_kvm.c +5 -0
     memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen));
+
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                              KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity))) {
+        return;
+    }

Can't we use gicv3 migration blocker provided if it is set before this reset.

yes we could. I hesitated but eventually found the relationship between the blocker and this kvm device group access was maybe not obvious.

As preferred.

Thanks

Eric

Quoted 14 lines
Quoted 13 lines
hw/intc/arm_gicv3_kvm.c +6 -1
+    /* Initialize to actual HW supported configuration */
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS,
+                      KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity),
+                      &c->icc_ctlr_el1[GICV3_NS], false);
+
+    c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS];
 }
 
 static void kvm_arm_gicv3_reset(DeviceState *dev)
--

2.5.5

Tested-by Prakash, Brahmajyosyula on v1 1/1
#4 lore raw
In reply to Eric Auger
Quoted 10 lines · Eric Auger

KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS needs to be checked before attempting to read ICC_CTLR_EL1; otherwise kernel versions not exposing this kvm device group will be incompatible with qemu 2.9.

Fixes 07a5628 ("hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers")

---

Thank Eric,

Verified compatibility for host kernel versions 4.4, 4.10 and 4.11-rc3, guest booted fine with these.