Skip to contentSkip to conversation

target-ppc: KVMPPC_H_CAS fix cpu-version endianess

PATCH In review Laurent Dufour 3 participants 3 messages Jun 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-ppc: KVMPPC_H_CAS fix cpu-version endianess

During KVMPPC_H_CAS processing, the cpu-version updated value is stored without taking care of the current endianess. As a consequence, the guest may not switch to the right CPU model, leading to unexpected results.

If needed, the value is now converted.

Fixes 6d9412ea8132 ("target-ppc: Implement "compat" CPU option")
---
 hw/ppc/spapr.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ppc/spapr.c +1 -2
index 82f183f173ee..85e9f4a74933 100644
@@ -228,8 +228,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
     int index = ppc_get_vcpu_dt_id(cpu);
 
     if (cpu->cpu_version) {
-        ret = fdt_setprop(fdt, offset, "cpu-version",
-                          &cpu->cpu_version, sizeof(cpu->cpu_version));
+        ret = fdt_setprop_cell(fdt, offset, "cpu-version", cpu->cpu_version);
         if (ret < 0) {
             return ret;
         }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · On Fri, 27 Jun 2014 15:47:37 +0200 Laurent Dufour <[email protected]>…

During KVMPPC_H_CAS processing, the cpu-version updated value is stored without taking care of the current endianess. As a consequence, the guest may not switch to the right CPU model, leading to unexpected results.

If needed, the value is now converted.

Fixes 6d9412ea8132 ("target-ppc: Implement "compat" CPU option")

---

Quoted 19 lines
 hw/ppc/spapr.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ppc/spapr.c +1 -2
index 82f183f173ee..85e9f4a74933 100644
@@ -228,8 +228,7 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
     int index = ppc_get_vcpu_dt_id(cpu);
 
     if (cpu->cpu_version) {
-        ret = fdt_setprop(fdt, offset, "cpu-version",
-                          &cpu->cpu_version, sizeof(cpu->cpu_version));
+        ret = fdt_setprop_cell(fdt, offset, "cpu-version", cpu->cpu_version);
         if (ret < 0) {
             return ret;
         }
Signature · 7 lines
Gregory Kurz                                     [email protected]
                                                 [email protected]
Software Engineer @ IBM/Meiosys                  http://www.ibm.com
Tel +33 (0)562 165 496

"Anarchy is about taking complete responsibility for yourself."
        Alan Moore.
#2 lore raw
Quoted 7 lines · Greg Kurz
Quoted 4 lines · On Fri, 27 Jun 2014 15:47:37 +0200 Laurent Dufour <[email protected]>…

During KVMPPC_H_CAS processing, the cpu-version updated value is stored without taking care of the current endianess. As a consequence, the guest may not switch to the right CPU model, leading to unexpected results.

Quoted 6 lines
Quoted 5 lines

If needed, the value is now converted.

Fixes 6d9412ea8132 ("target-ppc: Implement "compat" CPU option")

---

Good catch! Thanks, applied to ppc-next.

Alex