x86/cpuid: Fix feature flags reported to dom0
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 12 Jan 2017 16:14:56 +0000 (16:14 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 13 Jan 2017 13:16:57 +0000 (13:16 +0000)
commit38b1c3a5affbe3451f366576aef9c7149d62de04
tree21640a93aa24fbcaa7c098143dd77721def7fc91
parent2704c78aaa156e6843681ee344dd0ce75dbc63b2
x86/cpuid: Fix feature flags reported to dom0

c/s a11e8c9 "x86/pv: Use per-domain policy information in pv_cpuid()" switched
PV domains from using a (hardware for dom0, toolstack-chosen from domU) value
masked against pv_featureset[], to actually using the value calculated by
recalculate_cpuid_policy().

For domU, this is no practical change as the content is still chosen by the
toolstack.  For dom0 however, we no longer have two sources of information
potentially clearing bits.  Modern Linux seems to care about having CMP_LEGACY
set in its view of CPUID on an Intel box.

The deliberate setting of HTT, X2APIC and CMP_LEGACY in {pv,hvm}_featureset[]
is necessary for domUs, as the toolstack may have (tried to) set up topology
information in a different representation than the hardware uses.  The bits
therefore needed to be set in the masks used in the older logic, to avoid
clobbering the toolstacks information.

Move the HTT/X2APIC/CMP_LEGACY logic from calculate_{pv,hvm}_max_policy()
(where the meaning of {pv,hvm}_featureset[] has changed subtly) to
recalculate_cpuid_policy() where the masking logic now lives.

This will cause {pv,hvm}_max_policy to actually contain real hardware values
(so dom0 sees real hardware values), but still allows the toolstack to set
bits not present in real hardware for domUs.

Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpuid.c