On 21/10/2024 4:45 pm, Alejandro Vallejo wrote:
> Bump it to ARRAY_SIZE() so toolstack is able to extend a policy past
> host limits (i.e: to emulate a feature not present in the host)
>
> Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
> ---
> v7:
> * Replaces v6/patch1("Relax checks about policy compatibility")
> * Bumps basic.max_leaf to ARRAY_SIZE(basic.raw) to pass the
> compatibility checks rather than tweaking the checker.
> ---
> xen/arch/x86/cpu-policy.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
> index b6d9fad56773..715a66d2a978 100644
> --- a/xen/arch/x86/cpu-policy.c
> +++ b/xen/arch/x86/cpu-policy.c
> @@ -585,6 +585,9 @@ static void __init calculate_pv_max_policy(void)
> */
> p->feat.max_subleaf = ARRAY_SIZE(p->feat.raw) - 1;
>
> + /* Toolstack may populate leaves not present in the basic host leaves */
> + p->basic.max_leaf = ARRAY_SIZE(p->basic.raw) - 1;
> +
> x86_cpu_policy_to_featureset(p, fs);
>
> for ( i = 0; i < ARRAY_SIZE(fs); ++i )
> @@ -672,6 +675,9 @@ static void __init calculate_hvm_max_policy(void)
> */
> p->feat.max_subleaf = ARRAY_SIZE(p->feat.raw) - 1;
>
> + /* Toolstack may populate leaves not present in the basic host leaves */
> + p->basic.max_leaf = ARRAY_SIZE(p->basic.raw) - 1;
> +
> x86_cpu_policy_to_featureset(p, fs);
>
> mask = hvm_hap_supported() ?
This sadly doesn't do what you want. It leaves the default policy with
extended limits too.
To unblock the work (which is long overdue), here's one I prepared
earlie^W just now.
https://lore.kernel.org/xen-devel/20241029175505.2698661-1-andrew.cooper3@citrix.com/T/#u
~Andrew