]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
14 years agoMerge branch 'master' of git://github.com/cyrillos/vm
Pekka Enberg [Sun, 11 Apr 2010 18:07:45 +0000 (21:07 +0300)]
Merge branch 'master' of git://github.com/cyrillos/vm

14 years agokvm: Clean up early serial code
Pekka Enberg [Sun, 11 Apr 2010 18:05:36 +0000 (21:05 +0300)]
kvm: Clean up early serial code

Use similar constants and variable names as in arch/x86/kernel/early_printk.c
in the Linux kernel.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoioport: Make all PIT channels being dummy
Cyrill Gorcunov [Sun, 11 Apr 2010 17:56:56 +0000 (21:56 +0400)]
ioport: Make all PIT channels being dummy

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Force 'notsc' and 'earlyprintk' kernel parameters
Pekka Enberg [Sun, 11 Apr 2010 17:55:56 +0000 (20:55 +0300)]
kvm: Force 'notsc' and 'earlyprintk' kernel parameters

We don't support TSC calibration properly and we want early printk so force
them as kernel parameters.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add support for early serial printk
Pekka Enberg [Sun, 11 Apr 2010 17:42:10 +0000 (20:42 +0300)]
kvm: Add support for early serial printk

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Make command line to be placed at predefined address
Cyrill Gorcunov [Sun, 11 Apr 2010 16:09:28 +0000 (20:09 +0400)]
kvm: Make command line to be placed at predefined address

We support only 0x202 boot protocol at moment so that kernel command line is
copied into predefined address.

Reported-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix minor formatting glitch in cpuid.c
Pekka Enberg [Sun, 11 Apr 2010 14:08:15 +0000 (17:08 +0300)]
kvm: Fix minor formatting glitch in cpuid.c

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix off-by-one bugs in kvm__setup_cpuid()
Pekka Enberg [Sun, 11 Apr 2010 13:35:35 +0000 (16:35 +0300)]
kvm: Fix off-by-one bugs in kvm__setup_cpuid()

The cpuid_highest_func() and cpuid_highest_ext_func() return the highest
possible function number, not the first non-existing function.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore keyboard controller ioports
Pekka Enberg [Sun, 11 Apr 2010 12:29:43 +0000 (15:29 +0300)]
kvm: Ignore keyboard controller ioports

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore PIT ioports
Pekka Enberg [Sun, 11 Apr 2010 12:25:46 +0000 (15:25 +0300)]
kvm: Ignore PIT ioports

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore dummy delay ioport
Pekka Enberg [Sun, 11 Apr 2010 12:24:17 +0000 (15:24 +0300)]
kvm: Ignore dummy delay ioport

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore CRT control ioports
Pekka Enberg [Sun, 11 Apr 2010 12:22:38 +0000 (15:22 +0300)]
kvm: Ignore CRT control ioports

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore CMOS RAM/RTC ioports
Pekka Enberg [Sun, 11 Apr 2010 12:21:09 +0000 (15:21 +0300)]
kvm: Ignore CMOS RAM/RTC ioports

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore PIC accesses
Pekka Enberg [Sun, 11 Apr 2010 12:18:19 +0000 (15:18 +0300)]
kvm: Ignore PIC accesses

Fix up some dummy ioport ops so that we don't stop on PIC setup code in the
kernel.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore MMIO accesses
Pekka Enberg [Sun, 11 Apr 2010 12:15:02 +0000 (15:15 +0300)]
kvm: Ignore MMIO accesses

Lets cheat some more and ignore MMIO accesses altogether.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore PCI config space accesses
Pekka Enberg [Sun, 11 Apr 2010 12:01:02 +0000 (15:01 +0300)]
kvm: Ignore PCI config space accesses

Lets try to cheat a bit and just flat out ignore PCI config space accesses.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Don't crash debug dump if address isn't in guest memory
Pekka Enberg [Sun, 11 Apr 2010 09:45:15 +0000 (12:45 +0300)]
kvm: Don't crash debug dump if address isn't in guest memory

We don't do MMU translation in the hypevisor for guest memory addresses which
causes us to try to dereference invalid pointers.  Work around the problem by
checking that a pointer is in guest memory before dumping the contents.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Set up MAXPHYADDR guest CPUID
Pekka Enberg [Sun, 11 Apr 2010 09:37:54 +0000 (12:37 +0300)]
kvm: Set up MAXPHYADDR guest CPUID

As explained by Avi Kivity, we need to set up MAXPHYADDR for the guest to avoid
a triple fault when the guest tries to enter long mode. This fixes the
KVM_EXIT_SHUTDOWN problem I was seeing on my machine.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Dump page tables at exit
Pekka Enberg [Sun, 11 Apr 2010 06:28:14 +0000 (09:28 +0300)]
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>
14 years agokvm: Dump stack on KVM oops
Pekka Enberg [Thu, 8 Apr 2010 18:53:07 +0000 (21:53 +0300)]
kvm: Dump stack on KVM oops

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Show gdt and idt registers
Pekka Enberg [Thu, 8 Apr 2010 18:45:24 +0000 (21:45 +0300)]
kvm: Show gdt and idt registers

As suggested by Avi Kivity, dump 'gdt' and 'idt' registers as well.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Reference to undefined variable
Cyrill Gorcunov [Thu, 8 Apr 2010 17:53:13 +0000 (21:53 +0400)]
kvm: Reference to undefined variable

We may have cmdline_size not initialized before use. Fix it.

Reported-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add .gitignore for bios build files
Pekka Enberg [Thu, 8 Apr 2010 18:02:34 +0000 (21:02 +0300)]
kvm: Add .gitignore for bios build files

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Setup VCPU MSRs
Pekka Enberg [Thu, 8 Apr 2010 17:44:37 +0000 (20:44 +0300)]
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>
14 years agokvm: Clean up kvm__reset_vcpu() function
Pekka Enberg [Thu, 8 Apr 2010 17:42:32 +0000 (20:42 +0300)]
kvm: Clean up kvm__reset_vcpu() function

This patch splits kvm__reset_vcpu() into three separate helper functions to
make the function more readable.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add test binaries to .gitignore
Pekka Enberg [Thu, 8 Apr 2010 17:19:41 +0000 (20:19 +0300)]
kvm: Add test binaries to .gitignore

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clean up Makefile output
Pekka Enberg [Thu, 8 Apr 2010 17:19:12 +0000 (20:19 +0300)]
kvm: Clean up Makefile output

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Update command line related enitites in boot parameters
Cyrill Gorcunov [Fri, 2 Apr 2010 21:46:11 +0000 (01:46 +0400)]
kvm: Update command line related enitites in boot parameters

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add copying of kernel command line into guest memory
Cyrill Gorcunov [Fri, 2 Apr 2010 21:16:51 +0000 (01:16 +0400)]
kvm: Add copying of kernel command line into guest memory

We will need to modify heap pointer in guest.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agobios: Add bios stubs generated from assembly files
Cyrill Gorcunov [Thu, 1 Apr 2010 17:23:18 +0000 (21:23 +0400)]
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>
14 years agointerrupt: Move bios related constants to kvm/bios.h
Cyrill Gorcunov [Thu, 1 Apr 2010 15:51:46 +0000 (19:51 +0400)]
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>
14 years agokvm: Introduce kvm__dump_mem helper
Cyrill Gorcunov [Wed, 31 Mar 2010 19:57:12 +0000 (23:57 +0400)]
kvm: Introduce kvm__dump_mem helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agointerrupt: Add interrupt_table__set helper
Cyrill Gorcunov [Thu, 1 Apr 2010 15:23:21 +0000 (19:23 +0400)]
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>
14 years agobios: Add simple bin2c converter
Cyrill Gorcunov [Wed, 31 Mar 2010 19:45:15 +0000 (23:45 +0400)]
bios: Add simple bin2c converter

We will need it to convert binary data into compilable C code.
It's pretty trivial.

Signed-off-by: Tobias Brox <tobixen@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Free memory on exit
Pekka Enberg [Thu, 1 Apr 2010 14:45:26 +0000 (17:45 +0300)]
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>
14 years agokvm: Fix protected mode code dump
Pekka Enberg [Thu, 1 Apr 2010 14:32:38 +0000 (17:32 +0300)]
kvm: Fix protected mode code dump

This patch fixes protected mode code dump not to take 16-bit segment selector
into account when calculating the guest flat address.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore PIC init during boot
Pekka Enberg [Thu, 1 Apr 2010 14:23:38 +0000 (17:23 +0300)]
kvm: Ignore PIC init during boot

We don't have interrupt injection so we can safely ignore PIC interrupt masking
during bootup.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Ignore math co-processor reset I/O writes
Pekka Enberg [Thu, 1 Apr 2010 14:18:58 +0000 (17:18 +0300)]
kvm: Ignore math co-processor reset I/O writes

The Linux kernel resets math co-processor when entering protected mode.  Ignore
the reset for now so kernel boot doesn't stop there.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Setup guest FPU state
Pekka Enberg [Thu, 1 Apr 2010 13:35:38 +0000 (16:35 +0300)]
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>
14 years agokvm: Remove unused cpu.c file
Pekka Enberg [Wed, 31 Mar 2010 18:55:49 +0000 (21:55 +0300)]
kvm: Remove unused cpu.c file

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add simple NMI enable/disable support
Pekka Enberg [Wed, 31 Mar 2010 18:35:27 +0000 (21:35 +0300)]
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>
14 years agokvm: Don't abort guest on KVM_EXIT_IO
Pekka Enberg [Wed, 31 Mar 2010 18:11:30 +0000 (21:11 +0300)]
kvm: Don't abort guest on KVM_EXIT_IO

This is a preparational step for emulating IO.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Extract ioport emulation code to its own file
Pekka Enberg [Wed, 31 Mar 2010 18:08:16 +0000 (21:08 +0300)]
kvm: Extract ioport emulation code to its own file

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Extract CPUID code into its own file
Pekka Enberg [Wed, 31 Mar 2010 17:59:54 +0000 (20:59 +0300)]
kvm: Extract CPUID code into its own file

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Enable GCC debugging information
Pekka Enberg [Wed, 31 Mar 2010 17:52:12 +0000 (20:52 +0300)]
kvm: Enable GCC debugging information

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Setup CPUID for the guest
Pekka Enberg [Wed, 31 Mar 2010 16:45:23 +0000 (19:45 +0300)]
kvm: Setup CPUID for the guest

This patch sets up guest CPUID which is based on host CPUID.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Introduce --single-step command line option
Pekka Enberg [Wed, 31 Mar 2010 16:19:23 +0000 (19:19 +0300)]
kvm: Introduce --single-step command line option

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Put fake bios interrupt handlers into known memory area
Cyrill Gorcunov [Tue, 30 Mar 2010 19:26:29 +0000 (23:26 +0400)]
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>
14 years agokvm: Rename ivt_ prefixed entities
Cyrill Gorcunov [Mon, 29 Mar 2010 15:47:31 +0000 (19:47 +0400)]
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>
14 years agokvm: Move util.h to include/kvm directory
Pekka Enberg [Sun, 28 Mar 2010 16:54:24 +0000 (19:54 +0300)]
kvm: Move util.h to include/kvm directory

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clean up interrupt_table__setup()
Pekka Enberg [Sun, 28 Mar 2010 16:45:08 +0000 (19:45 +0300)]
kvm: Clean up interrupt_table__setup()

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Move interrupt table to struct kvm
Pekka Enberg [Sun, 28 Mar 2010 16:41:48 +0000 (19:41 +0300)]
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>
14 years agokvm: Remove unnecessary includes from interrupt.c
Pekka Enberg [Sun, 28 Mar 2010 16:35:32 +0000 (19:35 +0300)]
kvm: Remove unnecessary includes from interrupt.c

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clean up kvm/interrupt.h a bit
Pekka Enberg [Sun, 28 Mar 2010 16:34:30 +0000 (19:34 +0300)]
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>
14 years agokvm: Rename interrupt emulation source files
Pekka Enberg [Sun, 28 Mar 2010 16:33:16 +0000 (19:33 +0300)]
kvm: Rename interrupt emulation source files

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fill up fake IVT
Cyrill Gorcunov [Sun, 28 Mar 2010 15:53:30 +0000 (19:53 +0400)]
kvm: Fill up fake IVT

Fill up fake IVT to point to 2 bytes opcodes of "sti,iret". Since they have to
live somewhere in guest memory we use _pad entry from boot_params space.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Setup fake IVT table
Cyrill Gorcunov [Sun, 28 Mar 2010 15:10:03 +0000 (19:10 +0400)]
kvm: Setup fake IVT table

Setup fake interrupt handlers for real mode, it consists of iret opcode only.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Introduce IVT handling
Cyrill Gorcunov [Sun, 28 Mar 2010 14:45:51 +0000 (18:45 +0400)]
kvm: Introduce IVT handling

Introduce procedures for handling IVT (Interrupt Vector Table) to be used int
real mode bootstrap procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add --params option
Cyrill Gorcunov [Sun, 28 Mar 2010 10:35:06 +0000 (14:35 +0400)]
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>
14 years agokvm: Add --kernel parameter handling
Cyrill Gorcunov [Sun, 28 Mar 2010 10:27:44 +0000 (14:27 +0400)]
kvm: Add --kernel parameter handling

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fixup boot selector
Cyrill Gorcunov [Sun, 28 Mar 2010 14:21:05 +0000 (18:21 +0400)]
kvm: Fixup boot selector

The boot selector for modern boot protocol is 64K not 4K.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Use 64 bit names when showing registers
Cyrill Gorcunov [Sat, 27 Mar 2010 20:12:10 +0000 (23:12 +0300)]
kvm: Use 64 bit names when showing registers

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: load_bzimage: Proper check for number of setup sectors
Cyrill Gorcunov [Sat, 27 Mar 2010 19:11:26 +0000 (22:11 +0300)]
kvm: load_bzimage: Proper check for number of setup sectors

We should check for the number of setup sectors before adding the last one.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Introduce host_real_to_guest() helper function
Pekka Enberg [Sat, 27 Mar 2010 18:55:27 +0000 (20:55 +0200)]
kvm: Introduce host_real_to_guest() helper function

Introduce a new host_real_to_guest() helper function and use it to clean up
code.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Setup stack for the kernel
Pekka Enberg [Sat, 27 Mar 2010 18:46:33 +0000 (20:46 +0200)]
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>
14 years agokvm: Load kernel at 0x1000
Pekka Enberg [Sat, 27 Mar 2010 18:23:35 +0000 (20:23 +0200)]
kvm: Load kernel at 0x1000

As described in Documentation/x86/boot.txt, memory starting at 0x1000 is
available for the boot loader.  As we don't have a separate boot loader, load
the kernel at the address.  Note: we're setting up the segment selector here so
0x0100:0x0000 in 16-bit real mode is 0x1000 in physical memory.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix kernel boot IP
Pekka Enberg [Sat, 27 Mar 2010 18:16:51 +0000 (20:16 +0200)]
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>
14 years agokvm: Remove 'reset vector' hack
Pekka Enberg [Sat, 27 Mar 2010 18:05:04 +0000 (20:05 +0200)]
kvm: Remove 'reset vector' hack

As explained by Avi Kivity, KVM on Intel requires segment 'base' to equal to
'selector * 16'.  Fix that up and remove the 'reset vector' hack.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix setup size calculation
Pekka Enberg [Sat, 27 Mar 2010 17:59:52 +0000 (19:59 +0200)]
kvm: Fix setup size calculation

I need a brown paper bag.  When converting sectors to bytes, we need to shift
by 9 ("512"), not 4 ("16")...

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoRevert "kvm: Enable 'interrupt request window'"
Pekka Enberg [Sat, 27 Mar 2010 16:56:38 +0000 (18:56 +0200)]
Revert "kvm: Enable 'interrupt request window'"

This reverts commit c1a099311e695bfe1caca9a11e294fbd70d3ba11.  Interrupt
request windows are for host to guest interrupt injection.  Software interrupts
and traps happen 100% in the guest.

14 years agokvm: Enable 'interrupt request window'
Pekka Enberg [Sat, 27 Mar 2010 12:13:25 +0000 (14:13 +0200)]
kvm: Enable 'interrupt request window'

This patch enables KVM 'interrupt request window' so that KVM_RUN returns when
we hit an interrupt.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Document the 'reset vector' hack
Pekka Enberg [Sat, 27 Mar 2010 09:15:31 +0000 (11:15 +0200)]
kvm: Document the 'reset vector' hack

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clean up reset vector setup code
Pekka Enberg [Sat, 27 Mar 2010 09:08:32 +0000 (11:08 +0200)]
kvm: Clean up reset vector setup code

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add some single-step debugging and don't stop running
Pekka Enberg [Sat, 27 Mar 2010 08:58:58 +0000 (10:58 +0200)]
kvm: Add some single-step debugging and don't stop running

Now that we can execute some instructions, don't stop on first single step but
dump some debugging output instead and continue running.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Hardcode a "reset vector" at f000:fff0
Pekka Enberg [Sat, 27 Mar 2010 08:53:15 +0000 (10:53 +0200)]
kvm: Hardcode a "reset vector" at f000:fff0

It seems that if we attempt to run code at any other location than f000:fff0,
we get an KVM_EXIT_UNKNOWN error. To work around that, hardcode a "reset
vector" at f000:fff0 that jumps to 0000:0x7c000 and load the kernel at the
latter location.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Read the whole bzImage to memory
Pekka Enberg [Sat, 27 Mar 2010 08:15:18 +0000 (10:15 +0200)]
kvm: Read the whole bzImage to memory

We need to read the whole bzImage to memory; otherwise we miss some of the
setup code.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix bzImage setup sector default count
Pekka Enberg [Sat, 27 Mar 2010 07:54:58 +0000 (09:54 +0200)]
kvm: Fix bzImage setup sector default count

If setup sectors is zero, the real value is 4 as per
Documentation/x86/boot.txt.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Load bzImage real-mode boot sector and setup code
Pekka Enberg [Sat, 27 Mar 2010 07:34:00 +0000 (09:34 +0200)]
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>
14 years agoAdd support for loading flat binaries
Pekka Enberg [Fri, 26 Mar 2010 19:51:55 +0000 (21:51 +0200)]
Add support for loading flat binaries

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoAdd a simple "kernel" binary that can be used for testing
Pekka Enberg [Fri, 26 Mar 2010 19:40:46 +0000 (21:40 +0200)]
Add a simple "kernel" binary that can be used for testing

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoAdd info() helper
Cyrill Gorcunov [Fri, 26 Mar 2010 18:12:48 +0000 (21:12 +0300)]
Add info() helper

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoPrint 'avl' bits of a segment
Pekka Enberg [Fri, 26 Mar 2010 16:36:30 +0000 (18:36 +0200)]
Print 'avl' bits of a segment

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoMakefile: Add CPPFLAGS handling
Cyrill Gorcunov [Fri, 26 Mar 2010 15:48:11 +0000 (18:48 +0300)]
Makefile: Add CPPFLAGS handling

Some developers may need to pass specific flags
to compiler, usually due to different include/
directory and etc. So add well known CPPFLAGS
here.

Example:

$ CPPFLAGS="-I/home/include" make

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoFix up 'ip' in kvm__reset_vcpu() to take real mode into account
Pekka Enberg [Fri, 26 Mar 2010 15:24:39 +0000 (17:24 +0200)]
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>
14 years agoImprove KVM register dump output
Pekka Enberg [Thu, 25 Mar 2010 19:16:53 +0000 (21:16 +0200)]
Improve KVM register dump output

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoFix LDT descriptor type for KVM_SET_SREG
Pekka Enberg [Thu, 25 Mar 2010 19:15:27 +0000 (21:15 +0200)]
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>
14 years agoSetup segmentation for the guest
Pekka Enberg [Thu, 25 Mar 2010 18:37:48 +0000 (20:37 +0200)]
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>
14 years agoSeparate KVM code from the main loop
Pekka Enberg [Thu, 25 Mar 2010 15:40:51 +0000 (17:40 +0200)]
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>
14 years agoDon't die on old kernels without single-step debug support
Cyrill Gorcunov [Wed, 24 Mar 2010 21:15:36 +0000 (00:15 +0300)]
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>
14 years agoAdd utility functions
Cyrill Gorcunov [Wed, 24 Mar 2010 21:14:25 +0000 (00:14 +0300)]
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>
14 years agoEnable KVM guest single-stepping
Pekka Enberg [Wed, 24 Mar 2010 20:16:07 +0000 (22:16 +0200)]
Enable KVM guest single-stepping

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoMove KVM_SET_REGS to kvm__reset_vcpu()
Pekka Enberg [Wed, 24 Mar 2010 20:03:16 +0000 (22:03 +0200)]
Move KVM_SET_REGS to kvm__reset_vcpu()

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoDump KVM_EXIT_IO details
Pekka Enberg [Wed, 24 Mar 2010 19:33:45 +0000 (21:33 +0200)]
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>
14 years agoFix up rflags printing
Pekka Enberg [Wed, 24 Mar 2010 19:05:02 +0000 (21:05 +0200)]
Fix up rflags printing

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoSetup rflags properly to fix EXIT_UNKNOWN
Pekka Enberg [Wed, 24 Mar 2010 18:08:21 +0000 (20:08 +0200)]
Setup rflags properly to fix EXIT_UNKNOWN

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoFix guest code printout
Pekka Enberg [Wed, 24 Mar 2010 17:16:49 +0000 (19:16 +0200)]
Fix guest code printout

Doh, forgot to initialize 'c'...

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoShow dump of executed code at KVM exit
Pekka Enberg [Wed, 24 Mar 2010 17:04:31 +0000 (19:04 +0200)]
Show dump of executed code at KVM exit

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoPrint out constant names for KVM exit reasons
Pekka Enberg [Wed, 24 Mar 2010 16:49:32 +0000 (18:49 +0200)]
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>
14 years agoInitialize RIP before starting to run the guest
Pekka Enberg [Wed, 24 Mar 2010 16:13:46 +0000 (18:13 +0200)]
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>
14 years agoDump registers after KVM_RUN returns
Pekka Enberg [Wed, 24 Mar 2010 16:09:16 +0000 (18:09 +0200)]
Dump registers after KVM_RUN returns

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>