From: John Hodge Date: Sat, 19 Jun 2010 02:04:10 +0000 (+0800) Subject: Fixed #PF in Memory Manager (mm_virt.h was using KERNEL_BASE as a prefix) X-Git-Tag: rel0.06~144 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=a67686f0f79bba5390acf5ee29827d15e7abc4ff;p=tpg%2Facess2.git Fixed #PF in Memory Manager (mm_virt.h was using KERNEL_BASE as a prefix) --- diff --git a/Kernel/arch/x86_64/include/mm_virt.h b/Kernel/arch/x86_64/include/mm_virt.h index ac90321d..3c4240d7 100644 --- a/Kernel/arch/x86_64/include/mm_virt.h +++ b/Kernel/arch/x86_64/include/mm_virt.h @@ -32,7 +32,7 @@ * E480 00000000 - E500 00000000 39 512 GiB Physical Page DblAlloc Bitmap (1 page per bit) * E500 00000000 - E500 80000000 31 2 GiB Physical Page Super Bitmap (64 pages per bit) * FD00 00000000 - FD80 00000000 39 512 GiB Local APIC - * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 510) + * FE00 00000000 - FE80 00000000 39 512 GiB Fractal Mapping (PML4 508) * FE80 00000000 - FF00 00000000 39 512 GiB Temp Fractal Mapping * FF00 00000000 - FF80 00000000 39 512 GiB -- UNUSED -- * FF80 00000000 - FFFF 80000000 ~39 GiB -- UNUSED -- @@ -44,30 +44,30 @@ #define USER_STACK_SZ 0x00000000##00020000 // 64 KiB #define USER_STACK_TOP 0x00007FFF##FFFFF000 #define MM_USER_MAX 0x00007FFF##FFFFF000 -//#define KERNEL_BASE 0xFFFF8000##00000000 -#define MM_KHEAP_BASE (KERNEL_BASE|(0x8000##80000000)) -#define MM_KHEAP_MAX (KERNEL_BASE|(0x9000##00000000)) -#define MM_MODULE_MIN (KERNEL_BASE|(0x9000##00000000)) -#define MM_MODULE_MAX (KERNEL_BASE|(0x9800##00000000)) -#define MM_KERNEL_VFS (KERNEL_BASE|(0x9800##00000000)) -#define MM_KSTACK_BASE (KERNEL_BASE|(0xA000##00000000)) -#define MM_KSTACK_TOP (KERNEL_BASE|(0xB000##00000000)) +#define MM_KERNEL_RANGE 0xFFFF8000##00000000 +#define MM_KHEAP_BASE (MM_KERNEL_RANGE|(0x8000##80000000)) +#define MM_KHEAP_MAX (MM_KERNEL_RANGE|(0x9000##00000000)) +#define MM_MODULE_MIN (MM_KERNEL_RANGE|(0x9000##00000000)) +#define MM_MODULE_MAX (MM_KERNEL_RANGE|(0x9800##00000000)) +#define MM_KERNEL_VFS (MM_KERNEL_RANGE|(0x9800##00000000)) +#define MM_KSTACK_BASE (MM_KERNEL_RANGE|(0xA000##00000000)) +#define MM_KSTACK_TOP (MM_KERNEL_RANGE|(0xB000##00000000)) -#define MM_HWMAP_BASE (KERNEL_BASE|(0xC000##00000000)) -#define MM_HWMAP_TOP (KERNEL_BASE|(0xD000##00000000)) -#define MM_PPD_BASE (KERNEL_BASE|(0xD000##00000000)) +#define MM_HWMAP_BASE (MM_KERNEL_RANGE|(0xC000##00000000)) +#define MM_HWMAP_TOP (MM_KERNEL_RANGE|(0xD000##00000000)) +#define MM_PPD_BASE (MM_KERNEL_RANGE|(0xD000##00000000)) #define MM_PPD_CFG MM_PPD_BASE -#define MM_PPD_VFS (KERNEL_BASE|(0xD008##00000000)) -#define MM_USER_CODE (KERNEL_BASE|(0xD080##00000000)) +#define MM_PPD_VFS (MM_KERNEL_RANGE|(0xD008##00000000)) +#define MM_USER_CODE (MM_KERNEL_RANGE|(0xD080##00000000)) -#define MM_PAGE_COUNTS (KERNEL_BASE|(0xE000##00000000)) -#define MM_PAGE_BITMAP (KERNEL_BASE|(0xE400##00000000)) -#define MM_PAGE_DBLBMP (KERNEL_BASE|(0xE480##00000000)) -#define MM_PAGE_SUPBMP (KERNEL_BASE|(0xE500##00000000)) +#define MM_PAGE_COUNTS (MM_KERNEL_RANGE|(0xE000##00000000)) +#define MM_PAGE_BITMAP (MM_KERNEL_RANGE|(0xE400##00000000)) +#define MM_PAGE_DBLBMP (MM_KERNEL_RANGE|(0xE480##00000000)) +#define MM_PAGE_SUPBMP (MM_KERNEL_RANGE|(0xE500##00000000)) -#define MM_LOCALAPIC (KERNEL_BASE|(0xFD00##00000000)) -#define MM_FRACTAL_BASE (KERNEL_BASE|(0xFE00##00000000)) -#define MM_TMPFRAC_BASE (KERNEL_BASE|(0xFE80##00000000)) +#define MM_LOCALAPIC (MM_KERNEL_RANGE|(0xFD00##00000000)) +#define MM_FRACTAL_BASE (MM_KERNEL_RANGE|(0xFE00##00000000)) +#define MM_TMPFRAC_BASE (MM_KERNEL_RANGE|(0xFE80##00000000)) // === FUNCTIONS === diff --git a/Kernel/arch/x86_64/mm_virt.c b/Kernel/arch/x86_64/mm_virt.c index 538f6ca9..bc9e8f6f 100644 --- a/Kernel/arch/x86_64/mm_virt.c +++ b/Kernel/arch/x86_64/mm_virt.c @@ -47,6 +47,7 @@ void MM_DumpTables(tVAddr Start, tVAddr End); // === CODE === void MM_InitVirt(void) { + MM_DumpTables(0, -1L); } void MM_FinishVirtualInit(void) @@ -137,11 +138,12 @@ void MM_DumpTables(tVAddr Start, tVAddr End) tVAddr curPos; Uint page; + Log("Table Entries: (%p to %p)", Start, End); + End &= (1L << 48) - 1; Start >>= 12; End >>= 12; - Log("Table Entries:"); for(page = Start, curPos = Start<<12; page < End; curPos += 0x1000, page++) @@ -149,6 +151,11 @@ void MM_DumpTables(tVAddr Start, tVAddr End) if( curPos == 0x800000000000L ) curPos = 0xFFFF800000000000L; + //Debug("&PAGEMAPLVL4(%i page>>27) = %p", page>>27, &PAGEMAPLVL4(page>>27)); + //Debug("&PAGEDIRPTR(%i page>>18) = %p", page>>18, &PAGEDIRPTR(page>>18)); + //Debug("&PAGEDIR(%i page>>9) = %p", page>>9, &PAGEDIR(page>>9)); + //Debug("&PAGETABLE(%i page) = %p", page, &PAGETABLE(page)); + // End of a range if( !(PAGEMAPLVL4(page>>27) & PF_PRESENT) @@ -172,16 +179,19 @@ void MM_DumpTables(tVAddr Start, tVAddr End) if( !(PAGEMAPLVL4(page>>27) & PF_PRESENT) ) { page += (1 << 27) - 1; curPos += (1L << 39) - 0x1000; + //Debug("pml4 ent unset (page = 0x%x now)", page); continue; } if( !(PAGEDIRPTR(page>>18) & PF_PRESENT) ) { page += (1 << 18) - 1; curPos += (1L << 30) - 0x1000; + //Debug("pdp ent unset (page = 0x%x now)", page); continue; } if( !(PAGEDIR(page>>9) & PF_PRESENT) ) { page += (1 << 9) - 1; curPos += (1L << 21) - 0x1000; + //Debug("pd ent unset (page = 0x%x now)", page); continue; } if( !(PAGETABLE(page) & PF_PRESENT) ) continue; diff --git a/Kernel/arch/x86_64/start32.asm b/Kernel/arch/x86_64/start32.asm index 0178bddb..7154ad89 100644 --- a/Kernel/arch/x86_64/start32.asm +++ b/Kernel/arch/x86_64/start32.asm @@ -113,7 +113,7 @@ gMultibootPtr: [global gInitialPML4] gInitialPML4: ; Covers 256 TiB (Full 48-bit Virtual Address Space) dd gInitialPDP - KERNEL_BASE + 3, 0 ; Identity Map Low 4Mb - times 512-1-4 dq 0 + times 512-4-1 dq 0 dd gInitialPML4 - KERNEL_BASE + 3, 0 ; Fractal Mapping dq 0 dq 0 @@ -125,7 +125,8 @@ gInitialPDP: ; Covers 512 GiB gHighPDP: ; Covers 512 GiB times 510 dq 0 - dq 0 + 0x143 ; 1 GiB Page from zero + ;dq 0 + 0x143 ; 1 GiB Page from zero + dd gInitialPD - KERNEL_BASE + 3, 0 dq 0 gInitialPD: ; Covers 1 GiB