diff options
author | Borislav Petkov <bp@suse.de> | 2018-06-28 19:44:29 +0200 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2018-11-19 10:45:08 +0100 |
commit | 3974b68114fed3735f623931e673538d8ab92d26 (patch) | |
tree | 4be1cfa7f08d9133af4b7c13b36717edfc0159e0 /arch/x86/kernel/cpu/microcode | |
parent | x86/microcode/AMD: Add microcode container verification (diff) | |
download | linux-3974b68114fed3735f623931e673538d8ab92d26.tar.xz linux-3974b68114fed3735f623931e673538d8ab92d26.zip |
x86/microcode/AMD: Move verify_patch_size() up in the file
... to enable later improvements.
No functional changes.
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: x86@kernel.org
Link: https://lkml.kernel.org/r/20181107170218.7596-4-bp@alien8.de
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
-rw-r--r-- | arch/x86/kernel/cpu/microcode/amd.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index 36aeb01b3ae8..f8d60cb9bb9a 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -175,6 +175,47 @@ static bool verify_patch_section(const u8 *buf, size_t buf_size, bool early) } /* + * Check whether the passed remaining file @size is large enough to contain a + * patch of the indicated @patch_size (and also whether this size does not + * exceed the per-family maximum). + */ +static unsigned int verify_patch_size(u8 family, u32 patch_size, unsigned int size) +{ + u32 max_size; + +#define F1XH_MPB_MAX_SIZE 2048 +#define F14H_MPB_MAX_SIZE 1824 +#define F15H_MPB_MAX_SIZE 4096 +#define F16H_MPB_MAX_SIZE 3458 +#define F17H_MPB_MAX_SIZE 3200 + + switch (family) { + case 0x14: + max_size = F14H_MPB_MAX_SIZE; + break; + case 0x15: + max_size = F15H_MPB_MAX_SIZE; + break; + case 0x16: + max_size = F16H_MPB_MAX_SIZE; + break; + case 0x17: + max_size = F17H_MPB_MAX_SIZE; + break; + default: + max_size = F1XH_MPB_MAX_SIZE; + break; + } + + if (patch_size > min_t(u32, size, max_size)) { + pr_err("patch size mismatch\n"); + return 0; + } + + return patch_size; +} + +/* * This scans the ucode blob for the proper container as we can have multiple * containers glued together. Returns the equivalence ID from the equivalence * table or 0 if none found. @@ -562,47 +603,6 @@ static int collect_cpu_info_amd(int cpu, struct cpu_signature *csig) return 0; } -/* - * Check whether the passed remaining file @size is large enough to contain a - * patch of the indicated @patch_size (and also whether this size does not - * exceed the per-family maximum). - */ -static unsigned int verify_patch_size(u8 family, u32 patch_size, unsigned int size) -{ - u32 max_size; - -#define F1XH_MPB_MAX_SIZE 2048 -#define F14H_MPB_MAX_SIZE 1824 -#define F15H_MPB_MAX_SIZE 4096 -#define F16H_MPB_MAX_SIZE 3458 -#define F17H_MPB_MAX_SIZE 3200 - - switch (family) { - case 0x14: - max_size = F14H_MPB_MAX_SIZE; - break; - case 0x15: - max_size = F15H_MPB_MAX_SIZE; - break; - case 0x16: - max_size = F16H_MPB_MAX_SIZE; - break; - case 0x17: - max_size = F17H_MPB_MAX_SIZE; - break; - default: - max_size = F1XH_MPB_MAX_SIZE; - break; - } - - if (patch_size > min_t(u32, size, max_size)) { - pr_err("patch size mismatch\n"); - return 0; - } - - return patch_size; -} - static enum ucode_state apply_microcode_amd(int cpu) { struct cpuinfo_x86 *c = &cpu_data(cpu); |