Skip to content

Commit

Permalink
x86, microcode, AMD: Exit early on success
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Borislav Petkov authored and Borislav Petkov committed Dec 14, 2011
1 parent be62adb commit d733689
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions arch/x86/kernel/microcode_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,27 +282,23 @@ generic_load_microcode(int cpu, const u8 *data, size_t size)
mc_hdr = patch;
new_mc = patch;
new_rev = mc_hdr->patch_id;
leftover -= mc_size;
} else {
ucode_ptr += current_size;
leftover -= current_size;
goto out_ok;
}

ucode_ptr += current_size;
leftover -= current_size;
}

if (!new_mc) {
state = UCODE_NFOUND;
goto free_table;
}

if (!leftover) {
uci->mc = new_mc;
state = UCODE_OK;
pr_debug("CPU%d update ucode (0x%08x -> 0x%08x)\n",
cpu, uci->cpu_sig.rev, new_rev);
} else {
new_mc = NULL;
state = UCODE_ERROR;
}
out_ok:
uci->mc = new_mc;
state = UCODE_OK;
pr_debug("CPU%d update ucode (0x%08x -> 0x%08x)\n",
cpu, uci->cpu_sig.rev, new_rev);

free_table:
free_equiv_cpu_table();
Expand Down

0 comments on commit d733689

Please sign in to comment.