arch: x86_64: revoke lower 128MB mapping later, ldmxcsr require 32-bit address

This commit is contained in:
Yang Chung-Fan 2020-05-05 15:28:12 +09:00 committed by Brennan Ashton
parent 370eb169fd
commit 2936f72651
3 changed files with 30 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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();