]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: fix missing checks in syscall emulation
authorStephan Bärwolf <stephan.baerwolf@tu-ilmenau.de>
Thu, 12 Jan 2012 15:43:04 +0000 (16:43 +0100)
committerAvi Kivity <avi@redhat.com>
Wed, 1 Feb 2012 09:43:40 +0000 (11:43 +0200)
commitf6f77e4e93106f1927905f19d8eac2891bb78b67
tree0589cb84f1548ecc83999e8e61cd05121d9c51fd
parent4047dd2be20dd8512f3f8a7320ca1618159b4b75
KVM: x86: fix missing checks in syscall emulation

On hosts without this patch, 32bit guests will crash (and 64bit guests
may behave in a wrong way) for example by simply executing following
nasm-demo-application:

    [bits 32]
    global _start
    SECTION .text
    _start: syscall

(I tested it with winxp and linux - both always crashed)

    Disassembly of section .text:

    00000000 <_start>:
       0:   0f 05                   syscall

The reason seems a missing "invalid opcode"-trap (int6) for the
syscall opcode "0f05", which is not available on Intel CPUs
within non-longmodes, as also on some AMD CPUs within legacy-mode.
(depending on CPU vendor, MSR_EFER and cpuid)

Because previous mentioned OSs may not engage corresponding
syscall target-registers (STAR, LSTAR, CSTAR), they remain
NULL and (non trapping) syscalls are leading to multiple
faults and finally crashs.

Depending on the architecture (AMD or Intel) pretended by
guests, various checks according to vendor's documentation
are implemented to overcome the current issue and behave
like the CPUs physical counterparts.

[mtosatti: cleanup/beautify code]

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/kvm/emulate.c