Commit 329d2c15 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

infect: Move seized_native() into infect.c

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 795049e6
#include "infect.h"
static struct syscall_exec_desc sc_exec_table_64[] = {
#include "sys-exec-tbl-64.c"
......@@ -29,7 +30,7 @@ find_syscall_table(char *name, struct syscall_exec_desc *tbl)
#ifdef CONFIG_COMPAT
struct syscall_exec_desc * find_syscall(char *name, struct parasite_ctl *ctl)
{
if (seized_native(ctl))
if (compel_mode_native(ctl))
return find_syscall_table(name, sc_exec_table_64);
else
return find_syscall_table(name, sc_exec_table_32);
......
......@@ -76,4 +76,7 @@ extern int compel_stop_on_syscall(int tasks, int sys_nr,
extern int compel_stop_pie(pid_t pid, void *addr, enum trace_flags *tf, bool no_bp);
extern int compel_unmap(struct parasite_ctl *ctl, unsigned long addr);
extern int compel_mode_native(struct parasite_ctl *ctl);
#endif
......@@ -90,6 +90,5 @@ extern int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret,
unsigned long arg5, unsigned long arg6);
extern bool arch_can_dump_task(struct parasite_ctl *ctl);
extern bool seized_native(struct parasite_ctl *ctl);
#endif /* __CR_PARASITE_SYSCALL_H__ */
......@@ -638,7 +638,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size)
pid_t pid = ctl->rpid;
unsigned long sret = -ENOSYS;
int ret, fd, lfd;
bool __maybe_unused compat_task = !seized_native(ctl);
bool __maybe_unused compat_task = !compel_mode_native(ctl);
if (ctl->ictx.flags & INFECT_NO_MEMFD)
return 1;
......@@ -752,7 +752,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
* without using ptrace at all.
*/
if (seized_native(ctl))
if (compel_mode_native(ctl))
parasite_size = pie_size(parasite_native);
#ifdef CONFIG_COMPAT
else
......@@ -773,7 +773,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
pr_info("Putting parasite blob into %p->%p\n", ctl->local_map, ctl->remote_map);
if (seized_native(ctl))
if (compel_mode_native(ctl))
init_parasite_ctl(ctl, native);
#ifdef CONFIG_COMPAT
else
......@@ -964,7 +964,7 @@ int compel_cure_remote(struct parasite_ctl *ctl)
} else {
unsigned long ret;
syscall_seized(ctl, __NR(munmap, !seized_native(ctl)), &ret,
syscall_seized(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
(unsigned long)ctl->remote_map, ctl->map_length,
0, 0, 0, 0);
if (ret) {
......@@ -1206,3 +1206,8 @@ goon:
return 0;
}
int compel_mode_native(struct parasite_ctl *ctl)
{
return user_regs_native(&ctl->orig.regs);
}
......@@ -306,7 +306,7 @@ static int __parasite_dump_pages_seized(struct pstree_item *item,
* use, i.e. on non-lazy non-predump.
*/
cpp_flags |= PP_CHUNK_MODE;
if (!seized_native(ctl))
if (!compel_mode_native(ctl))
cpp_flags |= PP_COMPAT;
pp = create_page_pipe(vma_area_list->priv_size,
pargs_iovs(args), cpp_flags);
......
......@@ -89,11 +89,6 @@ static inline int ptrace_set_regs(int pid, user_regs_struct_t *regs)
}
#endif
bool seized_native(struct parasite_ctl *ctl)
{
return user_regs_native(&ctl->orig.regs);
}
int parasite_send_fd(struct parasite_ctl *ctl, int fd)
{
int sk;
......@@ -180,7 +175,7 @@ int parasite_dump_thread_leader_seized(struct parasite_ctl *ctl, int pid, CoreEn
struct parasite_dump_creds *pc;
int ret;
if (seized_native(ctl)) {
if (compel_mode_native(ctl)) {
args = compel_parasite_args(ctl, struct parasite_dump_thread);
pc = args->creds;
} else {
......@@ -200,7 +195,7 @@ int parasite_dump_thread_leader_seized(struct parasite_ctl *ctl, int pid, CoreEn
return -1;
}
if (seized_native(ctl))
if (compel_mode_native(ctl))
return dump_thread_core(pid, core, true, args);
else
return dump_thread_core(pid, core, false, args_c);
......@@ -220,7 +215,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
BUG_ON(id == 0); /* Leader is dumped in dump_task_core_all */
if (seized_native(ctl)) {
if (compel_mode_native(ctl)) {
args = compel_parasite_args(ctl, struct parasite_dump_thread);
pc = args->creds;
} else {
......@@ -255,7 +250,7 @@ int parasite_dump_thread_seized(struct parasite_ctl *ctl, int id,
return -1;
}
if (seized_native(ctl)) {
if (compel_mode_native(ctl)) {
tid->ns[0].virt = args->tid;
return dump_thread_core(pid, core, true, args);
} else {
......@@ -281,7 +276,7 @@ int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct cr_imgset *cr_
int ret, sig;
struct cr_img *img;
SaEntry se = SA_ENTRY__INIT;
bool native_task = seized_native(ctl);
bool native_task = compel_mode_native(ctl);
if (native_task)
args = compel_parasite_args(ctl, struct parasite_dump_sa_args);
......@@ -335,7 +330,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *i
struct parasite_dump_itimers_args_compat *args_c = NULL;
int ret;
if (seized_native(ctl))
if (compel_mode_native(ctl))
args = compel_parasite_args(ctl, struct parasite_dump_itimers_args);
else
args_c = compel_parasite_args(ctl, struct parasite_dump_itimers_args_compat);
......@@ -344,7 +339,7 @@ int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *i
if (ret < 0)
return ret;
if (seized_native(ctl))
if (compel_mode_native(ctl))
ASSIGN_ITIMER(args);
else
ASSIGN_ITIMER(args_c);
......@@ -373,7 +368,7 @@ static int core_alloc_posix_timers(TaskTimersEntry *tte, int n,
#define set_posix_timer_arg(args, ctl, m, val) \
do { \
if (seized_native(ctl)) \
if (compel_mode_native(ctl)) \
ASSIGN_TYPED( \
((struct parasite_dump_posix_timers_args*)args)->m, val); \
else \
......@@ -383,7 +378,7 @@ do { \
#define get_posix_timer_arg(out, m) \
do { \
if (seized_native(ctl)) \
if (compel_mode_native(ctl)) \
ASSIGN_TYPED( \
out, ((struct parasite_dump_posix_timers_args*)args)->m); \
else \
......@@ -423,7 +418,7 @@ int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args,
if (core_alloc_posix_timers(tte, proc_args->timer_n, &pte))
return -1;
if (seized_native(ctl))
if (compel_mode_native(ctl))
args_size = posix_timers_dump_size(proc_args->timer_n);
else
args_size = posix_timers_compat_dump_size(proc_args->timer_n);
......
......@@ -106,7 +106,7 @@ int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid,
* XXX: For compatible tasks, vDSO pfn is different from
* our native vdso_pfn. Check vma explicitly.
*/
if (!seized_native(ctl))
if (!compel_mode_native(ctl))
args->try_fill_symtable = true;
else
args->try_fill_symtable = (fd < 0) ? true : false;
......
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