diff --git a/boot/freeldr/freeldr/include/mm.h b/boot/freeldr/freeldr/include/mm.h index dd1bb195633..a3f34a55f78 100644 --- a/boot/freeldr/freeldr/include/mm.h +++ b/boot/freeldr/freeldr/include/mm.h @@ -51,7 +51,12 @@ typedef struct _FREELDR_MEMORY_DESCRIPTOR #define MM_PAGE_SIZE 4096 #define MM_PAGE_MASK 0xFFF #define MM_PAGE_SHIFT 12 -#define MM_MAX_PAGE 0xFFFFF +#if defined(_X86PAE_) +#define MM_MAX_PAGE 0x3FFFFFF /* 26 bits for the PFN */ +#else +#define MM_MAX_PAGE 0xFFFFF /* 20 bits for the PFN */ +#endif +#define MM_MAX_PAGE_LOADER 0xFFFFF /* 4 GB flat address range */ #define MM_SIZE_TO_PAGES(a) \ ( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) ) @@ -63,7 +68,8 @@ typedef struct _FREELDR_MEMORY_DESCRIPTOR #define MM_PAGE_SIZE 4096 #define MM_PAGE_MASK 0xFFF #define MM_PAGE_SHIFT 12 -#define MM_MAX_PAGE 0x3FFFF /* freeldr only maps 1 GB */ +#define MM_MAX_PAGE 0xFFFFFFFFF /* 36 bits for the PFN */ +#define MM_MAX_PAGE_LOADER 0x3FFFF /* on x64 freeldr only maps 1 GB */ #define MM_SIZE_TO_PAGES(a) \ ( ((a) >> MM_PAGE_SHIFT) + ((a) & MM_PAGE_MASK ? 1 : 0) ) diff --git a/boot/freeldr/freeldr/lib/mm/meminit.c b/boot/freeldr/freeldr/lib/mm/meminit.c index 8276cb8ca57..37a705a0c68 100644 --- a/boot/freeldr/freeldr/lib/mm/meminit.c +++ b/boot/freeldr/freeldr/lib/mm/meminit.c @@ -1,7 +1,7 @@ /* * FreeLoader * Copyright (C) 2006-2008 Aleksey Bragin - * Copyright (C) 2006-2009 Hervé Poussineau + * Copyright (C) 2006-2009 HervĂ© Poussineau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -438,7 +438,7 @@ PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount) if (MemoryDescriptor->BasePage < CandidateBasePage) continue; // Continue, if the address is too high - if (MemoryDescriptor->BasePage + RequiredPages >= MM_MAX_PAGE) continue; + if (MemoryDescriptor->BasePage + RequiredPages >= MM_MAX_PAGE_LOADER) continue; // Memory block is more suitable than the previous one CandidateBasePage = MemoryDescriptor->BasePage; @@ -447,7 +447,7 @@ PVOID MmFindLocationForPageLookupTable(PFN_NUMBER TotalPageCount) // Calculate the end address for the lookup table PageLookupTableEndPage = min(CandidateBasePage + CandidatePageCount, - MM_MAX_PAGE); + MM_MAX_PAGE_LOADER); // Calculate the virtual address PageLookupTableMemAddress = (PVOID)((PageLookupTableEndPage * PAGE_SIZE)