1 #include "libcflat.h" 2 #include "processor.h" 3 #include "desc.h" 4 test_ud2(bool * rflags_rf)5static int test_ud2(bool *rflags_rf) 6 { 7 asm volatile(ASM_TRY("1f") 8 "ud2 \n\t" 9 "1:" :); 10 *rflags_rf = exception_rflags_rf(); 11 return exception_vector(); 12 } 13 test_gp(bool * rflags_rf)14static int test_gp(bool *rflags_rf) 15 { 16 unsigned long tmp; 17 18 asm volatile("mov $0xffffffff, %0 \n\t" 19 ASM_TRY("1f") 20 "mov %0, %%cr4\n\t" 21 "1:" 22 : "=a"(tmp)); 23 *rflags_rf = exception_rflags_rf(); 24 return exception_vector(); 25 } 26 main(void)27int main(void) 28 { 29 int r; 30 bool rflags_rf; 31 32 printf("Starting IDT test\n"); 33 r = test_gp(&rflags_rf); 34 report(r == GP_VECTOR, "Testing #GP"); 35 report(rflags_rf, "Testing #GP rflags.rf"); 36 r = test_ud2(&rflags_rf); 37 report(r == UD_VECTOR, "Testing #UD"); 38 report(rflags_rf, "Testing #UD rflags.rf"); 39 40 return report_summary(); 41 } 42