Skip to content

Commit a23480f

Browse files
committed
iommu/amd: WARN if KVM calls GA IRTE helpers without virtual APIC support
WARN if KVM attempts to update IRTE entries when virtual APIC isn't fully supported, as KVM should guard all such calls on IRQ posting being enabled. Link: https://lore.kernel.org/r/20250611224604.313496-58-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 11a6045 commit a23480f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,8 +3836,10 @@ int amd_iommu_update_ga(int cpu, void *data)
38363836
struct amd_ir_data *ir_data = (struct amd_ir_data *)data;
38373837
struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
38383838

3839-
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
3840-
!entry || !entry->lo.fields_vapic.guest_mode)
3839+
if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
3840+
return -EINVAL;
3841+
3842+
if (!entry || !entry->lo.fields_vapic.guest_mode)
38413843
return 0;
38423844

38433845
if (!ir_data->iommu)
@@ -3856,7 +3858,10 @@ int amd_iommu_activate_guest_mode(void *data, int cpu)
38563858
struct irte_ga *entry = (struct irte_ga *) ir_data->entry;
38573859
u64 valid;
38583860

3859-
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) || !entry)
3861+
if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
3862+
return -EINVAL;
3863+
3864+
if (!entry)
38603865
return 0;
38613866

38623867
valid = entry->lo.fields_vapic.valid;
@@ -3885,8 +3890,10 @@ int amd_iommu_deactivate_guest_mode(void *data)
38853890
struct irq_cfg *cfg = ir_data->cfg;
38863891
u64 valid;
38873892

3888-
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) ||
3889-
!entry || !entry->lo.fields_vapic.guest_mode)
3893+
if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
3894+
return -EINVAL;
3895+
3896+
if (!entry || !entry->lo.fields_vapic.guest_mode)
38903897
return 0;
38913898

38923899
valid = entry->lo.fields_remap.valid;

0 commit comments

Comments
 (0)