From e2f0f431d96f16085d253c53cad585632af3e5bf Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 30 Aug 2022 20:54:16 +0900 Subject: [PATCH] arch: risc-v: Assign dedicated virtual addresses for text and heap Summary: - Current RISC-V/NuttX implementation assumes that text/data/heap areas are continuous. In fact, CONFIG_ARCH_TEXT_VBASE and CONFIG_ARCH_HEAP_VBASE are not used for memory allocation. - This commit assigns dedicated virtual addresses for text and heap which are the same approach to ARM-v7A/NuttX implementation. Impact: - None Testing: - Tested with rv-virt:knsh64 (will be updated later) Signed-off-by: Masayuki Ishikawa --- arch/risc-v/src/common/riscv_addrenv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/risc-v/src/common/riscv_addrenv.c b/arch/risc-v/src/common/riscv_addrenv.c index df981d1660b..7d3fc951ef8 100644 --- a/arch/risc-v/src/common/riscv_addrenv.c +++ b/arch/risc-v/src/common/riscv_addrenv.c @@ -377,11 +377,19 @@ int up_addrenv_create(size_t textsize, size_t datasize, size_t heapsize, /* Calculate the base addresses for convenience */ +#if (CONFIG_ARCH_TEXT_VBASE != 0x0) && (CONFIG_ARCH_HEAP_VBASE != 0x0) + resvbase = CONFIG_ARCH_DATA_VBASE; + resvsize = ARCH_DATA_RESERVE_SIZE; + textbase = CONFIG_ARCH_TEXT_VBASE; + database = resvbase + MM_PGALIGNUP(resvsize); + heapbase = CONFIG_ARCH_HEAP_VBASE; +#else resvbase = ADDRENV_VBASE; resvsize = ARCH_DATA_RESERVE_SIZE; textbase = resvbase + MM_PGALIGNUP(resvsize); database = textbase + MM_PGALIGNUP(textsize); heapbase = database + MM_PGALIGNUP(datasize); +#endif /* Allocate 1 extra page for heap, temporary fix for #5811 */