android_kernel_xiaomi_sdm845/drivers/kvm
Avi Kivity 6af11b9e82 KVM: Prevent system selectors leaking into guest on real->protected mode transition on vmx
Intel virtualization extensions do not support virtualizing real mode.  So
kvm uses virtualized vm86 mode to run real mode code.  Unfortunately, this
virtualized vm86 mode does not support the so called "big real" mode, where
the segment selector and base do not agree with each other according to the
real mode rules (base == selector << 4).

To work around this, kvm checks whether a selector/base pair violates the
virtualized vm86 rules, and if so, forces it into conformance.  On a
transition back to protected mode, if we see that the guest did not touch
a forced segment, we restore it back to the original protected mode value.

This pile of hacks breaks down if the gdt has changed in real mode, as it
can cause a segment selector to point to a system descriptor instead of a
normal data segment.  In fact, this happens with the Windows bootloader
and the qemu acpi bios, where a protected mode memcpy routine issues an
innocent 'pop %es' and traps on an attempt to load a system descriptor.

"Fix" by checking if the to-be-restored selector points at a system segment,
and if so, coercing it into a normal data segment.  The long term solution,
of course, is to abandon vm86 mode and use emulation for big real mode.

Signed-off-by: Avi Kivity <avi@qumranet.com>
2007-03-27 17:54:38 +02:00
..
Kconfig [PATCH] KVM: Put KVM in a new Virtualization menu 2006-12-13 09:05:46 -08:00
kvm_main.c KVM: Unset kvm_arch_ops if arch module loading failed 2007-03-18 10:49:06 +02:00
kvm_svm.h KVM: Use ARRAY_SIZE macro instead of manual calculation. 2007-03-04 11:12:39 +02:00
kvm_vmx.h [PATCH] KVM: Replace __x86_64__ with CONFIG_X86_64 2006-12-13 09:05:46 -08:00
kvm.h KVM: Per-vcpu inodes 2007-03-04 11:12:42 +02:00
Makefile [PATCH] kvm: userspace interface 2006-12-10 09:57:22 -08:00
mmu.c KVM: MMU: Fix host memory corruption on i386 with >= 4GB ram 2007-03-18 10:49:09 +02:00
paging_tmpl.h KVM: Cosmetics 2007-03-04 11:12:39 +02:00
segment_descriptor.h [PATCH] kvm: userspace interface 2006-12-10 09:57:22 -08:00
svm.c KVM: Per-vcpu inodes 2007-03-04 11:12:42 +02:00
svm.h [PATCH] kvm: userspace interface 2006-12-10 09:57:22 -08:00
vmx.c KVM: Prevent system selectors leaking into guest on real->protected mode transition on vmx 2007-03-27 17:54:38 +02:00
vmx.h [PATCH] kvm: vmx: handle triple faults by returning EXIT_REASON_SHUTDOWN to userspace 2007-02-12 09:48:40 -08:00
x86_emulate.c [PATCH] KVM: x86 emulator: fix bit string instructions 2007-01-23 07:52:06 -08:00
x86_emulate.h [PATCH] KVM: Replace __x86_64__ with CONFIG_X86_64 2006-12-13 09:05:46 -08:00