93 Commits

Author SHA1 Message Date
James Hunt 37eab77bea Merge branch 'upstream'
Signed-off-by: James Hunt <james.o.hunt@intel.com>
2015-11-04 13:24:07 +00:00
Oleg Nesterov 5614f9d933 kvmtool/x86: implement guest_pre_init
Add the tiny x86/init.S which just mounts /host and execs
/virt/init.

NOTE: of course, the usage of CONFIG_GUEST_PRE_INIT is ugly, we
need to cleanup this code. But I'd prefer to do this on top of
this minimal/simple change. And I think this needs cleanups in
any case, for example I think lkvm shouldn't abuse the "init="
kernel parameter at all.

Acked-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-10-27 17:03:37 +00:00
Fan Du b1ef6ede7b kvmtool: {x86} Add initrd support when loading elf kernel
Signed-off-by: Fan Du <fan.du@intel.com>
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
2015-10-23 14:32:51 +01:00
Dimitri John Ledkov e0b5a5d99c Fix compilation with old kernel headers.
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
2015-09-04 16:09:56 +01:00
Dimitri John Ledkov fdd5905807 Move more messages to debug. 2015-09-04 16:09:35 +01:00
Dimitri John Ledkov 70ca8618d8 x86: fix build failure with 4.1 kernels. 2015-07-15 13:06:38 +01:00
Dimitri John Ledkov 7a5e69fb4d kvmtool: make vmlinux support patch compile in the stand alone kvmtool. 2015-07-15 12:51:53 +01:00
Jim Kukunas a8dee709f8 lkvm: support booting into 64-bit vmlinux
TODO: mmap kernel
TODO: 32-bit
2015-07-15 02:01:50 +01:00
Arjan van de Ven 9c69d4ab47 Use a differently garbled CPU ID string 2015-07-15 02:01:50 +01:00
Arjan van de Ven dcc48d65e8 kvmtool: expose the TSC Deadline Timer feature to the guest
with the TSC deadline timer feature, we don't need to calibrate the apic
timers anymore, which saves more than 100 milliseconds of boot time.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
2015-07-15 02:01:50 +01:00
Andre Przywara 9759db0dd9 kvmtool: move include/bios/memcpy.h to x86/include/asm/bios
This file contains a prototype solely used by the BIOS blob code
for x86 systems. Make this clear by moving the include file into
the x86 directory.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 17:54:09 +01:00
Andre Przywara 813359ed4a kvmtool: add processor-flags.h with the single EFLAGS_CF define
Two BIOS source files used a definition from <asm/processor-flags.h>,
which could not be found on x86_64 multiarch machines without the
compat headers installed.
Create a file with the single definition actually used in the kvmtool
source tree.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 17:54:09 +01:00
Andre Przywara 1cbb2c50ce kvmtool: remove kvm/segment.h
This header just holds three trivial functions, but pulls in
linux/types.h, which calls for trouble when compiling BIOS files on
x86-64 multiarch machines.
Remove unnecessary includes and move the definitions into the files
where they are used.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 17:54:09 +01:00
Andre Przywara f323796502 kvmtool: pull x86 system header e820 definitions into kvm/e820.h
The x86 BIOS code included some definitions for the E820 table from
the Linux system headers, but those could not be found on x86_64
multiarch systems without the compat headers installed.
Pull the required definitions into the kvmtool source directory,
removing the reference to <asm/e820.h>.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 17:54:09 +01:00
Andre Przywara f23171ca13 kvmtool: remove reference to <asm/types.h> from BIOS include files
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>
2015-06-01 17:54:09 +01:00
Andre Przywara 2332392901 kvmtool: x86: Copy some Linux architecture specific headers
Although those header files are technically Linux internal, they
hold definitions for x86 hardware related bits (APIC, MPSPEC, VESA).
We just reuse their definitions, so copy those files over.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 16:40:11 +01:00
Andre Przywara 6002122071 kvmtool: Update architecture specific kvm.h files
Similarily to the generic uapi/linux/kvm.h, each architecture
carries a kvm.h header in its arch/*/include/uapi/asm directory.
These contain bits for the architecture specific interface.
Since we use many recent features in kvmtool, the system headers
provided by the distribution are usually not up-to-date.
Copy the Linux v4.1-rc6 versions of those files for all supported
architectures into the kvmtool tree to get access to the full glory.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
2015-06-01 16:40:11 +01:00
Andreas Herrmann b5a5cd6735 kvm tools: Provide per arch macro to specify type for KVM_CREATE_VM
This is is usually 0 for most archs. On mips we have two types.
TE (type 0) and MIPS-VZ (type 1). Default to 1 on mips.

Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Marc Zyngier 4123ca555b kvmtool: virtio: pass trapped vcpu to IO accessors
The recent introduction of bi-endianness on arm/arm64 had the
odd effect of breaking virtio-pci support on these platforms, as the
device endian field defaults to being VIRTIO_ENDIAN_HOST, which
is the wrong thing to have on a bi-endian capable architecture.

The fix is to check for the endianness on the ioport path the
same way we do it for mmio, which implies passing the vcpu all
the way down. Patch is a bit ugly, but aligns MMIO and ioport nicely.

Tested on arm64 and x86.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Marc Zyngier 9b7359101f kvmtool: pass trapped vcpu to MMIO accessors
In order to be able to find out about the endianness of a virtual
CPU, it is necessary to pass a pointer to the kvm_cpu structure
down to the MMIO accessors.

This patch just pushes such pointer as far as required for the
MMIO accessors to have a play with the vcpu.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon d97dadecbd kvm tools: ARM: allow default virtio transport to be passed on cmdline
This patch changes VIRTIO_DEFAULT_TRANS to take a struct kvm parameter,
allowing architectures to choose the default transport dynamically.

For ARM, this is driven by an arch-specific cmdline option.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon 9dc5430ce7 kvm tools: irq: make irq__alloc_line generic
All architectures are now doing the same thing for irq__alloc_line:

  1. Initialise a global counter to some fixed offset
  2. Return the current value of the counter and increment it

This is better off in core code, with each architecture specifying the
initial offset, which is specific to the interrupt controller being used
by the guest.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon 1178dd4db3 kvm tools: irq: rename irq__register_device to irq__alloc_line
Since irq__register_device no longer registers a device with anything,
rename it to irq__alloc_line, which better describes what is actually
going on.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon 7f542b0f39 kvm tools: irq: remove remaining parameters to irq__register_device
With the removal of the x86 irq rbtree, the only parameter used by
irq__register_device is actually used to return the new line.

This patch removes all of the parameters from irq__register_device and
returns the allocated line directly.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon f83cd1611d kvm tools: irq: replace the x86 irq rbtree with the PCI device tree
The x86 code keeps its own rbtree of PCI devices in order to allocate
interrupts. However, this functionality can be moved into the generic
PCI device tree and be reused by other architectures.

This patch removes the x86 tree and reworks the ACPI mptable generation
to use the PCI device tree for enumerating the bus.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon 2d6c72df83 kvm tools: irq: remove pin parameter from irq__register_device
In preparation for moving the irq allocation into generic code, remove
the pin parameter from irq__register_device and temporarily place the
onus on the emulation driver to allocate the pin (which is always 1 and
only used on PCI anyway).

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Will Deacon b403f2f7f7 kvm tools: pci: register 24-bit configuration space below MMIO region
Rather than performing all config accesses via ioports, map in a 24-bit
memory-mapped configuration space directly below the PCI MMIO region.

This will allow architectures to support PCI without having to support
legacy ioports in the guest kernel. Instead, kvm tool can forward the
config accesses directly to the relevant ioport config callbacks.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:55 +01:00
Cyrill Gorcunov 7800e6fa9b kvm tools: Don't disable PerfMon if host does not support it
KVM provides of PMU with architectural events, so don't disable
the NMI drivent based performance events when they are available
on the host.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
Cc: Asias He <asias.hejun@gmail.com>
2015-06-01 16:39:54 +01:00
Jonathan Austin 12c406a801 kvm tools: remove periodic tick in favour of a polling thread
Currently the only use of the periodic timer tick in kvmtool is to
handle reading from stdin. Though functional, this periodic tick can be
problematic on slow (eg FPGA) platforms and can cause low interactivity or
even stop the execution from progressing at all.

This patch removes the periodic tick in favour of a dedicated thread blocked
waiting for input from the console. In order to reflect the new behaviour,
the old 'kvm__arch_periodic_tick' function is renamed to 'kvm__arch_read_term'.

In making this change it is necessary to actively flush the emulated serial
console's output buffer after the guest writes to it, as otherwise flushing
only happens with terminal input. Similarly, it is no longer necessary to
flush the buffer when we process input.

Signed-off-by: Jonathan Austin <jonathan.austin@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Pekka Enberg 48bed025ff kvmtool, seabios: Ignore BIOS POST legacy registers
This makes SeaBIOS limp along all the way to boot menu:

  [penberg@tux kvm]$ ./vm run --firmware /usr/share/seabios/bios.bin
    # lkvm run -k ../../arch/x86/boot/bzImage -m 448 -c 4 --name guest-11658
  Start bios (version 0.6.0)
  Unable to unlock ram - bridge not found
  Ram Size=0x00100000 (0x0000000000000000 high)
  CPU Mhz=13
  Found 1 cpu(s) max supported 1 cpu(s)
  PCI: bus=0 devfn=0x08: vendor_id=0x1af4 device_id=0x1009
  PCI: bus=0 devfn=0x10: vendor_id=0x1af4 device_id=0x1009
  PCI: bus=0 devfn=0x18: vendor_id=0x1af4 device_id=0x1000
  region 0: 0x00000000
  region 1: 0x00000000
  WARNING - Unable to allocate resource at mptable_init:26!
  WARNING - Unable to allocate resource at smbios_init:381!
  Scan for VGA option rom
  WARNING - Timeout at i8042_wait_read:35!
  Found 2 lpt ports
  Found 4 serial ports
  Scan for option roms
  Press F12 for boot menu.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Cyrill Gorcunov bc0b99a2a7 kvm tools: Filter out CPU vendor string
Ingo Molnar reports unhandled MSR reads on an AMD machine:

  [1709265.368464] kvm: 25706: cpu6 unhandled rdmsr: 0xc0010048
  [1709265.397161] kvm: 25706: cpu7 unhandled rdmsr: 0xc0010048
  [1709265.425774] kvm: 25706: cpu8 unhandled rdmsr: 0xc0010048

  processor       : 11
  vendor_id       : AuthenticAMD
  cpu family      : 16
  model           : 8
  model name      : AMD Engineering Sample
  stepping        : 0
  cpu MHz         : 2400.000
  cache size      : 512 KB
  physical id     : 1
  siblings        : 6
  core id         : 5
  cpu cores       : 6
  apicid          : 21
  initial apicid  : 13
  fpu             : yes
  fpu_exception   : yes
  cpuid level     : 5
  wp              : yes
  flags           : fpu vme de pse tsc msr pae mce cx8 apic sep
  mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall
  nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc
  rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt
  lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse
  3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock
  nrip_save pausefilter
  bogomips        : 4800.01
  TLB size        : 1024 4K pages
  clflush size    : 64
  cache_alignment : 64
  address sizes   : 48 bits physical, 48 bits virtual
  power management: ts ttp tm stc 100mhzsteps hwpstate

and Asias He reports guest not booting on an AMD machine:

  processor       : 0
  vendor_id       : AuthenticAMD
  cpu family      : 21
  model           : 1
  model name      : AMD Opteron(TM) Processor 6274
  stepping        : 2
  microcode       : 0x6000626
  cpu MHz         : 2200.034
  cache size      : 2048 KB
  physical id     : 0
  siblings        : 16
  core id         : 0
  cpu cores       : 8
  apicid          : 32
  initial apicid  : 0
  fpu             : yes
  fpu_exception   : yes
  cpuid level     : 13
  wp              : yes
  flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge
  mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext
  fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc
  extd_apicid amd_dcm aperfmperf pni pclmulqdq monitor ssse3 cx16 sse4_1
  sse4_2 popcnt aes xsave avx lahf_lm cmp_legacy svm extapic cr8_legacy
  abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt lwp fma4
  nodeid_msr topoext perfctr_core perfctr_nb arat cpb hw_pstate npt lbrv
  svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists
  pausefilter pfthreshold
  bogomips        : 4400.06
  TLB size        : 1536 4K pages
  clflush size    : 64
  cache_alignment : 64
  address sizes   : 48 bits physical, 48 bits virtual
  power management: ts ttp tm 100mhzsteps hwpstate cpb

If CPU vendor string is not filetered in case of host AMD machine we get
unhandled MSR reads. Thus provide own string and kernel will use generic
CPU init.

Reported-by: Ingo Molnar <mingo@kernel.org>
CC: Sasha Levin <sasha.levin@oracle.com>
Tested-by: Asias He <asias@redhat.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
[ penberg@kernel.org: improve changelog ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Will Deacon 206c41f433 kvm tools: ioport: add arch callback to remap IRQ lines for ioport devices
If an architecture other than x86 wants to make use of ioport devices, the
interrupt lines will likely need remapping from their fixed values.

This patch allows an architecture callback, ioport__map_irq, to map
interrupts as appropriate.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Will Deacon dbfef85064 kvm tools: allow ioports to be offset from 0
Architectures without a legacy ioport may wish to emulate one, but not
at address 0x0.

This patch introduces KVM_IOPORT_AREA, which each architecture defines
to be the start of the ioport region (i.e. where port addresses are
offset from).

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Pekka Enberg 7bcceb95fd kvm tools: Initial GTK+ 3.0 UI
It's barely usable but it isn't getting any better sitting alone in a
private git branch.

You can start a new VM with the GTK UI like this:

  ./vm run --gtk

It's rough around the edges:

- Red and blue color channels are inverted.
- Some keys do not work.
- Mouse does not work.
- GTK assertion failure pops up on shutdown.

but I'm sure there's someone out there that's just dying to improve the
user experience.

Cc: Asias He <asias.hejun@gmail.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Asias He 6ad7171a69 kvm tools: Fix SDL and VNC by setting vidmode correctly
In commit dfefbe9d4894efc44c39b2041bd667d0dea43eca
kvm tools: allow arch's to provide their own command-line options,
vidmode is not setup correctly.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Asias He b2cf1e9f5f kvm tools: Beautify debug output
1. print mem debug info into debugfd instead guest console
2. always print page table info

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:54 +01:00
Will Deacon ff7ba6faee kvm tools: allow arch's to provide their own command-line options
Currently, only x86 has architecture command-line options (for setting
the BIOS video mode) however this is likely to become more common in the
future.

This patch adds some simple macros and a struct definition to allow
architectures to augment the command-line options with private
definitions. The BIOS video mode option (--vidmode) is also migrated to
the new framework.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Will Deacon f412251f98 kvm tools: teach guest_flat_to_host about memory banks starting above 0
Running a guest with multiple banks of memory based above 0 causes the
guest_flat_to_host address conversion to fail, as it is assumed that
guest memory addresses are offset linearly from 0.

This patch changes the translation function so that the kvm_mem_bank
structures registered by kvm__register_mem are used to translate guest
addresses, rather than use an offset from the start of host memory.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Will Deacon 21ff329de8 kvm tools: add generic device registration mechanism
PCI devices are currently registered into the pci_devices array via the
pci__register function, which can then be indexed later by architecture
code to construct device tree nodes. For MMIO devices, there is no such
utility.

Rather than invent a similar mechanism for MMIO, this patch creates a
global device registration mechanism, which allows the device type to be
specified when registered or indexing a device. Current users of the pci
registration code are migrated to the new infrastructure and virtio MMIO
devices are registered at init time.

As part of the device registration, allocation of the device number is
moved out of irq__register_device and performed when adding the device
header to the relevant bus tree, allowing us to maintain separate device
numberspaces for each bus.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Will Deacon ae06ce7165 kvm tools: allow arch to specify default virtio transport
Some architectures may provide only a restricted PCI implementation and
therefore prefer MMIO as the transport for virtio devices.

This patch allows the arch backend to specify the default virtio
transport. Some devices (e.g. net) allow the transport to be overriden
by the user and are left alone by this change.

Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Pekka Enberg 60e1cb554b kvm tools: Fast A20 gate emulation
Add simple "fast A20 gate" PS/2 system control port emulation for
SeaBIOS that probes the port.  As A20 gate is always enabled under KVM,
ignore writes to the port and report back that the gate is enabled.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Sasha Levin b0822113d5 kvm tools: don't exit on debug ioport write
While it shouldn't happen on regular guests, we sometimes hit it when fuzzing
within the guest, which would cause the lkvm process to exit - which is
undesired.

Our PIT tests were using the debug port to trigger a reboot. Instead of using
that port we now use the reboot line of our i8042 controller.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Sasha Levin 3d34111e7b kvm tools: fix SMP
We accidently broke SMP when we moved mptable init to before we initialize the vcpu
count, that means that we always built smptable which was not properly initialized
for the given configuration.

Instead of initializing mptable as part of the kvm arch initialization, let it
be initialized on it's own in the firmware initialization level.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Sasha Levin 4346fd8f1e kvm tools: remove global kvm object
This was ugly, and now we get rid of it.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Sasha Levin 49a8afd1b9 kvm tools: use init/exit where possible
Switch to using init/exit calls instead of the repeating call blocks in builtin-run.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:53 +01:00
Sasha Levin df4239fb27 kvm tools: move kvm_cpus into struct kvm
There's no reason the array of guest specific vcpus is global. Move it into
struct kvm.

Also split up arch specific vcpu init from the generic code and call it from
the kvm_cpu initializer.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:52 +01:00
Sasha Levin 42ac24f9e8 kvm tools: split struct kvm into arch specific part
Move all the non-arch specific members into a generic struct, and the arch specific
members into a arch specific kvm_arch. This prevents code duplication across different
archs.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:52 +01:00
Michael Ellerman 3ebd8e0bf3 kvm tools: Remember page size as kvm->ram_pagesize
On some powerpc platforms we need to make sure we only advertise page
sizes to the guest which are <= the size of the pages backing guest RAM.

So have mmap_hugetblfs() save the hugetblfs page size for us, and also
teach mmap_anon_or_hugetblfs() to set the page size for anonymous mmap.

Acked-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:52 +01:00
Michael Ellerman f8edca99fb kvm tools: Move mmap_anon_or_hugetblfs() into util
So we can use it on powerpc.

Acked-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:52 +01:00
Sasha Levin 0d5b41d930 kvm tools: set the HYPERVISOR flag in cpuid
We need to set the HYPERVISOR flag to let the kernel know we're running
under a hypervisor.

This makes the kernel enable all sorts of para-virtualization options
such as kvm-clock.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
[gorcunov@: Add comments on bits]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
2015-06-01 16:39:52 +01:00