Commit 03a9c6b0 authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

parasite-syscall: use the ptrace requests PTRACE_(GET|SET)REGSET to retrieve and set CPU registers

This patch introduces the routines ptrace_get_gpregs() and ptrace_set_gpregs()
that wrap the ptrace interface to get and set CPU registers respectively.
The motivation is to make the CRIU code be compatible with architectures that
don't support the PTRACE_GETREGS and PTRACE_SETREGS ptrace calls ---
the requests PTRACE_GETREGSET and PTRACE_SETREGSET are implemented instead.
Signed-off-by: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c2a366d4
...@@ -27,6 +27,11 @@ struct ptrace_peeksiginfo_args { ...@@ -27,6 +27,11 @@ struct ptrace_peeksiginfo_args {
#define PTRACE_PEEKSIGINFO_SHARED (1 << 0) #define PTRACE_PEEKSIGINFO_SHARED (1 << 0)
#endif #endif
#ifndef PTRACE_GETREGSET
# define PTRACE_GETREGSET 0x4204
# define PTRACE_SETREGSET 0x4205
#endif
#define PTRACE_GETSIGMASK 0x420a #define PTRACE_GETSIGMASK 0x420a
#define PTRACE_SETSIGMASK 0x420b #define PTRACE_SETSIGMASK 0x420b
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <elf.h>
#include "asm/parasite-syscall.h" #include "asm/parasite-syscall.h"
#include "asm/dump.h" #include "asm/dump.h"
...@@ -67,12 +68,20 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned ...@@ -67,12 +68,20 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned
static inline int ptrace_get_regs(int pid, user_regs_struct_t *regs) static inline int ptrace_get_regs(int pid, user_regs_struct_t *regs)
{ {
return ptrace(PTRACE_GETREGS, pid, NULL, regs); struct iovec iov;
iov.iov_base = regs;
iov.iov_len = sizeof(user_regs_struct_t);
return ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov);
} }
static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs) static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs)
{ {
return ptrace(PTRACE_SETREGS, pid, NULL, regs); struct iovec iov;
iov.iov_base = regs;
iov.iov_len = sizeof(user_regs_struct_t);
return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
} }
static int get_thread_ctx(int pid, struct thread_ctx *ctx) static int get_thread_ctx(int pid, struct thread_ctx *ctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment