Fix compilation on older compilers.

%d0 constrain is wrong, rely on variable length to choose correct
register instead.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
realmode: test SAHF instruction

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
kvm-unit-test: fix cpuid test

If cpuid is called with function value greater than max supported one
max supported value is used instead and index parameter is honored. That
is why we need to initialize index to same value in the test to get
same result from both cpuid invocations.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Fix x86/eventinj.c test compilation on 32bit

Tested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
remove unused files

There are several unused files, primarily because powerpc is an unused
arch. The exceptions are config-ia64.mak, which is also an unused arch
file, lib/fwcfg.c, lib/panic.c, x86/print.h and x86/run-kvm-unit-tests,
which are just unused. Remove them all in order to tidy things up.

Signed-off-by: Andrew Jones <drjones@redhat.com>
makefile and run_tests tweaks

- remove a redundant '-display none'
- remove a redundant -g from CFLAGS
- remove a useless -I../include/x86 from CFLAGS
- remove lib autodep files on make clean

Signed-off-by: Andrew Jones <drjones@redhat.com>
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 <drjones@redhat.com>
README touchup

Signed-off-by: Andrew Jones <drjones@redhat.com>
Introduce a simple iomap structure

Add a simple structure and search function to the common code that
can be used for looking up a set of addresses by type. The user
must supply the iomaps[] table, e.g.

struct iomap iomaps[] = {
{
    .type = "virtio_mmio",
    .nr = 4,
    .addrs = { 0x2000000, 0x2000200, 0x2000400, 0x2000600, },
},
{
    .type = NULL,
},
};

Also add a script scripts/gen-devtree-iomaps.pl that can generate
the iomaps table from an fdt, e.g.

fdtdump dtb | scripts/gen-devtree-iomaps.pl - virtio_mmio

Signed-off-by: Andrew Jones <drjones@redhat.com>
Add halt() and some error codes

Add a halt function that can be used by the test infrastructure on error
paths before exit() works. Also add some error codes that can be passed
to halt() in case the serial isn't working either. Then, on register
inspection of the halted guest we may be able to quickly determine the
problem without having to find the halt() call-site using its return
address.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Introduce virtio-testdev

virtio-testdev is a communication channel to qemu through virtio that
can be used by test code to send commands. The only command currently
implemented is EXIT, which allows the test code to exit with a given
status code.

Signed-off-by: Andrew Jones <drjones@redhat.com>
iomaps: fix coding style

Signed-off-by: Andrew Jones <drjones@redhat.com>
rework iomaps to get and search compatible strings

Signed-off-by: Andrew Jones <drjones@redhat.com>
rework errnos

Signed-off-by: Andrew Jones <drjones@redhat.com>
make simple x86 heap common

Signed-off-by: Andrew Jones <drjones@redhat.com>
rework virtio-testdev

- readl/writel framework
- better virtio abstraction

Signed-off-by: Andrew Jones <drjones@redhat.com>
Merge branch 'virtio-testdev' of https://github.com/rhdrjones/kvm-unit-tests into virtio-testdev
merge fixups

Signed-off-by: Andrew Jones <drjones@redhat.com>
arm: replace arbitrary divisions

arm can't do arbitrary divisions without software support. Usually
libgcc would jump in here, but depending on the toolchain used that may
or may not work. Luckily, we only care about two types of divisions.
Divide by 10 and divide by 16. Divide by 16 is already covered by gcc
since it's a power of two. Divide by 10 can be hacked up using a
multiplication and shift.

Signed-off-by: Andrew Jones <drjones@redhat.com>
arm: initial drop

This is the initial arm test infrastructure and a first test that
simply checks some bootinfo. kvm isn't needed to run this test. This
patch also adds a common build environment variable, $QEMU_BIN, which
allows makefiles to call on qemu when needed.

Try it out with
  yum install gcc-arm-linux-gnu dtc
  export QEMU=[qemu with mach-virt and virtio-testdev]
  ./configure --cross-prefix=arm-linux-gnu- --arch=arm
  make
  ./run_tests.sh

Signed-off-by: Andrew Jones <drjones@redhat.com>