expand-up & expand-down segments

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
firas981

expand-up & expand-down segments

Post by firas981 »

should anybody please explain to me expand-up & expand-down segments in IA-32 , they are not explained
clearly in intel's " Volume 3 System Programming Guide " .

thanks ;D
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:expand-up & expand-down segments

Post by Pype.Clicker »

Those 'expand down' segments are probably one of the most confusing stuff in the manuals ...

Basically, when you describe segments, you want them to be valid for offset ranging from 0 through a certain limit ... They are said to be 'expand-up' segments, because if you wish so, you can make them bigger by changing their limit. Clearly, the segment expansion/reduction occurs on the 'top' boundary while the 'bottom' of the segment remains at offset 0.

However, for stacks (which grows downwards), expand-up segments are not that useful. It would be more interresting to have a stack segment which we can expand/shrink by playing on the lowest bound and have [limit .. 0xFFFFFF] rather than [0 .. limit]

That way, when the stack grows beyond the limit, you catch a STACK FAULT and you can enlarge the stack, giving it more pages, etc.

Another interresting way to use the EXP-DOWN segments i found is to protect your kernel against NULL pointers ... indeed, an expand-down segment with a limit of 1 (granularity 4Kb) will allow the full range of address to be used *but* the range [0-4KB], which should catch most of NULL->field references ...
Post Reply