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
modify GDT in MP-System at runtime
Re: modify GDT in MP-System at runtime
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
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
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.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?
Ash
Re: modify GDT in MP-System at runtime
Hi,
Cheers,
Brendan
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).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.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: modify GDT in MP-System at runtime
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.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).