arch/risc-v: fix RV32 up_addrenv_destroy

This patch fixes the issue/12122 for RV32, where the scanning should be
limited to user space only.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
This commit is contained in:
Yanfeng Liu 2024-04-13 08:09:10 +08:00 committed by Xiang Xiao
parent 6d7355b929
commit 200424e59d

View File

@ -539,7 +539,10 @@ int up_addrenv_destroy(arch_addrenv_t *addrenv)
ptprev = (uintptr_t *)riscv_pgvaddr(addrenv->spgtables[ARCH_SPGTS - 1]);
if (ptprev)
{
for (i = 0; i < ENTRIES_PER_PGT; i++, vaddr += pgsize)
/* walk user space only */
i = (ARCH_SPGTS < 2) ? vaddr / pgsize : 0;
for (; i < ENTRIES_PER_PGT; i++, vaddr += pgsize)
{
ptlast = (uintptr_t *)riscv_pgvaddr(mmu_pte_to_paddr(ptprev[i]));
if (ptlast)