From f62115dfefa1bac15edfd478382427e7fb0747c9 Mon Sep 17 00:00:00 2001 From: Harylee Date: Mon, 28 Sep 2020 16:32:18 +0800 Subject: [PATCH] Fix mmap --- kernel/base/include/los_vm_map.h | 1 - kernel/base/vm/los_vm_map.c | 6 +++--- kernel/extended/dynload/src/los_load_elf.c | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/base/include/los_vm_map.h b/kernel/base/include/los_vm_map.h index 3ebd7570..da099c69 100755 --- a/kernel/base/include/los_vm_map.h +++ b/kernel/base/include/los_vm_map.h @@ -240,7 +240,6 @@ STATIC INLINE BOOL LOS_IsUserAddressRange(VADDR_T vaddr, size_t len) return (vaddr + len > vaddr) && LOS_IsUserAddress(vaddr) && (LOS_IsUserAddress(vaddr + len - 1)); } - STATIC INLINE BOOL LOS_IsVmallocAddress(VADDR_T vaddr) { return ((vaddr >= VMALLOC_START) && diff --git a/kernel/base/vm/los_vm_map.c b/kernel/base/vm/los_vm_map.c index 244bf877..c4271ab0 100755 --- a/kernel/base/vm/los_vm_map.c +++ b/kernel/base/vm/los_vm_map.c @@ -365,7 +365,7 @@ VADDR_T OsAllocRange(LosVmSpace *vmSpace, size_t len) if (nextStart < curEnd) { continue; } - if ((nextStart - curEnd) >= len) { + if ((curEnd + len) <= nextStart) { return curEnd; } else { curEnd = curRegion->range.base + curRegion->range.size; @@ -379,7 +379,7 @@ VADDR_T OsAllocRange(LosVmSpace *vmSpace, size_t len) if (nextStart < curEnd) { continue; } - if ((nextStart - curEnd) >= len) { + if ((curEnd + len) <= nextStart) { return curEnd; } else { curEnd = curRegion->range.base + curRegion->range.size; @@ -388,7 +388,7 @@ VADDR_T OsAllocRange(LosVmSpace *vmSpace, size_t len) } nextStart = vmSpace->mapBase + vmSpace->mapSize; - if ((nextStart - curEnd) >= len) { + if ((curEnd + len) <= nextStart) { return curEnd; } diff --git a/kernel/extended/dynload/src/los_load_elf.c b/kernel/extended/dynload/src/los_load_elf.c index 2d02b04a..8602d73a 100755 --- a/kernel/extended/dynload/src/los_load_elf.c +++ b/kernel/extended/dynload/src/los_load_elf.c @@ -983,6 +983,7 @@ STATIC VOID OsFlushAspace(ELFLoadInfo *loadInfo) processCB->vmSpace->heapBase += OsGetRndOffset(loadInfo); processCB->vmSpace->heapNow = processCB->vmSpace->heapBase; processCB->vmSpace->mapBase += OsGetRndOffset(loadInfo); + processCB->vmSpace->mapSize = loadInfo->stackBase - processCB->vmSpace->mapBase; LOS_ArchMmuContextSwitch(&OsCurrProcessGet()->vmSpace->archMmu); }