From 446fb034ddb70da23c8908388c502a2de0f36211 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 6 Jun 2024 15:15:06 +0200 Subject: [PATCH] drop some 6.6 fpsimd arm64 patches --- ...id-erroneous-elide-of-user-state-rel.patch | 127 ------------------ ...lement-lazy-restore-for-kernel-mode-.patch | 86 ------------ ...simd-implement-lazy-restore-for-kern.patch | 74 ---------- ...imd-implement-lazy-restore-for-kerne.patch | 75 ----------- queue-6.6/series | 4 - 5 files changed, 366 deletions(-) delete mode 100644 queue-6.6/arm64-fpsimd-avoid-erroneous-elide-of-user-state-rel.patch delete mode 100644 queue-6.6/arm64-fpsimd-implement-lazy-restore-for-kernel-mode-.patch delete mode 100644 queue-6.6/reapply-arm64-fpsimd-implement-lazy-restore-for-kern.patch delete mode 100644 queue-6.6/revert-arm64-fpsimd-implement-lazy-restore-for-kerne.patch diff --git a/queue-6.6/arm64-fpsimd-avoid-erroneous-elide-of-user-state-rel.patch b/queue-6.6/arm64-fpsimd-avoid-erroneous-elide-of-user-state-rel.patch deleted file mode 100644 index 587a6786c69..00000000000 --- a/queue-6.6/arm64-fpsimd-avoid-erroneous-elide-of-user-state-rel.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 0180bc16b0f2c38cf9215f40fdca39302bc242da Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Wed, 22 May 2024 11:13:36 +0200 -Subject: arm64/fpsimd: Avoid erroneous elide of user state reload - -From: Ard Biesheuvel - -[ Upstream commit e92bee9f861b466c676f0200be3e46af7bc4ac6b ] - -TIF_FOREIGN_FPSTATE is a 'convenience' flag that should reflect whether -the current CPU holds the most recent user mode FP/SIMD state of the -current task. It combines two conditions: -- whether the current CPU's FP/SIMD state belongs to the task; -- whether that state is the most recent associated with the task (as a - task may have executed on other CPUs as well). - -When a task is scheduled in and TIF_KERNEL_FPSTATE is set, it means the -task was in a kernel mode NEON section when it was scheduled out, and so -the kernel mode FP/SIMD state is restored. Since this implies that the -current CPU is *not* holding the most recent user mode FP/SIMD state of -the current task, the TIF_FOREIGN_FPSTATE flag is set too, so that the -user mode FP/SIMD state is reloaded from memory when returning to -userland. - -However, the task may be scheduled out after completing the kernel mode -NEON section, but before returning to userland. When this happens, the -TIF_FOREIGN_FPSTATE flag will not be preserved, but will be set as usual -the next time the task is scheduled in, and will be based on the above -conditions. - -This means that, rather than setting TIF_FOREIGN_FPSTATE when scheduling -in a task with TIF_KERNEL_FPSTATE set, the underlying state should be -updated so that TIF_FOREIGN_FPSTATE will assume the expected value as a -result. - -So instead, call fpsimd_flush_cpu_state(), which takes care of this. - -Closes: https://lore.kernel.org/all/cb8822182231850108fa43e0446a4c7f@kernel.org -Reported-by: Johannes Nixdorf -Fixes: aefbab8e77eb ("arm64: fpsimd: Preserve/restore kernel mode NEON at context switch") -Cc: Mark Brown -Cc: Dave Martin -Cc: Janne Grunau -Cc: stable@vger.kernel.org -Signed-off-by: Ard Biesheuvel -Tested-by: Janne Grunau -Tested-by: Johannes Nixdorf -Reviewed-by: Mark Brown -Link: https://lore.kernel.org/r/20240522091335.335346-2-ardb+git@google.com -Signed-off-by: Will Deacon -Signed-off-by: Sasha Levin ---- - arch/arm64/kernel/fpsimd.c | 44 +++++++++++++++++++------------------- - 1 file changed, 22 insertions(+), 22 deletions(-) - -diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c -index aa695057c93dd..55963fa64dec8 100644 ---- a/arch/arm64/kernel/fpsimd.c -+++ b/arch/arm64/kernel/fpsimd.c -@@ -1560,6 +1560,27 @@ static void fpsimd_save_kernel_state(struct task_struct *task) - fpsimd_save_state(&task->thread.kernel_fpsimd_state); - } - -+/* -+ * Invalidate any task's FPSIMD state that is present on this cpu. -+ * The FPSIMD context should be acquired with get_cpu_fpsimd_context() -+ * before calling this function. -+ */ -+static void fpsimd_flush_cpu_state(void) -+{ -+ WARN_ON(!system_supports_fpsimd()); -+ __this_cpu_write(fpsimd_last_state.st, NULL); -+ -+ /* -+ * Leaving streaming mode enabled will cause issues for any kernel -+ * NEON and leaving streaming mode or ZA enabled may increase power -+ * consumption. -+ */ -+ if (system_supports_sme()) -+ sme_smstop(); -+ -+ set_thread_flag(TIF_FOREIGN_FPSTATE); -+} -+ - void fpsimd_thread_switch(struct task_struct *next) - { - bool wrong_task, wrong_cpu; -@@ -1577,7 +1598,7 @@ void fpsimd_thread_switch(struct task_struct *next) - - if (test_tsk_thread_flag(next, TIF_KERNEL_FPSTATE)) { - fpsimd_load_kernel_state(next); -- set_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE); -+ fpsimd_flush_cpu_state(); - } else { - /* - * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's -@@ -1856,27 +1877,6 @@ void fpsimd_flush_task_state(struct task_struct *t) - barrier(); - } - --/* -- * Invalidate any task's FPSIMD state that is present on this cpu. -- * The FPSIMD context should be acquired with get_cpu_fpsimd_context() -- * before calling this function. -- */ --static void fpsimd_flush_cpu_state(void) --{ -- WARN_ON(!system_supports_fpsimd()); -- __this_cpu_write(fpsimd_last_state.st, NULL); -- -- /* -- * Leaving streaming mode enabled will cause issues for any kernel -- * NEON and leaving streaming mode or ZA enabled may increase power -- * consumption. -- */ -- if (system_supports_sme()) -- sme_smstop(); -- -- set_thread_flag(TIF_FOREIGN_FPSTATE); --} -- - /* - * Save the FPSIMD state to memory and invalidate cpu view. - * This function must be called with preemption disabled. --- -2.43.0 - diff --git a/queue-6.6/arm64-fpsimd-implement-lazy-restore-for-kernel-mode-.patch b/queue-6.6/arm64-fpsimd-implement-lazy-restore-for-kernel-mode-.patch deleted file mode 100644 index b23abe85fe2..00000000000 --- a/queue-6.6/arm64-fpsimd-implement-lazy-restore-for-kernel-mode-.patch +++ /dev/null @@ -1,86 +0,0 @@ -From afeeeb2dbfdded9651e5b4e01083c2d1c114ea82 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 8 Dec 2023 12:32:22 +0100 -Subject: arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD - -From: Ard Biesheuvel - -[ Upstream commit 2632e25217696712681dd1f3ecc0d71624ea3b23 ] - -Now that kernel mode FPSIMD state is context switched along with other -task state, we can enable the existing logic that keeps track of which -task's FPSIMD state the CPU is holding in its registers. If it is the -context of the task that we are switching to, we can elide the reload of -the FPSIMD state from memory. - -Note that we also need to check whether the FPSIMD state on this CPU is -the most recent: if a task gets migrated away and back again, the state -in memory may be more recent than the state in the CPU. So add another -CPU id field to task_struct to keep track of this. (We could reuse the -existing CPU id field used for user mode context, but that might result -in user state to be discarded unnecessarily, given that two distinct -CPUs could be holding the most recent user mode state and the most -recent kernel mode state) - -Signed-off-by: Ard Biesheuvel -Reviewed-by: Mark Brown -Acked-by: Mark Rutland -Link: https://lore.kernel.org/r/20231208113218.3001940-9-ardb@google.com -Signed-off-by: Will Deacon -Stable-dep-of: b8995a184170 ("Revert "arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD"") -Signed-off-by: Sasha Levin ---- - arch/arm64/include/asm/processor.h | 1 + - arch/arm64/kernel/fpsimd.c | 18 ++++++++++++++++++ - 2 files changed, 19 insertions(+) - -diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h -index ce6eebd6c08bd..5b0a04810b236 100644 ---- a/arch/arm64/include/asm/processor.h -+++ b/arch/arm64/include/asm/processor.h -@@ -169,6 +169,7 @@ struct thread_struct { - struct debug_info debug; /* debugging */ - - struct user_fpsimd_state kernel_fpsimd_state; -+ unsigned int kernel_fpsimd_cpu; - #ifdef CONFIG_ARM64_PTR_AUTH - struct ptrauth_keys_user keys_user; - #ifdef CONFIG_ARM64_PTR_AUTH_KERNEL -diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c -index aa695057c93dd..92cb6dd1cfc1a 100644 ---- a/arch/arm64/kernel/fpsimd.c -+++ b/arch/arm64/kernel/fpsimd.c -@@ -1552,12 +1552,30 @@ void do_fpsimd_exc(unsigned long esr, struct pt_regs *regs) - - static void fpsimd_load_kernel_state(struct task_struct *task) - { -+ struct cpu_fp_state *last = this_cpu_ptr(&fpsimd_last_state); -+ -+ /* -+ * Elide the load if this CPU holds the most recent kernel mode -+ * FPSIMD context of the current task. -+ */ -+ if (last->st == &task->thread.kernel_fpsimd_state && -+ task->thread.kernel_fpsimd_cpu == smp_processor_id()) -+ return; -+ - fpsimd_load_state(&task->thread.kernel_fpsimd_state); - } - - static void fpsimd_save_kernel_state(struct task_struct *task) - { -+ struct cpu_fp_state cpu_fp_state = { -+ .st = &task->thread.kernel_fpsimd_state, -+ .to_save = FP_STATE_FPSIMD, -+ }; -+ - fpsimd_save_state(&task->thread.kernel_fpsimd_state); -+ fpsimd_bind_state_to_cpu(&cpu_fp_state); -+ -+ task->thread.kernel_fpsimd_cpu = smp_processor_id(); - } - - void fpsimd_thread_switch(struct task_struct *next) --- -2.43.0 - diff --git a/queue-6.6/reapply-arm64-fpsimd-implement-lazy-restore-for-kern.patch b/queue-6.6/reapply-arm64-fpsimd-implement-lazy-restore-for-kern.patch deleted file mode 100644 index 8d6230a128c..00000000000 --- a/queue-6.6/reapply-arm64-fpsimd-implement-lazy-restore-for-kern.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 87a7238bf9d1b72ed2f9a136b04d22d6e5db2781 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Wed, 22 May 2024 11:53:05 +0100 -Subject: Reapply "arm64: fpsimd: Implement lazy restore for kernel mode - FPSIMD" - -From: Will Deacon - -[ Upstream commit f481bb32d60e45fb3d19ea68ce79c5629f3fc3a0 ] - -This reverts commit b8995a18417088bb53f87c49d200ec72a9dd4ec1. - -Ard managed to reproduce the dm-crypt corruption problem and got to the -bottom of it, so re-apply the problematic patch in preparation for -fixing things properly. - -Cc: stable@vger.kernel.org -Signed-off-by: Will Deacon -Signed-off-by: Sasha Levin ---- - arch/arm64/include/asm/processor.h | 1 + - arch/arm64/kernel/fpsimd.c | 18 ++++++++++++++++++ - 2 files changed, 19 insertions(+) - -diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h -index ce6eebd6c08bd..5b0a04810b236 100644 ---- a/arch/arm64/include/asm/processor.h -+++ b/arch/arm64/include/asm/processor.h -@@ -169,6 +169,7 @@ struct thread_struct { - struct debug_info debug; /* debugging */ - - struct user_fpsimd_state kernel_fpsimd_state; -+ unsigned int kernel_fpsimd_cpu; - #ifdef CONFIG_ARM64_PTR_AUTH - struct ptrauth_keys_user keys_user; - #ifdef CONFIG_ARM64_PTR_AUTH_KERNEL -diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c -index 55963fa64dec8..4c7bc3c01afc2 100644 ---- a/arch/arm64/kernel/fpsimd.c -+++ b/arch/arm64/kernel/fpsimd.c -@@ -1552,12 +1552,30 @@ void do_fpsimd_exc(unsigned long esr, struct pt_regs *regs) - - static void fpsimd_load_kernel_state(struct task_struct *task) - { -+ struct cpu_fp_state *last = this_cpu_ptr(&fpsimd_last_state); -+ -+ /* -+ * Elide the load if this CPU holds the most recent kernel mode -+ * FPSIMD context of the current task. -+ */ -+ if (last->st == &task->thread.kernel_fpsimd_state && -+ task->thread.kernel_fpsimd_cpu == smp_processor_id()) -+ return; -+ - fpsimd_load_state(&task->thread.kernel_fpsimd_state); - } - - static void fpsimd_save_kernel_state(struct task_struct *task) - { -+ struct cpu_fp_state cpu_fp_state = { -+ .st = &task->thread.kernel_fpsimd_state, -+ .to_save = FP_STATE_FPSIMD, -+ }; -+ - fpsimd_save_state(&task->thread.kernel_fpsimd_state); -+ fpsimd_bind_state_to_cpu(&cpu_fp_state); -+ -+ task->thread.kernel_fpsimd_cpu = smp_processor_id(); - } - - /* --- -2.43.0 - diff --git a/queue-6.6/revert-arm64-fpsimd-implement-lazy-restore-for-kerne.patch b/queue-6.6/revert-arm64-fpsimd-implement-lazy-restore-for-kerne.patch deleted file mode 100644 index 01f50dd5911..00000000000 --- a/queue-6.6/revert-arm64-fpsimd-implement-lazy-restore-for-kerne.patch +++ /dev/null @@ -1,75 +0,0 @@ -From b6fb5d8556512e9b817e4aa1fc270749c13feea4 Mon Sep 17 00:00:00 2001 -From: Sasha Levin -Date: Fri, 17 May 2024 12:55:55 +0100 -Subject: Revert "arm64: fpsimd: Implement lazy restore for kernel mode FPSIMD" - -From: Will Deacon - -[ Upstream commit b8995a18417088bb53f87c49d200ec72a9dd4ec1 ] - -This reverts commit 2632e25217696712681dd1f3ecc0d71624ea3b23. - -Johannes (and others) report data corruption with dm-crypt on Apple M1 -which has been bisected to this change. Revert the offending commit -while we figure out what's going on. - -Cc: stable@vger.kernel.org -Reported-by: Johannes Nixdorf -Link: https://lore.kernel.org/all/D1B7GPIR9K1E.5JFV37G0YTIF@shadowice.org/ -Signed-off-by: Will Deacon -Signed-off-by: Sasha Levin ---- - arch/arm64/include/asm/processor.h | 1 - - arch/arm64/kernel/fpsimd.c | 18 ------------------ - 2 files changed, 19 deletions(-) - -diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h -index 5b0a04810b236..ce6eebd6c08bd 100644 ---- a/arch/arm64/include/asm/processor.h -+++ b/arch/arm64/include/asm/processor.h -@@ -169,7 +169,6 @@ struct thread_struct { - struct debug_info debug; /* debugging */ - - struct user_fpsimd_state kernel_fpsimd_state; -- unsigned int kernel_fpsimd_cpu; - #ifdef CONFIG_ARM64_PTR_AUTH - struct ptrauth_keys_user keys_user; - #ifdef CONFIG_ARM64_PTR_AUTH_KERNEL -diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c -index 92cb6dd1cfc1a..aa695057c93dd 100644 ---- a/arch/arm64/kernel/fpsimd.c -+++ b/arch/arm64/kernel/fpsimd.c -@@ -1552,30 +1552,12 @@ void do_fpsimd_exc(unsigned long esr, struct pt_regs *regs) - - static void fpsimd_load_kernel_state(struct task_struct *task) - { -- struct cpu_fp_state *last = this_cpu_ptr(&fpsimd_last_state); -- -- /* -- * Elide the load if this CPU holds the most recent kernel mode -- * FPSIMD context of the current task. -- */ -- if (last->st == &task->thread.kernel_fpsimd_state && -- task->thread.kernel_fpsimd_cpu == smp_processor_id()) -- return; -- - fpsimd_load_state(&task->thread.kernel_fpsimd_state); - } - - static void fpsimd_save_kernel_state(struct task_struct *task) - { -- struct cpu_fp_state cpu_fp_state = { -- .st = &task->thread.kernel_fpsimd_state, -- .to_save = FP_STATE_FPSIMD, -- }; -- - fpsimd_save_state(&task->thread.kernel_fpsimd_state); -- fpsimd_bind_state_to_cpu(&cpu_fp_state); -- -- task->thread.kernel_fpsimd_cpu = smp_processor_id(); - } - - void fpsimd_thread_switch(struct task_struct *next) --- -2.43.0 - diff --git a/queue-6.6/series b/queue-6.6/series index 8b647186560..f6fdc24e5f2 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -548,10 +548,6 @@ iio-accel-mxc4005-allow-module-autoloading-via-of-co.patch iio-accel-mxc4005-reset-chip-on-probe-and-resume.patch misc-pvpanic-deduplicate-common-code.patch misc-pvpanic-pci-register-attributes-via-pci_driver.patch -arm64-fpsimd-implement-lazy-restore-for-kernel-mode-.patch -revert-arm64-fpsimd-implement-lazy-restore-for-kerne.patch -arm64-fpsimd-avoid-erroneous-elide-of-user-state-rel.patch -reapply-arm64-fpsimd-implement-lazy-restore-for-kern.patch serial-sc16is7xx-replace-hardcoded-divisor-value-wit.patch serial-sc16is7xx-fix-bug-in-sc16is7xx_set_baud-when-.patch eventfs-create-eventfs_root_inode-to-store-dentry.patch -- 2.47.3