Patch "iommu/amd: Don't block updates to GATag if guest mode is on" has been added to the 6.3-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

    iommu/amd: Don't block updates to GATag if guest mode is on

to the 6.3-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:
     iommu-amd-don-t-block-updates-to-gatag-if-guest-mode.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3119726a03f77fdc8524aeb3b4a3c47a3a256299
Author: Joao Martins <joao.m.martins@xxxxxxxxxx>
Date:   Wed Apr 19 21:11:53 2023 +0100

    iommu/amd: Don't block updates to GATag if guest mode is on
    
    [ Upstream commit ed8a2f4ddef2eaaf864ab1efbbca9788187036ab ]
    
    On KVM GSI routing table updates, specially those where they have vIOMMUs
    with interrupt remapping enabled (to boot >255vcpus setups without relying
    on KVM_FEATURE_MSI_EXT_DEST_ID), a VMM may update the backing VF MSIs
    with a new VCPU affinity.
    
    On AMD with AVIC enabled, the new vcpu affinity info is updated via:
            avic_pi_update_irte()
                    irq_set_vcpu_affinity()
                            amd_ir_set_vcpu_affinity()
                                    amd_iommu_{de}activate_guest_mode()
    
    Where the IRTE[GATag] is updated with the new vcpu affinity. The GATag
    contains VM ID and VCPU ID, and is used by IOMMU hardware to signal KVM
    (via GALog) when interrupt cannot be delivered due to vCPU is in
    blocking state.
    
    The issue is that amd_iommu_activate_guest_mode() will essentially
    only change IRTE fields on transitions from non-guest-mode to guest-mode
    and otherwise returns *with no changes to IRTE* on already configured
    guest-mode interrupts. To the guest this means that the VF interrupts
    remain affined to the first vCPU they were first configured, and guest
    will be unable to issue VF interrupts and receive messages like this
    from spurious interrupts (e.g. from waking the wrong vCPU in GALog):
    
    [  167.759472] __common_interrupt: 3.34 No irq handler for vector
    [  230.680927] mlx5_core 0000:00:02.0: mlx5_cmd_eq_recover:247:(pid
    3122): Recovered 1 EQEs on cmd_eq
    [  230.681799] mlx5_core 0000:00:02.0:
    wait_func_handle_exec_timeout:1113:(pid 3122): cmd[0]: CREATE_CQ(0x400)
    recovered after timeout
    [  230.683266] __common_interrupt: 3.34 No irq handler for vector
    
    Given the fact that amd_ir_set_vcpu_affinity() uses
    amd_iommu_activate_guest_mode() underneath it essentially means that VCPU
    affinity changes of IRTEs are nops. Fix it by dropping the check for
    guest-mode at amd_iommu_activate_guest_mode(). Same thing is applicable to
    amd_iommu_deactivate_guest_mode() although, even if the IRTE doesn't change
    underlying DestID on the host, the VFIO IRQ handler will still be able to
    poke at the right guest-vCPU.
    
    Fixes: b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activation code")
    Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
    Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@xxxxxxx>
    Link: https://lore.kernel.org/r/20230419201154.83880-2-joao.m.martins@xxxxxxxxxx
    Signed-off-by: Joerg Roedel <jroedel@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 167da5b1a5e31..99ec06b0e09f6 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3482,8 +3482,7 @@ int amd_iommu_activate_guest_mode(void *data)
 	struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
 	u64 valid;
 
-	if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
-	    !entry || entry->lo.fields_vapic.guest_mode)
+	if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) || !entry)
 		return 0;
 
 	valid = entry->lo.fields_vapic.valid;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux