Skip to content

Commit 9adbf3c

Browse files
mcarabassuryasaimadhu
authored andcommitted
x86/microcode: Fix return value for microcode late loading
The return value from stop_machine() might not be consistent. stop_machine_cpuslocked() returns: - zero if all functions have returned 0. - a non-zero value if at least one of the functions returned a non-zero value. There is no way to know if it is negative or positive. So make __reload_late() return 0 on success or negative otherwise. [ bp: Unify ret val check and touch up. ] Signed-off-by: Mihai Carabas <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 8f3d9f3 commit 9adbf3c

File tree

1 file changed

+7
-8
lines changed
  • arch/x86/kernel/cpu/microcode

1 file changed

+7
-8
lines changed

arch/x86/kernel/cpu/microcode/core.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,7 @@ static int __wait_for_cpus(atomic_t *t, long long timeout)
545545
/*
546546
* Returns:
547547
* < 0 - on error
548-
* 0 - no update done
549-
* 1 - microcode was updated
548+
* 0 - success (no update done or microcode was updated)
550549
*/
551550
static int __reload_late(void *info)
552551
{
@@ -573,11 +572,11 @@ static int __reload_late(void *info)
573572
else
574573
goto wait_for_siblings;
575574

576-
if (err > UCODE_NFOUND) {
577-
pr_warn("Error reloading microcode on CPU %d\n", cpu);
575+
if (err >= UCODE_NFOUND) {
576+
if (err == UCODE_ERROR)
577+
pr_warn("Error reloading microcode on CPU %d\n", cpu);
578+
578579
ret = -1;
579-
} else if (err == UCODE_UPDATED || err == UCODE_OK) {
580-
ret = 1;
581580
}
582581

583582
wait_for_siblings:
@@ -608,7 +607,7 @@ static int microcode_reload_late(void)
608607
atomic_set(&late_cpus_out, 0);
609608

610609
ret = stop_machine_cpuslocked(__reload_late, NULL, cpu_online_mask);
611-
if (ret > 0)
610+
if (ret == 0)
612611
microcode_check();
613612

614613
pr_info("Reload completed, microcode revision: 0x%x\n", boot_cpu_data.microcode);
@@ -649,7 +648,7 @@ static ssize_t reload_store(struct device *dev,
649648
put:
650649
put_online_cpus();
651650

652-
if (ret >= 0)
651+
if (ret == 0)
653652
ret = size;
654653

655654
return ret;

0 commit comments

Comments
 (0)