]> xenbits.xensource.com Git - xen.git/commit
amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD
authorRoger Pau Monné <roger.pau@citrix.com>
Mon, 15 Aug 2022 07:58:55 +0000 (09:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 15 Aug 2022 07:58:55 +0000 (09:58 +0200)
commit646589ac148a2ff6bb222a6081b4d7b13ee468c0
tree3cc19ad8e47095c39669d00b6d3867fe0d45322d
parenta2eeaa6906101fbf322766f37f8f061dd36fe58d
amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD

Expose VIRT_SSBD to guests if the hardware supports setting SSBD in
the LS_CFG MSR (a.k.a. non-architectural way). Different AMD CPU
families use different bits in LS_CFG, so exposing VIRT_SPEC_CTRL.SSBD
allows for an unified way of exposing SSBD support to guests on AMD
hardware that's compatible migration wise, regardless of what
underlying mechanism is used to set SSBD.

Note that on AMD Family 17h and Hygon Family 18h processors the value
of SSBD in LS_CFG is shared between threads on the same core, so
there's extra logic in order to synchronize the value and have SSBD
set as long as one of the threads in the core requires it to be set.
Such logic also requires extra storage for each thread state, which is
allocated at initialization time.

Do the context switching of the SSBD selection in LS_CFG between
hypervisor and guest in the same handler that's already used to switch
the value of VIRT_SPEC_CTRL.

Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Henry Wang <Henry.Wang@arm.com>
CHANGELOG.md
xen/arch/x86/cpu/amd.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/include/asm/amd.h
xen/arch/x86/spec_ctrl.c