diff --git a/arch/x86_64/src/common/x86_64_addrenv.c b/arch/x86_64/src/common/x86_64_addrenv.c index b8396b84bc0..1473987b37b 100644 --- a/arch/x86_64/src/common/x86_64_addrenv.c +++ b/arch/x86_64/src/common/x86_64_addrenv.c @@ -70,6 +70,8 @@ #include +#include + #include "addrenv.h" #include "pgalloc.h" #include "x86_64_mmu.h" @@ -192,10 +194,18 @@ static int create_spgtables(arch_addrenv_t *addrenv) static void copy_kernel_mappings(arch_addrenv_t *addrenv) { uintptr_t *pdpt = (uintptr_t *)x86_64_pgvaddr(addrenv->spgtables[1]); + int i; /* Kernel mapping - lower 1GB maps to 4GB-5GB */ pdpt[4] = X86_PDPT_KERNEL_MAP; + + /* Inherit the boot identity mapping of the low 4GB. */ + + for (i = 0; i < X86_MMU_LOWMEM_PDPTS; i++) + { + pdpt[i] = g_pdpt[i]; + } } /**************************************************************************** diff --git a/arch/x86_64/src/common/x86_64_mmu.h b/arch/x86_64/src/common/x86_64_mmu.h index e029075a194..634a60d1b97 100644 --- a/arch/x86_64/src/common/x86_64_mmu.h +++ b/arch/x86_64/src/common/x86_64_mmu.h @@ -57,6 +57,10 @@ #define X86_MMU_VADDR_INDEX(vaddr, ptlevel) \ ((vaddr >> X86_MMU_VADDR_SHIFT(ptlevel)) & X86_MMU_VPN_MASK) +/* Number of PDPT entries in the boot low-memory identity mapping. */ + +#define X86_MMU_LOWMEM_PDPTS 4 + /**************************************************************************** * Public Function Prototypes ****************************************************************************/