Damien Zammit via Bug reports for the GNU Hurd, le mar. 10 déc. 2024 07:29:56
+0000, a ecrit:
> If this is not done, the spl code is called by kmsg_putchar
> on APs during printing of bringup debug, causing the only
> unnecessary early access of GS.
> ---
> i386/i386/mp_desc.c | 3 ++-
> i386/i386at/model_dep.c | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/i386/i386/mp_desc.c b/i386/i386/mp_desc.c
> index 16b1c865..7595eb1e 100644
> --- a/i386/i386/mp_desc.c
> +++ b/i386/i386/mp_desc.c
> @@ -325,7 +325,7 @@ start_other_cpus(void)
>
> unsigned cpu;
>
> - splhigh();
> + asm volatile ("cli");
>
> /* Disable IOAPIC interrupts (IPIs not affected).
> * Clearing this flag is similar to masking all
> @@ -357,5 +357,6 @@ start_other_cpus(void)
>
> /* Re-enable IOAPIC interrupts as per setup */
> lapic_enable();
> + spl_init = 1;
> }
> #endif /* NCPUS > 1 */
> diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
> index 30449c37..7cbbf70b 100644
> --- a/i386/i386at/model_dep.c
> +++ b/i386/i386at/model_dep.c
> @@ -380,8 +380,9 @@ i386at_init(void)
> #else /* MACH_HYP */
> hyp_intrinit();
> #endif /* MACH_HYP */
> +#if NCPUS == 1
> spl_init = 1;
> -
> +#endif
But then kmsg_putchar becomes unsafe until very late, that will bite
us... And you never know who would introduce gs usage in whatever place
in the boot code.
I know that you don't like tinkering with assembler, but it's simpler to
fix one place than to have to maintain principles in a lot of places.
Samuel