Commit 761db0bd authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

clean root dir of all x86-ness



Remove all references to x86 from the root dir (except from in
configure).  Also remove references from the root dir README
by moving that documentation to the x86/README, and touch up
the READMEs at the same time.
Signed-off-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Acked-by: default avatarChristoffer Dall <christoffer.dall@linaro.org>
[Drop --test-dir, adjust includes. - Paolo]
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 1b468b3a
......@@ -18,7 +18,7 @@ cflatobjs := \
lib/report.o
#include architecure specific make rules
include config-$(ARCH).mak
include config/config-$(ARCH).mak
# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
......@@ -31,7 +31,6 @@ CFLAGS += $(autodepend-flags) -Wall
CFLAGS += $(call cc-option, -fomit-frame-pointer, "")
CFLAGS += $(call cc-option, -fno-stack-protector, "")
CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
CFLAGS += -I.
CXXFLAGS += $(CFLAGS)
......@@ -46,11 +45,11 @@ $(libcflat): $(cflatobjs)
%.o: %.S
$(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-include .*.d */.*.d */*/.*.d
-include */.*.d */*/.*.d
install:
mkdir -p $(DESTDIR)
install $(tests_and_config) $(DESTDIR)
clean: arch_clean
$(RM) *.o *.a .*.d lib/.*.d $(libcflat) $(cflatobjs)
$(RM) lib/.*.d $(libcflat) $(cflatobjs)
This directory contains sources for a kvm test suite.
Tests for x86 architecture are run as kernel images for qemu that supports multiboot format.
Tests uses an infrastructure called from the bios code. The infrastructure initialize the system/cpu's,
switch to long-mode and calls the 'main' function of the individual test.
Tests uses a qemu's virtual test device, named testdev, for services like printing, exiting, query memory size etc.
See file testdev.txt for more details.
To create the tests' images just type 'make' in this directory.
Tests' images created in ./<ARCH>/*.flat
An example of a test invocation:
Using qemu-kvm:
qemu-kvm -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat
This invocation runs the msr test case. The test outputs to stdio.
Using qemu (supported since qemu 1.3):
qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat
Note that it's not necessary to specify the "-m" option to qemu. The default
memory size is enough. Actually, the tests infrastructure doesn't support too
much RAM anyway, so specifying a large amount of RAM may break it.
Or use a runner script to detect the correct invocation:
./x86-run ./x86/msr.flat
To select a specific qemu binary, specify the QEMU=<path> environment:
QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
The exit status of the binary (and the script) is inconsistent: with
qemu-system, after the unittest is done, the exit status of qemu is 1,
different from the 'old style' qemu-kvm, whose exit status in successful
completion is 0.
To create the test images do
./configure
make
in this directory. Test images are created in ./<ARCH>/*.flat
Then use the runner script to detect the correct invocation and
invoke the test, e.g.
./x86-run ./x86/msr.flat
or
./run_tests.sh
to run them all.
To select a specific qemu binary, specify the QEMU=<path>
environment variable, e.g.
QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
Directory structure:
.: Makefile and config files for the tests
./lib: general services for the tests
./lib/<ARCH>: architecture dependent services for the tests
./<ARCH>: the sources of the tests and the created objects/images
.: configure script, top-level Makefile, and run_tests.sh
./config: collection of architecture dependent makefiles
./docs: documentation files
./lib: general architecture neutral services for the tests
./lib/<ARCH>: architecture dependent services for the tests
./<ARCH>: the sources of the tests and the created objects/images
See <ARCH>/README for architecture specific documentation.
TEST_DIR=x86
cstart.o = $(TEST_DIR)/cstart.o
bits = 32
ldarch = elf32-i386
......@@ -7,7 +6,7 @@ CFLAGS += -I $(KERNELDIR)/include
tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat
include config-x86-common.mak
include config/config-x86-common.mak
$(TEST_DIR)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o
......@@ -21,8 +21,8 @@ CFLAGS += -O1
libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
FLATLIBS = lib/libcflat.a $(libgcc)
%.elf: %.o $(FLATLIBS) flat.lds
$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds \
%.elf: %.o $(FLATLIBS) x86/flat.lds
$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
$(filter %.o, $^) $(FLATLIBS)
%.flat: %.elf
......
TEST_DIR=x86
cstart.o = $(TEST_DIR)/cstart64.o
bits = 64
ldarch = elf64-x86-64
......@@ -11,4 +10,4 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
tests += $(TEST_DIR)/svm.flat
tests += $(TEST_DIR)/vmx.flat
include config-x86-common.mak
include config/config-x86-common.mak
......@@ -62,6 +62,18 @@ while [[ "$1" = -* ]]; do
;;
esac
done
if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then
testdir=x86
else
testdir=$arch
fi
if [ ! -d $testdir ]; then
echo "$testdir does not exist!"
exit 1
fi
if [ -f $testdir/run ]; then
ln -fs $testdir/run $testdir-run
fi
# check for dependent 32 bit libraries
cat << EOF > lib_test.c
......@@ -89,4 +101,5 @@ LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy
AR=$cross_prefix$ar
API=$api
TEST_DIR=$testdir
EOF
#!/bin/bash
testroot=x86
config=$testroot/unittests.cfg
qemu=${qemu:-qemu-system-x86_64}
if [ ! -f config.mak ]; then
echo "run ./configure && make first. See ./configure -h"
exit
fi
source config.mak
config=$TEST_DIR/unittests.cfg
qemu=${QEMU:-qemu-system-$ARCH}
verbose=0
function run()
......@@ -27,7 +32,7 @@ function run()
return
fi
cmdline="./x86-run $kernel -smp $smp $opts"
cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
if [ $verbose != 0 ]; then
echo $cmdline
fi
......@@ -65,7 +70,7 @@ function run_all()
groups=""
arch=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$testroot/${BASH_REMATCH[1]}
kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
smp=${BASH_REMATCH[1]}
elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
......@@ -92,15 +97,12 @@ Usage: $0 [-g group] [-h] [-v]
-h: Output this help text
-v: Enables verbose mode
Set the environment variable QEMU=/path/to/qemu-system-x86_64 to
specify the appropriate qemu binary for x86-run.
Set the environment variable QEMU=/path/to/qemu-system-ARCH to
specify the appropriate qemu binary for ARCH-run.
EOF
}
# As it happens, config.mak is valid shell script code, too :-)
source config.mak
echo > test.log
while getopts "g:hv" opt; do
case $opt in
......
This file describes the virtual device of qemu for supporting this test suite.
Services supplied by the testdev device:
serial output: write only, on io port 0xf1
exit process: write only, on io port 0xf4, value used as exit code
ram size: read-only, on io port 0xd1, 4 bytes' size
irq line setting: write only, on io ports 0x2000 - 0x2018, value to set/clear
simple io: read/write, on io port 0xe0, 1/2/4 bytes
Test device used a char device for actual output
Tests for the x86 architecture are run as kernel images for qemu that support
multiboot format. The tests use an infrastructure called from the bios code.
The infrastructure initialize the system/cpus, switches to long-mode, and
calls the 'main' function of the individual test. Tests use a qemu virtual
test device, named testdev, for services like printing, exiting, querying
memory size, etc. See file docs/testdev.txt for more details.
Examples of a test invocation:
These invocations run the msr test case and outputs to stdio.
Using qemu-kvm:
qemu-kvm -device testdev,chardev=testlog \
-chardev file,id=testlog,path=msr.out \
-serial stdio -kernel ./x86/msr.flat
Using qemu (supported since qemu 1.3):
qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio \
-device isa-debug-exit,iobase=0xf4,iosize=0x4 \
-kernel ./x86/msr.flat
Tests in this directory and what they do:
access: lots of page table related access (pte/pde) (read/write)
apic: enable x2apic, self ipi, ioapic intr, ioapic simultaneous
emulator: move to/from regs, cmps, push, pop, to/from cr8, smsw and lmsw
hypercall: intel and amd hypercall insn
msr: write to msr (only KERNEL_GS_BASE for now)
port80: lots of out to port 80
realmode: goes back to realmode, shld, push/pop, mov immediate, cmp
immediate, add immediate, io, eflags instructions
(clc, cli, etc.), jcc short, jcc near, call, long jmp, xchg
sieve: heavy memory access with no paging and with paging static and
with paging vmalloc'ed
smptest: run smp_id() on every cpu and compares return value to number
tsc: write to tsc(0) and write to tsc(100000000000) and read it back
vmexit: long loops for each: cpuid, vmcall, mov_from_cr8, mov_to_cr8,
inl_pmtimer, ipi, ipi+halt
kvmclock_test: test of wallclock, monotonic cycle and performance of kvmclock
pcid: basic functionality test of PCID/INVPCID feature
access: lots of page table related access (pte/pde) (read/write)
apic: enable x2apic, self ipi, ioapic intr, ioapic simultaneous
emulator: move to/from regs, cmps, push, pop, to/from cr8, smsw and lmsw
hypercall: intel and amd hypercall insn
msr: write to msr (only KERNEL_GS_BASE for now)
port80: lots of out to port 80
realmode: goes back to realmode, shld, push/pop, mov immediate, cmp immediate, add immediate,
io, eflags instructions (clc, cli, etc.), jcc short, jcc near, call, long jmp, xchg
sieve: heavy memory access with no paging and with paging static and with paging vmalloc'ed
smptest: run smp_id() on every cpu and compares return value to number
tsc: write to tsc(0) and write to tsc(100000000000) and read it back
vmexit: long loops for each: cpuid, vmcall, mov_from_cr8, mov_to_cr8, inl_pmtimer, ipi, ipi+halt
kvmclock_test: test of wallclock, monotonic cycle and performance of kvmclock
pcid: basic functionality test of PCID/INVPCID feature
\ No newline at end of file
Legacy notes:
The exit status of the binary (and the script) is inconsistent: with
qemu-system, after the unit-test is done, the exit status of qemu is 1,
different from the 'old style' qemu-kvm, whose exit status in successful
completion is 0.
#include "libcflat.h"
#include "lib/x86/desc.h"
#include "lib/x86/processor.h"
#include "lib/x86/vm.h"
#include "x86/desc.h"
#include "x86/processor.h"
#include "x86/vm.h"
#define X86_FEATURE_SMAP 20
#define X86_EFLAGS_AC (1 << 18)
......
......@@ -6,7 +6,7 @@
*/
#include "libcflat.h"
#include "lib/x86/desc.h"
#include "x86/desc.h"
#define TSS_RETURN (FIRST_SPARE_SEL)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment