All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled
@ 2022-04-14 15:55 Niklas Cassel via
  2022-04-15  3:44 ` Bin Meng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Niklas Cassel via @ 2022-04-14 15:55 UTC (permalink / raw)
  To: Palmer Dabbelt, Alistair Francis, Bin Meng
  Cc: qemu-riscv, qemu-devel, Niklas Cassel

The device tree property "mmu-type" is currently exported as either
"riscv,sv32" or "riscv,sv48".

However, the riscv cpu device tree binding [1] has a specific value
"riscv,none" for a HART without a MMU.

Set the device tree property "mmu-type" to "riscv,none" when the CPU mmu
option is disabled using rv32,mmu=off or rv64,mmu=off.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/riscv/cpus.yaml?h=v5.17

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 hw/riscv/virt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index da50cbed43..3be6be9ad3 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -230,8 +230,14 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
         cpu_name = g_strdup_printf("/cpus/cpu@%d",
             s->soc[socket].hartid_base + cpu);
         qemu_fdt_add_subnode(mc->fdt, cpu_name);
-        qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
-            (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
+        if (riscv_feature(&s->soc[socket].harts[cpu].env,
+                          RISCV_FEATURE_MMU)) {
+            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
+                                    (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
+        } else {
+            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
+                                    "riscv,none");
+        }
         name = riscv_isa_string(&s->soc[socket].harts[cpu]);
         qemu_fdt_setprop_string(mc->fdt, cpu_name, "riscv,isa", name);
         g_free(name);
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled
  2022-04-14 15:55 [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled Niklas Cassel via
@ 2022-04-15  3:44 ` Bin Meng
  2022-04-15  5:27 ` Frank Chang
  2022-04-19  2:12 ` Alistair Francis
  2 siblings, 0 replies; 4+ messages in thread
From: Bin Meng @ 2022-04-15  3:44 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Alistair Francis, Bin Meng, Palmer Dabbelt, open list:RISC-V,
	qemu-devel@nongnu.org Developers

On Thu, Apr 14, 2022 at 11:55 PM Niklas Cassel via
<qemu-devel@nongnu.org> wrote:
>
> The device tree property "mmu-type" is currently exported as either
> "riscv,sv32" or "riscv,sv48".
>
> However, the riscv cpu device tree binding [1] has a specific value
> "riscv,none" for a HART without a MMU.
>
> Set the device tree property "mmu-type" to "riscv,none" when the CPU mmu
> option is disabled using rv32,mmu=off or rv64,mmu=off.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/riscv/cpus.yaml?h=v5.17
>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
>  hw/riscv/virt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled
  2022-04-14 15:55 [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled Niklas Cassel via
  2022-04-15  3:44 ` Bin Meng
@ 2022-04-15  5:27 ` Frank Chang
  2022-04-19  2:12 ` Alistair Francis
  2 siblings, 0 replies; 4+ messages in thread
From: Frank Chang @ 2022-04-15  5:27 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Alistair Francis, Bin Meng, Palmer Dabbelt, open list:RISC-V,
	qemu-devel@nongnu.org Developers

[-- Attachment #1: Type: text/plain, Size: 1887 bytes --]

On Thu, Apr 14, 2022 at 11:57 PM Niklas Cassel via <qemu-devel@nongnu.org>
wrote:

> The device tree property "mmu-type" is currently exported as either
> "riscv,sv32" or "riscv,sv48".
>
> However, the riscv cpu device tree binding [1] has a specific value
> "riscv,none" for a HART without a MMU.
>
> Set the device tree property "mmu-type" to "riscv,none" when the CPU mmu
> option is disabled using rv32,mmu=off or rv64,mmu=off.
>
> [1]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/riscv/cpus.yaml?h=v5.17
>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
> ---
>  hw/riscv/virt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index da50cbed43..3be6be9ad3 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -230,8 +230,14 @@ static void create_fdt_socket_cpus(RISCVVirtState *s,
> int socket,
>          cpu_name = g_strdup_printf("/cpus/cpu@%d",
>              s->soc[socket].hartid_base + cpu);
>          qemu_fdt_add_subnode(mc->fdt, cpu_name);
> -        qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> -            (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
> +        if (riscv_feature(&s->soc[socket].harts[cpu].env,
> +                          RISCV_FEATURE_MMU)) {
> +            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> +                                    (is_32_bit) ? "riscv,sv32" :
> "riscv,sv48");
> +        } else {
> +            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> +                                    "riscv,none");
> +        }
>          name = riscv_isa_string(&s->soc[socket].harts[cpu]);
>          qemu_fdt_setprop_string(mc->fdt, cpu_name, "riscv,isa", name);
>          g_free(name);
> --
> 2.35.1
>
>
>
Reviewed-by: Frank Chang <frank.chang@sifive.com>

[-- Attachment #2: Type: text/html, Size: 2936 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled
  2022-04-14 15:55 [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled Niklas Cassel via
  2022-04-15  3:44 ` Bin Meng
  2022-04-15  5:27 ` Frank Chang
@ 2022-04-19  2:12 ` Alistair Francis
  2 siblings, 0 replies; 4+ messages in thread
From: Alistair Francis @ 2022-04-19  2:12 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Alistair Francis, Bin Meng, Palmer Dabbelt, open list:RISC-V,
	qemu-devel@nongnu.org Developers

On Fri, Apr 15, 2022 at 1:56 AM Niklas Cassel via <qemu-devel@nongnu.org> wrote:
>
> The device tree property "mmu-type" is currently exported as either
> "riscv,sv32" or "riscv,sv48".
>
> However, the riscv cpu device tree binding [1] has a specific value
> "riscv,none" for a HART without a MMU.
>
> Set the device tree property "mmu-type" to "riscv,none" when the CPU mmu
> option is disabled using rv32,mmu=off or rv64,mmu=off.
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/riscv/cpus.yaml?h=v5.17
>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/riscv/virt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index da50cbed43..3be6be9ad3 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -230,8 +230,14 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
>          cpu_name = g_strdup_printf("/cpus/cpu@%d",
>              s->soc[socket].hartid_base + cpu);
>          qemu_fdt_add_subnode(mc->fdt, cpu_name);
> -        qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> -            (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
> +        if (riscv_feature(&s->soc[socket].harts[cpu].env,
> +                          RISCV_FEATURE_MMU)) {
> +            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> +                                    (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
> +        } else {
> +            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
> +                                    "riscv,none");
> +        }
>          name = riscv_isa_string(&s->soc[socket].harts[cpu]);
>          qemu_fdt_setprop_string(mc->fdt, cpu_name, "riscv,isa", name);
>          g_free(name);
> --
> 2.35.1
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-19  2:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 15:55 [PATCH] hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled Niklas Cassel via
2022-04-15  3:44 ` Bin Meng
2022-04-15  5:27 ` Frank Chang
2022-04-19  2:12 ` Alistair Francis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.