Re: [PATCH v2 01/10] x86/microcode/intel: expose collect_cpu_info_early() for IFS
From: Borislav Petkov
Date: Fri Apr 08 2022 - 04:34:28 EST
On Thu, Apr 07, 2022 at 12:13:38PM -0700, Jithu Joseph wrote:
> diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h
> index d85a07d7154f..cf0fd1d712b4 100644
> --- a/arch/x86/include/asm/microcode_intel.h
> +++ b/arch/x86/include/asm/microcode_intel.h
> @@ -68,6 +68,10 @@ static inline u32 intel_get_microcode_revision(void)
> return rev;
> }
>
> +int cpu_collect_info_early(struct ucode_cpu_info *uci);
> +bool cpu_signatures_match(unsigned int s1, unsigned int p1,
> + unsigned int s2, unsigned int p2);
> +
So you can't move the functions to cpu/intel.c but put the
prototype declarations in the microcode header - they should go to
arch/x86/include/asm/cpu.h or so.
> #ifdef CONFIG_MICROCODE_INTEL
> extern void __init load_ucode_intel_bsp(void);
> extern void load_ucode_intel_ap(void);
> diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
> index 8321c43554a1..2008c8267fd3 100644
> --- a/arch/x86/kernel/cpu/intel.c
> +++ b/arch/x86/kernel/cpu/intel.c
> @@ -181,6 +181,53 @@ static bool bad_spectre_microcode(struct cpuinfo_x86 *c)
> return false;
> }
>
> +bool cpu_signatures_match(unsigned int s1, unsigned int p1,
That function is Intel-specific:
intel_cpu_signatures_match()
and it is small enough to stick it in the above header and make it an
inline without the need for an export.
> + unsigned int s2, unsigned int p2)
> +{
> + if (s1 != s2)
> + return false;
> +
> + /* Processor flags are either both 0 ... */
> + if (!p1 && !p2)
> + return true;
> +
> + /* ... or they intersect. */
> + return p1 & p2;
> +}
> +EXPORT_SYMBOL_GPL(cpu_signatures_match);
> +
> +int cpu_collect_info_early(struct ucode_cpu_info *uci)
intel_collect_cpu_info_early()
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette