From caa096c64adc8c7caadbf08165907ab3cc42b5c4 Mon Sep 17 00:00:00 2001 From: Prakash Gupta Date: Thu, 12 Dec 2019 23:06:25 +0530 Subject: [PATCH] iommu/arm-smmu: restrict secure vmid update while attached Client can update secure vmid by setting attribute DOMAIN_ATTR_SECURE_VMID. If this is done after domain attach, it causes a condition where TTBR pages aren't mapped to secure VMID. This causes S2 translation fault. Disallow secure vmid update if domain is attached. While we are at it, restrict DOMAIN_ATTR_FAST update while domain is attached. Change-Id: I4246f1f90a11ed21dfafa360cc2f16ade2708d2b Signed-off-by: Prakash Gupta Signed-off-by: Chris Goldsworthy --- drivers/iommu/arm-smmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 96a213db2d84..d4e8f3a286a5 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -3602,6 +3602,12 @@ static int __arm_smmu_domain_set_attr(struct iommu_domain *domain, break; } case DOMAIN_ATTR_SECURE_VMID: + /* can't be changed while attached */ + if (smmu_domain->smmu != NULL) { + ret = -EBUSY; + break; + } + if (smmu_domain->secure_vmid != VMID_INVAL) { ret = -ENODEV; WARN(1, "secure vmid already set!"); @@ -3615,6 +3621,12 @@ static int __arm_smmu_domain_set_attr(struct iommu_domain *domain, * force DOMAIN_ATTR_ATOMIC to bet set. */ case DOMAIN_ATTR_FAST: + /* can't be changed while attached */ + if (smmu_domain->smmu != NULL) { + ret = -EBUSY; + break; + } + if (*((int *)data)) { if (IS_ENABLED(CONFIG_IOMMU_IO_PGTABLE_FAST)) { set_bit(DOMAIN_ATTR_FAST,