Hi,
I've just changed my data segments from EXPAND UP segments to EXPAND DOWN segments.
The expand up sements were using a base of 0 and limit of 0xFFFFF (32 bits, page granular).
The expand down segments use a base of 0 and a limit of 0.(32 bits, page granular).
(I made this change so that the stack segment will grow downwards.)
When I try to access address 0 or (0x78) which are both in the Interrupt vector table (for real mode), I get a general protection fault.
When I change the expand down segment to use a base of 0 and a limit of 0xFFFFF, the pc just keeps rebooting.
My question is, using a flat model, should my data segment selector be EXPAND UP and the stack selector EXPAND DOWN?
How are you all using this EXPAND UP/DOWN selectors?
(NOTE: When i use EXPAND UP for both DS and SS, I can access those addresses.MY CS selector has a base of 0 and limit of 0xFFFFF and is NON-Conforming.)
Data Segment problems
Re: Data Segment problems
Hi,
For expand down segments, the CPU allows accessed between LIMIT and 0xFFFFFFFF, and generates a GPF for all accesses below the limit. The idea being that you can decrease the limit to make the segment larger without making a mess of current offsets.
If you want to be able to access 4 GB with expand down segments you'd need "LIMIT = 0x00000000".
Mostly, if you're using paging then expand down segments aren't worth the hassle...
Cheers,
Brendan
For expand down segments, the CPU allows accessed between LIMIT and 0xFFFFFFFF, and generates a GPF for all accesses below the limit. The idea being that you can decrease the limit to make the segment larger without making a mess of current offsets.
In this case you'll be able to access zero bytes (from limit + 1 to 0xFFFFFFFF, or from 0xFFFFFFFF + 1 to 0xFFFFFFFF).slasher wrote:The expand up sements were using a base of 0 and limit of 0xFFFFF (32 bits, page granular).
If you want to be able to access 4 GB with expand down segments you'd need "LIMIT = 0x00000000".
Most OSs use the same expand up descriptor for DS, ES and SS. Using an expand down segment for the stack is good in theory (for preventing the stack from overflowing and trashing other data), but it tends to suck a bit once you've got multi-threading and need one segment descriptor per thread.slasher wrote:My question is, using a flat model, should my data segment selector be EXPAND UP and the stack selector EXPAND DOWN?
Mostly, if you're using paging then expand down segments aren't worth the hassle...
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.