Page 1 of 1
To ask questions about priviledge change
Posted: Sun May 22, 2011 7:08 pm
by leetow2003
The first I use instruction RETF from 0 ring to 3 ring,then I use calling gate
from ring 3 to ring 0,I want to know:
(1) These code segments are 32-bit segments,
so the stack segments must be 32-bit segmnet,is my opinion right?
(2) The DPL of calling gate is 3,its RPL must be 3,
is my opinion right?
Re: To ask questions about priviledge change
Posted: Mon May 23, 2011 2:33 am
by egos
leetow2003 wrote:(1) These code segments are 32-bit segments, so the stack segments must be 32-bit segmnet,is my opinion right?
Yes. And esp value should be multiple of 4 bytes.
leetow2003 wrote:(2) The DPL of calling gate is 3,its RPL must be 3, is my opinion right?
No. Here the same rule applies as for data access: Max(CPL, RPL) <= DPL (usually CPL=RPL). I.e. you can use same gate to transfer control to the kernel from any privilege level if its DPL=3.
Re: To ask questions about priviledge change
Posted: Mon May 23, 2011 4:46 am
by rdos
egos wrote:leetow2003 wrote:(1) These code segments are 32-bit segments, so the stack segments must be 32-bit segmnet,is my opinion right?
Yes. And esp value should be multiple of 4 bytes.
No. A 32-bit application can have a 16-bit kernel stack (for instance). The bitness of the stack segment only determines if the processor uses SP or ESP.
A segmented, 32-bit, application could also theoretically have a 16-bit stack segment. The code would not be dependent on this. Size for pushes are determined by code segment bitness, not stack segment bitness.