Skip to content

Commit

Permalink
x86/crtools: add injected int 0x80 instruction code
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
  • Loading branch information
0x7f454c46 authored and xemul committed Apr 18, 2016
1 parent 72f4e51 commit 12abdb2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions criu/arch/x86/crtools.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@
/*
* Injected syscall instruction
*/
/* FIXME: 32-bit syscalls */
const char code_syscall[] = {
0x0f, 0x05, /* syscall */
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc /* int 3, ... */
};

const char code_int_80[] = {
0xcd, 0x80, /* int $0x80 */
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc /* int 3, ... */
};

static const int
code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static const int
code_int_80_aligned = round_up(sizeof(code_syscall), sizeof(long));

static inline __always_unused void __check_code_syscall(void)
{
BUILD_BUG_ON(code_int_80_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
Expand Down Expand Up @@ -128,6 +135,8 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
r->r10 = arg4;
r->r8 = arg5;
r->r9 = arg6;

err = __parasite_execute_syscall(ctl, &regs, code_syscall);
} else {
user_regs_struct32 *r = &regs.compat;

Expand All @@ -138,9 +147,9 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
r->si = arg4;
r->di = arg5;
r->bp = arg6;
}

err = __parasite_execute_syscall(ctl, &regs, code_syscall);
err = __parasite_execute_syscall(ctl, &regs, code_int_80);
}

*ret = get_user_reg(&regs, ax);
return err;
Expand Down

0 comments on commit 12abdb2

Please sign in to comment.