android_kernel_motorola_sm6375/drivers/iommu
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Joao Martins 17d70de572 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: b9c6ff94e4 ("iommu/amd: Re-factor guest virtual APIC (de-)activation code")
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Link: https://lore.kernel.org/r/20230419201154.83880-2-joao.m.martins@oracle.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-06-09 10:28:52 +02:00
..
amd_iommu.c iommu/amd: Don't block updates to GATag if guest mode is on 2023-06-09 10:28:52 +02:00
amd_iommu.h
amd_iommu_debugfs.c
amd_iommu_init.c iommu/amd: Add a length limitation for the ivrs_acpihid command-line parameter 2023-03-17 08:32:49 +01:00
amd_iommu_proto.h
amd_iommu_quirks.c
amd_iommu_types.h
amd_iommu_v2.c iommu/amd: Fix pci device refcount leak in ppr_notifier() 2023-01-18 11:41:29 +01:00
arm-smmu-impl.c
arm-smmu-v3.c iommu/arm-smmu-v3: Acknowledge pri/event queue overflow if any 2023-05-30 12:44:04 +01:00
arm-smmu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
arm-smmu.h
dma-iommu.c dma-mapping: drop the dev argument to arch_sync_dma_for_* 2023-04-05 11:16:43 +02:00
dmar.c iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init() 2022-12-08 11:23:04 +01:00
exynos-iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
fsl_pamu.c iommu/fsl_pamu: Fix resource leak in fsl_pamu_probe() 2023-01-18 11:41:29 +01:00
fsl_pamu.h
fsl_pamu_domain.c
fsl_pamu_domain.h
hyperv-iommu.c
intel-iommu-debugfs.c
intel-iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
intel-pasid.c iommu/vt-d: Fix PASID directory pointer coherency 2023-03-17 08:32:50 +01:00
intel-pasid.h
intel-svm.c
intel-trace.c
intel_irq_remapping.c iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping() 2022-02-08 18:24:29 +01:00
io-pgtable-arm-v7s.c
io-pgtable-arm.c
io-pgtable.c
iommu-debugfs.c
iommu-sysfs.c
iommu-traces.c
iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
iova.c iommu/iova: Improve 32-bit free space estimate 2022-04-15 14:17:56 +02:00
ipmmu-vmsa.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
irq_remapping.c
irq_remapping.h
Kconfig
Makefile
msm_iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
msm_iommu.h
msm_iommu_hw-8xxx.h
mtk_iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
mtk_iommu.h
mtk_iommu_v1.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
of_iommu.c
omap-iommu-debug.c iommu/omap: Fix buffer overflow in debugfs 2022-10-26 13:22:45 +02:00
omap-iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
omap-iommu.h
omap-iopgtable.h
qcom_iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
rockchip-iommu.c iommu/rockchip: Fix unwind goto issue 2023-06-09 10:28:52 +02:00
s390-iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
tegra-gart.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
tegra-smmu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00
virtio-iommu.c iommu: Add gfp parameter to iommu_ops::map 2023-02-22 12:50:31 +01:00