git: db65db64fbf3 - main - Revert "LinuxKPI: Add explicit software context to FPU sections"
Date: Sat, 10 Feb 2024 22:03:22 UTC
The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=db65db64fbf36c7c3625d55b686201d962a7bc4b commit db65db64fbf36c7c3625d55b686201d962a7bc4b Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2024-02-10 22:01:50 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2024-02-10 22:01:50 +0000 Revert "LinuxKPI: Add explicit software context to FPU sections" kmalloc() support within FPU sections will be redone in other way. This reverts commit 5a3bd281672bd6bd8e18081c3928dfe76d330a5f. Sponsored by: Serenity Cyber Security, LLC Requested by: jhb --- sys/compat/linuxkpi/common/include/linux/compat.h | 6 ------ sys/compat/linuxkpi/common/include/linux/sched.h | 2 -- sys/compat/linuxkpi/common/src/linux_current.c | 18 ------------------ sys/compat/linuxkpi/common/src/linux_fpu.c | 14 ++++---------- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/compat.h b/sys/compat/linuxkpi/common/include/linux/compat.h index 7922e884beb1..d1a02f612f42 100644 --- a/sys/compat/linuxkpi/common/include/linux/compat.h +++ b/sys/compat/linuxkpi/common/include/linux/compat.h @@ -33,11 +33,6 @@ #include <sys/proc.h> #include <sys/malloc.h> -#if defined(__aarch64__) || defined(__arm__) || defined(__amd64__) || \ - defined(__i386__) || defined(__powerpc64__) -#define LKPI_HAVE_FPU_CTX -#endif - struct domainset; struct thread; struct task_struct; @@ -45,7 +40,6 @@ struct task_struct; extern int linux_alloc_current(struct thread *, int flags); extern void linux_free_current(struct task_struct *); extern struct domainset *linux_get_vm_domain_set(int node); -extern int linux_set_fpu_ctx(struct task_struct *); static inline void linux_set_current(struct thread *td) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index 77c4f6d3f80f..8cb6b12100d5 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -64,7 +64,6 @@ #define TASK_COMM_LEN (MAXCOMLEN + 1) struct seq_file; -struct fpu_kern_ctx; struct work_struct; struct task_struct { @@ -90,7 +89,6 @@ struct task_struct { struct task_struct *group_leader; unsigned rcu_section[TS_RCU_TYPE_MAX]; unsigned int fpu_ctx_level; - struct fpu_kern_ctx *fpu_ctx; }; #define current ({ \ diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c index d269552c4ffa..c342eb279caa 100644 --- a/sys/compat/linuxkpi/common/src/linux_current.c +++ b/sys/compat/linuxkpi/common/src/linux_current.c @@ -43,10 +43,6 @@ #include <sys/sysctl.h> #include <vm/uma.h> -#ifdef LKPI_HAVE_FPU_CTX -#include <machine/fpu.h> -#endif - #ifdef DEV_APIC extern u_int first_msi_irq, num_msi_irqs; #endif @@ -157,16 +153,6 @@ linux_alloc_current(struct thread *td, int flags) return (0); } -int -linux_set_fpu_ctx(struct task_struct *task) -{ -#ifdef LKPI_HAVE_FPU_CTX - if (task->fpu_ctx == NULL && curthread->td_critnest == 0) - task->fpu_ctx = fpu_kern_alloc_ctx(FPU_KERN_NOWAIT); -#endif - return (task->fpu_ctx != NULL ? 0 : ENOMEM); -} - struct mm_struct * linux_get_task_mm(struct task_struct *task) { @@ -190,10 +176,6 @@ void linux_free_current(struct task_struct *ts) { mmput(ts->mm); -#ifdef LKPI_HAVE_FPU_CTX - if (ts->fpu_ctx != NULL) - fpu_kern_free_ctx(ts->fpu_ctx); -#endif uma_zfree(linux_current_zone, ts); } diff --git a/sys/compat/linuxkpi/common/src/linux_fpu.c b/sys/compat/linuxkpi/common/src/linux_fpu.c index d510bc208b88..b26dce98774b 100644 --- a/sys/compat/linuxkpi/common/src/linux_fpu.c +++ b/sys/compat/linuxkpi/common/src/linux_fpu.c @@ -30,12 +30,11 @@ #include <sys/proc.h> #include <sys/kernel.h> -#include <linux/compat.h> #include <linux/sched.h> #include <asm/fpu/api.h> -#ifdef LKPI_HAVE_FPU_CTX +#if defined(__aarch64__) || defined(__amd64__) || defined(__i386__) #include <machine/fpu.h> @@ -48,20 +47,15 @@ void lkpi_kernel_fpu_begin(void) { - int err; - - if ((current->fpu_ctx_level)++ == 0) { - err = linux_set_fpu_ctx(current); - fpu_kern_enter(curthread, current->fpu_ctx, - err == 0 ? FPU_KERN_KTHR : FPU_KERN_NOCTX); - } + if ((current->fpu_ctx_level)++ == 0) + fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); } void lkpi_kernel_fpu_end(void) { if (--(current->fpu_ctx_level) == 0) - fpu_kern_leave(curthread, current->fpu_ctx); + fpu_kern_leave(curthread, NULL); } #else