1 #include "libcflat.h" 2 #include "desc.h" 3 4 static int test_ud2(bool *rflags_rf) 5 { 6 asm volatile(ASM_TRY("1f") 7 "ud2 \n\t" 8 "1:" :); 9 *rflags_rf = exception_rflags_rf(); 10 return exception_vector(); 11 } 12 13 static int test_gp(bool *rflags_rf) 14 { 15 unsigned long tmp; 16 17 asm volatile("mov $0xffffffff, %0 \n\t" 18 ASM_TRY("1f") 19 "mov %0, %%cr4\n\t" 20 "1:" 21 : "=a"(tmp)); 22 *rflags_rf = exception_rflags_rf(); 23 return exception_vector(); 24 } 25 26 int main(void) 27 { 28 int r; 29 bool rflags_rf; 30 31 printf("Starting IDT test\n"); 32 setup_idt(); 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