mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
x86/cpuid: Store the toolstacks choice of hypervisor max leaf
This removes all dependencies on the legacy cpuids[] array from cpuid_hypervisor_leaves(). Swap a BUG() to an ASSERT_UNREACHABLE(), because in the unlikely case that we hit it, returning all zeros to the guest is fine. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
07097cc0c6
commit
9db5d75c91
3 files changed
+16
-14
No files matched your search
@@ -136,6 +136,14 @@ static int update_domain_cpuid_info(struct domain *d,
|
||||
p->basic.raw[ctl->input[0]] = leaf;
|
||||
break;
|
||||
|
||||
case 0x40000000:
|
||||
p->hv_limit = ctl->eax;
|
||||
break;
|
||||
|
||||
case 0x40000100:
|
||||
p->hv2_limit = ctl->eax;
|
||||
break;
|
||||
|
||||
case 0x80000000 ... 0x80000000 + ARRAY_SIZE(p->extd.raw) - 1:
|
||||
p->extd.raw[ctl->input[0] - 0x80000000] = leaf;
|
||||
break;
|
||||
|
||||
+5
-14
@@ -906,26 +906,17 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf,
|
||||
uint32_t subleaf, struct cpuid_leaf *res)
|
||||
{
|
||||
const struct domain *d = v->domain;
|
||||
const struct cpuid_policy *p = d->arch.cpuid;
|
||||
uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
|
||||
uint32_t idx = leaf - base;
|
||||
uint32_t limit, dummy;
|
||||
unsigned int limit = is_viridian_domain(d) ? p->hv2_limit : p->hv_limit;
|
||||
|
||||
if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
|
||||
return; /* Avoid unnecessary pass through domain_cpuid() */
|
||||
|
||||
domain_cpuid(d, base, 0, &limit, &dummy, &dummy, &dummy);
|
||||
if ( limit == 0 )
|
||||
/* Default number of leaves */
|
||||
limit = XEN_CPUID_MAX_NUM_LEAVES;
|
||||
else
|
||||
{
|
||||
/* User-specified number of leaves */
|
||||
limit &= 0xff;
|
||||
if ( limit < 2 )
|
||||
limit = 2;
|
||||
else if ( limit > XEN_CPUID_MAX_NUM_LEAVES )
|
||||
limit = XEN_CPUID_MAX_NUM_LEAVES;
|
||||
}
|
||||
/* Clamp toolstack value between 2 and MAX_NUM_LEAVES. */
|
||||
limit = min(max(limit, 2u), XEN_CPUID_MAX_NUM_LEAVES + 0u);
|
||||
|
||||
if ( idx > limit )
|
||||
return;
|
||||
@@ -1015,7 +1006,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf,
|
||||
break;
|
||||
|
||||
default:
|
||||
BUG();
|
||||
ASSERT_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,9 @@ struct cpuid_policy
|
||||
#undef __DECL_BITFIELD
|
||||
#undef _DECL_BITFIELD
|
||||
#undef DECL_BITFIELD
|
||||
|
||||
/* Toolstack selected Hypervisor max_leaf (if non-zero). */
|
||||
uint8_t hv_limit, hv2_limit;
|
||||
};
|
||||
|
||||
/* Fill in a featureset bitmap from a CPUID policy. */
|
||||
|
||||