Skip to contentSkip to conversation

Patch "KVM: lapic: Fixup LDR on load in x2apic" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Dec 4, 2017

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

KVM: lapic: Fixup LDR on load in x2apic

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
kvm-lapic-fixup-ldr-on-load-in-x2apic.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 12806ba937382fdfdbad62a399aa2dce65c10fcd Mon Sep 17 00:00:00 2001

From: "Dr. David Alan Gilbert" <[email protected]>
Date: Fri, 17 Nov 2017 11:52:50 +0000
Subject: KVM: lapic: Fixup LDR on load in x2apic

From: Dr. David Alan Gilbert <[email protected]>

commit 12806ba937382fdfdbad62a399aa2dce65c10fcd upstream.

In x2apic mode the LDR is fixed based on the ID rather than separately loadable like it was before x2. When kvm_apic_set_state is called, the base is set, and if it has the X2APIC_ENABLE flag set then the LDR is calculated; however that value gets overwritten by the memcpy a few lines below overwriting it with the value that came from userland.

The symptom is a lack of EOI after loading the state (e.g. after a QEMU migration) and is due to the EOI bitmap being wrong due to the incorrect LDR. This was seen with a Win2016 guest under Qemu with irqchip=split whose USB mouse didn't work after a VM migration.

This corresponds to RH bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1502591

---
 arch/x86/kvm/lapic.c |    5 +++++
 1 file changed, 5 insertions(+)
arch/x86/kvm/lapic.c +5 -0
@@ -2201,6 +2201,7 @@ static int kvm_apic_state_fixup(struct k
 {
 	if (apic_x2apic_mode(vcpu->arch.apic)) {
 		u32 *id = (u32 *)(s->regs + APIC_ID);
+		u32 *ldr = (u32 *)(s->regs + APIC_LDR);
 
 		if (vcpu->kvm->arch.x2apic_format) {
 			if (*id != vcpu->vcpu_id)
@@ -2211,6 +2212,10 @@ static int kvm_apic_state_fixup(struct k
 			else
 				*id <<= 24;
 		}
+
+		/* In x2APIC mode, the LDR is fixed and based on the id */
+		if (set)
+			*ldr = kvm_apic_calc_x2apic_ldr(*id);
 	}
 
 	return 0;

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/kvm-lapic-fixup-ldr-on-load-in-x2apic.patch queue-4.14/kvm-lapic-split-out-x2apic-ldr-calculation.patch