[PATCH 2/2] powerpc/64s/interrupt: Check and fix srr_valid without crashing

Nicholas Piggin npiggin at gmail.com
Tue Jun 22 18:54:12 AEST 2021


Excerpts from Christophe Leroy's message of June 22, 2021 4:47 pm:
> 
> 
> Le 22/06/2021 à 08:04, Nicholas Piggin a écrit :
>> The PPC_RFI_SRR_DEBUG check added by patch "powerpc/64s: avoid reloading
>> (H)SRR registers if they are still valid" has a few deficiencies. It
>> does not fix the actual problem, it's not enabled by default, and it
>> causes a program check interrupt which can cause more difficulties.
>> 
>> However there are a lot of paths which may clobber SRRs or change return
>> regs, and difficult to have a high confidence that all paths are covered
>> without wider testing.
>> 
>> Add a relatively low overhead always-enabled check that catches most
>> such cases, reports once, and fixes it so the kernel can continue.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
>> ---
>>   arch/powerpc/kernel/interrupt.c | 58 +++++++++++++++++++++++++++++++++
>>   1 file changed, 58 insertions(+)
>> 
>> diff --git a/arch/powerpc/kernel/interrupt.c b/arch/powerpc/kernel/interrupt.c
>> index 05fa3ae56e25..5920a3e8d1d5 100644
>> --- a/arch/powerpc/kernel/interrupt.c
>> +++ b/arch/powerpc/kernel/interrupt.c
>> @@ -231,6 +231,56 @@ static notrace void booke_load_dbcr0(void)
>>   #endif
>>   }
>>   
>> +#include <linux/sched/debug.h> /* for show_regs */
>> +static void check_return_regs_valid(struct pt_regs *regs)
>> +{
>> +#ifdef CONFIG_PPC_BOOK3S_64
>> +	static bool warned = false;
>> +
>> +	if (regs->trap == 0x980 || regs->trap == 0xe00 || regs->trap == 0xe20 ||
>> +	    regs->trap == 0xe40 || regs->trap == 0xe60 || regs->trap == 0xe80 ||
>> +	    regs->trap == 0xea0 || regs->trap == 0xf80 || regs->trap == 0x1200 ||
>> +	    regs->trap == 0x1500 || regs->trap == 0x1600 || regs->trap == 0x1800) {
> 
> Can you use names defined in asm/interrupt.h instead of raw values ?
> Some are already there, others can be added.

Good idea. Could go into a helper too actually.

I wanted to clean up the KVM definitions and unify them with interrupt.h 
defs but that's a bit of churn. Can I get to that in the next merge or 
so?

Thanks,
Nick


More information about the Linuxppc-dev mailing list