Commit Graph

30 Commits

Author SHA1 Message Date
Cyrill Gorcunov 8b8fb6c724 kvm: Kill the bin2c helper
Instead of calling bin2c helper we just include 16-bit pure code with .incbin
and export the symbols we need.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 13a7760f97 kvm: Add support for early serial printk
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 29443dabe7 kvm: Ignore MMIO accesses
Lets cheat some more and ignore MMIO accesses altogether.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg f01944c845 kvm: Dump page tables at exit
To make debugging more easy, dump page tables at exit as suggested by Avi
Kivity.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 53d4871448 kvm: Setup VCPU MSRs
Use the KVM_SET_MSRS ioctl() to set up model-specific registers (MSRs) to a
known state.  The MSRs are initialized to zero for now because I'm not sure
what are the right values.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov 305d905423 bios: Add bios stubs generated from assembly files
We substitute hardcoded fake bios handlers with ones generated
from assembly sources. This way we may extend them if needed.

In particular new int0x10 handler just write output into video
guest memory so the node machine may read the output anytime
it needs (though, to be fair, the kernel uses int0x10 only once
at bootup procedure if there was an attempt to boot directly
from disk/floppy, any other output is done via video port I/O
which is not implemented yet).

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov 768e8acc92 interrupt: Move bios related constants to kvm/bios.h
This will allow us to share them between assembly code
and C code as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov 090f898eae kvm: Introduce kvm__dump_mem helper
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov d1a26cf05d interrupt: Add interrupt_table__set helper
In case if some particular interrupt entry needs
to be modified we should use interrupt_table__set
helper.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2015-06-01 16:39:39 +01:00
Pekka Enberg 9ef4c68e33 kvm: Free memory on exit
Free memory on exit so that valgrind reports are easier to read.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg ce4d0766ad kvm: Setup guest FPU state
Use the KVM_SET_FPU ioctl() to set up guest initial FPU state.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 1beb586be6 kvm: Remove unused cpu.c file
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 2049569d3d kvm: Add simple NMI enable/disable support
This patch adds simple NMI I/O port emulation.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg a1fe6bc58d kvm: Extract CPUID code into its own file
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov 22489bb099 kvm: Put fake bios interrupt handlers into known memory area
Instead of hacking boot protocol header better to place interrupt handlers into
BDA.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Cyrill Gorcunov bc75b0ae4d kvm: Rename ivt_ prefixed entities
Though ivt stands for interrupt vector table it's not that clear, lets use
real_intr_desc for that.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg f315008929 kvm: Move util.h to include/kvm directory
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 4b62331f45 kvm: Clean up interrupt_table__setup()
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg da8883c13e kvm: Move interrupt table to struct kvm
This patch moves the global interrupt table to struct kvm.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:39 +01:00
Pekka Enberg 68967fcf0d kvm: Clean up kvm/interrupt.h a bit
Add include guards to the header file and remove unnecessary #includes.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00
Pekka Enberg eda033194e kvm: Rename interrupt emulation source files
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00
Cyrill Gorcunov 6d1f350d0f kvm: Add --params option
In particular this will keep boot agruments for kernel. The commit technically
prepares ground for real argument pass.

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 dbdb74c21e kvm: Setup stack for the kernel
The Linux kernel expects stack to be set up for it.  Fixes a bug in the program
where we start to run an instruction stream filled with zeros.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00
Pekka Enberg edc8a14d5b kvm: Fix kernel boot IP
Booting to a Linux kernel is no longer supported.  Therefore, start executing
at offset 0x200 of bzImage which has a jump to real-mode setup code.  See
Documentation/x86/boot.txt for more details.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00
Pekka Enberg 5d67eaf6e3 kvm: Clean up reset vector setup code
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00
Pekka Enberg 7fb218bdd0 kvm: Load bzImage real-mode boot sector and setup code
We start KVM in 16-bit mode so we should set cs:ip to point to the real-mode
boot sector and setup code, not the protected mode kernel that starts at 1M.

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
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 b8f6afcd5e Initial commit
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
2015-06-01 16:39:38 +01:00