Commit a01a3f2d authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc: remove arguments from fault handler functions

Make mm fault handlers all just take the pt_regs * argument and load
DAR/DSISR from that. Make those that return a value return long.

This is done to make the function signatures match other handlers, which
will help with a future patch to add wrappers. Explicit arguments could
be added for performance but that would require more wrapper macro
variants.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210130130852.2952424-7-npiggin@gmail.com
parent a4922f54
...@@ -82,8 +82,8 @@ void kernel_bad_stack(struct pt_regs *regs); ...@@ -82,8 +82,8 @@ void kernel_bad_stack(struct pt_regs *regs);
void system_reset_exception(struct pt_regs *regs); void system_reset_exception(struct pt_regs *regs);
void machine_check_exception(struct pt_regs *regs); void machine_check_exception(struct pt_regs *regs);
void emulation_assist_interrupt(struct pt_regs *regs); void emulation_assist_interrupt(struct pt_regs *regs);
long do_slb_fault(struct pt_regs *regs, unsigned long ea); long do_slb_fault(struct pt_regs *regs);
void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err); void do_bad_slb_fault(struct pt_regs *regs);
/* signals, syscalls and interrupts */ /* signals, syscalls and interrupts */
long sys_swapcontext(struct ucontext __user *old_ctx, long sys_swapcontext(struct ucontext __user *old_ctx,
......
...@@ -456,7 +456,7 @@ static inline unsigned long hpt_hash(unsigned long vpn, ...@@ -456,7 +456,7 @@ static inline unsigned long hpt_hash(unsigned long vpn,
long hpte_insert_repeating(unsigned long hash, unsigned long vpn, unsigned long pa, long hpte_insert_repeating(unsigned long hash, unsigned long vpn, unsigned long pa,
unsigned long rlags, unsigned long vflags, int psize, int ssize); unsigned long rlags, unsigned long vflags, int psize, int ssize);
int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long dsisr); long do_hash_fault(struct pt_regs *regs);
extern int __hash_page_4K(unsigned long ea, unsigned long access, extern int __hash_page_4K(unsigned long ea, unsigned long access,
unsigned long vsid, pte_t *ptep, unsigned long trap, unsigned long vsid, pte_t *ptep, unsigned long trap,
unsigned long flags, int ssize, int subpage_prot); unsigned long flags, int ssize, int subpage_prot);
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
struct pt_regs; struct pt_regs;
extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long); long do_page_fault(struct pt_regs *);
extern void bad_page_fault(struct pt_regs *, unsigned long, int); extern void bad_page_fault(struct pt_regs *, unsigned long, int);
void __bad_page_fault(struct pt_regs *regs, unsigned long address, int sig); void __bad_page_fault(struct pt_regs *regs, unsigned long address, int sig);
extern void _exception(int, struct pt_regs *, int, unsigned long); extern void _exception(int, struct pt_regs *, int, unsigned long);
......
...@@ -1011,8 +1011,6 @@ storage_fault_common: ...@@ -1011,8 +1011,6 @@ storage_fault_common:
std r14,_DAR(r1) std r14,_DAR(r1)
std r15,_DSISR(r1) std r15,_DSISR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
mr r4,r14
mr r5,r15
ld r14,PACA_EXGEN+EX_R14(r13) ld r14,PACA_EXGEN+EX_R14(r13)
ld r15,PACA_EXGEN+EX_R15(r13) ld r15,PACA_EXGEN+EX_R15(r13)
bl do_page_fault bl do_page_fault
......
...@@ -1438,10 +1438,9 @@ EXC_VIRT_BEGIN(data_access, 0x4300, 0x80) ...@@ -1438,10 +1438,9 @@ EXC_VIRT_BEGIN(data_access, 0x4300, 0x80)
EXC_VIRT_END(data_access, 0x4300, 0x80) EXC_VIRT_END(data_access, 0x4300, 0x80)
EXC_COMMON_BEGIN(data_access_common) EXC_COMMON_BEGIN(data_access_common)
GEN_COMMON data_access GEN_COMMON data_access
ld r4,_DAR(r1) ld r4,_DSISR(r1)
ld r5,_DSISR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
andis. r0,r5,DSISR_DABRMATCH@h andis. r0,r4,DSISR_DABRMATCH@h
bne- 1f bne- 1f
BEGIN_MMU_FTR_SECTION BEGIN_MMU_FTR_SECTION
bl do_hash_fault bl do_hash_fault
...@@ -1504,10 +1503,9 @@ EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80) ...@@ -1504,10 +1503,9 @@ EXC_VIRT_BEGIN(data_access_slb, 0x4380, 0x80)
EXC_VIRT_END(data_access_slb, 0x4380, 0x80) EXC_VIRT_END(data_access_slb, 0x4380, 0x80)
EXC_COMMON_BEGIN(data_access_slb_common) EXC_COMMON_BEGIN(data_access_slb_common)
GEN_COMMON data_access_slb GEN_COMMON data_access_slb
ld r4,_DAR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD
BEGIN_MMU_FTR_SECTION BEGIN_MMU_FTR_SECTION
/* HPT case, do SLB fault */ /* HPT case, do SLB fault */
addi r3,r1,STACK_FRAME_OVERHEAD
bl do_slb_fault bl do_slb_fault
cmpdi r3,0 cmpdi r3,0
bne- 1f bne- 1f
...@@ -1519,8 +1517,6 @@ MMU_FTR_SECTION_ELSE ...@@ -1519,8 +1517,6 @@ MMU_FTR_SECTION_ELSE
ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
std r3,RESULT(r1) std r3,RESULT(r1)
RECONCILE_IRQ_STATE(r10, r11) RECONCILE_IRQ_STATE(r10, r11)
ld r4,_DAR(r1)
ld r5,RESULT(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl do_bad_slb_fault bl do_bad_slb_fault
b interrupt_return b interrupt_return
...@@ -1555,8 +1551,6 @@ EXC_VIRT_BEGIN(instruction_access, 0x4400, 0x80) ...@@ -1555,8 +1551,6 @@ EXC_VIRT_BEGIN(instruction_access, 0x4400, 0x80)
EXC_VIRT_END(instruction_access, 0x4400, 0x80) EXC_VIRT_END(instruction_access, 0x4400, 0x80)
EXC_COMMON_BEGIN(instruction_access_common) EXC_COMMON_BEGIN(instruction_access_common)
GEN_COMMON instruction_access GEN_COMMON instruction_access
ld r4,_DAR(r1)
ld r5,_DSISR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
BEGIN_MMU_FTR_SECTION BEGIN_MMU_FTR_SECTION
bl do_hash_fault bl do_hash_fault
...@@ -1602,10 +1596,9 @@ EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80) ...@@ -1602,10 +1596,9 @@ EXC_VIRT_BEGIN(instruction_access_slb, 0x4480, 0x80)
EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80) EXC_VIRT_END(instruction_access_slb, 0x4480, 0x80)
EXC_COMMON_BEGIN(instruction_access_slb_common) EXC_COMMON_BEGIN(instruction_access_slb_common)
GEN_COMMON instruction_access_slb GEN_COMMON instruction_access_slb
ld r4,_DAR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD
BEGIN_MMU_FTR_SECTION BEGIN_MMU_FTR_SECTION
/* HPT case, do SLB fault */ /* HPT case, do SLB fault */
addi r3,r1,STACK_FRAME_OVERHEAD
bl do_slb_fault bl do_slb_fault
cmpdi r3,0 cmpdi r3,0
bne- 1f bne- 1f
...@@ -1617,8 +1610,6 @@ MMU_FTR_SECTION_ELSE ...@@ -1617,8 +1610,6 @@ MMU_FTR_SECTION_ELSE
ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX) ALT_MMU_FTR_SECTION_END_IFCLR(MMU_FTR_TYPE_RADIX)
std r3,RESULT(r1) std r3,RESULT(r1)
RECONCILE_IRQ_STATE(r10, r11) RECONCILE_IRQ_STATE(r10, r11)
ld r4,_DAR(r1)
ld r5,RESULT(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl do_bad_slb_fault bl do_bad_slb_fault
b interrupt_return b interrupt_return
......
...@@ -179,9 +179,9 @@ _ENTRY(saved_ksp_limit) ...@@ -179,9 +179,9 @@ _ENTRY(saved_ksp_limit)
*/ */
START_EXCEPTION(0x0300, DataStorage) START_EXCEPTION(0x0300, DataStorage)
EXCEPTION_PROLOG EXCEPTION_PROLOG
mfspr r5, SPRN_ESR /* Grab the ESR, save it, pass arg3 */ mfspr r5, SPRN_ESR /* Grab the ESR, save it */
stw r5, _ESR(r11) stw r5, _ESR(r11)
mfspr r4, SPRN_DEAR /* Grab the DEAR, save it, pass arg2 */ mfspr r4, SPRN_DEAR /* Grab the DEAR, save it */
stw r4, _DEAR(r11) stw r4, _DEAR(r11)
EXC_XFER_LITE(0x300, handle_page_fault) EXC_XFER_LITE(0x300, handle_page_fault)
...@@ -191,9 +191,9 @@ _ENTRY(saved_ksp_limit) ...@@ -191,9 +191,9 @@ _ENTRY(saved_ksp_limit)
*/ */
START_EXCEPTION(0x0400, InstructionAccess) START_EXCEPTION(0x0400, InstructionAccess)
EXCEPTION_PROLOG EXCEPTION_PROLOG
mr r4,r12 /* Pass SRR0 as arg2 */ li r5,0
stw r4, _DEAR(r11) stw r5, _ESR(r11) /* Zero ESR */
li r5,0 /* Pass zero as arg3 */ stw r12, _DEAR(r11) /* SRR0 as DEAR */
EXC_XFER_LITE(0x400, handle_page_fault) EXC_XFER_LITE(0x400, handle_page_fault)
/* 0x0500 - External Interrupt Exception */ /* 0x0500 - External Interrupt Exception */
......
...@@ -312,14 +312,14 @@ DataStoreTLBMiss: ...@@ -312,14 +312,14 @@ DataStoreTLBMiss:
. = 0x1300 . = 0x1300
InstructionTLBError: InstructionTLBError:
EXCEPTION_PROLOG EXCEPTION_PROLOG
mr r4,r12
andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */ andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */
andis. r10,r9,SRR1_ISI_NOPT@h andis. r10,r9,SRR1_ISI_NOPT@h
beq+ .Litlbie beq+ .Litlbie
tlbie r4 tlbie r12
/* 0x400 is InstructionAccess exception, needed by bad_page_fault() */ /* 0x400 is InstructionAccess exception, needed by bad_page_fault() */
.Litlbie: .Litlbie:
stw r4, _DAR(r11) stw r12, _DAR(r11)
stw r5, _DSISR(r11)
EXC_XFER_LITE(0x400, handle_page_fault) EXC_XFER_LITE(0x400, handle_page_fault)
/* This is the data TLB error on the MPC8xx. This could be due to /* This is the data TLB error on the MPC8xx. This could be due to
......
...@@ -362,9 +362,9 @@ BEGIN_MMU_FTR_SECTION ...@@ -362,9 +362,9 @@ BEGIN_MMU_FTR_SECTION
END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE) END_MMU_FTR_SECTION_IFSET(MMU_FTR_HPTE_TABLE)
#endif #endif
#endif /* CONFIG_VMAP_STACK */ #endif /* CONFIG_VMAP_STACK */
1: mr r4,r12
andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */ andis. r5,r9,DSISR_SRR1_MATCH_32S@h /* Filter relevant SRR1 bits */
stw r4, _DAR(r11) stw r5, _DSISR(r11)
stw r12, _DAR(r11)
EXC_XFER_LITE(0x400, handle_page_fault) EXC_XFER_LITE(0x400, handle_page_fault)
/* External interrupt */ /* External interrupt */
...@@ -686,7 +686,6 @@ handle_page_fault_tramp_1: ...@@ -686,7 +686,6 @@ handle_page_fault_tramp_1:
#ifdef CONFIG_VMAP_STACK #ifdef CONFIG_VMAP_STACK
EXCEPTION_PROLOG_2 handle_dar_dsisr=1 EXCEPTION_PROLOG_2 handle_dar_dsisr=1
#endif #endif
lwz r4, _DAR(r11)
lwz r5, _DSISR(r11) lwz r5, _DSISR(r11)
/* fall through */ /* fall through */
handle_page_fault_tramp_2: handle_page_fault_tramp_2:
......
...@@ -476,9 +476,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV) ...@@ -476,9 +476,7 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_EMB_HV)
NORMAL_EXCEPTION_PROLOG(INST_STORAGE); \ NORMAL_EXCEPTION_PROLOG(INST_STORAGE); \
mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \ mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
stw r5,_ESR(r11); \ stw r5,_ESR(r11); \
mr r4,r12; /* Pass SRR0 as arg2 */ \ stw r12, _DEAR(r11); /* Pass SRR0 as arg2 */ \
stw r4, _DEAR(r11); \
li r5,0; /* Pass zero as arg3 */ \
EXC_XFER_LITE(0x0400, handle_page_fault) EXC_XFER_LITE(0x0400, handle_page_fault)
#define ALIGNMENT_EXCEPTION \ #define ALIGNMENT_EXCEPTION \
......
...@@ -1512,13 +1512,15 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap, ...@@ -1512,13 +1512,15 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap,
} }
EXPORT_SYMBOL_GPL(hash_page); EXPORT_SYMBOL_GPL(hash_page);
int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long dsisr) long do_hash_fault(struct pt_regs *regs)
{ {
unsigned long ea = regs->dar;
unsigned long dsisr = regs->dsisr;
unsigned long access = _PAGE_PRESENT | _PAGE_READ; unsigned long access = _PAGE_PRESENT | _PAGE_READ;
unsigned long flags = 0; unsigned long flags = 0;
struct mm_struct *mm; struct mm_struct *mm;
unsigned int region_id; unsigned int region_id;
int err; long err;
if (unlikely(dsisr & (DSISR_BAD_FAULT_64S | DSISR_KEYFAULT))) if (unlikely(dsisr & (DSISR_BAD_FAULT_64S | DSISR_KEYFAULT)))
goto page_fault; goto page_fault;
...@@ -1582,7 +1584,7 @@ int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long dsisr) ...@@ -1582,7 +1584,7 @@ int do_hash_fault(struct pt_regs *regs, unsigned long ea, unsigned long dsisr)
} else if (err) { } else if (err) {
page_fault: page_fault:
err = do_page_fault(regs, ea, dsisr); err = do_page_fault(regs);
} }
return err; return err;
......
...@@ -813,8 +813,9 @@ static long slb_allocate_user(struct mm_struct *mm, unsigned long ea) ...@@ -813,8 +813,9 @@ static long slb_allocate_user(struct mm_struct *mm, unsigned long ea)
return slb_insert_entry(ea, context, flags, ssize, false); return slb_insert_entry(ea, context, flags, ssize, false);
} }
long do_slb_fault(struct pt_regs *regs, unsigned long ea) long do_slb_fault(struct pt_regs *regs)
{ {
unsigned long ea = regs->dar;
unsigned long id = get_region_id(ea); unsigned long id = get_region_id(ea);
/* IRQs are not reconciled here, so can't check irqs_disabled */ /* IRQs are not reconciled here, so can't check irqs_disabled */
...@@ -865,13 +866,15 @@ long do_slb_fault(struct pt_regs *regs, unsigned long ea) ...@@ -865,13 +866,15 @@ long do_slb_fault(struct pt_regs *regs, unsigned long ea)
} }
} }
void do_bad_slb_fault(struct pt_regs *regs, unsigned long ea, long err) void do_bad_slb_fault(struct pt_regs *regs)
{ {
int err = regs->result;
if (err == -EFAULT) { if (err == -EFAULT) {
if (user_mode(regs)) if (user_mode(regs))
_exception(SIGSEGV, regs, SEGV_BNDERR, ea); _exception(SIGSEGV, regs, SEGV_BNDERR, regs->dar);
else else
bad_page_fault(regs, ea, SIGSEGV); bad_page_fault(regs, regs->dar, SIGSEGV);
} else if (err == -EINVAL) { } else if (err == -EINVAL) {
unrecoverable_exception(regs); unrecoverable_exception(regs);
} else { } else {
......
...@@ -542,12 +542,11 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -542,12 +542,11 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
} }
NOKPROBE_SYMBOL(__do_page_fault); NOKPROBE_SYMBOL(__do_page_fault);
int do_page_fault(struct pt_regs *regs, unsigned long address, long do_page_fault(struct pt_regs *regs)
unsigned long error_code)
{ {
const struct exception_table_entry *entry; const struct exception_table_entry *entry;
enum ctx_state prev_state = exception_enter(); enum ctx_state prev_state = exception_enter();
int rc = __do_page_fault(regs, address, error_code); int rc = __do_page_fault(regs, regs->dar, regs->dsisr);
exception_exit(prev_state); exception_exit(prev_state);
if (likely(!rc)) if (likely(!rc))
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment