[CRIU] [PATCH] criu: x86 -- Drop @ds test from compat mode
Cyrill Gorcunov
gorcunov at gmail.com
Fri Apr 8 03:02:09 PDT 2016
On Fri, Apr 08, 2016 at 11:06:45AM +0300, Cyrill Gorcunov wrote:
> On Fri, Apr 08, 2016 at 10:02:32AM +0200, Federico Reghenzani wrote:
> > Nope, I rechecked and it's patched. I tried also to clean, make and
> > install again, same behaviour.
>
> OK, thanks a lot! I'll ping you once I figure out what the problem is.
Could you please try this patch instead of previous?
Cyrill
-------------- next part --------------
>From f8055f8b643526c4246e4a5c3ff9a7ca75dc7d53 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Wed, 6 Apr 2016 16:41:41 +0300
Subject: [PATCH] criu: x86 -- Use regsets to find if task in compat mode
Reported-by: Federico Reghenzani <federico at reghe.net>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
criu/arch/x86/crtools.c | 28 +++++++++++++---------------
criu/arch/x86/include/asm/types.h | 10 ++++++++++
2 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index 51eab133f269..e80a5f7d17e8 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -55,24 +55,22 @@ void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *
static int task_in_compat_mode(pid_t pid)
{
- unsigned long cs, ds;
-
- errno = 0;
- cs = ptrace(PTRACE_PEEKUSER, pid, offsetof(user_regs_struct_t, cs), 0);
- if (errno != 0) {
- pr_perror("Can't get CS register for %d", pid);
- return -1;
- }
-
- errno = 0;
- ds = ptrace(PTRACE_PEEKUSER, pid, offsetof(user_regs_struct_t, ds), 0);
- if (errno != 0) {
- pr_perror("Can't get DS register for %d", pid);
+ union {
+ user_regs_struct_t x86_64_regs;
+ user_regs_struct32_t x86_32_regs;
+ } regs;
+
+ struct iovec iov = {
+ .iov_base = ®s,
+ .iov_len = sizeof(regs),
+ };
+
+ if (ptrace(PTRACE_GETREGSET, pid, NT_PRSTATUS, &iov)) {
+ pr_perror("Can't get registers for %d", pid);
return -1;
}
- /* It's x86-32 or x32 */
- return cs != 0x33 || ds == 0x2b;
+ return (iov.iov_len == sizeof(regs.x86_64_regs)) ? 0 : 1;
}
bool arch_can_dump_task(pid_t pid)
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index c8e76964e430..977c30f9afcb 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -91,6 +91,16 @@ typedef struct {
} user_regs_struct_t;
typedef struct {
+ u32 ebx, ecx, edx, esi, edi, ebp, eax;
+ unsigned short ds, __ds, es, __es;
+ unsigned short fs, __fs, gs, __gs;
+ u32 orig_eax, eip;
+ unsigned short cs, __cs;
+ u32 eflags, esp;
+ unsigned short ss, __ss;
+} user_regs_struct32_t;
+
+typedef struct {
unsigned short cwd;
unsigned short swd;
unsigned short twd; /* Note this is not the same as
--
2.5.5
More information about the CRIU
mailing list