Commit 0b3901fb authored by Dmitry Safonov's avatar Dmitry Safonov Committed by Pavel Emelyanov

parasite-syscall: get rid of code_syscall{,size} globals

I think, we may safely remove this exports, as:
- code_syscall is used only in one function, which now will have
  it as a parameter;
- code_syscall_size must be equall to BUILTIN_SYSCALL_SIZE under
  BUILD_BUG_ON, so BUILTIN_SYSCALL_SIZE may be used instead.
  (see ptrace(2) - align restriction to PTRACE_PEEKUSER).

This will reduce arch-depended code coupling a little.

(and I also interested in this because of I need __parasite_execute_syscall
to execute 32-bit syscall code on x86_64, which I prefer to leave without
some CONFIG_X86_64 as it's generic code)

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 5f51cd4d
......@@ -27,11 +27,12 @@ const char code_syscall[] = {
0x00, 0x00, 0x20, 0xd4 /* BRK #0 */
};
const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
static const int
code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static inline void __always_unused __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
......@@ -71,7 +72,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.regs[6] = 0;
regs.regs[7] = 0;
err = __parasite_execute_syscall(ctl, &regs);
err = __parasite_execute_syscall(ctl, &regs, code_syscall);
*ret = regs.regs[0];
return err;
......
......@@ -6,9 +6,6 @@ struct parasite_ctl;
#define ARCH_SI_TRAP TRAP_BRKPT
extern const char code_syscall[];
extern const int code_syscall_size;
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
void *mmap_seized(struct parasite_ctl *ctl,
......
......@@ -28,11 +28,12 @@ const char code_syscall[] = {
0xf0, 0x01, 0xf0, 0xe7 /* UDF #32 */
};
const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
static const int
code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static inline __always_unused void __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
......@@ -73,7 +74,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.ARM_r4 = arg5;
regs.ARM_r5 = arg6;
err = __parasite_execute_syscall(ctl, &regs);
err = __parasite_execute_syscall(ctl, &regs, code_syscall);
*ret = regs.ARM_r0;
return err;
......
......@@ -5,10 +5,6 @@
#define ARCH_SI_TRAP TRAP_BRKPT
extern const char code_syscall[];
extern const int code_syscall_size;
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
void *mmap_seized(struct parasite_ctl *ctl,
......
......@@ -32,8 +32,6 @@ const u32 code_syscall[] = {
0x0fe00000 /* twi 31,0,0 */
};
const int code_syscall_size = sizeof(code_syscall);
static inline void __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
......@@ -80,7 +78,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.gpr[7] = arg5;
regs.gpr[8] = arg6;
err = __parasite_execute_syscall(ctl, &regs);
err = __parasite_execute_syscall(ctl, &regs, code_syscall);
*ret = regs.gpr[3];
return err;
......
......@@ -5,9 +5,6 @@ struct parasite_ctl;
#define ARCH_SI_TRAP TRAP_BRKPT
extern const char code_syscall[];
extern const int code_syscall_size;
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
void *mmap_seized(struct parasite_ctl *ctl,
......
......@@ -31,11 +31,12 @@ const char code_syscall[] = {
0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc /* int 3, ... */
};
const int code_syscall_size = round_up(sizeof(code_syscall), sizeof(long));
static const int
code_syscall_aligned = round_up(sizeof(code_syscall), sizeof(long));
static inline __always_unused void __check_code_syscall(void)
{
BUILD_BUG_ON(sizeof(code_syscall) != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(code_syscall_aligned != BUILTIN_SYSCALL_SIZE);
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
......@@ -103,7 +104,7 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
regs.r8 = arg5;
regs.r9 = arg6;
err = __parasite_execute_syscall(ctl, &regs);
err = __parasite_execute_syscall(ctl, &regs, code_syscall);
*ret = regs.ax;
return err;
......
......@@ -8,9 +8,6 @@ struct parasite_ctl;
#define ARCH_SI_TRAP SI_KERNEL
extern const char code_syscall[];
extern const int code_syscall_size;
void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs);
void *mmap_seized(struct parasite_ctl *ctl,
......
......@@ -119,7 +119,7 @@ extern int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
unsigned long arg5, unsigned long arg6);
extern int __parasite_execute_syscall(struct parasite_ctl *ctl,
user_regs_struct_t *regs);
user_regs_struct_t *regs, const char *code_syscall);
extern bool arch_can_dump_task(pid_t pid);
/*
......
......@@ -44,7 +44,7 @@
static int can_run_syscall(unsigned long ip, unsigned long start,
unsigned long end, unsigned long pad)
{
return ip >= start && ip < (end - code_syscall_size - pad);
return ip >= start && ip < (end - BUILTIN_SYSCALL_SIZE - pad);
}
static int syscall_fits_vma_area(struct vma_area *vma_area, unsigned long pad)
......@@ -210,7 +210,8 @@ err:
return ret;
}
int __parasite_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *regs)
int __parasite_execute_syscall(struct parasite_ctl *ctl,
user_regs_struct_t *regs, const char *code_syscall)
{
pid_t pid = ctl->pid.real;
int err;
......
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