ANDROID: arm64: add vendor hooks for unusal abort cases

Add hooks to gather data of unsual aborts and summarize it with
other information.

Bug: 273189923

Signed-off-by: Sangmoon Kim <sangmoon.kim@samsung.com>
Change-Id: I74eb36b8551ed9a5e6dc87507939a7f4d81c9c18
(cherry picked from commit 102255d1e4)
This commit is contained in:
Sangmoon Kim
2021-01-19 21:24:58 +09:00
committed by Todd Kjos
parent 2d9a325f0c
commit bb8c223f2f
4 changed files with 51 additions and 0 deletions

View File

@@ -27,6 +27,8 @@
#include <asm/sysreg.h>
#include <asm/system_misc.h>
#include <trace/hooks/traps.h>
/*
* Handle IRQ/context state management when entering from kernel mode.
* Before this function is called it is not safe to call regular kernel code,
@@ -292,6 +294,7 @@ static void noinstr __panic_unhandled(struct pt_regs *regs, const char *vector,
vector, smp_processor_id(), esr,
esr_get_class_string(esr));
trace_android_rvh_panic_unhandled(regs, vector, esr);
__show_regs(regs);
panic("Unhandled exception");
}

View File

@@ -46,6 +46,8 @@
#include <asm/system_misc.h>
#include <asm/sysreg.h>
#include <trace/hooks/traps.h>
static bool __kprobes __check_eq(unsigned long pstate)
{
return (pstate & PSR_Z_BIT) != 0;
@@ -495,6 +497,7 @@ void do_undefinstr(struct pt_regs *regs, unsigned long esr)
if (call_undef_hook(regs) == 0)
return;
trace_android_rvh_do_undefinstr(regs, esr);
if (!user_mode(regs))
die("Oops - Undefined instruction", regs, esr);
@@ -509,6 +512,7 @@ void do_el0_bti(struct pt_regs *regs)
void do_el1_bti(struct pt_regs *regs, unsigned long esr)
{
trace_android_rvh_do_el1_bti(regs, esr);
die("Oops - BTI", regs, esr);
}
NOKPROBE_SYMBOL(do_el1_bti);
@@ -524,6 +528,7 @@ void do_el1_fpac(struct pt_regs *regs, unsigned long esr)
* Unexpected FPAC exception in the kernel: kill the task before it
* does any more harm.
*/
trace_android_rvh_do_el1_fpac(regs, esr);
die("Oops - FPAC", regs, esr);
}
NOKPROBE_SYMBOL(do_el1_fpac)
@@ -915,6 +920,8 @@ void __noreturn arm64_serror_panic(struct pt_regs *regs, unsigned long esr)
pr_crit("SError Interrupt on CPU%d, code 0x%016lx -- %s\n",
smp_processor_id(), esr, esr_get_class_string(esr));
trace_android_rvh_arm64_serror_panic(regs, esr);
if (regs)
__show_regs(regs);

View File

@@ -53,6 +53,7 @@
#include <trace/hooks/softlockup.h>
#include <trace/hooks/power.h>
#include <trace/hooks/fault.h>
#include <trace/hooks/traps.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -165,3 +166,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo_unfrozen);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_die_kernel_fault);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sea);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_sp_pc_abort);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_undefinstr);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_el1_bti);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_el1_fpac);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_panic_unhandled);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_arm64_serror_panic);

View File

@@ -0,0 +1,35 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM traps
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_TRAPS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_TRAPS_H
#include <trace/hooks/vendor_hooks.h>
struct pt_regs;
DECLARE_RESTRICTED_HOOK(android_rvh_do_undefinstr,
TP_PROTO(struct pt_regs *regs, unsigned long esr),
TP_ARGS(regs, esr),
TP_CONDITION(!user_mode(regs)));
DECLARE_RESTRICTED_HOOK(android_rvh_do_el1_bti,
TP_PROTO(struct pt_regs *regs, unsigned long esr),
TP_ARGS(regs, esr), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_do_el1_fpac,
TP_PROTO(struct pt_regs *regs, unsigned long esr),
TP_ARGS(regs, esr), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_panic_unhandled,
TP_PROTO(struct pt_regs *regs, const char *vector, unsigned long esr),
TP_ARGS(regs, vector, esr), 1);
DECLARE_RESTRICTED_HOOK(android_rvh_arm64_serror_panic,
TP_PROTO(struct pt_regs *regs, unsigned long esr),
TP_ARGS(regs, esr), 1);
#endif /* _TRACE_HOOK_TRAPS_H */
/* This part must be outside protection */
#include <trace/define_trace.h>