aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/microcode
diff options
context:
space:
mode:
authorBorislav Petkov <bp@suse.de>2016-12-18 11:44:11 -0500
committerThomas Gleixner <tglx@linutronix.de>2016-12-19 04:46:19 -0500
commit8feaa64a9a69652fdff87205f8a8cfe1bfd5b522 (patch)
treee1cf8f6ff9faa2daf663ce7394cd1a82927d1a5b /arch/x86/kernel/cpu/microcode
parentb0b3a37b908b5906524c11f3ca12cd7c9d4adc1c (diff)
x86/microcode/AMD: Make find_proper_container() sane again
Fixup signature and retvals, return the container struct through the passed in pointer, not as a function return value. Signed-off-by: Borislav Petkov <bp@suse.de> Cc: Jürgen Gross <jgross@suse.com> Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com> Link: http://lkml.kernel.org/r/20161218164414.9649-2-bp@alien8.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/cpu/microcode')
-rw-r--r--arch/x86/kernel/cpu/microcode/amd.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 6f353bdb3a25..31f4e3f94d46 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -116,10 +116,11 @@ static inline u16 find_equiv_id(struct equiv_cpu_entry *equiv_cpu_table,
116 116
117/* 117/*
118 * This scans the ucode blob for the proper container as we can have multiple 118 * This scans the ucode blob for the proper container as we can have multiple
119 * containers glued together. 119 * containers glued together. Returns the equivalence ID from the equivalence
120 * table or 0 if none found.
120 */ 121 */
121static struct container 122static u16
122find_proper_container(u8 *ucode, size_t size, u16 *ret_id) 123find_proper_container(u8 *ucode, size_t size, struct container *ret_cont)
123{ 124{
124 struct container ret = { NULL, 0 }; 125 struct container ret = { NULL, 0 };
125 u32 eax, ebx, ecx, edx; 126 u32 eax, ebx, ecx, edx;
@@ -138,7 +139,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
138 if (header[0] != UCODE_MAGIC || 139 if (header[0] != UCODE_MAGIC ||
139 header[1] != UCODE_EQUIV_CPU_TABLE_TYPE || /* type */ 140 header[1] != UCODE_EQUIV_CPU_TABLE_TYPE || /* type */
140 header[2] == 0) /* size */ 141 header[2] == 0) /* size */
141 return ret; 142 return eq_id;
142 143
143 eax = 0x00000001; 144 eax = 0x00000001;
144 ecx = 0; 145 ecx = 0;
@@ -163,8 +164,9 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
163 * ucode update loop below 164 * ucode update loop below
164 */ 165 */
165 left = ret.size - offset; 166 left = ret.size - offset;
166 *ret_id = eq_id; 167
167 return ret; 168 *ret_cont = ret;
169 return eq_id;
168 } 170 }
169 171
170 /* 172 /*
@@ -189,7 +191,7 @@ find_proper_container(u8 *ucode, size_t size, u16 *ret_id)
189 ucode = data; 191 ucode = data;
190 } 192 }
191 193
192 return ret; 194 return eq_id;
193} 195}
194 196
195static int __apply_microcode_amd(struct microcode_amd *mc_amd) 197static int __apply_microcode_amd(struct microcode_amd *mc_amd)
@@ -237,7 +239,7 @@ apply_microcode_early_amd(void *ucode, size_t size, bool save_patch)
237 if (check_current_patch_level(&rev, true)) 239 if (check_current_patch_level(&rev, true))
238 return (struct container){ NULL, 0 }; 240 return (struct container){ NULL, 0 };
239 241
240 ret = find_proper_container(ucode, size, &eq_id); 242 eq_id = find_proper_container(ucode, size, &ret);
241 if (!eq_id) 243 if (!eq_id)
242 return (struct container){ NULL, 0 }; 244 return (struct container){ NULL, 0 };
243 245
@@ -443,7 +445,7 @@ int __init save_microcode_in_initrd_amd(unsigned int fam)
443 return -EINVAL; 445 return -EINVAL;
444 } 446 }
445 447
446 cont = find_proper_container(cp.data, cp.size, &eq_id); 448 eq_id = find_proper_container(cp.data, cp.size, &cont);
447 if (!eq_id) { 449 if (!eq_id) {
448 cont.size = -1; 450 cont.size = -1;
449 return -EINVAL; 451 return -EINVAL;