diff --git a/tdx-compliance/tdx-compliance.c b/tdx-compliance/tdx-compliance.c index 4e26930e..fd7e1b2b 100644 --- a/tdx-compliance/tdx-compliance.c +++ b/tdx-compliance/tdx-compliance.c @@ -58,6 +58,7 @@ LIST_HEAD(cpuid_list); #define OPMASK_CPUID 1 #define OPMASK_CR 2 #define OPMASK_MSR 4 +#define OPMASK_DUMP 0x800 #define OPMASK_SINGLE 0x8000 #define CPUID_DUMP_PATTERN \ @@ -87,6 +88,17 @@ void parse_version(void) spec_version = (VER1_0 | VER1_5); } +static char* case_version(int ret) { + switch (ret) { + case VER1_0: + return "1.0"; + case VER1_5: + return "1.5"; + } + + return ""; +} + void parse_input(char* s) { memset(case_name, 0, sizeof(case_name)); @@ -206,6 +218,10 @@ static int run_all_msr(void) for (i = 0; i < ARRAY_SIZE(msr_cases); i++, t++) { if (operation & 0x8000 && strcmp(case_name, t->name) != 0) continue; + else if (operation & 0x800 && spec_version & t->version) { + pr_buf("%s %s\n", t->name, case_version(t->version)); + continue; + } if (!(spec_version & t->version)) continue; @@ -275,6 +291,10 @@ static int run_all_cpuid(void) if (operation & 0x8000 && strcmp(case_name, t->name) != 0) continue; + else if (operation & 0x800 && spec_version & t->version) { + pr_buf("%s %s\n", t->name, case_version(t->version)); + continue; + } if (!(spec_version & t->version)) continue; @@ -346,6 +366,10 @@ static int run_all_cr(void) for (i = 0; i < ARRAY_SIZE(cr_list); i++, t++) { if (operation & 0x8000 && strcmp(case_name, t->name) != 0) continue; + else if (operation & 0x800 && spec_version & t->version) { + pr_buf("%s %s\n", t->name, case_version(t->version)); + continue; + } if (!(spec_version & t->version)) continue; @@ -409,6 +433,8 @@ tdx_tests_proc_write(struct file *file, operation |= OPMASK_MSR; else if (strstr(case_name, "all")) operation |= OPMASK_CPUID | OPMASK_CR | OPMASK_MSR; + else if (strstr(case_name, "list")) + operation |= OPMASK_DUMP | OPMASK_CPUID | OPMASK_CR | OPMASK_MSR; else operation |= OPMASK_SINGLE | OPMASK_CPUID | OPMASK_CR | OPMASK_MSR; @@ -426,9 +452,10 @@ tdx_tests_proc_write(struct file *file, if (operation & OPMASK_MSR) run_all_msr(); - pr_buf("Total:%d, PASS:%d, FAIL:%d, SKIP:%d\n", - stat_total, stat_pass, stat_fail, - stat_total - stat_pass - stat_fail); + if (!(operation & OPMASK_DUMP)) + pr_buf("Total:%d, PASS:%d, FAIL:%d, SKIP:%d\n", + stat_total, stat_pass, stat_fail, + stat_total - stat_pass - stat_fail); kfree(str_input); operation = 0;