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
3 changes: 1 addition & 2 deletions BM/fred/fred_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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"
}

Expand Down
7 changes: 7 additions & 0 deletions BM/lam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ make
./lam -t <testcase_id>
(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
Expand All @@ -26,3 +32,4 @@ Test results (PASS or FAIL) will be printed out.
| 0x20 | inherit |
| 0x40 | pasid |
| 0x80 | cpuid |
| 0x100 | kconfig |
56 changes: 55 additions & 1 deletion BM/lam/lam.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <inttypes.h>
#include <sched.h>
#include <unistd.h>
#include <libgen.h>

#include <sys/uio.h>
#include <linux/io_uring.h>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions BM/lam/tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading