x86/xstate: Elide redundant writes in set_xcr0()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Apr 2021 19:17:55 +0000 (20:17 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 4 May 2021 18:12:47 +0000 (19:12 +0100)
commit9478ee4a1501c8899307eaa24585f8c6f8d23fa9
treeeb97c6ae0b74a35544912180ad658aa714ad3833
parent27f32dbdb1b11d171f0fa4dfd3263b44e9f7c71c
x86/xstate: Elide redundant writes in set_xcr0()

XSETBV is an expensive instruction as, amongst other things, it involves
reconfiguring the instruction decode at the frontend of the pipeline.

We have several paths which reconfigure %xcr0 in quick succession (the context
switch path has 5, including the fpu save/restore helpers), and only a single
caller takes any care to try to skip redundant writes.

Update set_xcr0() to perform amortisation automatically, and simplify the
__context_switch() path as a consequence.

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