[BUG] Work on null vector rejection
This commit is contained in:
parent
fcf6e745a7
commit
7cc39e37dc
|
@ -160,8 +160,6 @@ extern void MmStoreGdt(void);
|
|||
|
||||
void MmInitPaging(void);
|
||||
|
||||
void MmReloadPaging(void);
|
||||
|
||||
void MmActivatePageHandler(void);
|
||||
|
||||
//
|
||||
|
|
|
@ -71,6 +71,9 @@ void MmInitPaging(void)
|
|||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
||||
// NULL VECTOR
|
||||
MmPT[0] = ((ulong)(0*KPAGESIZE));
|
||||
|
||||
for (volatile ulong i = 0; i < NB_4K; i++) {
|
||||
MmPD[i] = (ulong)(&MmPT[i*512])| MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
@ -96,63 +99,6 @@ void MmInitPaging(void)
|
|||
//DebugLog("\tStack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
|
||||
}
|
||||
|
||||
//
|
||||
// Reloads the page tables
|
||||
//
|
||||
void MmReloadPaging(void)
|
||||
{
|
||||
extern MemoryMap_t memoryMap;
|
||||
ulong phRamSize = memoryMap.freeRamSize + memoryMap.nonfreeRamSize;
|
||||
|
||||
|
||||
for (volatile ulong i = 0; i < 512 * NB_4K; i++) {
|
||||
// STACK GUARD PAGE
|
||||
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.stackEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE));
|
||||
MmStackGuards[0] = ((ulong)(i*KPAGESIZE));
|
||||
continue;
|
||||
}
|
||||
|
||||
// ENOMEM like
|
||||
if ((ulong)(i*KPAGESIZE) > (ulong)phRamSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
// STACK GARD PAGE
|
||||
if ((ulong)(i*KPAGESIZE) == (ulong)BtLoaderInfo.kernelEndAddr) {
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE));
|
||||
MmStackGuards[1] = ((ulong)(i*KPAGESIZE));
|
||||
continue;
|
||||
}
|
||||
|
||||
MmPT[i] = ((ulong)(i*KPAGESIZE)) | MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
||||
for (volatile ulong i = 0; i < NB_4K; i++) {
|
||||
MmPD[i] = (ulong)(&MmPT[i*512])| MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
||||
for (volatile ulong i = NB_4K; i < 512 * RAM_MAX; i++) {
|
||||
// ENOMEM like
|
||||
if ((ulong)(i* UPAGESIZE) > (ulong)phRamSize) {
|
||||
break;
|
||||
}
|
||||
|
||||
MmPD[i] = 0;
|
||||
MmPD[i] = ((ulong)(i* UPAGESIZE)) | MF_PRESENT | MF_READWRITE | MF_HUGE;
|
||||
}
|
||||
|
||||
for (volatile int i = 0; i < RAM_MAX; i++) {
|
||||
MmPDP[i] = (ulong)(&MmPD[i*512])| MF_PRESENT | MF_READWRITE;
|
||||
}
|
||||
|
||||
MmPML4[0] = (ulong)(&MmPDP[0])| MF_PRESENT | MF_READWRITE;
|
||||
|
||||
MmLoadPML4((void *)MmPML4);
|
||||
DebugLog("\tPaging tables initialized at %p, %p\n", &MmPD, &MmPT);
|
||||
DebugLog("\tStack Guards at %p, %p\n", MmStackGuards[0], MmStackGuards[1]);
|
||||
}
|
||||
|
||||
// Returns the rank of the Stack Guards
|
||||
void *MmGetStackGuards(char rank)
|
||||
{
|
||||
|
|
|
@ -153,12 +153,6 @@ error_t CmdPF(int argc, char **argv, char *cmdline)
|
|||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdReloadPage(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
MmReloadPaging();
|
||||
return EOK;
|
||||
}
|
||||
|
||||
error_t CmdShell(int argc, char **argv, char *cmdline)
|
||||
{
|
||||
ShStartShell();
|
||||
|
@ -203,7 +197,6 @@ static Command_t testcmdtable[] =
|
|||
{ "help", CmdHelpTest, "Show this message" },
|
||||
{ "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"},
|
||||
{ "pf", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
||||
{ "rpag", CmdReloadPage, "Reload the pages directory" },
|
||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
||||
|
|
Loading…
Reference in New Issue