x86/cpuid: Rework HLE and RTM handling
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 4 Jun 2021 12:56:56 +0000 (14:56 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Jun 2021 12:56:56 +0000 (14:56 +0200)
commit3f8549386bc72b0ddc7020eec97f0b497785193e
tree15bc700dd7ea66a717267e882bb580f175a0cc0a
parentac507e078edcc18215d86c436d6c26dd76ffa15c
x86/cpuid: Rework HLE and RTM handling

The TAA mitigation offered the option to hide the HLE and RTM CPUID bits,
which has caused some migration compatibility problems.

These two bits are special.  Annotate them with ! to emphasise this point.

Hardware Lock Elision (HLE) may or may not be visible in CPUID, but is
disabled in microcode on all CPUs, and has been removed from the architecture.
Do not advertise it to VMs by default.

Restricted Transactional Memory (RTM) may or may not be visible in CPUID, and
may or may not be configured in force-abort mode.  Have tsx_init() note
whether RTM has been configured into force-abort mode, so
guest_common_feature_adjustments() can conditionally hide it from VMs by
default.

The host policy values for HLE/RTM may or may not be set, depending on any
previous running kernel's choice of visibility, and Xen's choice.  TSX is
available on any CPU which enumerates a TSX-hiding mechanism, so instead of
doing a two-step to clobber any hiding, scan CPUID, then set the visibility,
just force visibility of the bits in the first place.

With the HLE/RTM bits now unilaterally visible in the host policy,
xc_cpuid_apply_policy() can construct a more appropriate policy out of thin
air for pre-4.13 VMs with no CPUID data in their migration stream, and
specifically one where HLE/RTM doesn't potentially disappear behind the back
of a running VM.

Fixes: 8c4330818f6 ("x86/spec-ctrl: Mitigate the TSX Asynchronous Abort sidechannel")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: 8fe24090d940d760145ccd5e234290be7418b175
master date: 2021-05-27 19:34:00 +0100
tools/libxc/xc_cpuid_x86.c
xen/arch/x86/cpuid.c
xen/arch/x86/spec_ctrl.c
xen/arch/x86/tsx.c
xen/include/asm-x86/processor.h
xen/include/public/arch-x86/cpufeatureset.h