[tip: x86/cleanups] x86/cpu: Constify struct x86_cpu_id
From: tip-bot2 for Christophe JAILLET
Date: Sun Sep 27 2026 - 19:06:40 EST
The following commit has been merged into the x86/cleanups branch of tip:
Commit-ID: c7243accb48a7987b2e80751f712c3f4fe2b3714
Gitweb: https://git.kernel.org/tip/c7243accb48a7987b2e80751f712c3f4fe2b3714
Author: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
AuthorDate: Sun, 09 Aug 2026 23:32:25 +02:00
Committer: Borislav Petkov (AMD) <bp@xxxxxxxxx>
CommitterDate: Sun, 27 Sep 2026 15:50:03 -07:00
x86/cpu: Constify struct x86_cpu_id
'struct x86_cpu_id' is not modified in this compilation unit.
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 kB of memory at runtime.
On a x86_64, with allmodconfig:
text data bss dec hex filename
55725 28774 512 85011 14c13 arch/x86/kernel/cpu/common.o.before
61464 22918 512 84894 14b9e arch/x86/kernel/cpu/common.o.after
[ bp: Massage commit message. ]
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
Signed-off-by: Borislav Petkov (AMD) <bp@xxxxxxxxx>
Link: https://patch.msgid.link/f08d3a0e7aefe3bad66251927cbd03b8cbf9df73.1786311119.git.christophe.jaillet@xxxxxxxxxx
---
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 c735282..593ca8c 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"
{}
};