ppc: Improve emulation of THRM registers
PATCH 1/1 ppc: Improve emulation of THRM registers
The 75x and 74xx processors have some thermal monitoring SPRs that some OSes such as MacOS do use. Our current "dumb" implementation isn't good enough and will cause some versions of MacOS to hang during boot.
This lifts an improved emulation from MacOnLinux and adapts it to qemu, thus fixing the problem.
--- target-ppc/helper.h | 1 + target-ppc/misc_helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ target-ppc/translate_init.c | 13 ++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-)
target-ppc/helper.h +1 -0
@@ -670,3 +670,4 @@ DEF_HELPER_4(dscli, void, env, fprp, fprp, i32) DEF_HELPER_4(dscliq, void, env, fprp, fprp, i32) DEF_HELPER_1(tbegin, void, env) +DEF_HELPER_1 (fixup_thrm, void, env)
target-ppc/misc_helper.c +41 -0
44 lines not on this page · raw message
target-ppc/translate_init.c +10 -3
@@ -1179,23 +1179,30 @@ static void gen_spr_amr(CPUPPCState *env, bool has_iamr) }#endif /* TARGET_PPC64 */ +static void spr_read_thrm (DisasContext *ctx,int gprn,int sprn) +{ +gen_helper_fixup_thrm (cpu_env); +gen_load_spr (cpu_gpr[gprn], sprn); +spr_load_dump_spr (sprn); +} +static void gen_spr_thrm (CPUPPCState *env) {/* Thermal management */ /* XXX : not implemented */ spr_register (env,SPR_THRM1 ,"THRM1" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_thrm, &spr_write_generic,0x00000000 );/* XXX : not implemented */ spr_register (env,SPR_THRM2 ,"THRM2" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_thrm, &spr_write_generic,0x00000000 );/* XXX : not implemented */ spr_register (env,SPR_THRM3 ,"THRM3" ,SPR_NOACCESS ,SPR_NOACCESS , - &spr_read_generic, &spr_write_generic, + &spr_read_thrm, &spr_write_generic,0x00000000 ); }
Quoted 29 lines · Benjamin Herrenschmidt
The 75x and 74xx processors have some thermal monitoring SPRs that some OSes such as MacOS do use. Our current "dumb" implementation isn't good enough and will cause some versions of MacOS to hang during boot.
This lifts an improved emulation from MacOnLinux and adapts it to qemu, thus fixing the problem.
Signed-off-by Benjamin Herrenschmidt <[email protected]>---
target-ppc/helper.h | 1 + target-ppc/misc_helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ target-ppc/translate_init.c | 13 ++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-)target-ppc/helper.h +1
-0@@ -670,3 +670,4 @@ DEF_HELPER_4(dscli, void, env, fprp, fprp, i32) DEF_HELPER_4(dscliq, void, env, fprp, fprp, i32) DEF_HELPER_1(tbegin, void, env) +DEF_HELPER_1 (fixup_thrm, void, env)target-ppc/misc_helper.c +0
-0
target-ppc/misc_helper.c void ppc_store_msr(CPUPPCState *env, target_ulong value) · line 172
Quoted 7 lines
target-ppc/misc_helper.c +4
-0@@ -166,3 +166,44 @@ void ppc_store_msr(CPUPPCState *env, target_ulong value) {hreg_store_msr (env, value,0 ); } + +/* This code is lifted from MacOnLinux. It is called whenever +* THRM1,2 or 3 is read an fixes up the values in such a way +* that will mac MacOS not hang. These registers exist on some
Typo: mac -> make?
Quoted 23 lines · BALATON Zoltan
Quoted 22 lines · Benjamin Herrenschmidt
The 75x and 74xx processors have some thermal monitoring SPRs that some OSes such as MacOS do use. Our current "dumb" implementation isn't good enough and will cause some versions of MacOS to hang during boot.
This lifts an improved emulation from MacOnLinux and adapts it to qemu, thus fixing the problem.
Signed-off-by Benjamin Herrenschmidt <[email protected]>---
target-ppc/helper.h | 1 + target-ppc/misc_helper.c | 41 +++++++++++++++++++++++++++++++++++++++++ target-ppc/translate_init.c | 13 ++++++++++--- 3 files changed, 52 insertions(+), 3 deletions(-)target-ppc/helper.h +0
-0@@ -670,3 +670,4 @@ DEF_HELPER_4(dscli, void, env, fprp, fprp, i32)DEF_HELPER_4 (dscliq, void, env, fprp, fprp, i32)
Quoted 16 lines
Quoted 7 lines
target-ppc/helper.h +1
-0DEF_HELPER_1(tbegin, void, env) +DEF_HELPER_1 (fixup_thrm, void, env)target-ppc/misc_helper.c +0
-0target-ppc/misc_helper.c void ppc_store_msr(CPUPPCState *env, target_ulong value) · line 172
Quoted 7 lines
target-ppc/misc_helper.c +4
-0@@ -166,3 +166,44 @@ void ppc_store_msr(CPUPPCState *env, target_ulong value) {hreg_store_msr (env, value,0 ); } + +/* This code is lifted from MacOnLinux. It is called whenever +* THRM1,2 or 3 is read an fixes up the values in such a way +* that will mac MacOS not hang. These registers exist on some Typo: mac -> make?
I've made this change, along with a number of checkpatch fixes as I've merged this into my tree.
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