void test_cpl(void) { int cpl; change_cpl(1); cpl = get_cpl(); ASSERT(cpl == 1); change_cpl(3); cpl = get_cpl(); ASSERT(cpl == 3); debug("changing CPL seems to work\n\n"); sleep(1); }
void get_system_information(void) { cprintf("Getting system information: "); cprintf("CPU..."); _cputype=get_cpu_type();_cpuvendor=get_cpu_id(); cprintf("\b\b\b\b\b\bFPU..."); _fputype=get_fpu_type();_fpuinfo=get_fpu_info(); cprintf("\b\b\b\b\b\bSYS..."); _systype=get_sys_type();_codecpl=get_cpl();_codeiopl=get_iopl(); _extendertype=get_extender_type(); _dpmiflags=get_dpmi_flags(); if((_dpmiflags&0x02)==0) _modetype=1; else _modetype=0; cprintf("\b\b\b\b\b\bMEM..."); _totalmemsize=get_total_size(); _lomemsize=get_lomem_size(); _himemsize=get_himem_size(); printf("\b\b\b\b\b\bDone. \n"); }
void trap_test(void) { test_cpl(); #ifdef USER_DEBUG /* If the #gpf handler stuff is really broken, you might want to start out by manually building the trap frames, and trapping back to user space. */ { u_int handler13 = (u_int)&exc_13_handler; u_int handler14 = (u_int)&exc_14_handler; VMSTATE->cr[0] |= 1; lmsw_test(handler13); lidt_test(handler13); hlt_test(handler13); lgdt_test(handler13); clts_test(handler13); cr3_test(handler13); /* set a new page table */ setup_pt(); add_page_test(handler14); /* add an entry to it */ change_page_test(handler14); /* change an entry in it */ } #else /* If the #gpf handlers aren't fundamentally broken, test this way. */ { Bit32u tmp, tmp2; change_cpl(1); debug("Simulating guest running at CPL %d\n\n", get_cpl()); sleep(1); asm("in $0x80, %al"); asm("mov $0x80, %dx"); asm(".byte 0xec"); debug("trivial inb seems to work\n\n"); sleep(1); asm("hlt"); debug("hlt seems to work\n\n"); sleep(1); /* IF */ asm("pushf"); asm("popl %0"::"m" (tmp)); asm("cli"); asm("pushf"); asm("popl %0"::"m" (tmp2)); #if 0 /* only for V86 :( */ ASSERT((tmp2 & IF_MASK) == 0); ASSERT(((tmp & ~IF_MASK) & ~0xff) == (tmp2 & ~0xff)); #endif asm("sti"); asm("pushf"); asm("popl %0"::"m" (tmp2)); #if 0 /* only for V86 :( */ ASSERT((tmp2 & IF_MASK)); ASSERT((tmp & ~0xff) == (tmp2 & ~0xff)); #endif debug("cli/sti seem to work\n\n"); sleep(1); /* test move to/from segment registers */ /* test move to/from control registers */ VMSTATE->cr[0] = 0x12456789; VMSTATE->cr[2] = 0x1da53799; VMSTATE->cr[3] = 0x12416189; VMSTATE->cr[4] = 0x1dd5378a; asm("mov %cr0, %ebx"); asm("mov %%ebx, %0"::"m" (tmp)); ASSERT(tmp == VMSTATE->cr[0]); asm("mov %cr2, %ebx"); asm("mov %%ebx, %0"::"m" (tmp)); ASSERT(tmp == VMSTATE->cr[2]); asm("mov %cr3, %ebx"); asm("mov %%ebx, %0"::"m" (tmp)); ASSERT(tmp == VMSTATE->cr[3]); asm("mov %cr4, %ebx"); asm("mov %%ebx, %0"::"m" (tmp)); ASSERT(tmp == VMSTATE->cr[4]); debug("move from CR3 seems to work\n\n"); change_cpl(3); } #endif }