[coyotos-dev] SMP: apboot.S misbehaves for cpu_ncpu > 2 [PATCH]

Jonathan S. Shapiro shap at eros-os.com
Mon Nov 5 12:29:52 EST 2007


Jeroen:

On Sun, 2007-11-04 at 13:34 -0500, Jeroen Visser wrote:
> The following patch (or similar) is needed for cpu_ncpu > 2.

Do you perhaps mean >= 2? Ah. No, I see the problem. The problem is that
we are copying this code once, instead of once per CPU initialization.
When the relocation of boot_gdt_base is performed the second time, it
loads a bad GDT base address.

I agree that this patch solves that problem, but before I apply it I
want to ask a code maintenance question:

It seems likely to me that this code will get modified over time, and
that we will be forced to do more hand-relocation as that occurs. It
seems to me further that this relocation problem is likely to recur as
we do, because we will tend to forget about the issue over time.
Finally, it seems to me that the relocation problem is unlikely to get
tested well, because most developers will recompile and test the single
CPU scenario.

Aside: I am one of those developers. It took me some head scratching to
understand why your code was fixing anything.

There are two possible fixes:

  1. Implement the relocation at run time, as you have done.
  2. Copy a fresh copy of the page for each CPU initialization, so
     that we do not need to consider problems that might result
     from repeated relocations.

There is nothing here that is performance critical, so which fix do you
think is less likely to yield coding errors under future maintenance?

shap
-- 
Jonathan S. Shapiro, Ph.D.
Managing Director
The EROS Group, LLC
www.coyotos.org, www.eros-os.org



More information about the coyotos-dev mailing list