TCG reports the SEP feature (SYSENTER/SYSEXIT) in user mode emulation,
but does not plumb it into the linux-user run loop. Split the helper into
system emulation and user-mode emulation cases and implement the latter.
SYSENTER does not have the best design for a kernel-mode entry
instruction, and therefore Linux always makes it return to the
vsyscall page. Because QEMU does not provide the_contents_ of
the vsyscall page, the instructions executed after SYSEXIT have
to be emulated by hand until the first RET.
Some corner cases, such as restarting the system call after the
system call has rewritten the SYSENTER instruction, are not emulated
correctly. On Linux, the system call restart uses the SYSENTER
call in the vsyscall page, while on QEMU it uses the emulated
program's instruction.
Signed-off-by: Paolo Bonzini<pbonzini@redhat.com>
---
linux-user/i386/cpu_loop.c | 51 +++++++++++++++++++++++++++--
target/i386/cpu.c | 9 ++++-
target/i386/cpu.h | 1 +
target/i386/helper.h | 2 +-
target/i386/tcg/seg_helper.c | 33 -------------------
target/i386/tcg/sysemu/seg_helper.c | 33 +++++++++++++++++++
target/i386/tcg/translate.c | 2 +-
target/i386/tcg/user/seg_helper.c | 16 +++++++++
8 files changed, 109 insertions(+), 38 deletions(-)