mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 02:54:58 -06:00
riscv: Correctly set the device-tree entry 'mmu-type'
The 'mmu-type' should reflect what the hardware is capable of so use the new satp_mode field in RISCVCPUConfig to do that. Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Bin Meng <bmeng@tinylab.org> Reviewed-by: Frank Chang <frank.chang@sifive.com> Message-ID: <20230303131252.892893-6-alexghiti@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
This commit is contained in:
parent
6df3747a27
commit
ed9eb20694
1 changed files with 11 additions and 8 deletions
|
@ -228,8 +228,9 @@ static void create_fdt_socket_cpus(RISCVVirtState *s, int socket,
|
||||||
int cpu;
|
int cpu;
|
||||||
uint32_t cpu_phandle;
|
uint32_t cpu_phandle;
|
||||||
MachineState *ms = MACHINE(s);
|
MachineState *ms = MACHINE(s);
|
||||||
char *name, *cpu_name, *core_name, *intc_name;
|
char *name, *cpu_name, *core_name, *intc_name, *sv_name;
|
||||||
bool is_32_bit = riscv_is_32bit(&s->soc[0]);
|
bool is_32_bit = riscv_is_32bit(&s->soc[0]);
|
||||||
|
uint8_t satp_mode_max;
|
||||||
|
|
||||||
for (cpu = s->soc[socket].num_harts - 1; cpu >= 0; cpu--) {
|
for (cpu = s->soc[socket].num_harts - 1; cpu >= 0; cpu--) {
|
||||||
RISCVCPU *cpu_ptr = &s->soc[socket].harts[cpu];
|
RISCVCPU *cpu_ptr = &s->soc[socket].harts[cpu];
|
||||||
|
@ -239,13 +240,15 @@ 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(ms->fdt, cpu_name);
|
qemu_fdt_add_subnode(ms->fdt, cpu_name);
|
||||||
if (cpu_ptr->cfg.mmu) {
|
|
||||||
qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type",
|
satp_mode_max = satp_mode_max_from_map(
|
||||||
(is_32_bit) ? "riscv,sv32" : "riscv,sv48");
|
s->soc[socket].harts[cpu].cfg.satp_mode.map);
|
||||||
} else {
|
sv_name = g_strdup_printf("riscv,%s",
|
||||||
qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type",
|
satp_mode_str(satp_mode_max, is_32_bit));
|
||||||
"riscv,none");
|
qemu_fdt_setprop_string(ms->fdt, cpu_name, "mmu-type", sv_name);
|
||||||
}
|
g_free(sv_name);
|
||||||
|
|
||||||
|
|
||||||
name = riscv_isa_string(cpu_ptr);
|
name = riscv_isa_string(cpu_ptr);
|
||||||
qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name);
|
qemu_fdt_setprop_string(ms->fdt, cpu_name, "riscv,isa", name);
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue