Skip to content

Commit b6024b2

Browse files
Eli Cooperrichardweinberger
authored andcommitted
um: extend fpstate to _xstate to support YMM registers
Extends fpstate to _xstate, in order to hold AVX/YMM registers. To avoid oversized stack frame, the following functions have been refactored by using malloc. - sig_handler_common - timer_real_alarm_handler Signed-off-by: Eli Cooper <elicooper@gmx.com>
1 parent 6de5a8a commit b6024b2

3 files changed

Lines changed: 32 additions & 21 deletions

File tree

‎arch/um/os-Linux/signal.c‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,29 @@ void (*sig_info[NSIG])(int, struct siginfo *, struct uml_pt_regs *) = {
2929

3030
static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)
3131
{
32-
struct uml_pt_regs r;
32+
struct uml_pt_regs *r;
3333
int save_errno = errno;
3434

35-
r.is_user = 0;
35+
r = malloc(sizeof(struct uml_pt_regs));
36+
if (!r)
37+
panic("out of memory");
38+
39+
r->is_user = 0;
3640
if (sig == SIGSEGV) {
3741
/* For segfaults, we want the data from the sigcontext. */
38-
get_regs_from_mc(&r, mc);
39-
GET_FAULTINFO_FROM_MC(r.faultinfo, mc);
42+
get_regs_from_mc(r, mc);
43+
GET_FAULTINFO_FROM_MC(r->faultinfo, mc);
4044
}
4145

4246
/* enable signals if sig isn't IRQ signal */
4347
if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGALRM))
4448
unblock_signals();
4549

46-
(*sig_info[sig])(sig, si, &r);
50+
(*sig_info[sig])(sig, si, r);
4751

4852
errno = save_errno;
53+
54+
free(r);
4955
}
5056

5157
/*
@@ -83,11 +89,17 @@ void sig_handler(int sig, struct siginfo *si, mcontext_t *mc)
8389

8490
static void timer_real_alarm_handler(mcontext_t *mc)
8591
{
86-
struct uml_pt_regs regs;
92+
struct uml_pt_regs *regs;
93+
94+
regs = malloc(sizeof(struct uml_pt_regs));
95+
if (!regs)
96+
panic("out of memory");
8797

8898
if (mc != NULL)
89-
get_regs_from_mc(&regs, mc);
90-
timer_handler(SIGALRM, NULL, &regs);
99+
get_regs_from_mc(regs, mc);
100+
timer_handler(SIGALRM, NULL, regs);
101+
102+
free(regs);
91103
}
92104

93105
void timer_alarm_handler(int sig, struct siginfo *unused_si, mcontext_t *mc)

‎arch/x86/um/signal.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,15 @@ static int copy_sc_from_user(struct pt_regs *regs,
226226
#endif
227227
{
228228
err = copy_from_user(regs->regs.fp, (void *)sc.fpstate,
229-
sizeof(struct user_i387_struct));
229+
sizeof(struct _xstate));
230230
if (err)
231231
return 1;
232232
}
233233
return 0;
234234
}
235235

236236
static int copy_sc_to_user(struct sigcontext __user *to,
237-
struct _fpstate __user *to_fp, struct pt_regs *regs,
237+
struct _xstate __user *to_fp, struct pt_regs *regs,
238238
unsigned long mask)
239239
{
240240
struct sigcontext sc;
@@ -300,23 +300,22 @@ static int copy_sc_to_user(struct sigcontext __user *to,
300300
return 1;
301301
}
302302

303-
err = convert_fxsr_to_user(to_fp, &fpx);
303+
err = convert_fxsr_to_user(&to_fp->fpstate, &fpx);
304304
if (err)
305305
return 1;
306306

307-
err |= __put_user(fpx.swd, &to_fp->status);
308-
err |= __put_user(X86_FXSR_MAGIC, &to_fp->magic);
307+
err |= __put_user(fpx.swd, &to_fp->fpstate.status);
308+
err |= __put_user(X86_FXSR_MAGIC, &to_fp->fpstate.magic);
309309
if (err)
310310
return 1;
311311

312-
if (copy_to_user(&to_fp->_fxsr_env[0], &fpx,
312+
if (copy_to_user(&to_fp->fpstate._fxsr_env[0], &fpx,
313313
sizeof(struct user_fxsr_struct)))
314314
return 1;
315315
} else
316316
#endif
317317
{
318-
if (copy_to_user(to_fp, regs->regs.fp,
319-
sizeof(struct user_i387_struct)))
318+
if (copy_to_user(to_fp, regs->regs.fp, sizeof(struct _xstate)))
320319
return 1;
321320
}
322321

@@ -325,7 +324,7 @@ static int copy_sc_to_user(struct sigcontext __user *to,
325324

326325
#ifdef CONFIG_X86_32
327326
static int copy_ucontext_to_user(struct ucontext __user *uc,
328-
struct _fpstate __user *fp, sigset_t *set,
327+
struct _xstate __user *fp, sigset_t *set,
329328
unsigned long sp)
330329
{
331330
int err = 0;
@@ -341,7 +340,7 @@ struct sigframe
341340
char __user *pretcode;
342341
int sig;
343342
struct sigcontext sc;
344-
struct _fpstate fpstate;
343+
struct _xstate fpstate;
345344
unsigned long extramask[_NSIG_WORDS-1];
346345
char retcode[8];
347346
};
@@ -354,7 +353,7 @@ struct rt_sigframe
354353
void __user *puc;
355354
struct siginfo info;
356355
struct ucontext uc;
357-
struct _fpstate fpstate;
356+
struct _xstate fpstate;
358357
char retcode[8];
359358
};
360359

@@ -483,7 +482,7 @@ struct rt_sigframe
483482
char __user *pretcode;
484483
struct ucontext uc;
485484
struct siginfo info;
486-
struct _fpstate fpstate;
485+
struct _xstate fpstate;
487486
};
488487

489488
int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig,

‎arch/x86/um/user-offsets.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void foo(void)
5050
DEFINE(HOST_GS, GS);
5151
DEFINE(HOST_ORIG_AX, ORIG_EAX);
5252
#else
53-
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
53+
DEFINE(HOST_FP_SIZE, sizeof(struct _xstate) / sizeof(unsigned long));
5454
DEFINE_LONGS(HOST_BX, RBX);
5555
DEFINE_LONGS(HOST_CX, RCX);
5656
DEFINE_LONGS(HOST_DI, RDI);

0 commit comments

Comments
 (0)