Skip to contentSkip to conversation

target-ppc: Add MMU model check for booke machines

PATCH Applied Valentin Plotkin 3 participants 3 messages Jan 26, 2017 – Feb 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: Add MMU model check for booke machines

From: Valentin Plotkin <[email protected]>

Machines bamboo, e500 and virtex-ml507 assume a certain MMU model, otherwise resulting in unpredictable behavior. Add apropriate checks into *_init functions.

---
 hw/ppc/e500.c          | 6 ++++++
 hw/ppc/ppc440_bamboo.c | 6 ++++++
 hw/ppc/virtex_ml507.c  | 7 +++++++
 3 files changed, 19 insertions(+)
hw/ppc/e500.c +6 -0
index cf8b122..5b1958c 100644
@@ -827,6 +827,12 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         env = &cpu->env;
         cs = CPU(cpu);
 
+        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
+            fprintf(stderr, "MMU model %i not supported by this machine.\n",
+                env->mmu_model);
+            exit(1);
+        }
+
         if (!firstenv) {
             firstenv = env;
         }
hw/ppc/ppc440_bamboo.c +6 -0
index 5c535b1..9d997bf 100644
@@ -193,6 +193,12 @@ static void bamboo_init(MachineState *machine)
     }
     env = &cpu->env;
 
+    if (env->mmu_model != POWERPC_MMU_BOOKE) {
+        fprintf(stderr, "MMU model %i not supported by this machine.\n",
+            env->mmu_model);
+        exit(1);
+    }
+
     qemu_register_reset(main_cpu_reset, cpu);
     ppc_booke_timers_init(cpu, 400000000, 0);
     ppc_dcr_init(env, NULL, NULL);
hw/ppc/virtex_ml507.c +7 -0
index b97d966..fdbcf22 100644
@@ -221,6 +221,13 @@ static void virtex_init(MachineState *machine)
 
     cpu = ppc440_init_xilinx(&ram_size, 1, machine->cpu_model, 400000000);
     env = &cpu->env;
+
+    if (env->mmu_model != POWERPC_MMU_BOOKE) {
+        fprintf(stderr, "MMU model %i not supported by this machine.\n",
+            env->mmu_model);
+        exit(1);
+    }
+
     qemu_register_reset(main_cpu_reset, cpu);
 
     memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size);
Signature · 11 lines
2.5.5


This fixes 'qemu-system-ppc -nographic -cpu G2leGP3 -M ppce500; bug from
BiteSizedTasks.

Version 2: fixed style, moved checks from mmubooke_create_initial_mapping
to *_init. Thanks to Thomas Huth <[email protected]>.

Version 2.1: seems like my mailer added linebreaks without ever notyfing.
Sorry for the mess, will use git send-mail from now on.
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Valentin Plotkin

From: Valentin Plotkin <[email protected]>

Machines bamboo, e500 and virtex-ml507 assume a certain MMU model, otherwise resulting in unpredictable behavior. Add apropriate checks into *_init functions.

Thanks Valentin.

Regarding the virtex parts:

Quoted 72 lines
---
 hw/ppc/e500.c          | 6 ++++++
 hw/ppc/ppc440_bamboo.c | 6 ++++++
 hw/ppc/virtex_ml507.c  | 7 +++++++
 3 files changed, 19 insertions(+)
hw/ppc/e500.c +6 -0
index cf8b122..5b1958c 100644
@@ -827,6 +827,12 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         env = &cpu->env;
         cs = CPU(cpu);
 
+        if (env->mmu_model != POWERPC_MMU_BOOKE206) {
+            fprintf(stderr, "MMU model %i not supported by this machine.\n",
+                env->mmu_model);
+            exit(1);
+        }
+
         if (!firstenv) {
             firstenv = env;
         }
hw/ppc/ppc440_bamboo.c +6 -0
index 5c535b1..9d997bf 100644
@@ -193,6 +193,12 @@ static void bamboo_init(MachineState *machine)
     }
     env = &cpu->env;
 
+    if (env->mmu_model != POWERPC_MMU_BOOKE) {
+        fprintf(stderr, "MMU model %i not supported by this machine.\n",
+            env->mmu_model);
+        exit(1);
+    }
+
     qemu_register_reset(main_cpu_reset, cpu);
     ppc_booke_timers_init(cpu, 400000000, 0);
     ppc_dcr_init(env, NULL, NULL);
hw/ppc/virtex_ml507.c +7 -0
index b97d966..fdbcf22 100644
@@ -221,6 +221,13 @@ static void virtex_init(MachineState *machine)
 
     cpu = ppc440_init_xilinx(&ram_size, 1, machine->cpu_model, 400000000);
     env = &cpu->env;
+
+    if (env->mmu_model != POWERPC_MMU_BOOKE) {
+        fprintf(stderr, "MMU model %i not supported by this machine.\n",
+            env->mmu_model);
+        exit(1);
+    }
+
     qemu_register_reset(main_cpu_reset, cpu);
 
     memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size);
Signature · 11 lines
2.5.5


This fixes 'qemu-system-ppc -nographic -cpu G2leGP3 -M ppce500; bug from
BiteSizedTasks.

Version 2: fixed style, moved checks from mmubooke_create_initial_mapping
to *_init. Thanks to Thomas Huth <[email protected]>.

Version 2.1: seems like my mailer added linebreaks without ever notyfing.
Sorry for the mess, will use git send-mail from now on.
Applied
#2 lore raw
In reply to Valentin Plotkin
Quoted 7 lines · Valentin Plotkin

From: Valentin Plotkin <[email protected]>

Machines bamboo, e500 and virtex-ml507 assume a certain MMU model, otherwise resulting in unpredictable behavior. Add apropriate checks into *_init functions.

Applied to ppc-for-2.9.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson