2023-08-12 20:45:35

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V2 09/37] x86/microcode/intel: Remove pointless mutex

From: Thomas Gleixner <[email protected]>

There is no concurreny.

Signed-off-by: Thomas Gleixner <[email protected]>

---
arch/x86/kernel/cpu/microcode/intel.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)
---
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -397,22 +397,6 @@ scan_microcode(void *data, size_t size,
return patch;
}

-/*
- * Save this microcode patch. It will be loaded early when a CPU is
- * hot-added or resumes.
- */
-static void save_mc_for_early(struct ucode_cpu_info *uci, u8 *mc, unsigned int size)
-{
- /* Synchronization during CPU hotplug. */
- static DEFINE_MUTEX(x86_cpu_microcode_mutex);
-
- mutex_lock(&x86_cpu_microcode_mutex);
-
- save_microcode_patch(uci, mc, size);
-
- mutex_unlock(&x86_cpu_microcode_mutex);
-}
-
static bool load_builtin_intel_microcode(struct cpio_data *cp)
{
unsigned int eax = 1, ebx, ecx = 0, edx;
@@ -829,12 +813,8 @@ static enum ucode_state generic_load_mic
vfree(uci->mc);
uci->mc = (struct microcode_intel *)new_mc;

- /*
- * If early loading microcode is supported, save this mc into
- * permanent memory. So it will be loaded early when a CPU is hot added
- * or resumes.
- */
- save_mc_for_early(uci, new_mc, new_mc_size);
+ /* Save for CPU hotplug */
+ save_microcode_patch(uci, new_mc, new_mc_size);

pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n",
cpu, new_rev, uci->cpu_sig.rev);



2023-08-13 07:34:32

by Nikolay Borisov

[permalink] [raw]
Subject: Re: [patch V2 09/37] x86/microcode/intel: Remove pointless mutex



On 12.08.23 г. 22:58 ч., Thomas Gleixner wrote:
> From: Thomas Gleixner <[email protected]>
>
> There is no concurreny.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
>
> ---
> arch/x86/kernel/cpu/microcode/intel.c | 24 ++----------------------
> 1 file changed, 2 insertions(+), 22 deletions(-)
> ---
> --- a/arch/x86/kernel/cpu/microcode/intel.c
> +++ b/arch/x86/kernel/cpu/microcode/intel.c
> @@ -397,22 +397,6 @@ scan_microcode(void *data, size_t size,
> return patch;
> }
>
> -/*
> - * Save this microcode patch. It will be loaded early when a CPU is
> - * hot-added or resumes.
> - */
> -static void save_mc_for_early(struct ucode_cpu_info *uci, u8 *mc, unsigned int size)
> -{
> - /* Synchronization during CPU hotplug. */
> - static DEFINE_MUTEX(x86_cpu_microcode_mutex);
> -
> - mutex_lock(&x86_cpu_microcode_mutex);
> -
> - save_microcode_patch(uci, mc, size);
> -
> - mutex_unlock(&x86_cpu_microcode_mutex);
> -}
> -


So this function is ultimately invoked from a write to the 'reload'
sysfs file, what about 2 racing writes to this file ? Though if it's
about cpu hotplug then in reload_store() this is handled via
cpus_read_lock I guess so indeed this is correct.

2023-08-13 10:03:44

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch V2 09/37] x86/microcode/intel: Remove pointless mutex

On Sun, Aug 13 2023 at 09:55, Nikolay Borisov wrote:
> On 12.08.23 г. 22:58 ч., Thomas Gleixner wrote:
>
> So this function is ultimately invoked from a write to the 'reload'
> sysfs file, what about 2 racing writes to this file ? Though if it's
> about cpu hotplug then in reload_store() this is handled via
> cpus_read_lock I guess so indeed this is correct.

80347cd515ca ("x86/microcode: Remove microcode_mutex")

Subject: [tip: x86/microcode] x86/microcode/intel: Remove pointless mutex

The following commit has been merged into the x86/microcode branch of tip:

Commit-ID: d2700f406713d04573803b9fe8a0fb02c015df39
Gitweb: https://git.kernel.org/tip/d2700f406713d04573803b9fe8a0fb02c015df39
Author: Thomas Gleixner <[email protected]>
AuthorDate: Sat, 12 Aug 2023 21:58:50 +02:00
Committer: Borislav Petkov (AMD) <[email protected]>
CommitterDate: Sun, 13 Aug 2023 18:42:55 +02:00

x86/microcode/intel: Remove pointless mutex

There is no concurrency.

Signed-off-by: Thomas Gleixner <[email protected]>
Signed-off-by: Borislav Petkov (AMD) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
---
arch/x86/kernel/cpu/microcode/intel.c | 24 ++----------------------
1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c
index 8621ef4..94dd6af 100644
--- a/arch/x86/kernel/cpu/microcode/intel.c
+++ b/arch/x86/kernel/cpu/microcode/intel.c
@@ -397,22 +397,6 @@ next:
return patch;
}

-/*
- * Save this microcode patch. It will be loaded early when a CPU is
- * hot-added or resumes.
- */
-static void save_mc_for_early(struct ucode_cpu_info *uci, u8 *mc, unsigned int size)
-{
- /* Synchronization during CPU hotplug. */
- static DEFINE_MUTEX(x86_cpu_microcode_mutex);
-
- mutex_lock(&x86_cpu_microcode_mutex);
-
- save_microcode_patch(uci, mc, size);
-
- mutex_unlock(&x86_cpu_microcode_mutex);
-}
-
static bool load_builtin_intel_microcode(struct cpio_data *cp)
{
unsigned int eax = 1, ebx, ecx = 0, edx;
@@ -829,12 +813,8 @@ static enum ucode_state generic_load_microcode(int cpu, struct iov_iter *iter)
vfree(uci->mc);
uci->mc = (struct microcode_intel *)new_mc;

- /*
- * If early loading microcode is supported, save this mc into
- * permanent memory. So it will be loaded early when a CPU is hot added
- * or resumes.
- */
- save_mc_for_early(uci, new_mc, new_mc_size);
+ /* Save for CPU hotplug */
+ save_microcode_patch(uci, new_mc, new_mc_size);

pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n",
cpu, new_rev, uci->cpu_sig.rev);