Re: [PATCH 04/12] x86/mm: get INVLPGB count max from CPUID

From: Borislav Petkov
Date: Thu Jan 02 2025 - 07:15:47 EST


On Mon, Dec 30, 2024 at 12:53:05PM -0500, Rik van Riel wrote:
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index f1fea506e20f..6c4d08f8f7b1 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -138,6 +138,10 @@ __visible unsigned long mmu_cr4_features __ro_after_init;
> __visible unsigned long mmu_cr4_features __ro_after_init = X86_CR4_PAE;
> #endif
>
> +#ifdef CONFIG_CPU_SUP_AMD
> +u16 invlpgb_count_max __ro_after_init;
> +#endif

You can define this in amd.c and put the ifdeffery in the header. Something
like:

#ifdef CONFIG_CPU_SUP_AMD
extern u16 invlpgb_count_max __ro_after_init;
#else
#define invlpgb_count_max 0
#endif

or so and use it freely in the remaining places.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette