This is a note to let you know that I've just added the patch titled KVM: SVM: Process ICR on AVIC IPI delivery failure due to invalid target to the 6.1-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-svm-process-icr-on-avic-ipi-delivery-failure-due-to-invalid-target.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 5aede752a839904059c2b5d68be0dc4501c6c15f Mon Sep 17 00:00:00 2001 From: Sean Christopherson <seanjc@xxxxxxxxxx> Date: Fri, 6 Jan 2023 01:12:37 +0000 Subject: KVM: SVM: Process ICR on AVIC IPI delivery failure due to invalid target From: Sean Christopherson <seanjc@xxxxxxxxxx> commit 5aede752a839904059c2b5d68be0dc4501c6c15f upstream. Emulate ICR writes on AVIC IPI failures due to invalid targets using the same logic as failures due to invalid types. AVIC acceleration fails if _any_ of the targets are invalid, and crucially VM-Exits before sending IPIs to targets that _are_ valid. In logical mode, the destination is a bitmap, i.e. a single IPI can target multiple logical IDs. Doing nothing causes KVM to drop IPIs if at least one target is valid and at least one target is invalid. Fixes: 18f40c53e10f ("svm: Add VMEXIT handlers for AVIC") Cc: stable@xxxxxxxxxxxxxxx Reviewed-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> Reviewed-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx> Message-Id: <20230106011306.85230-5-seanjc@xxxxxxxxxx> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/x86/kvm/svm/avic.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -502,14 +502,18 @@ int avic_incomplete_ipi_interception(str trace_kvm_avic_incomplete_ipi(vcpu->vcpu_id, icrh, icrl, id, index); switch (id) { + case AVIC_IPI_FAILURE_INVALID_TARGET: case AVIC_IPI_FAILURE_INVALID_INT_TYPE: /* * Emulate IPIs that are not handled by AVIC hardware, which - * only virtualizes Fixed, Edge-Triggered INTRs. The exit is - * a trap, e.g. ICR holds the correct value and RIP has been - * advanced, KVM is responsible only for emulating the IPI. - * Sadly, hardware may sometimes leave the BUSY flag set, in - * which case KVM needs to emulate the ICR write as well in + * only virtualizes Fixed, Edge-Triggered INTRs, and falls over + * if _any_ targets are invalid, e.g. if the logical mode mask + * is a superset of running vCPUs. + * + * The exit is a trap, e.g. ICR holds the correct value and RIP + * has been advanced, KVM is responsible only for emulating the + * IPI. Sadly, hardware may sometimes leave the BUSY flag set, + * in which case KVM needs to emulate the ICR write as well in * order to clear the BUSY flag. */ if (icrl & APIC_ICR_BUSY) @@ -525,8 +529,6 @@ int avic_incomplete_ipi_interception(str */ avic_kick_target_vcpus(vcpu->kvm, apic, icrl, icrh, index); break; - case AVIC_IPI_FAILURE_INVALID_TARGET: - break; case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE: WARN_ONCE(1, "Invalid backing page\n"); break; Patches currently in stable-queue which might be from seanjc@xxxxxxxxxx are queue-6.1/kvm-svm-hyper-v-placate-modpost-section-mismatch-error.patch queue-6.1/kvm-svm-flush-the-current-tlb-when-activating-avic.patch queue-6.1/x86-virt-force-gif-1-prior-to-disabling-svm-for-reboot-flows.patch queue-6.1/kvm-x86-inject-gp-if-wrmsr-sets-reserved-bits-in-apic-self-ipi.patch queue-6.1/x86-reboot-disable-svm-not-just-vmx-when-stopping-cpus.patch queue-6.1/kvm-svm-process-icr-on-avic-ipi-delivery-failure-due-to-invalid-target.patch queue-6.1/kvm-x86-don-t-inhibit-apicv-avic-if-xapic-id-mismatch-is-due-to-32-bit-id.patch queue-6.1/x86-reboot-disable-virtualization-in-an-emergency-if-svm-is-supported.patch queue-6.1/kvm-svm-don-t-put-load-avic-when-setting-virtual-apic-mode.patch queue-6.1/x86-crash-disable-virt-in-core-nmi-crash-handler-to-avoid-double-shootdown.patch queue-6.1/kvm-register-dev-kvm-as-the-_very_-last-thing-during-initialization.patch queue-6.1/kvm-x86-don-t-inhibit-apicv-avic-on-xapic-id-change-if-apic-is-disabled.patch queue-6.1/kvm-destroy-target-device-if-coalesced-mmio-unregistration-fails.patch queue-6.1/kvm-svm-fix-potential-overflow-in-sev-s-send-receive_update_data.patch queue-6.1/kvm-x86-blindly-get-current-x2apic-reg-value-on-nodecode-write-traps.patch queue-6.1/kvm-x86-purge-highest-isr-cache-when-updating-apicv-state.patch queue-6.1/kvm-x86-inject-gp-on-x2apic-wrmsr-that-sets-reserved-bits-63-32.patch queue-6.1/kvm-vmx-fix-crash-due-to-uninitialized-current_vmcs.patch