On 17/08/2023 7:22 am, Jan Beulich wrote:
> --- a/xen/lib/x86/cpuid.c
> +++ b/xen/lib/x86/cpuid.c
> @@ -104,6 +104,22 @@ void x86_cpu_featureset_to_policy(
>      p->feat._7d1             = fs[FEATURESET_7d1];
>      p->arch_caps.lo          = fs[FEATURESET_m10Al];
>      p->arch_caps.hi          = fs[FEATURESET_m10Ah];
> +
> +    /*
> +     * We may force-enable certain features, which then needs reflecting in
> +     * respective max leaf / subleaf values.
> +     *
> +     * ARCH_CAPS lives in 7d0.
> +     */
> +    if ( p->feat._7d0 && p->basic.max_leaf < 7 )
> +        p->basic.max_leaf = 7;
> +
> +    /*
> +     * AMD's speculation related features (e.g. LFENCE_DISPATCH) live in
> +     * leaf e21a.
> +     */
> +    if ( p->extd.e21a && p->extd.max_leaf < 0x80000021 )
> +        p->extd.max_leaf = 0x80000021;

This logic cannot live here - this function is a simple deserialisation
of an array.

Such logic belongs in create compatible policy, the patch for which has
been pending even longer.

The toolstack does need to take when extending like this, and it is not
safe to do it automatically like this.

~Andrew

Reply via email to