]> xenbits.xensource.com Git - xen.git/commit
x86/vmx: Fold VMCS logic in vmx_{get,set}_segment_register()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 21 Jan 2022 11:00:09 +0000 (11:00 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 27 Jan 2022 17:38:15 +0000 (17:38 +0000)
commitb4c669fd7eabfdba93aa96a3a3b62829a67a60d5
tree7dd60ecdc72759d03ba5b26c561c4ef58f995c65
parent0bdc43c8dec993258e930b34855853c22b917519
x86/vmx: Fold VMCS logic in vmx_{get,set}_segment_register()

Xen's segment enumeration almost matches the VMCS encoding order, while the
VMCS encoding order has the system segments immediately following the user
segments for all relevant attributes.

Use a sneaky xor to hide the difference in encoding order to fold the switch
statements, dropping 10 __vmread() and 10 __vmwrite() calls.  Bloat-o-meter
reports:

  add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-433 (-433)
  Function                                     old     new   delta
  vmx_set_segment_register                     804     593    -211
  vmx_get_segment_register                     778     556    -222

showing that these wrappers aren't trivial.  In addition, 20 BUGs worth of
metadata are dropped.

No functional change.

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