|
@@ -27,6 +27,7 @@
|
|
#include "hw/intc/arm_gicv3_common.h"
|
|
#include "hw/intc/arm_gicv3_common.h"
|
|
#include "gicv3_internal.h"
|
|
#include "gicv3_internal.h"
|
|
#include "hw/arm/linux-boot-if.h"
|
|
#include "hw/arm/linux-boot-if.h"
|
|
|
|
+#include "sysemu/kvm.h"
|
|
|
|
|
|
static int gicv3_pre_save(void *opaque)
|
|
static int gicv3_pre_save(void *opaque)
|
|
{
|
|
{
|
|
@@ -141,6 +142,79 @@ static const VMStateDescription vmstate_gicv3_cpu = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+static int gicv3_gicd_no_migration_shift_bug_pre_load(void *opaque)
|
|
|
|
+{
|
|
|
|
+ GICv3State *cs = opaque;
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * The gicd_no_migration_shift_bug flag is used for migration compatibility
|
|
|
|
+ * for old version QEMU which may have the GICD bmp shift bug under KVM mode.
|
|
|
|
+ * Strictly, what we want to know is whether the migration source is using
|
|
|
|
+ * KVM. Since we don't have any way to determine that, we look at whether the
|
|
|
|
+ * destination is using KVM; this is close enough because for the older QEMU
|
|
|
|
+ * versions with this bug KVM -> TCG migration didn't work anyway. If the
|
|
|
|
+ * source is a newer QEMU without this bug it will transmit the migration
|
|
|
|
+ * subsection which sets the flag to true; otherwise it will remain set to
|
|
|
|
+ * the value we select here.
|
|
|
|
+ */
|
|
|
|
+ if (kvm_enabled()) {
|
|
|
|
+ cs->gicd_no_migration_shift_bug = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int gicv3_gicd_no_migration_shift_bug_post_load(void *opaque,
|
|
|
|
+ int version_id)
|
|
|
|
+{
|
|
|
|
+ GICv3State *cs = opaque;
|
|
|
|
+
|
|
|
|
+ if (cs->gicd_no_migration_shift_bug) {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* Older versions of QEMU had a bug in the handling of state save/restore
|
|
|
|
+ * to the KVM GICv3: they got the offset in the bitmap arrays wrong,
|
|
|
|
+ * so that instead of the data for external interrupts 32 and up
|
|
|
|
+ * starting at bit position 32 in the bitmap, it started at bit
|
|
|
|
+ * position 64. If we're receiving data from a QEMU with that bug,
|
|
|
|
+ * we must move the data down into the right place.
|
|
|
|
+ */
|
|
|
|
+ memmove(cs->group, (uint8_t *)cs->group + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->group) - GIC_INTERNAL / 8);
|
|
|
|
+ memmove(cs->grpmod, (uint8_t *)cs->grpmod + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->grpmod) - GIC_INTERNAL / 8);
|
|
|
|
+ memmove(cs->enabled, (uint8_t *)cs->enabled + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->enabled) - GIC_INTERNAL / 8);
|
|
|
|
+ memmove(cs->pending, (uint8_t *)cs->pending + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->pending) - GIC_INTERNAL / 8);
|
|
|
|
+ memmove(cs->active, (uint8_t *)cs->active + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->active) - GIC_INTERNAL / 8);
|
|
|
|
+ memmove(cs->edge_trigger, (uint8_t *)cs->edge_trigger + GIC_INTERNAL / 8,
|
|
|
|
+ sizeof(cs->edge_trigger) - GIC_INTERNAL / 8);
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * While this new version QEMU doesn't have this kind of bug as we fix it,
|
|
|
|
+ * so it needs to set the flag to true to indicate that and it's necessary
|
|
|
|
+ * for next migration to work from this new version QEMU.
|
|
|
|
+ */
|
|
|
|
+ cs->gicd_no_migration_shift_bug = true;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const VMStateDescription vmstate_gicv3_gicd_no_migration_shift_bug = {
|
|
|
|
+ .name = "arm_gicv3/gicd_no_migration_shift_bug",
|
|
|
|
+ .version_id = 1,
|
|
|
|
+ .minimum_version_id = 1,
|
|
|
|
+ .pre_load = gicv3_gicd_no_migration_shift_bug_pre_load,
|
|
|
|
+ .post_load = gicv3_gicd_no_migration_shift_bug_post_load,
|
|
|
|
+ .fields = (VMStateField[]) {
|
|
|
|
+ VMSTATE_BOOL(gicd_no_migration_shift_bug, GICv3State),
|
|
|
|
+ VMSTATE_END_OF_LIST()
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
static const VMStateDescription vmstate_gicv3 = {
|
|
static const VMStateDescription vmstate_gicv3 = {
|
|
.name = "arm_gicv3",
|
|
.name = "arm_gicv3",
|
|
.version_id = 1,
|
|
.version_id = 1,
|
|
@@ -165,6 +239,10 @@ static const VMStateDescription vmstate_gicv3 = {
|
|
VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu,
|
|
VMSTATE_STRUCT_VARRAY_POINTER_UINT32(cpu, GICv3State, num_cpu,
|
|
vmstate_gicv3_cpu, GICv3CPUState),
|
|
vmstate_gicv3_cpu, GICv3CPUState),
|
|
VMSTATE_END_OF_LIST()
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
+ },
|
|
|
|
+ .subsections = (const VMStateDescription * []) {
|
|
|
|
+ &vmstate_gicv3_gicd_no_migration_shift_bug,
|
|
|
|
+ NULL
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
@@ -364,6 +442,7 @@ static void arm_gicv3_common_reset(DeviceState *dev)
|
|
gicv3_gicd_group_set(s, i);
|
|
gicv3_gicd_group_set(s, i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ s->gicd_no_migration_shift_bug = true;
|
|
}
|
|
}
|
|
|
|
|
|
static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,
|
|
static void arm_gic_common_linux_init(ARMLinuxBootIf *obj,
|