]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: mm: Add page fault trace points
authorNam Cao <namcao@linutronix.de>
Wed, 9 Jul 2025 19:21:19 +0000 (21:21 +0200)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Wed, 9 Jul 2025 19:27:01 +0000 (15:27 -0400)
Add page fault trace points, which are useful to implement RV monitor that
watches page faults.

Signed-off-by: Nam Cao <namcao@linutronix.de>
Acked-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
arch/riscv/mm/fault.c

index 0194324a0c5060dd6e205166c34c79480e0f7960..04ed6f8acae4fd0ecb175ef7520da381a8cbecf6 100644 (file)
@@ -20,6 +20,9 @@
 #include <asm/ptrace.h>
 #include <asm/tlbflush.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/exceptions.h>
+
 #include "../kernel/head.h"
 
 static void show_pte(unsigned long addr)
@@ -291,6 +294,11 @@ void handle_page_fault(struct pt_regs *regs)
        if (kprobe_page_fault(regs, cause))
                return;
 
+       if (user_mode(regs))
+               trace_page_fault_user(addr, regs, cause);
+       else
+               trace_page_fault_kernel(addr, regs, cause);
+
        /*
         * Fault-in kernel-space virtual memory on-demand.
         * The 'reference' page table is init_mm.pgd.