From: John Hodge Date: Sat, 10 May 2014 02:39:02 +0000 (+0800) Subject: Kernel/x86_64 - Fix DumpTables handling edge of user range X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5613cdc027f43292c2ee156ff6102ce5af2a7ad2;p=tpg%2Facess2.git Kernel/x86_64 - Fix DumpTables handling edge of user range --- diff --git a/KernelLand/Kernel/arch/x86_64/mm_virt.c b/KernelLand/Kernel/arch/x86_64/mm_virt.c index 4e2968fd..3d89ea6e 100644 --- a/KernelLand/Kernel/arch/x86_64/mm_virt.c +++ b/KernelLand/Kernel/arch/x86_64/mm_virt.c @@ -301,8 +301,6 @@ void MM_DumpTables(tVAddr Start, tVAddr End) const tPAddr MASK = ~CHANGEABLE_BITS; // Physical address and access bits tVAddr rangeStart = 0; tPAddr expected = CHANGEABLE_BITS; // CHANGEABLE_BITS is used because it's not a vaild value - tVAddr curPos; - Uint page; tPAddr expected_pml4 = PF_WRITE|PF_USER; tPAddr expected_pdp = PF_WRITE|PF_USER; tPAddr expected_pd = PF_WRITE|PF_USER; @@ -311,11 +309,12 @@ void MM_DumpTables(tVAddr Start, tVAddr End) End &= (1L << 48) - 1; - Start >>= 12; End >>= 12; + Start >>= 12; + End >>= 12; - for(page = Start, curPos = Start<<12; - page < End; - curPos += 0x1000, page++) + // `page` will not overflow, End is 48-12 bits + tVAddr curPos = Start << 12; + for(Uint page = Start; page <= End; curPos += 0x1000, page++) { //Debug("&PAGEMAPLVL4(%i page>>27) = %p", page>>27, &PAGEMAPLVL4(page>>27)); //Debug("&PAGEDIRPTR(%i page>>18) = %p", page>>18, &PAGEDIRPTR(page>>18)); @@ -486,7 +485,7 @@ int MM_MapEx(volatile void *VAddr, tPAddr PAddr, BOOL bTemp, BOOL bLarge) *ent = PAddr | 3; - if( (tVAddr)VAddr < USER_MAX ) + if( (tVAddr)VAddr <= USER_MAX ) *ent |= PF_USER; INVLPG( VAddr );