Merge tag 'x86_cleanups_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Aug 2021 20:35:36 +0000 (13:35 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 30 Aug 2021 20:35:36 +0000 (13:35 -0700)
Pull x86 cleanups from Borislav Petkov:
 "The usual round of minor cleanups and fixes"

* tag 'x86_cleanups_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/kaslr: Have process_mem_region() return a boolean
  x86/power: Fix kernel-doc warnings in cpu.c
  x86/mce/inject: Replace deprecated CPU-hotplug functions.
  x86/microcode: Replace deprecated CPU-hotplug functions.
  x86/mtrr: Replace deprecated CPU-hotplug functions.
  x86/mmiotrace: Replace deprecated CPU-hotplug functions.

arch/x86/boot/compressed/kaslr.c
arch/x86/kernel/cpu/mce/inject.c
arch/x86/kernel/cpu/microcode/core.c
arch/x86/kernel/cpu/mtrr/mtrr.c
arch/x86/mm/mmio-mod.c
arch/x86/power/cpu.c

index e366907..67c3208 100644 (file)
@@ -668,7 +668,7 @@ static bool process_mem_region(struct mem_vector *region,
 
                if (slot_area_index == MAX_SLOT_AREA) {
                        debug_putstr("Aborted e820/efi memmap scan when walking immovable regions(slot_areas full)!\n");
-                       return 1;
+                       return true;
                }
        }
 #endif
index 4e86d97..0bfc140 100644 (file)
@@ -235,7 +235,7 @@ static void __maybe_unused raise_mce(struct mce *m)
                unsigned long start;
                int cpu;
 
-               get_online_cpus();
+               cpus_read_lock();
                cpumask_copy(mce_inject_cpumask, cpu_online_mask);
                cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
                for_each_online_cpu(cpu) {
@@ -269,7 +269,7 @@ static void __maybe_unused raise_mce(struct mce *m)
                }
                raise_local();
                put_cpu();
-               put_online_cpus();
+               cpus_read_unlock();
        } else {
                preempt_disable();
                raise_local();
@@ -529,7 +529,7 @@ static void do_inject(void)
                cpu = get_nbc_for_node(topology_die_id(cpu));
        }
 
-       get_online_cpus();
+       cpus_read_lock();
        if (!cpu_online(cpu))
                goto err;
 
@@ -553,7 +553,7 @@ static void do_inject(void)
        }
 
 err:
-       put_online_cpus();
+       cpus_read_unlock();
 
 }
 
index 6a6318e..efb69be 100644 (file)
@@ -55,7 +55,7 @@ LIST_HEAD(microcode_cache);
  * All non cpu-hotplug-callback call sites use:
  *
  * - microcode_mutex to synchronize with each other;
- * - get/put_online_cpus() to synchronize with
+ * - cpus_read_lock/unlock() to synchronize with
  *   the cpu-hotplug-callback call sites.
  *
  * We guarantee that only a single cpu is being
@@ -431,7 +431,7 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
                return ret;
        }
 
-       get_online_cpus();
+       cpus_read_lock();
        mutex_lock(&microcode_mutex);
 
        if (do_microcode_update(buf, len) == 0)
@@ -441,7 +441,7 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
                perf_check_microcode();
 
        mutex_unlock(&microcode_mutex);
-       put_online_cpus();
+       cpus_read_unlock();
 
        return ret;
 }
@@ -629,7 +629,7 @@ static ssize_t reload_store(struct device *dev,
        if (val != 1)
                return size;
 
-       get_online_cpus();
+       cpus_read_lock();
 
        ret = check_online_cpus();
        if (ret)
@@ -644,7 +644,7 @@ static ssize_t reload_store(struct device *dev,
        mutex_unlock(&microcode_mutex);
 
 put:
-       put_online_cpus();
+       cpus_read_unlock();
 
        if (ret == 0)
                ret = size;
@@ -853,14 +853,14 @@ static int __init microcode_init(void)
        if (IS_ERR(microcode_pdev))
                return PTR_ERR(microcode_pdev);
 
-       get_online_cpus();
+       cpus_read_lock();
        mutex_lock(&microcode_mutex);
 
        error = subsys_interface_register(&mc_cpu_interface);
        if (!error)
                perf_check_microcode();
        mutex_unlock(&microcode_mutex);
-       put_online_cpus();
+       cpus_read_unlock();
 
        if (error)
                goto out_pdev;
@@ -892,13 +892,13 @@ static int __init microcode_init(void)
                           &cpu_root_microcode_group);
 
  out_driver:
-       get_online_cpus();
+       cpus_read_lock();
        mutex_lock(&microcode_mutex);
 
        subsys_interface_unregister(&mc_cpu_interface);
 
        mutex_unlock(&microcode_mutex);
-       put_online_cpus();
+       cpus_read_unlock();
 
  out_pdev:
        platform_device_unregister(microcode_pdev);
index a76694b..2746cac 100644 (file)
@@ -336,7 +336,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
        replace = -1;
 
        /* No CPU hotplug when we change MTRR entries */
-       get_online_cpus();
+       cpus_read_lock();
 
        /* Search for existing MTRR  */
        mutex_lock(&mtrr_mutex);
@@ -398,7 +398,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
        error = i;
  out:
        mutex_unlock(&mtrr_mutex);
-       put_online_cpus();
+       cpus_read_unlock();
        return error;
 }
 
@@ -485,7 +485,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
 
        max = num_var_ranges;
        /* No CPU hotplug when we change MTRR entries */
-       get_online_cpus();
+       cpus_read_lock();
        mutex_lock(&mtrr_mutex);
        if (reg < 0) {
                /*  Search for existing MTRR  */
@@ -520,7 +520,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
        error = reg;
  out:
        mutex_unlock(&mtrr_mutex);
-       put_online_cpus();
+       cpus_read_unlock();
        return error;
 }
 
index cd768da..933a2eb 100644 (file)
@@ -376,12 +376,12 @@ static void enter_uniprocessor(void)
                goto out;
        }
 
-       get_online_cpus();
+       cpus_read_lock();
        cpumask_copy(downed_cpus, cpu_online_mask);
        cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus);
        if (num_online_cpus() > 1)
                pr_notice("Disabling non-boot CPUs...\n");
-       put_online_cpus();
+       cpus_read_unlock();
 
        for_each_cpu(cpu, downed_cpus) {
                err = remove_cpu(cpu);
index 3a070e7..6665f88 100644 (file)
@@ -58,19 +58,20 @@ static void msr_restore_context(struct saved_context *ctxt)
 }
 
 /**
- *     __save_processor_state - save CPU registers before creating a
- *             hibernation image and before restoring the memory state from it
- *     @ctxt - structure to store the registers contents in
+ * __save_processor_state() - Save CPU registers before creating a
+ *                             hibernation image and before restoring
+ *                             the memory state from it
+ * @ctxt: Structure to store the registers contents in.
  *
- *     NOTE: If there is a CPU register the modification of which by the
- *     boot kernel (ie. the kernel used for loading the hibernation image)
- *     might affect the operations of the restored target kernel (ie. the one
- *     saved in the hibernation image), then its contents must be saved by this
- *     function.  In other words, if kernel A is hibernated and different
- *     kernel B is used for loading the hibernation image into memory, the
- *     kernel A's __save_processor_state() function must save all registers
- *     needed by kernel A, so that it can operate correctly after the resume
- *     regardless of what kernel B does in the meantime.
+ * NOTE: If there is a CPU register the modification of which by the
+ * boot kernel (ie. the kernel used for loading the hibernation image)
+ * might affect the operations of the restored target kernel (ie. the one
+ * saved in the hibernation image), then its contents must be saved by this
+ * function.  In other words, if kernel A is hibernated and different
+ * kernel B is used for loading the hibernation image into memory, the
+ * kernel A's __save_processor_state() function must save all registers
+ * needed by kernel A, so that it can operate correctly after the resume
+ * regardless of what kernel B does in the meantime.
  */
 static void __save_processor_state(struct saved_context *ctxt)
 {
@@ -181,9 +182,9 @@ static void fix_processor_context(void)
 }
 
 /**
- * __restore_processor_state - restore the contents of CPU registers saved
- *                             by __save_processor_state()
- * @ctxt - structure to load the registers contents from
+ * __restore_processor_state() - Restore the contents of CPU registers saved
+ *                               by __save_processor_state()
+ * @ctxt: Structure to load the registers contents from.
  *
  * The asm code that gets us here will have restored a usable GDT, although
  * it will be pointing to the wrong alias.