VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   30 Branches   50 Tags
author: Sebastian Andrzej Siewior <bigeasy@linutronix.de> 2021-07-29 12:52:14 +0200 committer: Minda Chen <minda.chen@starfivetech.com> 2023-11-06 19:24:52 +0800 commit: dcc75fc8b5cf7334fc212c72538827796803c35a parent: b77bc48a663da7cb5501e60c33914e2bacd939f3
Commit Summary:
arm64/sve: Delay freeing memory in fpsimd_flush_thread()
Diffstat:
1 file changed, 5 insertions, 1 deletion
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index ff4962750b3d..5e5a869b1f3a 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1033,6 +1033,7 @@ void fpsimd_thread_switch(struct task_struct *next)
 void fpsimd_flush_thread(void)
 {
 	int vl, supported_vl;
+	void *sve_state = NULL;
 
 	if (!system_supports_fpsimd())
 		return;
@@ -1045,7 +1046,10 @@ void fpsimd_flush_thread(void)
 
 	if (system_supports_sve()) {
 		clear_thread_flag(TIF_SVE);
-		sve_free(current);
+
+		/* Defer kfree() while in atomic context */
+		sve_state = current->thread.sve_state;
+		current->thread.sve_state = NULL;
 
 		/*
 		 * Reset the task vector length as required.
@@ -1079,6 +1083,7 @@ void fpsimd_flush_thread(void)
 	}
 
 	put_cpu_fpsimd_context();
+	kfree(sve_state);
 }
 
 /*