Skip to content

Commit 5492bf5

Browse files
Salil Mehtajongwu
authored andcommitted
arm64: kernel: Bound the total(present+disabled) cpus with nr_cpu_ids
Bound the total number of identified cpus(including disabled cpus) by maximum allowed limit by the kernel. Max value is either specified as part of the kernel parameters 'nr_cpus' or specified during compile time using CONFIG_NR_CPUS. Signed-off-by: Salil Mehta <[email protected]> Signed-off-by: Xiongfeng Wang <[email protected]>
1 parent 74df87d commit 5492bf5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

arch/arm64/kernel/smp.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ static int __init smp_cpu_setup(int cpu)
530530
}
531531

532532
static bool bootcpu_valid __initdata;
533+
static bool cpus_clipped __initdata = false;
533534
static unsigned int cpu_count = 1;
534535
static unsigned int disabled_cpu_count;
535536

@@ -553,6 +554,11 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
553554
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
554555
u64 hwid = processor->arm_mpidr;
555556

557+
if (total_cpu_count > nr_cpu_ids) {
558+
cpus_clipped = true;
559+
return;
560+
}
561+
556562
if (!(processor->flags & ACPI_MADT_ENABLED)) {
557563
#ifndef CONFIG_ACPI_HOTPLUG_CPU
558564
pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid);
@@ -586,8 +592,8 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
586592
return;
587593
}
588594

589-
if (cpu_count >= NR_CPUS)
590-
return;
595+
// if (cpu_count >= NR_CPUS)
596+
// return;
591597

592598
/* map the logical cpu id to cpu MPIDR */
593599
set_cpu_logical_map(total_cpu_count, hwid);
@@ -706,8 +712,10 @@ static void __init of_parse_and_init_cpus(void)
706712
continue;
707713
}
708714

709-
if (cpu_count >= NR_CPUS)
715+
if (cpu_count >= NR_CPUS) {
716+
cpus_clipped = true;
710717
goto next;
718+
}
711719

712720
pr_debug("cpu logical map 0x%llx\n", hwid);
713721
set_cpu_logical_map(cpu_count, hwid);
@@ -728,16 +736,17 @@ static void __init of_parse_and_init_cpus(void)
728736
*/
729737
void __init smp_init_cpus(void)
730738
{
739+
unsigned int total_cpu_count = disabled_cpu_count + cpu_count;
731740
int i;
732741

733742
if (acpi_disabled)
734743
of_parse_and_init_cpus();
735744
else
736745
acpi_parse_and_init_cpus();
737746

738-
if (cpu_count > nr_cpu_ids)
747+
if (cpus_clipped)
739748
pr_warn("Number of cores (%d) exceeds configured maximum of %u - clipping\n",
740-
cpu_count, nr_cpu_ids);
749+
total_cpu_count, nr_cpu_ids);
741750

742751
if (!bootcpu_valid) {
743752
pr_err("missing boot CPU MPIDR, not enabling secondaries\n");

0 commit comments

Comments
 (0)