Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add all version run in a curcuit. #105

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 6 additions & 6 deletions tdx-compliance/tdx-compliance-cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,39 @@
struct test_cpuid *t; \
int bnr = _bit_nr; \
t = kzalloc(sizeof(struct test_cpuid), GFP_KERNEL); \
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg "[" #_bit_nr "]_";\
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg "[" #_bit_nr "]";\
t->version = _vsn; \
t->leaf = _leaf; \
t->subleaf = _subleaf; \
t->regs._reg.mask = BIT(bnr); \
t->regs._reg.expect = BIT(bnr) * (_val); \
list_add(&t->list, &cpuid_list); \
list_add_tail(&t->list, &cpuid_list); \
} while (0)

#define EXP_CPUID_BYTE(_leaf, _subleaf, _reg, _val, _vsn) do { \
struct test_cpuid *t; \
t = kzalloc(sizeof(struct test_cpuid), GFP_KERNEL); \
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg "_"; \
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg; \
t->version = _vsn; \
t->leaf = _leaf; \
t->subleaf = _subleaf; \
t->regs._reg.mask = 0xffffffff; \
t->regs._reg.expect = (_val); \
list_add(&t->list, &cpuid_list); \
list_add_tail(&t->list, &cpuid_list); \
} while (0)

#define EXP_CPUID_RES_BITS(_leaf, _subleaf, _reg, _bit_s, _bit_e, _vsn) do { \
int i = 0; \
struct test_cpuid *t; \
t = kzalloc(sizeof(struct test_cpuid), GFP_KERNEL); \
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg "[" #_bit_e ":" #_bit_s "]_";\
t->name = "CPUID(" #_leaf "," #_subleaf ")." #_reg "[" #_bit_e ":" #_bit_s "]";\
t->version = _vsn; \
t->leaf = _leaf; \
t->subleaf = _subleaf; \
for (i = _bit_s; i <= (_bit_e); i++) { \
t->regs._reg.mask |= BIT(i); \
} \
list_add(&t->list, &cpuid_list); \
list_add_tail(&t->list, &cpuid_list); \
} while (0)

void initial_cpuid(void)
Expand Down
2 changes: 1 addition & 1 deletion tdx-compliance/tdx-compliance-msr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define DEF_MSR(_name, _msr_num, _rw, _excp, _precond, _size, _vsn) \
{ \
.name = _name "_" #_rw "_", \
.name = _name "_" #_rw, \
.version = _vsn, \
.msr.msr_num = _msr_num, \
.run_msr_rw = _rw##_msr##_native, \
Expand Down
29 changes: 20 additions & 9 deletions tdx-compliance/tdx-compliance.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ static char *result_str(int ret)
return "UNKNOWN";
}

char *get_version(int version) {
if (version == 1)
return "_1.0";
else if (version == 2)
return "_1.5";
else if (version == 3)
return "_generic";
else
return "none";
}

static int check_results_msr(struct test_msr *t)
{
if (t->excp.expect == t->excp.val)
Expand Down Expand Up @@ -186,6 +197,7 @@ static int run_all_msr(void)
t->ret = check_results_msr(t);
t->ret == 1 ? stat_pass++ : stat_fail++;

version_name = get_version(t->version);
pr_buf("%d: %s%s:\t %s\n", ++stat_total, t->name, version_name,
result_str(t->ret));
}
Expand All @@ -208,6 +220,7 @@ static int check_results_cpuid(struct test_cpuid *t)
* Show the detail that resutls in the failure,
* CPUID here focus on the fixed bit, not actual cpuid val.
*/
version_name = get_version(t->version);
pr_buf("CPUID: %s%s\n", t->name, version_name);
pr_buf("CPUID :" CPUID_DUMP_PATTERN,
(t->regs.eax.val & t->regs.eax.mask), (t->regs.ebx.val & t->regs.ebx.mask),
Expand Down Expand Up @@ -255,6 +268,7 @@ static int run_all_cpuid(void)
else if (t->ret == -1)
stat_fail++;

version_name = get_version(t->version);
pr_buf("%d: %s%s:\t %s\n", ++stat_total, t->name, version_name, result_str(t->ret));
}
return 0;
Expand Down Expand Up @@ -365,15 +379,12 @@ tdx_tests_proc_write(struct file *file,
if (*(str_input + strlen(str_input) - 1) == '\n')
*(str_input + strlen(str_input) - 1) = '\0';

if (strstr(str_input, "1.0")) {
spec_version |= VER1_0;
version_name = "v1.0";
}
else if (strstr(str_input, "1.5")) {
spec_version |= VER1_5;
version_name = "v1.5";
}

if (strstr(str_input, "1.0"))
spec_version = VER1_0;
else if (strstr(str_input, "1.5"))
spec_version = VER1_5;
else
spec_version = (VER1_0 | VER1_5);

if (strstr(str_input, "cpuid"))
operation |= OPMASK_CPUID;
Expand Down
Loading