Due to our kernel heritage we have code in kvmtool that relies on
the (still) implicit -std=gnu89 compiler switch.
It turns out that this just affects some structure initialization,
where we currently provide a cast to the type, which upsets GCC for
anything beyond -std=gnu89 (for instance gnu99 or gnu11).
We do need the casts when initializing structures that are not
assigned to the same type, so we put it there explicitly.
This allows us to compile with all the three GNU standards GCC
currently supports: gnu89/90, gnu99 and gnu11.
GCC threatens people with moving to gnu11 as the new default standard,
so lets fix this better sooner than later.
(Compiling without GNU extensions still breaks and I don't bother to
fix that without very good reasons.)
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
When including asm-generic/types.h instead of asm/types.h it results
in conflicting types for __s64 et al (at least with my
toolchain). Other header files are including asm/types.h
(e.g. include/kvm/ioport.h) and types defined there don't necessarily
match the types defined in asm-generic/types.h.
Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
In util/iovec.c we reference EXPORT_SYMBOL, which is only useful
within the kernel. To get rid of the dummy include file, simply
remove those lines.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
For x86 the files that become the BIOS blob are compiled with -m32.
Although we avoid including any system libraries, we use some headers
from /usr/include, which asks for trouble if compiling on a x86-64
multiarch system (Debian/Ubuntu). Without 32-bit compat headers
installed there, the compiler will not find the right files.
However as the BIOS code is actually a self-contained binary without
any relationship to the Linux userland, it should not use or rely
on Linux system headers.
Replace includes of linux/types.h in BIOS code with asm/bios/types.h,
which simply contains the u{8,16,32,64} data types needed by the code.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The 9p kernel code uses separate types for uid_t and gid_t. To avoid
changing too much code needlessly, copy over the kernel definitions
from uidgid.h into 9p.h.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The special Linux poison bits do not make sense in userland, so
just replace them with NULL to spot bogus accesses.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The ARM part requires psci.h, which is pretty recent, so older
distributions might not carry it. This pulls in sizes.h, which is not
an uapi header, but quite convenient and not really Linux specific.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Some distributions with an older uapi header copy do not have all the
definitions that we need (Ubuntu 12.04 comes to mind).
So copy the latest versions from the Linux tree to override the system
header versions.
Also include virtio_mmio.h, which is technically not an uapi header,
but is used in such a way. QEMU has actually a copy of these
definitions in its own header file, so our approach should even be
better.
Those files are from a Linux v4.1-rc6 source tree, but the virtio-1.0
updates have been left out. kvmtool implements only the older version
of virtio.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
This file includes 9P protocol definitions which we need.
Copy them from a recent Linux tree.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
The uapi copy of kvm.h is usually outdated, so copy over a fresh copy
from the Linux v4.1-rc6 source tree. This exercise should later be
repeated when new kvmtool code requires this.
It seems to be common practise in QEMU to do so.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Instead of moving the whole include file in, we just copy the needed
definitions from byteorder/generic.h into the kvmtool headers.
This avoids needless clutter of the include directory.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
This is not really Linux specific, just a neat implementation
used by kvmtool, too.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Copy some non-Linux specific header files over to the kvmtool
directory. This includes generic helpers like stringify and list
definitions.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
They're hidden inside net/core/iovec.c. It'd be nice to just link to that
but they're not too generic and come with tons of net/ specific code we
don't want. So we just copy over the relevant parts.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
linux/compiler.h will never give us a definition for __compiler_offsetof
because __KERNEL__ isn't defined, so just use the simple definition that
we have already.
This patch removes the redundant code.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
There were a number of changes that caused problems:
- UAPI conversion
- the old version of the rbtree-augmented API got removed, I
updated the implementation to the new API
- lib/rbtree.c wants a 'true' definition
Lightly tested: it boots a v3.7-rc1 defconfig+kvmconfig kernel.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch brings virito-scsi support to kvm tool.
With the introduce of tcm_vhost (vhost-scsi)
tcm_vhost: Initial merge for vhost level target fabric driver
we can implement virito-scsi by simply having vhost-scsi to handle the
SCSI command.
Howto use:
1) Setup the tcm_vhost target through /sys/kernel/config
[Stefan Hajnoczi, Thanks for the script to setup tcm_vhost]
** Setup wwpn and tpgt
$ wwpn="naa.0"
$ tpgt=/sys/kernel/config/target/vhost/$wwpn/tpgt_0
$ nexus=$tpgt/nexus
$ mkdir -p $tpgt
$ echo -n $wwpn > $nexus
** Setup lun using /dev/ram
$ n=0
$ lun=$tpgt/lun/lun_${n}
$ data=/sys/kernel/config/target/core/iblock_0/data_${n}
$ ram=/dev/ram${n}
$ mkdir -p $lun
$ mkdir -p $data
$ echo -n udev_path=${ram} > $data/control
$ echo -n 1 > $data/enable
$ ln -s $data $lun
2) Run kvm tool with the new disk option '-d scsi:$wwpn:$tpgt', e.g
$ lkvm run -k /boot/bzImage -d ~/img/sid.img -d scsi:naa.0:0
Signed-off-by: Asias He <asias.hejun@gmail.com>
Cc: Nicholas A. Bellinger <nab@linux-iscsi.org>
Cc: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Commit 2084c24 ("do not export kernel's NULL #define to userspace") broken KVM
tool build:
FYI:
CC framebuffer.o
In file included from include/kvm/framebuffer.h:5:0,
from framebuffer.c:1:
../../include/linux/list.h: In function ‘INIT_HLIST_NODE’:
../../include/linux/list.h:572:12: error: ‘NULL’ undeclared (first use in this function)
../../include/linux/list.h:572:12: note: each undeclared identifier is reported only once for each function it appears in
../../include/linux/list.h: In function ‘hlist_move_list’:
../../include/linux/list.h:657:15: error: ‘NULL’ undeclared (first use in this function)
make: *** [framebuffer.o] Error 1
due to this upstream commit:
2084c24a8141 do not export kernel's NULL #define to userspace
Fix that.
Reported-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
In file included from ../../include/linux/stddef.h:4:0,
from ../../include/linux/list.h:5,
from include/kvm/framebuffer.h:5,
from builtin-run.c:8:
include/linux/compiler.h:8:0: error: "__attribute_const__" redefined [-Werror]
/usr/include/sys/cdefs.h:226:0: note: this is the location of the previous definition
cc1: all warnings being treated as errors
make: *** [builtin-run.o] Error 1
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Add compiler.h file to support using kernel error check funciotns(e.g
ERR_PTR, PTR_ERR and so on).
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvmtool's types.h includes <asm/types.h>, which by default on PPC64 brings in
int-l64.h; define __SANE_USERSPACE_TYPES__ to get LL64 types.
This patch also adds CFLAGS to the final link, so that any -m64 is obeyed
when linking, too.
Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Ingo reported a build breakage caused by absence of 'notrace' definition. Fix
it by adding compiler.h into own headers set.
Reported-by: Ingo Molnar <mingo@elte.hu>
Tested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Interval rb-tree allows to directly store interval ranges
and quickly lookup an overlap with a single point or a range.
The helper is based on the kernel rb-tree implementation
(located in <linux/rbtree.h>) which alows for the augmention
of the classical rb-tree to be used as an interval tree.
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Instead of having static definitions of devices, Use a
dynamic registry of pci devices.
The structure is a rbtree which holds device types (net,
blk, etc). Each device entry holds a list of IRQ lines
associated with that device (pin).
Devices dynamically register upon initialization, and receive
a set of: device id, irq pin and irq line.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Provide wrappers and other environmental dependencies that the
asm/system.h header file from hell needs to build fine in user-space.
Sidenote: right now alternative() defaults to the compatible, slightly
slower barrier instructions that work on all x86 systems.
If this ever shows up in profiles then kvm could provide an alternatives
patching machinery as well. Right now those instructions are emitted
into special sections and then discarded by the linker harmlessly.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Adds kernel headers so that <linux/list.h> (and others) could be included
directly.
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Make the MIN_RAM_SIZE_MB constant 64-bit on 32-bit systems as well, otherwise
we get this build failure:
kvm-run.c: In function ‘kvm_cmd_run’:
kvm-run.c:119: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘u64’
Also adjust affected printf format string - this necessiates the use of
the sane Linux definition of u64 instead of the brain-dead int64_t
variant.
That also allows (and necessiates) the removal of the ugly PRIu64 format
string hackery. Friends don't let friends use PRI* hackeries! :-)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
This patch adds KVM ABI headers to the source tree. We can no longer include
<linux/kvm.h> directly because someone added a "#warning" to <linux/types.h>
that prevents kernel header inclusion from userspace.
We can switch back to using kernel headers if we ever make it to Linux
mainline.
Signed-off-by: Pekka Enberg <penberg@kernel.org>