hw/riscv: virt: fix DT property mmu-type when CPU mmu option is disabled
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: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Frank Chang <frank.chang@sifive.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-Id: <20220414155510.1364147-1-niklas.cassel@wdc.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
		
							parent
							
								
									6248a8fe4d
								
							
						
					
					
						commit
						d6db2c0fab
					
				@ -230,8 +230,14 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
 | 
				
			|||||||
        cpu_name = g_strdup_printf("/cpus/cpu@%d",
 | 
					        cpu_name = g_strdup_printf("/cpus/cpu@%d",
 | 
				
			||||||
            s->soc[socket].hartid_base + cpu);
 | 
					            s->soc[socket].hartid_base + cpu);
 | 
				
			||||||
        qemu_fdt_add_subnode(mc->fdt, cpu_name);
 | 
					        qemu_fdt_add_subnode(mc->fdt, cpu_name);
 | 
				
			||||||
 | 
					        if (riscv_feature(&s->soc[socket].harts[cpu].env,
 | 
				
			||||||
 | 
					                          RISCV_FEATURE_MMU)) {
 | 
				
			||||||
            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
 | 
					            qemu_fdt_setprop_string(mc->fdt, cpu_name, "mmu-type",
 | 
				
			||||||
                                    (is_32_bit) ? "riscv,sv32" : "riscv,sv48");
 | 
					                                    (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]);
 | 
					        name = riscv_isa_string(&s->soc[socket].harts[cpu]);
 | 
				
			||||||
        qemu_fdt_setprop_string(mc->fdt, cpu_name, "riscv,isa", name);
 | 
					        qemu_fdt_setprop_string(mc->fdt, cpu_name, "riscv,isa", name);
 | 
				
			||||||
        g_free(name);
 | 
					        g_free(name);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user