From da8fb93c27a71d4dbd5a2cdc30d6fec37d2b0a40 Mon Sep 17 00:00:00 2001 From: Farrah Chen Date: Tue, 23 Dec 2025 10:52:47 +0800 Subject: [PATCH 1/2] BM/FRED: Case improvement Check fred=on kernel cmdline only before dmesg and cpuinfo test. Cpuid test has no dependency on it. Remove duplicate cmdline check for cpuinfo. And fix a bug. Signed-off-by: Farrah Chen --- BM/fred/fred_test.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BM/fred/fred_test.sh b/BM/fred/fred_test.sh index ad3e7f7..419ce51 100755 --- a/BM/fred/fred_test.sh +++ b/BM/fred/fred_test.sh @@ -21,6 +21,7 @@ __EOF ###################### Functions ###################### # Check if FRED is enabled in Kernel config kconfig_test() { + local ret=0 general_test.sh -t kconfig -k "CONFIG_X86_FRED=y" || ret=1 [ $ret -eq 0 ] || die "CONFIG_X86_FRED=y is not set in Kconfig, FRED is not enabled" } @@ -45,7 +46,6 @@ dmesg_test() { # CPUID test: Check FRED CPUID cpuid_test() { - do_cmd "grep -q 'fred=on' '/proc/cmdline'" #CPUID.0x7.1.EAX[17] == 1 do_cmd "cpuid_check 7 0 1 0 a 17" } @@ -58,7 +58,6 @@ lkgs_cpuid_test() { # CPUINFO test: Check FRED cpu flag in cpu info cpuinfo_test() { - do_cmd "grep -q 'fred=on' '/proc/cmdline'" do_cmd "cpu_info_check fred" } From 42cb7ee7d347d4e7d3cb153d65b297ed5e050496 Mon Sep 17 00:00:00 2001 From: Farrah Chen Date: Tue, 23 Dec 2025 13:35:23 +0800 Subject: [PATCH 2/2] BM/lam: Add Kconfig test Signed-off-by: Farrah Chen --- BM/lam/README.md | 7 ++++++ BM/lam/lam.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++- BM/lam/tests | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/BM/lam/README.md b/BM/lam/README.md index 0ae3b16..3164d02 100644 --- a/BM/lam/README.md +++ b/BM/lam/README.md @@ -13,6 +13,12 @@ make ./lam -t (for example, cpuid) ./lam -t 0x80 ``` +You also can run the cases together with runtests command, e.g. + +``` +cd .. +./runtests -f lam/tests -o logfile +``` Test results (PASS or FAIL) will be printed out. ## Testcase ID @@ -26,3 +32,4 @@ Test results (PASS or FAIL) will be printed out. | 0x20 | inherit | | 0x40 | pasid | | 0x80 | cpuid | +| 0x100 | kconfig | diff --git a/BM/lam/lam.c b/BM/lam/lam.c index 5a7098e..7d5a324 100755 --- a/BM/lam/lam.c +++ b/BM/lam/lam.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -48,8 +49,9 @@ #define FUNC_INHERITE 0x20 #define FUNC_PASID 0x40 #define FUNC_CPUID 0x80 +#define FUNC_CONFIG 0x100 -#define TEST_MASK 0xff +#define TEST_MASK 0x1ff #define LOW_ADDR (0x1UL << 30) #define HIGH_ADDR (0x3UL << 48) @@ -842,6 +844,43 @@ int handle_cpuid(struct testcases *test) return ret; } +int handle_config(struct testcases *test) +{ + int ret = 0; + char command[256]; + char result[16]; + FILE *fp; + + /* Use shell script to check CONFIG_ADDRESS_MASKING */ + snprintf(command, sizeof(command), + "source %s/../common/common.sh; get_kconfig CONFIG_ADDRESS_MASKING", + dirname(realpath("/proc/self/exe", NULL))); + + fp = popen(command, "r"); + if (!fp) { + printf("Failed to execute shell command\n"); + return 1; + } + + if (fgets(result, sizeof(result), fp)) { + /* Remove newline */ + result[strcspn(result, "\n")] = 0; + if (strcmp(result, "y") == 0) { + printf("CONFIG_ADDRESS_MASKING=y is set\n"); + ret = 0; + } else { + printf("CONFIG_ADDRESS_MASKING is not set to 'y', value: %s\n", result); + ret = 1; + } + } else { + printf("Failed to read config value\n"); + ret = 1; + } + + pclose(fp); + return ret; +} + static void run_test(struct testcases *test, int count) { int i, ret = 0; @@ -1002,6 +1041,7 @@ static void cmd_help(void) printf("\t\t0x20:inherit;\n"); printf("\t\t0x40:pasid;\n"); printf("\t\t0x80:cpuid;\n"); + printf("\t\t0x100:config;\n"); printf("\t-h: help\n"); } @@ -1240,6 +1280,17 @@ static struct testcases cpuid_cases[] = { }, }; +/* config_cases + * kernel config checking. + */ +static struct testcases config_cases[] = { + { + .expected = 0, + .test_func = handle_config, + .msg = "CONFIG: CONFIG_ADDRESS_MASKING\n", + }, +}; + int main(int argc, char **argv) { int c = 0; @@ -1305,6 +1356,9 @@ int main(int argc, char **argv) if (tests & FUNC_CPUID) run_test(cpuid_cases, ARRAY_SIZE(cpuid_cases)); + if (tests & FUNC_CONFIG) + run_test(config_cases, ARRAY_SIZE(config_cases)); + printf("Total tests: %d; Pass:%d\n", tests_cnt, tests_pass); return (tests_cnt - tests_pass); diff --git a/BM/lam/tests b/BM/lam/tests index 59cc39c..22b19ff 100644 --- a/BM/lam/tests +++ b/BM/lam/tests @@ -7,3 +7,4 @@ lam -t 0x10 # io_uring lam -t 0x20 # inherit lam -t 0x40 # pasid lam -t 0x80 # cpuid +lam -t 0x100 # kconfig