x86/cpuid: Clobber CPUID leaves 0x800000{1d..20} in policies
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 6 Apr 2022 21:40:20 +0000 (22:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 7 Apr 2022 10:36:45 +0000 (11:36 +0100)
commitd4012d50082c2eae2f3cbe7770be13b9227fbc3f
tree4f357e255e4c364ac2031b9d4996f01de2a2ee5c
parent99d829dba1390b98a3ca07b365713e62182ee7ca
x86/cpuid: Clobber CPUID leaves 0x800000{1d..20} in policies

c/s 1a914256dca5 increased the AMD max leaf from 0x8000001c to 0x80000021, but
did not adjust anything in the calculate_*_policy() chain.  As a result, on
hardware supporting these leaves, we read the real hardware values into the
raw policy, then copy into host, and all the way into the PV/HVM default
policies.

All 4 of these leaves have enable bits (first two by TopoExt, next by SEV,
next by PQOS), so any software following the rules is fine and will leave them
alone.  However, leaf 0x8000001d takes a subleaf input and at least two
userspace utilities have been observed to loop indefinitely under Xen (clearly
waiting for eax to report "no more cache levels").

Such userspace is buggy, but Xen's behaviour isn't great either.

In the short term, clobber all information in these leaves.  This is a giant
bodge, but there are complexities with implementing all of these leaves
properly.

Fixes: 1a914256dca5 ("x86/cpuid: support LFENCE always serialising CPUID bit")
Link: https://github.com/QubesOS/qubes-issues/issues/7392
Reported-by: fosslinux <fosslinux@aussies.space>
Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpuid.c