Blame view
arch/um/os-Linux/registers.c
1.14 KB
97870c34b um: Add SPDX head... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
42daba316 uml: stop saving ... |
2 3 |
/* * Copyright (C) 2004 PathScale, Inc |
ba180fd43 uml: style fixes ... |
4 |
* Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
42daba316 uml: stop saving ... |
5 6 7 8 9 |
*/ #include <errno.h> #include <string.h> #include <sys/ptrace.h> |
37185b332 um: get rid of po... |
10 11 12 |
#include <sysdep/ptrace.h> #include <sysdep/ptrace_user.h> #include <registers.h> |
42daba316 uml: stop saving ... |
13 |
|
3e6f2ac48 uml: kill process... |
14 |
int save_registers(int pid, struct uml_pt_regs *regs) |
42daba316 uml: stop saving ... |
15 16 |
{ int err; |
18badddaa uml: rename pt_re... |
17 |
err = ptrace(PTRACE_GETREGS, pid, 0, regs->gp); |
ba180fd43 uml: style fixes ... |
18 |
if (err < 0) |
3e6f2ac48 uml: kill process... |
19 20 |
return -errno; return 0; |
42daba316 uml: stop saving ... |
21 |
} |
3e6f2ac48 uml: kill process... |
22 |
int restore_registers(int pid, struct uml_pt_regs *regs) |
42daba316 uml: stop saving ... |
23 24 |
{ int err; |
18badddaa uml: rename pt_re... |
25 |
err = ptrace(PTRACE_SETREGS, pid, 0, regs->gp); |
ba180fd43 uml: style fixes ... |
26 |
if (err < 0) |
3e6f2ac48 uml: kill process... |
27 28 |
return -errno; return 0; |
42daba316 uml: stop saving ... |
29 |
} |
d25f2e123 uml: use ptrace d... |
30 31 32 |
/* This is set once at boot time and not changed thereafter */ static unsigned long exec_regs[MAX_REG_NR]; |
fbfe9c847 um: Save FPU regi... |
33 |
static unsigned long exec_fp_regs[FP_SIZE]; |
d25f2e123 uml: use ptrace d... |
34 |
|
3e6f2ac48 uml: kill process... |
35 |
int init_registers(int pid) |
42daba316 uml: stop saving ... |
36 37 38 39 |
{ int err; err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs); |
3e6f2ac48 uml: kill process... |
40 41 |
if (err < 0) return -errno; |
a5f6096c8 uml: floating poi... |
42 43 |
arch_init_registers(pid); |
fbfe9c847 um: Save FPU regi... |
44 |
get_fp_registers(pid, exec_fp_regs); |
3e6f2ac48 uml: kill process... |
45 |
return 0; |
42daba316 uml: stop saving ... |
46 |
} |
fbfe9c847 um: Save FPU regi... |
47 |
void get_safe_registers(unsigned long *regs, unsigned long *fp_regs) |
42daba316 uml: stop saving ... |
48 49 |
{ memcpy(regs, exec_regs, sizeof(exec_regs)); |
fbfe9c847 um: Save FPU regi... |
50 51 52 |
if (fp_regs) memcpy(fp_regs, exec_fp_regs, sizeof(exec_fp_regs)); |
42daba316 uml: stop saving ... |
53 |
} |