From a8ca76845cb1b4637eaa5ada91e6520731bd7650 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Tue, 12 Oct 2021 20:04:38 +0900 Subject: [PATCH] smp: Don't just fatal() if there's too many cores; initialize up to 32 --- base/usr/include/kernel/process.h | 2 +- kernel/arch/x86_64/smp.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/base/usr/include/kernel/process.h b/base/usr/include/kernel/process.h index 74fa5fd6..b1d06048 100644 --- a/base/usr/include/kernel/process.h +++ b/base/usr/include/kernel/process.h @@ -192,7 +192,7 @@ struct ProcessorLocal { #endif }; -extern struct ProcessorLocal processor_local_data[32]; +extern struct ProcessorLocal processor_local_data[]; extern int processor_count; /** diff --git a/kernel/arch/x86_64/smp.c b/kernel/arch/x86_64/smp.c index 9eebecf4..4beb0f41 100644 --- a/kernel/arch/x86_64/smp.c +++ b/kernel/arch/x86_64/smp.c @@ -247,13 +247,13 @@ void smp_initialize(void) { switch (entry[0]) { case 0: if (entry[4] & 0x01) { + if (cores == 32) { /* TODO define this somewhere better */ + printf("smp: too many cores\n"); + goto _toomany; + } processor_local_data[cores].cpu_id = cores; processor_local_data[cores].lapic_id = entry[3]; cores++; - if (cores == 33) { - printf("smp: too many cores\n"); - arch_fatal(); - } } break; /* TODO: Other entries */ @@ -262,6 +262,7 @@ void smp_initialize(void) { } } +_toomany: processor_count = cores; if (!lapic_base) return;