yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-apic-Use-32bit-APIC-ID-for-migration-instance-ID.patch

902636
From 0d5a09173eb75b7e56122c2aefb2646a2be58400 Mon Sep 17 00:00:00 2001
902636
From: Peter Xu <peterx@redhat.com>
902636
Date: Fri, 31 Jan 2020 17:12:57 +0000
902636
Subject: [PATCH 15/15] apic: Use 32bit APIC ID for migration instance ID
902636
902636
RH-Author: Peter Xu <peterx@redhat.com>
902636
Message-id: <20200131171257.1066593-4-peterx@redhat.com>
902636
Patchwork-id: 93628
902636
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 3/3] apic: Use 32bit APIC ID for migration instance ID
902636
Bugzilla: 1529231
902636
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
902636
RH-Acked-by: Juan Quintela <quintela@redhat.com>
902636
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
902636
Migration is silently broken now with x2apic config like this:
902636
902636
     -smp 200,maxcpus=288,sockets=2,cores=72,threads=2 \
902636
     -device intel-iommu,intremap=on,eim=on
902636
902636
After migration, the guest kernel could hang at anything, due to
902636
x2apic bit not migrated correctly in IA32_APIC_BASE on some vcpus, so
902636
any operations related to x2apic could be broken then (e.g., RDMSR on
902636
x2apic MSRs could fail because KVM would think that the vcpu hasn't
902636
enabled x2apic at all).
902636
902636
The issue is that the x2apic bit was never applied correctly for vcpus
902636
whose ID > 255 when migrate completes, and that's because when we
902636
migrate APIC we use the APICCommonState.id as instance ID of the
902636
migration stream, while that's too short for x2apic.
902636
902636
Let's use the newly introduced initial_apic_id for that.
902636
902636
Signed-off-by: Peter Xu <peterx@redhat.com>
902636
Reviewed-by: Juan Quintela <quintela@redhat.com>
902636
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
902636
Signed-off-by: Juan Quintela <quintela@redhat.com>
902636
(cherry picked from commit 0ab994867c365db21e15f9503922c79234d8e40e)
902636
Signed-off-by: Peter Xu <peterx@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 hw/intc/apic_common.c | 5 ++++-
902636
 1 file changed, 4 insertions(+), 1 deletion(-)
902636
902636
diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c
902636
index 54b8731..b5dbeb6 100644
902636
--- a/hw/intc/apic_common.c
902636
+++ b/hw/intc/apic_common.c
902636
@@ -268,7 +268,10 @@ static void apic_common_realize(DeviceState *dev, Error **errp)
902636
     APICCommonState *s = APIC_COMMON(dev);
902636
     APICCommonClass *info;
902636
     static DeviceState *vapic;
902636
-    uint32_t instance_id = s->id;
902636
+    uint32_t instance_id = s->initial_apic_id;
902636
+
902636
+    /* Normally initial APIC ID should be no more than hundreds */
902636
+    assert(instance_id != VMSTATE_INSTANCE_ID_ANY);
902636
 
902636
     info = APIC_COMMON_GET_CLASS(s);
902636
     info->realize(dev, errp);
902636
-- 
902636
1.8.3.1
902636