Skip to content

Commit 230bda0

Browse files
committed
Merge tag 'x86_cleanups_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
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.
2 parents 42f6e86 + 5b3fd8a commit 230bda0

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

arch/x86/boot/compressed/kaslr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ static bool process_mem_region(struct mem_vector *region,
668668

669669
if (slot_area_index == MAX_SLOT_AREA) {
670670
debug_putstr("Aborted e820/efi memmap scan when walking immovable regions(slot_areas full)!\n");
671-
return 1;
671+
return true;
672672
}
673673
}
674674
#endif

arch/x86/kernel/cpu/mce/inject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static void __maybe_unused raise_mce(struct mce *m)
235235
unsigned long start;
236236
int cpu;
237237

238-
get_online_cpus();
238+
cpus_read_lock();
239239
cpumask_copy(mce_inject_cpumask, cpu_online_mask);
240240
cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
241241
for_each_online_cpu(cpu) {
@@ -269,7 +269,7 @@ static void __maybe_unused raise_mce(struct mce *m)
269269
}
270270
raise_local();
271271
put_cpu();
272-
put_online_cpus();
272+
cpus_read_unlock();
273273
} else {
274274
preempt_disable();
275275
raise_local();
@@ -529,7 +529,7 @@ static void do_inject(void)
529529
cpu = get_nbc_for_node(topology_die_id(cpu));
530530
}
531531

532-
get_online_cpus();
532+
cpus_read_lock();
533533
if (!cpu_online(cpu))
534534
goto err;
535535

@@ -553,7 +553,7 @@ static void do_inject(void)
553553
}
554554

555555
err:
556-
put_online_cpus();
556+
cpus_read_unlock();
557557

558558
}
559559

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ LIST_HEAD(microcode_cache);
5555
* All non cpu-hotplug-callback call sites use:
5656
*
5757
* - microcode_mutex to synchronize with each other;
58-
* - get/put_online_cpus() to synchronize with
58+
* - cpus_read_lock/unlock() to synchronize with
5959
* the cpu-hotplug-callback call sites.
6060
*
6161
* 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,
431431
return ret;
432432
}
433433

434-
get_online_cpus();
434+
cpus_read_lock();
435435
mutex_lock(&microcode_mutex);
436436

437437
if (do_microcode_update(buf, len) == 0)
@@ -441,7 +441,7 @@ static ssize_t microcode_write(struct file *file, const char __user *buf,
441441
perf_check_microcode();
442442

443443
mutex_unlock(&microcode_mutex);
444-
put_online_cpus();
444+
cpus_read_unlock();
445445

446446
return ret;
447447
}
@@ -629,7 +629,7 @@ static ssize_t reload_store(struct device *dev,
629629
if (val != 1)
630630
return size;
631631

632-
get_online_cpus();
632+
cpus_read_lock();
633633

634634
ret = check_online_cpus();
635635
if (ret)
@@ -644,7 +644,7 @@ static ssize_t reload_store(struct device *dev,
644644
mutex_unlock(&microcode_mutex);
645645

646646
put:
647-
put_online_cpus();
647+
cpus_read_unlock();
648648

649649
if (ret == 0)
650650
ret = size;
@@ -853,14 +853,14 @@ static int __init microcode_init(void)
853853
if (IS_ERR(microcode_pdev))
854854
return PTR_ERR(microcode_pdev);
855855

856-
get_online_cpus();
856+
cpus_read_lock();
857857
mutex_lock(&microcode_mutex);
858858

859859
error = subsys_interface_register(&mc_cpu_interface);
860860
if (!error)
861861
perf_check_microcode();
862862
mutex_unlock(&microcode_mutex);
863-
put_online_cpus();
863+
cpus_read_unlock();
864864

865865
if (error)
866866
goto out_pdev;
@@ -892,13 +892,13 @@ static int __init microcode_init(void)
892892
&cpu_root_microcode_group);
893893

894894
out_driver:
895-
get_online_cpus();
895+
cpus_read_lock();
896896
mutex_lock(&microcode_mutex);
897897

898898
subsys_interface_unregister(&mc_cpu_interface);
899899

900900
mutex_unlock(&microcode_mutex);
901-
put_online_cpus();
901+
cpus_read_unlock();
902902

903903
out_pdev:
904904
platform_device_unregister(microcode_pdev);

arch/x86/kernel/cpu/mtrr/mtrr.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
336336
replace = -1;
337337

338338
/* No CPU hotplug when we change MTRR entries */
339-
get_online_cpus();
339+
cpus_read_lock();
340340

341341
/* Search for existing MTRR */
342342
mutex_lock(&mtrr_mutex);
@@ -398,7 +398,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
398398
error = i;
399399
out:
400400
mutex_unlock(&mtrr_mutex);
401-
put_online_cpus();
401+
cpus_read_unlock();
402402
return error;
403403
}
404404

@@ -485,7 +485,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
485485

486486
max = num_var_ranges;
487487
/* No CPU hotplug when we change MTRR entries */
488-
get_online_cpus();
488+
cpus_read_lock();
489489
mutex_lock(&mtrr_mutex);
490490
if (reg < 0) {
491491
/* Search for existing MTRR */
@@ -520,7 +520,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
520520
error = reg;
521521
out:
522522
mutex_unlock(&mtrr_mutex);
523-
put_online_cpus();
523+
cpus_read_unlock();
524524
return error;
525525
}
526526

arch/x86/mm/mmio-mod.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ static void enter_uniprocessor(void)
376376
goto out;
377377
}
378378

379-
get_online_cpus();
379+
cpus_read_lock();
380380
cpumask_copy(downed_cpus, cpu_online_mask);
381381
cpumask_clear_cpu(cpumask_first(cpu_online_mask), downed_cpus);
382382
if (num_online_cpus() > 1)
383383
pr_notice("Disabling non-boot CPUs...\n");
384-
put_online_cpus();
384+
cpus_read_unlock();
385385

386386
for_each_cpu(cpu, downed_cpus) {
387387
err = remove_cpu(cpu);

arch/x86/power/cpu.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,20 @@ static void msr_restore_context(struct saved_context *ctxt)
5858
}
5959

6060
/**
61-
* __save_processor_state - save CPU registers before creating a
62-
* hibernation image and before restoring the memory state from it
63-
* @ctxt - structure to store the registers contents in
61+
* __save_processor_state() - Save CPU registers before creating a
62+
* hibernation image and before restoring
63+
* the memory state from it
64+
* @ctxt: Structure to store the registers contents in.
6465
*
65-
* NOTE: If there is a CPU register the modification of which by the
66-
* boot kernel (ie. the kernel used for loading the hibernation image)
67-
* might affect the operations of the restored target kernel (ie. the one
68-
* saved in the hibernation image), then its contents must be saved by this
69-
* function. In other words, if kernel A is hibernated and different
70-
* kernel B is used for loading the hibernation image into memory, the
71-
* kernel A's __save_processor_state() function must save all registers
72-
* needed by kernel A, so that it can operate correctly after the resume
73-
* regardless of what kernel B does in the meantime.
66+
* NOTE: If there is a CPU register the modification of which by the
67+
* boot kernel (ie. the kernel used for loading the hibernation image)
68+
* might affect the operations of the restored target kernel (ie. the one
69+
* saved in the hibernation image), then its contents must be saved by this
70+
* function. In other words, if kernel A is hibernated and different
71+
* kernel B is used for loading the hibernation image into memory, the
72+
* kernel A's __save_processor_state() function must save all registers
73+
* needed by kernel A, so that it can operate correctly after the resume
74+
* regardless of what kernel B does in the meantime.
7475
*/
7576
static void __save_processor_state(struct saved_context *ctxt)
7677
{
@@ -181,9 +182,9 @@ static void fix_processor_context(void)
181182
}
182183

183184
/**
184-
* __restore_processor_state - restore the contents of CPU registers saved
185-
* by __save_processor_state()
186-
* @ctxt - structure to load the registers contents from
185+
* __restore_processor_state() - Restore the contents of CPU registers saved
186+
* by __save_processor_state()
187+
* @ctxt: Structure to load the registers contents from.
187188
*
188189
* The asm code that gets us here will have restored a usable GDT, although
189190
* it will be pointing to the wrong alias.

0 commit comments

Comments
 (0)