Re: Subject: [patch V3 09/30] x86/microcode/intel: Switch to kvmalloc()

From: Qiuxu Zhuo
Date: Mon Sep 25 2023 - 11:44:43 EST


> ...
> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> Microcode blobs are getting larger and might soon reach the kmalloc()
> limit. Switch over kvmalloc().
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> ---
> arch/x86/kernel/cpu/microcode/intel.c | 50 +++++++++++++++++-----------------
> 1 file changed, 26 insertions(+), 24 deletions(-)
> ---
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> ...
> static void save_microcode_patch(struct microcode_intel *patch)
> {
> - struct microcode_intel *mc;
> + unsigned int size = get_totalsize(&patch->hdr);
> + struct microcode_intel *mc = NULL;

No need to initialize the 'mc' to NULL as it's unconditionally
set by the following kmemdup().

>
> - mc = kmemdup(patch, get_totalsize(&patch->hdr), GFP_KERNEL);
> + mc = kvmemdup(patch, size, GFP_KERNEL);
> if (mc)
> update_ucode_pointer(mc);
> + else
> + pr_err("Unable to allocate microcode memory size: %u\n", size);
> }
>
> ...