small instrumentation updates
Ingo,
Please pull the perf/core branch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
perf/core
Thanks,
Frederic
---
Borislav Petkov (1):
tracing: Fix function-graph build warning on 32-bit
Frederic Weisbecker (1):
x86: Barf when vmalloc and kmemcheck faults happen in NMI
arch/x86/mm/fault.c | 4 ++++ arch/x86/mm/kmemcheck/kmemcheck.c | 2 ++ kernel/trace/trace_functions_graph.c | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-)
PATCH 1/2 tracing: Fix function-graph build warning on 32-bit
From: Borislav Petkov <[email protected]>
Fix
kernel/trace/trace_functions_graph.c: In function ‘trace_print_graph_duration’:kernel/trace/trace_functions_graph.c:652: warning: comparison of distinct pointer types lacks a cast
when building 36-rc6 on a 32-bit due to the strict type check failing in the min() macro.
LKML-Reference: <[email protected]>
--- kernel/trace/trace_functions_graph.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_functions_graph.c +3 -2
@@ -665,8 +665,9 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s)/* Print nsecs (we don't want to exceed 7 numbers) */ if (len <7 ) { -snprintf (nsecs_str,min (sizeof (nsecs_str),8UL - len),"%03lu" , - nsecs_rem); +size_t slen =min_t (size_t,sizeof (nsecs_str),8UL - len); + +snprintf (nsecs_str, slen,"%03lu" , nsecs_rem); ret =trace_seq_printf (s,".%s" , nsecs_str);if (!ret)return TRACE_TYPE_PARTIAL_LINE ;
Signature · 1 line
1.6.2.3
PATCH 2/2 x86: Barf when vmalloc and kmemcheck faults happen in NMI
In reply to Frederic WeisbeckerIn x86, faults exit by executing the iret instruction, which then reenables NMIs if we faulted in NMI context. Then if a fault happens in NMI, another NMI can nest after the fault exits.
But we don't yet support nested NMIs because we have only one NMI stack. To prevent from that, check that vmalloc and kmemcheck faults don't happen in this context. Most of the other kernel faults in NMIs can be more easily spotted by finding explicit copy_from,to_user() calls on review.
--- arch/x86/mm/fault.c | 4 ++++ arch/x86/mm/kmemcheck/kmemcheck.c | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-)
arch/x86/mm/fault.c +4 -0
@@ -251,6 +251,8 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)if (!(address >=VMALLOC_START && address <VMALLOC_END ))return -1 ; +WARN_ON_ONCE (in_nmi ()); +/* * Synchronize this task's top level page-table * with the 'reference' page table.
@@ -369,6 +371,8 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)if (!(address >=VMALLOC_START && address <VMALLOC_END ))return -1 ; +WARN_ON_ONCE (in_nmi ()); +/* * Copy kernel mappings over when needed. This can also * happen within a race in page table update. In the later
arch/x86/mm/kmemcheck/kmemcheck.c +2 -0
@@ -631,6 +631,8 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,if (!pte)return false; +WARN_ON_ONCE (in_nmi ()); +if (error_code &2 )kmemcheck_access (regs, address,KMEMCHECK_WRITE );else
Signature · 1 line
1.6.2.3
Quoted 14 lines · Frederic Weisbecker
Ingo,
Please pull the perf/core branch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/random-tracing.git
perf/coreThanks,
Frederic
---Borislav Petkov (1):
tracing: Fix function-graph build warning on 32-bit
Quoted 8 lines
Frederic Weisbecker (1):
x86: Barf when vmalloc and kmemcheck faults happen in NMIarch/x86/mm/fault.c | 4 ++++ arch/x86/mm/kmemcheck/kmemcheck.c | 2 ++ kernel/trace/trace_functions_graph.c | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-)
Pulled, thanks a lot Frederic!
Ingo