From 15f19c32ac76f36f2178bf7253650ce1a414372b Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Thu, 1 Feb 2024 14:59:10 +0200 Subject: [PATCH] arch/addrenv: Add utility function to wipe one page up_addrenv_page_wipe can be used to wipe a single page of memory. --- arch/risc-v/src/common/riscv_addrenv_pgmap.c | 20 +++++++++++++++++++ include/nuttx/arch.h | 21 +++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/arch/risc-v/src/common/riscv_addrenv_pgmap.c b/arch/risc-v/src/common/riscv_addrenv_pgmap.c index da9e250e76..0d36c1adeb 100644 --- a/arch/risc-v/src/common/riscv_addrenv_pgmap.c +++ b/arch/risc-v/src/common/riscv_addrenv_pgmap.c @@ -147,6 +147,26 @@ bool up_addrenv_user_vaddr(uintptr_t vaddr) return riscv_uservaddr(vaddr); } +/**************************************************************************** + * Name: up_addrenv_page_wipe + * + * Description: + * Wipe a page of physical memory, first mapping it into kernel virtual + * memory. + * + * Input Parameters: + * page - The page physical address. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +void up_addrenv_page_wipe(uintptr_t page) +{ + riscv_pgwipe(page); +} + #ifdef CONFIG_MM_KMAP /**************************************************************************** diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 2aee23fc8c..785b113b94 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1378,7 +1378,7 @@ uintptr_t up_addrenv_page_vaddr(uintptr_t page); * vaddr - The virtual address. * * Returned Value: - * True if it is; false if it's not + * True if it is; false if it's not. * ****************************************************************************/ @@ -1386,6 +1386,25 @@ uintptr_t up_addrenv_page_vaddr(uintptr_t page); bool up_addrenv_user_vaddr(uintptr_t vaddr); #endif +/**************************************************************************** + * Name: up_addrenv_page_wipe + * + * Description: + * Wipe a page of physical memory, first mapping it into kernel virtual + * memory. + * + * Input Parameters: + * page - The page physical address. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_ARCH_ADDRENV +void up_addrenv_page_wipe(uintptr_t page); +#endif + /**************************************************************************** * Name: up_addrenv_kmap_init *