From: Jerome Forissier <jerome.forissier@linaro.org>
To: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
xypron.glpk@gmx.de, trini@konsulko.com
Cc: "Alexey Brodkin" <alexey.brodkin@synopsys.com>,
"Eugeniy Paltsev" <Eugeniy.Paltsev@synopsys.com>,
"Caleb Connolly" <caleb.connolly@linaro.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Sumit Garg" <sumit.garg@linaro.org>,
"Huan Wang" <alison.wang@nxp.com>,
"Angelo Dureghello" <angelo@kernel-space.org>,
"Thomas Chou" <thomas@wytron.com.tw>,
"Rick Chen" <rick@andestech.com>, Leo <ycliang@andestech.com>,
"Marek Vasut" <marex@denx.de>,
"Nobuhiro Iwamatsu" <iwamatsu@nigauri.org>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Sughosh Ganu" <sughosh.ganu@linaro.org>,
"Simon Glass" <sjg@chromium.org>,
"Pierre-Clément Tosi" <ptosi@google.com>,
"Sam Protsenko" <semen.protsenko@linaro.org>,
"Peng Fan" <peng.fan@nxp.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Sam Edwards" <CFSworks@gmail.com>,
"Peter Hoyes" <Peter.Hoyes@arm.com>,
"Andre Przywara" <andre.przywara@arm.com>,
"Patrick Rudolph" <patrick.rudolph@9elements.com>,
"Sam Day" <me@samcday.com>,
"Mayuresh Chitale" <mchitale@ventanamicro.com>,
"Mattijs Korpershoek" <mkorpershoek@baylibre.com>,
"Stefan Roese" <sr@denx.de>,
"Jagan Teki" <jagan@amarulasolutions.com>,
"Alex Shumsky" <alexthreed@gmail.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Joshua Watt" <jpewhacker@gmail.com>,
"Evgeny Bachinin" <EABachinin@salutedevices.com>,
"Rasmus Villemoes" <rasmus.villemoes@prevas.dk>,
"Michal Simek" <michal.simek@amd.com>,
"Christian Marangi" <ansuelsmth@gmail.com>,
"Jonas Jelonek" <jelonek.jonas@gmail.com>,
uboot-snps-arc@synopsys.com, u-boot@lists.denx.de,
u-boot-qcom@groups.io
Subject: Re: [PATCH v1 1/6] meminfo: add memory details for armv8
Date: Wed, 5 Feb 2025 10:27:04 +0100 [thread overview]
Message-ID: <445a0c31-5a18-42e7-bb95-e380437d57f4@linaro.org> (raw)
In-Reply-To: <20250205071714.635518-2-ilias.apalodimas@linaro.org>
On 2/5/25 08:16, Ilias Apalodimas wrote:
> Upcoming patches are mapping memory with RO, RW^X etc permsissions.
> Fix the meminfo command to display them properly
>
> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
> arch/arm/cpu/armv8/cache_v8.c | 26 +++++++++++++++++++++++---
> arch/arm/include/asm/armv8/mmu.h | 2 ++
> cmd/meminfo.c | 5 +++++
> 3 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
> index 5d6953ffedd1..c4b3da4a8da7 100644
> --- a/arch/arm/cpu/armv8/cache_v8.c
> +++ b/arch/arm/cpu/armv8/cache_v8.c
> @@ -421,7 +421,7 @@ static int count_ranges(void)
> return count;
> }
>
> -#define ALL_ATTRS (3 << 8 | PMD_ATTRINDX_MASK)
> +#define ALL_ATTRS (3 << 8 | PMD_ATTRMASK)
> #define PTE_IS_TABLE(pte, level) (pte_type(&(pte)) == PTE_TYPE_TABLE && (level) < 3)
>
> enum walker_state {
> @@ -568,6 +568,20 @@ static void pretty_print_table_attrs(u64 pte)
> static void pretty_print_block_attrs(u64 pte)
> {
> u64 attrs = pte & PMD_ATTRINDX_MASK;
> + u64 perm_attrs = pte & PMD_ATTRMASK;
> + char mem_attrs[16] = { 0 };
11 is enough is seems?
> + int cnt = 0;
> +
> + if (perm_attrs & PTE_BLOCK_PXN)
> + cnt += snprintf(mem_attrs + cnt, sizeof(mem_attrs) - cnt, "PXN ");
> + if (perm_attrs & PTE_BLOCK_UXN)
> + cnt += snprintf(mem_attrs + cnt, sizeof(mem_attrs) - cnt, "UXN ");
> + if (perm_attrs & PTE_BLOCK_RO)
> + cnt += snprintf(mem_attrs + cnt, sizeof(mem_attrs) - cnt, "RO");
> + if (!mem_attrs[0])
> + snprintf(mem_attrs, sizeof(mem_attrs), "RWX ");
> +
> + printf(" | %-10s", mem_attrs);
>
> switch (attrs) {
> case PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE):
> @@ -613,6 +627,7 @@ static void print_pte(u64 pte, int level)
> {
> if (PTE_IS_TABLE(pte, level)) {
> printf(" %-5s", "Table");
> + printf(" %-12s", "|");
> pretty_print_table_attrs(pte);
> } else {
> pretty_print_pte_type(pte);
> @@ -642,9 +657,9 @@ static bool pagetable_print_entry(u64 start_attrs, u64 end, int va_bits, int lev
>
> printf("%*s", indent * 2, "");
> if (PTE_IS_TABLE(start_attrs, level))
> - printf("[%#011llx]%14s", _addr, "");
> + printf("[%#016llx]%19s", _addr, "");
> else
> - printf("[%#011llx - %#011llx]", _addr, end);
> + printf("[%#016llx - %#016llx]", _addr, end);
>
> printf("%*s | ", (3 - level) * 2, "");
> print_pte(start_attrs, level);
> @@ -1112,3 +1127,8 @@ void __weak enable_caches(void)
> icache_enable();
> dcache_enable();
> }
> +
> +void arch_dump_mem_attrs(void)
> +{
> + dump_pagetable(gd->arch.tlb_addr, get_tcr(NULL, NULL));
> +}
> diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
> index 0ab681c893d3..6af8cd111a44 100644
> --- a/arch/arm/include/asm/armv8/mmu.h
> +++ b/arch/arm/include/asm/armv8/mmu.h
> @@ -66,6 +66,7 @@
> #define PTE_BLOCK_NG (1 << 11)
> #define PTE_BLOCK_PXN (UL(1) << 53)
> #define PTE_BLOCK_UXN (UL(1) << 54)
> +#define PTE_BLOCK_RO (UL(1) << 7)
>
> /*
> * AttrIndx[2:0]
> @@ -75,6 +76,7 @@
> #define PMD_ATTRMASK (PTE_BLOCK_PXN | \
> PTE_BLOCK_UXN | \
> PMD_ATTRINDX_MASK | \
> + PTE_BLOCK_RO | \
> PTE_TYPE_VALID)
>
> /*
> diff --git a/cmd/meminfo.c b/cmd/meminfo.c
> index 5e83d61c2dd3..3915e2bbb268 100644
> --- a/cmd/meminfo.c
> +++ b/cmd/meminfo.c
> @@ -15,6 +15,10 @@
>
> DECLARE_GLOBAL_DATA_PTR;
>
> +void __weak arch_dump_mem_attrs(void)
> +{
> +}
> +
> static void print_region(const char *name, ulong base, ulong size, ulong *uptop)
> {
> ulong end = base + size;
> @@ -54,6 +58,7 @@ static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc,
>
> puts("DRAM: ");
> print_size(gd->ram_size, "\n");
> + arch_dump_mem_attrs();
>
> if (!IS_ENABLED(CONFIG_CMD_MEMINFO_MAP))
> return 0;
next prev parent reply other threads:[~2025-02-05 13:17 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 7:16 [PATCH v1 0/6] Fix page permission on arm64 architectures Ilias Apalodimas
2025-02-05 7:16 ` [PATCH v1 1/6] meminfo: add memory details for armv8 Ilias Apalodimas
2025-02-05 9:27 ` Jerome Forissier [this message]
2025-02-05 10:32 ` Ilias Apalodimas
2025-02-11 21:08 ` Caleb Connolly
2025-02-05 7:16 ` [PATCH v1 2/6] doc: update meminfo with arch specific information Ilias Apalodimas
2025-02-05 17:22 ` Tom Rini
2025-02-05 17:35 ` Ilias Apalodimas
2025-02-06 12:31 ` Simon Glass
2025-02-06 12:32 ` Ilias Apalodimas
2025-02-05 7:16 ` [PATCH v1 3/6] arm: Prepare linker scripts for memory permissions Ilias Apalodimas
2025-02-05 8:22 ` Ilias Apalodimas
2025-02-05 12:41 ` Michal Simek
2025-02-05 13:11 ` Ilias Apalodimas
2025-02-05 19:03 ` Tom Rini
2025-02-05 17:23 ` Richard Henderson
2025-02-05 17:34 ` Ilias Apalodimas
2025-02-05 17:33 ` Tom Rini
2025-02-05 19:18 ` Ilias Apalodimas
2025-02-05 19:25 ` Tom Rini
2025-02-05 21:35 ` Ilias Apalodimas
2025-02-05 7:16 ` [PATCH v1 4/6] arm64: mmu_change_region_attr() add an option not to break PTEs Ilias Apalodimas
2025-02-05 7:16 ` [PATCH v1 5/6] treewide: Add a function to change page permissions Ilias Apalodimas
2025-02-05 16:47 ` Heinrich Schuchardt
2025-02-05 16:54 ` Ilias Apalodimas
2025-02-06 9:42 ` Ilias Apalodimas
2025-02-06 10:38 ` Heinrich Schuchardt
2025-02-06 12:30 ` Simon Glass
2025-02-06 12:51 ` Ilias Apalodimas
2025-02-06 12:58 ` Simon Glass
2025-02-06 15:15 ` Ilias Apalodimas
2025-02-06 15:47 ` Simon Glass
2025-02-06 16:21 ` Ilias Apalodimas
2025-02-09 14:35 ` Simon Glass
2025-02-09 16:36 ` Tom Rini
2025-02-09 16:39 ` Tom Rini
2025-02-09 20:15 ` Simon Glass
2025-02-09 20:27 ` Heinrich Schuchardt
2025-02-20 9:22 ` Ilias Apalodimas
2025-02-09 16:37 ` Tom Rini
2025-02-05 7:16 ` [PATCH v1 6/6] arm64: Enable RW, RX and RO mappings for the relocated binary Ilias Apalodimas
2025-02-05 9:57 ` Jerome Forissier
2025-02-05 10:31 ` Ilias Apalodimas
2025-02-05 19:17 ` Tom Rini
2025-02-06 8:33 ` [PATCH v1 0/6] Fix page permission on arm64 architectures Neil Armstrong
2025-02-06 12:33 ` Simon Glass
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=445a0c31-5a18-42e7-bb95-e380437d57f4@linaro.org \
--to=jerome.forissier@linaro.org \
--cc=CFSworks@gmail.com \
--cc=EABachinin@salutedevices.com \
--cc=Eugeniy.Paltsev@synopsys.com \
--cc=Peter.Hoyes@arm.com \
--cc=alexey.brodkin@synopsys.com \
--cc=alexthreed@gmail.com \
--cc=alison.wang@nxp.com \
--cc=andre.przywara@arm.com \
--cc=angelo@kernel-space.org \
--cc=ansuelsmth@gmail.com \
--cc=caleb.connolly@linaro.org \
--cc=ilias.apalodimas@linaro.org \
--cc=iwamatsu@nigauri.org \
--cc=jagan@amarulasolutions.com \
--cc=jcmvbkbc@gmail.com \
--cc=jelonek.jonas@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=jpewhacker@gmail.com \
--cc=marex@denx.de \
--cc=mchitale@ventanamicro.com \
--cc=me@samcday.com \
--cc=michal.simek@amd.com \
--cc=mkorpershoek@baylibre.com \
--cc=neil.armstrong@linaro.org \
--cc=patrick.rudolph@9elements.com \
--cc=peng.fan@nxp.com \
--cc=ptosi@google.com \
--cc=rasmus.villemoes@prevas.dk \
--cc=richard.henderson@linaro.org \
--cc=rick@andestech.com \
--cc=semen.protsenko@linaro.org \
--cc=sjg@chromium.org \
--cc=sr@denx.de \
--cc=sughosh.ganu@linaro.org \
--cc=sumit.garg@linaro.org \
--cc=thomas@wytron.com.tw \
--cc=trini@konsulko.com \
--cc=u-boot-qcom@groups.io \
--cc=u-boot@lists.denx.de \
--cc=uboot-snps-arc@synopsys.com \
--cc=xypron.glpk@gmx.de \
--cc=ycliang@andestech.com \
/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