x86/microcode/AMD: Increase microcode PATCH_MAX_SIZE
Subsystems (3)
PATCH 1/1 x86/microcode/AMD: Increase microcode PATCH_MAX_SIZE
Future AMD cpus will have microcode patches that exceed the current limit of three 4K pages. Increase substantially to avoid future size increases.
--- arch/x86/include/asm/microcode_amd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/microcode_amd.h +1 -1
@@ -41,7 +41,7 @@ struct microcode_amd {unsigned int mpb[]; }; -#define PATCH_MAX_SIZE (3 * PAGE_SIZE) +#define PATCH_MAX_SIZE (8 * PAGE_SIZE)#ifdef CONFIG_MICROCODE_AMD extern void __init load_ucode_amd_bsp (unsigned int family);
Signature · 1 line
2.39.3
Quoted 3 lines · John Allen
Future AMD cpus will have microcode patches that exceed the current limit of three 4K pages. Increase substantially to avoid future size increases.
Hi,
so with my current distro (openSUSE TW):
$ zgrep NODES_SHIFT /proc/config.gz CONFIG_NODES_SHIFT=10
This:
static u8 amd_ucode_patch[MAX_NUMNODES][PATCH_MAX_SIZE];
is now 32M instead of 12M. That is a complete waste on my _one_ node system. Can we make amd_ucode_patch dynamic first, depending on num_online_nodes()?
Quoted 11 lines
Signed-off-by John Allen <[email protected]>--- arch/x86/include/asm/microcode_amd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/include/asm/microcode_amd.h +0
-0
arch/x86/include/asm/microcode_amd.h struct microcode_amd { · line 47
Quoted 8 lines
arch/x86/include/asm/microcode_amd.h +1
-1@@ -41,7 +41,7 @@ struct microcode_amd {unsigned int mpb[]; }; -#define PATCH_MAX_SIZE (3 * PAGE_SIZE) +#define PATCH_MAX_SIZE (8 * PAGE_SIZE)#ifdef CONFIG_MICROCODE_AMD extern void __init load_ucode_amd_bsp (unsigned int family);
thanks,
Signature · 2 lines
js suse labs
Borislav Petkov
maintainerQuoted 2 lines · Jiri Slaby
is now 32M instead of 12M. That is a complete waste on my _one_ node system. Can we make
amd_ucode_patchdynamic first, depending onnum_online_nodes()?
I have a small set which gets rid of all those arrays - I just need to finish it.
:-(
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteBorislav Petkov
maintainerRemove stable@.
This below seems to work here on a couple of machines.
Can you run it too pls to confirm?
Thx.
---
From: "Borislav Petkov (AMD)" <[email protected]>
Date: Wed, 7 Jun 2023 21:01:06 +0200
Subject: [PATCH] x86/microcode/AMD: Rip out static buffers
Load straight from the containers (initrd or builtin, for example). There's no need to cache the patch per node.
This even simplifies the code a bit with the opportunity for more cleanups later.
--- arch/x86/include/asm/microcode_amd.h | 6 +- arch/x86/kernel/cpu/microcode/amd.c | 91 +++++++++------------------- arch/x86/kernel/cpu/microcode/core.c | 4 +- 3 files changed, 31 insertions(+), 70 deletions(-)
arch/x86/include/asm/microcode_amd.h +2 -4
@@ -44,13 +44,11 @@ struct microcode_amd {#define PATCH_MAX_SIZE (3 * PAGE_SIZE)#ifdef CONFIG_MICROCODE_AMD -extern void __init load_ucode_amd_bsp (unsigned int family); -extern void load_ucode_amd_ap (unsigned int family); +extern void load_ucode_amd_early (unsigned int cpuid_1_eax);extern int __init save_microcode_in_initrd_amd (unsigned int family);void reload_ucode_amd (unsigned int cpu);#else -static inline void __init load_ucode_amd_bsp (unsigned int family) {} -static inline void load_ucode_amd_ap (unsigned int family) {} +static inline void load_ucode_amd_early (unsigned int cpuid_1_eax) {}static inline int __init save_microcode_in_initrd_amd (unsigned int family) {return -EINVAL ; }static inline void reload_ucode_amd (unsigned int cpu) {}
arch/x86/kernel/cpu/microcode/amd.c +27 -64
152 lines not on this page · raw message
arch/x86/kernel/cpu/microcode/core.c +2 -2
@@ -172,7 +172,7 @@ void __init load_ucode_bsp(void)if (intel)load_ucode_intel_bsp ();else -load_ucode_amd_bsp (cpuid_1_eax); +load_ucode_amd_early (cpuid_1_eax); }static bool check_loader_disabled_ap (void )
@@ -200,7 +200,7 @@ void load_ucode_ap(void)break ;case X86_VENDOR_AMD :if (x86_family (cpuid_1_eax) >=0x10 ) -load_ucode_amd_ap (cpuid_1_eax); +load_ucode_amd_early (cpuid_1_eax);break ;default :break ;
Signature · 7 lines
2.41.0
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJohn Allen
Tested-byQuoted 7 lines · Borislav Petkov
Remove stable@.
This below seems to work here on a couple of machines.
Can you run it too pls to confirm?
Thx.
Yes, this appears to be working on my machine as well.
Borislav Petkov
maintainerQuoted 3 lines · John Allen
Yes, this appears to be working on my machine as well.
Tested-by John Allen <[email protected]>
Thanks, I'll queue it.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette[tip: x86/microcode] x86/microcode/AMD: Rip out static buffers
In reply to John AllenThe following commit has been merged into the x86/microcode branch of tip:
The following commit has been merged into the x86/microcode branch of tip:
Commit-ID: 05e91e72113833385fb8c9a33bda9dbd93e27609 Gitweb: https://git.kernel.org/tip/05e91e72113833385fb8c9a33bda9dbd93e27609 Author: Borislav Petkov (AMD) <[email protected]> AuthorDate: Wed, 07 Jun 2023 21:01:06 +02:00 Committer: Borislav Petkov (AMD) <[email protected]> CommitterDate: Thu, 27 Jul 2023 10:04:54 +02:00
x86/microcode/AMD: Rip out static buffers
Load straight from the containers (initrd or builtin, for example). There's no need to cache the patch per node.
This even simplifies the code a bit with the opportunity for more cleanups later.
--- arch/x86/include/asm/microcode_amd.h | 6 +-- arch/x86/kernel/cpu/microcode/amd.c | 91 ++++++++------------------- arch/x86/kernel/cpu/microcode/core.c | 4 +- 3 files changed, 31 insertions(+), 70 deletions(-)
arch/x86/include/asm/microcode_amd.h +2 -4
@@ -44,13 +44,11 @@ struct microcode_amd {#define PATCH_MAX_SIZE (3 * PAGE_SIZE)#ifdef CONFIG_MICROCODE_AMD -extern void __init load_ucode_amd_bsp (unsigned int family); -extern void load_ucode_amd_ap (unsigned int family); +extern void load_ucode_amd_early (unsigned int cpuid_1_eax);extern int __init save_microcode_in_initrd_amd (unsigned int family);void reload_ucode_amd (unsigned int cpu);#else -static inline void __init load_ucode_amd_bsp (unsigned int family) {} -static inline void load_ucode_amd_ap (unsigned int family) {} +static inline void load_ucode_amd_early (unsigned int cpuid_1_eax) {}static inline int __init save_microcode_in_initrd_amd (unsigned int family) {return -EINVAL ; }static inline void reload_ucode_amd (unsigned int cpu) {}
arch/x86/kernel/cpu/microcode/amd.c +27 -64
152 lines not on this page · raw message
arch/x86/kernel/cpu/microcode/core.c +2 -2
@@ -172,7 +172,7 @@ void __init load_ucode_bsp(void)if (intel)load_ucode_intel_bsp ();else -load_ucode_amd_bsp (cpuid_1_eax); +load_ucode_amd_early (cpuid_1_eax); }static bool check_loader_disabled_ap (void )
@@ -200,7 +200,7 @@ void load_ucode_ap(void)break ;case X86_VENDOR_AMD :if (x86_family (cpuid_1_eax) >=0x10 ) -load_ucode_amd_ap (cpuid_1_eax); +load_ucode_amd_early (cpuid_1_eax);break ;default :break ;