diff --git a/kernel/base/vm/los_vm_page.c b/kernel/base/vm/los_vm_page.c index b612b5c2a2b40c2ef06599df210f7291729e4d10..9f2efd624c8065c83048f21d10fc4b9a4882f6b4 100755 --- a/kernel/base/vm/los_vm_page.c +++ b/kernel/base/vm/los_vm_page.c @@ -76,7 +76,12 @@ VOID OsVmPageStartup(VOID) OsVmPhysAreaSizeAdjust(ROUNDUP((g_vmBootMemBase - KERNEL_ASPACE_BASE), PAGE_SIZE)); - nPage = OsVmPhysPageNumGet(); + /* + * Pages getting from OsVmPhysPageNumGet() interface here contain the memory + * struct LosVmPage occupied, which satisfies the equation: + * nPage * sizeof(LosVmPage) + nPage * PAGE_SIZE = OsVmPhysPageNumGet() * PAGE_SIZE. + */ + nPage = OsVmPhysPageNumGet() * PAGE_SIZE / (sizeof(LosVmPage) + PAGE_SIZE); g_vmPageArraySize = nPage * sizeof(LosVmPage); g_vmPageArray = (LosVmPage *)OsVmBootMemAlloc(g_vmPageArraySize); diff --git a/kernel/base/vm/los_vm_phys.c b/kernel/base/vm/los_vm_phys.c index afb70520588e6736500411f20ec1898747735858..bc2c8491477c9958319aef2e1a8691742efb937a 100755 --- a/kernel/base/vm/los_vm_phys.c +++ b/kernel/base/vm/los_vm_phys.c @@ -108,12 +108,12 @@ VOID OsVmPhysSegAdd(VOID) VOID OsVmPhysAreaSizeAdjust(size_t size) { - INT32 i; - - for (i = 0; i < (sizeof(g_physArea) / sizeof(g_physArea[0])); i++) { - g_physArea[i].start += size; - g_physArea[i].size -= size; - } + /* + * The first physics memory segment is used for kernel image and kernel heap, + * so just need to adjust the first one here. + */ + g_physArea[0].start += size; + g_physArea[0].size -= size; } UINT32 OsVmPhysPageNumGet(VOID)