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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>