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 := \ ...@@ -18,7 +18,7 @@ cflatobjs := \
lib/report.o lib/report.o
#include architecure specific make rules #include architecure specific make rules
include config-$(ARCH).mak include config/config-$(ARCH).mak
# cc-option # cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
...@@ -31,7 +31,6 @@ CFLAGS += $(autodepend-flags) -Wall ...@@ -31,7 +31,6 @@ CFLAGS += $(autodepend-flags) -Wall
CFLAGS += $(call cc-option, -fomit-frame-pointer, "") CFLAGS += $(call cc-option, -fomit-frame-pointer, "")
CFLAGS += $(call cc-option, -fno-stack-protector, "") CFLAGS += $(call cc-option, -fno-stack-protector, "")
CFLAGS += $(call cc-option, -fno-stack-protector-all, "") CFLAGS += $(call cc-option, -fno-stack-protector-all, "")
CFLAGS += -I.
CXXFLAGS += $(CFLAGS) CXXFLAGS += $(CFLAGS)
...@@ -46,11 +45,11 @@ $(libcflat): $(cflatobjs) ...@@ -46,11 +45,11 @@ $(libcflat): $(cflatobjs)
%.o: %.S %.o: %.S
$(CC) $(CFLAGS) -c -nostdlib -o $@ $< $(CC) $(CFLAGS) -c -nostdlib -o $@ $<
-include .*.d */.*.d */*/.*.d -include */.*.d */*/.*.d
install: install:
mkdir -p $(DESTDIR) mkdir -p $(DESTDIR)
install $(tests_and_config) $(DESTDIR) install $(tests_and_config) $(DESTDIR)
clean: arch_clean 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. This directory contains sources for a kvm test suite.
Tests for x86 architecture are run as kernel images for qemu that supports multiboot format. To create the test images do
Tests uses an infrastructure called from the bios code. The infrastructure initialize the system/cpu's, ./configure
switch to long-mode and calls the 'main' function of the individual test. make
Tests uses a qemu's virtual test device, named testdev, for services like printing, exiting, query memory size etc. in this directory. Test images are created in ./<ARCH>/*.flat
See file testdev.txt for more details.
Then use the runner script to detect the correct invocation and
To create the tests' images just type 'make' in this directory. invoke the test, e.g.
Tests' images created in ./<ARCH>/*.flat ./x86-run ./x86/msr.flat
or
An example of a test invocation: ./run_tests.sh
Using qemu-kvm: to run them all.
qemu-kvm -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat To select a specific qemu binary, specify the QEMU=<path>
This invocation runs the msr test case. The test outputs to stdio. environment variable, e.g.
QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./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
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.
Directory structure: Directory structure:
.: Makefile and config files for the tests .: configure script, top-level Makefile, and run_tests.sh
./lib: general services for the tests ./config: collection of architecture dependent makefiles
./lib/<ARCH>: architecture dependent services for the tests ./docs: documentation files
./<ARCH>: the sources of the tests and the created objects/images ./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 cstart.o = $(TEST_DIR)/cstart.o
bits = 32 bits = 32
ldarch = elf32-i386 ldarch = elf32-i386
...@@ -7,7 +6,7 @@ CFLAGS += -I $(KERNELDIR)/include ...@@ -7,7 +6,7 @@ CFLAGS += -I $(KERNELDIR)/include
tests = $(TEST_DIR)/taskswitch.flat $(TEST_DIR)/taskswitch2.flat 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)/taskswitch.elf: $(cstart.o) $(TEST_DIR)/taskswitch.o
$(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o $(TEST_DIR)/taskswitch2.elf: $(cstart.o) $(TEST_DIR)/taskswitch2.o
...@@ -21,8 +21,8 @@ CFLAGS += -O1 ...@@ -21,8 +21,8 @@ CFLAGS += -O1
libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name) libgcc := $(shell $(CC) -m$(bits) --print-libgcc-file-name)
FLATLIBS = lib/libcflat.a $(libgcc) FLATLIBS = lib/libcflat.a $(libgcc)
%.elf: %.o $(FLATLIBS) flat.lds %.elf: %.o $(FLATLIBS) x86/flat.lds
$(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds \ $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,x86/flat.lds \
$(filter %.o, $^) $(FLATLIBS) $(filter %.o, $^) $(FLATLIBS)
%.flat: %.elf %.flat: %.elf
......
TEST_DIR=x86
cstart.o = $(TEST_DIR)/cstart64.o cstart.o = $(TEST_DIR)/cstart64.o
bits = 64 bits = 64
ldarch = elf64-x86-64 ldarch = elf64-x86-64
...@@ -11,4 +10,4 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \ ...@@ -11,4 +10,4 @@ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/apic.flat \
tests += $(TEST_DIR)/svm.flat tests += $(TEST_DIR)/svm.flat
tests += $(TEST_DIR)/vmx.flat tests += $(TEST_DIR)/vmx.flat
include config-x86-common.mak include config/config-x86-common.mak
...@@ -62,6 +62,18 @@ while [[ "$1" = -* ]]; do ...@@ -62,6 +62,18 @@ while [[ "$1" = -* ]]; do
;; ;;
esac esac
done 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 # check for dependent 32 bit libraries
cat << EOF > lib_test.c cat << EOF > lib_test.c
...@@ -89,4 +101,5 @@ LD=$cross_prefix$ld ...@@ -89,4 +101,5 @@ LD=$cross_prefix$ld
OBJCOPY=$cross_prefix$objcopy OBJCOPY=$cross_prefix$objcopy
AR=$cross_prefix$ar AR=$cross_prefix$ar
API=$api API=$api
TEST_DIR=$testdir
EOF EOF
#!/bin/bash #!/bin/bash
testroot=x86 if [ ! -f config.mak ]; then
config=$testroot/unittests.cfg echo "run ./configure && make first. See ./configure -h"
qemu=${qemu:-qemu-system-x86_64} exit
fi
source config.mak
config=$TEST_DIR/unittests.cfg
qemu=${QEMU:-qemu-system-$ARCH}
verbose=0 verbose=0
function run() function run()
...@@ -27,7 +32,7 @@ function run() ...@@ -27,7 +32,7 @@ function run()
return return
fi fi
cmdline="./x86-run $kernel -smp $smp $opts" cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
if [ $verbose != 0 ]; then if [ $verbose != 0 ]; then
echo $cmdline echo $cmdline
fi fi
...@@ -65,7 +70,7 @@ function run_all() ...@@ -65,7 +70,7 @@ function run_all()
groups="" groups=""
arch="" arch=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$testroot/${BASH_REMATCH[1]} kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
smp=${BASH_REMATCH[1]} smp=${BASH_REMATCH[1]}
elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
...@@ -92,15 +97,12 @@ Usage: $0 [-g group] [-h] [-v] ...@@ -92,15 +97,12 @@ Usage: $0 [-g group] [-h] [-v]
-h: Output this help text -h: Output this help text
-v: Enables verbose mode -v: Enables verbose mode
Set the environment variable QEMU=/path/to/qemu-system-x86_64 to Set the environment variable QEMU=/path/to/qemu-system-ARCH to
specify the appropriate qemu binary for x86-run. specify the appropriate qemu binary for ARCH-run.
EOF EOF
} }
# As it happens, config.mak is valid shell script code, too :-)
source config.mak
echo > test.log echo > test.log
while getopts "g:hv" opt; do while getopts "g:hv" opt; do
case $opt in 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: 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) Legacy notes:
apic: enable x2apic, self ipi, ioapic intr, ioapic simultaneous The exit status of the binary (and the script) is inconsistent: with
emulator: move to/from regs, cmps, push, pop, to/from cr8, smsw and lmsw qemu-system, after the unit-test is done, the exit status of qemu is 1,
hypercall: intel and amd hypercall insn different from the 'old style' qemu-kvm, whose exit status in successful
msr: write to msr (only KERNEL_GS_BASE for now) completion is 0.
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
#include "libcflat.h" #include "libcflat.h"
#include "lib/x86/desc.h" #include "x86/desc.h"
#include "lib/x86/processor.h" #include "x86/processor.h"
#include "lib/x86/vm.h" #include "x86/vm.h"
#define X86_FEATURE_SMAP 20 #define X86_FEATURE_SMAP 20
#define X86_EFLAGS_AC (1 << 18) #define X86_EFLAGS_AC (1 << 18)
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
#include "libcflat.h" #include "libcflat.h"
#include "lib/x86/desc.h" #include "x86/desc.h"
#define TSS_RETURN (FIRST_SPARE_SEL) #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