Skip to contentSkip to conversation

Arm migration fixes for 3.0

PATCH Superseded Peter Maydell 2 participants 8 messages Aug 3, 2018 – Aug 6, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Arm migration fixes for 3.0

This patchset primarily fixes problems with Arm migration induced by a bug in the core vmstate handling of subsections:
currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it.

I did an audit of all uses of subsections in QEMU, and found that we had four which didn't define a .needed function (assuming that this meant "always needed", same as the semantics for not providing a .needed function for a toplevel vmsd). This patchset fixes them all up by providing a dummy needed function.

It also fixes an error in vmstate_gicv3_cpu which was accidentally initializing .subsections twice and so ignoring one of the subsections.

Strictly speaking only the first patch is a true regression from 2.12.

Disclaimer: compile tested only as I have to rush out the door in a moment, but I wanted to get these on-list for review given that rc4 isn't too far away... I'll test them properly on Monday.

thanks
-- PMM

Peter Maydell (3):
hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a
needed function
hw/intc/arm_gicv3_common: Combine duplicate .subsections in
vmstate_gicv3_cpu
target/arm: Add dummy needed functions to M profile vmstate
subsections

 hw/intc/arm_gicv3_common.c | 9 ++++++---
 target/arm/machine.c       | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a needed function

Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving vmstate_gicv3_gicd_no_migration_shift_bug a 'needed' function that always returns true.

---
This should go into 3.0 to avoid awkward migration compat problems:
the no-migration-shift-bug subsection is new in 3.0.

---
 hw/intc/arm_gicv3_common.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/intc/arm_gicv3_common.c +6 -0
index ff326b374ad..e58bc8b8105 100644
@@ -203,10 +203,16 @@ static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
     return 0;
 }
 
+static bool needed_always(void *opaque)
+{
+    return true;
+}
+
 const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
     .name = "arm_gicv3/gicd_no_migration_shift_bug",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = needed_always,
     .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load,
     .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
     .fields = (VMStateField[]) {
Signature · 1 line
2.17.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [Qemu-arm] [PATCH 1/3] hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a needed function

Quoted 7 lines · * Peter Maydell ([email protected]) wrote:

Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving vmstate_gicv3_gicd_no_migration_shift_bug a 'needed' function that always returns true.

Quoted 31 lines

---
This should go into 3.0 to avoid awkward migration compat problems:
the no-migration-shift-bug subsection is new in 3.0.

---
 hw/intc/arm_gicv3_common.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/intc/arm_gicv3_common.c +6 -0
index ff326b374ad..e58bc8b8105 100644
@@ -203,10 +203,16 @@ static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
     return 0;
 }
 
+static bool needed_always(void *opaque)
+{
+    return true;
+}
+
 const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
     .name = "arm_gicv3/gicd_no_migration_shift_bug",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = needed_always,
     .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load,
     .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
     .fields = (VMStateField[]) {
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw

Re: [Qemu-arm] [PATCH 1/3] hw/intc/arm_gicv3_common: Give no-migration-shift-bug subsection a needed function

In reply to Peter Maydell

Forgot to cc Shannon on this one. Given that the missing .needed function meant we weren't ever transmitting the subsection with the no-shift-bug flag, this ought to mean that for current master migration of KVM goes wrong (since the destination thinks the source has the bug when it does not). I'm just going to try to set up to test this...

thanks
-- PMM

Quoted 37 lines · Peter Maydell

Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving vmstate_gicv3_gicd_no_migration_shift_bug a 'needed' function that always returns true.

---
This should go into 3.0 to avoid awkward migration compat problems:
the no-migration-shift-bug subsection is new in 3.0.

---
 hw/intc/arm_gicv3_common.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/intc/arm_gicv3_common.c +6 -1
index ff326b374ad..e58bc8b8105 100644
@@ -203,10 +203,16 @@ static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
     return 0;
 }
 
+static bool needed_always(void *opaque)
+{
+    return true;
+}
+
 const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
     .name = "arm_gicv3/gicd_no_migration_shift_bug",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = needed_always,
     .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load,
     .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
     .fields = (VMStateField[]) {
--

2.17.1

#4 lore raw

PATCH 2/3 hw/intc/arm_gicv3_common: Combine duplicate .subsections in vmstate_gicv3_cpu

In reply to Peter Maydell

Commit 6692aac411199064 accidentally introduced a second initialization of the .subsections field of vmstate_gicv3_cpu, instead of adding the new subsection to the existing list. The effect of this was probably that migration of GICv3 with virtualization enabled was broken (or alternatively that migration of ICC_SRE_EL1 was broken, depending on which of the two initializers the compiler used). Combine the two into a single list.

---
Not strictly a 2.12 regression.

---
 hw/intc/arm_gicv3_common.c | 3 ---
 1 file changed, 3 deletions(-)
hw/intc/arm_gicv3_common.c +0 -3
index e58bc8b8105..e1a8999cf5b 100644
@@ -134,9 +134,6 @@ static const VMStateDescription vmstate_gicv3_cpu = {
     },
     .subsections = (const VMStateDescription * []) {
         &vmstate_gicv3_cpu_virt,
-        NULL
-    },
-    .subsections = (const VMStateDescription * []) {
         &vmstate_gicv3_cpu_sre_el1,
         NULL
     }
Signature · 1 line
2.17.1
Reviewed-by on v1 2/3
#5 lore raw

Re: [Qemu-arm] [PATCH 2/3] hw/intc/arm_gicv3_common: Combine duplicate .subsections in vmstate_gicv3_cpu

Quoted 9 lines · * Peter Maydell ([email protected]) wrote:

Commit 6692aac411199064 accidentally introduced a second initialization of the .subsections field of vmstate_gicv3_cpu, instead of adding the new subsection to the existing list. The effect of this was probably that migration of GICv3 with virtualization enabled was broken (or alternatively that migration of ICC_SRE_EL1 was broken, depending on which of the two initializers the compiler used). Combine the two into a single list.

Quoted 23 lines

---
Not strictly a 2.12 regression.

---
 hw/intc/arm_gicv3_common.c | 3 ---
 1 file changed, 3 deletions(-)
hw/intc/arm_gicv3_common.c +0 -3
index e58bc8b8105..e1a8999cf5b 100644
@@ -134,9 +134,6 @@ static const VMStateDescription vmstate_gicv3_cpu = {
     },
     .subsections = (const VMStateDescription * []) {
         &vmstate_gicv3_cpu_virt,
-        NULL
-    },
-    .subsections = (const VMStateDescription * []) {
         &vmstate_gicv3_cpu_sre_el1,
         NULL
     }
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#6 lore raw

PATCH 3/3 target/arm: Add dummy needed functions to M profile vmstate subsections

In reply to Peter Maydell

Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving various M profile vmstate structs a 'needed' function that always returns true.
We reuse m_needed() for this, since it's always true here.

---
Not strictly a regression as it only affects M profile CPUs with the security extensions, and migration of those was broken anyway in 2.12 due to a different bug.

---
 target/arm/machine.c | 3 +++
 1 file changed, 3 insertions(+)
target/arm/machine.c +3 -0
index 2e28d086bdf..ff4ec22bf75 100644
@@ -184,6 +184,7 @@ static const VMStateDescription vmstate_m_faultmask_primask = {
     .name = "cpu/m/faultmask-primask",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU),
         VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU),
@@ -230,6 +231,7 @@ static const VMStateDescription vmstate_m_scr = {
     .name = "cpu/m/scr",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
         VMSTATE_END_OF_LIST()
@@ -240,6 +242,7 @@ static const VMStateDescription vmstate_m_other_sp = {
     .name = "cpu/m/other-sp",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
         VMSTATE_END_OF_LIST()
Signature · 1 line
2.17.1
Reviewed-by on v1 3/3
#7 lore raw

Re: [Qemu-devel] [PATCH 3/3] target/arm: Add dummy needed functions to M profile vmstate subsections

Quoted 8 lines · * Peter Maydell ([email protected]) wrote:

Currently the migration code incorrectly treats a subsection with no .needed function pointer as if it was the subsection list terminator -- it is ignored and so is everything after it. Work around this by giving various M profile vmstate structs a 'needed' function that always returns true.
We reuse m_needed() for this, since it's always true here.

Quoted 39 lines

---
Not strictly a regression as it only affects M profile CPUs with the security extensions, and migration of those was broken anyway in 2.12 due to a different bug.

---
 target/arm/machine.c | 3 +++
 1 file changed, 3 insertions(+)
target/arm/machine.c +3 -0
index 2e28d086bdf..ff4ec22bf75 100644
@@ -184,6 +184,7 @@ static const VMStateDescription vmstate_m_faultmask_primask = {
     .name = "cpu/m/faultmask-primask",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.faultmask[M_REG_NS], ARMCPU),
         VMSTATE_UINT32(env.v7m.primask[M_REG_NS], ARMCPU),
@@ -230,6 +231,7 @@ static const VMStateDescription vmstate_m_scr = {
     .name = "cpu/m/scr",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.scr[M_REG_NS], ARMCPU),
         VMSTATE_END_OF_LIST()
@@ -240,6 +242,7 @@ static const VMStateDescription vmstate_m_other_sp = {
     .name = "cpu/m/other-sp",
     .version_id = 1,
     .minimum_version_id = 1,
+    .needed = m_needed,
     .fields = (VMStateField[]) {
         VMSTATE_UINT32(env.v7m.other_sp, ARMCPU),
         VMSTATE_END_OF_LIST()
Signature · 1 line
2.17.1

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK