platform/x86/amd/pmf: Add support for PMF-TA interaction
Hello Shyam Sundar S K,
Commit ae82cef7d9c5 ("platform/x86/amd/pmf: Add support for PMF-TA interaction") from Dec 12, 2023 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/amd/pmf/tee-if.c:261 amd_pmf_invoke_cmd_enact() warn: set error code if 'arg.ret != 0' drivers/platform/x86/amd/pmf/tee-if.c:307 amd_pmf_invoke_cmd_init() warn: set error code if 'arg.ret != 0'
drivers/platform/x86/amd/pmf/tee-if.c
234 int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev)
235 {
236 struct ta_pmf_shared_memory *ta_sm = NULL;
237 struct ta_pmf_enact_result *out = NULL;
238 struct ta_pmf_enact_table *in = NULL;
239 struct tee_param param[MAX_TEE_PARAM];
240 struct tee_ioctl_invoke_arg arg;
241 int ret = 0;
242
243 if (!dev->tee_ctx)
244 return -ENODEV;
245
246 memset(dev->shbuf, 0, dev->policy_sz);
247 ta_sm = dev->shbuf;
248 out = &ta_sm->pmf_output.policy_apply_table;
249 in = &ta_sm->pmf_input.enact_table;
250
251 memset(ta_sm, 0, sizeof(*ta_sm));
252 ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES;
253 ta_sm->if_version = PMF_TA_IF_VERSION_MAJOR;
254
255 amd_pmf_populate_ta_inputs(dev, in);
256 amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES, &arg, param);
257
258 ret = tee_client_invoke_func(dev->tee_ctx, &arg, param);
259 if (ret < 0 || arg.ret != 0) {
260 dev_err(dev->dev, "TEE enact cmd failed. err: %x, ret:%d\n", arg.ret, ret);--> 261 return ret;
return ret ?: -EINVAL? (not sure what kind of error codes are stored in arg.ret).
262 }
263
264 if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) {
265 amd_pmf_dump_ta_inputs(dev, in);
266 dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count,
267 ta_sm->pmf_result);
268 amd_pmf_apply_policies(dev, out);
269 }
270
271 return 0;
272 }This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
Hi Dan,
I was OOO. Apologies for the long delay in responding back on this thread.
Quoted 39 lines · Dan Carpenter
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Hello Shyam Sundar S K,
Commit
ae82cef7d9c5("platform/x86/amd/pmf: Add support for PMF-TA interaction") from Dec 12, 2023 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/amd/pmf/tee-if.c:261amd_pmf_invoke_cmd_enact()warn: set error code if 'arg.ret != 0'drivers/platform/x86/amd/pmf/tee-if.c:307amd_pmf_invoke_cmd_init()warn: set error code if 'arg.ret != 0'
drivers/platform/x86/amd/pmf/tee-if.c234 int amd_pmf_invoke_cmd_enact(struct amd_pmf_dev *dev) 235 { 236 struct ta_pmf_shared_memory *ta_sm = NULL; 237 struct ta_pmf_enact_result *out = NULL; 238 struct ta_pmf_enact_table *in = NULL; 239 struct tee_param param[MAX_TEE_PARAM]; 240 struct tee_ioctl_invoke_arg arg; 241 int ret = 0; 242 243 if (!dev->tee_ctx) 244 return -ENODEV; 245 246 memset(dev->shbuf, 0, dev->policy_sz); 247 ta_sm = dev->shbuf; 248 out = &ta_sm->pmf_output.policy_apply_table; 249 in = &ta_sm->pmf_input.enact_table; 250 251 memset(ta_sm, 0, sizeof(*ta_sm)); 252 ta_sm->command_id = TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES; 253 ta_sm->if_version = PMF_TA_IF_VERSION_MAJOR; 254 255 amd_pmf_populate_ta_inputs(dev, in); 256 amd_pmf_prepare_args(dev, TA_PMF_COMMAND_POLICY_BUILDER_ENACT_POLICIES, &arg, param); 257 258 ret = tee_client_invoke_func(dev->tee_ctx, &arg, param); 259 if (ret < 0 || arg.ret != 0) { 260 dev_err(dev->dev, "TEE enact cmd failed. err: %x, ret:%d\n", arg.ret, ret);
Quoted 4 lines
--> 261 return ret;
return ret ?:
-EINVAL? (not sure what kind of error codes are stored in arg.ret).
Yes.
return ret ?: -EINVAL is the right thing to do in this case.
But I quickly ran the smatch and could not catch the problem what you is being reported. Can you let me know how to trigger this warning?
Thanks,
Shyam
Quoted 17 lines
262 } 263 264 if (ta_sm->pmf_result == TA_PMF_TYPE_SUCCESS && out->actions_count) { 265 amd_pmf_dump_ta_inputs(dev, in); 266 dev_dbg(dev->dev, "action count:%u result:%x\n", out->actions_count, 267 ta_sm->pmf_result); 268 amd_pmf_apply_policies(dev, out); 269 } 270 271 return 0; 272 }This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter