On 16.08.2024 13:14, Sergiy Kibrik wrote:
> Put platforms-specific code under #ifdef CONFIG_{AMD,INTEL} so that when
> corresponding CPU support is disabled by configuration less dead code will end
> up in the build.
>
> This includes re-ordering of calls to ibpb_calculations() &
> div_calculations(),
> but since they don't access common variables or feature bits it should be
> safe to do.
>
> Signed-off-by: Sergiy Kibrik <[email protected]>
> CC: Jan Beulich <[email protected]>
For one please consider adding Requested-by: or Suggested-by: tags.
> --- a/xen/arch/x86/spec_ctrl.c
> +++ b/xen/arch/x86/spec_ctrl.c
> @@ -1012,6 +1012,7 @@ static bool __init should_use_eager_fpu(void)
> }
> }
>
> +#ifdef CONFIG_AMD
> /*
> *
> https://www.amd.com/content/dam/amd/en/documents/corporate/cr/speculative-return-stack-overflow-whitepaper.pdf
> */
> @@ -1110,6 +1111,7 @@ static void __init div_calculations(bool hw_smt_enabled)
> "enabled. Please assess your configuration and choose an\n"
> "explicit 'smt=<bool>' setting. See XSA-439.\n");
> }
> +#endif /* CONFIG_AMD */
And then no, I don't think we want to use #ifdef-ary here. IS_ENABLED()
inside the functions (where the vendor checks are) is not only making
sure the compiler will still parse all the code even when either vendor's
support was turned off, but will also help review (by having in context
what the actual vendor checks are in each function).
Jan