x86/xstate: reset cached register values on resume
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fri, 19 Nov 2021 08:40:44 +0000 (09:40 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Nov 2021 08:40:44 +0000 (09:40 +0100)
commit3d031d9e79481768abf93c1aab30116806eb604f
tree947e4e39ccfddfe6b59a0653be89ce02a3f163ae
parent9d3bac49a54ffacd44d7fffda307b211d78b2ce0
x86/xstate: reset cached register values on resume

set_xcr0() and set_msr_xss() use cached value to avoid setting the
register to the same value over and over. But suspend/resume implicitly
reset the registers and since percpu areas are not deallocated on
suspend anymore, the cache gets stale.
Reset the cache on resume, to ensure the next write will really hit the
hardware. Choose value 0, as it will never be a legitimate write to
those registers - and so, will force write (and cache update).

Note the cache is used io get_xcr0() and get_msr_xss() too, but:
- set_xcr0() is called few lines below in xstate_init(), so it will
  update the cache with appropriate value
- get_msr_xss() is not used anywhere - and thus not before any
  set_msr_xss() that will fill the cache

Fixes: aca2a985a55a "xen: don't free percpu areas during suspend"
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: f7f4a523927fa4c7598e4647a16bc3e3cf8009d0
master date: 2021-11-04 14:42:37 +0100
xen/arch/x86/xstate.c