ANDROID: fix add vendor hooks for unusual abort cases

Add hooks to check the do_serror can be recover or not.
When PCIe encounters completion timeout, PCIe hardware will
reply slave error to bus, which will causes the system to panic.

Bug: 247846368

Signed-off-by: qizhong cheng <qizhong.cheng@mediatek.com>
Change-Id: Iaef6c9a6ac07e552939c0f8e386213cb930cfb6e
(cherry picked from commit a89fbc0de097cf73f7203f60e4d3fdca1439afd7)
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 33f9b87..0f04969 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -947,6 +947,13 @@ bool arm64_is_fatal_ras_serror(struct pt_regs *regs, unsigned int esr)
 
 void do_serror(struct pt_regs *regs, unsigned int esr)
 {
+	int ret = 0;
+
+	/* Add vendor hooks for unusual abort cases */
+	trace_android_rvh_do_serror(regs, esr, &ret);
+	if (ret != 0)
+		return;
+
 	/* non-RAS errors are not containable */
 	if (!arm64_is_ras_serror(esr) || arm64_is_fatal_ras_serror(regs, esr))
 		arm64_serror_panic(regs, esr);
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c
index 4efa32b..00183a1 100644
--- a/drivers/android/vendor_hooks.c
+++ b/drivers/android/vendor_hooks.c
@@ -281,6 +281,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_undefinstr);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_ptrauth_fault);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_panic_unhandled);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_arm64_serror_panic);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_serror);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vmpressure);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sha256);
 EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_aes_expandkey);
diff --git a/include/trace/hooks/traps.h b/include/trace/hooks/traps.h
index 04f1c29..4357f80 100644
--- a/include/trace/hooks/traps.h
+++ b/include/trace/hooks/traps.h
@@ -31,6 +31,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_arm64_serror_panic,
 	TP_PROTO(struct pt_regs *regs, unsigned int esr),
 	TP_ARGS(regs, esr), 1);
 
+DECLARE_RESTRICTED_HOOK(android_rvh_do_serror,
+	TP_PROTO(struct pt_regs *regs, unsigned int esr, int *ret),
+	TP_ARGS(regs, esr, ret), 1);
+
 #endif /* _TRACE_HOOK_TRAPS_H */
 /* This part must be outside protection */
 #include <trace/define_trace.h>