ANDROID: vendor_hooks: FPSIMD save/restore by using vendor_hooks
- To use fpsimd in kernel task, vendor_hook call is needed to
save/restore fpsimd at scheduling time.
- ANDROID_VENDOR_DATA added to thread_struct.
- Vendor_hooks is called when thread is switching for save/restore
fpsimd states.
(trace_android_vh_is_fpsimd_save(prev, next))
This patch was previously in android-mainline, but was reverted
due to conflicts in the 6.2-rc1 merge (aosp/2365029). Adding back.
Bug: 149632552
Bug: 313805669
Change-Id: Ibaa13484d1251fc53c304972f46e8e8a2c1df7fa
Signed-off-by: Wooyeon Kim <wooy88.kim@samsung.com>
Signed-off-by: Jing-Ting Wu <Jing-Ting.Wu@mediatek.com>
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index f773712..a87fca8c 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -31,6 +31,7 @@
#include <linux/stddef.h>
#include <linux/string.h>
#include <linux/thread_info.h>
+#include <linux/android_vendor.h>
#include <vdso/processor.h>
@@ -184,6 +185,7 @@ struct thread_struct {
u64 sctlr_user;
u64 svcr;
u64 tpidr2_el0;
+ ANDROID_VENDOR_DATA(1);
};
static inline unsigned int thread_get_vl(struct thread_struct *thread,
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 740e11c..c4988cf 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -42,6 +42,7 @@
#include <linux/prctl.h>
#include <linux/stacktrace.h>
#include <trace/hooks/mpam.h>
+#include <trace/hooks/fpsimd.h>
#include <asm/alternative.h>
#include <asm/compat.h>
@@ -557,6 +558,8 @@ struct task_struct *__switch_to(struct task_struct *prev,
if (prev->thread.sctlr_user != next->thread.sctlr_user)
update_sctlr_el1(next->thread.sctlr_user);
+ trace_android_vh_is_fpsimd_save(prev, next);
+
/* the actual thread switch */
last = cpu_switch_to(prev, next);
diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c
index ac264e4..67b7dc1 100644
--- a/drivers/android/vendor_hooks.c
+++ b/drivers/android/vendor_hooks.c
@@ -34,6 +34,7 @@
#include <trace/hooks/gic_v3.h>
#include <trace/hooks/remoteproc.h>
#include <trace/hooks/timer.h>
+#include <trace/hooks/fpsimd.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -90,3 +91,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_bpf_syscall);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rproc_recovery_set);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index);
+EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save);
diff --git a/include/trace/hooks/fpsimd.h b/include/trace/hooks/fpsimd.h
new file mode 100644
index 0000000..1033718
--- /dev/null
+++ b/include/trace/hooks/fpsimd.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM fpsimd
+
+#define TRACE_INCLUDE_PATH trace/hooks
+
+#if !defined(_TRACE_HOOK_FPSIMD_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_HOOK_FPSIMD_H
+
+#include <trace/hooks/vendor_hooks.h>
+
+struct task_struct;
+
+DECLARE_HOOK(android_vh_is_fpsimd_save,
+ TP_PROTO(struct task_struct *prev, struct task_struct *next),
+ TP_ARGS(prev, next))
+
+#endif /* _TRACE_HOOK_FPSIMD_H */
+/* This part must be outside protection */
+#include <trace/define_trace.h>