x86: remove the use of vm86_mode()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 7 Apr 2016 22:05:01 +0000 (00:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 7 Apr 2016 22:05:01 +0000 (00:05 +0200)
commita35dc6ccbb5c77f83dd03f6de0e58e71f805debf
treea74862482eeba4a872a992c991d779769b6a1de1
parent9d313bdebb86ff4dc663f740e7a9a158e238303d
x86: remove the use of vm86_mode()

Xen, being 64bit only, cannot run PV guests in vm86 mode.  HVM guests however
can be running in vm86 mode, and common codepaths need to be able to cope.

The definition of vm86_mode() in x86_64/regs.h is incorrect, as the predicate
is used by non-PV codepaths.

One buggy use is in hvm/emulate.c.  An HVM guest can be in vm86 mode, and
vm86_mode() sliently omits the check.  Luckily, due to the VEX prefix decoding
logic in x86_emulate(), there is no path to the erronious use with EFLAGS_VM
set.

Another potentially problematic use is in show_guest_stack().  In principle,
show_guest_stack() is common code called for both PV and HVM vcpus.  HVM vcpus
exit early (with no reasonable way of making the code generic), making this
part a PV-only codepath.

Open-code its use in emulate.c, matching the surrounding code.  This causes
all other uses to be in PV-only codepaths, making the code to be logically
dead.  Drop it completely, to avoid future misuse.

Part of resulting cleanup removes vm86attr from read_descriptor(), although
retaining one relevant piece of information; i.e. whether we are reading a
selector for an instruction fetch, or a data fetch.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/emulate.c
xen/arch/x86/traps.c
xen/include/asm-x86/regs.h
xen/include/asm-x86/x86_64/regs.h