[PATCH] x86/cpu: Constify struct x86_cpu_id

From: Christophe JAILLET

Date: Sun Aug 09 2026 - 17:32:56 EST


'struct x86_cpu_id' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increases overall security.

It is only used in cpu_has_old_microcode() which is an __init function.
So, using __initconst is safe and will save about 6 ko of memory at
runtime.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
55725 28774 512 85011 14c13 arch/x86/kernel/cpu/common.o

After:
=====
text data bss dec hex filename
61464 22918 512 84894 14b9e arch/x86/kernel/cpu/common.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
Compile tested only.
---
arch/x86/kernel/cpu/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index fa429f04f003..fb6ec831d250 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1427,7 +1427,7 @@ static bool __init vulnerable_to_its(u64 x86_arch_cap_msr)
return false;
}

-static struct x86_cpu_id cpu_latest_microcode[] = {
+static const struct x86_cpu_id cpu_latest_microcode[] __initconst = {
#include "microcode/intel-ucode-defs.h"
{}
};
--
2.55.0