Skip to content

Commit 44a025f

Browse files
committed
Fix: Add limit check for level in el3 parameter
- Add limit check for level in el3 parameter ensuring it executes FR level when unintended value is provided Signed-off-by: sapthagiri padmanabhan <sapthagiri.padmanabhan@arm.com> Change-Id: I21d2a90b591b033219b487a00b9dd073b4905993
1 parent f9132cb commit 44a025f

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

apps/baremetal/acs_runtime_init.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,35 @@ acs_list_contains(const uint32_t *list, uint32_t count, uint32_t value)
5151
return false;
5252
}
5353

54+
static uint32_t
55+
acs_clamp_level_for_arch(uint32_t requested_level)
56+
{
57+
uint32_t min_level = 0;
58+
uint32_t max_level = 0;
59+
60+
#if defined(BSA)
61+
min_level = BSA_MIN_LEVEL_SUPPORTED;
62+
max_level = (uint32_t)BSA_LEVEL_FR;
63+
#elif defined(SBSA)
64+
min_level = SBSA_MIN_LEVEL_SUPPORTED;
65+
max_level = (uint32_t)SBSA_LEVEL_FR;
66+
#elif defined(PC_BSA)
67+
min_level = PCBSA_MIN_LEVEL_SUPPORTED;
68+
max_level = (uint32_t)PCBSA_LEVEL_FR;
69+
#else
70+
return requested_level;
71+
#endif
72+
73+
if (requested_level < min_level || requested_level > max_level) {
74+
val_print(WARN,
75+
"ACS Level (EL3 parameter) %d is not supported maxing it to level FR\n",
76+
requested_level);
77+
return max_level;
78+
}
79+
80+
return requested_level;
81+
}
82+
5483
bool
5584
acs_is_module_enabled(uint32_t module_base)
5685
{
@@ -260,7 +289,7 @@ acs_apply_el3_params(acs_run_request_t *ctx, acs_execution_policy_t *policy)
260289
ctx->bsa_sw_view_mask = params->software_view_filter;
261290
policy->pcie_cache_present = params->cache;
262291
policy->sys_last_lvl_cache = params->sys_cache;
263-
ctx->level_value = params->level;
292+
ctx->level_value = acs_clamp_level_for_arch((uint32_t)params->level);
264293

265294
if (params->level_selection >= LVL_FILTER_NONE &&
266295
params->level_selection <= LVL_FILTER_FR)

val/include/acs_app_defs.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636
#define PCBSA_MAX_LEVEL_SUPPORTED 1
3737

3838
#define LEVEL_PRINT_FORMAT(level, filter_mode, fr_level) ((filter_mode == LVL_FILTER_FR) ? \
39-
((filter_mode == LVL_FILTER_ONLY && level == fr_level) ? \
40-
"\n Starting tests for only level FR " : "\n Starting tests for level FR ") : \
39+
"\n Starting tests for level FR " : \
4140
((filter_mode == LVL_FILTER_ONLY) ? \
42-
"\n Starting tests for only level %2d " : "\n Starting tests for level %2d "))
41+
((level == fr_level) ? "\n Starting tests for only level FR " \
42+
: "\n Starting tests for only level %2d ") : \
43+
((level == fr_level) ? "\n Starting tests for level FR " : "\n Starting tests for level %2d ")))
4344

4445
#endif /* __ACS_APP_DEFS_H__ */

0 commit comments

Comments
 (0)