* [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) @ 2024-10-19 20:34 kernel test robot 2024-10-19 22:05 ` Nicolin Chen 0 siblings, 1 reply; 4+ messages in thread From: kernel test robot @ 2024-10-19 20:34 UTC (permalink / raw) To: Nicolin Chen; +Cc: oe-kbuild-all, Jason Gunthorpe, Eric Auger tree: https://github.com/jgunthorpe/linux smmuv3_nesting head: fa1528253d221071f2c743b194d5aebad4b55a93 commit: a29d6e74459ce8ff8a2c370e09cdd85d2ee89480 [11/17] iommu/arm-smmu-v3: Add arm_smmu_cache_invalidate_user config: arm64-randconfig-r123-20241019 (https://download.01.org/0day-ci/archive/20241020/202410200404.OJrmhHAF-lkp@intel.com/config) compiler: aarch64-linux-gcc (GCC) 14.1.0 reproduce: (https://download.01.org/0day-ci/archive/20241020/202410200404.OJrmhHAF-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410200404.OJrmhHAF-lkp@intel.com/ sparse warnings: (new ones prefixed by >>) >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 @@ got unsigned long long [usertype] @@ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: expected restricted __le64 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: got unsigned long long [usertype] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:142:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 @@ got unsigned long long [usertype] @@ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:142:21: sparse: expected restricted __le64 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:142:21: sparse: got unsigned long long [usertype] >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:144:25: sparse: sparse: restricted __le64 degrades to integer >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:147:29: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 @@ got unsigned long long @@ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:147:29: sparse: expected restricted __le64 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:147:29: sparse: got unsigned long long >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:155:29: sparse: sparse: invalid assignment: &= drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:155:29: sparse: left side has type restricted __le64 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:155:29: sparse: right side has type unsigned long long drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:156:29: sparse: sparse: invalid assignment: |= drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:156:29: sparse: left side has type restricted __le64 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:156:29: sparse: right side has type unsigned long long >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:202:51: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned long long [usertype] *cmds @@ got restricted __le64 * @@ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:202:51: sparse: expected unsigned long long [usertype] *cmds drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:202:51: sparse: got restricted __le64 * vim +141 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c 127 128 /* 129 * Convert, in place, the raw invalidation command into an internal format that 130 * can be passed to arm_smmu_cmdq_issue_cmdlist(). Internally commands are 131 * stored in CPU endian. 132 * 133 * Enforce the VMID on the command. 134 */ 135 static int 136 arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain, 137 struct iommu_hwpt_arm_smmuv3_invalidate *cmd) 138 { 139 u16 vmid = nested_domain->s2_parent->s2_cfg.vmid; 140 > 141 cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); 142 cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); 143 > 144 switch (cmd->cmd[0] & CMDQ_0_OP) { 145 case CMDQ_OP_TLBI_NSNH_ALL: 146 /* Convert to NH_ALL */ > 147 cmd->cmd[0] = CMDQ_OP_TLBI_NH_ALL | 148 FIELD_PREP(CMDQ_TLBI_0_VMID, vmid); 149 cmd->cmd[1] = 0; 150 break; 151 case CMDQ_OP_TLBI_NH_VA: 152 case CMDQ_OP_TLBI_NH_VAA: 153 case CMDQ_OP_TLBI_NH_ALL: 154 case CMDQ_OP_TLBI_NH_ASID: > 155 cmd->cmd[0] &= ~CMDQ_TLBI_0_VMID; 156 cmd->cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_VMID, vmid); 157 break; 158 default: 159 return -EIO; 160 } 161 return 0; 162 } 163 164 static int arm_smmu_cache_invalidate_user(struct iommu_domain *domain, 165 struct iommu_user_data_array *array) 166 { 167 struct arm_smmu_nested_domain *nested_domain = 168 to_smmu_nested_domain(domain); 169 struct arm_smmu_device *smmu = nested_domain->s2_parent->smmu; 170 struct iommu_hwpt_arm_smmuv3_invalidate *last_batch; 171 struct iommu_hwpt_arm_smmuv3_invalidate *cmds; 172 struct iommu_hwpt_arm_smmuv3_invalidate *cur; 173 struct iommu_hwpt_arm_smmuv3_invalidate *end; 174 int ret; 175 176 cmds = kcalloc(array->entry_num, sizeof(*cmds), GFP_KERNEL); 177 if (!cmds) 178 return -ENOMEM; 179 cur = cmds; 180 end = cmds + array->entry_num; 181 182 static_assert(sizeof(*cmds) == 2 * sizeof(u64)); 183 ret = iommu_copy_struct_from_full_user_array( 184 cmds, sizeof(*cmds), array, 185 IOMMU_HWPT_INVALIDATE_DATA_ARM_SMMUV3); 186 if (ret) 187 goto out; 188 189 last_batch = cmds; 190 while (cur != end) { 191 ret = arm_smmu_convert_user_cmd(nested_domain, cur); 192 if (ret) 193 goto out; 194 195 /* FIXME work in blocks of CMDQ_BATCH_ENTRIES and copy each block? */ 196 cur++; 197 if (cur != end && (cur - last_batch) != CMDQ_BATCH_ENTRIES - 1) 198 continue; 199 200 /* FIXME always uses the main cmdq rather than trying to group by type */ 201 ret = arm_smmu_cmdq_issue_cmdlist(smmu, &smmu->cmdq, > 202 last_batch->cmd, 203 cur - last_batch, true); 204 if (ret) { 205 cur--; 206 goto out; 207 } 208 last_batch = cur; 209 } 210 out: 211 array->entry_num = cur - cmds; 212 kfree(cmds); 213 return ret; 214 } 215 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) 2024-10-19 20:34 [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) kernel test robot @ 2024-10-19 22:05 ` Nicolin Chen 2024-10-21 12:41 ` Jason Gunthorpe 0 siblings, 1 reply; 4+ messages in thread From: Nicolin Chen @ 2024-10-19 22:05 UTC (permalink / raw) To: kernel test robot; +Cc: oe-kbuild-all, Jason Gunthorpe, Eric Auger On Sun, Oct 20, 2024 at 04:34:57AM +0800, kernel test robot wrote: > sparse warnings: (new ones prefixed by >>) > >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 @@ got unsigned long long [usertype] @@ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: expected restricted __le64 > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: got unsigned long long [usertype] [...] > 127 > 128 /* > 129 * Convert, in place, the raw invalidation command into an internal format that > 130 * can be passed to arm_smmu_cmdq_issue_cmdlist(). Internally commands are > 131 * stored in CPU endian. > 132 * > 133 * Enforce the VMID on the command. > 134 */ > 135 static int > 136 arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain, > 137 struct iommu_hwpt_arm_smmuv3_invalidate *cmd) > 138 { > 139 u16 vmid = nested_domain->s2_parent->s2_cfg.vmid; > 140 > > 141 cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); > 142 cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); The iommu_hwpt_arm_smmuv3_invalidate holds a le64 array, though we could probably do everything here in the le64 format, but... > 199 > 200 /* FIXME always uses the main cmdq rather than trying to group by type */ > 201 ret = arm_smmu_cmdq_issue_cmdlist(smmu, &smmu->cmdq, > > 202 last_batch->cmd, > 203 cur - last_batch, true); ..eventually, here arm_smmu_cmdq_issue_cmdlist needs u64. So, I am adding an extra native-endian structure to fix this: ---------------------------------------------------------------------- @@ -217,6 +217,10 @@ static int arm_vsmmu_vsid_to_sid(struct arm_vsmmu *vsmmu, u32 vsid, u32 *sid) return ret; } +struct vsmmu_invalidation_cmd { + u64 cmd[2]; +}; + /* * Convert, in place, the raw invalidation command into an internal format that * can be passed to arm_smmu_cmdq_issue_cmdlist(). Internally commands are @@ -226,7 +230,7 @@ static int arm_vsmmu_vsid_to_sid(struct arm_vsmmu *vsmmu, u32 vsid, u32 *sid) */ static int arm_vsmmu_convert_user_cmd(struct arm_vsmmu *vsmmu, - struct iommu_viommu_arm_smmuv3_invalidate *cmd) + struct vsmmu_invalidation_cmd *cmd) { cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); @@ -266,11 +270,11 @@ static int arm_vsmmu_cache_invalidate(struct iommufd_viommu *viommu, struct iommu_user_data_array *array) { struct arm_vsmmu *vsmmu = container_of(viommu, struct arm_vsmmu, core); - struct iommu_viommu_arm_smmuv3_invalidate *last; - struct iommu_viommu_arm_smmuv3_invalidate *cmds; - struct iommu_viommu_arm_smmuv3_invalidate *cur; - struct iommu_viommu_arm_smmuv3_invalidate *end; struct arm_smmu_device *smmu = vsmmu->smmu; + struct vsmmu_invalidation_cmd *last; + struct vsmmu_invalidation_cmd *cmds; + struct vsmmu_invalidation_cmd *cur; + struct vsmmu_invalidation_cmd *end; int ret; cmds = kcalloc(array->entry_num, sizeof(*cmds), GFP_KERNEL); ---------------------------------------------------------------------- Nicolin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) 2024-10-19 22:05 ` Nicolin Chen @ 2024-10-21 12:41 ` Jason Gunthorpe 2024-10-21 21:02 ` Nicolin Chen 0 siblings, 1 reply; 4+ messages in thread From: Jason Gunthorpe @ 2024-10-21 12:41 UTC (permalink / raw) To: Nicolin Chen; +Cc: kernel test robot, oe-kbuild-all, Eric Auger On Sat, Oct 19, 2024 at 03:05:27PM -0700, Nicolin Chen wrote: > On Sun, Oct 20, 2024 at 04:34:57AM +0800, kernel test robot wrote: > > > sparse warnings: (new ones prefixed by >>) > > >> drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __le64 @@ got unsigned long long [usertype] @@ > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: expected restricted __le64 > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: got unsigned long long [usertype] > [...] > > 127 > > 128 /* > > 129 * Convert, in place, the raw invalidation command into an internal format that > > 130 * can be passed to arm_smmu_cmdq_issue_cmdlist(). Internally commands are > > 131 * stored in CPU endian. > > 132 * > > 133 * Enforce the VMID on the command. > > 134 */ > > 135 static int > > 136 arm_smmu_convert_user_cmd(struct arm_smmu_nested_domain *nested_domain, > > 137 struct iommu_hwpt_arm_smmuv3_invalidate *cmd) > > 138 { > > 139 u16 vmid = nested_domain->s2_parent->s2_cfg.vmid; > > 140 > > > 141 cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); > > 142 cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); > > The iommu_hwpt_arm_smmuv3_invalidate holds a le64 array, though > we could probably do everything here in the le64 format, but... > > > 199 > > 200 /* FIXME always uses the main cmdq rather than trying to group by type */ > > 201 ret = arm_smmu_cmdq_issue_cmdlist(smmu, &smmu->cmdq, > > > 202 last_batch->cmd, > > 203 cur - last_batch, true); > > ..eventually, here arm_smmu_cmdq_issue_cmdlist needs u64. > > So, I am adding an extra native-endian structure to fix this: > > ---------------------------------------------------------------------- > @@ -217,6 +217,10 @@ static int arm_vsmmu_vsid_to_sid(struct arm_vsmmu *vsmmu, u32 vsid, u32 *sid) > return ret; > } > > +struct vsmmu_invalidation_cmd { > + u64 cmd[2]; > +}; > + > /* > * Convert, in place, the raw invalidation command into an internal format that > * can be passed to arm_smmu_cmdq_issue_cmdlist(). Internally commands are > @@ -226,7 +230,7 @@ static int arm_vsmmu_vsid_to_sid(struct arm_vsmmu *vsmmu, u32 vsid, u32 *sid) > */ > static int > arm_vsmmu_convert_user_cmd(struct arm_vsmmu *vsmmu, > - struct iommu_viommu_arm_smmuv3_invalidate *cmd) > + struct vsmmu_invalidation_cmd *cmd) > { > cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); > cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); That's going to make spare complain here though :\ You need a union to quiet it.. Or probably just a __force and a comment is fine Jason ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) 2024-10-21 12:41 ` Jason Gunthorpe @ 2024-10-21 21:02 ` Nicolin Chen 0 siblings, 0 replies; 4+ messages in thread From: Nicolin Chen @ 2024-10-21 21:02 UTC (permalink / raw) To: Jason Gunthorpe; +Cc: kernel test robot, oe-kbuild-all, Eric Auger On Mon, Oct 21, 2024 at 09:41:25AM -0300, Jason Gunthorpe wrote: > > arm_vsmmu_convert_user_cmd(struct arm_vsmmu *vsmmu, > > - struct iommu_viommu_arm_smmuv3_invalidate *cmd) > > + struct vsmmu_invalidation_cmd *cmd) > > { > > cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); > > cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); > > That's going to make spare complain here though :\ > > You need a union to quiet it.. Or probably just a __force and a > comment is fine Oh, right... I did __force, and confirmed with sparse: - cmd->cmd[0] = le64_to_cpu(cmd->cmd[0]); - cmd->cmd[1] = le64_to_cpu(cmd->cmd[1]); + /* Commands are le64 stored in u64 */ + cmd->cmd[0] = le64_to_cpu((__force __le64)cmd->cmd[0]); + cmd->cmd[1] = le64_to_cpu((__force __le64)cmd->cmd[1]); Thanks Nicolin ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-21 21:03 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-19 20:34 [jgunthorpe:smmuv3_nesting 11/17] drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c:141:21: sparse: sparse: incorrect type in assignment (different base types) kernel test robot 2024-10-19 22:05 ` Nicolin Chen 2024-10-21 12:41 ` Jason Gunthorpe 2024-10-21 21:02 ` Nicolin Chen
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.