report is nice, use it more
Subsystems (3)
cover report is nice, use it more
This series applies report() to more x86 unit tests. It also cleans up some uses of it in vmx_tests. Finally, it also introduces report prefix support, and applies that a few places. There should be no functional changes with this series, except of course the output formatting (which makes the churn debatable). Anyway, I believe this series helps us to start converging on a "standard" output format for all unit tests.
I'm afraid I didn't test all the changes, as not all unit tests could run on my test machine.
svm - didn't run
xsave - didn't run 'have xsave' tests
asyncpf - is commented out of unittests.cfg,
and I didn't uncomment it out
pmu - didn't run
(I probably should add a bunch of kvm-unit-tests contributors to
the CC in order to alert them that I'm touching their unit tests, but I don't think this series warrants all the git blaming, so I'm not adding anybody at all :-)
Andrew Jones (10):
x86: hypercall: add missing report_summary
x86: pmu: report takes a fmt
x86: vmx: better use of report
x86: tsc_adjust: use report
x86: svm: use report
x86: asyncpf: use report
x86: xsave: use report
report: add prefix support
x86: use report prefixes
arm: use report prefixes
arm/selftest.c | 31 ++++----- lib/libcflat.h | 2 + lib/report.c | 22 ++++++ lib/string.c | 17 +++++ lib/string.h | 1 + x86/apic.c | 8 ++- x86/asyncpf.c | 15 ++-- x86/hypercall.c | 2 +- x86/pmu.c | 28 +++++--- x86/svm.c | 25 +++---- x86/tsc_adjust.c | 44 ++++-------- x86/vmx_tests.c | 204 +++++++++++++------------------------------------------ x86/xsave.c | 150 +++++++++++++++------------------------- 13 files changed, 210 insertions(+), 339 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/10 x86: hypercall: add missing report_summary
--- x86/hypercall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
x86/hypercall.c +1 -1
@@ -76,5 +76,5 @@ int main(int ac, char **av)report ("VMMCALL on edge of canonical address space (AMD)" ,test_edge ());#endif -return 0 ; +return report_summary (); }
Signature · 1 line
1.9.3
PATCH 2/10 x86: pmu: report takes a fmt
In reply to Andrew Jones--- x86/pmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
x86/pmu.c +1 -3
@@ -228,14 +228,12 @@ static void check_gp_counter(struct pmu_event *evt) .ctr = MSR_IA32_PERFCTR0, .config = EVNTSEL_OS | EVNTSEL_USR | evt->unit_sel, }; -char fmt[100 ];int i;for (i =0 ; i < num_counters; i++, cnt.ctr++) { cnt.count =0 ;measure (&cnt,1 ); -snprintf (fmt,sizeof (fmt),"%s-%%d" , evt->name); -report (fmt,verify_event (cnt.count, evt), i); +report ("%s-%%d" ,verify_event (cnt.count, evt), evt->name, i); } }
Signature · 1 line
1.9.3
PATCH 3/10 x86: vmx: better use of report
In reply to Andrew Jones--- x86/vmx_tests.c | 204 ++++++++++++++------------------------------------------ 1 file changed, 49 insertions(+), 155 deletions(-)
x86/vmx_tests.c +49 -155
@@ -271,13 +271,8 @@ static void test_ctrl_pat_main()wrmsr (MSR_IA32_CR_PAT ,0x6 );vmcall (); guest_ia32_pat =rdmsr (MSR_IA32_CR_PAT ); -if (ctrl_enter_rev.clr &ENT_LOAD_PAT ) { -if (guest_ia32_pat != ia32_pat) { -report ("Entry load PAT" ,0 ); -return ; - } -report ("Entry load PAT" ,1 ); - } +if (ctrl_enter_rev.clr &ENT_LOAD_PAT ) +report ("Entry load PAT" , guest_ia32_pat == ia32_pat); }static int test_ctrl_pat_exit_handler ()
@@ -295,19 +290,12 @@ static int test_ctrl_pat_exit_handler()printf ("\tEXI_SAVE_PAT is not supported\n" );vmcs_write (GUEST_PAT ,0x6 ); }else { -if (guest_pat ==0x6 ) -report ("Exit save PAT" ,1 ); -else -report ("Exit save PAT" ,0 ); +report ("Exit save PAT" , guest_pat ==0x6 ); }if (!(ctrl_exit_rev.clr &EXI_LOAD_PAT ))printf ("\tEXI_LOAD_PAT is not supported\n" ); -else { -if (rdmsr (MSR_IA32_CR_PAT ) == ia32_pat) -report ("Exit load PAT" ,1 ); -else -report ("Exit load PAT" ,0 ); - } +else +report ("Exit load PAT" ,rdmsr (MSR_IA32_CR_PAT ) == ia32_pat);vmcs_write (GUEST_PAT , ia32_pat);vmcs_write (GUEST_RIP , guest_rip +3 );return VMX_TEST_RESUME ;
@@ -350,13 +338,8 @@ static void test_ctrl_efer_main()wrmsr (MSR_EFER , ia32_efer);vmcall (); guest_ia32_efer =rdmsr (MSR_EFER ); -if (ctrl_enter_rev.clr &ENT_LOAD_EFER ) { -if (guest_ia32_efer != ia32_efer) { -report ("Entry load EFER" ,0 ); -return ; - } -report ("Entry load EFER" ,1 ); - } +if (ctrl_enter_rev.clr &ENT_LOAD_EFER ) +report ("Entry load EFER" , guest_ia32_efer == ia32_efer); }static int test_ctrl_efer_exit_handler ()
@@ -374,19 +357,13 @@ static int test_ctrl_efer_exit_handler()printf ("\tEXI_SAVE_EFER is not supported\n" );vmcs_write (GUEST_EFER , ia32_efer); }else { -if (guest_efer == ia32_efer) -report ("Exit save EFER" ,1 ); -else -report ("Exit save EFER" ,0 ); +report ("Exit save EFER" , guest_efer == ia32_efer); }if (!(ctrl_exit_rev.clr &EXI_LOAD_EFER )) {printf ("\tEXI_LOAD_EFER is not supported\n" );wrmsr (MSR_EFER , ia32_efer ^EFER_NX ); }else { -if (rdmsr (MSR_EFER ) == (ia32_efer ^EFER_NX )) -report ("Exit load EFER" ,1 ); -else -report ("Exit load EFER" ,0 ); +report ("Exit load EFER" ,rdmsr (MSR_EFER ) == (ia32_efer ^EFER_NX )); }vmcs_write (GUEST_PAT , ia32_efer);vmcs_write (GUEST_RIP , guest_rip +3 );
@@ -436,20 +413,12 @@ static void cr_shadowing_main()vmx_set_test_stage (4 );vmcall (); cr0 =read_cr0 (); -if (vmx_get_test_stage () !=5 ) { -if (cr0 == guest_cr0) -report ("Read shadowing CR0" ,1 ); -else -report ("Read shadowing CR0" ,0 ); - } +if (vmx_get_test_stage () !=5 ) +report ("Read shadowing CR0" , cr0 == guest_cr0);vmx_set_test_stage (5 ); cr4 =read_cr4 (); -if (vmx_get_test_stage () !=6 ) { -if (cr4 == guest_cr4) -report ("Read shadowing CR4" ,1 ); -else -report ("Read shadowing CR4" ,0 ); - } +if (vmx_get_test_stage () !=6 ) +report ("Read shadowing CR4" , cr4 == guest_cr4);// Test write shadow (same value with shadow) vmx_set_test_stage (6 );write_cr0 (guest_cr0);
@@ -470,40 +439,28 @@ static void cr_shadowing_main() "mov %%rsi, %%cr0\n\t" ::"m"(tmp) :"rsi", "memory", "cc"); -if (vmx_get_test_stage () !=9 ) -report ("Write shadowing different X86_CR0_TS" ,0 ); -else -report ("Write shadowing different X86_CR0_TS" ,1 ); +report ("Write shadowing different X86_CR0_TS" ,vmx_get_test_stage () ==9 );vmx_set_test_stage (9 ); tmp = guest_cr0 ^X86_CR0_MP ; asmvolatile ("mov %0, %%rsi\n\t" "mov %%rsi, %%cr0\n\t" ::"m" (tmp) :"rsi" ,"memory" ,"cc" ); -if (vmx_get_test_stage () !=10 ) -report ("Write shadowing different X86_CR0_MP" ,0 ); -else -report ("Write shadowing different X86_CR0_MP" ,1 ); +report ("Write shadowing different X86_CR0_MP" ,vmx_get_test_stage () ==10 );vmx_set_test_stage (10 ); tmp = guest_cr4 ^X86_CR4_TSD ; asmvolatile ("mov %0, %%rsi\n\t" "mov %%rsi, %%cr4\n\t" ::"m" (tmp) :"rsi" ,"memory" ,"cc" ); -if (vmx_get_test_stage () !=11 ) -report ("Write shadowing different X86_CR4_TSD" ,0 ); -else -report ("Write shadowing different X86_CR4_TSD" ,1 ); +report ("Write shadowing different X86_CR4_TSD" ,vmx_get_test_stage () ==11 );vmx_set_test_stage (11 ); tmp = guest_cr4 ^X86_CR4_DE ; asmvolatile ("mov %0, %%rsi\n\t" "mov %%rsi, %%cr4\n\t" ::"m" (tmp) :"rsi" ,"memory" ,"cc" ); -if (vmx_get_test_stage () !=12 ) -report ("Write shadowing different X86_CR4_DE" ,0 ); -else -report ("Write shadowing different X86_CR4_DE" ,1 ); +report ("Write shadowing different X86_CR4_DE" ,vmx_get_test_stage () ==12 ); }static int cr_shadowing_exit_handler ()
@@ -521,28 +478,16 @@ static int cr_shadowing_exit_handler()case VMX_VMCALL :switch (vmx_get_test_stage ()) {case 0 : -if (guest_cr0 ==vmcs_read (GUEST_CR0 )) -report ("Read through CR0" ,1 ); -else -report ("Read through CR0" ,0 ); +report ("Read through CR0" , guest_cr0 ==vmcs_read (GUEST_CR0 ));break ;case 1 : -if (guest_cr4 ==vmcs_read (GUEST_CR4 )) -report ("Read through CR4" ,1 ); -else -report ("Read through CR4" ,0 ); +report ("Read through CR4" , guest_cr4 ==vmcs_read (GUEST_CR4 ));break ;case 2 : -if (guest_cr0 ==vmcs_read (GUEST_CR0 )) -report ("Write through CR0" ,1 ); -else -report ("Write through CR0" ,0 ); +report ("Write through CR0" , guest_cr0 ==vmcs_read (GUEST_CR0 ));break ;case 3 : -if (guest_cr4 ==vmcs_read (GUEST_CR4 )) -report ("Write through CR4" ,1 ); -else -report ("Write through CR4" ,0 ); +report ("Write through CR4" , guest_cr4 ==vmcs_read (GUEST_CR4 ));break ;case 4 : guest_cr0 =vmcs_read (GUEST_CR0 ) ^ (X86_CR0_TS |X86_CR0_MP );
@@ -553,16 +498,12 @@ static int cr_shadowing_exit_handler()vmcs_write (CR4_READ_SHADOW , guest_cr4 & (X86_CR4_TSD |X86_CR4_DE ));break ;case 6 : -if (guest_cr0 == (vmcs_read (GUEST_CR0 ) ^ (X86_CR0_TS |X86_CR0_MP ))) -report ("Write shadowing CR0 (same value)" ,1 ); -else -report ("Write shadowing CR0 (same value)" ,0 ); +report ("Write shadowing CR0 (same value)" , + guest_cr0 == (vmcs_read (GUEST_CR0 ) ^ (X86_CR0_TS |X86_CR0_MP )));break ;case 7 : -if (guest_cr4 == (vmcs_read (GUEST_CR4 ) ^ (X86_CR4_TSD |X86_CR4_DE ))) -report ("Write shadowing CR4 (same value)" ,1 ); -else -report ("Write shadowing CR4 (same value)" ,0 ); +report ("Write shadowing CR4 (same value)" , + guest_cr4 == (vmcs_read (GUEST_CR4 ) ^ (X86_CR4_TSD |X86_CR4_DE )));break ;default :// Should not reach here
@@ -642,59 +583,37 @@ static void iobmp_main()vmx_set_test_stage (0 );inb (0x5000 );outb (0x0 ,0x5000 ); -if (vmx_get_test_stage () !=0 ) -report ("I/O bitmap - I/O pass" ,0 ); -else -report ("I/O bitmap - I/O pass" ,1 ); +report ("I/O bitmap - I/O pass" ,vmx_get_test_stage () ==0 );// test IO width, in/out ((u8 *)io_bitmap_a)[0 ] =0xFF ;vmx_set_test_stage (2 );inb (0x0 ); -if (vmx_get_test_stage () !=3 ) -report ("I/O bitmap - trap in" ,0 ); -else -report ("I/O bitmap - trap in" ,1 ); +report ("I/O bitmap - trap in" ,vmx_get_test_stage () ==3 );vmx_set_test_stage (3 );outw (0x0 ,0x0 ); -if (vmx_get_test_stage () !=4 ) -report ("I/O bitmap - trap out" ,0 ); -else -report ("I/O bitmap - trap out" ,1 ); +report ("I/O bitmap - trap out" ,vmx_get_test_stage () ==4 );vmx_set_test_stage (4 );inl (0x0 ); -if (vmx_get_test_stage () !=5 ) -report ("I/O bitmap - I/O width, long" ,0 ); +report ("I/O bitmap - I/O width, long" ,vmx_get_test_stage () ==5 );// test low/high IO port vmx_set_test_stage (5 ); ((u8 *)io_bitmap_a)[0x5000 /8 ] = (1 << (0x5000 %8 ));inb (0x5000 ); -if (vmx_get_test_stage () ==6 ) -report ("I/O bitmap - I/O port, low part" ,1 ); -else -report ("I/O bitmap - I/O port, low part" ,0 ); +report ("I/O bitmap - I/O port, low part" ,vmx_get_test_stage () ==6 );vmx_set_test_stage (6 ); ((u8 *)io_bitmap_b)[0x1000 /8 ] = (1 << (0x1000 %8 ));inb (0x9000 ); -if (vmx_get_test_stage () ==7 ) -report ("I/O bitmap - I/O port, high part" ,1 ); -else -report ("I/O bitmap - I/O port, high part" ,0 ); +report ("I/O bitmap - I/O port, high part" ,vmx_get_test_stage () ==7 );// test partial pass vmx_set_test_stage (7 );inl (0x4FFF ); -if (vmx_get_test_stage () ==8 ) -report ("I/O bitmap - partial pass" ,1 ); -else -report ("I/O bitmap - partial pass" ,0 ); +report ("I/O bitmap - partial pass" ,vmx_get_test_stage () ==8 );// test overrun vmx_set_test_stage (8 );memset (io_bitmap_a,0x0 ,PAGE_SIZE );memset (io_bitmap_b,0x0 ,PAGE_SIZE );inl (0xFFFF ); -if (vmx_get_test_stage () ==9 ) -report ("I/O bitmap - overrun" ,1 ); -else -report ("I/O bitmap - overrun" ,0 ); +report ("I/O bitmap - overrun" ,vmx_get_test_stage () ==9 );vmx_set_test_stage (9 );vmcall ();outb (0x0 ,0x0 );
@@ -725,32 +644,21 @@ static int iobmp_exit_handler()vmx_inc_test_stage ();break ;case 2 : -if ((exit_qual &VMX_IO_SIZE_MASK ) != _VMX_IO_BYTE) -report ("I/O bitmap - I/O width, byte" ,0 ); -else -report ("I/O bitmap - I/O width, byte" ,1 ); -if (!(exit_qual &VMX_IO_IN )) -report ("I/O bitmap - I/O direction, in" ,0 ); -else -report ("I/O bitmap - I/O direction, in" ,1 ); +report ("I/O bitmap - I/O width, byte" , + (exit_qual &VMX_IO_SIZE_MASK ) == _VMX_IO_BYTE); +report ("I/O bitmap - I/O direction, in" , exit_qual &VMX_IO_IN );vmx_inc_test_stage ();break ;case 3 : -if ((exit_qual &VMX_IO_SIZE_MASK ) != _VMX_IO_WORD) -report ("I/O bitmap - I/O width, word" ,0 ); -else -report ("I/O bitmap - I/O width, word" ,1 ); -if (!(exit_qual &VMX_IO_IN )) -report ("I/O bitmap - I/O direction, out" ,1 ); -else -report ("I/O bitmap - I/O direction, out" ,0 ); +report ("I/O bitmap - I/O width, word" , + (exit_qual &VMX_IO_SIZE_MASK ) == _VMX_IO_WORD); +report ("I/O bitmap - I/O direction, out" , + !(exit_qual &VMX_IO_IN ));vmx_inc_test_stage ();break ;case 4 : -if ((exit_qual &VMX_IO_SIZE_MASK ) != _VMX_IO_LONG) -report ("I/O bitmap - I/O width, long" ,0 ); -else -report ("I/O bitmap - I/O width, long" ,1 ); +report ("I/O bitmap - I/O width, long" , + (exit_qual &VMX_IO_SIZE_MASK ) == _VMX_IO_LONG);vmx_inc_test_stage ();break ;case 5 :
@@ -922,8 +830,6 @@ static int insn_intercept_init()static void insn_intercept_main () { -char msg[80 ]; -for (cur_insn =0 ; insn_table[cur_insn].name !=NULL ; cur_insn++) {vmx_set_test_stage (cur_insn *2 ); if ((insn_table[cur_insn].type == INSN_CPU0 &&
@@ -943,9 +849,8 @@ static void insn_intercept_main()/* skip hlt, it stalls the guest and is tested below */ if (insn_table[cur_insn].insn_func != insn_hlt) insn_table[cur_insn].insn_func (); -snprintf (msg,sizeof (msg),"execute %s" , - insn_table[cur_insn].name); -report (msg,vmx_get_test_stage () == cur_insn *2 ); +report ("execute %s" ,vmx_get_test_stage () == cur_insn *2 , + insn_table[cur_insn].name); }else if (insn_table[cur_insn].type !=INSN_ALWAYS_TRAP ) printf("\tCPU_CTRL%d.CPU_%s always traps.\n", insn_table[cur_insn].type - INSN_CPU0,
@@ -954,9 +859,8 @@ static void insn_intercept_main()vmcall (); insn_table[cur_insn].insn_func (); -snprintf (msg,sizeof (msg),"intercept %s" , - insn_table[cur_insn].name); -report (msg,vmx_get_test_stage () == cur_insn *2 +1 ); +report ("intercept %s" ,vmx_get_test_stage () == cur_insn *2 +1 , + insn_table[cur_insn].name);vmx_set_test_stage (cur_insn *2 +1 );vmcall ();
@@ -1115,28 +1019,18 @@ static void ept_main()vmx_set_test_stage (2 );vmcall (); *((u32 *)data_page1) =MAGIC_VAL_1 ; -if (vmx_get_test_stage () !=3 ) { -report ("EPT misconfigurations" ,0 ); - goto t1; - } -report ("EPT misconfigurations" ,1 ); +report ("EPT misconfigurations" ,vmx_get_test_stage () ==3 ); t1:// Test EPT violation vmx_set_test_stage (3 );vmcall (); *((u32 *)data_page1) =MAGIC_VAL_1 ; -if (vmx_get_test_stage () ==4 ) -report ("EPT violation - page permission" ,1 ); -else -report ("EPT violation - page permission" ,0 ); +report ("EPT violation - page permission" ,vmx_get_test_stage () ==4 );// Violation caused by EPT paging structure vmx_set_test_stage (4 );vmcall (); *((u32 *)data_page1) =MAGIC_VAL_2 ; -if (vmx_get_test_stage () ==5 ) -report ("EPT violation - paging structure" ,1 ); -else -report ("EPT violation - paging structure" ,0 ); +report ("EPT violation - paging structure" ,vmx_get_test_stage () ==5 );// Test EPT access to L1 MMIO vmx_set_test_stage (6 );
Signature · 1 line
1.9.3
PATCH 4/10 x86: tsc_adjust: use report
In reply to Andrew Jones--- x86/tsc_adjust.c | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-)
x86/tsc_adjust.c +13 -31
@@ -7,35 +7,22 @@ int main() {u64 t1, t2, t3, t4, t5;u64 est_delta_time; -bool pass = true;if (cpuid (7 ).b & (1 <<1 )) {// IA32_TSC_ADJUST Feature is enabled? -if (rdmsr (IA32_TSC_ADJUST ) !=0x0 ) { -printf ("failure: IA32_TSC_ADJUST msr was incorrectly" -" initialized\n" ); - pass = false; - } +report ("IA32_TSC_ADJUST msr initialization" , +rdmsr (IA32_TSC_ADJUST ) ==0x0 ); t3 =100000000000ull ; t1 =rdtsc ();wrmsr (IA32_TSC_ADJUST , t3); t2 =rdtsc (); -if (rdmsr (IA32_TSC_ADJUST ) != t3) { -printf ("failure: IA32_TSC_ADJUST msr read / write" -" incorrect\n" ); - pass = false; - } -if (t2 - t1 < t3) { -printf ("failure: TSC did not adjust for IA32_TSC_ADJUST" -" value\n" ); - pass = false; - } +report ("IA32_TSC_ADJUST msr read / write" , +rdmsr (IA32_TSC_ADJUST ) == t3); +report ("TSC adjustment for IA32_TSC_ADJUST value" , + (t2 - t1) >= t3); t3 =0x0 ;wrmsr (IA32_TSC_ADJUST , t3); -if (rdmsr (IA32_TSC_ADJUST ) != t3) { -printf ("failure: IA32_TSC_ADJUST msr read / write" -" incorrect\n" ); - pass = false; - } +report ("IA32_TSC_ADJUST msr read / write" , +rdmsr (IA32_TSC_ADJUST ) == t3); t4 =100000000000ull ; t1 =rdtsc ();wrtsc (t4);
@@ -44,17 +31,12 @@ int main()// est of time between reading tsc and writing tsc, // (based on IA32_TSC_ADJUST msr value) should be small est_delta_time = t4 - t5 - t1; -if (est_delta_time >2 * (t2 - t4)) { -// arbitray 2x latency (wrtsc->rdtsc) threshold -printf ("failure: IA32_TSC_ADJUST msr incorrectly" -" adjusted on tsc write\n" ); - pass = false; - } -if (pass)printf ("success: IA32_TSC_ADJUST enabled and" -" working correctly\n" ); +// arbitray 2x latency (wrtsc->rdtsc) threshold +report ("IA32_TSC_ADJUST msr adjustment on tsc write" , + est_delta_time <= (2 * (t2 - t4))); }else { -printf ("success: IA32_TSC_ADJUST feature not enabled\n" ); +report ("IA32_TSC_ADJUST feature not enabled" , true); } -return pass?0 :1 ; +return report_summary (); }
Signature · 1 line
1.9.3
PATCH 5/10 x86: svm: use report
In reply to Andrew Jones--- x86/svm.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
x86/svm.c +8 -17
@@ -239,11 +239,10 @@ struct regs regs;#define LOAD_GPR_C SAVE_GPR_C -static bool test_run (struct test *test,struct vmcb *vmcb) +static void test_run (struct test *test,struct vmcb *vmcb) {u64 vmcb_phys =virt_to_phys (vmcb);u64 guest_stack[10000 ]; -bool success; test->vmcb = vmcb; test->prepare (test);
@@ -276,12 +275,7 @@ static bool test_run(struct test *test, struct vmcb *vmcb) ++test->exits; }while (!test->finished (test)); - - success = test->succeeded (test); - -printf ("%s: %s\n" , test->name, success ?"PASS" :"FAIL" ); - -return success; +report ("%s" , test->succeeded (test), test->name); }static bool smp_supported (void )
@@ -610,7 +604,7 @@ static void test_ioio(struct test *test)return ; fail: -printf ("test failure, stage %d\n" ,get_test_stage (test)); +report ("stage %d\n" , false,get_test_stage (test)); test->scratch =-1 ; }
@@ -685,8 +679,8 @@ static void sel_cr0_bug_test(struct test *test)* are not in guest-mode anymore so we can't trigger an intercept. * Trigger a tripple-fault for now. */ -printf ("sel_cr0 test failed. Can not recover from this - exiting\n" ); -exit (1 ); +report ("sel_cr0 test. Can not recover from this - exiting\n" , false); +exit (report_summary ()); }static bool sel_cr0_bug_check (struct test *test)
@@ -1062,7 +1056,7 @@ static struct test tests[] = {int main (int ac,char **av) { -int i, nr, passed, done; +int i, nr;struct vmcb *vmcb;setup_vm ();
@@ -1078,14 +1072,11 @@ int main(int ac, char **av) vmcb =alloc_page (); nr =ARRAY_SIZE (tests); - passed = done =0 ;for (i =0 ; i < nr; ++i) {if (!tests[i].supported ())continue ; - done +=1 ; - passed +=test_run (&tests[i], vmcb); +test_run (&tests[i], vmcb); } -printf ("\nSUMMARY: %d TESTS, %d FAILURES\n" , done, (done - passed)); -return passed == done ?0 :1 ; +return report_summary (); }
Signature · 1 line
1.9.3
PATCH 6/10 x86: asyncpf: use report
In reply to Andrew Jones--- x86/asyncpf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
x86/asyncpf.c +6 -9
@@ -37,7 +37,6 @@ volatile uint32_t apf_reason __attribute__((aligned(64)));char *buf;volatile uint64_t i;volatile uint64_t phys; -bool fail;static inline uint32_t get_apf_reason (void ) {
@@ -53,21 +52,21 @@ static void pf_isr(struct ex_regs *r)switch (reason) {case 0 : -printf ("unexpected #PF at %p\n" ,read_cr2 ()); - fail = true; +report ("unexpected #PF at %p\n" , false,read_cr2 ());break ;case KVM_PV_REASON_PAGE_NOT_PRESENT : phys =virt_to_phys_cr3 (virt);install_pte (phys_to_virt (read_cr3 ()),1 , virt, phys,0 );write_cr3 (read_cr3 ()); -printf ("Got not present #PF token %x virt addr %p phys addr %p\n" ,read_cr2 (), virt, phys); +report ("Got not present #PF token %x virt addr %p phys addr %p\n" , + true,read_cr2 (), virt, phys);while (phys) {safe_halt ();/* enables irq */ irq_disable (); }break ;case KVM_PV_REASON_PAGE_READY : -printf ("Got present #PF token %x\n" ,read_cr2 ()); +report ("Got present #PF token %x\n" , true,read_cr2 ());if ((uint32_t )read_cr2 () == ~0 )break ;install_pte (phys_to_virt (read_cr3 ()),1 , virt, phys |PTE_PRESENT |PTE_WRITE ,0 );
@@ -75,8 +74,7 @@ static void pf_isr(struct ex_regs *r) phys =0 ;break ;default : -printf ("unexpected async pf reason %d\n" , reason); - fail = true; +report ("unexpected async pf reason %d\n" , false, reason);break ; } }
@@ -107,6 +105,5 @@ int main(int ac, char **av) }irq_disable (); -printf ("%s\n" , fail ?"FAIL" :"PASS" ); -return fail; +return report_summary (); }
Signature · 1 line
1.9.3
PATCH 7/10 x86: xsave: use report
In reply to Andrew Jones--- x86/xsave.c | 150 +++++++++++++++++++++++------------------------------------- 1 file changed, 56 insertions(+), 94 deletions(-)
x86/xsave.c +56 -94
@@ -65,134 +65,103 @@ uint64_t get_supported_xcr0(void)#define XSTATE_SSE 0x2#define XSTATE_YMM 0x4 -static int total_tests, fail_tests; - -void pass_if (int condition) -{ - total_tests ++; -if (condition) -printf ("Pass!\n" ); -else { -printf ("Fail!\n" ); - fail_tests ++; - } -} -void test_xsave (void ) {unsigned long cr4;uint64_t supported_xcr0;uint64_t test_bits;u64 xcr0; -int r;printf ("Legal instruction testing:\n" ); + supported_xcr0 =get_supported_xcr0 ();printf ("Supported XCR0 bits: 0x%x\n" , supported_xcr0); -printf ("Check minimal XSAVE required bits: " ); test_bits =XSTATE_FP |XSTATE_SSE ; -pass_if ((supported_xcr0 & test_bits) == test_bits); +report ("Check minimal XSAVE required bits" , + (supported_xcr0 & test_bits) == test_bits); -printf ("Set CR4 OSXSAVE: " ); cr4 =read_cr4 (); - r =write_cr4_checking (cr4 |X86_CR4_OSXSAVE ); -pass_if (r ==0 ); - -printf ("Check CPUID.1.ECX.OSXSAVE - expect 1: " ); -pass_if (check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE )); +report ("Set CR4 OSXSAVE" ,write_cr4_checking (cr4 |X86_CR4_OSXSAVE ) ==0 ); +report ("Check CPUID.1.ECX.OSXSAVE - expect 1" , +check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE )); -printf (" Legal tests\n" ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP): " ); +printf ("\tLegal tests\n" ); test_bits =XSTATE_FP ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==0 ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, " -"XSTATE_FP | XSTATE_SSE): " ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP)" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==0 ); + test_bits =XSTATE_FP |XSTATE_SSE ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==0 ); -printf (" xgetbv(XCR_XFEATURE_ENABLED_MASK): " ); - r =xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0); -pass_if (r ==0 ); -printf (" Illegal tests\n" ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, 0) - expect #GP: " ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP | XSTATE_SSE)" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==0 ); +report (" xgetbv(XCR_XFEATURE_ENABLED_MASK)" , +xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0) ==0 ); + +printf ("\tIllegal tests\n" ); test_bits =0 ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==GP_VECTOR ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_SSE) " -"- expect #GP: " ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, 0) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==GP_VECTOR ); + test_bits =XSTATE_SSE ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==GP_VECTOR ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_SSE) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==GP_VECTOR ); +if (supported_xcr0 &XSTATE_YMM ) { -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, " -"XSTATE_YMM) - expect #GP: " ); test_bits =XSTATE_YMM ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==GP_VECTOR ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, " -"XSTATE_FP | XSTATE_YMM) - expect #GP: " ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_YMM) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==GP_VECTOR ); + test_bits =XSTATE_FP |XSTATE_YMM ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==GP_VECTOR ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP | XSTATE_YMM) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==GP_VECTOR ); } -printf (" xsetbv(XCR_XFEATURE_ILLEGAL_MASK, XSTATE_FP) " -"- expect #GP: " ); + test_bits =XSTATE_SSE ; - r =xsetbv_checking (XCR_XFEATURE_ILLEGAL_MASK , test_bits); -pass_if (r ==GP_VECTOR ); -printf (" xgetbv(XCR_XFEATURE_ILLEGAL_MASK, XSTATE_FP) " -"- expect #GP: " ); +report ("\t\txsetbv(XCR_XFEATURE_ILLEGAL_MASK, XSTATE_FP) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ILLEGAL_MASK , test_bits) ==GP_VECTOR ); + test_bits =XSTATE_SSE ; - r =xsetbv_checking (XCR_XFEATURE_ILLEGAL_MASK , test_bits); -pass_if (r ==GP_VECTOR ); +report ("\t\txgetbv(XCR_XFEATURE_ILLEGAL_MASK, XSTATE_FP) - expect #GP" , +xsetbv_checking (XCR_XFEATURE_ILLEGAL_MASK , test_bits) ==GP_VECTOR ); -printf ("Unset CR4 OSXSAVE: " ); cr4 &= ~X86_CR4_OSXSAVE ; - r =write_cr4_checking (cr4); -pass_if (r ==0 ); -printf ("Check CPUID.1.ECX.OSXSAVE - expect 0: " ); -pass_if (check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE ) ==0 ); -printf (" Illegal tests:\n" ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP) - expect #UD: " ); +report ("Unset CR4 OSXSAVE" ,write_cr4_checking (cr4) ==0 ); +report ("Check CPUID.1.ECX.OSXSAVE - expect 0" , +check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE ) ==0 ); + +printf ("\tIllegal tests:\n" ); test_bits =XSTATE_FP ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==UD_VECTOR ); -printf (" xsetbv(XCR_XFEATURE_ENABLED_MASK, " -"XSTATE_FP | XSTATE_SSE) - expect #UD: " ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP) - expect #UD" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==UD_VECTOR ); + test_bits =XSTATE_FP |XSTATE_SSE ; - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits); -pass_if (r ==UD_VECTOR ); -printf (" Illegal tests:\n" ); -printf (" xgetbv(XCR_XFEATURE_ENABLED_MASK) - expect #UD: " ); - r =xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0); -pass_if (r ==UD_VECTOR ); +report ("\t\txsetbv(XCR_XFEATURE_ENABLED_MASK, XSTATE_FP | XSTATE_SSE) - expect #UD" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK , test_bits) ==UD_VECTOR ); + +printf ("\tIllegal tests:\n" ); +report ("\txgetbv(XCR_XFEATURE_ENABLED_MASK) - expect #UD" , +xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0) ==UD_VECTOR ); }void test_no_xsave (void ) {unsigned long cr4;u64 xcr0; -int r; -printf ("Check CPUID.1.ECX.OSXSAVE - expect 0: " ); -pass_if (check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE ) ==0 ); +report ("Check CPUID.1.ECX.OSXSAVE - expect 0" , +check_cpuid_1_ecx (CPUID_1_ECX_OSXSAVE ) ==0 );printf ("Illegal instruction testing:\n" ); -printf ("Set OSXSAVE in CR4 - expect #GP: " ); cr4 =read_cr4 (); - r =write_cr4_checking (cr4 |X86_CR4_OSXSAVE ); -pass_if (r ==GP_VECTOR ); +report ("Set OSXSAVE in CR4 - expect #GP" , +write_cr4_checking (cr4 |X86_CR4_OSXSAVE ) ==GP_VECTOR ); -printf ("Execute xgetbv - expect #UD: " ); - r =xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0); -pass_if (r ==UD_VECTOR ); +report ("Execute xgetbv - expect #UD" , +xgetbv_checking (XCR_XFEATURE_ENABLED_MASK , &xcr0) ==UD_VECTOR ); -printf ("Execute xsetbv - expect #UD: " ); - r =xsetbv_checking (XCR_XFEATURE_ENABLED_MASK ,0x3 ); -pass_if (r ==UD_VECTOR ); +report ("Execute xsetbv - expect #UD" , +xsetbv_checking (XCR_XFEATURE_ENABLED_MASK ,0x3 ) ==UD_VECTOR ); }int main (void )
@@ -205,12 +174,5 @@ int main(void)printf ("CPU don't has XSAVE feature\n" );test_no_xsave (); } -printf ("Total test: %d\n" , total_tests); -if (fail_tests ==0 ) -printf ("ALL PASS!\n" ); -else { -printf ("Fail %d tests.\n" , fail_tests); -return 1 ; - } -return 0 ; +return report_summary (); }
Signature · 1 line
1.9.3
PATCH 8/10 report: add prefix support
In reply to Andrew JonesAdd some methods to report in order to manage output prefixes. Also add strstr to string, as it was useful for implementing report_prefix_pop. Prefixes can be useful, as test code frequently has the following pattern
main()
{
foreach(subtest)
run(subtest)
}
But, if we want output lines to include 'subtest: ', then we need
report("%s: ...", cond, subtest, ...)
for each report line. With push/pop we can now just do
subtest()
{
report_prefix_push(subtest); report(...);
...
report(...);
report_prefix_pop();}
--- lib/libcflat.h | 2 ++ lib/report.c | 22 ++++++++++++++++++++++ lib/string.c | 17 +++++++++++++++++ lib/string.h | 1 + 4 files changed, 42 insertions(+)
lib/libcflat.h +2 -0
@@ -57,6 +57,8 @@ extern int snprintf(char *buf, int size, const char *fmt, ...);extern int vsnprintf (char *buf,int size,const char *fmt,va_list va);extern long atol (const char *ptr); +void report_prefix_push (const char *prefix); +void report_prefix_pop (void );void report (const char *msg_fmt,bool pass, ...);void report_xfail (const char *msg_fmt,bool xfail,bool pass, ...);int report_summary (void );
lib/report.c +22 -0
@@ -13,6 +13,27 @@#include "libcflat.h" static unsigned int tests, failures, xfailures; +static char prefixes[256 ]; + +void report_prefix_push (const char *prefix) +{ +strcat (prefixes, prefix); +strcat (prefixes,": " ); +} + +void report_prefix_pop (void ) +{ +char *p, *q; + +if (!*prefixes) +return ; + +for (p = prefixes, q =strstr (p,": " ) +2 ; + *q; + p = q, q =strstr (p,": " ) +2 ) + ; + *p ='\0' ; +}void va_report_xfail (const char *msg_fmt,bool xfail,bool cond,va_list va) {
@@ -22,6 +43,7 @@ void va_report_xfail(const char *msg_fmt, bool xfail, bool cond, va_list va) tests++;printf ("%s: " , cond ? pass : fail); +puts (prefixes);vsnprintf (buf,sizeof (buf), msg_fmt, va);puts (buf);puts ("\n" );
lib/string.c +17 -0
@@ -45,6 +45,23 @@ char *strchr(const char *s, int c)return (char *)s; } +char *strstr (const char *s1,const char *s2) +{ +size_t l1, l2; + + l2 =strlen (s2); +if (!l2) +return (char *)s1; + l1 =strlen (s1); +while (l1 >= l2) { + l1--; +if (!memcmp (s1, s2, l2)) +return (char *)s1; + s1++; + } +return NULL ; +} +void *memset (void *s,int c,size_t n) {size_t i;
lib/string.h +1 -0
@@ -6,6 +6,7 @@ extern char *strcat(char *dest, const char *src);extern char *strcpy (char *dest,const char *src);extern int strcmp (const char *a,const char *b);extern char *strchr (const char *s,int c); +char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);extern void *memcpy (void *dest,const void *src,size_t n);extern int memcmp (const void *s1,const void *s2,size_t n);
Signature · 1 line
1.9.3
PATCH 9/10 x86: use report prefixes
In reply to Andrew JonesSo far only applied in a couple obvious places, where temporary prefixes were already used.
--- x86/apic.c | 8 ++++++-- x86/pmu.c | 24 ++++++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-)
x86/apic.c +6 -2
@@ -121,19 +121,23 @@ static void test_apicbase(void)wrmsr (MSR_IA32_APICBASE , orig_apicbase & ~(APIC_EN |APIC_EXTD ));wrmsr (MSR_IA32_APICBASE ,ALTERNATE_APIC_BASE |APIC_BSP |APIC_EN ); +report_prefix_push ("apicbase" ); +report ("relocate apic" , *(volatile u32 *)(ALTERNATE_APIC_BASE +APIC_LVR ) == lvr); value = orig_apicbase | (1UL <<cpuid_maxphyaddr ()); -report ("apicbase: reserved physaddr bits" , +report ("reserved physaddr bits" ,test_for_exception (GP_VECTOR , do_write_apicbase, &value)); value = orig_apicbase |1 ; -report ("apicbase: reserved low bits" , +report ("reserved low bits" ,test_for_exception (GP_VECTOR , do_write_apicbase, &value));wrmsr (MSR_IA32_APICBASE , orig_apicbase);apic_write (APIC_SPIV ,0x1ff ); + +report_prefix_pop (); }static void eoi (void )
x86/pmu.c +16 -8
@@ -309,6 +309,8 @@ static void check_counter_overflow(void)/* clear status before test */ wrmsr (MSR_CORE_PERF_GLOBAL_OVF_CTRL ,rdmsr (MSR_CORE_PERF_GLOBAL_STATUS )); +report_prefix_push ("overflow" ); +for (i =0 ; i < num_counters +1 ; i++, cnt.ctr++) {uint64_t status;int idx;
@@ -321,14 +323,16 @@ static void check_counter_overflow(void) idx =event_to_global_idx (&cnt); cnt.count =1 - count;measure (&cnt,1 ); -report ("overflow-%d" , cnt.count ==1 , i); +report ("cntr-%d" , cnt.count ==1 , i); status =rdmsr (MSR_CORE_PERF_GLOBAL_STATUS ); -report ("overflow status-%d" , status & (1ull << idx), i); +report ("status-%d" , status & (1ull << idx), i);wrmsr (MSR_CORE_PERF_GLOBAL_OVF_CTRL , status); status =rdmsr (MSR_CORE_PERF_GLOBAL_STATUS ); -report ("overflow status clear-%d" , !(status & (1ull << idx)), i); -report ("overflow irq-%d" ,check_irq () == (i %2 ), i); +report ("status clear-%d" , !(status & (1ull << idx)), i); +report ("irq-%d" ,check_irq () == (i %2 ), i); } + +report_prefix_pop (); }static void check_gp_counter_cmask (void )
@@ -348,20 +352,24 @@ static void check_rdpmc(void)uint64_t val =0x1f3456789ull ;int i; +report_prefix_push ("rdpmc" ); +for (i =0 ; i < num_counters; i++) {uint64_t x = (val &0xffffffff ) | ((1ull << (eax.split.bit_width -32 )) -1 ) <<32 ;wrmsr (MSR_IA32_PERFCTR0 + i, val); -report ("rdpmc-%d" ,rdpmc (i) == x, i); -report ("rdpmc fast-%d" ,rdpmc (i | (1 <<31 )) == (u32 )val, i); +report ("cntr-%d" ,rdpmc (i) == x, i); +report ("fast-%d" ,rdpmc (i | (1 <<31 )) == (u32 )val, i); }for (i =0 ; i < edx.split.num_counters_fixed; i++) {uint64_t x = (val &0xffffffff ) | ((1ull << (edx.split.bit_width_fixed -32 )) -1 ) <<32 ;wrmsr (MSR_CORE_PERF_FIXED_CTR0 + i, val); -report ("rdpmc fixed-%d" ,rdpmc (i | (1 <<30 )) == x, i); -report ("rdpmc fixed fast-%d" ,rdpmc (i | (3 <<30 )) == (u32 )val, i); +report ("fixed cntr-%d" ,rdpmc (i | (1 <<30 )) == x, i); +report ("fixed fast-%d" ,rdpmc (i | (3 <<30 )) == (u32 )val, i); } + +report_prefix_pop (); }int main (int ac,char **av)
Signature · 1 line
1.9.3
PATCH 10/10 arm: use report prefixes
In reply to Andrew Jonesarm/selftest was already making use of prefixes, managing them itself. Use the prefix support now built into report.
--- arm/selftest.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-)
arm/selftest.c +12 -19
@@ -13,23 +13,10 @@#include "asm/processor.h" #include "asm/page.h" -#define TESTGRP "selftest" - -static char testname[64 ]; - -static void testname_set (const char *subtest) -{ -strcpy (testname,TESTGRP ); -if (subtest) { -strcat (testname,"::" ); -strcat (testname, subtest); - } -} -static void assert_args (int num_args,int needed_args) {if (num_args < needed_args) { -printf ("%s: not enough arguments\n" , testname); +printf ("selftest: not enough arguments\n" );abort (); } }
@@ -60,19 +47,24 @@ static void check_setup(int argc, char **argv)if (!var)continue ; +report_prefix_push (var); +if (strcmp (var,"mem" ) ==0 ) {phys_addr_t memsize =PHYS_END -PHYS_OFFSET ;phys_addr_t expected = ((phys_addr_t )val)*1024 *1024 ; -report ("%s[%s]" , memsize == expected, testname,"mem" ); +report ("size = %d MB" , memsize == expected, + memsize/1024 /1024 ); ++nr_tests; }else if (strcmp (var,"smp" ) ==0 ) { -report ("%s[%s]" , nr_cpus == (int )val, testname,"smp" ); +report ("nr_cpus = %d" , nr_cpus == (int )val, nr_cpus); ++nr_tests; } + +report_prefix_pop (); }assert_args (nr_tests,2 );
@@ -181,15 +173,16 @@ static bool check_svc(void) static void check_vectors(void *arg __unused) { -report ("%s" ,check_und () &&check_svc (), testname); +report ("und" ,check_und ()); +report ("svc" ,check_svc ());exit (report_summary ()); }int main (int argc,char **argv) { -testname_set (NULL ); +report_prefix_push ("selftest" );assert_args (argc,1 ); -testname_set (argv[0 ]); +report_prefix_push (argv[0 ]);if (strcmp (argv[0 ],"setup" ) ==0 ) {
Signature · 1 line
1.9.3
Quoted 16 lines · Andrew Jones
This series applies
report()to more x86 unit tests. It also cleans up some uses of it invmx_tests. Finally, it also introduces report prefix support, and applies that a few places. There should be no functional changes with this series, except of course the output formatting (which makes the churn debatable). Anyway, I believe this series helps us to start converging on a "standard" output format for all unit tests.I'm afraid I didn't test all the changes, as not all unit tests could run on my test machine.
svm - didn't run
xsave - didn't run 'have xsave' tests
asyncpf - is commented out of unittests.cfg,
and I didn't uncomment it out
pmu - didn't run
Quoted 4 lines
(I probably should add a bunch of kvm-unit-tests contributors to
the CC in order to alert them that I'm touching their unit tests, but I don't think this series warrants all the git blaming, so I'm not adding anybody at all :-)
Forgot to mention that these patches are available here
https://github.com/rhdrjones/kvm-unit-tests/tree/more-report
Quoted 32 lines
Andrew Jones (10):
x86: hypercall: add missingreport_summary
x86: pmu: report takes a fmt
x86: vmx: better use of report
x86:tsc_adjust: use report
x86: svm: use report
x86: asyncpf: use report
x86: xsave: use report
report: add prefix support
x86: use report prefixes
arm: use report prefixesarm/selftest.c | 31 ++++----- lib/libcflat.h | 2 + lib/report.c | 22 ++++++ lib/string.c | 17 +++++ lib/string.h | 1 + x86/apic.c | 8 ++- x86/asyncpf.c | 15 ++-- x86/hypercall.c | 2 +- x86/pmu.c | 28 +++++--- x86/svm.c | 25 +++---- x86/tsc_adjust.c | 44 ++++-------- x86/vmx_tests.c | 204 +++++++++++++------------------------------------------ x86/xsave.c | 150 +++++++++++++++------------------------- 13 files changed, 210 insertions(+), 339 deletions(-)Signature · 1 line
1.9.3
Paolo Bonzini
maintainerRe: [PATCH 02/10] x86: pmu: report takes a fmt
In reply to Andrew JonesQuoted 12 lines · Andrew Jones
Signed-off-by Andrew Jones <[email protected]>--- x86/pmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)x86/pmu.c +0
-0@@ -228,14 +228,12 @@ static void check_gp_counter(struct pmu_event *evt) .ctr = MSR_IA32_PERFCTR0, .config = EVNTSEL_OS | EVNTSEL_USR | evt->unit_sel,
x86/pmu.c static void check_gp_counter(struct pmu_event *evt) · line 236
Quoted 10 lines
x86/pmu.c +1
-3}; -char fmt[100 ];int i;for (i =0 ; i < num_counters; i++, cnt.ctr++) { cnt.count =0 ;measure (&cnt,1 ); -snprintf (fmt,sizeof (fmt),"%s-%%d" , evt->name); -report (fmt,verify_event (cnt.count, evt), i); +report ("%s-%%d" ,verify_event (cnt.count, evt), evt->name, i);
Should be %s-%d, changed it.
Paolo
Quoted 4 lines
x86/pmu.c +0
-0} }
Paolo Bonzini
maintainerRe: [PATCH 02/10] x86: pmu: report takes a fmt
In reply to Andrew JonesQuoted 12 lines · Andrew Jones
Signed-off-by Andrew Jones <[email protected]>--- x86/pmu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)x86/pmu.c +0
-0@@ -228,14 +228,12 @@ static void check_gp_counter(struct pmu_event *evt) .ctr = MSR_IA32_PERFCTR0, .config = EVNTSEL_OS | EVNTSEL_USR | evt->unit_sel,
x86/pmu.c static void check_gp_counter(struct pmu_event *evt) · line 236
Quoted 10 lines
x86/pmu.c +1
-3}; -char fmt[100 ];int i;for (i =0 ; i < num_counters; i++, cnt.ctr++) { cnt.count =0 ;measure (&cnt,1 ); -snprintf (fmt,sizeof (fmt),"%s-%%d" , evt->name); -report (fmt,verify_event (cnt.count, evt), i); +report ("%s-%%d" ,verify_event (cnt.count, evt), evt->name, i);
Should be %s-%d, changed it.
Paolo
Quoted 4 lines
x86/pmu.c +0
-0} }
Paolo Bonzini
maintainerQuoted 8 lines · Andrew Jones
Quoted 8 lines
I'm afraid I didn't test all the changes, as not all unit tests could run on my test machine.
svm - didn't run
xsave - didn't run 'have xsave' tests
asyncpf - is commented out of unittests.cfg,
and I didn't uncomment it out
pmu - didn't run
Tested svm/xsave/pmu myself, applied series.
Paolo