Commit 9adbf3c6 authored by Mihai Carabas's avatar Mihai Carabas Committed by Borislav Petkov

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: default avatarMihai Carabas <mihai.carabas@oracle.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/1587497318-4438-1-git-send-email-mihai.carabas@oracle.com
parent 8f3d9f35
...@@ -545,8 +545,7 @@ static int __wait_for_cpus(atomic_t *t, long long timeout) ...@@ -545,8 +545,7 @@ static int __wait_for_cpus(atomic_t *t, long long timeout)
/* /*
* Returns: * Returns:
* < 0 - on error * < 0 - on error
* 0 - no update done * 0 - success (no update done or microcode was updated)
* 1 - microcode was updated
*/ */
static int __reload_late(void *info) static int __reload_late(void *info)
{ {
...@@ -573,11 +572,11 @@ static int __reload_late(void *info) ...@@ -573,11 +572,11 @@ static int __reload_late(void *info)
else else
goto wait_for_siblings; goto wait_for_siblings;
if (err > UCODE_NFOUND) { if (err >= UCODE_NFOUND) {
pr_warn("Error reloading microcode on CPU %d\n", cpu); if (err == UCODE_ERROR)
pr_warn("Error reloading microcode on CPU %d\n", cpu);
ret = -1; ret = -1;
} else if (err == UCODE_UPDATED || err == UCODE_OK) {
ret = 1;
} }
wait_for_siblings: wait_for_siblings:
...@@ -608,7 +607,7 @@ static int microcode_reload_late(void) ...@@ -608,7 +607,7 @@ static int microcode_reload_late(void)
atomic_set(&late_cpus_out, 0); atomic_set(&late_cpus_out, 0);
ret = stop_machine_cpuslocked(__reload_late, NULL, cpu_online_mask); ret = stop_machine_cpuslocked(__reload_late, NULL, cpu_online_mask);
if (ret > 0) if (ret == 0)
microcode_check(); microcode_check();
pr_info("Reload completed, microcode revision: 0x%x\n", boot_cpu_data.microcode); 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, ...@@ -649,7 +648,7 @@ static ssize_t reload_store(struct device *dev,
put: put:
put_online_cpus(); put_online_cpus();
if (ret >= 0) if (ret == 0)
ret = size; ret = size;
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment