Skip to content

Commit d733689

Browse files
Borislav PetkovBorislav Petkov
authored andcommitted
x86, microcode, AMD: Exit early on success
Once we've found and validated the ucode patch for the current CPU, there's no need to iterate over the remaining patches in the binary image. Exit then and save us a bunch of cycles. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
1 parent be62adb commit d733689

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

‎arch/x86/kernel/microcode_amd.c‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -282,27 +282,23 @@ generic_load_microcode(int cpu, const u8 *data, size_t size)
282282
mc_hdr = patch;
283283
new_mc = patch;
284284
new_rev = mc_hdr->patch_id;
285-
leftover -= mc_size;
286-
} else {
287-
ucode_ptr += current_size;
288-
leftover -= current_size;
285+
goto out_ok;
289286
}
287+
288+
ucode_ptr += current_size;
289+
leftover -= current_size;
290290
}
291291

292292
if (!new_mc) {
293293
state = UCODE_NFOUND;
294294
goto free_table;
295295
}
296296

297-
if (!leftover) {
298-
uci->mc = new_mc;
299-
state = UCODE_OK;
300-
pr_debug("CPU%d update ucode (0x%08x -> 0x%08x)\n",
301-
cpu, uci->cpu_sig.rev, new_rev);
302-
} else {
303-
new_mc = NULL;
304-
state = UCODE_ERROR;
305-
}
297+
out_ok:
298+
uci->mc = new_mc;
299+
state = UCODE_OK;
300+
pr_debug("CPU%d update ucode (0x%08x -> 0x%08x)\n",
301+
cpu, uci->cpu_sig.rev, new_rev);
306302

307303
free_table:
308304
free_equiv_cpu_table();

0 commit comments

Comments
 (0)