x86/fault: Further improve #PF oops messages
v3 cover x86/fault: Further improve #PF oops messages
Rework the messages printed for #PF oopses to display more detailed information about the fault in human readable form and to avoid conflicting messages and/or statements that may not always be accurate.
v3:
- Prepend a patch to reword the initial BUG message
- Add sample output in the changelogs
- Swap the order of the #PF lines. For most cases the three main lines show up in reverse fir-tree ordering and the cause of the fault is easy to pick out since it's the last thing highlighted by pr_alert (excepting when dumping the IDT, GDT, etc...).
v2:
- Explicitly call out protection keys violations
- "Slightly" reword the changelog
v1: https://lkml.kernel.org/r/[email protected]
v2: https://lkml.kernel.org/r/[email protected]
Sean Christopherson (2):
x86/fault: Reword initial BUG message for unhandled page faults x86/fault: Decode and print #PF oops in human readable form
arch/x86/mm/fault.c | 51 +++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 34 deletions(-)
Signature · 1 line
2.19.2
PATCH v3 1/2 x86/fault: Reword initial BUG message for unhandled page faults
Reword the NULL pointer dereference case to simply state that a NULL pointer was dereferenced, i.e. drop "unable to handle" as that implies that there are instances where the kernel actual does handle NULL pointer dereferences, which is not true barring funky exception fixup.
For the non-NULL case, replace "kernel paging request" with "page fault" as the kernel can technically oops on faults that originated in user code. Dropping "kernel" also allows future patches to provide detailed information on where the fault occurred, e.g. user vs. kernel, without conflicting with the initial BUG message.
In both cases, replace "at address=" with wording more appropriate to the oops, as "at" may be interpreted as stating that the address is the RIP of the instruction that faulted.
Last, and probably least, further qualify the NULL-pointer path by checking that the fault actually originated in kernel code. It's technically possible for userspace to map address 0, and not printing a super specific message is the least of our worries if the kernel does manage to oops on an actual NULL pointer dereference from userspace.
Before:
BUG: unable to handle kernel NULL pointer dereference at ffffbeef00000000
BUG: unable to handle kernel paging request at ffffbeef00000000After:
BUG: kernel NULL pointer dereference, address = 0000000000000008
BUG: unable to handle page fault for address = ffffbeef00000000--- arch/x86/mm/fault.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +6 -3
@@ -644,9 +644,12 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad from_kuid(&init_user_ns, current_uid())); } -pr_alert ("BUG: unable to handle kernel %s at %px\n" , - address <PAGE_SIZE ?"NULL pointer dereference" :"paging request" , - (void *)address); +if (address <PAGE_SIZE && !user_mode (regs)) +pr_alert ("BUG: kernel NULL pointer dereference, address = %px\n" , + (void *)address); +else +pr_alert ("BUG: unable to handle page fault for address = %px\n" , + (void *)address); err_txt[0 ] =0 ;
Signature · 1 line
2.19.2
tip-bot for Sean Christopherson
merge bot[tip:x86/mm] x86/fault: Reword initial BUG message for unhandled page faults
x86/fault: Reword initial BUG message for unhandled page faults
Commit-ID: f28b11a2abd9cf5535baa03e28fc63ad0e14f52a Gitweb: https://git.kernel.org/tip/f28b11a2abd9cf5535baa03e28fc63ad0e14f52a Author: Sean Christopherson <[email protected]> AuthorDate: Fri, 21 Dec 2018 13:36:56 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 19 Apr 2019 19:31:15 +0200
x86/fault: Reword initial BUG message for unhandled page faults
Reword the NULL pointer dereference case to simply state that a NULL pointer was dereferenced, i.e. drop "unable to handle" as that implies that there are instances where the kernel actual does handle NULL pointer dereferences, which is not true barring funky exception fixup.
For the non-NULL case, replace "kernel paging request" with "page fault" as the kernel can technically oops on faults that originated in user code. Dropping "kernel" also allows future patches to provide detailed information on where the fault occurred, e.g. user vs. kernel, without conflicting with the initial BUG message.
In both cases, replace "at address=" with wording more appropriate to the oops, as "at" may be interpreted as stating that the address is the RIP of the instruction that faulted.
Last, and probably least, further qualify the NULL-pointer path by checking that the fault actually originated in kernel code. It's technically possible for userspace to map address 0, and not printing a super specific message is the least of our worries if the kernel does manage to oops on an actual NULL pointer dereference from userspace.
Before:
BUG: unable to handle kernel NULL pointer dereference at ffffbeef00000000
BUG: unable to handle kernel paging request at ffffbeef00000000After:
BUG: kernel NULL pointer dereference, address = 0000000000000008
BUG: unable to handle page fault for address = ffffbeef00000000--- arch/x86/mm/fault.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +6 -3
@@ -644,9 +644,12 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad from_kuid(&init_user_ns, current_uid())); } -pr_alert ("BUG: unable to handle kernel %s at %px\n" , - address <PAGE_SIZE ?"NULL pointer dereference" :"paging request" , - (void *)address); +if (address <PAGE_SIZE && !user_mode (regs)) +pr_alert ("BUG: kernel NULL pointer dereference, address = %px\n" , + (void *)address); +else +pr_alert ("BUG: unable to handle page fault for address = %px\n" , + (void *)address); err_txt[0 ] =0 ;
PATCH v3 2/2 x86/fault: Decode and print #PF oops in human readable form
In reply to Sean ChristophersonLinus pointed out that deciphering the raw #PF error code and printing a more human readable message are two different things, and also that printing the negative cases is mostly just noise[1]. For example, the USER bit doesn't mean the fault originated in user code and stating that an oops wasn't due to a protection keys violation isn't interesting since an oops on a keys violation is a one-in-a-million scenario.
Remove the per-bit decoding of the error code and instead print:
- the raw error code
- why the fault occurred
- the effective privilege level of the access
- the type of access
- whether the fault originated in user code or kernel code
This provides the user with the information needed to triage 99.9% of oopses without polluting the log with useless information or conflating the error_code with the CPL.
Sample output:
BUG: kernel NULL pointer dereference, address = 0000000000000008
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffbeef00000000
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffc90000230000
#PF: supervisor-privileged write access from kernel code
#PF: error_code(0x000b) - reserved bit violation[1] https://lkml.kernel.org/r/CAHk-=whk_fsnxVMvF1T2fFCaP2WrvSybABrLQCWLJyCvHw6NKA@mail.gmail.com
--- arch/x86/mm/fault.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
arch/x86/mm/fault.c +11 -31
@@ -603,24 +603,9 @@ static void show_ldttss(const struct desc_ptr *gdt, const char *name, u16 index) name, index, addr, (desc.limit0 | (desc.limit1 << 16))); } -/* -* This helper function transforms the #PF error_code bits into -* "[PROT] [USER]" type of descriptive, almost human-readable error strings: -*/ -static void err_str_append (unsigned long error_code,char *buf,unsigned long mask,const char *txt) -{ -if (error_code & mask) { -if (buf[0 ]) -strcat (buf," " ); -strcat (buf, txt); - } -} -static void show_fault_oops (struct pt_regs *regs,unsigned long error_code,unsigned long address) { -char err_txt[64 ]; -if (!oops_may_print ())return ;
@@ -651,27 +636,22 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long adpr_alert ("BUG: unable to handle page fault for address = %px\n" , (void *)address); - err_txt[0 ] =0 ; - -/* -* Note: length of these appended strings including the separation space and the -* zero delimiter must fit into err_txt[]. -*/ -err_str_append (error_code, err_txt,X86_PF_PROT ,"[PROT]" ); -err_str_append (error_code, err_txt,X86_PF_WRITE ,"[WRITE]" ); -err_str_append (error_code, err_txt,X86_PF_USER ,"[USER]" ); -err_str_append (error_code, err_txt,X86_PF_RSVD ,"[RSVD]" ); -err_str_append (error_code, err_txt,X86_PF_INSTR ,"[INSTR]" ); -err_str_append (error_code, err_txt,X86_PF_PK ,"[PK]" ); - -pr_alert ("#PF error: %s\n" , error_code ? err_txt :"[normal kernel read fault]" ); +pr_alert ("#PF: %s-privileged %s from %s code\n" , + (error_code &X86_PF_USER ) ?"user" :"supervisor" , + (error_code &X86_PF_INSTR ) ?"instruction fetch" : + (error_code &X86_PF_WRITE ) ?"write access" : +"read access" , +user_mode (regs) ?"user" :"kernel" ); +pr_alert ("#PF: error_code(0x%04lx) - %s\n" , error_code, + !(error_code &X86_PF_PROT ) ?"not-present page" : + (error_code &X86_PF_RSVD ) ?"reserved bit violation" : + (error_code &X86_PF_PK ) ?"protection keys violation" : +"permissions violation" );if (!(error_code &X86_PF_USER ) &&user_mode (regs)) {struct desc_ptr idt, gdt;u16 ldtr, tr; -pr_alert ("This was a system access from user code\n" ); -/* * This can happen for quite a few reasons. The more obvious * ones are faults accessing the GDT, or LDT. Perhaps
Signature · 1 line
2.19.2
tip-bot for Sean Christopherson
merge bot[tip:x86/mm] x86/fault: Decode and print #PF oops in human readable form
x86/fault: Decode and print #PF oops in human readable form
Commit-ID: 18ea35c5ed9921867194a8efc2a0ac2d5a3c7d2a Gitweb: https://git.kernel.org/tip/18ea35c5ed9921867194a8efc2a0ac2d5a3c7d2a Author: Sean Christopherson <[email protected]> AuthorDate: Fri, 21 Dec 2018 13:36:57 -0800 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 19 Apr 2019 19:31:16 +0200
x86/fault: Decode and print #PF oops in human readable form
Linus pointed out that deciphering the raw #PF error code and printing a more human readable message are two different things, and also that printing the negative cases is mostly just noise[1]. For example, the USER bit doesn't mean the fault originated in user code and stating that an oops wasn't due to a protection keys violation isn't interesting since an oops on a keys violation is a one-in-a-million scenario.
Remove the per-bit decoding of the error code and instead print:
- the raw error code
- why the fault occurred
- the effective privilege level of the access
- the type of access
- whether the fault originated in user code or kernel code
This provides the user with the information needed to triage 99.9% of oopses without polluting the log with useless information or conflating the error_code with the CPL.
Sample output:
BUG: kernel NULL pointer dereference, address = 0000000000000008
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffbeef00000000
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffc90000230000
#PF: supervisor-privileged write access from kernel code
#PF: error_code(0x000b) - reserved bit violation[1] https://lkml.kernel.org/r/CAHk-=whk_fsnxVMvF1T2fFCaP2WrvSybABrLQCWLJyCvHw6NKA@mail.gmail.com
--- arch/x86/mm/fault.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)
arch/x86/mm/fault.c +11 -31
@@ -603,24 +603,9 @@ static void show_ldttss(const struct desc_ptr *gdt, const char *name, u16 index) name, index, addr, (desc.limit0 | (desc.limit1 << 16))); } -/* -* This helper function transforms the #PF error_code bits into -* "[PROT] [USER]" type of descriptive, almost human-readable error strings: -*/ -static void err_str_append (unsigned long error_code,char *buf,unsigned long mask,const char *txt) -{ -if (error_code & mask) { -if (buf[0 ]) -strcat (buf," " ); -strcat (buf, txt); - } -} -static void show_fault_oops (struct pt_regs *regs,unsigned long error_code,unsigned long address) { -char err_txt[64 ]; -if (!oops_may_print ())return ;
@@ -651,27 +636,22 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long adpr_alert ("BUG: unable to handle page fault for address = %px\n" , (void *)address); - err_txt[0 ] =0 ; - -/* -* Note: length of these appended strings including the separation space and the -* zero delimiter must fit into err_txt[]. -*/ -err_str_append (error_code, err_txt,X86_PF_PROT ,"[PROT]" ); -err_str_append (error_code, err_txt,X86_PF_WRITE ,"[WRITE]" ); -err_str_append (error_code, err_txt,X86_PF_USER ,"[USER]" ); -err_str_append (error_code, err_txt,X86_PF_RSVD ,"[RSVD]" ); -err_str_append (error_code, err_txt,X86_PF_INSTR ,"[INSTR]" ); -err_str_append (error_code, err_txt,X86_PF_PK ,"[PK]" ); - -pr_alert ("#PF error: %s\n" , error_code ? err_txt :"[normal kernel read fault]" ); +pr_alert ("#PF: %s-privileged %s from %s code\n" , + (error_code &X86_PF_USER ) ?"user" :"supervisor" , + (error_code &X86_PF_INSTR ) ?"instruction fetch" : + (error_code &X86_PF_WRITE ) ?"write access" : +"read access" , +user_mode (regs) ?"user" :"kernel" ); +pr_alert ("#PF: error_code(0x%04lx) - %s\n" , error_code, + !(error_code &X86_PF_PROT ) ?"not-present page" : + (error_code &X86_PF_RSVD ) ?"reserved bit violation" : + (error_code &X86_PF_PK ) ?"protection keys violation" : +"permissions violation" );if (!(error_code &X86_PF_USER ) &&user_mode (regs)) {struct desc_ptr idt, gdt;u16 ldtr, tr; -pr_alert ("This was a system access from user code\n" ); -/* * This can happen for quite a few reasons. The more obvious * ones are faults accessing the GDT, or LDT. Perhaps
Borislav Petkov
maintainerRe: [tip:x86/mm] x86/fault: Decode and print #PF oops in human readable form
Quoted 11 lines · tip-bot for Sean Christopherson
BUG: kernel NULL pointer dereference, address = 0000000000000008
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffbeef00000000
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffc90000230000
#PF: supervisor-privileged write access from kernel code
#PF: error_code(0x000b) - reserved bit violationWriting those in human-readable form is nice. May I suggest making those messages more succinct, though - we'll be staring at them for years, after all.
---
From: Borislav Petkov <[email protected]>
Date: Sun, 21 Apr 2019 20:24:08 +0200
Subject: [PATCH] x86/fault: Make fault messages more succinct
So we are going to be staring at those in the next years, let's make them more succinct. In particular:
- change "address = " to "address: "
- "-privileged" reads funny. It should be simply "kernel" or "user"
- "from kernel code" reads funny too. "kernel mode" or "user mode" is more natural.
An actual example says more than 1000 words, of course:
[ 0.248370] BUG: kernel NULL pointer dereference, address: 00000000000005b8 [ 0.249120] #PF: supervisor write access in kernel mode [ 0.249717] #PF: error_code(0x0002) - not-present page
--- arch/x86/mm/fault.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +3 -3
@@ -630,13 +630,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad }if (address <PAGE_SIZE && !user_mode (regs)) -pr_alert ("BUG: kernel NULL pointer dereference, address = %px\n" , +pr_alert ("BUG: kernel NULL pointer dereference, address: %px\n" , (void *)address);else -pr_alert ("BUG: unable to handle page fault for address = %px\n" , +pr_alert ("BUG: unable to handle page fault for address: %px\n" , (void *)address); -pr_alert ("#PF: %s-privileged %s from %s code\n" , +pr_alert ("#PF: %s %s in %s mode\n" , (error_code &X86_PF_USER ) ?"user" :"supervisor" , (error_code &X86_PF_INSTR ) ?"instruction fetch" : (error_code & X86_PF_WRITE) ? "write access" :
Signature · 7 lines
2.21.0
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.tip-bot for Borislav Petkov
merge bot[tip:x86/mm] x86/fault: Make fault messages more succinct
x86/fault: Make fault messages more succinct
Commit-ID: ea2f8d60603efbd1cb4e193a593945a2fe24d264 Gitweb: https://git.kernel.org/tip/ea2f8d60603efbd1cb4e193a593945a2fe24d264 Author: Borislav Petkov <[email protected]> AuthorDate: Sun, 21 Apr 2019 20:35:24 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Sun, 21 Apr 2019 20:48:51 +0200
x86/fault: Make fault messages more succinct
So we are going to be staring at those in the next years, let's make them more succinct. In particular:
- change "address = " to "address: "
- "-privileged" reads funny. It should be simply "kernel" or "user"
- "from kernel code" reads funny too. "kernel mode" or "user mode" is more natural.
An actual example says more than 1000 words, of course:
[ 0.248370] BUG: kernel NULL pointer dereference, address: 00000000000005b8 [ 0.249120] #PF: supervisor write access in kernel mode [ 0.249717] #PF: error_code(0x0002) - not-present page
--- arch/x86/mm/fault.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/fault.c +3 -3
@@ -630,13 +630,13 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long ad }if (address <PAGE_SIZE && !user_mode (regs)) -pr_alert ("BUG: kernel NULL pointer dereference, address = %px\n" , +pr_alert ("BUG: kernel NULL pointer dereference, address: %px\n" , (void *)address);else -pr_alert ("BUG: unable to handle page fault for address = %px\n" , +pr_alert ("BUG: unable to handle page fault for address: %px\n" , (void *)address); -pr_alert ("#PF: %s-privileged %s from %s code\n" , +pr_alert ("#PF: %s %s in %s mode\n" , (error_code &X86_PF_USER ) ?"user" :"supervisor" , (error_code &X86_PF_INSTR ) ?"instruction fetch" : (error_code & X86_PF_WRITE) ? "write access" :
Re: [PATCH v3 2/2] x86/fault: Decode and print #PF oops in human readable form
In reply to Sean ChristophersonQuoted 21 lines · Sean Christopherson
Linus pointed out that deciphering the raw #PF error code and printing a more human readable message are two different things, and also that printing the negative cases is mostly just noise[1]. For example, the USER bit doesn't mean the fault originated in user code and stating that an oops wasn't due to a protection keys violation isn't interesting since an oops on a keys violation is a one-in-a-million scenario.
Remove the per-bit decoding of the error code and instead print:
- the raw error code
- why the fault occurred
- the effective privilege level of the access
- the type of access
- whether the fault originated in user code or kernel codeThis provides the user with the information needed to triage 99.9% of oopses without polluting the log with useless information or conflating the
error_codewith the CPL.Sample output:
Quoted 11 lines
BUG: kernel NULL pointer dereference, address = 0000000000000008
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffbeef00000000
#PF: supervisor-privileged instruction fetch from kernel code
#PF: error_code(0x0010) - not-present page
BUG: unable to handle page fault for address = ffffc90000230000
#PF: supervisor-privileged write access from kernel code
#PF: error_code(0x000b) - reserved bit violationAs a note for future.
I see 3 recent changes that shuffle crash format forth and back:
ea2f8d60603efbd1cb4e193a593945a2fe24d264 x86/fault: Make fault messages more succinct f28b11a2abd9cf5535baa03e28fc63ad0e14f52a x86/fault: Reword initial BUG message for unhandled page faults 18ea35c5ed9921867194a8efc2a0ac2d5a3c7d2a x86/fault: Decode and print #PF oops in human readable form
Ideally, such changes are coordinated with kernel testing for gradual rollout. Since kernel does not provide an official facility for crash parsing, the actual output effectively becomes part of public API. Such changes in format may lead to glues bugs, not duped bugs and missed bugs (including incorrect bisection, when something stopped being detected as a crash at all).
Ideally-ideally, kernel provides some kind official output parsing facility (that can understand when kernel has bugged, when the crash starts/end and some kind of stable identity for a crash) and includes output parsing tests for all types of crashes because this types kernel sabotaging testing happens periodically.
We already have samples for "address =" format, but not for "address:" yet. So I still can't update parsing for the final format and we have massively glued crash reports.
Quoted 90 lines
[1] https://lkml.kernel.org/r/CAHk-=whk_fsnxVMvF1T2fFCaP2WrvSybABrLQCWLJyCvHw6NKA@mail.gmail.com
Suggested-by Linus Torvalds <[email protected]>Cc Andy Lutomirski <[email protected]>Cc Borislav Petkov <[email protected]>Cc Dave Hansen <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Linus Torvalds <[email protected]>Cc Peter Zijlstra <[email protected]>Cc Rik van Riel <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Yu-cheng Yu <[email protected]>Cc Ingo Molnar <[email protected]>Signed-off-by Sean Christopherson <[email protected]>--- arch/x86/mm/fault.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-)arch/x86/mm/fault.c +11
-32@@ -603,24 +603,9 @@ static void show_ldttss(const struct desc_ptr *gdt, const char *name, u16 index) name, index, addr, (desc.limit0 | (desc.limit1 << 16))); } -/* -* This helper function transforms the #PF error_code bits into -* "[PROT] [USER]" type of descriptive, almost human-readable error strings: -*/ -static void err_str_append (unsigned long error_code,char *buf,unsigned long mask,const char *txt) -{ -if (error_code & mask) { -if (buf[0 ]) -strcat (buf," " ); -strcat (buf, txt); - } -} -static void show_fault_oops (struct pt_regs *regs,unsigned long error_code,unsigned long address) { -char err_txt[64 ]; -if (!oops_may_print ())return ;@@ -651,27 +636,22 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code, unsigned long adpr_alert ("BUG: unable to handle page fault for address = %px\n" , (void *)address); - err_txt[0 ] =0 ; - -/* -* Note: length of these appended strings including the separation space and the -* zero delimiter must fit into err_txt[]. -*/ -err_str_append (error_code, err_txt,X86_PF_PROT ,"[PROT]" ); -err_str_append (error_code, err_txt,X86_PF_WRITE ,"[WRITE]" ); -err_str_append (error_code, err_txt,X86_PF_USER ,"[USER]" ); -err_str_append (error_code, err_txt,X86_PF_RSVD ,"[RSVD]" ); -err_str_append (error_code, err_txt,X86_PF_INSTR ,"[INSTR]" ); -err_str_append (error_code, err_txt,X86_PF_PK ,"[PK]" ); - -pr_alert ("#PF error: %s\n" , error_code ? err_txt :"[normal kernel read fault]" ); +pr_alert ("#PF: %s-privileged %s from %s code\n" , + (error_code &X86_PF_USER ) ?"user" :"supervisor" , + (error_code &X86_PF_INSTR ) ?"instruction fetch" : + (error_code &X86_PF_WRITE ) ?"write access" : +"read access" , +user_mode (regs) ?"user" :"kernel" ); +pr_alert ("#PF: error_code(0x%04lx) - %s\n" , error_code, + !(error_code &X86_PF_PROT ) ?"not-present page" : + (error_code &X86_PF_RSVD ) ?"reserved bit violation" : + (error_code &X86_PF_PK ) ?"protection keys violation" : +"permissions violation" );if (!(error_code &X86_PF_USER ) &&user_mode (regs)) {struct desc_ptr idt, gdt;u16 ldtr, tr; -pr_alert ("This was a system access from user code\n" ); -/* * This can happen for quite a few reasons. The more obvious * ones are faults accessing the GDT, or LDT. Perhaps -- 2.19.2
Borislav Petkov
maintainerRe: [PATCH v3 2/2] x86/fault: Decode and print #PF oops in human readable form
Quoted 3 lines · Dmitry Vyukov
Ideally, such changes are coordinated with kernel testing for gradual rollout. Since kernel does not provide an official facility for crash parsing, the actual output effectively becomes part of public API.
Well, printk message formats are not an API. I agree, though, that if this is how kernel testing is going to get told about crashes, then we'd need some sort of parsing specification which gets changed together with when the actual messages are changed, so that tools don't break.
Or something slicker and more robust than tools parsing dmesg output...
Signature · 4 lines
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.High latency ping. These still apply as-is.
Quoted 29 lines · Sean Christopherson
Rework the messages printed for #PF oopses to display more detailed information about the fault in human readable form and to avoid conflicting messages and/or statements that may not always be accurate.
v3:
- Prepend a patch to reword the initial BUG message
- Add sample output in the changelogs
- Swap the order of the #PF lines. For most cases the three main lines show up in reverse fir-tree ordering and the cause of the fault is easy to pick out since it's the last thing highlighted bypr_alert(excepting when dumping the IDT, GDT, etc...).v2:
- Explicitly call out protection keys violations
- "Slightly" reword the changelogv1: https://lkml.kernel.org/r/[email protected]
v2: https://lkml.kernel.org/r/[email protected]Sean Christopherson (2):
x86/fault: Reword initial BUG message for unhandled page faults x86/fault: Decode and print #PF oops in human readable formarch/x86/mm/fault.c | 51 +++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 34 deletions(-)Signature · 1 line
2.19.2