* [bug report] kselftest/arm64: Add utilities and a test to validate mte memory
@ 2022-07-18 14:47 Dan Carpenter
2022-07-19 12:44 ` Amit Kachhap
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-07-18 14:47 UTC (permalink / raw)
To: amit.kachhap; +Cc: linux-kselftest
Hello Amit Daniel Kachhap,
The patch e9b60476bea0: "kselftest/arm64: Add utilities and a test to
validate mte memory" from Oct 2, 2020, leads to the following Smatch
static checker warning:
./tools/testing/selftests/arm64/mte/mte_common_util.c:336 mte_default_setup()
warn: bitwise AND condition is false here
./tools/testing/selftests/arm64/mte/mte_common_util.c
316 int mte_default_setup(void)
317 {
318 unsigned long hwcaps2 = getauxval(AT_HWCAP2);
319 unsigned long en = 0;
320 int ret;
321
322 if (!(hwcaps2 & HWCAP2_MTE)) {
323 ksft_print_msg("SKIP: MTE features unavailable\n");
324 return KSFT_SKIP;
325 }
326 /* Get current mte mode */
327 ret = prctl(PR_GET_TAGGED_ADDR_CTRL, en, 0, 0, 0);
328 if (ret < 0) {
329 ksft_print_msg("FAIL:prctl PR_GET_TAGGED_ADDR_CTRL with error =%d\n", ret);
330 return KSFT_FAIL;
331 }
332 if (ret & PR_MTE_TCF_SYNC)
333 mte_cur_mode = MTE_SYNC_ERR;
334 else if (ret & PR_MTE_TCF_ASYNC)
335 mte_cur_mode = MTE_ASYNC_ERR;
--> 336 else if (ret & PR_MTE_TCF_NONE)
It looks like the intent was to make PR_MTE_TCF_NONE into an ifdef
configurable thing but that never happened?
337 mte_cur_mode = MTE_NONE_ERR;
338
339 mte_cur_pstate_tco = mte_get_pstate_tco();
340 /* Disable PSTATE.TCO */
341 mte_disable_pstate_tco();
342 return 0;
343 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [bug report] kselftest/arm64: Add utilities and a test to validate mte memory
2022-07-18 14:47 [bug report] kselftest/arm64: Add utilities and a test to validate mte memory Dan Carpenter
@ 2022-07-19 12:44 ` Amit Kachhap
0 siblings, 0 replies; 2+ messages in thread
From: Amit Kachhap @ 2022-07-19 12:44 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-kselftest
Hi,
On 7/18/22 20:17, Dan Carpenter wrote:
> Hello Amit Daniel Kachhap,
>
> The patch e9b60476bea0: "kselftest/arm64: Add utilities and a test to
> validate mte memory" from Oct 2, 2020, leads to the following Smatch
> static checker warning:
>
> ./tools/testing/selftests/arm64/mte/mte_common_util.c:336 mte_default_setup()
> warn: bitwise AND condition is false here
>
> ./tools/testing/selftests/arm64/mte/mte_common_util.c
> 316 int mte_default_setup(void)
> 317 {
> 318 unsigned long hwcaps2 = getauxval(AT_HWCAP2);
> 319 unsigned long en = 0;
> 320 int ret;
> 321
> 322 if (!(hwcaps2 & HWCAP2_MTE)) {
> 323 ksft_print_msg("SKIP: MTE features unavailable\n");
> 324 return KSFT_SKIP;
> 325 }
> 326 /* Get current mte mode */
> 327 ret = prctl(PR_GET_TAGGED_ADDR_CTRL, en, 0, 0, 0);
> 328 if (ret < 0) {
> 329 ksft_print_msg("FAIL:prctl PR_GET_TAGGED_ADDR_CTRL with error =%d\n", ret);
> 330 return KSFT_FAIL;
> 331 }
> 332 if (ret & PR_MTE_TCF_SYNC)
> 333 mte_cur_mode = MTE_SYNC_ERR;
> 334 else if (ret & PR_MTE_TCF_ASYNC)
> 335 mte_cur_mode = MTE_ASYNC_ERR;
> --> 336 else if (ret & PR_MTE_TCF_NONE)
>
> It looks like the intent was to make PR_MTE_TCF_NONE into an ifdef
> configurable thing but that never happened?
Thanks for pointing this out. I will send the proper fix with
the Reported bys .
Regards,
Amit
>
> 337 mte_cur_mode = MTE_NONE_ERR;
> 338
> 339 mte_cur_pstate_tco = mte_get_pstate_tco();
> 340 /* Disable PSTATE.TCO */
> 341 mte_disable_pstate_tco();
> 342 return 0;
> 343 }
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-19 13:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 14:47 [bug report] kselftest/arm64: Add utilities and a test to validate mte memory Dan Carpenter
2022-07-19 12:44 ` Amit Kachhap
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.