[OpenBIOS] [PATCH] ppc: fix mtmsr for SF setting
Alexander Graf
agraf at csgraf.de
Fri Jun 17 00:03:40 CEST 2011
On 16.06.2011, at 21:43, Segher Boessenkool wrote:
>> This patch adds a runtime check on PVR to see if we're running on a 64-bit
>> capable CPU. If so, we use mtmsrd, which can set the high 32bits of MSR.
>
> That PVR check isn't quite correct.
>
>> mfmsr r1 ; /* unset MSR_SF */ \
>> clrlwi r1,r1,0 ; \
>> - mtmsr r1 ; \
>> + mtmsrd r1 ; \
>
> clrlwi 1,1,0 is rlwinm 1,1,0,0,31 which clears all the top 32 bits, not
> only MSR[SF]. Importantly it clears MSR[HV], which you do not want. Use
> rldicl instead?
Now that we actually detect if we're on a 64-bit CPU, we can indeed be a bit more clever about it. However, I don't think any of the upper 32 bits are important to us, no?
> Instead of the PVR thing, you could check if MSR[SF] is set, and only then
> clear it. Is this same code used on 32-bit systems?
>
> lis x,0x8000 ; add. x,x,x ; beq ohai_we_are_32bit
lis x,0x8000 would result in 0xffffffff80000000 or 0x80000000 in x respectively. add. compares the full register with 0, so we also get to analyze the shifted out 8. Very nice trick indeed and exactly what I was searching for! Thanks a lot!
Alex
More information about the OpenBIOS
mailing list