[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/12 gnumach] Print warning on bad cpu numbering and assume
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 03/12 gnumach] Print warning on bad cpu numbering and assume BSP |
Date: |
Tue, 31 Jan 2023 20:41:33 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Applied, thanks!
Damien Zammit, le mar. 31 janv. 2023 09:36:12 +0000, a ecrit:
> ---
> i386/i386/apic.c | 5 +++++
> i386/i386/cpu_number.c | 16 +++++++++++++---
> 2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/i386/i386/apic.c b/i386/i386/apic.c
> index e53d4749..891ce288 100644
> --- a/i386/i386/apic.c
> +++ b/i386/i386/apic.c
> @@ -278,6 +278,11 @@ lapic_enable(void)
> cpu_intr_save(&flags);
>
> apic_id = apic_get_current_cpu();
> + if (apic_id < 0)
> + {
> + printf("apic_get_current_cpu() failed, assuming BSP\n");
> + apic_id = 0;
> + }
>
> dummy = lapic->dest_format.r;
> lapic->dest_format.r = 0xffffffff; /* flat model */
> diff --git a/i386/i386/cpu_number.c b/i386/i386/cpu_number.c
> index 65d74ddc..c719d841 100644
> --- a/i386/i386/cpu_number.c
> +++ b/i386/i386/cpu_number.c
> @@ -19,14 +19,24 @@
> #include <i386/apic.h>
> #include <i386/smp.h>
> #include <i386/cpu.h>
> +#include <kern/printf.h>
>
> #if NCPUS > 1
> int cpu_number(void)
> {
> - int kernel_id;
> - unsigned long flags;
> + int kernel_id, apic_id;
>
> - kernel_id = apic_get_cpu_kernel_id(apic_get_current_cpu());
> + apic_id = apic_get_current_cpu();
> + if (apic_id < 0) {
> + printf("apic_get_current_cpu() failed, assuming BSP\n");
> + apic_id = 0;
> + }
> +
> + kernel_id = apic_get_cpu_kernel_id(apic_id);
> + if (kernel_id < 0) {
> + printf("apic_get_cpu_kernel_id() failed, assuming BSP\n");
> + kernel_id = 0;
> + }
>
> return kernel_id;
> }
> --
> 2.34.1
>
>
>
--
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.