]> git.karo-electronics.de Git - karo-tx-linux.git/log
karo-tx-linux.git
13 years agokvm: Kill stale interrupt configuration comment
Pekka Enberg [Wed, 5 Jan 2011 16:11:15 +0000 (18:11 +0200)]
kvm: Kill stale interrupt configuration comment

Yes, our interrupt configuration is OK. We can see the guest interrupt trapping
to our hypervisor.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement virtio blk device vring lookup
Pekka Enberg [Wed, 5 Jan 2011 16:00:52 +0000 (18:00 +0200)]
kvm: Implement virtio blk device vring lookup

This patch changes VIRTIO_PCI_QUEUE_NOTIFY handler to look up the actual I/O
request from the vring. We don't inject anything back to the guest yet.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement virtqueues for virtio block device
Pekka Enberg [Tue, 4 Jan 2011 19:07:30 +0000 (21:07 +0200)]
kvm: Implement virtqueues for virtio block device

This patch implements virtqueues for virtio block device. It doesn't handle the
I/O requests on the vring yet, though.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Add ->queue_selector and ->queue_pfn to struct device
Pekka Enberg [Tue, 4 Jan 2011 18:41:25 +0000 (20:41 +0200)]
kvm: Add ->queue_selector and ->queue_pfn to struct device

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Make virtio block device read-only
Pekka Enberg [Tue, 4 Jan 2011 17:30:06 +0000 (19:30 +0200)]
kvm: Make virtio block device read-only

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement virtio blk device config space
Pekka Enberg [Tue, 4 Jan 2011 16:21:21 +0000 (18:21 +0200)]
kvm: Implement virtio blk device config space

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agoRevert "kvm: Fix virtio block PCI device IRQ configuration"
Pekka Enberg [Tue, 4 Jan 2011 16:21:35 +0000 (18:21 +0200)]
Revert "kvm: Fix virtio block PCI device IRQ configuration"

This reverts commit 00b793d98754629f833d5a3003554f841e64ec45.

13 years agokvm: Remove bogus #include directive
Pekka Enberg [Tue, 4 Jan 2011 15:22:57 +0000 (17:22 +0200)]
kvm: Remove bogus #include directive

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Don't use VIRTIO_BLK_F_SEG_MAX in the hypervisor
Pekka Enberg [Tue, 4 Jan 2011 15:20:23 +0000 (17:20 +0200)]
kvm: Don't use VIRTIO_BLK_F_SEG_MAX in the hypervisor

We don't actually support VIRTIO_BLK_F_SEG_MAX so disable it from host
features. This fixes the following error during virtio block device probe in
the guest kernel which is caused by bogus "sg_elems" in virtblk_probe():

  ------------[ cut here ]------------
  WARNING: at mm/page_alloc.c:1968 __alloc_pages_nodemask+0x5b4/0x6c0()
  Modules linked in:
  Pid: 1, comm: swapper Not tainted 2.6.35-rc3 #48
  Call Trace:
   [<ffffffff81081e7f>] warn_slowpath_common+0x7f/0xc0
   [<ffffffff81081eda>] warn_slowpath_null+0x1a/0x20
   [<ffffffff8110a6e4>] __alloc_pages_nodemask+0x5b4/0x6c0
   [<ffffffff8124f860>] ? idr_get_empty_slot+0x110/0x2c0
   [<ffffffff8124f860>] ? idr_get_empty_slot+0x110/0x2c0
   [<ffffffff81138795>] alloc_page_interleave+0x45/0xa0
   [<ffffffff811395d9>] alloc_pages_current+0xb9/0xe0
   [<ffffffff8110993e>] __get_free_pages+0xe/0x50
   [<ffffffff8114191e>] __kmalloc+0x14e/0x1c0
   [<ffffffff8137dbf7>] ? virtio_config_buf+0x57/0x80
   [<ffffffff81671e15>] virtblk_probe+0x78/0x498

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Cleanup virtio block device I/O functions
Pekka Enberg [Tue, 4 Jan 2011 15:14:56 +0000 (17:14 +0200)]
kvm: Cleanup virtio block device I/O functions

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agokvm: Implement "host features" for virtio blk device
Pekka Enberg [Tue, 4 Jan 2011 15:13:19 +0000 (17:13 +0200)]
kvm: Implement "host features" for virtio blk device

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agobios: Use proper grep syntax
Cyrill Gorcunov [Mon, 3 Jan 2011 16:37:36 +0000 (19:37 +0300)]
bios: Use proper grep syntax

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
13 years agokvm: Fix virtio block PCI device IRQ configuration
Pekka Enberg [Mon, 3 Jan 2011 16:21:11 +0000 (18:21 +0200)]
kvm: Fix virtio block PCI device IRQ configuration

This patch fixes up hang when guest kernel tries to setup virtio block device.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
13 years agobios: Get rid of redundant ops
Cyrill Gorcunov [Thu, 18 Nov 2010 17:17:04 +0000 (20:17 +0300)]
bios: Get rid of redundant ops

cli/sti is not needed here

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Don't forget to close initrd file
Cyrill Gorcunov [Sun, 29 Aug 2010 16:17:03 +0000 (20:17 +0400)]
kvm: Don't forget to close initrd file

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Fix kernel loading error messages
Pekka Enberg [Sun, 29 Aug 2010 14:11:17 +0000 (17:11 +0300)]
kvm: Fix kernel loading error messages

This patch fixes kernel loading error messages. We expect users to try to load
bzImage most of the time and. However, if the user passes a binary that's not a
bzImage, lets just print out the following warning:

  Warning: vmlinux is not a bzImage. Trying to load it as a flat binary...

and pass the control to the binary.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Add virtio_blk.h to tree
Cyrill Gorcunov [Sun, 29 Aug 2010 11:42:51 +0000 (15:42 +0400)]
kvm: Add virtio_blk.h to tree

This patch adds virtio_blk.h from Linux kernel sources to the tree. We will
need it to implement virtio block device emulation.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add virtio_ring.h to tree
Cyrill Gorcunov [Sun, 29 Aug 2010 11:27:40 +0000 (15:27 +0400)]
kvm: Add virtio_ring.h to tree

This patch adds virtio_ring.h from Linux kernel sources to the tree. We will
need it to implement virtio block device emulation.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Virtio block device emulation
Pekka Enberg [Sun, 15 Aug 2010 15:39:27 +0000 (18:39 +0300)]
kvm: Virtio block device emulation

This patch implements a rough first version of virtio block device emulation.
You can enable it with the '--enable-virtio' command line option. We're still
missing virtio queue handling so enabling virtio will cause a guest kernel to
hang.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Add cscope target to Makefile
Asias He [Wed, 25 Aug 2010 03:06:34 +0000 (11:06 +0800)]
kvm: Add cscope target to Makefile

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Fail virtio blk ioports by default
Pekka Enberg [Sun, 15 Aug 2010 14:17:43 +0000 (17:17 +0300)]
kvm: Fail virtio blk ioports by default

This patch changes virtio block device ioports to fail by default and adds few
specific stubs to keep kernel booting still.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Add virtio PCI ioport handler stubs
Pekka Enberg [Sun, 15 Aug 2010 12:13:00 +0000 (15:13 +0300)]
kvm: Add virtio PCI ioport handler stubs

This patch adds stub virtio PCI ioport handlers to our virtio emulation layer.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Add port range to ioport__register()
Pekka Enberg [Sun, 15 Aug 2010 12:03:01 +0000 (15:03 +0300)]
kvm: Add port range to ioport__register()

This patch adds a 'count' argument to ioport__register() to allow callers to
register a range of ioports.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Update .gitignore to ignore tags
Pekka Enberg [Sun, 15 Aug 2010 11:45:13 +0000 (14:45 +0300)]
kvm: Update .gitignore to ignore tags

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Extract virtio-blk driver to separate file
Pekka Enberg [Sun, 15 Aug 2010 11:44:41 +0000 (14:44 +0300)]
kvm: Extract virtio-blk driver to separate file

This patch extracts virtio-blk driver to a separate file.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agokvm: Fix unaligned PCI_CONFIG_ADDRESS accesses
Pekka Enberg [Sun, 15 Aug 2010 11:27:23 +0000 (14:27 +0300)]
kvm: Fix unaligned PCI_CONFIG_ADDRESS accesses

This patch fixes unaligned PCI_CONFIG_ADDRESS accesses to use the same
mechanism as with PCI_CONFIG_DATA.

Signed-off-by: Pekka Enberg <penberg@kernel.org>
14 years agoMerge branch 'master' of git://github.com/cyrillos/vm
Pekka Enberg [Sun, 15 Aug 2010 09:10:51 +0000 (12:10 +0300)]
Merge branch 'master' of git://github.com/cyrillos/vm

14 years agokvm: Support loading initrd image
Cyrill Gorcunov [Sun, 8 Aug 2010 18:35:30 +0000 (22:35 +0400)]
kvm: Support loading initrd image

The start address of initrd image is set properly
but it seems we need /dev tuning since kernel issue
panic still.

Suggested-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add KVM ABI headers
Pekka Enberg [Mon, 9 Aug 2010 16:06:02 +0000 (19:06 +0300)]
kvm: Add KVM ABI headers

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>
14 years agokvm: Kill virtio debugging code
Pekka Enberg [Sun, 8 Aug 2010 15:03:52 +0000 (18:03 +0300)]
kvm: Kill virtio debugging code

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, pci: fill up virtio device configuration header
Asias He [Sat, 7 Aug 2010 06:47:25 +0000 (14:47 +0800)]
kvm, pci: fill up virtio device configuration header

IO     base address register must be aligned at  4 bytes.
Memory base address register must be aligned at 16 bytes.
We should not shift io port or memory address in base address register.
See PCI_System_Architecture_FourthEdition Page 427.

We need more io space for virtio device, qemu-kvm uses 64 byes,
so io space reserved for bios is not enough.

See drivers/virtio/virtio_pci.c
static struct virtio_config_ops virtio_pci_config_ops = {
        .get            = vp_get,
        .set            = vp_set,
        .get_status     = vp_get_status,
        .set_status     = vp_set_status,
        .reset          = vp_reset,
        .find_vqs       = vp_find_vqs,
        .del_vqs        = vp_del_vqs,
        .get_features   = vp_get_features,
        .finalize_features = vp_finalize_features,
};

---------------------------------------------------------------------
guest_using_virtio_blk $ lspci -xxx
00:04.0 SCSI storage controller: Qumranet, Inc. Virtio block device
00: f4 1a 01 10 03 00 10 00 00 00 00 01 00 00 00 00
10: 01 c2 00 00 00 00 03 f2 00 00 00 00 00 00 00 00
20: 00 00 00 00 00 00 00 00 00 00 00 00 f4 1a 02 00
30: 00 00 00 00 40 00 00 00 00 00 00 00 0b 01 00 00
40: 11 00 01 80 01 00 00 00 01 08 00 00 00 00 00 00
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---------------------------------------------------------------------
guest_using_virtio_blk $  cat /proc/iomem
f2030000-f2030fff : 0000:00:04.0
  f2030000-f2030fff : virtio-pci
---------------------------------------------------------------------
guest_using_virtio_blk $ cat /proc/ioports
c200-c23f : 0000:00:04.0
  c200-c23f : virtio-pci
---------------------------------------------------------------------

$ ./kvm bzImage #virtio enabled guest kernel
Logs:
[    0.548000] virtio-pci 0000:00:01.0: enabling device (0000 -> 0001)
[    0.549000] asias:drivers/virtio/virtio.c:virtio_dev_probe
[    0.549000] asias:drivers/virtio/virtio_pci.c:vp_get_features
  Info: virtio_io
[    0.549000] asias:drivers/block/virtio_blk.c:virtblk_probe
[    0.549000] virtio_blk: probe of virtio0 failed with error -16

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, pci: Claim virtio device ioport in pci header
Cyrill Gorcunov [Sun, 1 Aug 2010 10:06:17 +0000 (14:06 +0400)]
kvm, pci: Claim virtio device ioport in pci header

It still doesn't work because we need to fill .class
properly. But at least virtio probe function passes fine now.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, pci: Fix offset for pci CONFIG_DATA ioport
Cyrill Gorcunov [Sun, 1 Aug 2010 08:57:55 +0000 (12:57 +0400)]
kvm, pci: Fix offset for pci CONFIG_DATA ioport

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, pci: Add bus forwarding register
Cyrill Gorcunov [Sat, 31 Jul 2010 21:16:17 +0000 (01:16 +0400)]
kvm, pci: Add bus forwarding register

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, pci: Fix unaligned PCI accesses
Pekka Enberg [Sat, 31 Jul 2010 20:20:01 +0000 (23:20 +0300)]
kvm, pci: Fix unaligned PCI accesses

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, pci: Don't calculate offset twice
Pekka Enberg [Sat, 31 Jul 2010 20:05:01 +0000 (23:05 +0300)]
kvm, pci: Don't calculate offset twice

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix PCI config space emulation
Pekka Enberg [Sat, 31 Jul 2010 20:01:10 +0000 (23:01 +0300)]
kvm: Fix PCI config space emulation

This fixes the two problems:

  1. Yes, 'register number' is offset in 4 bytes, not 1 byte

  2. We must be able to return sane values for the whole 256 configuration
     space, not just for the first 64 bytes that's covered by the fixed header

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, pci: Fix device probe accesses
Pekka Enberg [Sat, 31 Jul 2010 19:51:07 +0000 (22:51 +0300)]
kvm, pci: Fix device probe accesses

The register number is offset in bytes, not in words.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, pci: Add dummy virtio device for probing
Cyrill Gorcunov [Sat, 31 Jul 2010 19:06:10 +0000 (23:06 +0400)]
kvm, pci: Add dummy virtio device for probing

[ penberg@cs.helsinki.fi: fixes, cleanups ]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, pci: Return "no device" by default
Cyrill Gorcunov [Sat, 31 Jul 2010 16:04:24 +0000 (20:04 +0400)]
kvm, pci: Return "no device" by default

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add PCI CONFIG_ADDRESS register layout
Pekka Enberg [Sat, 31 Jul 2010 14:54:56 +0000 (17:54 +0300)]
kvm: Add PCI CONFIG_ADDRESS register layout

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agopci: Fix typo in previous commit
Cyrill Gorcunov [Sat, 31 Jul 2010 14:03:14 +0000 (18:03 +0400)]
pci: Fix typo in previous commit

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agopci: Use proper PCI port names
Cyrill Gorcunov [Sat, 31 Jul 2010 13:50:15 +0000 (17:50 +0400)]
pci: Use proper PCI port names

[ penberg@cs.helsinki.fi: rename ops and variables ]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Initial PCI probe emulation
Pekka Enberg [Sat, 31 Jul 2010 12:52:43 +0000 (15:52 +0300)]
kvm: Initial PCI probe emulation

This patch adds simple PCI Configuration Mechanism 1 probing emulation. It
doesn't expose any actual PCI devices yet.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Force PCI Configuration Mechanism 1
Pekka Enberg [Sat, 31 Jul 2010 13:09:36 +0000 (16:09 +0300)]
kvm: Force PCI Configuration Mechanism 1

This patch forces the guest Linux kernel to use PCI Configuration Mechanism 1.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Enable Linux kernel PCI probing
Pekka Enberg [Sat, 31 Jul 2010 12:10:45 +0000 (15:10 +0300)]
kvm: Enable Linux kernel PCI probing

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add some more ioport emulation
Pekka Enberg [Sat, 31 Jul 2010 12:18:43 +0000 (15:18 +0300)]
kvm: Add some more ioport emulation

This patch adds some more ioport emulation code so that I can boot a Linux
kernel cleanly with "--ioport-debug" command line option enabled.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agobios: clean predefined bios area early
Cyrill Gorcunov [Wed, 28 Jul 2010 17:13:27 +0000 (21:13 +0400)]
bios: clean predefined bios area early

otherwise say EBDA area could have some trash
values gotten from malloc.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Use proper segment + offset in e820 bios
Pekka Enberg [Fri, 16 Jul 2010 12:44:26 +0000 (15:44 +0300)]
kvm: Use proper segment + offset in e820 bios

This patch fixes E820 BIOS emulation on AMD CPUs that, unlike Intel ones,
require proper 16-bit segment/offset addressing in virtualized 16-bit mode.

Reported-by: Asias He <asias.hejun@gmail.com>
Tested-by: Asias He <asias.hejun@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Exclude BIOS object files from header deps
Pekka Enberg [Fri, 16 Jul 2010 13:42:13 +0000 (16:42 +0300)]
kvm: Exclude BIOS object files from header deps

This patch fixes build error reported by Asias.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clean header dependency files
Pekka Enberg [Fri, 16 Jul 2010 13:40:01 +0000 (16:40 +0300)]
kvm: Clean header dependency files

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix Makefile header dependencies
Pekka Enberg [Fri, 16 Jul 2010 13:12:53 +0000 (16:12 +0300)]
kvm: Fix Makefile header dependencies

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Update bios .gitignore list
Pekka Enberg [Thu, 15 Jul 2010 15:04:41 +0000 (18:04 +0300)]
kvm: Update bios .gitignore list

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Clear performance monitoring CPUID flags
Pekka Enberg [Thu, 15 Jul 2010 14:53:58 +0000 (17:53 +0300)]
kvm: Clear performance monitoring CPUID flags

Commit 3d446cf17faefd621c0842b58c92a50bd307eec7 ("kvm__setup_cpuid: use
KVM_GET_SUPPORTED_CPUID to simplify cpuid setup") causes the following errors
to be printed on host kernel dmesg:

[  775.134693] kvm: 2882: cpu0 unhandled rdmsr: 0x345
[  775.143130] kvm: 2882: cpu0 unhandled wrmsr: 0x40 data 0
[  775.143136] kvm: 2882: cpu0 unhandled wrmsr: 0x60 data 0
[  775.143141] kvm: 2882: cpu0 unhandled wrmsr: 0x41 data 0
[  775.143146] kvm: 2882: cpu0 unhandled wrmsr: 0x61 data 0
[  775.143150] kvm: 2882: cpu0 unhandled wrmsr: 0x42 data 0
[  775.143155] kvm: 2882: cpu0 unhandled wrmsr: 0x62 data 0
[  775.143159] kvm: 2882: cpu0 unhandled wrmsr: 0x43 data 0
[  775.143164] kvm: 2882: cpu0 unhandled wrmsr: 0x63 data 0

As explained by Cyrill Gorcunov, these MSR accesses come from Linux performance
events subsystems which is not supported by our little hypervisor. Therefore,
clear the performance monitoring CPUID flags to let guest kernels know about
that.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Use sizeof instead of magic number
Pekka Enberg [Thu, 15 Jul 2010 14:44:23 +0000 (17:44 +0300)]
kvm: Use sizeof instead of magic number

The 'ecx' register contains size of copied data. Use sizeof(struct e820_entry)
instead of a magic number to make it obvious from the code.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Cleanup BIOS setup code
Pekka Enberg [Thu, 15 Jul 2010 09:39:07 +0000 (12:39 +0300)]
kvm: Cleanup BIOS setup code

This patch cleans up BIOS setup code by introducing struct irq_handler and
switching to more declarative setup.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, bios: Make e820 map to look similar the real one
Cyrill Gorcunov [Wed, 14 Jul 2010 14:57:17 +0000 (18:57 +0400)]
kvm, bios: Make e820 map to look similar the real one

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Remove unused outb() function from e820.c
Pekka Enberg [Thu, 15 Jul 2010 09:22:57 +0000 (12:22 +0300)]
kvm: Remove unused outb() function from e820.c

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, bios: BIOS code redesign
Cyrill Gorcunov [Wed, 14 Jul 2010 17:28:59 +0000 (21:28 +0400)]
kvm, bios: BIOS code redesign

Instead of keeping bios code in various bin junks make
it to host in one binary blob. This blob gets copied
to a predefined place at startup and IVT handlers set
as appropriate.

Also we need to generate header file which will contain
BIOS tourine offsets for symbols being used.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Use -Werror for building the thing
Pekka Enberg [Wed, 14 Jul 2010 12:28:45 +0000 (15:28 +0300)]
kvm: Use -Werror for building the thing

It's easy to miss warnings so use -Werror. We're a shiny new userspace project
so there's no reason not to use it.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Use 32-bit operand size prefix for rdfs8()
Pekka Enberg [Wed, 14 Jul 2010 12:20:21 +0000 (15:20 +0300)]
kvm: Use 32-bit operand size prefix for rdfs8()

E820 memory map resides in EBDA region which starts at address 0x9fc00 which
doesn't fit in 16 bits. Therefore, use 'addr32' operand size prefix to fix the
following error:

  bios/e820.c: Assembler messages:
  bios/e820.c:14: Warning: 654336 shortened to 64512

Acked-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix load_bzimage for flat binaries
Pekka Enberg [Wed, 14 Jul 2010 11:58:25 +0000 (14:58 +0300)]
kvm: Fix load_bzimage for flat binaries

We must not die if load_bzimage() fails because we want to fall-back to loading
flat binaries.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix usage command line format
Pekka Enberg [Wed, 14 Jul 2010 11:34:40 +0000 (14:34 +0300)]
kvm: Fix usage command line format

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Check for read() return value in load_bzimage()
Pekka Enberg [Wed, 14 Jul 2010 11:32:15 +0000 (14:32 +0300)]
kvm: Check for read() return value in load_bzimage()

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix VM support check for unrecognized CPUs
Pekka Enberg [Wed, 14 Jul 2010 11:30:50 +0000 (14:30 +0300)]
kvm: Fix VM support check for unrecognized CPUs

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Use -Os optimization for GCC
Pekka Enberg [Wed, 14 Jul 2010 11:26:47 +0000 (14:26 +0300)]
kvm: Use -Os optimization for GCC

GCC generates unreadable machine code with default optimization level.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm__setup_cpuid: use KVM_GET_SUPPORTED_CPUID to simplify cpuid setup
Asias He [Mon, 12 Jul 2010 12:52:23 +0000 (20:52 +0800)]
kvm__setup_cpuid: use KVM_GET_SUPPORTED_CPUID to simplify cpuid setup

Let kernel setup "struct kvm_cpuid2" for us!

https://kerneltrap.org/mailarchive/linux-kernel/2010/4/27/4563640
Avi Kivity:
'''
No.  KVM_GET_CPUID2 reads what was set by KVM_SET_CPUID, as modified by
the guest executing the cpuid instruction.  KVM_GET_SUPPORTED_CPUID
tells userspace which bits are supported by the host cpu and kvm.

The API for KVM_GET_SUPPORTED_CPUID returns all cpuid leaves supported
in one go, IIRC.
'''
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add --mem= option
Cyrill Gorcunov [Sun, 11 Jul 2010 10:06:30 +0000 (14:06 +0400)]
kvm: Add --mem= option

Which allow an user to specify the amount of memory
he would like to provide for kernel.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agobios: No need for sti at int15 irq exit
Cyrill Gorcunov [Sat, 10 Jul 2010 20:57:47 +0000 (00:57 +0400)]
bios: No need for sti at int15 irq exit

iret will restore eflags anyway

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agobios: Don't clobber 32bit registers
Cyrill Gorcunov [Sat, 10 Jul 2010 20:56:33 +0000 (00:56 +0400)]
bios: Don't clobber 32bit registers

To be on safe side we better to save whole 32bit
of appropriate registers. Even in real mode.

At moment no code affected but it's possible in future.
Actually int15 code does touch 32bit registers but it
uses caller's stack.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: BIOS E820 memory map emulation
Pekka Enberg [Thu, 8 Jul 2010 18:27:35 +0000 (21:27 +0300)]
kvm: BIOS E820 memory map emulation

This patch adds BIOS E820 memory map emulation to KVM.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, bios: Rework BIOS setup
Cyrill Gorcunov [Thu, 8 Jul 2010 15:00:07 +0000 (19:00 +0400)]
kvm, bios: Rework BIOS setup

This is a really huge rework of our primitive BIOS emulator.

The initial idea was to implement stack management in BIOS
irq handlers. In turn it ends up in re-factoring of all BIOS
code.

Some code details
-----------------

1) BIOS stack is placed at predefined constant memory address.
2) BIOS stack is only 64 bytes deep. It must be enough even for
   future irq handlers.
3) To be able to place irq handlers at almost arbitrary place of
   guest memory their start address must be 16 byte aligned.
   This makes easy to compute irq routines local variables addresses.
4) To eliminate address relocations in irq handlers code we use a
   special loader script.

TODO
----

- Still needs e820 map implements, int15 is dummy at moment

P.S. Thanks H. Peter Anvin for advices.

[ penberg@cs.helsinki.fi: cleanups ]
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agoExclude .cscope from .gitignore
Cyrill Gorcunov [Thu, 8 Jul 2010 11:05:46 +0000 (15:05 +0400)]
Exclude .cscope from .gitignore

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, bios: Get rid of buggy int10 handler
Cyrill Gorcunov [Wed, 7 Jul 2010 19:19:34 +0000 (23:19 +0400)]
kvm, bios: Get rid of buggy int10 handler

At moment any BIOS code using which needs own stack
have to be remade. It's a bit not that easy task.

We're happily may live without int10 handler since we
switch to early_printk interface really early. And
actually we don't scan VGA memory anyway so that even
if there is something written we ignore the result.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Cleanup struct boot_params setup
Pekka Enberg [Mon, 5 Jul 2010 19:16:54 +0000 (22:16 +0300)]
kvm: Cleanup struct boot_params setup

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Cleanup kvm__cpu_supports_vm()
Pekka Enberg [Mon, 5 Jul 2010 18:43:17 +0000 (21:43 +0300)]
kvm: Cleanup kvm__cpu_supports_vm()

This patch cleans up kvm__cpu_supports_vm() by unifying the VMX and SVM paths.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Check for SVM extension being supported for AMD cpus
Cyrill Gorcunov [Mon, 5 Jul 2010 17:10:48 +0000 (21:10 +0400)]
kvm: Check for SVM extension being supported for AMD cpus

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Check vmx capability using cpuid
Asias He [Mon, 5 Jul 2010 06:01:11 +0000 (14:01 +0800)]
kvm: Check vmx capability using cpuid

[ penberg@cs.helsinki.fi: use host_cpuid(), cleanups ]
Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Introduce '--kvm-dev' command line option
Pekka Enberg [Sun, 4 Jul 2010 18:57:14 +0000 (21:57 +0300)]
kvm: Introduce '--kvm-dev' command line option

This patch introduces a '--kvm-dev' command line option for debugging purposes.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Introduce 'make devices' target
Pekka Enberg [Sun, 4 Jul 2010 16:24:35 +0000 (19:24 +0300)]
kvm: Introduce 'make devices' target

This patch adds a 'make devices' target to Makefile that sets up KVM device if
one does not exist in '/dev/kvm'.

Suggested-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Fix compilation warning
Pekka Enberg [Sun, 4 Jul 2010 11:13:20 +0000 (14:13 +0300)]
kvm: Fix compilation warning

This patch fixes the following compilation warning:

  main.c: In function ‘main’:
  main.c:149: warning: label ‘out’ defined but not used

Reported-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Don't stop on ioport errors by default
Pekka Enberg [Sun, 4 Jul 2010 11:02:05 +0000 (14:02 +0300)]
kvm: Don't stop on ioport errors by default

This patch introduces a '--ioport-debug' option that preserves the old
stop-on-error behavior and changes the default to keep on running despite of
ioport errors. This allows Linux kernel to boot to VFS mount phase.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add '--params' to usage
Pekka Enberg [Sun, 4 Jul 2010 10:59:10 +0000 (13:59 +0300)]
kvm: Add '--params' to usage

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add proper 00E0 ioport handling
Pekka Enberg [Sun, 4 Jul 2010 10:41:45 +0000 (13:41 +0300)]
kvm: Add proper 00E0 ioport handling

We use 00E0 ioport for trapping to the hypervisor. This patch cleans up
handling of the ioport to call exit() in ioport emulation handler.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Cleanup ioport_ops table
Pekka Enberg [Sun, 4 Jul 2010 10:35:30 +0000 (13:35 +0300)]
kvm: Cleanup ioport_ops table

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Cleanup command line parsing
Pekka Enberg [Sun, 4 Jul 2010 10:32:20 +0000 (13:32 +0300)]
kvm: Cleanup command line parsing

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Use 'nopci pci=off' kernel parameters by default
Pekka Enberg [Sun, 4 Jul 2010 10:18:59 +0000 (13:18 +0300)]
kvm: Use 'nopci pci=off' kernel parameters by default

As pointed out by Cyrill, use 'nopci pci=off' by default to avoid the need for
emulating PCI.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, cpuid: Use logical AND on bit ops
Cyrill Gorcunov [Sun, 4 Jul 2010 10:00:35 +0000 (14:00 +0400)]
kvm, cpuid: Use logical AND on bit ops

Otherwise we may push cleaned bits back.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, cpuid: Fill up func 0 and 4
Cyrill Gorcunov [Sat, 3 Jul 2010 20:52:41 +0000 (00:52 +0400)]
kvm, cpuid: Fill up func 0 and 4

Retun "qemu64" largest function number and set
cpu to GenueIntel, fill up cache info and rename
cpuid to host_cpuid since we may need to distinguish
which cpuid (host or guest) is called.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: KVM_CAP_EXT_CPUID is required
Cyrill Gorcunov [Sat, 3 Jul 2010 17:58:24 +0000 (21:58 +0400)]
kvm: KVM_CAP_EXT_CPUID is required

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, cpuid: Fix XSTOR and VMX compatibility in cpuid
Cyrill Gorcunov [Sat, 3 Jul 2010 15:21:33 +0000 (19:21 +0400)]
kvm, cpuid: Fix XSTOR and VMX compatibility in cpuid

Under virtual environment we don't support XSTOR and VMX features.

Reported-by: Asias He <asias.hejun.hj@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm, tests: Use motherboard specific ports for testing
Cyrill Gorcunov [Thu, 10 Jun 2010 17:15:26 +0000 (21:15 +0400)]
kvm, tests: Use motherboard specific ports for testing

H. Peter Anvin suggested to use motherboard specific ports
for testing instead of ones well known. Thanks, Peter!

Reported-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add force exit from tests
Cyrill Gorcunov [Thu, 10 Jun 2010 16:55:40 +0000 (20:55 +0400)]
kvm: Add force exit from tests

To make so we write any value to port 0 and
start kvm in --dbgtest mode so we are expecting
for this exit.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agotests/pit: Increase PIT frequency up to 1KHz
Cyrill Gorcunov [Wed, 9 Jun 2010 20:05:07 +0000 (00:05 +0400)]
tests/pit: Increase PIT frequency up to 1KHz

Otherwise it's too boring ;)

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Check for HTL extension granted
Cyrill Gorcunov [Wed, 9 Jun 2010 19:05:58 +0000 (23:05 +0400)]
kvm: Check for HTL extension granted

We need it thought it seems it doesn't work in
all our testcases.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
14 years agokvm: Add 'check' target to Makefile
Pekka Enberg [Wed, 9 Jun 2010 18:32:29 +0000 (21:32 +0300)]
kvm: Add 'check' target to Makefile

This patch adds a 'check' target to Makefile that can be used to run some
simple test cases.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm, test: Improve PIT test output
Pekka Enberg [Wed, 9 Jun 2010 18:30:56 +0000 (21:30 +0300)]
kvm, test: Improve PIT test output

This patch makes the PIT test output less verbose.

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add .gitignore for tests
Pekka Enberg [Wed, 9 Jun 2010 18:25:49 +0000 (21:25 +0300)]
kvm: Add .gitignore for tests

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agokvm: Add Makefile for compiling all test cases
Pekka Enberg [Wed, 9 Jun 2010 18:25:18 +0000 (21:25 +0300)]
kvm: Add Makefile for compiling all test cases

Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
14 years agotest/pit: Fill up IDT with noop handler
Cyrill Gorcunov [Wed, 9 Jun 2010 18:17:56 +0000 (22:17 +0400)]
test/pit: Fill up IDT with noop handler

To cover all IRQs.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>