Skip to content

Commit da0c565

Browse files
nicolincjgunthorpe
authored andcommitted
iommu/arm-smmu-v3: Set MEV bit in nested STE for DoS mitigations
There is a DoS concern on the shared hardware event queue among devices passed through to VMs, that too many translation failures that belong to VMs could overflow the shared hardware event queue if those VMs or their VMMs don't handle/recover the devices properly. The MEV bit in the STE allows to configure the SMMU HW to merge similar event records, though there is no guarantee. Set it in a nested STE for DoS mitigations. In the future, we might want to enable the MEV for non-nested cases too such as domain->type == IOMMU_DOMAIN_UNMANAGED or even IOMMU_DOMAIN_DMA. Link: https://patch.msgid.link/r/8ed12feef67fc65273d0f5925f401a81f56acebe.1741719725.git.nicolinc@nvidia.com Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Pranjal Shrivastava <[email protected]> Acked-by: Will Deacon <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent e7d3fa3 commit da0c565

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ static void arm_smmu_make_nested_cd_table_ste(
4343
target->data[0] |= nested_domain->ste[0] &
4444
~cpu_to_le64(STRTAB_STE_0_CFG);
4545
target->data[1] |= nested_domain->ste[1];
46+
/* Merge events for DoS mitigations on eventq */
47+
target->data[1] |= cpu_to_le64(STRTAB_STE_1_MEV);
4648
}
4749

4850
/*

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ void arm_smmu_get_ste_used(const __le64 *ent, __le64 *used_bits)
10521052
cpu_to_le64(STRTAB_STE_1_S1DSS | STRTAB_STE_1_S1CIR |
10531053
STRTAB_STE_1_S1COR | STRTAB_STE_1_S1CSH |
10541054
STRTAB_STE_1_S1STALLD | STRTAB_STE_1_STRW |
1055-
STRTAB_STE_1_EATS);
1055+
STRTAB_STE_1_EATS | STRTAB_STE_1_MEV);
10561056
used_bits[2] |= cpu_to_le64(STRTAB_STE_2_S2VMID);
10571057

10581058
/*
@@ -1068,7 +1068,7 @@ void arm_smmu_get_ste_used(const __le64 *ent, __le64 *used_bits)
10681068
if (cfg & BIT(1)) {
10691069
used_bits[1] |=
10701070
cpu_to_le64(STRTAB_STE_1_S2FWB | STRTAB_STE_1_EATS |
1071-
STRTAB_STE_1_SHCFG);
1071+
STRTAB_STE_1_SHCFG | STRTAB_STE_1_MEV);
10721072
used_bits[2] |=
10731073
cpu_to_le64(STRTAB_STE_2_S2VMID | STRTAB_STE_2_VTCR |
10741074
STRTAB_STE_2_S2AA64 | STRTAB_STE_2_S2ENDI |

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ static inline u32 arm_smmu_strtab_l2_idx(u32 sid)
266266
#define STRTAB_STE_1_S1COR GENMASK_ULL(5, 4)
267267
#define STRTAB_STE_1_S1CSH GENMASK_ULL(7, 6)
268268

269+
#define STRTAB_STE_1_MEV (1UL << 19)
269270
#define STRTAB_STE_1_S2FWB (1UL << 25)
270271
#define STRTAB_STE_1_S1STALLD (1UL << 27)
271272

0 commit comments

Comments
 (0)