History

iommu/arm-smmu-v3-iommufd: Report CFGI/TLBI-repeat erratum

A guest with access to VCMDQ generates its own invalidation commands and must apply any invalidation errata before submitting them. If the host also repeats those commands, each affected invalidation is issued four times instead of twice. Add IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI to report the CFGI/TLBI-repeat erratum to user space. This allows the VMM to expose the erratum to the guest or apply the workaround itself. Use the raw __arm_smmu_cmdq_issue_cmdlist() helper for user-provided invalidations so the host does not apply the workaround a second time. Add arm_smmu_erratum_repeat_tlbi_cfgi() to query the static key when populating the SMMUv3 hardware information.

Ashish Mhetre committed 3 months ago

Commit d501d661 parent 95ed2da4 files · +24 −4Browse files

Unified · Split

4 files
  1. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c +5 −2
  2. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +6 −1
  3. drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +1 −0
  4. include/uapi/linux/iommufd.h +12 −1
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c+5−2
@@ -33,6 +33,9 @@ void *arm_smmu_hw_info(struct device *dev, u32 *length, · 32 unmodified lines
33 info->iidr = readl_relaxed(master->smmu->base + ARM_SMMU_IIDR);33 info->iidr = readl_relaxed(master->smmu->base + ARM_SMMU_IIDR);
34 info->aidr = readl_relaxed(master->smmu->base + ARM_SMMU_AIDR);34 info->aidr = readl_relaxed(master->smmu->base + ARM_SMMU_AIDR);
35 35
36 if (arm_smmu_erratum_repeat_tlbi_cfgi())
37 info->flags |= IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI;
38
36 *length = sizeof(*info);39 *length = sizeof(*info);
37 *type = IOMMU_HW_INFO_TYPE_ARM_SMMUV3;40 *type = IOMMU_HW_INFO_TYPE_ARM_SMMUV3;
38 41
@@ -386,8 +389,8 @@ int arm_vsmmu_cache_invalidate(struct iommufd_viommu *viommu, · 347 unmodified lines
386 continue;389 continue;
387 390
388 /* FIXME always uses the main cmdq rather than trying to group by type */391 /* FIXME always uses the main cmdq rather than trying to group by type */
389 ret = arm_smmu_cmdq_issue_cmdlist(smmu, &smmu->cmdq, &last->cmd,392 ret = __arm_smmu_cmdq_issue_cmdlist(smmu, &smmu->cmdq, &last->cmd,
390 cur - last, true);393 cur - last, true);
391 if (ret) {394 if (ret) {
392 cur--;395 cur--;
393 goto out;396 goto out;
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c+6−1
@@ -829,11 +829,16 @@ int __arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, · 828 unmodified lines
829 return ret;829 return ret;
830}830}
831 831
832bool arm_smmu_erratum_repeat_tlbi_cfgi(void)
833{
834 return static_branch_unlikely(&arm_smmu_erratum_repeat_tlbi_cfgi_key);
835}
836
832static bool arm_smmu_erratum_cmd_needs_repeating(struct arm_smmu_cmd *cmd)837static bool arm_smmu_erratum_cmd_needs_repeating(struct arm_smmu_cmd *cmd)
833{838{
834 u8 opcode;839 u8 opcode;
835 840
836 if (!static_branch_unlikely(&arm_smmu_erratum_repeat_tlbi_cfgi_key))841 if (!arm_smmu_erratum_repeat_tlbi_cfgi())
837 return false;842 return false;
838 843
839 opcode = FIELD_GET(CMDQ_0_OP, cmd->data[0]);844 opcode = FIELD_GET(CMDQ_0_OP, cmd->data[0]);
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h+1−0
@@ -1216,6 +1216,7 @@ int arm_smmu_cmdq_issue_cmdlist(struct arm_smmu_device *smmu, · 1215 unmodified lines
1216 struct arm_smmu_cmdq *cmdq,1216 struct arm_smmu_cmdq *cmdq,
1217 struct arm_smmu_cmd *cmds, int n,1217 struct arm_smmu_cmd *cmds, int n,
1218 bool sync);1218 bool sync);
1219bool arm_smmu_erratum_repeat_tlbi_cfgi(void);
1219 1220
1220#ifdef CONFIG_ARM_SMMU_V3_SVA1221#ifdef CONFIG_ARM_SMMU_V3_SVA
1221bool arm_smmu_sva_supported(struct arm_smmu_device *smmu);1222bool arm_smmu_sva_supported(struct arm_smmu_device *smmu);
include/uapi/linux/iommufd.h+12−1
@@ -574,11 +574,22 @@ struct iommu_hw_info_vtd { · 573 unmodified lines
574 __aligned_u64 ecap_reg;574 __aligned_u64 ecap_reg;
575};575};
576 576
577/**
578 * enum iommu_hw_info_arm_smmuv3_flags - Flags for ARM SMMUv3 hw_info
579 * @IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI:
580 * If set, user space must issue TLBI/CFGI+SYNC commands twice due to
581 * hardware erratum T264-SMMU-3. See the description at
582 * arm_smmu_erratum_repeat_tlbi_cfgi_key.
583 */
584enum iommu_hw_info_arm_smmuv3_flags {
585 IOMMU_HW_INFO_ARM_SMMUV3_ERRATA_REPEAT_TLBI_CFGI = 1 << 0,
586};
587
577/**588/**
578 * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information589 * struct iommu_hw_info_arm_smmuv3 - ARM SMMUv3 hardware information
579 * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3)590 * (IOMMU_HW_INFO_TYPE_ARM_SMMUV3)
580 *591 *
581 * @flags: Must be set to 0592 * @flags: Combination of enum iommu_hw_info_arm_smmuv3_flags
582 * @__reserved: Must be 0593 * @__reserved: Must be 0
583 * @idr: Implemented features for ARM SMMU Non-secure programming interface594 * @idr: Implemented features for ARM SMMU Non-secure programming interface
584 * @iidr: Information about the implementation and implementer of ARM SMMU,595 * @iidr: Information about the implementation and implementer of ARM SMMU,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t