aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/um/os-Linux
diff options
context:
space:
mode:
authorThomas Meyer <thomas@m3y3r.de>2017-07-29 17:03:23 +0200
committerRichard Weinberger <richard@nod.at>2017-09-13 22:24:38 +0200
commit6f602afda7275c24c20ba38b5b6cd4ed08561fff (patch)
tree33ee34f627f020b350fbc351eef16674588c3786 /arch/x86/um/os-Linux
parentLinux 4.13 (diff)
downloadlinux-dev-6f602afda7275c24c20ba38b5b6cd4ed08561fff.tar.xz
linux-dev-6f602afda7275c24c20ba38b5b6cd4ed08561fff.zip
um: Fix FP register size for XSTATE/XSAVE
Hard code max size. Taken from https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/common/x86-xstate.h Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/x86/um/os-Linux')
-rw-r--r--arch/x86/um/os-Linux/registers.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/arch/x86/um/os-Linux/registers.c b/arch/x86/um/os-Linux/registers.c
index 28775f55bde2..3c423dfcd78b 100644
--- a/arch/x86/um/os-Linux/registers.c
+++ b/arch/x86/um/os-Linux/registers.c
@@ -5,6 +5,7 @@
*/
#include <errno.h>
+#include <stdlib.h>
#include <sys/ptrace.h>
#ifdef __i386__
#include <sys/user.h>
@@ -31,7 +32,7 @@ int save_fp_registers(int pid, unsigned long *fp_regs)
if (have_xstate_support) {
iov.iov_base = fp_regs;
- iov.iov_len = sizeof(struct _xstate);
+ iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
return -errno;
return 0;
@@ -51,10 +52,9 @@ int restore_fp_registers(int pid, unsigned long *fp_regs)
{
#ifdef PTRACE_SETREGSET
struct iovec iov;
-
if (have_xstate_support) {
iov.iov_base = fp_regs;
- iov.iov_len = sizeof(struct _xstate);
+ iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_SETREGSET, pid, NT_X86_XSTATE, &iov) < 0)
return -errno;
return 0;
@@ -125,13 +125,19 @@ int put_fp_registers(int pid, unsigned long *regs)
void arch_init_registers(int pid)
{
#ifdef PTRACE_GETREGSET
- struct _xstate fp_regs;
+ void * fp_regs;
struct iovec iov;
- iov.iov_base = &fp_regs;
- iov.iov_len = sizeof(struct _xstate);
+ fp_regs = malloc(FP_SIZE * sizeof(unsigned long));
+ if(fp_regs == NULL)
+ return;
+
+ iov.iov_base = fp_regs;
+ iov.iov_len = FP_SIZE * sizeof(unsigned long);
if (ptrace(PTRACE_GETREGSET, pid, NT_X86_XSTATE, &iov) == 0)
have_xstate_support = 1;
+
+ free(fp_regs);
#endif
}
#endif