From 76bfb994a7bd990d7ecbd710e7becd3d8d9a1910 Mon Sep 17 00:00:00 2001 From: p-szafonimateusz Date: Tue, 20 Aug 2024 13:18:17 +0200 Subject: [PATCH] arch/x86_64/src/intel64: use legacy method to map memory <4GB the new mapping method may not work when we have to map memory at the early boot stage Signed-off-by: p-szafonimateusz --- arch/x86_64/src/intel64/intel64_map_region.c | 30 +++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/arch/x86_64/src/intel64/intel64_map_region.c b/arch/x86_64/src/intel64/intel64_map_region.c index 40f35622d65..9bf93cb1870 100644 --- a/arch/x86_64/src/intel64/intel64_map_region.c +++ b/arch/x86_64/src/intel64/intel64_map_region.c @@ -33,19 +33,19 @@ #include "pgalloc.h" /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /**************************************************************************** - * Name: up_map_region + * Name: up_map_region_higmem * * Description: - * Map a memory region as 1:1 by MMU + * Map a memory region as 1:1 by MMU for high memory region (>4Gb) * ****************************************************************************/ #ifdef CONFIG_MM_PGALLOC -int up_map_region(void *base, size_t size, int flags) +static int up_map_region_highmem(void *base, size_t size, int flags) { uintptr_t bb; int ptlevel; @@ -113,7 +113,20 @@ int up_map_region(void *base, size_t size, int flags) return 0; } -#else +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_map_region + * + * Description: + * Map a memory region as 1:1 by MMU + * + ****************************************************************************/ + int up_map_region(void *base, size_t size, int flags) { uint64_t bb; @@ -133,9 +146,13 @@ int up_map_region(void *base, size_t size, int flags) if (bb > 0xffffffff) { - /* More than 4GB can't be mapped with this implementtion */ +#ifdef CONFIG_MM_PGALLOC + return up_map_region_highmem(base, size, flags); +#else + /* More than 4GB can't be mapped without CONFIG_MM_PGALLOC */ PANIC(); +#endif } curr = bb; @@ -149,4 +166,3 @@ int up_map_region(void *base, size_t size, int flags) return 0; } -#endif