always save and restore %fs, %gs to ensure old segment entries are never
accessible to user from the hidden CPU segment registers.
This commit is contained in:
parent
adcd16c3f7
commit
c7317d4dc7
2 changed files with 12 additions and 4 deletions
|
@ -8,6 +8,8 @@ alltraps:
|
||||||
# Build trap frame.
|
# Build trap frame.
|
||||||
pushl %ds
|
pushl %ds
|
||||||
pushl %es
|
pushl %es
|
||||||
|
pushl %fs
|
||||||
|
pushl %gs
|
||||||
pushal
|
pushal
|
||||||
|
|
||||||
# Set up data segments.
|
# Set up data segments.
|
||||||
|
@ -24,6 +26,8 @@ alltraps:
|
||||||
.globl trapret
|
.globl trapret
|
||||||
trapret:
|
trapret:
|
||||||
popal
|
popal
|
||||||
|
popl %gs
|
||||||
|
popl %fs
|
||||||
popl %es
|
popl %es
|
||||||
popl %ds
|
popl %ds
|
||||||
addl $0x8, %esp # trapno and errcode
|
addl $0x8, %esp # trapno and errcode
|
||||||
|
|
12
x86.h
12
x86.h
|
@ -135,21 +135,25 @@ struct trapframe {
|
||||||
uint eax;
|
uint eax;
|
||||||
|
|
||||||
// rest of trap frame
|
// rest of trap frame
|
||||||
ushort es;
|
ushort gs;
|
||||||
ushort padding1;
|
ushort padding1;
|
||||||
ushort ds;
|
ushort fs;
|
||||||
ushort padding2;
|
ushort padding2;
|
||||||
|
ushort es;
|
||||||
|
ushort padding3;
|
||||||
|
ushort ds;
|
||||||
|
ushort padding4;
|
||||||
uint trapno;
|
uint trapno;
|
||||||
|
|
||||||
// below here defined by x86 hardware
|
// below here defined by x86 hardware
|
||||||
uint err;
|
uint err;
|
||||||
uint eip;
|
uint eip;
|
||||||
ushort cs;
|
ushort cs;
|
||||||
ushort padding3;
|
ushort padding5;
|
||||||
uint eflags;
|
uint eflags;
|
||||||
|
|
||||||
// below here only when crossing rings, such as from user to kernel
|
// below here only when crossing rings, such as from user to kernel
|
||||||
uint esp;
|
uint esp;
|
||||||
ushort ss;
|
ushort ss;
|
||||||
ushort padding4;
|
ushort padding6;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue