x86/vmx: Shorten vmx_{get,set}_segment_register() for user segments
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 23 Sep 2016 14:03:08 +0000 (15:03 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Dec 2016 12:56:38 +0000 (12:56 +0000)
commitda2209921e509d809f049b98467b019b4600aebb
treefb5503de2ca3ec533b18794cb2c75fe9299f7af5
parent660eb42c021869cb57a32504e875135ea167f056
x86/vmx: Shorten vmx_{get,set}_segment_register() for user segments

The x86_segment enumeration matches hardware SReg encoding, which can be used
to calculate the appropriate VMCS fields, rather than open coding every
instance.

This reduces the size of the switch statement, and the number of embedded BUG
frames from the __vm{read,write}() calls.  In the unlikely case that a call
does fault, the field can unambiguously be retrieved from the GPR state
printed.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vmx/vmcs.h