From: Anshul Dalal <anshuld@ti.com>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Anshul Dalal <anshuld@ti.com>
Cc: <u-boot@lists.denx.de>, <d-gole@ti.com>, <b-padhi@ti.com>,
<vigneshr@ti.com>, <trini@konsulko.com>, <nm@ti.com>,
<robertcnelson@gmail.com>, <w.egorov@phytec.de>,
<francesco.dolcini@toradex.com>, <ggiordano@phytec.com>,
<m-chawdhry@ti.com>, <afd@ti.com>, <bb@ti.com>, <u-kumar1@ti.com>,
<devarsht@ti.com>, <xypron.glpk@gmx.de>
Subject: Re: [PATCH v10 07/11] arm: armv8: mmu: add mmu_unmap_reserved_mem
Date: Fri, 17 Oct 2025 18:20:21 +0530 [thread overview]
Message-ID: <DDKLZC5V72FZ.2GAUEUKTYIS8N@ti.com> (raw)
In-Reply-To: <CAC_iWjJSdG6Z-6HtKt3VaJPT8A4HZO3UxbfmuFJ4RCY7jvJPvg@mail.gmail.com>
On Fri Oct 17, 2025 at 6:04 PM IST, Ilias Apalodimas wrote:
> Hi Anshul,
>
> On Fri, 10 Oct 2025 at 16:44, Anshul Dalal <anshuld@ti.com> wrote:
>>
>> For armv8, U-Boot uses a static map defined as 'mem_map' for configuring
>> the MMU's page tables, done by mmu_setup.
>>
>> Though this works well for simpler platforms, it makes creating runtime
>> carveouts by modifying the static array at runtime exceedingly complex
>> like in mach-snapdragon/board.c.
>>
>> Creation of such carveouts are much better handled by APIs such as
>> mmu_change_region_attr once the page tables are configured. Usually such
>> carveouts are configured via the device-tree's reserved-memory node
>> which provides the address and size for the carveout.
>>
>> Therefore this patch adds mmu_unmap_reserved_mem which acts as a wrapper
>> over mmu_change_region_attr, helping unmap a reserved-memory region.
>>
>> Signed-off-by: Anshul Dalal <anshuld@ti.com>
>> Tested-by: Wadim Egorov <w.egorov@phytec.de>
>> ---
>> arch/arm/cpu/armv8/cache_v8.c | 26 ++++++++++++++++++++++++++
>> arch/arm/include/asm/armv8/mmu.h | 8 ++++++++
>> 2 files changed, 34 insertions(+)
>>
>> diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
>> index 9b3c37dae82..f2e006a98ab 100644
>> --- a/arch/arm/cpu/armv8/cache_v8.c
>> +++ b/arch/arm/cpu/armv8/cache_v8.c
>> @@ -86,6 +86,32 @@ int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs)
>>
>> return 0;
>> }
>> +
>> +int mmu_unmap_reserved_mem(const char *name)
>> +{
>> + void *fdt = (void *)gd->fdt_blob;
>> + char node_path[128];
>> + fdt_addr_t addr;
>> + fdt_size_t size;
>> + int ret;
>> +
>> + snprintf(node_path, sizeof(node_path), "/reserved-memory/%s", name);
>> + ret = fdt_path_offset(fdt, node_path);
>> + if (ret < 0)
>> + return ret;
>> +
>> + if (!fdtdec_get_bool(fdt, ret, "no-map"))
>> + return -EINVAL;
>> +
>
> Apologies I wasn't clear on my last mail. Can we do this check
> conditional please? IOW add a "check_nomap" in the function args
Will add that in the next revision, thanks for the review!
Anshul
>
>> + addr = fdtdec_get_addr_size(fdt, ret, "reg", &size);
>> + if (addr == FDT_ADDR_T_NONE)
>> + return -1;
>> +
>> + mmu_change_region_attr_nobreak(addr, size, PTE_TYPE_FAULT);
>> +
>> + return 0;
>> +}
>> +
>> u64 get_tcr(u64 *pips, u64 *pva_bits)
>> {
>> int el = get_effective_el();
>> diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
>> index 6e7a3366844..ca402c7d74c 100644
>> --- a/arch/arm/include/asm/armv8/mmu.h
>> +++ b/arch/arm/include/asm/armv8/mmu.h
>> @@ -207,6 +207,14 @@ void setup_pgtables(void);
>> */
>> int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs);
>>
>> +/**
>> + * mmu_unmap_reserved_mem() - Unmaps a reserved-memory node as PTE_TYPE_FAULT
>> + * once MMU is configured by mmu_setup.
>> + *
>> + * @name: The name of the node under "/reserved-memory/" path
>> + */
>> +int mmu_unmap_reserved_mem(const char *name);
>> +
>> u64 get_tcr(u64 *pips, u64 *pva_bits);
>>
>> /**
>> --
>> 2.51.0
>>
>
> Other than that
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
next prev parent reply other threads:[~2025-10-17 12:50 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 13:44 [PATCH v10 00/11] Add support for dynamic MMU configuration Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 01/11] mach-k3: use minimal memory map for all K3 Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 02/11] mach-k3: use custom enable_cache Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 03/11] arm: armv8: mmu: export mmu_setup Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 04/11] arm: armv8: invalidate dcache entries on dcache_enable Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 05/11] arm: armv8: mmu: add mem_map_from_dram_banks Anshul Dalal
2025-10-17 12:09 ` Ilias Apalodimas
2025-10-17 12:47 ` Anshul Dalal
2025-10-17 13:00 ` Ilias Apalodimas
2025-10-10 13:44 ` [PATCH v10 06/11] mach-k3: map all banks using mem_map_from_dram_banks Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 07/11] arm: armv8: mmu: add mmu_unmap_reserved_mem Anshul Dalal
2025-10-17 12:34 ` Ilias Apalodimas
2025-10-17 12:50 ` Anshul Dalal [this message]
2025-10-10 13:44 ` [PATCH v10 08/11] spl: split spl_board_fixups to arch/board specific Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 09/11] mach-k3: add reserved memory fixups for next boot stage Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 10/11] mach-k3: add carveouts for TFA and optee Anshul Dalal
2025-10-10 13:44 ` [PATCH v10 11/11] arm: mach-k3: reserve space for page table entries Anshul Dalal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DDKLZC5V72FZ.2GAUEUKTYIS8N@ti.com \
--to=anshuld@ti.com \
--cc=afd@ti.com \
--cc=b-padhi@ti.com \
--cc=bb@ti.com \
--cc=d-gole@ti.com \
--cc=devarsht@ti.com \
--cc=francesco.dolcini@toradex.com \
--cc=ggiordano@phytec.com \
--cc=ilias.apalodimas@linaro.org \
--cc=m-chawdhry@ti.com \
--cc=nm@ti.com \
--cc=robertcnelson@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=u-kumar1@ti.com \
--cc=vigneshr@ti.com \
--cc=w.egorov@phytec.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox