um: remove auxiliary FP registers

We do not need the extra save/restore of the FP registers when getting
the fault information. This was originally added in commit 2f56debd77
("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 fbfe9c847e ("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>
This commit is contained in:
Benjamin Berg 2024-10-05 01:38:21 +02:00 committed by Johannes Berg
parent 48a858e081
commit c6ce72005d
4 changed files with 9 additions and 24 deletions

View 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) \

View 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);

View 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)

View File

@ -141,16 +141,10 @@ void wait_stub_done(int pid)
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);