bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/5 gnumach] i386: Refactor int stacks to be per cpu for SMP


From: Almudena Garcia
Subject: Re: [PATCH 2/5 gnumach] i386: Refactor int stacks to be per cpu for SMP
Date: Thu, 2 Feb 2023 16:56:55 +0100

I already suggested move this to a function

+#ifndef MACH_HYP
+    /* Turn paging on.
+     * TODO: Why does setting the WP bit here cause a crash?
+     */
+    set_cr0(get_cr0() | CR0_PG /* | CR0_WP */);
+    set_cr0(get_cr0() & ~(CR0_CD | CR0_NW));
+    if (CPU_HAS_FEATURE(CPU_FEATURE_PGE))
+        set_cr4(get_cr4() | CR4_PGE);

Added to this, checking this

void
 start_other_cpus(void)
 {
-       int cpu;
-       for (cpu = 0; cpu < NCPUS; cpu++)
-               if (cpu != cpu_number())
-                       cpu_start(cpu);
-}
+       int ncpus = smp_get_numcpus();
+
+       //Copy cpu initialization assembly routine
+       memcpy((void*)phystokv(AP_BOOT_ADDR), (void*) &apboot,
+              (uint32_t)&apbootend - (uint32_t)&apboot);

+#ifndef APIC
+       lapic_enable(); /* Enable lapic only once */
+#endif
+       unsigned cpu;
+
+       splhigh();
+
+       bspdone = 0;
+       for (cpu = 1; cpu < ncpus; cpu++) {
+               machine_slot[cpu].running = FALSE;
+
+               //Start cpu
+               printf("Starting AP %d\n", cpu);
+               cpu_start(cpu);
+
+               bspdone++;
+               do {
+                       asm volatile ("pause" : : : "memory");
+               } while (machine_slot[cpu].running == FALSE);
+
+               __sync_synchronize();
+       }
+       printf("BSP: Completed SMP init\n");
+}
 #endif /* NCPUS > 1 */

I miss the stack's memory reserve and assignation for AP processors, which was usually make before startup these. Where are this?

El mié, 1 feb 2023 a las 18:54, Samuel Thibault (<samuel.thibault@gnu.org>) escribió:
Hello,

Damien Zammit, le mer. 01 févr. 2023 10:05:47 +0000, a ecrit:
> This is a rather large commit, but difficult to break it up.

Perhaps you can separate out the moving of the i386at_init code

> @@ -448,47 +444,8 @@ i386at_init(void)
>        */
>       biosmem_setup();
>
> -     /*
> -      * We'll have to temporarily install a direct mapping
> -      * between physical memory and low linear memory,
> -      * until we start using our new kernel segment descriptors.
> -      */
> -#if INIT_VM_MIN_KERNEL_ADDRESS != LINEAR_MIN_KERNEL_ADDRESS
> -     vm_offset_t delta = INIT_VM_MIN_KERNEL_ADDRESS - LINEAR_MIN_KERNEL_ADDRESS;
> -     if ((vm_offset_t)(-delta) < delta)
> -             delta = (vm_offset_t)(-delta);
> -     int nb_direct = delta >> PDESHIFT;
> -     for (i = 0; i < nb_direct; i++)
> -             kernel_page_dir[lin2pdenum_cont(INIT_VM_MIN_KERNEL_ADDRESS) + i] =
> -                     kernel_page_dir[lin2pdenum_cont(LINEAR_MIN_KERNEL_ADDRESS) + i];

[etc.]

into functions?

Samuel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]