x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 28 Jan 2022 11:57:19 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 1 Feb 2022 13:20:44 +0000 (13:20 +0000)
commit00f2992b6c7a9d4090443c1a85bf83224a87eeb9
treef8539b0d4a820adc0da80c360e5236adfa483710
parent71fac402e05ade7b0af2c34f77517449f6f7e2c1
x86/spec-ctrl: Record the last write to MSR_SPEC_CTRL

In some cases, writes to MSR_SPEC_CTRL do not have interesting side effects,
and we should implement lazy context switching like we do with other MSRs.

In the short term, this will be used by the SVM infrastructure, but I expect
to extend it to other contexts in due course.

Introduce cpu_info.last_spec_ctrl for the purpose, and cache writes made from
the boot/resume paths.  The value can't live in regular per-cpu data when it
is eventually used for PV guests when XPTI might be active.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/acpi/power.c
xen/arch/x86/include/asm/current.h
xen/arch/x86/include/asm/spec_ctrl_asm.h
xen/arch/x86/setup.c
xen/arch/x86/smpboot.c
xen/arch/x86/spec_ctrl.c