x86emul: fix SYSENTER/SYSCALL switching into 64-bit mode
authorJan Beulich <jbeulich@suse.com>
Thu, 11 Feb 2021 16:53:10 +0000 (17:53 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 11 Feb 2021 16:53:10 +0000 (17:53 +0100)
commitf3e1eb2f0234c955243a915d69ebd84f26eec130
treeccab49370665f3fa278f7d5fbaaf51342f20e7fa
parent01456785ce093d95c6a8515e6b8feeb39e1820b8
x86emul: fix SYSENTER/SYSCALL switching into 64-bit mode

When invoked by compat mode, mode_64bit() will be false at the start of
emulation. The logic after complete_insn, however, needs to consider the
mode switched into, in particular to avoid truncating RIP.

Inspired by / paralleling and extending Linux commit 943dea8af21b ("KVM:
x86: Update emulator context mode if SYSENTER xfers to 64-bit mode").

While there, tighten a related assertion in x86_emulate_wrapper() - we
want to be sure to not switch into an impossible mode when the code gets
built for 32-bit only (as is possible for the test harness).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citirix.com>
xen/arch/x86/x86_emulate/x86_emulate.c