<s>
A	O
call	B-Device
gate	I-Device
is	O
a	O
mechanism	O
in	O
Intel	O
's	O
x86	B-Operating_System
architecture	I-Operating_System
for	O
changing	O
the	O
privilege	B-Device
level	I-Device
of	O
a	O
process	O
when	O
it	O
executes	O
a	O
predefined	O
function	O
call	O
using	O
a	O
CALL	O
FAR	O
instruction	O
.	O
</s>
<s>
Call	B-Device
gates	I-Device
are	O
intended	O
to	O
allow	O
less	O
privileged	O
code	O
to	O
call	O
code	O
with	O
a	O
higher	O
privilege	B-Device
level	I-Device
.	O
</s>
<s>
This	O
type	O
of	O
mechanism	O
is	O
essential	O
in	O
modern	O
operating	B-General_Concept
systems	I-General_Concept
that	O
employ	O
memory	B-General_Concept
protection	I-General_Concept
since	O
it	O
allows	O
user	O
applications	O
to	O
use	O
kernel	B-Operating_System
functions	O
and	O
system	B-Operating_System
calls	I-Operating_System
in	O
a	O
way	O
that	O
can	O
be	O
controlled	O
by	O
the	O
operating	B-General_Concept
system	I-General_Concept
.	O
</s>
<s>
Call	B-Device
gates	I-Device
use	O
a	O
special	O
selector	O
value	O
to	O
reference	O
a	O
descriptor	O
accessed	O
via	O
the	O
Global	B-General_Concept
Descriptor	I-General_Concept
Table	I-General_Concept
or	O
the	O
Local	B-General_Concept
Descriptor	I-General_Concept
Table	I-General_Concept
,	O
which	O
contains	O
the	O
information	O
needed	O
for	O
the	O
call	O
across	O
privilege	O
boundaries	O
.	O
</s>
<s>
This	O
is	O
similar	O
to	O
the	O
mechanism	O
used	O
for	O
interrupts	B-Application
.	O
</s>
<s>
Assuming	O
a	O
call	B-Device
gate	I-Device
has	O
been	O
set	O
up	O
already	O
by	O
the	O
operating	B-Operating_System
system	I-Operating_System
kernel	I-Operating_System
,	O
code	O
simply	O
does	O
a	O
CALL	O
FAR	O
with	O
the	O
necessary	O
segment	B-Device
selector	I-Device
(	O
the	O
offset	O
field	O
is	O
ignored	O
)	O
.	O
</s>
<s>
Assuming	O
all	O
checks	O
pass	O
,	O
a	O
new	O
CS/EIP	O
is	O
loaded	O
from	O
the	O
segment	B-Operating_System
descriptor	I-Operating_System
,	O
and	O
continuation	O
information	O
is	O
pushed	O
onto	O
the	O
stack	O
of	O
the	O
new	O
privilege	B-Device
level	I-Device
(	O
old	O
SS	O
,	O
old	O
ESP	O
,	O
old	O
CS	O
,	O
old	O
EIP	B-General_Concept
,	O
in	O
that	O
order	O
)	O
.	O
</s>
<s>
The	O
number	O
of	O
parameters	O
to	O
copy	O
is	O
located	O
in	O
the	O
call	B-Device
gate	I-Device
descriptor	O
.	O
</s>
<s>
The	O
kernel	B-Operating_System
may	O
return	O
to	O
the	O
user	O
space	O
program	O
by	O
using	O
a	O
RET	O
FAR	O
instruction	O
which	O
pops	O
the	O
continuation	O
information	O
off	O
the	O
stack	O
and	O
returns	O
to	O
the	O
outer	O
privilege	B-Device
level	I-Device
.	O
</s>
<s>
Multics	B-Application
was	O
the	O
first	O
user	O
of	O
call	B-Device
gates	I-Device
.	O
</s>
<s>
The	O
Honeywell	B-Device
6180	I-Device
had	O
call	B-Device
gates	I-Device
as	O
part	O
of	O
the	O
architecture	O
,	O
but	O
Multics	B-Application
simulated	O
them	O
on	O
the	O
older	O
GE	B-Device
645	I-Device
.	O
</s>
<s>
OS/2	B-Application
was	O
an	O
early	O
user	O
of	O
Intel	O
call	B-Device
gates	I-Device
to	O
transfer	O
between	O
application	O
code	O
running	O
in	O
ring	B-Operating_System
3	I-Operating_System
,	O
privileged	O
code	O
running	O
in	O
ring	B-Operating_System
2	I-Operating_System
,	O
and	O
kernel	B-Operating_System
code	O
in	O
ring	B-Operating_System
0	I-Operating_System
.	O
</s>
<s>
Windows	O
95	O
executes	O
drivers	O
and	O
process	O
switching	O
in	O
ring	B-Operating_System
0	I-Operating_System
,	O
while	O
applications	O
,	O
including	O
API	O
DLL	O
such	O
as	O
kernel32.dll	O
and	O
krnl386.exe	O
are	O
executed	O
in	O
ring	B-Operating_System
3	I-Operating_System
.	O
</s>
<s>
Driver	O
VWIN32.VXD	O
provides	O
key	O
operating	B-General_Concept
system	I-General_Concept
primitives	O
at	O
ring	B-Operating_System
0	I-Operating_System
.	O
</s>
<s>
Upon	O
return	O
from	O
the	O
INT	O
instruction	O
,	O
the	O
ES.DI	O
registers	O
contain	O
a	O
far	O
pointer	O
that	O
can	O
be	O
called	O
to	O
transfer	O
control	O
to	O
the	O
VxD	O
running	O
at	O
ring	B-Operating_System
0	I-Operating_System
.	O
</s>
<s>
The	O
descriptor	O
pointed	O
by	O
ES	O
is	O
actually	O
a	O
call	B-Device
gate	I-Device
.	O
</s>
<s>
32-bit	O
applications	O
,	O
however	O
,	O
when	O
they	O
need	O
to	O
access	O
Windows	O
95	O
driver	O
code	O
,	O
call	O
undocumented	O
VxDCall	O
function	O
in	O
KERNEL32.DLL	O
which	O
essentially	O
calls	O
INT	O
30h	O
,	O
which	O
changes	O
ring	B-Operating_System
mode	O
.	O
</s>
<s>
Modern	O
x86	B-Operating_System
operating	B-General_Concept
systems	I-General_Concept
are	O
transitioning	O
away	O
from	O
CALL	O
FAR	O
call	B-Device
gates	I-Device
.	O
</s>
<s>
With	O
the	O
introduction	O
of	O
x86	B-Operating_System
instructions	O
for	O
system	B-Operating_System
call	I-Operating_System
(	O
SYSENTER/SYSEXIT	O
by	O
Intel	O
and	O
SYSCALL/SYSRET	O
by	O
AMD	O
)	O
,	O
a	O
new	O
faster	O
mechanism	O
was	O
introduced	O
for	O
control	O
transfers	O
for	O
x86	B-Operating_System
programs	O
.	O
</s>
<s>
As	O
most	O
other	O
architectures	O
do	O
not	O
support	O
call	B-Device
gates	I-Device
,	O
their	O
use	O
was	O
rare	O
even	O
before	O
these	O
new	O
instructions	O
,	O
as	O
software	O
interrupts	B-Application
or	O
traps	B-Application
were	O
preferred	O
for	O
portability	O
,	O
even	O
though	O
call	B-Device
gates	I-Device
are	O
significantly	O
faster	O
than	O
interrupts	B-Application
.	O
</s>
<s>
Call	B-Device
gates	I-Device
are	O
more	O
flexible	O
than	O
the	O
SYSENTER/SYSEXIT	O
and	O
SYSCALL/SYSRET	O
instructions	O
since	O
unlike	O
the	O
latter	O
two	O
,	O
call	B-Device
gates	I-Device
allow	O
for	O
changing	O
from	O
an	O
arbitrary	O
privilege	B-Device
level	I-Device
to	O
an	O
arbitrary	O
(	O
albeit	O
higher	O
or	O
equal	O
)	O
privilege	B-Device
level	I-Device
.	O
</s>
<s>
The	O
fast	O
SYS*	O
instructions	O
only	O
allow	O
control	O
transfers	O
from	O
ring	B-Operating_System
3	I-Operating_System
to	O
0	O
and	O
vice	O
versa	O
.	O
</s>
<s>
To	O
preserve	O
system	O
security	O
,	O
the	O
Global	B-General_Concept
Descriptor	I-General_Concept
Table	I-General_Concept
must	O
be	O
held	O
in	O
protected	B-General_Concept
memory	I-General_Concept
,	O
otherwise	O
any	O
program	O
will	O
be	O
able	O
to	O
create	O
its	O
own	O
call	B-Device
gate	I-Device
and	O
use	O
it	O
to	O
raise	O
its	O
privilege	B-Device
level	I-Device
.	O
</s>
<s>
Call	B-Device
gates	I-Device
have	O
been	O
used	O
in	O
software	O
security	O
exploits	O
,	O
when	O
ways	O
have	O
been	O
found	O
around	O
this	O
protection	O
.	O
</s>
<s>
One	O
example	O
of	O
this	O
is	O
the	O
e-mail	O
worm	O
Gurong.A	O
,	O
written	O
to	O
exploit	O
the	O
Microsoft	B-Application
Windows	I-Application
operating	I-Application
system	I-Application
,	O
which	O
uses	O
\Device\PhysicalMemory	O
to	O
install	O
a	O
call	B-Device
gate	I-Device
.	O
</s>
