diff --git a/arch/x86_64/include/intel64/arch.h b/arch/x86_64/include/intel64/arch.h index ae097536635..65e204ddbed 100644 --- a/arch/x86_64/include/intel64/arch.h +++ b/arch/x86_64/include/intel64/arch.h @@ -581,6 +581,7 @@ int up_map_region(void *base, int size, int flags); void x86_64_check_and_enable_capability(void); extern void __enable_sse3(void); +extern void __revoke_low_memory(void); extern void __enable_pcid(void); #ifdef __cplusplus diff --git a/arch/x86_64/src/intel64/intel64_head.S b/arch/x86_64/src/intel64/intel64_head.S index 06d5934f038..d5642456d09 100644 --- a/arch/x86_64/src/intel64/intel64_head.S +++ b/arch/x86_64/src/intel64/intel64_head.S @@ -65,6 +65,7 @@ .global __nxstart .global __enable_sse3 .global __enable_pcid + .global __revoke_low_memory .global nx_start /* nx_start is defined elsewhere */ .global up_lowsetup /* up_lowsetup is defined elsewhere */ .global g_idle_topstack /* The end of the idle stack, the start of the heap */ @@ -133,7 +134,7 @@ start32: // Popluate the lower 4GB as non-present // for ecx = 0...512 * 4 : Loop and setup the page directories - mov $0x800, %ecx // 512 * 3 + mov $0x800, %ecx // 512 * 4 epd_loop: mov %esi, %edx or $(X86_PAGE_WR | X86_PAGE_PRESENT), %edx @@ -244,20 +245,7 @@ start64: .type __nxstart, @function __nxstart: - /* We are now in high memory, revoke the lower 128MB memory mapping */ - lea pd_low, %edi - mov $0, %eax - - // for ecx = 0...64 : Loop and setup 64x 2MB page directories - mov $64, %ecx -npd_loop: - mov %eax, 0(%edi) - add $(HUGE_PAGE_SIZE), %eax - add $(X86_PAGE_ENTRY_SIZE), %edi - - // end for ecx - dec %ecx - jnz npd_loop + /* We are now in high memory, will revoke the lower 128MB memory mapping in lowsetup*/ //clear out bss section movabs $_sbss, %rbx @@ -289,6 +277,29 @@ hang: jmp hang .size __nxstart, . - __nxstart + .type __revoke_low_memory, @function +__revoke_low_memory: + + /* Revoke the lower 128MB memory mapping */ + lea pd_low, %edi + lea pt_low, %esi + + // for ecx = 0...64 : Loop and setup 64x 2MB page directories + mov $64, %ecx +npd_loop: + mov %esi, %edx + or $(X86_PAGE_WR | X86_PAGE_PRESENT), %edx + mov %edx, 0(%edi) + add $(PAGE_SIZE), %esi + add $(X86_PAGE_ENTRY_SIZE), %edi + + // end for ecx + dec %ecx + jnz npd_loop + + ret + + .size __revoke_low_memory, . - __revoke_low_memory /**************************************************************************** * Name: __enable_sse3 diff --git a/arch/x86_64/src/intel64/intel64_lowsetup.c b/arch/x86_64/src/intel64/intel64_lowsetup.c index 39c965e5be2..7fa6f0545fa 100644 --- a/arch/x86_64/src/intel64/intel64_lowsetup.c +++ b/arch/x86_64/src/intel64/intel64_lowsetup.c @@ -94,6 +94,9 @@ void up_lowsetup(void) x86_64_check_and_enable_capability(); + /* Revoke the lower memory */ + __revoke_low_memory(); + /* perform board-specific initializations */ x86_64_boardinitialize();