X86: Set up a space for a GDT in SE so we can set up TLS or LDT segments.
This commit is contained in:
parent
281ef8111a
commit
e23d688d8f
|
@ -251,6 +251,20 @@ I386LiveProcess::startup()
|
||||||
|
|
||||||
argsInit(sizeof(uint32_t), VMPageSize);
|
argsInit(sizeof(uint32_t), VMPageSize);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set up a GDT for this process. The whole GDT wouldn't really be for
|
||||||
|
* this process, but the only parts we care about are.
|
||||||
|
*/
|
||||||
|
_gdtStart = stack_base;
|
||||||
|
_gdtSize = VMPageSize;
|
||||||
|
pTable->allocate(_gdtStart, _gdtSize);
|
||||||
|
uint64_t zero = 0;
|
||||||
|
assert(_gdtSize % sizeof(zero) == 0);
|
||||||
|
for (Addr gdtCurrent = _gdtStart;
|
||||||
|
gdtCurrent < _gdtStart + _gdtSize; gdtCurrent += sizeof(zero)) {
|
||||||
|
initVirtMem->write(gdtCurrent, zero);
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < contextIds.size(); i++) {
|
for (int i = 0; i < contextIds.size(); i++) {
|
||||||
ThreadContext * tc = system->getThreadContext(contextIds[i]);
|
ThreadContext * tc = system->getThreadContext(contextIds[i]);
|
||||||
|
|
||||||
|
@ -281,6 +295,10 @@ I386LiveProcess::startup()
|
||||||
|
|
||||||
tc->setMiscRegNoEffect(MISCREG_CS_ATTR, csAttr);
|
tc->setMiscRegNoEffect(MISCREG_CS_ATTR, csAttr);
|
||||||
|
|
||||||
|
tc->setMiscRegNoEffect(MISCREG_TSG_BASE, _gdtStart);
|
||||||
|
tc->setMiscRegNoEffect(MISCREG_TSG_EFF_BASE, _gdtStart);
|
||||||
|
tc->setMiscRegNoEffect(MISCREG_TSG_LIMIT, _gdtStart + _gdtSize - 1);
|
||||||
|
|
||||||
//Set up the registers that describe the operating mode.
|
//Set up the registers that describe the operating mode.
|
||||||
CR0 cr0 = 0;
|
CR0 cr0 = 0;
|
||||||
cr0.pg = 1; // Turn on paging.
|
cr0.pg = 1; // Turn on paging.
|
||||||
|
|
|
@ -70,6 +70,9 @@ namespace X86ISA
|
||||||
class X86LiveProcess : public LiveProcess
|
class X86LiveProcess : public LiveProcess
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
Addr _gdtStart;
|
||||||
|
Addr _gdtSize;
|
||||||
|
|
||||||
SyscallDesc *syscallDescs;
|
SyscallDesc *syscallDescs;
|
||||||
const int numSyscallDescs;
|
const int numSyscallDescs;
|
||||||
|
|
||||||
|
@ -80,6 +83,12 @@ namespace X86ISA
|
||||||
void argsInit(int pageSize);
|
void argsInit(int pageSize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Addr gdtStart()
|
||||||
|
{ return _gdtStart; }
|
||||||
|
|
||||||
|
Addr gdtSize()
|
||||||
|
{ return _gdtSize; }
|
||||||
|
|
||||||
SyscallDesc* getDesc(int callnum);
|
SyscallDesc* getDesc(int callnum);
|
||||||
|
|
||||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||||
|
|
Loading…
Reference in a new issue