[PATCH 10/10] powerpc: move norestart trap flag to bit 0
Nicholas Piggin
npiggin at gmail.com
Tue Mar 16 18:11:42 AEDT 2021
Excerpts from Christophe Leroy's message of March 15, 2021 6:14 pm:
>
>
> Le 15/03/2021 à 04:17, Nicholas Piggin a écrit :
>> Compact the trap flags down to use the low 4 bits of regs.trap.
>>
>> A few 64e interrupt trap numbers set bit 4. Although they tended to be
>> trivial so it wasn't a real problem[1], it is not the right thing to do,
>> and confusing.
>>
>> [*] E.g., 0x310 hypercall goes to unknown_exception, which prints
>> regs->trap directly so 0x310 will appear fine, and only the syscall
>> interrupt will test norestart, so it won't be confused by 0x310.
>>
>> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
>> ---
>> arch/powerpc/include/asm/ptrace.h | 14 ++++++++++----
>> 1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
>> index 91194fdd5d01..6a04abfe5eb6 100644
>> --- a/arch/powerpc/include/asm/ptrace.h
>> +++ b/arch/powerpc/include/asm/ptrace.h
>> @@ -185,15 +185,21 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
>> #define current_pt_regs() \
>> ((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1)
>>
>> +/*
>> + * The 4 low bits (0xf) are available as flags to overload the trap word,
>> + * because interrupt vectors have minimum alignment of 0x10. TRAP_FLAGS_MASK
>> + * must cover the bits used as flags, including bit 0 which is used as the
>> + * "norestart" bit.
>> + */
>> #ifdef __powerpc64__
>> -#define TRAP_FLAGS_MASK 0x10
>> +#define TRAP_FLAGS_MASK 0x1
>> #define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK)
>> #else
>> /*
>> * On 4xx we use bit 1 in the trap word to indicate whether the exception
>> * is a critical exception (1 means it is).
>> */
>> -#define TRAP_FLAGS_MASK 0x1E
>> +#define TRAP_FLAGS_MASK 0xf
>
> Could we set 0xf for all and remove the ifdef __powerpc64__ ?
I like that it documents the bit number allocation so I prefer to leave
it, but TRAP() does not have to be defined twice at least.
>
>> #define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK)
>> #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0)
>> #define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0)
>> @@ -222,12 +228,12 @@ static inline bool trap_is_syscall(struct pt_regs *regs)
>>
>> static inline bool trap_norestart(struct pt_regs *regs)
>> {
>> - return regs->trap & 0x10;
>> + return regs->trap & 0x1;
>> }
>>
>> static inline void set_trap_norestart(struct pt_regs *regs)
>> {
>> - regs->trap |= 0x10;
>> + regs->trap |= 0x1;
>> }
>>
>> #define arch_has_single_step() (1)
>>
>
> While we are playing with ->trap, in mm/book3s64/hash_utils.c there is an if (regs->trap == 0x400).
> Should be TRAP(regs) == 0x400 ?
Yes I would say so, if you want to do a patch you can add
Acked-by: Nicholas Piggin <npiggin at gmail.com>
Otherwise I can do it.
Thanks,
Nick
More information about the Linuxppc-dev
mailing list