17d36db35SAvi Kivity 2761db0bdSAndrew JonesTests for the x86 architecture are run as kernel images for qemu that support 3761db0bdSAndrew Jonesmultiboot format. The tests use an infrastructure called from the bios code. 4761db0bdSAndrew JonesThe infrastructure initialize the system/cpus, switches to long-mode, and 5761db0bdSAndrew Jonescalls the 'main' function of the individual test. Tests use a qemu virtual 6761db0bdSAndrew Jonestest device, named testdev, for services like printing, exiting, querying 7761db0bdSAndrew Jonesmemory size, etc. See file docs/testdev.txt for more details. 8761db0bdSAndrew Jones 9761db0bdSAndrew JonesExamples of a test invocation: 10761db0bdSAndrew Jones These invocations run the msr test case and outputs to stdio. 11761db0bdSAndrew Jones 12761db0bdSAndrew Jones Using qemu-kvm: 13761db0bdSAndrew Jones 14761db0bdSAndrew Jones qemu-kvm -device testdev,chardev=testlog \ 15761db0bdSAndrew Jones -chardev file,id=testlog,path=msr.out \ 16761db0bdSAndrew Jones -serial stdio -kernel ./x86/msr.flat 17761db0bdSAndrew Jones 18761db0bdSAndrew Jones Using qemu (supported since qemu 1.3): 19761db0bdSAndrew Jones 20761db0bdSAndrew Jones qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio \ 21761db0bdSAndrew Jones -device isa-debug-exit,iobase=0xf4,iosize=0x4 \ 22761db0bdSAndrew Jones -kernel ./x86/msr.flat 23761db0bdSAndrew Jones 24761db0bdSAndrew JonesTests in this directory and what they do: 257d36db35SAvi Kivity access: lots of page table related access (pte/pde) (read/write) 267d36db35SAvi Kivity apic: enable x2apic, self ipi, ioapic intr, ioapic simultaneous 277d36db35SAvi Kivity emulator: move to/from regs, cmps, push, pop, to/from cr8, smsw and lmsw 287d36db35SAvi Kivity hypercall: intel and amd hypercall insn 297d36db35SAvi Kivity msr: write to msr (only KERNEL_GS_BASE for now) 30761db0bdSAndrew Jones realmode: goes back to realmode, shld, push/pop, mov immediate, cmp 31761db0bdSAndrew Jones immediate, add immediate, io, eflags instructions 32761db0bdSAndrew Jones (clc, cli, etc.), jcc short, jcc near, call, long jmp, xchg 33761db0bdSAndrew Jones sieve: heavy memory access with no paging and with paging static and 34761db0bdSAndrew Jones with paging vmalloc'ed 357d36db35SAvi Kivity smptest: run smp_id() on every cpu and compares return value to number 367d36db35SAvi Kivity tsc: write to tsc(0) and write to tsc(100000000000) and read it back 37761db0bdSAndrew Jones vmexit: long loops for each: cpuid, vmcall, mov_from_cr8, mov_to_cr8, 38761db0bdSAndrew Jones inl_pmtimer, ipi, ipi+halt 39ce83c7adSJason Wang kvmclock_test: test of wallclock, monotonic cycle and performance of kvmclock 40b44d84daSMao, Junjie pcid: basic functionality test of PCID/INVPCID feature 41761db0bdSAndrew Jones 42761db0bdSAndrew JonesLegacy notes: 43*b2a2aa5dSAndrew Jones The exit status of the binary is inconsistent; with qemu-system, after 44*b2a2aa5dSAndrew Jones the unit-test is done, the exit status of qemu is 1, different from the 45*b2a2aa5dSAndrew Jones 'old style' qemu-kvm, whose exit status in successful completion is 0. 46*b2a2aa5dSAndrew Jones The run script converts the qemu-system exit status to 0 (SUCCESS), and 47*b2a2aa5dSAndrew Jones treats the legacy exit status of 0 as an error, converting it to an exit 48*b2a2aa5dSAndrew Jones status of 1. 49