2023-09-20 03:57:43

by Yu-Chien Peter Lin

[permalink] [raw]
Subject: [PATCH v3 2/3] riscv: Introduce PBMT field to PTDUMP

This patch introduces the PBMT field to the PTDUMP, so it can
display the memory attributes for NC or IO.

Signed-off-by: Yu Chien Peter Lin <[email protected]>
---
Changes v1 -> v2
- no change
Changes v2 -> v3
- Add ".." when PBMT field is clear
---
arch/riscv/mm/ptdump.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c
index 57a0926c6627..13997cf3fe36 100644
--- a/arch/riscv/mm/ptdump.c
+++ b/arch/riscv/mm/ptdump.c
@@ -135,6 +135,12 @@ struct prot_bits {

static const struct prot_bits pte_bits[] = {
{
+#ifdef CONFIG_64BIT
+ .mask = _PAGE_MTMASK_SVPBMT,
+ .set = "MT(%s)",
+ .clear = " .. ",
+ }, {
+#endif
.mask = _PAGE_SOFT,
.set = "RSW(%d)",
.clear = " .. ",
@@ -205,6 +211,16 @@ static void dump_prot(struct pg_state *st)
if (val) {
if (pte_bits[i].mask == _PAGE_SOFT)
sprintf(s, pte_bits[i].set, val >> 8);
+#ifdef CONFIG_64BIT
+ else if (pte_bits[i].mask == _PAGE_MTMASK_SVPBMT) {
+ if (val == _PAGE_NOCACHE_SVPBMT)
+ sprintf(s, pte_bits[i].set, "NC");
+ else if (val == _PAGE_IO_SVPBMT)
+ sprintf(s, pte_bits[i].set, "IO");
+ else
+ sprintf(s, pte_bits[i].set, "??");
+ }
+#endif
else
sprintf(s, "%s", pte_bits[i].set);
} else {
--
2.34.1


2023-09-20 09:21:55

by Alexandre Ghiti

[permalink] [raw]
Subject: Re: [PATCH v3 2/3] riscv: Introduce PBMT field to PTDUMP


On 20/09/2023 05:55, Yu Chien Peter Lin wrote:
> This patch introduces the PBMT field to the PTDUMP, so it can
> display the memory attributes for NC or IO.
>
> Signed-off-by: Yu Chien Peter Lin <[email protected]>
> ---
> Changes v1 -> v2
> - no change
> Changes v2 -> v3
> - Add ".." when PBMT field is clear
> ---
> arch/riscv/mm/ptdump.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c
> index 57a0926c6627..13997cf3fe36 100644
> --- a/arch/riscv/mm/ptdump.c
> +++ b/arch/riscv/mm/ptdump.c
> @@ -135,6 +135,12 @@ struct prot_bits {
>
> static const struct prot_bits pte_bits[] = {
> {
> +#ifdef CONFIG_64BIT
> + .mask = _PAGE_MTMASK_SVPBMT,
> + .set = "MT(%s)",
> + .clear = " .. ",
> + }, {
> +#endif
> .mask = _PAGE_SOFT,
> .set = "RSW(%d)",
> .clear = " .. ",
> @@ -205,6 +211,16 @@ static void dump_prot(struct pg_state *st)
> if (val) {
> if (pte_bits[i].mask == _PAGE_SOFT)
> sprintf(s, pte_bits[i].set, val >> 8);
> +#ifdef CONFIG_64BIT
> + else if (pte_bits[i].mask == _PAGE_MTMASK_SVPBMT) {
> + if (val == _PAGE_NOCACHE_SVPBMT)
> + sprintf(s, pte_bits[i].set, "NC");
> + else if (val == _PAGE_IO_SVPBMT)
> + sprintf(s, pte_bits[i].set, "IO");
> + else
> + sprintf(s, pte_bits[i].set, "??");
> + }
> +#endif
> else
> sprintf(s, "%s", pte_bits[i].set);
> } else {


You can add:

Reviewed-by: Alexandre Ghiti <[email protected]>

Tested-by: Alexandre Ghiti <[email protected]>

Thanks!

Alex