A recent attempt to restrict the use of rfi to 64bit cpus in qemu broke 32bit OpenBIOS when run under a 970.
This is adding a dynamic check on the pvr to choose between rfi and rfid. Only the 970 family is supported.
Signed-off-by: Cédric Le Goater clg@kaod.org ---
Tested on qemu.
arch/ppc/qemu/start.S | 25 +++++++++++++++++++++++-- arch/ppc/start.S | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-)
Index: openbios.git/arch/ppc/qemu/start.S =================================================================== --- openbios.git.orig/arch/ppc/qemu/start.S +++ openbios.git/arch/ppc/qemu/start.S @@ -27,6 +27,27 @@
#ifdef CONFIG_PPC_64BITSUPPORT
+/* When running on ppc64, we cannot use rfi anymore. Let's try to + * catch which cpu we are running on and act accordingly. This is + * for 970s only. + */ +.macro do_rfi + mtsprg1 r3 + mfpvr r3 + rlwinm r3,r3,16,16,31 + cmplwi cr1,r3,0x0039 /* 970 CPUs */ + beq- cr1,0f + cmplwi cr1,r3,0x003C /* 970fx CPUs */ + beq- cr1,0f + cmplwi cr1,r3,0x0044 /* 970mp CPUs */ + beq- cr1,0f + mfsprg1 r3 + rfi +0: + mfsprg1 r3 + rfid +.endm + /* We're trying to use the same code for the ppc32 and ppc64 handlers here. * On ppc32 we only save/restore the registers, C considers volatile. * @@ -148,7 +169,7 @@ ll r31,(35 * ULONG_SIZE)(r1) ; \ .endif ; \ ll r1,(1 * ULONG_SIZE)(r1) ; /* restore stack at last */ \ - rfi + do_rfi
// PPC32
@@ -319,7 +340,7 @@ VECTOR( 0x800, "FPU" ): ori r3,r3,0x2000 mtsrr1 r3 mfsprg1 r3 - RFI + do_rfi
ILLEGAL_VECTOR( 0x900 ) ILLEGAL_VECTOR( 0xa00 ) Index: openbios.git/arch/ppc/start.S =================================================================== --- openbios.git.orig/arch/ppc/start.S +++ openbios.git/arch/ppc/start.S @@ -25,6 +25,27 @@ #define ILLEGAL_VECTOR( v ) .org __vectors + v ; bl trap_error ; #define VECTOR( v, dummystr ) .org __vectors + v ; vector__##v
+/* When running on ppc64, we cannot use rfi anymore. Let's try to + * catch which cpu we are running on and act accordingly. This is + * for 970s only. + */ +.macro do_rfi + mtsprg1 r3 + mfpvr r3 + rlwinm r3,r3,16,16,31 + cmplwi cr1,r3,0x0039 /* 970 CPUs */ + beq- cr1,0f + cmplwi cr1,r3,0x003C /* 970fx CPUs */ + beq- cr1,0f + cmplwi cr1,r3,0x0044 /* 970mp CPUs */ + beq- cr1,0f + mfsprg1 r3 + rfi +0: + mfsprg1 r3 + rfid +.endm + #define EXCEPTION_PREAMBLE \ mtsprg1 r1 ; /* scratch */ \ mfsprg0 r1 ; /* exception stack in sprg0 */ \ @@ -252,7 +273,7 @@ exception_return: lwz r11,44(r1) lwz r12,48(r1) lwz r1,4(r1) // restore r1 - rfi + do_rfi
trap_error: mflr r3 @@ -287,7 +308,7 @@ VECTOR( 0x800, "FPU" ): ori r3,r3,0x2000 mtsrr1 r3 mfsprg1 r3 - rfi + do_rfi
ILLEGAL_VECTOR( 0x900 ) ILLEGAL_VECTOR( 0xa00 )