Page 1 of 1
modify GDT in MP-System at runtime
Posted: Mon Feb 09, 2009 7:00 am
by WeirdCat
How do you best add entries to the GDT (for TSSs and LDTs) on a multi processor system at runtime and propagate them to all CPUs?
At the moment the limit of my GDT is as small as possible, but if I wanted to add additional entries at runtime I had to increase the limit and propagate the new value to all CPUs. To spare me the process of propagating changes I'm planning to just set the GDT limit to 0xFFFF and fill all unused entries with zeroes. To prevent the loading of invalid entries I'm planning to use a locked CMPXCHG8B to modify GDT entries. Is this wise, or do I could get in trouble with this later on?
TIA,
Ash
Re: modify GDT in MP-System at runtime
Posted: Mon Feb 09, 2009 7:20 am
by AJ
Hi,
Before you even load the GDT on the AP's, you have presumambly detected (and therefore know the number of) processors. Why not simply create a GDT after AP detection, when you know the exact number of entries you need?
Cheers,
Adam
Re: modify GDT in MP-System at runtime
Posted: Mon Feb 09, 2009 8:33 am
by WeirdCat
AJ wrote:Before you even load the GDT on the AP's, you have presumambly detected (and therefore know the number of) processors. Why not simply create a GDT after AP detection, when you know the exact number of entries you need?
This would be a viable solution if I only create one TSS/CPU, but I think I will give each Task it's own TSS and since they should be spawnable at runtime I need a way to modify the GDT at runtime.
Ash
Re: modify GDT in MP-System at runtime
Posted: Mon Feb 09, 2009 9:54 am
by Brendan
Hi,
Ash wrote:This would be a viable solution if I only create one TSS/CPU, but I think I will give each Task it's own TSS and since they should be spawnable at runtime I need a way to modify the GDT at runtime.
In this case, you need 2 TSS descriptors in the GDT for each CPU (where you change the TSS descriptor just before doing the task switch to avoid the "maximum of 8190 tasks" limit), but each pair of TSS descriptors are only used by one CPU (no locks needed) and could be allocated/setup during boot (unless you want to support hot-plug CPUs).
Cheers,
Brendan
Re: modify GDT in MP-System at runtime
Posted: Mon Feb 09, 2009 11:30 am
by WeirdCat
Brendan wrote:In this case, you need 2 TSS descriptors in the GDT for each CPU (where you change the TSS descriptor just before doing the task switch to avoid the "maximum of 8190 tasks" limit), but each pair of TSS descriptors are only used by one CPU (no locks needed) and could be allocated/setup during boot (unless you want to support hot-plug CPUs).
Isn't there a CPU internal cache for segment descriptors that you sidestep when you constantly overwrite a TSS descriptor? I'm not sure how relevant this in reality is, but on the other hand a 4k tasks limit ((1xTSS+1xLDT)/Task) doesn't seem to hard to me. My Vista runs < 100 processes with < 1000 threads at the moment.