Pekka Enberg
06e41eeadc
Fix up 'ip' in kvm__reset_vcpu() to take real mode into account
...
We can't just set 'rip' to 1 MB mark because in real mode, 'ip' is just 16 bits
wide.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
ce5e0ecbbf
Improve KVM register dump output
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
7085d9359d
Fix LDT descriptor type for KVM_SET_SREG
...
This patch fixes the KVM_EXIT_UNKNOWN error when running bzImage.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
5360207747
Setup segmentation for the guest
...
This patch adds segmentation setup for the guest. It's not perfect yet as we
get KVM_EXIT_UNKNOWN but it's a start nevertheless.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
ae1fae34a8
Separate KVM code from the main loop
...
This patch separates the KVM code in its own file and cleans everything up a
bit while at it.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Cyrill Gorcunov
b625d4b6aa
Don't die on old kernels without single-step debug support
...
Better inform the user that the host kernel do not
support single-stepping debug.
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com >
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Cyrill Gorcunov
ad054a21d2
Add utility functions
...
Move helpers out to separate files.
Mostly borrowed from perf
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com >
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
aee6632eee
Enable KVM guest single-stepping
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
e3a07fc182
Move KVM_SET_REGS to kvm__reset_vcpu()
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
8d20223edc
Dump KVM_EXIT_IO details
...
When KVM_RUN returns with KVM_EXIT_IO, dump the I/O details and exit.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
2177ec43a9
Fix up rflags printing
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
a2fe61994f
Setup rflags properly to fix EXIT_UNKNOWN
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
6e8abc3811
Fix guest code printout
...
Doh, forgot to initialize 'c'...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
6f10be05fc
Show dump of executed code at KVM exit
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
d5741c92aa
Print out constant names for KVM exit reasons
...
Things are way easier to debug that way.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
8e12640544
Initialize RIP before starting to run the guest
...
Use the return value of load_kernel() to initialize RIP register before
starting the guest with KVM_RUN ioctl().
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
7118d2cabe
Dump registers after KVM_RUN returns
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
696a1b0a7d
Update .gitignore to include object files
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
ee0e89c5f1
Load bzImage to guest RAM
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
0d1f17ec4d
Initialize guest memory region properly
...
Use posix_memalign() to allocate memory for the guest and register the region
to KVM.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
f5ab5f67ff
Initial version of kernel image loading
...
This patch adds support for checking whether the provided kernel image is a
bzImage or not.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
caf44df2f8
Load kernel image to the VM
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
b6e5a081c5
Move CPU emulation code to cpu.c
...
The kvm.c file is getting bigger so move CPU emulation code to a separate file.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
1f9cff2305
Mmap the kvm_run structure
...
Mmap the kvm_run structure and print out ->exit_reason in human-readable form
upon exit to make it more visible what's happening after KVM_RUN ioctl() is
called.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
73ac60e636
Clean up struct kvm file descriptor names
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
895c2fef34
Set up TSS address to make vcpu creation work
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
2b0e334253
Initialize KVM some more
...
This patch adds some more KVM initialization code. Doesn't work yet, though.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
4076b0411d
Clean up KVM initialization
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
2da26a59d3
Check for KVM_CAP_USER_MEMORY
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
9b1fb1c3dc
Move KVM fds into 'struct kvm'
...
This patch introduces a 'struct kvm' and moves the KVM related file descriptors
into it so that we can introduce helper functions more easily.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
28fa19c020
Create a VM using ioctl(KVM_CREATE_VM)
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
e1f3acc598
Add .gitignore file
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
6c7d85141b
Check for KVM_API_VERSION at init
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00
Pekka Enberg
b8f6afcd5e
Initial commit
...
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi >
2015-06-01 16:39:38 +01:00