[PATCH] powerpc: booke: fix boot crash due to null hugepd

Laurentiu Tudor laurentiu.tudor at nxp.com
Fri Feb 17 21:18:56 AEDT 2017



On 02/17/2017 12:08 PM, Scott Wood wrote:
> On Thu, 2017-02-16 at 09:11 -0600, laurentiu.tudor at nxp.com wrote:
>> From: Laurentiu Tudor <laurentiu.tudor at nxp.com>
>>
>> On 32-bit book-e machines, hugepd_ok() does not take
>> into account null hugepd values, causing this crash at boot:
>
> Why only 32-bit?

I wanted to get this patch out as quick as possible so i didn't had
time to investigate in depth. I just tested on 64-bit that the
kernel boots ok.

>> diff --git a/arch/powerpc/include/asm/nohash/pgtable.h
>> b/arch/powerpc/include/asm/nohash/pgtable.h
>> index 0cd8a38..e5805ad 100644
>> --- a/arch/powerpc/include/asm/nohash/pgtable.h
>> +++ b/arch/powerpc/include/asm/nohash/pgtable.h
>> @@ -230,7 +230,7 @@ static inline int hugepd_ok(hugepd_t hpd)
>>   	return ((hpd_val(hpd) & 0x4) != 0);
>>   #else
>>   	/* We clear the top bit to indicate hugepd */
>> -	return ((hpd_val(hpd) & PD_HUGE) ==  0);
>> +	return (hpd_val(hpd) && (hpd_val(hpd) & PD_HUGE) == 0);
>>   #endif
>>   }
>>
>
> Any reason why this can't go back to being "hpd_val(hpd) > 0"?  Why was nohash
> changed to begin with?  I don't expect nohash (or at least fsl-book3e) will
> ever have a pagetable that is not native-endian, and "> 0" is consistent with
> what the TLB miss code is doing.

The patch that introduced the brokenness changes "hugepd_t.pd" from 
"signed long" to "unsigned long" so as a consequence "> 0" was replaced
with the bitwise op.

---
Best Regards, Laurentiu


More information about the Linuxppc-dev mailing list