]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.162/svm-fix-avic-incomplete-ipi-emulation.patch
Linux 4.9.162
[thirdparty/kernel/stable-queue.git] / releases / 4.9.162 / svm-fix-avic-incomplete-ipi-emulation.patch
1 From fcbe00c7276be22464570b598d42cbc108ff1d00 Mon Sep 17 00:00:00 2001
2 From: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
3 Date: Tue, 22 Jan 2019 10:25:13 +0000
4 Subject: svm: Fix AVIC incomplete IPI emulation
5
6 [ Upstream commit bb218fbcfaaa3b115d4cd7a43c0ca164f3a96e57 ]
7
8 In case of incomplete IPI with invalid interrupt type, the current
9 SVM driver does not properly emulate the IPI, and fails to boot
10 FreeBSD guests with multiple vcpus when enabling AVIC.
11
12 Fix this by update APIC ICR high/low registers, which also
13 emulate sending the IPI.
14
15 Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
16 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
17 Signed-off-by: Sasha Levin <sashal@kernel.org>
18 ---
19 arch/x86/kvm/svm.c | 19 ++++---------------
20 1 file changed, 4 insertions(+), 15 deletions(-)
21
22 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
23 index c8efacf2e65f1..afc2bd03b4d9e 100644
24 --- a/arch/x86/kvm/svm.c
25 +++ b/arch/x86/kvm/svm.c
26 @@ -3932,25 +3932,14 @@ static int avic_incomplete_ipi_interception(struct vcpu_svm *svm)
27 kvm_lapic_reg_write(apic, APIC_ICR, icrl);
28 break;
29 case AVIC_IPI_FAILURE_TARGET_NOT_RUNNING: {
30 - int i;
31 - struct kvm_vcpu *vcpu;
32 - struct kvm *kvm = svm->vcpu.kvm;
33 struct kvm_lapic *apic = svm->vcpu.arch.apic;
34
35 /*
36 - * At this point, we expect that the AVIC HW has already
37 - * set the appropriate IRR bits on the valid target
38 - * vcpus. So, we just need to kick the appropriate vcpu.
39 + * Update ICR high and low, then emulate sending IPI,
40 + * which is handled when writing APIC_ICR.
41 */
42 - kvm_for_each_vcpu(i, vcpu, kvm) {
43 - bool m = kvm_apic_match_dest(vcpu, apic,
44 - icrl & KVM_APIC_SHORT_MASK,
45 - GET_APIC_DEST_FIELD(icrh),
46 - icrl & KVM_APIC_DEST_MASK);
47 -
48 - if (m && !avic_vcpu_is_running(vcpu))
49 - kvm_vcpu_wake_up(vcpu);
50 - }
51 + kvm_lapic_reg_write(apic, APIC_ICR2, icrh);
52 + kvm_lapic_reg_write(apic, APIC_ICR, icrl);
53 break;
54 }
55 case AVIC_IPI_FAILURE_INVALID_TARGET:
56 --
57 2.19.1
58