Messages in this thread Patch in this message | | | From | "Pontes, Otavio" <> | Subject | Re: [PATCH 1/1] x86/microcode: Check for offline CPUs before checking for microcode update | Date | Fri, 19 Mar 2021 18:48:14 +0000 |
| |
Sorry, I forgot to copy LKML
________________________________________ From: Pontes, Otavio <otavio.pontes@intel.com> Sent: Friday, March 19, 2021 9:55 AM To: x86@kernel.org Cc: Borislav Petkov; Thomas Gleixner; Pontes, Otavio; Raj, Ashok; Luck, Tony Subject: [PATCH 1/1] x86/microcode: Check for offline CPUs before checking for microcode update
Checking for any offline CPUs to abort microcode update must be done before kernel caching a new microcode from the filesystem. Otherwise when offlined CPUs are onlined later, those cores are going to be updated with the new microcode while CPUs previously onine will continue to run with the older microcode. If update is aborted before checking for the microcode file, offline CPUs that are onlined later will get the same microcode as online CPUs.
Turn off one core (2 threads) $ echo 0 > /sys/devices/system/cpu/cpu3/online $ echo 0 > /sys/devices/system/cpu/cpu1/online
Install the ucode fails because there's one core off $ cp intel-ucode/06-8e-09 /lib/firmware/intel-ucode/ $ echo 1 > /sys/devices/system/cpu/microcode/reload bash: echo: write error: Invalid argument
Turn the core back on $ echo 1 > /sys/devices/system/cpu/cpu3/online $ echo 1 > /sys/devices/system/cpu/cpu1/online $ cat /proc/cpuinfo |grep microcode microcode : 0x30 microcode : 0xde microcode : 0x30 microcode : 0xde
Fixes: 30ec26da9967 ("x86/microcode: Do not upload microcode if CPUs are offline") Signed-off-by: Otavio Pontes <otavio.pontes@intel.com> Acked-by: Ashok Raj <ashok.raj@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> --- arch/x86/kernel/cpu/microcode/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index b935e1b5f115..6a6318e9590c 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -629,16 +629,16 @@ static ssize_t reload_store(struct device *dev, if (val != 1) return size;
- tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev, true); - if (tmp_ret != UCODE_NEW) - return size; - get_online_cpus();
ret = check_online_cpus(); if (ret) goto put;
+ tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev, true); + if (tmp_ret != UCODE_NEW) + goto put; + mutex_lock(µcode_mutex); ret = microcode_reload_late(); mutex_unlock(µcode_mutex); -- 2.30.2
| |