@@ -586,6 +586,10 @@ static void test_is_compatible_success(void)
.platform_info.cpuid_faulting = true,
},
},
+ {
+ .name = "Host missing leaf 0xb, Guest wanted",
+ .guest.basic.max_leaf = 0xb,
+ },
};
struct cpu_policy_errors no_errors = INIT_CPU_POLICY_ERRORS;
@@ -614,7 +618,7 @@ static void test_is_compatible_failure(void)
} tests[] = {
{
.name = "Host basic.max_leaf out of range",
- .guest.basic.max_leaf = 1,
+ .guest.basic.max_leaf = 0xc,
.e = { 0, -1, -1 },
},
{
@@ -15,7 +15,16 @@ int x86_cpu_policies_are_compatible(const struct cpu_policy *host,
#define FAIL_MSR(m) \
do { e.msr = (m); goto out; } while ( 0 )
- if ( guest->basic.max_leaf > host->basic.max_leaf )
+ /*
+ * Old AMD hardware doesn't expose topology information in leaf 0xb. We
+ * want to emulate that leaf with credible information because it must be
+ * present on systems in which we emulate the x2APIC.
+ *
+ * For that reason, allow the max basic guest leaf to be larger than the
+ * hosts' up until 0xb.
+ */
+ if ( guest->basic.max_leaf > 0xb &&
+ guest->basic.max_leaf > host->basic.max_leaf )
FAIL_CPUID(0, NA);
if ( guest->feat.max_subleaf > host->feat.max_subleaf )
Allow a guest policy have up to leaf 0xb even if the host doesn't. Otherwise it's not possible to show leaf 0xb to guests we're emulating an x2APIC for on old AMD machines. No externally visible changes though because toolstack doesn't yet populate that leaf. Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com> --- tools/tests/cpu-policy/test-cpu-policy.c | 6 +++++- xen/lib/x86/policy.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-)