]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
um: remove auxiliary FP registers
authorBenjamin Berg <benjamin.berg@intel.com>
Fri, 4 Oct 2024 23:38:21 +0000 (01:38 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 10 Oct 2024 10:10:30 +0000 (12:10 +0200)
We do not need the extra save/restore of the FP registers when getting
the fault information. This was originally added in commit 2f56debd77a8
("uml: fix FP register corruption") but at that time the code was not
saving/restoring the FP registers when switching to userspace. This was
fixed in commit fbfe9c847edf ("um: Save FPU registers between task
switches") and since then the auxiliary registers have not been useful.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20241004233821.2130874-1-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
arch/um/include/asm/thread_info.h
arch/um/include/shared/os.h
arch/um/kernel/process.c
arch/um/os-Linux/skas/process.c

index c7b4b49826a2aafc040d13fcc8a09765639f6cd2..4d2a768246bc68577c1068592fc00169b0a81a12 100644 (file)
@@ -23,8 +23,6 @@ struct thread_info {
        int                     preempt_count;  /* 0 => preemptable,
                                                   <0 => BUG */
        struct thread_info      *real_thread;    /* Points to non-IRQ stack */
-       unsigned long aux_fp_regs[FP_SIZE];     /* auxiliary fp_regs to save/restore
-                                                  them out-of-band */
 };
 
 #define INIT_THREAD_INFO(tsk)                  \
index e54f64f55bb70382ffe6a2dbc0ca4c34e6709868..b511637e1f76dbe9639a40f9bfcbee31f14db234 100644 (file)
@@ -285,7 +285,7 @@ int protect(struct mm_id *mm_idp, unsigned long addr,
 /* skas/process.c */
 extern int is_skas_winch(int pid, int fd, void *data);
 extern int start_userspace(unsigned long stub_stack);
-extern void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs);
+extern void userspace(struct uml_pt_regs *regs);
 extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
 extern void switch_threads(jmp_buf *me, jmp_buf *you);
 extern int start_idle_thread(void *stack, jmp_buf *switch_buf);
index 701b7bb2525efb51504ffee67a52728f67447abf..d45c79f82d7c1829bc6d228845fbf18b86b5ada1 100644 (file)
@@ -116,7 +116,7 @@ void new_thread_handler(void)
         * callback returns only if the kernel thread execs a process
         */
        fn(arg);
-       userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
+       userspace(&current->thread.regs.regs);
 }
 
 /* Called magically, see new_thread_handler above */
@@ -133,7 +133,7 @@ static void fork_handler(void)
 
        current->thread.prev_sched = NULL;
 
-       userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
+       userspace(&current->thread.regs.regs);
 }
 
 int copy_thread(struct task_struct * p, const struct kernel_clone_args *args)
index b6f656bcffb1788736b116bdf9c2eda042fda51f..be666e02c44f4f3b6c870b9e78942751aa8645a6 100644 (file)
@@ -141,16 +141,10 @@ bad_wait:
 
 extern unsigned long current_stub_stack(void);
 
-static void get_skas_faultinfo(int pid, struct faultinfo *fi, unsigned long *aux_fp_regs)
+static void get_skas_faultinfo(int pid, struct faultinfo *fi)
 {
        int err;
 
-       err = get_fp_registers(pid, aux_fp_regs);
-       if (err < 0) {
-               printk(UM_KERN_ERR "save_fp_registers returned %d\n",
-                      err);
-               fatal_sigsegv();
-       }
        err = ptrace(PTRACE_CONT, pid, 0, SIGSEGV);
        if (err) {
                printk(UM_KERN_ERR "Failed to continue stub, pid = %d, "
@@ -164,18 +158,11 @@ static void get_skas_faultinfo(int pid, struct faultinfo *fi, unsigned long *aux
         * the stub stack page. We just have to copy it.
         */
        memcpy(fi, (void *)current_stub_stack(), sizeof(*fi));
-
-       err = put_fp_registers(pid, aux_fp_regs);
-       if (err < 0) {
-               printk(UM_KERN_ERR "put_fp_registers returned %d\n",
-                      err);
-               fatal_sigsegv();
-       }
 }
 
-static void handle_segv(int pid, struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
+static void handle_segv(int pid, struct uml_pt_regs *regs)
 {
-       get_skas_faultinfo(pid, &regs->faultinfo, aux_fp_regs);
+       get_skas_faultinfo(pid, &regs->faultinfo);
        segv(regs->faultinfo, 0, 1, NULL);
 }
 
@@ -336,7 +323,7 @@ int start_userspace(unsigned long stub_stack)
        return err;
 }
 
-void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
+void userspace(struct uml_pt_regs *regs)
 {
        int err, status, op, pid = userspace_pid[0];
        siginfo_t si;
@@ -435,11 +422,11 @@ void userspace(struct uml_pt_regs *regs, unsigned long *aux_fp_regs)
                        case SIGSEGV:
                                if (PTRACE_FULL_FAULTINFO) {
                                        get_skas_faultinfo(pid,
-                                                          &regs->faultinfo, aux_fp_regs);
+                                                          &regs->faultinfo);
                                        (*sig_info[SIGSEGV])(SIGSEGV, (struct siginfo *)&si,
                                                             regs);
                                }
-                               else handle_segv(pid, regs, aux_fp_regs);
+                               else handle_segv(pid, regs);
                                break;
                        case SIGTRAP + 0x80:
                                handle_trap(pid, regs);