DSISR has a bit to tell if the fault is due to a read or a write.
Display it.
Signed-off-by: Christophe Leroy <redacted>
---
arch/powerpc/mm/fault.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -645,6 +645,7 @@ NOKPROBE_SYMBOL(do_page_fault);voidbad_page_fault(structpt_regs*regs,unsignedlongaddress,intsig){conststructexception_table_entry*entry;+intis_write=page_fault_is_write(regs->dsisr);/* Are we prepared to handle this fault? */if((entry=search_exception_tables(regs->nip))!=NULL){
@@ -658,9 +659,10 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)case0x300:case0x380:case0xe00:-pr_alert("BUG: %s at 0x%08lx\n",+pr_alert("BUG: %s on %s at 0x%08lx\n",regs->dar<PAGE_SIZE?"Kernel NULL pointer dereference":-"Unable to handle kernel data access",regs->dar);+"Unable to handle kernel data access",+is_write?"write":"read",regs->dar);break;case0x400:case0x480:
@@ -645,6 +645,7 @@ NOKPROBE_SYMBOL(do_page_fault);voidbad_page_fault(structpt_regs*regs,unsignedlongaddress,intsig){conststructexception_table_entry*entry;+intis_write=page_fault_is_write(regs->dsisr);/* Are we prepared to handle this fault? */if((entry=search_exception_tables(regs->nip))!=NULL){
@@ -658,9 +659,10 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)case0x300:case0x380:case0xe00:-pr_alert("BUG: %s at 0x%08lx\n",+pr_alert("BUG: %s on %s at 0x%08lx\n",regs->dar<PAGE_SIZE?"Kernel NULL pointer dereference":-"Unable to handle kernel data access",regs->dar);+"Unable to handle kernel data access",+is_write?"write":"read",regs->dar);break;case0x400:case0x480:
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2019-08-29 12:14:45
Christophe Leroy [off-list ref] writes:
DSISR has a bit to tell if the fault is due to a read or a write.
Except some CPUs don't have a DSISR?
Which is why we have page_fault_is_write() that's used in
__do_page_fault().
Or is that old cruft?
I see eg. in head_40x.S we pass r5=0 for error code, and we don't set
regs->dsisr anywhere AFAICS. So it might just contain some junk.
cheers
@@ -645,6 +645,7 @@ NOKPROBE_SYMBOL(do_page_fault);voidbad_page_fault(structpt_regs*regs,unsignedlongaddress,intsig){conststructexception_table_entry*entry;+intis_write=page_fault_is_write(regs->dsisr);/* Are we prepared to handle this fault? */if((entry=search_exception_tables(regs->nip))!=NULL){
@@ -658,9 +659,10 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)case0x300:case0x380:case0xe00:-pr_alert("BUG: %s at 0x%08lx\n",+pr_alert("BUG: %s on %s at 0x%08lx\n",regs->dar<PAGE_SIZE?"Kernel NULL pointer dereference":-"Unable to handle kernel data access",regs->dar);+"Unable to handle kernel data access",+is_write?"write":"read",regs->dar);
DSISR has a bit to tell if the fault is due to a read or a write.
Except some CPUs don't have a DSISR?
Which is why we have page_fault_is_write() that's used in
__do_page_fault().
Or is that old cruft?
I see eg. in head_40x.S we pass r5=0 for error code, and we don't set
regs->dsisr anywhere AFAICS. So it might just contain some junk.
But then we have a problem with show_regs() as well, havent't we ?
if (trap == 0x200 || trap == 0x300 || trap == 0x600)
#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
pr_cont("DEAR: "REG" ESR: "REG" ", regs->dar, regs->dsisr);
#else
pr_cont("DAR: "REG" DSISR: %08lx ", regs->dar, regs->dsisr);
#endif
I need to look closer.
Christophe
@@ -645,6 +645,7 @@ NOKPROBE_SYMBOL(do_page_fault);voidbad_page_fault(structpt_regs*regs,unsignedlongaddress,intsig){conststructexception_table_entry*entry;+intis_write=page_fault_is_write(regs->dsisr);/* Are we prepared to handle this fault? */if((entry=search_exception_tables(regs->nip))!=NULL){
@@ -658,9 +659,10 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)case0x300:case0x380:case0xe00:-pr_alert("BUG: %s at 0x%08lx\n",+pr_alert("BUG: %s on %s at 0x%08lx\n",regs->dar<PAGE_SIZE?"Kernel NULL pointer dereference":-"Unable to handle kernel data access",regs->dar);+"Unable to handle kernel data access",+is_write?"write":"read",regs->dar);
DSISR has a bit to tell if the fault is due to a read or a write.
Except some CPUs don't have a DSISR?
Which is why we have page_fault_is_write() that's used in
__do_page_fault().
And that's why I'm also using page_fault_is_write() in my patch.
Or is that old cruft?
I see eg. in head_40x.S we pass r5=0 for error code, and we don't set
regs->dsisr anywhere AFAICS. So it might just contain some junk.
We pass r5=0 in ISI but r5=SPRN_ESR in DSI.
And r5 is also saved into _ESR(r11)
And in asm-offset.c, we have:
STACK_PT_REGS_OFFSET(_ESR, dsisr);
So regs->dsisr has the expected content.
Christophe
@@ -645,6 +645,7 @@ NOKPROBE_SYMBOL(do_page_fault);voidbad_page_fault(structpt_regs*regs,unsignedlongaddress,intsig){conststructexception_table_entry*entry;+intis_write=page_fault_is_write(regs->dsisr);/* Are we prepared to handle this fault? */if((entry=search_exception_tables(regs->nip))!=NULL){
@@ -658,9 +659,10 @@ void bad_page_fault(struct pt_regs *regs, unsigned long address, int sig)case0x300:case0x380:case0xe00:-pr_alert("BUG: %s at 0x%08lx\n",+pr_alert("BUG: %s on %s at 0x%08lx\n",regs->dar<PAGE_SIZE?"Kernel NULL pointer dereference":-"Unable to handle kernel data access",regs->dar);+"Unable to handle kernel data access",+is_write?"write":"read",regs->dar);