x86/amd: Use newer SSBD mechanisms if they exist
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 30 Nov 2018 17:17:38 +0000 (17:17 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 8 Sep 2021 13:16:19 +0000 (14:16 +0100)
commit2a4e6c4e4bea2e0bb720418c331ee28ff9c7632e
tree0879dda024c4275ef1a136907085e259cc593600
parent747424c664bb164a04e7a9f2ffbf02d4a1630d7d
x86/amd: Use newer SSBD mechanisms if they exist

The opencoded legacy Memory Disambiguation logic in init_amd() neglected
Fam19h for the Zen3 microarchitecture.  Further more, all Zen2 based system
have the architectural MSR_SPEC_CTRL and the SSBD bit within it, so shouldn't
be using MSR_AMD64_LS_CFG.

Implement the algorithm given in AMD's SSBD whitepaper, and leave a
printk_once() behind in the case that no controls can be found.

This now means that a user explicitly choosing `spec-ctrl=ssbd` will properly
turn off Memory Disambiguation on Fam19h/Zen3 systems.

This still remains a single system-wide setting (for now), and is not context
switched between vCPUs.  As such, it doesn't interact with Intel's use of
MSR_SPEC_CTRL and default_xen_spec_ctrl (yet).

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/amd.c
xen/arch/x86/cpu/cpu.h
xen/arch/x86/cpu/hygon.c
xen/arch/x86/spec_ctrl.c