Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ if(DEFINED ACS_VERBOSE_LEVEL)
endif()
endif()

option(ACS_RULE_CACHE "Reuse completed base-rule results within a baremetal run" OFF)
if(ACS_RULE_CACHE)
add_compile_definitions(ACS_RULE_CACHE=1)
endif()

# Propagate ACS_LEVEL into compiler definitions for all sources.
# This selects the compliance level for the active ACS suite at compile
# time, overriding the PLATFORM_OVERRIDE_<ACS>_LEVEL value supplied by
Expand Down Expand Up @@ -189,6 +194,7 @@ list(APPEND CLEAN_LIST

# Optional forwarding of ACS_ENABLED_MODULE_LIST to inner configure
set(DEFAULT_OVERRIDE_ARGS "")
list(APPEND DEFAULT_OVERRIDE_ARGS -DACS_RULE_CACHE=${ACS_RULE_CACHE})
if(DEFINED CROSS_COMPILE AND NOT "${CROSS_COMPILE}" STREQUAL "")
message(STATUS "[ACS] : CROSS_COMPILE (top-level) = ${CROSS_COMPILE}")
list(APPEND DEFAULT_OVERRIDE_ARGS -DCROSS_COMPILE=${CROSS_COMPILE})
Expand Down
6 changes: 6 additions & 0 deletions apps/baremetal/acs_runtime_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ acs_load_execution_policy_defaults(acs_execution_policy_t *policy)
policy->crypto_support = defaults->crypto_support;
policy->sys_last_lvl_cache = defaults->sys_last_lvl_cache;
policy->el1skiptrap_mask = defaults->el1skiptrap_mask;
policy->rule_cache_enabled = defaults->rule_cache_enabled;
}

platform_defaults = acs_get_platform_execution_policy_defaults();
Expand All @@ -185,6 +186,7 @@ acs_load_execution_policy_defaults(acs_execution_policy_t *policy)
policy->crypto_support = platform_defaults->crypto_support;
policy->sys_last_lvl_cache = platform_defaults->sys_last_lvl_cache;
policy->el1skiptrap_mask = platform_defaults->el1skiptrap_mask;
policy->rule_cache_enabled = platform_defaults->rule_cache_enabled;

if (platform_defaults->timeout_pass != 0u)
policy->timeout_pass = platform_defaults->timeout_pass;
Expand Down Expand Up @@ -408,6 +410,10 @@ acs_apply_compile_params(acs_run_request_t *ctx, acs_execution_policy_t *policy)
ctx->execute_modules_owned = false;
#endif

#if defined(ACS_RULE_CACHE) && ACS_RULE_CACHE
policy->rule_cache_enabled = true;
#endif

#ifdef ACS_VERBOSE_LEVEL
/*
* Allow compile-time override of the default print verbosity.
Expand Down
2 changes: 2 additions & 0 deletions apps/uefi/acs_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ command_init (void)
if (has_os) ctx->bsa_sw_view_mask |= (1u << SW_OS);
if (has_ps) ctx->bsa_sw_view_mask |= (1u << SW_PS);

policy->rule_cache_enabled = ShellCommandLineGetFlag(ParamPackage, L"-rule-cache");

/* Parse -skip CLI */
if (ShellCommandLineGetFlag (ParamPackage, L"-skip")) {
CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-skip");
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/bsa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-p2p", TypeFlag},
{L"-ps", TypeFlag},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skip-dp-nic-ms", TypeFlag},
{L"-skipmodule", TypeValue},
Expand Down Expand Up @@ -92,6 +93,8 @@ HelpMsg (VOID)
" Examples: -r B_PE_01,B_PE_02,B_GIC_01\n"
" -r rules.txt (file may mix commas/newlines; lines \n"
" starting with # are comments)\n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-skip Rule ID(s) to be skipped (comma-separated, like -r)\n"
" Example: -skip B_PE_01,B_GIC_02\n"
"-skip-dp-nic-ms \n"
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/mpam_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ HelpMsg (
" Accepted values: CACHE, REG, ERROR, MBWU\n"
"-r Run tests for passed comma-separated SYS-MPAM rule IDs or a rules file\n"
" Example: -r RBDJXQ\n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-skip SYS-MPAM rule ID(s) to be skipped (comma-separated, like -r)\n"
"-skipmodule\n"
" Skip the specified modules (comma-separated names).\n"
Expand All @@ -123,6 +125,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-l", TypeValue},
{L"-m", TypeValue},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skipmodule", TypeValue},
{L"-v", TypeValue},
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/pc_bsa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-only", TypeValue},
{L"-p2p", TypeFlag},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skip-dp-nic-ms", TypeFlag},
{L"-skipmodule", TypeValue},
Expand Down Expand Up @@ -76,6 +77,8 @@ HelpMsg (VOID)
" starting with # are comments)\n"
"-only <n> \n"
" Only run tests for rules at level <n> \n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-skip Rule ID(s) to be skipped (comma-separated, like -r)\n"
" Example: -skip B_PE_01,B_GIC_02\n"
"-skip-dp-nic-ms \n"
Expand Down
2 changes: 2 additions & 0 deletions apps/uefi/pfdi_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ HelpMsg (
"-h, -help Print this message\n"
"-m <list> Run only the specified modules (comma-separated names)\n"
"-r <rules> Run specified rule IDs (comma-separated) or a rules file\n"
"-rule-cache Reuse completed base-rule results within this run (opt-in)\n"
"-skip <rules>\n"
" Skip the specified rule IDs\n"
" Accepted value: PFDI\n"
Expand All @@ -52,6 +53,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-help", TypeFlag},
{L"-m", TypeValue},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skipmodule", TypeValue},
{L"-v", TypeValue},
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/sbsa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-only", TypeValue},
{L"-p2p", TypeFlag},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skip-dp-nic-ms", TypeFlag},
{L"-skipmodule", TypeValue},
Expand Down Expand Up @@ -83,6 +84,8 @@ HelpMsg (VOID)
" Examples: -r B_PE_01,B_PE_02,B_GIC_01\n"
" -r rules.txt (file may mix commas/newlines; lines \n"
" starting with # are comments)\n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-skip Rule ID(s) to be skipped (comma-separated, like -r)\n"
" Example: -skip B_PE_01,B_GIC_02\n"
"-skip-dp-nic-ms \n"
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/vbsa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-only", TypeValue},
{L"-p2p", TypeFlag},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skip-dp-nic-ms", TypeFlag},
{L"-skipmodule", TypeValue},
Expand Down Expand Up @@ -82,6 +83,8 @@ HelpMsg (VOID)
" Examples: -r B_PE_01,B_PE_02,B_GIC_01\n"
" -r rules.txt (file may mix commas/newlines; lines \n"
" starting with # are comments)\n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-skip Rule ID(s) to be skipped (comma-separated, like -r)\n"
" Example: -skip B_PE_01,B_GIC_02\n"
"-skip-dp-nic-ms \n"
Expand Down
3 changes: 3 additions & 0 deletions apps/uefi/xbsa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-p2p", TypeFlag},
{L"-ps", TypeFlag},
{L"-r", TypeValue},
{L"-rule-cache", TypeFlag},
{L"-skip", TypeValue},
{L"-skip-dp-nic-ms", TypeFlag},
{L"-skipmodule", TypeValue},
Expand Down Expand Up @@ -110,6 +111,8 @@ HelpMsg (VOID)
" Examples: -r B_PE_01,B_PE_02,B_GIC_01\n"
" -r rules.txt (file may mix commas/newlines; lines \n"
" starting with # are comments)\n"
"-rule-cache\n"
" Reuse completed base-rule results within this run (opt-in).\n"
"-slc Provide system last level cache type\n"
" 1 - PPTT PE-side cache, 2 - HMAT mem-side cache\n"
"-skip Rule ID(s) to be skipped (comma-separated, like -r)\n"
Expand Down
21 changes: 21 additions & 0 deletions docs/common/cli_args.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,34 @@ semantics so individual READMEs can simply reference it.
| `-os`, `-hyp`, `-ps` | BSA | Software-view filters; combine the flags to restrict execution to OS, hypervisor, or platform-security content. |
| `-p2p` | All | Indicate that the PCIe hierarchy supports peer-to-peer transactions so related checks run. |
| `-r <rules\|file>` | All | Run only the supplied rule IDs or the IDs provided in a file (same format as `-skip`). |
| `-rule-cache` | Rule-based UEFI apps | Opt in to reuse of completed base-rule results within the current run. Reused results remain reported with a `(cached)` marker. |
| `-skip <rules\|file>` | All | Skip the listed rule IDs (comma-separated) or load IDs from a text file (comments start with `#`; commas/newlines are accepted). |
| `-skip-dp-nic-ms` | All | Skip PCIe exerciser coverage for DisplayPort, network, and mass-storage devices when those endpoints are unavailable. |
| `-skipmodule <modules>` | All | Exclude the listed modules from the run (for example, `-skipmodule PE,GIC`). |
| `-slc <type>` | SBSA | Provide the system last-level cache implementation (`1` for PPTT PE-side cache, `2` for HMAT memory-side cache). |
| `-timeout <microseconds>` | All | Set pass timeout (delay in microseconds) for wakeup and watchdog and & timer tests (1ms = wakeup & WD default , 1sec = timer default, 500us = minimum, 2sec = maximum delay). |
| `-v <level>` | All | Set verbosity: 5=ERROR, 4=WARN, 3=TEST, 2=DEBUG, 1=INFO. |

## Opt-in rule result reuse

`-rule-cache` reuses a completed result only for the same base-rule ID within
one suite invocation. Each run resets the result map, including when a later
run changes the PE count or rule selections. This cache does not merge different
rule IDs that share a test entry, and unknown results are not reused.
Rules whose tests depend on the parent rule are marked
`.cache_policy = RULE_CACHE_RERUN` in `val/src/rule_metadata.c` and always run again.
Aliases still traverse and report their children, so
skip filtering, aggregation and cycle/depth checks remain active.

The option is off by default. It skips repeat execution, including test side
effects; use it only when once-per-run execution is appropriate for the selected
rules. Omit it when investigating order-dependent or repeat-execution behavior.
This option does not change the existing SYS-MPAM test-entry cache.

Baremetal builds can opt in with `cmake --preset sbsa -DACS_RULE_CACHE=ON`.
Non-CMake integrations can set the execution policy's `rule_cache_enabled`
field before calling `run_tests()`.

Refer to each specification README for other variant-level constraints, rule
prefix conventions, and concrete invocation examples tailored to that ACS
target.
Expand Down
3 changes: 3 additions & 0 deletions val/include/acs_execution_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* - wakeup/watchdog/timer timeout controls
* - crypto-extension and EL1 trap workarounds
* - system last-level cache hinting
* - opt-in per-run base-rule result reuse
*/
typedef struct acs_execution_policy {
uint32_t pcie_p2p;
Expand All @@ -54,6 +55,7 @@ typedef struct acs_execution_policy {
* not safely expose them. Compose with EL1SKIPTRAP_* flags.
*/
uint32_t el1skiptrap_mask;
bool rule_cache_enabled;
} acs_execution_policy_t;

void acs_reset_execution_policy(void);
Expand All @@ -72,5 +74,6 @@ uint32_t acs_policy_get_timer_timeout_us(void);
uint32_t acs_policy_get_crypto_support(void);
uint32_t acs_policy_get_sys_last_lvl_cache(void);
uint32_t acs_policy_get_el1skiptrap_mask(void);
bool acs_policy_get_rule_cache_enabled(void);

#endif /* __ACS_EXECUTION_POLICY_H__ */
1 change: 1 addition & 0 deletions val/include/rule_based_execution.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef struct {
TEST_ENTRY_ID_e test_entry_id;
MODULE_NAME_e module_id; /* Module to which this test belongs */
RULE_FLAG_e flag;
RULE_CACHE_POLICY_e cache_policy;
uint32_t test_num;
char8_t platform_bitmask;
char8_t rule_desc[RULE_DESC_SIZE];
Expand Down
6 changes: 6 additions & 0 deletions val/include/rule_based_execution_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,12 @@ typedef enum {
ALIAS_RULE
} RULE_FLAG_e;

/* Result reuse policy for a base rule in rule_test_map_t (used with rule caching) */
typedef enum {
RULE_CACHE_REUSE = 0, /* Default: a completed result may be reused in this run */
RULE_CACHE_RERUN /* Test selection depends on the parent rule; always rerun */
} RULE_CACHE_POLICY_e;

/* SBSA levels enum */
typedef enum {
SBSA_LEVEL_3 = 3,
Expand Down
5 changes: 5 additions & 0 deletions val/src/acs_execution_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,8 @@ uint32_t acs_policy_get_el1skiptrap_mask(void)
{
return g_execution_policy.el1skiptrap_mask;
}

bool acs_policy_get_rule_cache_enabled(void)
{
return g_execution_policy.rule_cache_enabled;
}
25 changes: 22 additions & 3 deletions val/src/rule_based_orchestrator.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "val_interface.h"
#include "acs_pe.h"
#include "acs_memory.h"
#include "acs_execution_policy.h"

extern uint8_t g_current_pal;
extern rule_test_map_t rule_test_map[RULE_ID_SENTINEL];
Expand Down Expand Up @@ -173,14 +174,16 @@ static void print_alias_walk_banner(RULE_ID_e rule_id, uint32_t indent, bool sta
* @param indent Indentation for child rule logging.
* @param num_pe Number of PEs in the system.
* @param report_self True if this invocation should print its own start/end.
* @param reuse_results Reuse completed base-rule results from this run.
*
* @return Rule execution status.
*/
static uint32_t execute_rule_recursive(const acs_run_request_t *ctx,
RULE_ID_e rule_id,
uint32_t indent,
uint32_t num_pe,
bool report_self)
bool report_self,
bool reuse_results)
{
bool test_ns_flag;
bool test_pass_flag;
Expand Down Expand Up @@ -232,6 +235,18 @@ static uint32_t execute_rule_recursive(const acs_run_request_t *ctx,
}
}

/* Aliases must still walk their children, including cycle/depth checks. */
if (reuse_results && rule_test_map[rule_id].flag == BASE_RULE &&
rule_test_map[rule_id].cache_policy == RULE_CACHE_REUSE &&
rule_status_map[rule_id] != TEST_STATE_UNKNOWN) {
rule_test_status = rule_status_map[rule_id];
old_log_indent = val_log_get_indent();
val_log_set_indent(indent);
val_print(INFO, "\n Reusing rule result from this run (cached)");
val_log_set_indent(old_log_indent);
goto exit_rule;
}

if (rule_test_map[rule_id].flag == ALIAS_RULE) {
alias_rule_map_index = alias_rule_map_get_index(rule_id);
if (alias_rule_map_index == INVALID_IDX) {
Expand Down Expand Up @@ -287,7 +302,8 @@ static uint32_t execute_rule_recursive(const acs_run_request_t *ctx,

/* Always recurse with indent == 1 for descendants. This keeps logs
readable while still showing child and intermediate alias nodes. */
child_rule_status = execute_rule_recursive(ctx, child_rule_id, 1, num_pe, 1);
child_rule_status = execute_rule_recursive(ctx, child_rule_id, 1, num_pe, 1,
reuse_results);

#ifdef TARGET_LINUX
if (child_rule_status == TEST_STATE_UNKNOWN) {
Expand Down Expand Up @@ -667,6 +683,7 @@ run_tests(const acs_run_request_t *ctx)
uint32_t num_pe;
RULE_ID_e *rule_list;
uint32_t list_size;
bool reuse_results;

if (ctx == NULL || ctx->rule_list == NULL || ctx->rule_count == 0)
return;
Expand All @@ -681,6 +698,7 @@ run_tests(const acs_run_request_t *ctx)
test_entry_status_cache_enable(ctx->arch_selection == ARCH_SYS_MPAM);
/* Initialize per-test-entry status map to TEST_STATUS_UNKNOWN for this run */
test_entry_status_map_reset();
reuse_results = acs_policy_get_rule_cache_enabled();

/* Get number of PEs in the system */
num_pe = val_pe_get_num();
Expand Down Expand Up @@ -710,7 +728,8 @@ run_tests(const acs_run_request_t *ctx)
goto report_status;
}

rule_test_status = execute_rule_recursive(ctx, rule_list[i], 0, num_pe, 0);
rule_test_status = execute_rule_recursive(ctx, rule_list[i], 0, num_pe, 0,
reuse_results);
report_status:
/* Record and print overall rule status */
rule_status_map[rule_list[i]] = rule_test_status;
Expand Down
Loading
Loading