Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compel
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2021-07-19 10:28:38 +0300
committerAndrei Vagin <avagin@gmail.com>2021-09-03 20:31:00 +0300
commit93dd984ca0ee0e31a5650f64328222e748152bcb (patch)
tree024483c121704ec8d106c9bf596441b51e51a67c /compel
parent1e26f170caa8b2c26f5d09a78ffe9fdea70d38d0 (diff)
Run 'make indent' on all C files
Acked-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'compel')
-rw-r--r--compel/arch/aarch64/src/lib/cpu.c25
-rw-r--r--compel/arch/aarch64/src/lib/handle-elf.c10
-rw-r--r--compel/arch/aarch64/src/lib/infect.c46
-rw-r--r--compel/arch/arm/src/lib/handle-elf.c5
-rw-r--r--compel/arch/arm/src/lib/infect.c46
-rw-r--r--compel/arch/mips/src/lib/cpu.c13
-rw-r--r--compel/arch/mips/src/lib/handle-elf.c5
-rw-r--r--compel/arch/mips/src/lib/infect.c68
-rw-r--r--compel/arch/ppc64/src/lib/cpu.c20
-rw-r--r--compel/arch/ppc64/src/lib/handle-elf.c10
-rw-r--r--compel/arch/ppc64/src/lib/infect.c130
-rw-r--r--compel/arch/s390/plugins/std/syscalls/syscalls-s390.c5
-rw-r--r--compel/arch/s390/src/lib/cpu.c20
-rw-r--r--compel/arch/s390/src/lib/handle-elf.c5
-rw-r--r--compel/arch/s390/src/lib/infect.c115
-rw-r--r--compel/arch/x86/plugins/std/syscalls/syscall32.c42
-rw-r--r--compel/arch/x86/src/lib/cpu.c107
-rw-r--r--compel/arch/x86/src/lib/handle-elf.c5
-rw-r--r--compel/arch/x86/src/lib/infect.c195
-rw-r--r--compel/arch/x86/src/lib/thread_area.c8
-rw-r--r--compel/plugins/fds/fds.c4
-rw-r--r--compel/plugins/shmem/shmem.c3
-rw-r--r--compel/plugins/std/fds.c4
-rw-r--r--compel/plugins/std/infect.c26
-rw-r--r--compel/plugins/std/std.c6
-rw-r--r--compel/plugins/std/string.c23
-rw-r--r--compel/src/lib/handle-elf.c267
-rw-r--r--compel/src/lib/infect-rpc.c12
-rw-r--r--compel/src/lib/infect.c168
-rw-r--r--compel/src/lib/ptrace.c6
-rw-r--r--compel/src/main.c102
-rw-r--r--compel/test/fdspy/parasite.c16
-rw-r--r--compel/test/fdspy/spy.c24
-rw-r--r--compel/test/infect/parasite.c13
-rw-r--r--compel/test/infect/spy.c26
-rw-r--r--compel/test/rsys/spy.c22
36 files changed, 719 insertions, 883 deletions
diff --git a/compel/arch/aarch64/src/lib/cpu.c b/compel/arch/aarch64/src/lib/cpu.c
index cfaab1e65..538a29887 100644
--- a/compel/arch/aarch64/src/lib/cpu.c
+++ b/compel/arch/aarch64/src/lib/cpu.c
@@ -7,7 +7,7 @@
#include "log.h"
-#undef LOG_PREFIX
+#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
@@ -22,11 +22,24 @@ static void fetch_rt_cpuinfo(void)
}
}
-void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { }
-void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { }
-int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; }
-int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; }
-int compel_cpuid(compel_cpuinfo_t *info) { return 0; }
+void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+}
+void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+}
+int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+ return 0;
+}
+int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+ return 0;
+}
+int compel_cpuid(compel_cpuinfo_t *info)
+{
+ return 0;
+}
bool compel_cpu_has_feature(unsigned int feature)
{
diff --git a/compel/arch/aarch64/src/lib/handle-elf.c b/compel/arch/aarch64/src/lib/handle-elf.c
index 1ee65ee2c..206aef4cd 100644
--- a/compel/arch/aarch64/src/lib/handle-elf.c
+++ b/compel/arch/aarch64/src/lib/handle-elf.c
@@ -5,15 +5,13 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_64_le[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-static const unsigned char __maybe_unused
-elf_ident_64_be[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_be[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/aarch64/src/lib/infect.c b/compel/arch/aarch64/src/lib/infect.c
index 586eedac0..7cfa637eb 100644
--- a/compel/arch/aarch64/src/lib/infect.c
+++ b/compel/arch/aarch64/src/lib/infect.c
@@ -18,12 +18,11 @@ unsigned __page_shift = 0;
* Injected syscall instruction
*/
const char code_syscall[] = {
- 0x01, 0x00, 0x00, 0xd4, /* SVC #0 */
- 0x00, 0x00, 0x20, 0xd4 /* BRK #0 */
+ 0x01, 0x00, 0x00, 0xd4, /* SVC #0 */
+ 0x00, 0x00, 0x20, 0xd4 /* BRK #0 */
};
-static const int
-code_syscall_aligned = 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)
{
@@ -31,17 +30,15 @@ static inline void __always_unused __check_code_syscall(void)
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
struct fpsimd_context *fpsimd = RT_SIGFRAME_FPU(sigframe);
memcpy(sigframe->uc.uc_mcontext.regs, regs->regs, sizeof(regs->regs));
- sigframe->uc.uc_mcontext.sp = regs->sp;
- sigframe->uc.uc_mcontext.pc = regs->pc;
- sigframe->uc.uc_mcontext.pstate = regs->pstate;
+ sigframe->uc.uc_mcontext.sp = regs->sp;
+ sigframe->uc.uc_mcontext.pc = regs->pc;
+ sigframe->uc.uc_mcontext.pstate = regs->pstate;
memcpy(fpsimd->vregs, fpregs->vregs, 32 * sizeof(__uint128_t));
@@ -54,15 +51,13 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
return 0;
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
- struct rt_sigframe *rsigframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, __maybe_unused unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpsimd = ext_regs ? ext_regs : &tmp;
struct iovec iov;
@@ -104,13 +99,8 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
return 0;
}
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
@@ -131,15 +121,12 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
return err;
}
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
- err = compel_syscall(ctl, __NR_mmap, &map,
- (unsigned long)addr, length, prot, flags, fd, offset);
+ err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset);
if (err < 0 || (long)map < 0)
map = 0;
@@ -166,9 +153,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
long ret;
int err;
- err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->uc.uc_stack,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
@@ -191,4 +176,3 @@ unsigned long compel_task_size(void)
break;
return task_size;
}
-
diff --git a/compel/arch/arm/src/lib/handle-elf.c b/compel/arch/arm/src/lib/handle-elf.c
index 5b8d00a6f..a84524abd 100644
--- a/compel/arch/arm/src/lib/handle-elf.c
+++ b/compel/arch/arm/src/lib/handle-elf.c
@@ -5,9 +5,8 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_32[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_32[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/arm/src/lib/infect.c b/compel/arch/arm/src/lib/infect.c
index 1ddb48654..6715afdb3 100644
--- a/compel/arch/arm/src/lib/infect.c
+++ b/compel/arch/arm/src/lib/infect.c
@@ -17,12 +17,11 @@
* Injected syscall instruction
*/
const char code_syscall[] = {
- 0x00, 0x00, 0x00, 0xef, /* SVC #0 */
- 0xf0, 0x01, 0xf0, 0xe7 /* UDF #32 */
+ 0x00, 0x00, 0x00, 0xef, /* SVC #0 */
+ 0xf0, 0x01, 0xf0, 0xe7 /* UDF #32 */
};
-static const int
-code_syscall_aligned = 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)
{
@@ -30,9 +29,7 @@ static inline __always_unused void __check_code_syscall(void)
BUILD_BUG_ON(!is_log2(sizeof(code_syscall)));
}
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
struct aux_sigframe *aux = (struct aux_sigframe *)(void *)&sigframe->sig.uc.uc_regspace;
@@ -62,16 +59,14 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
return 0;
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
- struct rt_sigframe *rsigframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
#define PTRACE_GETVFPREGS 27
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, __maybe_unused unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *vfp = ext_regs ? ext_regs : &tmp;
int ret = -1;
@@ -116,13 +111,8 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
return 0;
}
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
@@ -141,9 +131,7 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
return err;
}
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
@@ -151,8 +139,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
if (offset & ~PAGE_MASK)
return 0;
- err = compel_syscall(ctl, __NR_mmap2, &map,
- (unsigned long)addr, length, prot, flags, fd, offset >> 12);
+ err = compel_syscall(ctl, __NR_mmap2, &map, (unsigned long)addr, length, prot, flags, fd, offset >> 12);
if (err < 0 || map > ctl->ictx.task_size)
map = 0;
@@ -182,9 +169,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
long ret;
int err;
- err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->sig.uc.uc_stack,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->sig.uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
@@ -193,9 +178,9 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
* arch/arm/include/asm/memory.h
* arch/arm/Kconfig (PAGE_OFFSET values in Memory split section)
*/
-#define TASK_SIZE_MIN 0x3f000000
-#define TASK_SIZE_MAX 0xbf000000
-#define SZ_1G 0x40000000
+#define TASK_SIZE_MIN 0x3f000000
+#define TASK_SIZE_MAX 0xbf000000
+#define SZ_1G 0x40000000
unsigned long compel_task_size(void)
{
@@ -207,4 +192,3 @@ unsigned long compel_task_size(void)
return task_size;
}
-
diff --git a/compel/arch/mips/src/lib/cpu.c b/compel/arch/mips/src/lib/cpu.c
index bdb65ff9f..172b90e27 100644
--- a/compel/arch/mips/src/lib/cpu.c
+++ b/compel/arch/mips/src/lib/cpu.c
@@ -6,22 +6,27 @@
#include "common/compiler.h"
#include "log.h"
-#undef LOG_PREFIX
+#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
static bool rt_info_done = false;
-void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature){ }
+void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
+{
+}
-void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature){ }
+void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
+{
+}
int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
{
return 0;
}
-int compel_cpuid(compel_cpuinfo_t *c){
+int compel_cpuid(compel_cpuinfo_t *c)
+{
return 0;
}
diff --git a/compel/arch/mips/src/lib/handle-elf.c b/compel/arch/mips/src/lib/handle-elf.c
index 988985151..a605a5a45 100644
--- a/compel/arch/mips/src/lib/handle-elf.c
+++ b/compel/arch/mips/src/lib/handle-elf.c
@@ -5,9 +5,8 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_64_le[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/mips/src/lib/infect.c b/compel/arch/mips/src/lib/infect.c
index d8c03c33a..68d0a2728 100644
--- a/compel/arch/mips/src/lib/infect.c
+++ b/compel/arch/mips/src/lib/infect.c
@@ -23,8 +23,8 @@
* mips64el is Little Endian
*/
const char code_syscall[] = {
- 0x0c, 0x00, 0x00, 0x00, /* syscall */
- 0x0d, 0x00, 0x00, 0x00 /* break */
+ 0x0c, 0x00, 0x00, 0x00, /* syscall */
+ 0x0d, 0x00, 0x00, 0x00 /* break */
};
/* 10-byte legacy floating point register */
@@ -40,10 +40,7 @@ struct fpxreg {
uint16_t padding[3];
};
-
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
sigframe->rs_uc.uc_mcontext.sc_regs[0] = regs->regs[0];
sigframe->rs_uc.uc_mcontext.sc_regs[1] = regs->regs[1];
@@ -117,17 +114,15 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
return 0;
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
- struct rt_sigframe *rsigframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, __maybe_unused unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, __maybe_unused unsigned long flags)
{
- user_fpregs_struct_t xsave = { }, *xs = ext_regs ? ext_regs : &xsave;
+ user_fpregs_struct_t xsave = {}, *xs = ext_regs ? ext_regs : &xsave;
int ret = -1;
pr_info("Dumping GP/FPU registers for %d\n", pid);
@@ -143,7 +138,7 @@ int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
case ERESTARTNOHAND:
case ERESTARTSYS:
case ERESTARTNOINTR:
- regs->regs[2] = regs->regs[0];
+ regs->regs[2] = regs->regs[0];
regs->regs[7] = regs->regs[26];
regs->cp0_epc -= 4;
break;
@@ -170,13 +165,8 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
return 0;
}
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
/*refer to glibc-2.20/sysdeps/unix/sysv/linux/mips/mips64/syscall.S*/
user_regs_struct_t regs = ctl->orig.regs;
@@ -193,18 +183,15 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
err = compel_execute_syscall(ctl, &regs, code_syscall);
*ret = regs.regs[2];
- return err;
+ return err;
}
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
- err = compel_syscall(ctl, __NR_mmap, &map,
- (unsigned long)addr, length, prot, flags, fd, offset >> PAGE_SHIFT);
+ err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset >> PAGE_SHIFT);
if (err < 0 || IS_ERR_VALUE(map)) {
pr_err("remote mmap() failed: %s\n", strerror(-map));
@@ -236,13 +223,10 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
long ret;
int err;
- err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->rs_uc.uc_stack,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->rs_uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
-
int ptrace_set_breakpoint(pid_t pid, void *addr)
{
return 0;
@@ -256,9 +240,12 @@ int ptrace_flush_breakpoints(pid_t pid)
/*refer to kernel linux-3.10/arch/mips/include/asm/processor.h*/
#define TASK_SIZE32 0x7fff8000UL
#define TASK_SIZE64 0x10000000000UL
-#define TASK_SIZE TASK_SIZE64
+#define TASK_SIZE TASK_SIZE64
-unsigned long compel_task_size(void) { return TASK_SIZE; }
+unsigned long compel_task_size(void)
+{
+ return TASK_SIZE;
+}
/*
* Get task registers (overwrites weak function)
@@ -292,30 +279,31 @@ void compel_relocs_apply_mips(void *mem, void *vbase, struct parasite_blob_desc
for (i = 0, j = 0; i < nr_relocs; i++) {
if (elf_relocs[i].type & COMPEL_TYPE_MIPS_26) {
int *where = (mem + elf_relocs[i].offset);
- *where = *where | ((elf_relocs[i].addend + ((unsigned long)vbase & 0x00fffffff) /*low 28 bit*/)>>2);
+ *where = *where |
+ ((elf_relocs[i].addend + ((unsigned long)vbase & 0x00fffffff) /*low 28 bit*/) >> 2);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_64) {
unsigned long *where = (mem + elf_relocs[i].offset);
*where = elf_relocs[i].addend + (unsigned long)vbase;
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HI16) {
/* refer to binutils mips.cc */
int *where = (mem + elf_relocs[i].offset);
- int v_lo16 = (unsigned long)vbase &0x00ffff;
+ int v_lo16 = (unsigned long)vbase & 0x00ffff;
- if ((v_lo16+elf_relocs[i].value+elf_relocs[i].addend) >= 0x8000) {
- *where = *where | ((((unsigned long)vbase>>16) &0xffff)+0x1);
+ if ((v_lo16 + elf_relocs[i].value + elf_relocs[i].addend) >= 0x8000) {
+ *where = *where | ((((unsigned long)vbase >> 16) & 0xffff) + 0x1);
} else {
- *where = *where | ((((unsigned long)vbase>>16) &0xffff));
+ *where = *where | ((((unsigned long)vbase >> 16) & 0xffff));
}
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_LO16) {
int *where = (mem + elf_relocs[i].offset);
- int v_lo16 = (unsigned long)vbase &0x00ffff;
+ int v_lo16 = (unsigned long)vbase & 0x00ffff;
*where = *where | ((v_lo16 + elf_relocs[i].addend) & 0xffff);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HIGHER) {
int *where = (mem + elf_relocs[i].offset);
- *where = *where | ((( (unsigned long)vbase + (uint64_t) 0x80008000) >> 32) & 0xffff);
+ *where = *where | ((((unsigned long)vbase + (uint64_t)0x80008000) >> 32) & 0xffff);
} else if (elf_relocs[i].type & COMPEL_TYPE_MIPS_HIGHEST) {
int *where = (mem + elf_relocs[i].offset);
- *where = *where | ((( (unsigned long)vbase + (uint64_t) 0x800080008000llu) >> 48) & 0xffff);
+ *where = *where | ((((unsigned long)vbase + (uint64_t)0x800080008000llu) >> 48) & 0xffff);
} else {
BUG();
}
diff --git a/compel/arch/ppc64/src/lib/cpu.c b/compel/arch/ppc64/src/lib/cpu.c
index 7a3972790..f7a128ca3 100644
--- a/compel/arch/ppc64/src/lib/cpu.c
+++ b/compel/arch/ppc64/src/lib/cpu.c
@@ -10,7 +10,7 @@
#include "log.h"
-#undef LOG_PREFIX
+#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
@@ -25,10 +25,20 @@ static void fetch_rt_cpuinfo(void)
}
}
-void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { }
-void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { }
-int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; }
-int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; }
+void compel_set_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+}
+void compel_clear_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+}
+int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+ return 0;
+}
+int compel_test_cpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+ return 0;
+}
int compel_cpuid(compel_cpuinfo_t *info)
{
diff --git a/compel/arch/ppc64/src/lib/handle-elf.c b/compel/arch/ppc64/src/lib/handle-elf.c
index f29fdc8a3..84a360c43 100644
--- a/compel/arch/ppc64/src/lib/handle-elf.c
+++ b/compel/arch/ppc64/src/lib/handle-elf.c
@@ -5,15 +5,13 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_64_le[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-static const unsigned char __maybe_unused
-elf_ident_64_be[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_be[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/ppc64/src/lib/infect.c b/compel/arch/ppc64/src/lib/infect.c
index 5797fb16d..fc174d0dd 100644
--- a/compel/arch/ppc64/src/lib/infect.c
+++ b/compel/arch/ppc64/src/lib/infect.c
@@ -15,11 +15,11 @@
#include "infect-priv.h"
#ifndef NT_PPC_TM_SPR
-#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
-#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
-#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
-#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
-#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
+#define NT_PPC_TM_CGPR 0x108 /* TM checkpointed GPR Registers */
+#define NT_PPC_TM_CFPR 0x109 /* TM checkpointed FPR Registers */
+#define NT_PPC_TM_CVMX 0x10a /* TM checkpointed VMX Registers */
+#define NT_PPC_TM_CVSX 0x10b /* TM checkpointed VSX Registers */
+#define NT_PPC_TM_SPR 0x10c /* TM Special Purpose Registers */
#endif
unsigned __page_size = 0;
@@ -29,8 +29,8 @@ unsigned __page_shift = 0;
* Injected syscall instruction
*/
const uint32_t code_syscall[] = {
- 0x44000002, /* sc */
- 0x0fe00000 /* twi 31,0,0 */
+ 0x44000002, /* sc */
+ 0x0fe00000 /* twi 31,0,0 */
};
static inline __always_unused void __check_code_syscall(void)
@@ -43,14 +43,14 @@ static void prep_gp_regs(mcontext_t *dst, user_regs_struct_t *regs)
{
memcpy(dst->gp_regs, regs->gpr, sizeof(regs->gpr));
- dst->gp_regs[PT_NIP] = regs->nip;
- dst->gp_regs[PT_MSR] = regs->msr;
- dst->gp_regs[PT_ORIG_R3] = regs->orig_gpr3;
- dst->gp_regs[PT_CTR] = regs->ctr;
- dst->gp_regs[PT_LNK] = regs->link;
- dst->gp_regs[PT_XER] = regs->xer;
- dst->gp_regs[PT_CCR] = regs->ccr;
- dst->gp_regs[PT_TRAP] = regs->trap;
+ dst->gp_regs[PT_NIP] = regs->nip;
+ dst->gp_regs[PT_MSR] = regs->msr;
+ dst->gp_regs[PT_ORIG_R3] = regs->orig_gpr3;
+ dst->gp_regs[PT_CTR] = regs->ctr;
+ dst->gp_regs[PT_LNK] = regs->link;
+ dst->gp_regs[PT_XER] = regs->xer;
+ dst->gp_regs[PT_CCR] = regs->ccr;
+ dst->gp_regs[PT_TRAP] = regs->trap;
}
static void put_fpu_regs(mcontext_t *mc, uint64_t *fpregs)
@@ -74,9 +74,7 @@ static void put_vsx_regs(mcontext_t *mc, uint64_t *vsxregs)
memcpy((uint64_t *)(mc->v_regs + 1), vsxregs, sizeof(*vsxregs) * NVSXREG);
}
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
mcontext_t *dst_tc = &sigframe->uc_transact.uc_mcontext;
mcontext_t *dst = &sigframe->uc.uc_mcontext;
@@ -134,14 +132,12 @@ static void update_vregs(mcontext_t *lcontext, mcontext_t *rcontext)
uint64_t offset = (uint64_t)(lcontext->v_regs) - (uint64_t)lcontext;
lcontext->v_regs = (vrregset_t *)((uint64_t)rcontext + offset);
- pr_debug("Updated v_regs:%llx (rcontext:%llx)\n",
- (unsigned long long)lcontext->v_regs,
+ pr_debug("Updated v_regs:%llx (rcontext:%llx)\n", (unsigned long long)lcontext->v_regs,
(unsigned long long)rcontext);
}
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *frame,
- struct rt_sigframe *rframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *frame, struct rt_sigframe *rframe)
{
uint64_t msr = frame->uc.uc_mcontext.gp_regs[PT_MSR];
@@ -155,9 +151,8 @@ int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *frame,
/* Updating the transactional state address if any */
if (frame->uc.uc_link) {
- update_vregs(&frame->uc_transact.uc_mcontext,
- &rframe->uc_transact.uc_mcontext);
- frame->uc.uc_link = &rframe->uc_transact;
+ update_vregs(&frame->uc_transact.uc_mcontext, &rframe->uc_transact.uc_mcontext);
+ frame->uc.uc_link = &rframe->uc_transact;
}
return 0;
@@ -214,7 +209,7 @@ static int get_fpu_regs(pid_t pid, user_fpregs_struct_t *fp)
static int get_altivec_regs(pid_t pid, user_fpregs_struct_t *fp)
{
- if (ptrace(PTRACE_GETVRREGS, pid, 0, (void*)&fp->vrregs) < 0) {
+ if (ptrace(PTRACE_GETVRREGS, pid, 0, (void *)&fp->vrregs) < 0) {
/* PTRACE_GETVRREGS returns EIO if Altivec is not supported.
* This should not happen if msr_vec is set. */
if (errno != EIO) {
@@ -240,7 +235,7 @@ static int get_altivec_regs(pid_t pid, user_fpregs_struct_t *fp)
*/
static int get_vsx_regs(pid_t pid, user_fpregs_struct_t *fp)
{
- if (ptrace(PTRACE_GETVSRREGS, pid, 0, (void*)fp->vsxregs) < 0) {
+ if (ptrace(PTRACE_GETVSRREGS, pid, 0, (void *)fp->vsxregs) < 0) {
/*
* EIO is returned in the case PTRACE_GETVRREGS is not
* supported.
@@ -263,22 +258,23 @@ static int get_tm_regs(pid_t pid, user_fpregs_struct_t *fpregs)
pr_debug("Dumping TM registers\n");
-#define TM_REQUIRED 0
-#define TM_OPTIONAL 1
-#define PTRACE_GET_TM(s,n,c,u) do { \
- iov.iov_base = &s; \
- iov.iov_len = sizeof(s); \
- if (ptrace(PTRACE_GETREGSET, pid, c, &iov)) { \
- if (!u || errno != EIO) { \
- pr_perror("Couldn't get TM "n); \
- pr_err("Your kernel seems to not support the " \
- "new TM ptrace API (>= 4.8)\n"); \
- goto out_free; \
- } \
- pr_debug("TM "n" not supported.\n"); \
- iov.iov_base = NULL; \
- } \
-} while(0)
+#define TM_REQUIRED 0
+#define TM_OPTIONAL 1
+#define PTRACE_GET_TM(s, n, c, u) \
+ do { \
+ iov.iov_base = &s; \
+ iov.iov_len = sizeof(s); \
+ if (ptrace(PTRACE_GETREGSET, pid, c, &iov)) { \
+ if (!u || errno != EIO) { \
+ pr_perror("Couldn't get TM " n); \
+ pr_err("Your kernel seems to not support the " \
+ "new TM ptrace API (>= 4.8)\n"); \
+ goto out_free; \
+ } \
+ pr_debug("TM " n " not supported.\n"); \
+ iov.iov_base = NULL; \
+ } \
+ } while (0)
/* Get special registers */
PTRACE_GET_TM(fpregs->tm.tm_spr_regs, "SPR", NT_PPC_TM_SPR, TM_REQUIRED);
@@ -304,11 +300,10 @@ static int get_tm_regs(pid_t pid, user_fpregs_struct_t *fpregs)
return 0;
out_free:
- return -1; /* still failing the checkpoint */
+ return -1; /* still failing the checkpoint */
}
-static int __get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+static int __get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
pr_info("Dumping GP/FPU registers for %d\n", pid);
@@ -317,7 +312,7 @@ static int __get_task_regs(pid_t pid, user_regs_struct_t *regs,
* arch/powerpc/kernel/signal.c
*/
#ifndef TRAP
-#define TRAP(r) ((r).trap & ~0xF)
+#define TRAP(r) ((r).trap & ~0xF)
#endif
if (TRAP(*regs) == 0x0C00 && regs->ccr & 0x10000000) {
@@ -347,10 +342,8 @@ static int __get_task_regs(pid_t pid, user_regs_struct_t *regs,
* impossible) or suspended (easy to get).
*/
if (MSR_TM_ACTIVE(regs->msr)) {
- pr_debug("Task %d has %s TM operation at 0x%lx\n",
- pid,
- (regs->msr & MSR_TMS) ? "a suspended" : "an active",
- regs->nip);
+ pr_debug("Task %d has %s TM operation at 0x%lx\n", pid,
+ (regs->msr & MSR_TMS) ? "a suspended" : "an active", regs->nip);
if (get_tm_regs(pid, fpregs))
return -1;
fpregs->flags = USER_FPREGS_FL_TM;
@@ -372,9 +365,8 @@ static int __get_task_regs(pid_t pid, user_regs_struct_t *regs,
return 0;
}
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, __maybe_unused unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
int ret;
@@ -401,11 +393,11 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
}
if (ext_regs->flags & USER_FPREGS_FL_ALTIVEC) {
- if (ptrace(PTRACE_SETVRREGS, pid, 0, (void*)&ext_regs->vrregs) < 0) {
+ if (ptrace(PTRACE_SETVRREGS, pid, 0, (void *)&ext_regs->vrregs) < 0) {
pr_perror("Couldn't set Altivec registers");
ret = -1;
}
- if (ptrace(PTRACE_SETVSRREGS, pid, 0, (void*)ext_regs->vsxregs) < 0) {
+ if (ptrace(PTRACE_SETVSRREGS, pid, 0, (void *)ext_regs->vsxregs) < 0) {
pr_perror("Couldn't set VSX registers");
ret = -1;
}
@@ -414,13 +406,8 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
return ret;
}
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
@@ -433,21 +420,18 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
regs.gpr[7] = arg5;
regs.gpr[8] = arg6;
- err = compel_execute_syscall(ctl, &regs, (char*)code_syscall);
+ err = compel_execute_syscall(ctl, &regs, (char *)code_syscall);
*ret = regs.gpr[3];
return err;
}
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map = 0;
int err;
- err = compel_syscall(ctl, __NR_mmap, &map,
- (unsigned long)addr, length, prot, flags, fd, offset);
+ err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)addr, length, prot, flags, fd, offset);
if (err < 0 || (long)map < 0)
map = 0;
@@ -463,7 +447,7 @@ void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *
regs->gpr[12] = new_ip;
regs->nip = new_ip;
if (stack)
- regs->gpr[1] = (unsigned long) stack;
+ regs->gpr[1] = (unsigned long)stack;
regs->trap = 0;
}
@@ -480,9 +464,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
long ret;
int err;
- err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->uc.uc_stack,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
@@ -491,7 +473,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
*
* NOTE: 32bit tasks are not supported.
*/
-#define TASK_SIZE_64TB (0x0000400000000000UL)
+#define TASK_SIZE_64TB (0x0000400000000000UL)
#define TASK_SIZE_512TB (0x0002000000000000UL)
#define TASK_SIZE_MIN TASK_SIZE_64TB
diff --git a/compel/arch/s390/plugins/std/syscalls/syscalls-s390.c b/compel/arch/s390/plugins/std/syscalls/syscalls-s390.c
index 2b35cca4a..11c3284ab 100644
--- a/compel/arch/s390/plugins/std/syscalls/syscalls-s390.c
+++ b/compel/arch/s390/plugins/std/syscalls/syscalls-s390.c
@@ -3,14 +3,13 @@
/*
* Define prototype because of compile error if we include uapi/std/syscall.h
*/
-long sys_old_mmap (struct mmap_arg_struct *);
+long sys_old_mmap(struct mmap_arg_struct *);
/*
* On s390 we have defined __ARCH_WANT_SYS_OLD_MMAP - Therefore implement
* system call with one parameter "mmap_arg_struct".
*/
-unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot,
- unsigned long flags, unsigned long fd,
+unsigned long sys_mmap(void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd,
unsigned long offset)
{
struct mmap_arg_struct arg_struct;
diff --git a/compel/arch/s390/src/lib/cpu.c b/compel/arch/s390/src/lib/cpu.c
index 5d86bf239..c98607e16 100644
--- a/compel/arch/s390/src/lib/cpu.c
+++ b/compel/arch/s390/src/lib/cpu.c
@@ -9,7 +9,7 @@
#include "log.h"
-#undef LOG_PREFIX
+#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
@@ -23,10 +23,20 @@ static void fetch_rt_cpuinfo(void)
}
}
-void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { }
-void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { }
-int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature) { return 0; }
-int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) { return 0; }
+void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
+{
+}
+void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
+{
+}
+int compel_test_fpu_cap(compel_cpuinfo_t *info, unsigned int feature)
+{
+ return 0;
+}
+int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
+{
+ return 0;
+}
int compel_cpuid(compel_cpuinfo_t *info)
{
diff --git a/compel/arch/s390/src/lib/handle-elf.c b/compel/arch/s390/src/lib/handle-elf.c
index 6ed382c92..8e766dc1b 100644
--- a/compel/arch/s390/src/lib/handle-elf.c
+++ b/compel/arch/s390/src/lib/handle-elf.c
@@ -5,9 +5,8 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_64[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x02, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
index a928c72c3..77ace713a 100644
--- a/compel/arch/s390/src/lib/infect.c
+++ b/compel/arch/s390/src/lib/infect.c
@@ -17,25 +17,23 @@
#include "ptrace.h"
#include "infect-priv.h"
-#define NT_PRFPREG 2
-#define NT_S390_VXRS_LOW 0x309
-#define NT_S390_VXRS_HIGH 0x30a
-#define NT_S390_GS_CB 0x30b
-#define NT_S390_GS_BC 0x30c
-#define NT_S390_RI_CB 0x30d
+#define NT_PRFPREG 2
+#define NT_S390_VXRS_LOW 0x309
+#define NT_S390_VXRS_HIGH 0x30a
+#define NT_S390_GS_CB 0x30b
+#define NT_S390_GS_BC 0x30c
+#define NT_S390_RI_CB 0x30d
/*
* Print general purpose and access registers
*/
-static void print_user_regs_struct(const char *msg, int pid,
- user_regs_struct_t *regs)
+static void print_user_regs_struct(const char *msg, int pid, user_regs_struct_t *regs)
{
int i;
pr_debug("%s: Registers for pid=%d\n", msg, pid);
- pr_debug("system_call %08lx\n", (unsigned long) regs->system_call);
- pr_debug(" psw %016lx %016lx\n", regs->prstatus.psw.mask,
- regs->prstatus.psw.addr);
+ pr_debug("system_call %08lx\n", (unsigned long)regs->system_call);
+ pr_debug(" psw %016lx %016lx\n", regs->prstatus.psw.mask, regs->prstatus.psw.addr);
pr_debug(" orig_gpr2 %016lx\n", regs->prstatus.orig_gpr2);
for (i = 0; i < 16; i++)
pr_debug(" g%02d %016lx\n", i, regs->prstatus.gprs[i]);
@@ -57,9 +55,7 @@ static void print_vxrs(user_fpregs_struct_t *fpregs)
for (i = 0; i < 16; i++)
pr_debug(" vx_low%02d %016lx\n", i, fpregs->vxrs_low[i]);
for (i = 0; i < 16; i++)
- pr_debug(" vx_high%02d %016lx %016lx\n", i,
- fpregs->vxrs_high[i].part1,
- fpregs->vxrs_high[i].part2);
+ pr_debug(" vx_high%02d %016lx %016lx\n", i, fpregs->vxrs_high[i].part1, fpregs->vxrs_high[i].part2);
}
/*
@@ -111,8 +107,7 @@ static void print_ri_cb(user_fpregs_struct_t *fpregs)
* Print FP registers, VX registers, guarded-storage, and
* runtime-instrumentation
*/
-static void print_user_fpregs_struct(const char *msg, int pid,
- user_fpregs_struct_t *fpregs)
+static void print_user_fpregs_struct(const char *msg, int pid, user_fpregs_struct_t *fpregs)
{
int i;
@@ -126,28 +121,19 @@ static void print_user_fpregs_struct(const char *msg, int pid,
print_ri_cb(fpregs);
}
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
_sigregs_ext *dst_ext = &sigframe->uc.uc_mcontext_ext;
_sigregs *dst = &sigframe->uc.uc_mcontext;
- memcpy(dst->regs.gprs, regs->prstatus.gprs,
- sizeof(regs->prstatus.gprs));
- memcpy(dst->regs.acrs, regs->prstatus.acrs,
- sizeof(regs->prstatus.acrs));
- memcpy(&dst->regs.psw, &regs->prstatus.psw,
- sizeof(regs->prstatus.psw));
- memcpy(&dst->fpregs.fpc, &fpregs->prfpreg.fpc,
- sizeof(fpregs->prfpreg.fpc));
- memcpy(&dst->fpregs.fprs, &fpregs->prfpreg.fprs,
- sizeof(fpregs->prfpreg.fprs));
+ memcpy(dst->regs.gprs, regs->prstatus.gprs, sizeof(regs->prstatus.gprs));
+ memcpy(dst->regs.acrs, regs->prstatus.acrs, sizeof(regs->prstatus.acrs));
+ memcpy(&dst->regs.psw, &regs->prstatus.psw, sizeof(regs->prstatus.psw));
+ memcpy(&dst->fpregs.fpc, &fpregs->prfpreg.fpc, sizeof(fpregs->prfpreg.fpc));
+ memcpy(&dst->fpregs.fprs, &fpregs->prfpreg.fprs, sizeof(fpregs->prfpreg.fprs));
if (fpregs->flags & USER_FPREGS_VXRS) {
- memcpy(&dst_ext->vxrs_low, &fpregs->vxrs_low,
- sizeof(fpregs->vxrs_low));
- memcpy(&dst_ext->vxrs_high, &fpregs->vxrs_high,
- sizeof(fpregs->vxrs_high));
+ memcpy(&dst_ext->vxrs_low, &fpregs->vxrs_low, sizeof(fpregs->vxrs_low));
+ memcpy(&dst_ext->vxrs_high, &fpregs->vxrs_high, sizeof(fpregs->vxrs_high));
} else {
memset(&dst_ext->vxrs_low, 0, sizeof(dst_ext->vxrs_low));
memset(&dst_ext->vxrs_high, 0, sizeof(dst_ext->vxrs_high));
@@ -155,8 +141,7 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
return 0;
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
- struct rt_sigframe *rsigframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
return 0;
}
@@ -169,9 +154,7 @@ static inline void rewind_psw(psw_t *psw, unsigned long bytes)
unsigned long mask;
pr_debug("Rewind psw: %016lx bytes=%lu\n", psw->addr, bytes);
- mask = (psw->mask & PSW_MASK_EA) ? -1UL :
- (psw->mask & PSW_MASK_BA) ? (1UL << 31) - 1 :
- (1UL << 24) - 1;
+ mask = (psw->mask & PSW_MASK_EA) ? -1UL : (psw->mask & PSW_MASK_BA) ? (1UL << 31) - 1 : (1UL << 24) - 1;
psw->addr = (psw->addr - bytes) & mask;
}
@@ -310,9 +293,8 @@ static int s390_disable_ri_bit(pid_t pid, user_regs_struct_t *regs)
/*
* Prepare task registers for restart
*/
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, __maybe_unused unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, __maybe_unused unsigned long flags)
{
user_fpregs_struct_t tmp, *fpregs = ext_regs ? ext_regs : &tmp;
struct iovec iov;
@@ -429,10 +411,10 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
* Injected syscall instruction
*/
const char code_syscall[] = {
- 0x0a, 0x00, /* sc 0 */
- 0x00, 0x01, /* S390_BREAKPOINT_U16 */
- 0x00, 0x01, /* S390_BREAKPOINT_U16 */
- 0x00, 0x01, /* S390_BREAKPOINT_U16 */
+ 0x0a, 0x00, /* sc 0 */
+ 0x00, 0x01, /* S390_BREAKPOINT_U16 */
+ 0x00, 0x01, /* S390_BREAKPOINT_U16 */
+ 0x00, 0x01, /* S390_BREAKPOINT_U16 */
};
static inline void __check_code_syscall(void)
@@ -444,19 +426,14 @@ static inline void __check_code_syscall(void)
/*
* Issue s390 system call
*/
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
int err;
/* Load syscall number into %r1 */
- regs.prstatus.gprs[1] = (unsigned long) nr;
+ regs.prstatus.gprs[1] = (unsigned long)nr;
/* Load parameter registers %r2-%r7 */
regs.prstatus.gprs[2] = arg1;
regs.prstatus.gprs[3] = arg2;
@@ -465,7 +442,7 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
regs.prstatus.gprs[6] = arg5;
regs.prstatus.gprs[7] = arg6;
- err = compel_execute_syscall(ctl, &regs, (char *) code_syscall);
+ err = compel_execute_syscall(ctl, &regs, (char *)code_syscall);
/* Return code from system is in %r2 */
if (ret)
@@ -476,9 +453,7 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
/*
* Issue s390 mmap call
*/
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
void *where = (void *)ctl->ictx.syscall_ip + BUILTIN_SYSCALL_SIZE;
struct mmap_arg_struct arg_struct;
@@ -501,8 +476,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
}
/* Do syscall */
- err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long) where,
- 0, 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_mmap, &map, (unsigned long)where, 0, 0, 0, 0, 0);
if (err < 0 || (long)map < 0)
map = 0;
@@ -510,8 +484,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
pr_err("Can't restore mmap args (pid: %d)\n", pid);
if (map != 0) {
- err = compel_syscall(ctl, __NR_munmap, NULL, map,
- length, 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_munmap, NULL, map, length, 0, 0, 0, 0);
if (err)
pr_err("Can't munmap %d\n", err);
map = 0;
@@ -524,14 +497,12 @@ void *remote_mmap(struct parasite_ctl *ctl,
/*
* Setup registers for parasite call
*/
-void parasite_setup_regs(unsigned long new_ip, void *stack,
- user_regs_struct_t *regs)
+void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs)
{
regs->prstatus.psw.addr = new_ip;
if (!stack)
return;
- regs->prstatus.gprs[15] = ((unsigned long) stack) -
- STACK_FRAME_OVERHEAD;
+ regs->prstatus.gprs[15] = ((unsigned long)stack) - STACK_FRAME_OVERHEAD;
}
/*
@@ -579,9 +550,7 @@ int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
long ret;
int err;
- err = compel_syscall(ctl, __NR_sigaltstack,
- &ret, 0, (unsigned long)&s->uc.uc_stack,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR_sigaltstack, &ret, 0, (unsigned long)&s->uc.uc_stack, 0, 0, 0, 0);
return err ? err : ret;
}
@@ -655,9 +624,9 @@ enum kernel_ts_level {
};
/* See arch/s390/include/asm/processor.h */
-#define TASK_SIZE_LEVEL_3 0x40000000000UL /* 4 TB */
-#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */
-#define TASK_SIZE_LEVEL_5 0xffffffffffffefffUL /* 16 EB - 0x1000 */
+#define TASK_SIZE_LEVEL_3 0x40000000000UL /* 4 TB */
+#define TASK_SIZE_LEVEL_4 0x20000000000000UL /* 8 PB */
+#define TASK_SIZE_LEVEL_5 0xffffffffffffefffUL /* 16 EB - 0x1000 */
/*
* Return detected kernel version regarding task size level
@@ -671,12 +640,12 @@ static enum kernel_ts_level get_kernel_ts_level(void)
/* Check for 5 levels */
if (criu_end_addr >= TASK_SIZE_LEVEL_4)
return KERNEL_TS_LEVEL_5;
- else if (munmap((void *) TASK_SIZE_LEVEL_4, 0x1000) == 0)
+ else if (munmap((void *)TASK_SIZE_LEVEL_4, 0x1000) == 0)
return KERNEL_TS_LEVEL_5;
if (criu_end_addr < TASK_SIZE_LEVEL_3) {
/* Check for 4 level kernel with fix */
- if (munmap((void *) TASK_SIZE_LEVEL_3, 0x1000) == 0)
+ if (munmap((void *)TASK_SIZE_LEVEL_3, 0x1000) == 0)
return KERNEL_TS_LEVEL_4_FIX_YES;
else
return KERNEL_TS_LEVEL_4_FIX_NO;
diff --git a/compel/arch/x86/plugins/std/syscalls/syscall32.c b/compel/arch/x86/plugins/std/syscalls/syscall32.c
index e172cacff..0f2fec3ff 100644
--- a/compel/arch/x86/plugins/std/syscalls/syscall32.c
+++ b/compel/arch/x86/plugins/std/syscalls/syscall32.c
@@ -1,16 +1,16 @@
#include "asm/types.h"
#include "syscall-32.h"
-#define SYS_SOCKET 1 /* sys_socket(2) */
-#define SYS_BIND 2 /* sys_bind(2) */
-#define SYS_CONNECT 3 /* sys_connect(2) */
-#define SYS_SENDTO 11 /* sys_sendto(2) */
-#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
-#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
-#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
-#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
-#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
-#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
+#define SYS_SOCKET 1 /* sys_socket(2) */
+#define SYS_BIND 2 /* sys_bind(2) */
+#define SYS_CONNECT 3 /* sys_connect(2) */
+#define SYS_SENDTO 11 /* sys_sendto(2) */
+#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
+#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
+#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
+#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
+#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
+#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
long sys_socket(int domain, int type, int protocol)
{
@@ -20,59 +20,61 @@ long sys_socket(int domain, int type, int protocol)
long sys_connect(int sockfd, struct sockaddr *addr, int addrlen)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen };
return sys_socketcall(SYS_CONNECT, (unsigned long *)a);
}
long sys_sendto(int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)buff, (uint32_t)len, (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)buff, (uint32_t)len,
+ (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len };
return sys_socketcall(SYS_SENDTO, (unsigned long *)a);
}
long sys_recvfrom(int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)ubuf, (uint32_t)size, (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)ubuf, (uint32_t)size,
+ (uint32_t)flags, (uint32_t)addr, (uint32_t)addr_len };
return sys_socketcall(SYS_RECVFROM, (unsigned long *)a);
}
long sys_sendmsg(int sockfd, const struct msghdr *msg, int flags)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags };
return sys_socketcall(SYS_SENDMSG, (unsigned long *)a);
}
long sys_recvmsg(int sockfd, struct msghdr *msg, int flags)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)msg, (uint32_t)flags };
return sys_socketcall(SYS_RECVMSG, (unsigned long *)a);
}
long sys_shutdown(int sockfd, int how)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)how};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)how };
return sys_socketcall(SYS_SHUTDOWN, (unsigned long *)a);
}
long sys_bind(int sockfd, const struct sockaddr *addr, int addrlen)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)addr, (uint32_t)addrlen };
return sys_socketcall(SYS_BIND, (unsigned long *)a);
}
long sys_setsockopt(int sockfd, int level, int optname, const void *optval, unsigned int optlen)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen };
return sys_socketcall(SYS_SETSOCKOPT, (unsigned long *)a);
}
long sys_getsockopt(int sockfd, int level, int optname, const void *optval, unsigned int *optlen)
{
- uint32_t a[] = {(uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen};
+ uint32_t a[] = { (uint32_t)sockfd, (uint32_t)level, (uint32_t)optname, (uint32_t)optval, (uint32_t)optlen };
return sys_socketcall(SYS_GETSOCKOPT, (unsigned long *)a);
}
-#define SHMAT 21
+#define SHMAT 21
long sys_shmat(int shmid, void *shmaddr, int shmflag)
{
diff --git a/compel/arch/x86/src/lib/cpu.c b/compel/arch/x86/src/lib/cpu.c
index c96f01353..5ca794ea0 100644
--- a/compel/arch/x86/src/lib/cpu.c
+++ b/compel/arch/x86/src/lib/cpu.c
@@ -8,7 +8,7 @@
#include "log.h"
#include "common/bug.h"
-#undef LOG_PREFIX
+#undef LOG_PREFIX
#define LOG_PREFIX "cpu: "
static compel_cpuinfo_t rt_info;
@@ -29,32 +29,24 @@ static void fetch_rt_cpuinfo(void)
* to save/restore PT state in Linux.
*/
-static const char * const xfeature_names[] = {
- "x87 floating point registers" ,
- "SSE registers" ,
- "AVX registers" ,
- "MPX bounds registers" ,
- "MPX CSR" ,
- "AVX-512 opmask" ,
- "AVX-512 Hi256" ,
- "AVX-512 ZMM_Hi256" ,
- "Processor Trace" ,
+static const char *const xfeature_names[] = {
+ "x87 floating point registers",
+ "SSE registers",
+ "AVX registers",
+ "MPX bounds registers",
+ "MPX CSR",
+ "AVX-512 opmask",
+ "AVX-512 Hi256",
+ "AVX-512 ZMM_Hi256",
+ "Processor Trace",
"Protection Keys User registers",
- "Hardware Duty Cycling" ,
+ "Hardware Duty Cycling",
};
static short xsave_cpuid_features[] = {
- X86_FEATURE_FPU,
- X86_FEATURE_XMM,
- X86_FEATURE_AVX,
- X86_FEATURE_MPX,
- X86_FEATURE_MPX,
- X86_FEATURE_AVX512F,
- X86_FEATURE_AVX512F,
- X86_FEATURE_AVX512F,
- X86_FEATURE_INTEL_PT,
- X86_FEATURE_PKU,
- X86_FEATURE_HDC,
+ X86_FEATURE_FPU, X86_FEATURE_XMM, X86_FEATURE_AVX, X86_FEATURE_MPX,
+ X86_FEATURE_MPX, X86_FEATURE_AVX512F, X86_FEATURE_AVX512F, X86_FEATURE_AVX512F,
+ X86_FEATURE_INTEL_PT, X86_FEATURE_PKU, X86_FEATURE_HDC,
};
void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature)
@@ -89,8 +81,7 @@ static int compel_fpuid(compel_cpuinfo_t *c)
uint32_t eax, ebx, ecx, edx;
size_t i;
- BUILD_BUG_ON(ARRAY_SIZE(xsave_cpuid_features) !=
- ARRAY_SIZE(xfeature_names));
+ BUILD_BUG_ON(ARRAY_SIZE(xsave_cpuid_features) != ARRAY_SIZE(xfeature_names));
if (!compel_test_cpu_cap(c, X86_FEATURE_FPU)) {
pr_err("fpu: No FPU detected\n");
@@ -98,9 +89,7 @@ static int compel_fpuid(compel_cpuinfo_t *c)
}
if (!compel_test_cpu_cap(c, X86_FEATURE_XSAVE)) {
- pr_info("fpu: x87 FPU will use %s\n",
- compel_test_cpu_cap(c, X86_FEATURE_FXSR) ?
- "FXSAVE" : "FSAVE");
+ pr_info("fpu: x87 FPU will use %s\n", compel_test_cpu_cap(c, X86_FEATURE_FXSR) ? "FXSAVE" : "FSAVE");
return 0;
}
@@ -140,12 +129,11 @@ static int compel_fpuid(compel_cpuinfo_t *c)
c->xsaves_size = ebx;
pr_debug("fpu: xfeatures_mask 0x%llx xsave_size %u xsave_size_max %u xsaves_size %u\n",
- (unsigned long long)c->xfeatures_mask,
- c->xsave_size, c->xsave_size_max, c->xsaves_size);
+ (unsigned long long)c->xfeatures_mask, c->xsave_size, c->xsave_size_max, c->xsaves_size);
if (c->xsave_size_max > sizeof(struct xsave_struct))
- pr_warn_once("fpu: max xsave frame exceed xsave_struct (%u %u)\n",
- c->xsave_size_max, (unsigned)sizeof(struct xsave_struct));
+ pr_warn_once("fpu: max xsave frame exceed xsave_struct (%u %u)\n", c->xsave_size_max,
+ (unsigned)sizeof(struct xsave_struct));
memset(c->xstate_offsets, 0xff, sizeof(c->xstate_offsets));
memset(c->xstate_sizes, 0xff, sizeof(c->xstate_sizes));
@@ -160,10 +148,10 @@ static int compel_fpuid(compel_cpuinfo_t *c)
* in the fixed offsets in the xsave area in either compacted form
* or standard form.
*/
- c->xstate_offsets[0] = 0;
- c->xstate_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
- c->xstate_offsets[1] = c->xstate_sizes[0];
- c->xstate_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
+ c->xstate_offsets[0] = 0;
+ c->xstate_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
+ c->xstate_offsets[1] = c->xstate_sizes[0];
+ c->xstate_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
if (!(c->xfeatures_mask & (1UL << i)))
@@ -189,8 +177,7 @@ static int compel_fpuid(compel_cpuinfo_t *c)
* highest offset in the buffer. Ensure it does.
*/
if (last_good_offset > c->xstate_offsets[i])
- pr_warn_once("fpu: misordered xstate %d %d\n",
- last_good_offset, c->xstate_offsets[i]);
+ pr_warn_once("fpu: misordered xstate %d %d\n", last_good_offset, c->xstate_offsets[i]);
last_good_offset = c->xstate_offsets[i];
}
@@ -198,10 +185,10 @@ static int compel_fpuid(compel_cpuinfo_t *c)
BUILD_BUG_ON(sizeof(c->xstate_offsets) != sizeof(c->xstate_sizes));
BUILD_BUG_ON(sizeof(c->xstate_comp_offsets) != sizeof(c->xstate_comp_sizes));
- c->xstate_comp_offsets[0] = 0;
- c->xstate_comp_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
- c->xstate_comp_offsets[1] = c->xstate_comp_sizes[0];
- c->xstate_comp_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
+ c->xstate_comp_offsets[0] = 0;
+ c->xstate_comp_sizes[0] = offsetof(struct i387_fxsave_struct, xmm_space);
+ c->xstate_comp_offsets[1] = c->xstate_comp_sizes[0];
+ c->xstate_comp_sizes[1] = FIELD_SIZEOF(struct i387_fxsave_struct, xmm_space);
if (!compel_test_cpu_cap(c, X86_FEATURE_XSAVES)) {
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
@@ -211,8 +198,7 @@ static int compel_fpuid(compel_cpuinfo_t *c)
}
}
} else {
- c->xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] =
- FXSAVE_SIZE + XSAVE_HDR_SIZE;
+ c->xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] = FXSAVE_SIZE + XSAVE_HDR_SIZE;
for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) {
if ((c->xfeatures_mask & (1UL << i)))
@@ -221,8 +207,7 @@ static int compel_fpuid(compel_cpuinfo_t *c)
c->xstate_comp_sizes[i] = 0;
if (i > FIRST_EXTENDED_XFEATURE) {
- c->xstate_comp_offsets[i] = c->xstate_comp_offsets[i-1]
- + c->xstate_comp_sizes[i-1];
+ c->xstate_comp_offsets[i] = c->xstate_comp_offsets[i - 1] + c->xstate_comp_sizes[i - 1];
/*
* The value returned by ECX[1] indicates the alignment
@@ -240,9 +225,9 @@ static int compel_fpuid(compel_cpuinfo_t *c)
for (i = 0; i < ARRAY_SIZE(c->xstate_offsets); i++) {
if (!(c->xfeatures_mask & (1UL << i)))
continue;
- pr_debug("fpu: %-32s xstate_offsets %6d / %-6d xstate_sizes %6d / %-6d\n",
- xfeature_names[i], c->xstate_offsets[i], c->xstate_comp_offsets[i],
- c->xstate_sizes[i], c->xstate_comp_sizes[i]);
+ pr_debug("fpu: %-32s xstate_offsets %6d / %-6d xstate_sizes %6d / %-6d\n", xfeature_names[i],
+ c->xstate_offsets[i], c->xstate_comp_offsets[i], c->xstate_sizes[i],
+ c->xstate_comp_sizes[i]);
}
}
@@ -261,20 +246,15 @@ int compel_cpuid(compel_cpuinfo_t *c)
*/
/* Get vendor name */
- cpuid(0x00000000,
- (unsigned int *)&c->cpuid_level,
- (unsigned int *)&c->x86_vendor_id[0],
- (unsigned int *)&c->x86_vendor_id[8],
- (unsigned int *)&c->x86_vendor_id[4]);
+ cpuid(0x00000000, (unsigned int *)&c->cpuid_level, (unsigned int *)&c->x86_vendor_id[0],
+ (unsigned int *)&c->x86_vendor_id[8], (unsigned int *)&c->x86_vendor_id[4]);
if (!strcmp(c->x86_vendor_id, "GenuineIntel")) {
c->x86_vendor = X86_VENDOR_INTEL;
- } else if (!strcmp(c->x86_vendor_id, "AuthenticAMD") ||
- !strcmp(c->x86_vendor_id, "HygonGenuine")) {
+ } else if (!strcmp(c->x86_vendor_id, "AuthenticAMD") || !strcmp(c->x86_vendor_id, "HygonGenuine")) {
c->x86_vendor = X86_VENDOR_AMD;
} else {
- pr_err("Unsupported CPU vendor %s\n",
- c->x86_vendor_id);
+ pr_err("Unsupported CPU vendor %s\n", c->x86_vendor_id);
return -1;
}
@@ -369,7 +349,7 @@ int compel_cpuid(compel_cpuinfo_t *c)
while (*p)
*q++ = *p++;
while (q <= &c->x86_model_id[48])
- *q++ = '\0'; /* Zero-pad the rest */
+ *q++ = '\0'; /* Zero-pad the rest */
}
}
@@ -440,8 +420,7 @@ int compel_cpuid(compel_cpuinfo_t *c)
break;
}
- pr_debug("x86_family %u x86_vendor_id %s x86_model_id %s\n",
- c->x86_family, c->x86_vendor_id, c->x86_model_id);
+ pr_debug("x86_family %u x86_vendor_id %s x86_model_id %s\n", c->x86_family, c->x86_vendor_id, c->x86_model_id);
return compel_fpuid(c);
}
@@ -461,8 +440,7 @@ bool compel_fpu_has_feature(unsigned int feature)
uint32_t compel_fpu_feature_size(unsigned int feature)
{
fetch_rt_cpuinfo();
- if (feature >= FIRST_EXTENDED_XFEATURE &&
- feature < XFEATURE_MAX)
+ if (feature >= FIRST_EXTENDED_XFEATURE && feature < XFEATURE_MAX)
return rt_info.xstate_sizes[feature];
return 0;
}
@@ -470,8 +448,7 @@ uint32_t compel_fpu_feature_size(unsigned int feature)
uint32_t compel_fpu_feature_offset(unsigned int feature)
{
fetch_rt_cpuinfo();
- if (feature >= FIRST_EXTENDED_XFEATURE &&
- feature < XFEATURE_MAX)
+ if (feature >= FIRST_EXTENDED_XFEATURE && feature < XFEATURE_MAX)
return rt_info.xstate_offsets[feature];
return 0;
}
diff --git a/compel/arch/x86/src/lib/handle-elf.c b/compel/arch/x86/src/lib/handle-elf.c
index 938999b2e..78b23f28a 100644
--- a/compel/arch/x86/src/lib/handle-elf.c
+++ b/compel/arch/x86/src/lib/handle-elf.c
@@ -5,9 +5,8 @@
#include "piegen.h"
#include "log.h"
-static const unsigned char __maybe_unused
-elf_ident_64_le[EI_NIDENT] = {
- 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
+static const unsigned char __maybe_unused elf_ident_64_le[EI_NIDENT] = {
+ 0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, /* clang-format */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
diff --git a/compel/arch/x86/src/lib/infect.c b/compel/arch/x86/src/lib/infect.c
index 566238d2d..1e344bf3a 100644
--- a/compel/arch/x86/src/lib/infect.c
+++ b/compel/arch/x86/src/lib/infect.c
@@ -24,29 +24,27 @@
#include "log.h"
#ifndef NT_X86_XSTATE
-#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
+#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
#endif
#ifndef NT_PRSTATUS
-#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
+#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
#endif
/*
* Injected syscall instruction
*/
const char code_syscall[] = {
- 0x0f, 0x05, /* syscall */
- 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc /* int 3, ... */
+ 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, ... */
+ 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 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)
{
@@ -57,22 +55,22 @@ static inline __always_unused void __check_code_syscall(void)
/* 10-byte legacy floating point register */
struct fpreg {
- uint16_t significand[4];
- uint16_t exponent;
+ uint16_t significand[4];
+ uint16_t exponent;
};
/* 16-byte floating point register */
struct fpxreg {
- uint16_t significand[4];
- uint16_t exponent;
- uint16_t padding[3];
+ uint16_t significand[4];
+ uint16_t exponent;
+ uint16_t padding[3];
};
-#define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n) * 16)
-#define FP_EXP_TAG_VALID 0
-#define FP_EXP_TAG_ZERO 1
-#define FP_EXP_TAG_SPECIAL 2
-#define FP_EXP_TAG_EMPTY 3
+#define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n)*16)
+#define FP_EXP_TAG_VALID 0
+#define FP_EXP_TAG_ZERO 1
+#define FP_EXP_TAG_SPECIAL 2
+#define FP_EXP_TAG_EMPTY 3
static inline uint32_t twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
{
@@ -92,9 +90,7 @@ static inline uint32_t twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
tag = FP_EXP_TAG_SPECIAL;
break;
case 0x0000:
- if (!st->significand[0] &&
- !st->significand[1] &&
- !st->significand[2] &&
+ if (!st->significand[0] && !st->significand[1] && !st->significand[2] &&
!st->significand[3])
tag = FP_EXP_TAG_ZERO;
else
@@ -115,8 +111,7 @@ static inline uint32_t twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
return ret;
}
-void compel_convert_from_fxsr(struct user_i387_ia32_struct *env,
- struct i387_fxsave_struct *fxsave)
+void compel_convert_from_fxsr(struct user_i387_ia32_struct *env, struct i387_fxsave_struct *fxsave)
{
struct fpxreg *from = (struct fpxreg *)&fxsave->st_space[0];
struct fpreg *to = (struct fpreg *)env->st_space;
@@ -140,16 +135,12 @@ void compel_convert_from_fxsr(struct user_i387_ia32_struct *env,
memcpy(&to[i], &from[i], sizeof(to[0]));
}
-int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
- user_regs_struct_t *regs,
- user_fpregs_struct_t *fpregs)
+int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs)
{
bool is_native = user_regs_native(regs);
- fpu_state_t *fpu_state = is_native ?
- &sigframe->native.fpu_state :
- &sigframe->compat.fpu_state;
+ fpu_state_t *fpu_state = is_native ? &sigframe->native.fpu_state : &sigframe->compat.fpu_state;
if (is_native) {
-#define cpreg64_native(d, s) sigframe->native.uc.uc_mcontext.d = regs->native.s
+#define cpreg64_native(d, s) sigframe->native.uc.uc_mcontext.d = regs->native.s
cpreg64_native(rdi, di);
cpreg64_native(rsi, si);
cpreg64_native(rbp, bp);
@@ -173,7 +164,7 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
sigframe->is_native = true;
#undef cpreg64_native
} else {
-#define cpreg32_compat(d) sigframe->compat.uc.uc_mcontext.d = regs->compat.d
+#define cpreg32_compat(d) sigframe->compat.uc.uc_mcontext.d = regs->compat.d
cpreg32_compat(gs);
cpreg32_compat(fs);
cpreg32_compat(es);
@@ -206,34 +197,28 @@ int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe,
return 0;
}
-int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe,
- struct rt_sigframe *rsigframe)
+int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe)
{
- fpu_state_t *fpu_state = (sigframe->is_native) ?
- &rsigframe->native.fpu_state :
- &rsigframe->compat.fpu_state;
+ fpu_state_t *fpu_state = (sigframe->is_native) ? &rsigframe->native.fpu_state : &rsigframe->compat.fpu_state;
if (sigframe->is_native) {
unsigned long addr = (unsigned long)(void *)&fpu_state->fpu_state_64.xsave;
if ((addr % 64ul)) {
- pr_err("Unaligned address passed: %lx (native %d)\n",
- addr, sigframe->is_native);
+ pr_err("Unaligned address passed: %lx (native %d)\n", addr, sigframe->is_native);
return -1;
}
sigframe->native.uc.uc_mcontext.fpstate = (uint64_t)addr;
} else if (!sigframe->is_native) {
- sigframe->compat.uc.uc_mcontext.fpstate =
- (uint32_t)(unsigned long)(void *)&fpu_state->fpu_state_ia32;
+ sigframe->compat.uc.uc_mcontext.fpstate = (uint32_t)(unsigned long)(void *)&fpu_state->fpu_state_ia32;
}
return 0;
}
-#define get_signed_user_reg(pregs, name) \
- ((user_regs_native(pregs)) ? (int64_t)((pregs)->native.name) : \
- (int32_t)((pregs)->compat.name))
+#define get_signed_user_reg(pregs, name) \
+ ((user_regs_native(pregs)) ? (int64_t)((pregs)->native.name) : (int32_t)((pregs)->compat.name))
static int get_task_xsave(pid_t pid, user_fpregs_struct_t *xsave)
{
@@ -310,8 +295,7 @@ static int corrupt_extregs(pid_t pid)
* - zdtm.py will grep it auto-magically from logs
* (and the seed will be known from an automatical testing)
*/
- pr_err("Corrupting %s for %d, seed %u\n",
- use_xsave ? "xsave" : "fpuregs", pid, seed);
+ pr_err("Corrupting %s for %d, seed %u\n", use_xsave ? "xsave" : "fpuregs", pid, seed);
if (!use_xsave) {
if (ptrace(PTRACE_SETFPREGS, pid, NULL, &ext_regs)) {
@@ -334,15 +318,13 @@ static int corrupt_extregs(pid_t pid)
return 0;
}
-int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs,
- user_fpregs_struct_t *ext_regs, save_regs_t save,
- void *arg, unsigned long flags)
+int compel_get_task_regs(pid_t pid, user_regs_struct_t *regs, user_fpregs_struct_t *ext_regs, save_regs_t save,
+ void *arg, unsigned long flags)
{
- user_fpregs_struct_t xsave = { }, *xs = ext_regs ? ext_regs : &xsave;
+ user_fpregs_struct_t xsave = {}, *xs = ext_regs ? ext_regs : &xsave;
int ret = -1;
- pr_info("Dumping general registers for %d in %s mode\n", pid,
- user_regs_native(regs) ? "native" : "compat");
+ pr_info("Dumping general registers for %d in %s mode\n", pid, user_regs_native(regs) ? "native" : "compat");
/* Did we come from a system call? */
if (get_signed_user_reg(regs, orig_ax) >= 0) {
@@ -423,13 +405,8 @@ int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs)
return 0;
}
-int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
- unsigned long arg1,
- unsigned long arg2,
- unsigned long arg3,
- unsigned long arg4,
- unsigned long arg5,
- unsigned long arg6)
+int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret, unsigned long arg1, unsigned long arg2,
+ unsigned long arg3, unsigned long arg4, unsigned long arg5, unsigned long arg6)
{
user_regs_struct_t regs = ctl->orig.regs;
bool native = user_regs_native(&regs);
@@ -438,51 +415,47 @@ int compel_syscall(struct parasite_ctl *ctl, int nr, long *ret,
if (native) {
user_regs_struct64 *r = &regs.native;
- r->ax = (uint64_t)nr;
- r->di = arg1;
- r->si = arg2;
- r->dx = arg3;
+ r->ax = (uint64_t)nr;
+ r->di = arg1;
+ r->si = arg2;
+ r->dx = arg3;
r->r10 = arg4;
- r->r8 = arg5;
- r->r9 = arg6;
+ r->r8 = arg5;
+ r->r9 = arg6;
err = compel_execute_syscall(ctl, &regs, code_syscall);
} else {
user_regs_struct32 *r = &regs.compat;
- r->ax = (uint32_t)nr;
- r->bx = arg1;
- r->cx = arg2;
- r->dx = arg3;
- r->si = arg4;
- r->di = arg5;
- r->bp = arg6;
+ r->ax = (uint32_t)nr;
+ r->bx = arg1;
+ r->cx = arg2;
+ r->dx = arg3;
+ r->si = arg4;
+ r->di = arg5;
+ r->bp = arg6;
err = compel_execute_syscall(ctl, &regs, code_int_80);
}
- *ret = native ?
- (long)get_user_reg(&regs, ax) :
- (int)get_user_reg(&regs, ax);
+ *ret = native ? (long)get_user_reg(&regs, ax) : (int)get_user_reg(&regs, ax);
return err;
}
-void *remote_mmap(struct parasite_ctl *ctl,
- void *addr, size_t length, int prot,
- int flags, int fd, off_t offset)
+void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
long map;
int err;
bool compat_task = !user_regs_native(&ctl->orig.regs);
- err = compel_syscall(ctl, __NR(mmap, compat_task), &map,
- (unsigned long)addr, length, prot, flags, fd, offset);
+ err = compel_syscall(ctl, __NR(mmap, compat_task), &map, (unsigned long)addr, length, prot, flags, fd, offset);
if (err < 0)
return NULL;
if (map == -EACCES && (prot & PROT_WRITE) && (prot & PROT_EXEC)) {
pr_warn("mmap(PROT_WRITE | PROT_EXEC) failed for %d, "
- "check selinux execmem policy\n", ctl->rpid);
+ "check selinux execmem policy\n",
+ ctl->rpid);
return NULL;
}
if (IS_ERR_VALUE(map)) {
@@ -507,18 +480,17 @@ void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *
{
set_user_reg(regs, ip, new_ip);
if (stack)
- set_user_reg(regs, sp, (unsigned long) stack);
+ set_user_reg(regs, sp, (unsigned long)stack);
/* Avoid end of syscall processing */
set_user_reg(regs, orig_ax, -1);
/* Make sure flags are in known state */
- set_user_reg(regs, flags, get_user_reg(regs, flags) &
- ~(X86_EFLAGS_TF | X86_EFLAGS_DF | X86_EFLAGS_IF));
+ set_user_reg(regs, flags, get_user_reg(regs, flags) & ~(X86_EFLAGS_TF | X86_EFLAGS_DF | X86_EFLAGS_IF));
}
-#define USER32_CS 0x23
-#define USER_CS 0x33
+#define USER32_CS 0x23
+#define USER_CS 0x33
static bool ldt_task_selectors(pid_t pid)
{
@@ -574,30 +546,26 @@ bool arch_can_dump_task(struct parasite_ctl *ctl)
int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s)
{
int native = compel_mode_native(ctl);
- void *where = native ?
- (void *)&s->native.uc.uc_stack :
- (void *)&s->compat.uc.uc_stack;
+ void *where = native ? (void *)&s->native.uc.uc_stack : (void *)&s->compat.uc.uc_stack;
long ret;
int err;
- err = compel_syscall(ctl, __NR(sigaltstack, !native),
- &ret, 0, (unsigned long)where,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR(sigaltstack, !native), &ret, 0, (unsigned long)where, 0, 0, 0, 0);
return err ? err : ret;
}
/* Copied from the gdb header gdb/nat/x86-dregs.h */
/* Debug registers' indices. */
-#define DR_FIRSTADDR 0
-#define DR_LASTADDR 3
-#define DR_NADDR 4 /* The number of debug address registers. */
-#define DR_STATUS 6 /* Index of debug status register (DR6). */
-#define DR_CONTROL 7 /* Index of debug control register (DR7). */
+#define DR_FIRSTADDR 0
+#define DR_LASTADDR 3
+#define DR_NADDR 4 /* The number of debug address registers. */
+#define DR_STATUS 6 /* Index of debug status register (DR6). */
+#define DR_CONTROL 7 /* Index of debug control register (DR7). */
-#define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit. */
-#define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit. */
-#define DR_ENABLE_SIZE 2 /* Two enable bits per debug register. */
+#define DR_LOCAL_ENABLE_SHIFT 0 /* Extra shift to the local enable bit. */
+#define DR_GLOBAL_ENABLE_SHIFT 1 /* Extra shift to the global enable bit. */
+#define DR_ENABLE_SIZE 2 /* Two enable bits per debug register. */
/* Locally enable the break/watchpoint in the I'th debug register. */
#define X86_DR_LOCAL_ENABLE(i) (1 << (DR_LOCAL_ENABLE_SHIFT + DR_ENABLE_SIZE * (i)))
@@ -607,17 +575,14 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
int ret;
/* Set a breakpoint */
- if (ptrace(PTRACE_POKEUSER, pid,
- offsetof(struct user, u_debugreg[DR_FIRSTADDR]),
- addr)) {
+ if (ptrace(PTRACE_POKEUSER, pid, offsetof(struct user, u_debugreg[DR_FIRSTADDR]), addr)) {
pr_perror("Unable to setup a breakpoint into %d", pid);
return -1;
}
/* Enable the breakpoint */
- if (ptrace(PTRACE_POKEUSER, pid,
- offsetof(struct user, u_debugreg[DR_CONTROL]),
- X86_DR_LOCAL_ENABLE(DR_FIRSTADDR))) {
+ if (ptrace(PTRACE_POKEUSER, pid, offsetof(struct user, u_debugreg[DR_CONTROL]),
+ X86_DR_LOCAL_ENABLE(DR_FIRSTADDR))) {
pr_perror("Unable to enable the breakpoint for %d", pid);
return -1;
}
@@ -634,9 +599,7 @@ int ptrace_set_breakpoint(pid_t pid, void *addr)
int ptrace_flush_breakpoints(pid_t pid)
{
/* Disable the breakpoint */
- if (ptrace(PTRACE_POKEUSER, pid,
- offsetof(struct user, u_debugreg[DR_CONTROL]),
- 0)) {
+ if (ptrace(PTRACE_POKEUSER, pid, offsetof(struct user, u_debugreg[DR_CONTROL]), 0)) {
pr_perror("Unable to disable the breakpoint for %d", pid);
return -1;
}
@@ -668,8 +631,7 @@ int ptrace_get_regs(pid_t pid, user_regs_struct_t *regs)
}
pr_err("PTRACE_GETREGSET read %zu bytes for pid %d, but native/compat regs sizes are %zu/%zu bytes\n",
- iov.iov_len, pid,
- sizeof(regs->native), sizeof(regs->compat));
+ iov.iov_len, pid, sizeof(regs->native), sizeof(regs->compat));
return -1;
}
@@ -687,11 +649,14 @@ int ptrace_set_regs(pid_t pid, user_regs_struct_t *regs)
return ptrace(PTRACE_SETREGSET, pid, NT_PRSTATUS, &iov);
}
-#define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
+#define TASK_SIZE ((1UL << 47) - PAGE_SIZE)
/*
* Task size may be limited to 3G but we need a
* higher limit, because it's backward compatible.
*/
-#define TASK_SIZE_IA32 (0xffffe000)
+#define TASK_SIZE_IA32 (0xffffe000)
-unsigned long compel_task_size(void) { return TASK_SIZE; }
+unsigned long compel_task_size(void)
+{
+ return TASK_SIZE;
+}
diff --git a/compel/arch/x86/src/lib/thread_area.c b/compel/arch/x86/src/lib/thread_area.c
index 3ff5dc5d4..4750c6cdd 100644
--- a/compel/arch/x86/src/lib/thread_area.c
+++ b/compel/arch/x86/src/lib/thread_area.c
@@ -8,7 +8,7 @@
#include "infect-priv.h"
#ifndef PTRACE_GET_THREAD_AREA
-# define PTRACE_GET_THREAD_AREA 25
+#define PTRACE_GET_THREAD_AREA 25
#endif
/*
@@ -49,12 +49,10 @@ int __compel_arch_fetch_thread_area(int tid, struct thread_ctx *th)
d->entry_number = GDT_ENTRY_TLS_MIN + i;
}
- for (i = 0; i < GDT_ENTRY_TLS_NUM; i++)
- {
+ for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) {
user_desc_t *d = &ptls->desc[i];
- err = ptrace(PTRACE_GET_THREAD_AREA, tid,
- GDT_ENTRY_TLS_MIN + i, d);
+ err = ptrace(PTRACE_GET_THREAD_AREA, tid, GDT_ENTRY_TLS_MIN + i, d);
/*
* Ignoring absent syscall on !CONFIG_IA32_EMULATION
* where such mixed code can't run.
diff --git a/compel/plugins/fds/fds.c b/compel/plugins/fds/fds.c
index 7ed94509d..c0c6a2131 100644
--- a/compel/plugins/fds/fds.c
+++ b/compel/plugins/fds/fds.c
@@ -9,8 +9,8 @@
#include "common/compiler.h"
#include "common/bug.h"
-#define __sys(foo) sys_##foo
-#define __sys_err(ret) ret
+#define __sys(foo) sys_##foo
+#define __sys_err(ret) ret
#include "common/scm.h"
diff --git a/compel/plugins/shmem/shmem.c b/compel/plugins/shmem/shmem.c
index 695d1931f..2b402f926 100644
--- a/compel/plugins/shmem/shmem.c
+++ b/compel/plugins/shmem/shmem.c
@@ -12,8 +12,7 @@ void *shmem_create(unsigned long size)
void *mem;
struct shmem_plugin_msg spi;
- mem = (void *)sys_mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_ANONYMOUS, 0, 0);
+ mem = (void *)sys_mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0);
if (mem == MAP_FAILED)
return NULL;
diff --git a/compel/plugins/std/fds.c b/compel/plugins/std/fds.c
index 499102788..6a0757992 100644
--- a/compel/plugins/std/fds.c
+++ b/compel/plugins/std/fds.c
@@ -10,7 +10,7 @@
#include "common/compiler.h"
#include "common/bug.h"
-#define __sys(foo) sys_##foo
-#define __sys_err(ret) ret
+#define __sys(foo) sys_##foo
+#define __sys_err(ret) ret
#include "common/scm-code.c"
diff --git a/compel/plugins/std/infect.c b/compel/plugins/std/infect.c
index 9749db7b7..abecc140f 100644
--- a/compel/plugins/std/infect.c
+++ b/compel/plugins/std/infect.c
@@ -5,9 +5,9 @@
#include "common/lock.h"
#include "common/page.h"
-#define pr_err(fmt, ...) print_on_level(1, fmt, ##__VA_ARGS__)
-#define pr_info(fmt, ...) print_on_level(3, fmt, ##__VA_ARGS__)
-#define pr_debug(fmt, ...) print_on_level(4, fmt, ##__VA_ARGS__)
+#define pr_err(fmt, ...) print_on_level(1, fmt, ##__VA_ARGS__)
+#define pr_info(fmt, ...) print_on_level(3, fmt, ##__VA_ARGS__)
+#define pr_debug(fmt, ...) print_on_level(4, fmt, ##__VA_ARGS__)
#include "common/bug.h"
@@ -51,8 +51,7 @@ static int __parasite_daemon_reply_ack(unsigned int cmd, int err)
return -1;
}
- pr_debug("__sent ack msg: %d %d %d\n",
- m.cmd, m.ack, m.err);
+ pr_debug("__sent ack msg: %d %d %d\n", m.cmd, m.ack, m.err);
return 0;
}
@@ -64,16 +63,14 @@ static int __parasite_daemon_wait_msg(struct ctl_msg *m)
pr_debug("Daemon waits for command\n");
while (1) {
- *m = (struct ctl_msg){ };
+ *m = (struct ctl_msg){};
ret = sys_recvfrom(tsock, m, sizeof(*m), MSG_WAITALL, NULL, 0);
if (ret != sizeof(*m)) {
- pr_err("Trimmed message received (%d/%d)\n",
- (int)sizeof(*m), ret);
+ pr_err("Trimmed message received (%d/%d)\n", (int)sizeof(*m), ret);
return -1;
}
- pr_debug("__fetched msg: %d %d %d\n",
- m->cmd, m->ack, m->err);
+ pr_debug("__fetched msg: %d %d %d\n", m->cmd, m->ack, m->err);
return 0;
}
@@ -94,8 +91,7 @@ static int fini(void)
parasite_cleanup();
new_sp = (long)sigframe + RT_SIGFRAME_OFFSET(sigframe);
- pr_debug("%ld: new_sp=%lx ip %lx\n", sys_gettid(),
- new_sp, RT_SIGFRAME_REGIP(sigframe));
+ pr_debug("%ld: new_sp=%lx ip %lx\n", sys_gettid(), new_sp, RT_SIGFRAME_REGIP(sigframe));
sys_close(tsock);
std_log_set_fd(-1);
@@ -155,7 +151,7 @@ static noinline __used int parasite_init_daemon(void *data)
int ret;
args->sigreturn_addr = (uint64_t)(uintptr_t)fini_sigreturn;
- sigframe = (void*)(uintptr_t)args->sigframe;
+ sigframe = (void *)(uintptr_t)args->sigframe;
#ifdef ARCH_HAS_LONG_PAGES
__page_size = args->page_size;
#endif
@@ -193,7 +189,7 @@ err:
}
#ifndef __parasite_entry
-# define __parasite_entry
+#define __parasite_entry
#endif
/*
@@ -205,7 +201,7 @@ err:
* initialization. Otherwise, we end up with COMMON symbols.
*/
unsigned int __export_parasite_service_cmd = 0;
-void * __export_parasite_service_args_ptr = NULL;
+void *__export_parasite_service_args_ptr = NULL;
int __used __parasite_entry parasite_service(void)
{
diff --git a/compel/plugins/std/std.c b/compel/plugins/std/std.c
index 82f51eac4..01f88ef80 100644
--- a/compel/plugins/std/std.c
+++ b/compel/plugins/std/std.c
@@ -46,11 +46,9 @@ err:
return ret;
}
-#define plugin_init_count(size) ((size) / (sizeof(plugin_init_t *)))
+#define plugin_init_count(size) ((size) / (sizeof(plugin_init_t *)))
-int __export_std_compel_start(struct prologue_init_args *args,
- const plugin_init_t * const *init_array,
- size_t init_size)
+int __export_std_compel_start(struct prologue_init_args *args, const plugin_init_t *const *init_array, size_t init_size)
{
unsigned int i;
int ret = 0;
diff --git a/compel/plugins/std/string.c b/compel/plugins/std/string.c
index 85bede803..bde1bc68b 100644
--- a/compel/plugins/std/string.c
+++ b/compel/plugins/std/string.c
@@ -100,18 +100,11 @@ void std_vdprintf(int fd, const char *format, va_list args)
std_dputs(fd, va_arg(args, char *));
break;
case 'd':
- __std_vprint_long(buf, sizeof(buf),
- along ?
- va_arg(args, long) :
- (long)va_arg(args, int),
- &t);
+ __std_vprint_long(buf, sizeof(buf), along ? va_arg(args, long) : (long)va_arg(args, int), &t);
std_dputs(fd, t);
break;
case 'x':
- __std_vprint_long_hex(buf, sizeof(buf),
- along ?
- va_arg(args, long) :
- (long)va_arg(args, int),
+ __std_vprint_long_hex(buf, sizeof(buf), along ? va_arg(args, long) : (long)va_arg(args, int),
&t);
std_dputs(fd, t);
break;
@@ -130,9 +123,7 @@ void std_dprintf(int fd, const char *format, ...)
static inline bool __isspace(unsigned char c)
{
- return c == ' ' || c == '\f' ||
- c == '\n' || c == '\r' ||
- c == '\t' || c == '\v';
+ return c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v';
}
static unsigned char __tolower(unsigned char c)
@@ -142,8 +133,7 @@ static unsigned char __tolower(unsigned char c)
static inline bool __isalpha(unsigned char c)
{
- return ((c <= 'Z' && c >= 'A') ||
- (c <= 'z' && c >= 'a'));
+ return ((c <= 'Z' && c >= 'A') || (c <= 'z' && c >= 'a'));
}
static inline bool __isdigit(unsigned char c)
@@ -208,7 +198,7 @@ unsigned long std_strtoul(const char *nptr, char **endptr, int base)
if (__isspace(*s))
continue;
if (!__isalnum(*s))
- goto fin;
+ goto fin;
v = __conv_val(*s);
if (v == -1u || v > base)
goto fin;
@@ -222,7 +212,6 @@ fin:
return neg ? (unsigned long)-num : (unsigned long)num;
}
-
/*
* C compiler is free to insert implicit calls to memcmp, memset,
* memcpy and memmove, assuming they are available during linking.
@@ -267,7 +256,7 @@ void *memset(void *s, const int c, size_t count)
size_t i = 0;
while (i < count)
- dest[i++] = (char) c;
+ dest[i++] = (char)c;
return s;
}
diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c
index 9a972bee6..9662751e0 100644
--- a/compel/src/lib/handle-elf.c
+++ b/compel/src/lib/handle-elf.c
@@ -28,44 +28,39 @@ static bool __ptr_oob(const uintptr_t ptr, const uintptr_t start, const size_t s
}
/* Check if pointed structure's end is out-of-bound */
-static bool __ptr_struct_end_oob(const uintptr_t ptr, const size_t struct_size,
- const uintptr_t start, const size_t size)
+static bool __ptr_struct_end_oob(const uintptr_t ptr, const size_t struct_size, const uintptr_t start,
+ const size_t size)
{
/* the last byte of the structure should be inside [begin, end) */
return __ptr_oob(ptr + struct_size - 1, start, size);
}
/* Check if pointed structure is out-of-bound */
-static bool __ptr_struct_oob(const uintptr_t ptr, const size_t struct_size,
- const uintptr_t start, const size_t size)
+static bool __ptr_struct_oob(const uintptr_t ptr, const size_t struct_size, const uintptr_t start, const size_t size)
{
- return __ptr_oob(ptr, start, size) ||
- __ptr_struct_end_oob(ptr, struct_size, start, size);
+ return __ptr_oob(ptr, start, size) || __ptr_struct_end_oob(ptr, struct_size, start, size);
}
-static bool test_pointer(const void *ptr, const void *start, const size_t size,
- const char *name, const char *file, const int line)
+static bool test_pointer(const void *ptr, const void *start, const size_t size, const char *name, const char *file,
+ const int line)
{
if (__ptr_oob((const uintptr_t)ptr, (const uintptr_t)start, size)) {
- pr_err("Corrupted pointer %p (%s) at %s:%d\n",
- ptr, name, file, line);
+ pr_err("Corrupted pointer %p (%s) at %s:%d\n", ptr, name, file, line);
return true;
}
return false;
}
-#define ptr_func_exit(__ptr) \
- do { \
- if (test_pointer((__ptr), mem, size, #__ptr, \
- __FILE__, __LINE__)) { \
- free(sec_hdrs); \
- return -1; \
- } \
+#define ptr_func_exit(__ptr) \
+ do { \
+ if (test_pointer((__ptr), mem, size, #__ptr, __FILE__, __LINE__)) { \
+ free(sec_hdrs); \
+ return -1; \
+ } \
} while (0)
#ifdef ELF_PPC64
-static int do_relative_toc(long value, uint16_t *location,
- unsigned long mask, int complain_signed)
+static int do_relative_toc(long value, uint16_t *location, unsigned long mask, int complain_signed)
{
if (complain_signed && (value + 0x8000 > 0xffff)) {
pr_err("TOC16 relocation overflows (%ld)\n", value);
@@ -73,8 +68,7 @@ static int do_relative_toc(long value, uint16_t *location,
}
if ((~mask & 0xffff) & value) {
- pr_err("bad TOC16 relocation (%ld) (0x%lx)\n",
- value, (~mask & 0xffff) & value);
+ pr_err("bad TOC16 relocation (%ld) (0x%lx)\n", value, (~mask & 0xffff) & value);
return -1;
}
@@ -89,23 +83,24 @@ static bool is_header_supported(Elf_Ehdr *hdr)
return false;
if ((hdr->e_type != ET_REL
#ifdef NO_RELOCS
- && hdr->e_type != ET_EXEC
+ && hdr->e_type != ET_EXEC
#endif
- ) || hdr->e_version != EV_CURRENT)
+ ) ||
+ hdr->e_version != EV_CURRENT)
return false;
return true;
}
static const char *get_strings_section(Elf_Ehdr *hdr, uintptr_t mem, size_t size)
{
- size_t sec_table_size = ((size_t) hdr->e_shentsize) * hdr->e_shnum;
+ size_t sec_table_size = ((size_t)hdr->e_shentsize) * hdr->e_shnum;
uintptr_t sec_table = mem + hdr->e_shoff;
Elf_Shdr *secstrings_hdr;
uintptr_t addr;
if (__ptr_struct_oob(sec_table, sec_table_size, mem, size)) {
- pr_err("Section table [%#zx, %#zx) is out of [%#zx, %#zx)\n",
- sec_table, sec_table + sec_table_size, mem, mem + size);
+ pr_err("Section table [%#zx, %#zx) is out of [%#zx, %#zx)\n", sec_table, sec_table + sec_table_size,
+ mem, mem + size);
return NULL;
}
@@ -113,24 +108,22 @@ static const char *get_strings_section(Elf_Ehdr *hdr, uintptr_t mem, size_t size
* strings section header's offset in section headers table is
* (size of section header * index of string section header)
*/
- addr = sec_table + ((size_t) hdr->e_shentsize) * hdr->e_shstrndx;
- if (__ptr_struct_oob(addr, sizeof(Elf_Shdr),
- sec_table, sec_table_size)) {
- pr_err("String section header @%#zx is out of [%#zx, %#zx)\n",
- addr, sec_table, sec_table + sec_table_size);
+ addr = sec_table + ((size_t)hdr->e_shentsize) * hdr->e_shstrndx;
+ if (__ptr_struct_oob(addr, sizeof(Elf_Shdr), sec_table, sec_table_size)) {
+ pr_err("String section header @%#zx is out of [%#zx, %#zx)\n", addr, sec_table,
+ sec_table + sec_table_size);
return NULL;
}
- secstrings_hdr = (void*)addr;
+ secstrings_hdr = (void *)addr;
addr = mem + secstrings_hdr->sh_offset;
if (__ptr_struct_oob(addr, secstrings_hdr->sh_size, mem, size)) {
- pr_err("String section @%#zx size %#lx is out of [%#zx, %#zx)\n",
- addr, (unsigned long)secstrings_hdr->sh_size,
- mem, mem + size);
+ pr_err("String section @%#zx size %#lx is out of [%#zx, %#zx)\n", addr,
+ (unsigned long)secstrings_hdr->sh_size, mem, mem + size);
return NULL;
}
- return (void*)addr;
+ return (void *)addr;
}
/*
@@ -159,8 +152,7 @@ int __handle_elf(void *mem, size_t size)
pr_debug("Header\n");
pr_debug("------------\n");
- pr_debug("\ttype 0x%x machine 0x%x version 0x%x\n",
- (unsigned)hdr->e_type, (unsigned)hdr->e_machine,
+ pr_debug("\ttype 0x%x machine 0x%x version 0x%x\n", (unsigned)hdr->e_type, (unsigned)hdr->e_machine,
(unsigned)hdr->e_version);
if (!is_header_supported(hdr)) {
@@ -189,8 +181,7 @@ int __handle_elf(void *mem, size_t size)
symtab_hdr = sh;
ptr_func_exit(&secstrings[sh->sh_name]);
- pr_debug("\t index %-2zd type 0x%-2x name %s\n", i,
- (unsigned)sh->sh_type, &secstrings[sh->sh_name]);
+ pr_debug("\t index %-2zd type 0x%-2x name %s\n", i, (unsigned)sh->sh_type, &secstrings[sh->sh_name]);
sec_hdrs[i] = sh;
@@ -214,9 +205,7 @@ int __handle_elf(void *mem, size_t size)
}
if (sh->sh_addr && sh->sh_addr != k)
pr_info("Overriding unexpected precalculated address of section (section %s addr 0x%lx expected 0x%lx)\n",
- &secstrings[sh->sh_name],
- (unsigned long) sh->sh_addr,
- (unsigned long) k);
+ &secstrings[sh->sh_name], (unsigned long)sh->sh_addr, (unsigned long)k);
sh->sh_addr = k;
k += sh->sh_size;
}
@@ -262,8 +251,8 @@ int __handle_elf(void *mem, size_t size)
continue;
pr_debug("\ttype 0x%-2x bind 0x%-2x shndx 0x%-4x value 0x%-2lx name %s\n",
- (unsigned)ELF_ST_TYPE(sym->st_info), (unsigned)ELF_ST_BIND(sym->st_info),
- (unsigned)sym->st_shndx, (unsigned long)sym->st_value, name);
+ (unsigned)ELF_ST_TYPE(sym->st_info), (unsigned)ELF_ST_BIND(sym->st_info),
+ (unsigned)sym->st_shndx, (unsigned long)sym->st_value, name);
#ifdef ELF_PPC64
if (!sym->st_value && !strncmp(name, ".TOC.", 6)) {
if (!toc_offset) {
@@ -276,18 +265,15 @@ int __handle_elf(void *mem, size_t size)
#endif
if (strncmp(name, "__export", 8))
continue;
- if ((sym->st_shndx && sym->st_shndx < hdr->e_shnum) ||
- sym->st_shndx == SHN_ABS) {
+ if ((sym->st_shndx && sym->st_shndx < hdr->e_shnum) || sym->st_shndx == SHN_ABS) {
if (sym->st_shndx == SHN_ABS) {
sh_src = NULL;
} else {
sh_src = sec_hdrs[sym->st_shndx];
ptr_func_exit(sh_src);
}
- pr_out("#define %s_sym%s 0x%lx\n",
- opts.prefix, name,
- (unsigned long)(sym->st_value +
- (sh_src ? sh_src->sh_addr : 0)));
+ pr_out("#define %s_sym%s 0x%lx\n", opts.prefix, name,
+ (unsigned long)(sym->st_value + (sh_src ? sh_src->sh_addr : 0)));
}
}
@@ -305,9 +291,8 @@ int __handle_elf(void *mem, size_t size)
sh_rel = sec_hdrs[sh->sh_info];
ptr_func_exit(sh_rel);
- pr_debug("\tsection %2zd type 0x%-2x link 0x%-2x info 0x%-2x name %s\n", i,
- (unsigned)sh->sh_type, (unsigned)sh->sh_link,
- (unsigned)sh->sh_info, &secstrings[sh->sh_name]);
+ pr_debug("\tsection %2zd type 0x%-2x link 0x%-2x info 0x%-2x name %s\n", i, (unsigned)sh->sh_type,
+ (unsigned)sh->sh_link, (unsigned)sh->sh_info, &secstrings[sh->sh_name]);
for (k = 0; k < sh->sh_size / sh->sh_entsize; k++) {
int64_t __maybe_unused addend64, __maybe_unused value64;
@@ -334,8 +319,7 @@ int __handle_elf(void *mem, size_t size)
pr_debug("\t\tr_offset 0x%-4lx r_info 0x%-4lx / sym 0x%-2lx type 0x%-2lx symsecoff 0x%-4lx\n",
(unsigned long)r->rel.r_offset, (unsigned long)r->rel.r_info,
- (unsigned long)ELF_R_SYM(r->rel.r_info),
- (unsigned long)ELF_R_TYPE(r->rel.r_info),
+ (unsigned long)ELF_R_SYM(r->rel.r_info), (unsigned long)ELF_R_TYPE(r->rel.r_info),
(unsigned long)sh_rel->sh_addr);
if (sym->st_shndx == SHN_UNDEF) {
@@ -345,8 +329,7 @@ int __handle_elf(void *mem, size_t size)
* Their type is STT_NOTYPE, so report any
* other one.
*/
- if (ELF32_ST_TYPE(sym->st_info) != STT_NOTYPE
- || strncmp(name, ".TOC.", 6)) {
+ if (ELF32_ST_TYPE(sym->st_info) != STT_NOTYPE || strncmp(name, ".TOC.", 6)) {
pr_err("Unexpected undefined symbol:%s\n", name);
goto err;
}
@@ -385,8 +368,8 @@ int __handle_elf(void *mem, size_t size)
Elf_Shdr *sh_src;
if ((unsigned)sym->st_shndx > (unsigned)hdr->e_shnum) {
- pr_err("Unexpected symbol section index %u/%u\n",
- (unsigned)sym->st_shndx, hdr->e_shnum);
+ pr_err("Unexpected symbol section index %u/%u\n", (unsigned)sym->st_shndx,
+ hdr->e_shnum);
goto err;
}
sh_src = sec_hdrs[sym->st_shndx];
@@ -419,11 +402,10 @@ int __handle_elf(void *mem, size_t size)
*
* Here we are only handle the case '3' which is the most commonly seen.
*/
-#define LOCAL_OFFSET(s) ((s->st_other >> 5) & 0x7)
+#define LOCAL_OFFSET(s) ((s->st_other >> 5) & 0x7)
if (LOCAL_OFFSET(sym)) {
if (LOCAL_OFFSET(sym) != 3) {
- pr_err("Unexpected local offset value %d\n",
- LOCAL_OFFSET(sym));
+ pr_err("Unexpected local offset value %d\n", LOCAL_OFFSET(sym));
goto err;
}
pr_debug("\t\t\tUsing local offset\n");
@@ -435,28 +417,28 @@ int __handle_elf(void *mem, size_t size)
switch (ELF_R_TYPE(r->rel.r_info)) {
#ifdef CONFIG_MIPS
case R_MIPS_PC16:
- /* s+a-p relative */
- *((int32_t *)where) = *((int32_t *)where) | ((value32 + addend32 - place)>>2);
- break;
+ /* s+a-p relative */
+ *((int32_t *)where) = *((int32_t *)where) | ((value32 + addend32 - place) >> 2);
+ break;
case R_MIPS_26:
- /* local : (((A << 2) | (P & 0xf0000000) + S) >> 2
+ /* local : (((A << 2) | (P & 0xf0000000) + S) >> 2
* external : (sign–extend(A < 2) + S) >> 2
*/
- if (((unsigned)ELF_ST_BIND(sym->st_info) == 0x1)
- || ((unsigned)ELF_ST_BIND(sym->st_info) == 0x2)){
- /* bind type local is 0x0 ,global is 0x1,WEAK is 0x2 */
- addend32 = value32;
- }
- pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_26, "
- ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_26 */\n",
- (unsigned int)place, addend32, value32);
- break;
+ if (((unsigned)ELF_ST_BIND(sym->st_info) == 0x1) ||
+ ((unsigned)ELF_ST_BIND(sym->st_info) == 0x2)) {
+ /* bind type local is 0x0 ,global is 0x1,WEAK is 0x2 */
+ addend32 = value32;
+ }
+ pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_26, "
+ ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_26 */\n",
+ (unsigned int)place, addend32, value32);
+ break;
case R_MIPS_32:
- /* S+A */
- break;
+ /* S+A */
+ break;
case R_MIPS_64:
pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_64, "
@@ -465,39 +447,38 @@ int __handle_elf(void *mem, size_t size)
break;
case R_MIPS_HIGHEST:
- pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HIGHEST, "
- ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HIGHEST */\n",
- (unsigned int)place, addend32, value32);
- break;
+ pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HIGHEST, "
+ ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HIGHEST */\n",
+ (unsigned int)place, addend32, value32);
+ break;
case R_MIPS_HIGHER:
- pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HIGHER, "
- ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HIGHER */\n",
- (unsigned int)place, addend32, value32);
- break;
+ pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HIGHER, "
+ ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HIGHER */\n",
+ (unsigned int)place, addend32, value32);
+ break;
case R_MIPS_HI16:
- pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HI16, "
- ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HI16 */\n",
- (unsigned int)place, addend32, value32);
- break;
+ pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_HI16, "
+ ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_HI16 */\n",
+ (unsigned int)place, addend32, value32);
+ break;
case R_MIPS_LO16:
- if((unsigned)ELF_ST_BIND(sym->st_info) == 0x1){
- /* bind type local is 0x0 ,global is 0x1 */
- addend32 = value32;
- }
- pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_LO16, "
- ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_LO16 */\n",
- (unsigned int)place, addend32, value32);
- break;
+ if ((unsigned)ELF_ST_BIND(sym->st_info) == 0x1) {
+ /* bind type local is 0x0 ,global is 0x1 */
+ addend32 = value32;
+ }
+ pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_MIPS_LO16, "
+ ".addend = %-8d, .value = 0x%-16x, }, /* R_MIPS_LO16 */\n",
+ (unsigned int)place, addend32, value32);
+ break;
#endif
#ifdef ELF_PPC64
case R_PPC64_REL24:
/* Update PC relative offset, linker has not done this yet */
- pr_debug("\t\t\tR_PPC64_REL24 at 0x%-4lx val 0x%lx\n",
- place, value64);
+ pr_debug("\t\t\tR_PPC64_REL24 at 0x%-4lx val 0x%lx\n", place, value64);
/* Convert value to relative */
value64 -= place;
if (value64 + 0x2000000 > 0x3ffffff || (value64 & 3) != 0) {
@@ -505,60 +486,54 @@ int __handle_elf(void *mem, size_t size)
goto err;
}
/* Only replace bits 2 through 26 */
- *(uint32_t *)where = (*(uint32_t *)where & ~0x03fffffc) |
- (value64 & 0x03fffffc);
+ *(uint32_t *)where = (*(uint32_t *)where & ~0x03fffffc) | (value64 & 0x03fffffc);
break;
case R_PPC64_ADDR32:
case R_PPC64_REL32:
- pr_debug("\t\t\tR_PPC64_ADDR32 at 0x%-4lx val 0x%x\n",
- place, (unsigned int)(value32 + addend32));
+ pr_debug("\t\t\tR_PPC64_ADDR32 at 0x%-4lx val 0x%x\n", place,
+ (unsigned int)(value32 + addend32));
pr_out(" { .offset = 0x%-8x, .type = COMPEL_TYPE_INT, "
" .addend = %-8d, .value = 0x%-16x, "
"}, /* R_PPC64_ADDR32 */\n",
- (unsigned int) place, addend32, value32);
+ (unsigned int)place, addend32, value32);
break;
case R_PPC64_ADDR64:
case R_PPC64_REL64:
- pr_debug("\t\t\tR_PPC64_ADDR64 at 0x%-4lx val 0x%lx\n",
- place, value64 + addend64);
+ pr_debug("\t\t\tR_PPC64_ADDR64 at 0x%-4lx val 0x%lx\n", place, value64 + addend64);
pr_out("\t{ .offset = 0x%-8x, .type = COMPEL_TYPE_LONG,"
" .addend = %-8ld, .value = 0x%-16lx, "
"}, /* R_PPC64_ADDR64 */\n",
- (unsigned int) place, (long)addend64, (long)value64);
+ (unsigned int)place, (long)addend64, (long)value64);
break;
case R_PPC64_TOC16_HA:
- pr_debug("\t\t\tR_PPC64_TOC16_HA at 0x%-4lx val 0x%lx\n",
- place, value64 + addend64 - toc_offset + 0x8000);
- if (do_relative_toc((value64 + addend64 - toc_offset + 0x8000) >> 16,
- where, 0xffff, 1))
+ pr_debug("\t\t\tR_PPC64_TOC16_HA at 0x%-4lx val 0x%lx\n", place,
+ value64 + addend64 - toc_offset + 0x8000);
+ if (do_relative_toc((value64 + addend64 - toc_offset + 0x8000) >> 16, where, 0xffff, 1))
goto err;
break;
case R_PPC64_TOC16_LO:
- pr_debug("\t\t\tR_PPC64_TOC16_LO at 0x%-4lx val 0x%lx\n",
- place, value64 + addend64 - toc_offset);
- if (do_relative_toc(value64 + addend64 - toc_offset,
- where, 0xffff, 1))
+ pr_debug("\t\t\tR_PPC64_TOC16_LO at 0x%-4lx val 0x%lx\n", place,
+ value64 + addend64 - toc_offset);
+ if (do_relative_toc(value64 + addend64 - toc_offset, where, 0xffff, 1))
goto err;
break;
case R_PPC64_TOC16_LO_DS:
- pr_debug("\t\t\tR_PPC64_TOC16_LO_DS at 0x%-4lx val 0x%lx\n",
- place, value64 + addend64 - toc_offset);
- if (do_relative_toc(value64 + addend64 - toc_offset,
- where, 0xfffc, 0))
+ pr_debug("\t\t\tR_PPC64_TOC16_LO_DS at 0x%-4lx val 0x%lx\n", place,
+ value64 + addend64 - toc_offset);
+ if (do_relative_toc(value64 + addend64 - toc_offset, where, 0xfffc, 0))
goto err;
break;
case R_PPC64_REL16_HA:
value64 += addend64 - place;
- pr_debug("\t\t\tR_PPC64_REL16_HA at 0x%-4lx val 0x%lx\n",
- place, value64);
+ pr_debug("\t\t\tR_PPC64_REL16_HA at 0x%-4lx val 0x%lx\n", place, value64);
/* check that we are dealing with the addis 2,12 instruction */
- if (((*(uint32_t*)where) & 0xffff0000) != 0x3c4c0000) {
+ if (((*(uint32_t *)where) & 0xffff0000) != 0x3c4c0000) {
pr_err("Unexpected instruction for R_PPC64_REL16_HA\n");
goto err;
}
@@ -567,10 +542,9 @@ int __handle_elf(void *mem, size_t size)
case R_PPC64_REL16_LO:
value64 += addend64 - place;
- pr_debug("\t\t\tR_PPC64_REL16_LO at 0x%-4lx val 0x%lx\n",
- place, value64);
+ pr_debug("\t\t\tR_PPC64_REL16_LO at 0x%-4lx val 0x%lx\n", place, value64);
/* check that we are dealing with the addi 2,2 instruction */
- if (((*(uint32_t*)where) & 0xffff0000) != 0x38420000) {
+ if (((*(uint32_t *)where) & 0xffff0000) != 0x38420000) {
pr_err("Unexpected instruction for R_PPC64_REL16_LO\n");
goto err;
}
@@ -594,14 +568,16 @@ int __handle_elf(void *mem, size_t size)
(unsigned int)place, (long)addend64, (long)value64);
break;
case R_X86_64_PC32: /* Symbol + Addend - Place (4 bytes) */
- pr_debug("\t\t\t\tR_X86_64_PC32 at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
+ pr_debug("\t\t\t\tR_X86_64_PC32 at 0x%-4lx val 0x%x\n", place,
+ value32 + addend32 - (int32_t)place);
/*
* R_X86_64_PC32 are relative, patch them inplace.
*/
*((int32_t *)where) = value32 + addend32 - place;
break;
case R_X86_64_PLT32: /* ProcLinkage + Addend - Place (4 bytes) */
- pr_debug("\t\t\t\tR_X86_64_PLT32 at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
+ pr_debug("\t\t\t\tR_X86_64_PLT32 at 0x%-4lx val 0x%x\n", place,
+ value32 + addend32 - (int32_t)place);
/*
* R_X86_64_PLT32 are relative, patch them inplace.
*/
@@ -626,7 +602,8 @@ int __handle_elf(void *mem, size_t size)
(unsigned int)place, addend32, value32);
break;
case R_386_PC32: /* Symbol + Addend - Place */
- pr_debug("\t\t\t\tR_386_PC32 at 0x%-4lx val 0x%x\n", place, value32 + addend32 - (int32_t)place);
+ pr_debug("\t\t\t\tR_386_PC32 at 0x%-4lx val 0x%x\n", place,
+ value32 + addend32 - (int32_t)place);
/*
* R_386_PC32 are relative, patch them inplace.
*/
@@ -661,7 +638,7 @@ int __handle_elf(void *mem, size_t size)
#endif
default:
pr_err("Unsupported relocation of type %lu\n",
- (unsigned long)ELF_R_TYPE(r->rel.r_info));
+ (unsigned long)ELF_R_TYPE(r->rel.r_info));
goto err;
}
}
@@ -679,11 +656,11 @@ int __handle_elf(void *mem, size_t size)
if (!(sh->sh_flags & SHF_ALLOC) || !sh->sh_size)
continue;
- shdata = mem + sh->sh_offset;
+ shdata = mem + sh->sh_offset;
pr_debug("Copying section '%s'\n"
"\tstart:0x%lx (gap:0x%lx) size:0x%lx\n",
- &secstrings[sh->sh_name], (unsigned long) sh->sh_addr,
- (unsigned long)(sh->sh_addr - k), (unsigned long) sh->sh_size);
+ &secstrings[sh->sh_name], (unsigned long)sh->sh_addr, (unsigned long)(sh->sh_addr - k),
+ (unsigned long)sh->sh_size);
/* write 0 in the gap between the 2 sections */
for (; k < sh->sh_addr; k++) {
@@ -704,21 +681,20 @@ int __handle_elf(void *mem, size_t size)
pr_out("};\n");
pr_out("\n");
pr_out("static void __maybe_unused %s_setup_c_header_desc(struct parasite_blob_desc *pbd, bool native)\n",
- opts.prefix);
- pr_out(
-"{\n"
-" pbd->parasite_type = COMPEL_BLOB_CHEADER;\n"
-);
+ opts.prefix);
+ pr_out("{\n"
+ " pbd->parasite_type = COMPEL_BLOB_CHEADER;\n");
pr_out("\tpbd->hdr.mem = %s_blob;\n", opts.prefix);
- pr_out("\tpbd->hdr.bsize = sizeof(%s_blob);\n",
- opts.prefix);
+ pr_out("\tpbd->hdr.bsize = sizeof(%s_blob);\n", opts.prefix);
pr_out("\tif (native)\n");
pr_out("\t\tpbd->hdr.parasite_ip_off = "
- "%s_sym__export_parasite_head_start;\n", opts.prefix);
+ "%s_sym__export_parasite_head_start;\n",
+ opts.prefix);
pr_out("#ifdef CONFIG_COMPAT\n");
pr_out("\telse\n");
pr_out("\t\tpbd->hdr.parasite_ip_off = "
- "%s_sym__export_parasite_head_start_compat;\n", opts.prefix);
+ "%s_sym__export_parasite_head_start_compat;\n",
+ opts.prefix);
pr_out("#endif /* CONFIG_COMPAT */\n");
pr_out("\tpbd->hdr.cmd_off = %s_sym__export_parasite_service_cmd;\n", opts.prefix);
pr_out("\tpbd->hdr.args_ptr_off = %s_sym__export_parasite_service_args_ptr;\n", opts.prefix);
@@ -727,12 +703,11 @@ int __handle_elf(void *mem, size_t size)
pr_out("\tpbd->hdr.data_off = %#lx;\n", data_off);
pr_out("\tpbd->hdr.relocs = %s_relocs;\n", opts.prefix);
pr_out("\tpbd->hdr.nr_relocs = "
- "sizeof(%s_relocs) / sizeof(%s_relocs[0]);\n",
- opts.prefix, opts.prefix);
+ "sizeof(%s_relocs) / sizeof(%s_relocs[0]);\n",
+ opts.prefix, opts.prefix);
pr_out("}\n");
pr_out("\n");
- pr_out("static void __maybe_unused %s_setup_c_header(struct parasite_ctl *ctl)\n",
- opts.prefix);
+ pr_out("static void __maybe_unused %s_setup_c_header(struct parasite_ctl *ctl)\n", opts.prefix);
pr_out("{\n");
pr_out("\t%s_setup_c_header_desc(compel_parasite_blob_desc(ctl), compel_mode_native(ctl));\n", opts.prefix);
pr_out("}\n");
diff --git a/compel/src/lib/infect-rpc.c b/compel/src/lib/infect-rpc.c
index 265a4ad2f..6b19fa6bd 100644
--- a/compel/src/lib/infect-rpc.c
+++ b/compel/src/lib/infect-rpc.c
@@ -19,8 +19,7 @@ static int __parasite_send_cmd(int sockfd, struct ctl_msg *m)
pr_perror("Failed to send command %d to daemon", m->cmd);
return -1;
} else if (ret != sizeof(*m)) {
- pr_err("Message to daemon is trimmed (%d/%d)\n",
- (int)sizeof(*m), ret);
+ pr_err("Message to daemon is trimmed (%d/%d)\n", (int)sizeof(*m), ret);
return -1;
}
@@ -42,12 +41,10 @@ int parasite_wait_ack(int sockfd, unsigned int cmd, struct ctl_msg *m)
pr_perror("Failed to read ack");
return -1;
} else if (ret != sizeof(*m)) {
- pr_err("Message reply from daemon is trimmed (%d/%d)\n",
- (int)sizeof(*m), ret);
+ pr_err("Message reply from daemon is trimmed (%d/%d)\n", (int)sizeof(*m), ret);
return -1;
}
- pr_debug("Fetched ack: %d %d %d\n",
- m->cmd, m->ack, m->err);
+ pr_debug("Fetched ack: %d %d %d\n", m->cmd, m->ack, m->err);
if (m->cmd != cmd || m->ack != cmd) {
pr_err("Communication error, this is not "
@@ -68,8 +65,7 @@ int compel_rpc_sync(unsigned int cmd, struct parasite_ctl *ctl)
return -1;
if (m.err != 0) {
- pr_err("Command %d for daemon failed with %d\n",
- cmd, m.err);
+ pr_err("Command %d for daemon failed with %d\n", cmd, m.err);
return -1;
}
diff --git a/compel/src/lib/infect.c b/compel/src/lib/infect.c
index a15b99ad6..0fb9e715c 100644
--- a/compel/src/lib/infect.c
+++ b/compel/src/lib/infect.c
@@ -27,18 +27,17 @@
#include "rpc-pie-priv.h"
#include "infect-util.h"
-#define __sys(foo) foo
-#define __sys_err(ret) (-errno)
+#define __sys(foo) foo
+#define __sys_err(ret) (-errno)
#include "common/scm.h"
#include "common/scm-code.c"
#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - \
- (size_t)((struct sockaddr_un *) 0)->sun_path)
+#define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - (size_t)((struct sockaddr_un *)0)->sun_path)
#endif
-#define PARASITE_STACK_SIZE (16 << 10)
+#define PARASITE_STACK_SIZE (16 << 10)
#ifndef SECCOMP_MODE_DISABLED
#define SECCOMP_MODE_DISABLED 0
@@ -193,10 +192,9 @@ static int skip_sigstop(int pid, int nr_signals)
* of it so the task would not know if it was saddled
* up with someone else.
*/
-int compel_wait_task(int pid, int ppid,
- int (*get_status)(int pid, struct seize_task_status *, void *),
- void (*free_status)(int pid, struct seize_task_status *, void *),
- struct seize_task_status *ss, void *data)
+int compel_wait_task(int pid, int ppid, int (*get_status)(int pid, struct seize_task_status *, void *),
+ void (*free_status)(int pid, struct seize_task_status *, void *), struct seize_task_status *ss,
+ void *data)
{
siginfo_t si;
int status, nr_sigstop;
@@ -232,8 +230,8 @@ try_again:
if (pid == getpid())
pr_err("The criu itself is within dumped tree.\n");
else
- pr_err("Unseizable non-zombie %d found, state %c, err %d/%d\n",
- pid, ss->state, ret, wait_errno);
+ pr_err("Unseizable non-zombie %d found, state %c, err %d/%d\n", pid, ss->state, ret,
+ wait_errno);
return -1;
}
@@ -244,8 +242,7 @@ try_again:
}
if ((ppid != -1) && (ss->ppid != ppid)) {
- pr_err("Task pid reused while suspending (%d: %d -> %d)\n",
- pid, ppid, ss->ppid);
+ pr_err("Task pid reused while suspending (%d: %d -> %d)\n", pid, ppid, ss->ppid);
goto err;
}
@@ -267,8 +264,7 @@ try_again:
* handle one and repeat.
*/
- if (ptrace(PTRACE_CONT, pid, NULL,
- (void *)(unsigned long)si.si_signo)) {
+ if (ptrace(PTRACE_CONT, pid, NULL, (void *)(unsigned long)si.si_signo)) {
pr_perror("Can't continue signal handling, aborting");
goto err;
}
@@ -368,8 +364,7 @@ static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
int sun_len;
saddr->sun_family = AF_UNIX;
- snprintf(saddr->sun_path, UNIX_PATH_MAX,
- "X/crtools-pr-%d", key);
+ snprintf(saddr->sun_path, UNIX_PATH_MAX, "X/crtools-pr-%d", key);
sun_len = SUN_LEN(saddr);
*saddr->sun_path = '\0';
@@ -377,8 +372,7 @@ static int gen_parasite_saddr(struct sockaddr_un *saddr, int key)
return sun_len;
}
-static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
- struct parasite_init_args *args)
+static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid, struct parasite_init_args *args)
{
int ssock = -1;
socklen_t sk_len;
@@ -395,7 +389,7 @@ static int prepare_tsock(struct parasite_ctl *ctl, pid_t pid,
goto err;
}
- if (getsockname(ssock, (struct sockaddr *) &addr, &sk_len) < 0) {
+ if (getsockname(ssock, (struct sockaddr *)&addr, &sk_len) < 0) {
pr_perror("Unable to get name for a socket");
return -1;
}
@@ -430,8 +424,8 @@ err:
static int setup_child_handler(struct parasite_ctl *ctl)
{
struct sigaction sa = {
- .sa_sigaction = ctl->ictx.child_handler,
- .sa_flags = SA_SIGINFO | SA_RESTART,
+ .sa_sigaction = ctl->ictx.child_handler,
+ .sa_flags = SA_SIGINFO | SA_RESTART,
};
sigemptyset(&sa.sa_mask);
@@ -454,8 +448,8 @@ static int restore_child_handler(struct parasite_ctl *ctl)
return 0;
}
-static int parasite_run(pid_t pid, int cmd, unsigned long ip, void *stack,
- user_regs_struct_t *regs, struct thread_ctx *octx)
+static int parasite_run(pid_t pid, int cmd, unsigned long ip, void *stack, user_regs_struct_t *regs,
+ struct thread_ctx *octx)
{
k_rtsigset_t block;
@@ -493,8 +487,7 @@ err_sig:
return -1;
}
-static int restore_thread_ctx(int pid, struct thread_ctx *ctx,
- bool restore_ext_regs)
+static int restore_thread_ctx(int pid, struct thread_ctx *ctx, bool restore_ext_regs)
{
int ret = 0;
@@ -515,10 +508,8 @@ static int restore_thread_ctx(int pid, struct thread_ctx *ctx,
}
/* we run at @regs->ip */
-static int parasite_trap(struct parasite_ctl *ctl, pid_t pid,
- user_regs_struct_t *regs,
- struct thread_ctx *octx,
- bool may_use_extended_regs)
+static int parasite_trap(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs, struct thread_ctx *octx,
+ bool may_use_extended_regs)
{
siginfo_t siginfo;
int status;
@@ -546,12 +537,11 @@ static int parasite_trap(struct parasite_ctl *ctl, pid_t pid,
if (ptrace_get_regs(pid, regs)) {
pr_perror("Can't obtain registers (pid: %d)", pid);
- goto err;
+ goto err;
}
if (WSTOPSIG(status) != SIGTRAP || siginfo.si_code != ARCH_SI_TRAP) {
- pr_debug("** delivering signal %d si_code=%d\n",
- siginfo.si_signo, siginfo.si_code);
+ pr_debug("** delivering signal %d si_code=%d\n", siginfo.si_signo, siginfo.si_code);
pr_err("Unexpected %d task interruption, aborting\n", pid);
goto err;
@@ -569,9 +559,7 @@ err:
return ret;
}
-
-int compel_execute_syscall(struct parasite_ctl *ctl,
- user_regs_struct_t *regs, const char *code_syscall)
+int compel_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *regs, const char *code_syscall)
{
pid_t pid = ctl->rpid;
int err;
@@ -582,8 +570,7 @@ int compel_execute_syscall(struct parasite_ctl *ctl,
* we will need it to restore original program content.
*/
memcpy(code_orig, code_syscall, sizeof(code_orig));
- if (ptrace_swap_area(pid, (void *)ctl->ictx.syscall_ip,
- (void *)code_orig, sizeof(code_orig))) {
+ if (ptrace_swap_area(pid, (void *)ctl->ictx.syscall_ip, (void *)code_orig, sizeof(code_orig))) {
pr_err("Can't inject syscall blob (pid: %d)\n", pid);
return -1;
}
@@ -592,8 +579,7 @@ int compel_execute_syscall(struct parasite_ctl *ctl,
if (!err)
err = parasite_trap(ctl, pid, regs, &ctl->orig, false);
- if (ptrace_poke_area(pid, (void *)code_orig,
- (void *)ctl->ictx.syscall_ip, sizeof(code_orig))) {
+ if (ptrace_poke_area(pid, (void *)code_orig, (void *)ctl->ictx.syscall_ip, sizeof(code_orig))) {
pr_err("Can't restore syscall blob (pid: %d)\n", ctl->rpid);
err = -1;
}
@@ -633,7 +619,7 @@ static int parasite_init_daemon(struct parasite_ctl *ctl)
struct parasite_init_args *args;
pid_t pid = ctl->rpid;
user_regs_struct_t regs;
- struct ctl_msg m = { };
+ struct ctl_msg m = {};
*ctl->cmd = PARASITE_CMD_INIT_DAEMON;
@@ -674,12 +660,11 @@ static int parasite_init_daemon(struct parasite_ctl *ctl)
pr_info("Wait for parasite being daemonized...\n");
if (parasite_wait_ack(ctl->tsock, PARASITE_CMD_INIT_DAEMON, &m)) {
- pr_err("Can't switch parasite %d to daemon mode %d\n",
- pid, m.err);
+ pr_err("Can't switch parasite %d to daemon mode %d\n", pid, m.err);
goto err;
}
- ctl->sigreturn_addr = (void*)(uintptr_t)args->sigreturn_addr;
+ ctl->sigreturn_addr = (void *)(uintptr_t)args->sigreturn_addr;
ctl->daemonized = true;
pr_info("Parasite %d has been switched to daemon mode\n", pid);
return 0;
@@ -698,8 +683,7 @@ static int parasite_start_daemon(struct parasite_ctl *ctl)
* while in daemon it is not such.
*/
- if (compel_get_task_regs(pid, &ctl->orig.regs, NULL, ictx->save_regs,
- ictx->regs_arg, ictx->flags)) {
+ if (compel_get_task_regs(pid, &ctl->orig.regs, NULL, ictx->save_regs, ictx->regs_arg, ictx->flags)) {
pr_err("Can't obtain regs for thread %d\n", pid);
return -1;
}
@@ -722,8 +706,7 @@ static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size,
{
int fd;
- ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot,
- MAP_ANONYMOUS | MAP_SHARED, -1, 0);
+ ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
if (!ctl->remote_map) {
pr_err("Can't allocate memory for parasite blob (pid: %d)\n", ctl->rpid);
return -1;
@@ -731,13 +714,12 @@ static int parasite_mmap_exchange(struct parasite_ctl *ctl, unsigned long size,
ctl->map_length = round_up(size, page_size());
- fd = ctl->ictx.open_proc(ctl->rpid, O_RDWR, "map_files/%lx-%lx",
- (long)ctl->remote_map, (long)ctl->remote_map + ctl->map_length);
+ fd = ctl->ictx.open_proc(ctl->rpid, O_RDWR, "map_files/%lx-%lx", (long)ctl->remote_map,
+ (long)ctl->remote_map + ctl->map_length);
if (fd < 0)
return -1;
- ctl->local_map = mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_FILE, fd, 0);
+ ctl->local_map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE, fd, 0);
close(fd);
if (ctl->local_map == MAP_FAILED) {
@@ -779,8 +761,7 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size,
return -1;
}
- ret = compel_syscall(ctl, __NR(memfd_create, compat_task), &sret,
- (unsigned long)where, 0, 0, 0, 0, 0);
+ ret = compel_syscall(ctl, __NR(memfd_create, compat_task), &sret, (unsigned long)where, 0, 0, 0, 0, 0);
if (ptrace_poke_area(pid, orig_code, where, sizeof(orig_code))) {
fd = (int)sret;
@@ -812,15 +793,13 @@ static int parasite_memfd_exchange(struct parasite_ctl *ctl, unsigned long size,
goto err_cure;
}
- ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot,
- MAP_FILE | MAP_SHARED, fd, 0);
+ ctl->remote_map = remote_mmap(ctl, NULL, size, remote_prot, MAP_FILE | MAP_SHARED, fd, 0);
if (!ctl->remote_map) {
pr_err("Can't rmap memfd for parasite blob\n");
goto err_curef;
}
- ctl->local_map = mmap(NULL, size, PROT_READ | PROT_WRITE,
- MAP_SHARED | MAP_FILE, lfd, 0);
+ ctl->local_map = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FILE, lfd, 0);
if (ctl->local_map == MAP_FAILED) {
ctl->local_map = NULL;
pr_perror("Can't lmap memfd for parasite blob");
@@ -867,7 +846,8 @@ void compel_relocs_apply(void *mem, void *vbase, struct parasite_blob_desc *pbd)
int rel;
got[j] = vbase + elf_relocs[i].value;
- rel = (unsigned)((void *)&got[j] - (void *)mem) - elf_relocs[i].offset + elf_relocs[i].addend;
+ rel = (unsigned)((void *)&got[j] - (void *)mem) - elf_relocs[i].offset +
+ elf_relocs[i].addend;
*value = rel;
j++;
@@ -888,8 +868,7 @@ long remote_mprotect(struct parasite_ctl *ctl, void *addr, size_t len, int prot)
int err;
bool compat_task = !user_regs_native(&ctl->orig.regs);
- err = compel_syscall(ctl, __NR(mprotect, compat_task), &ret,
- (unsigned long)addr, len, prot, 0, 0, 0);
+ err = compel_syscall(ctl, __NR(mprotect, compat_task), &ret, (unsigned long)addr, len, prot, 0, 0, 0);
if (err < 0) {
pr_err("compel_syscall for mprotect failed\n");
return -1;
@@ -917,8 +896,7 @@ static int compel_map_exchange(struct parasite_ctl *ctl, unsigned long size)
if (!ctl->pblob.hdr.data_off)
return 0;
- ret = remote_mprotect(ctl, ctl->remote_map + ctl->pblob.hdr.data_off,
- size - ctl->pblob.hdr.data_off,
+ ret = remote_mprotect(ctl, ctl->remote_map + ctl->pblob.hdr.data_off, size - ctl->pblob.hdr.data_off,
PROT_READ | PROT_WRITE);
if (ret)
pr_err("remote_mprotect failed\n");
@@ -1000,7 +978,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
* already the case, as args follows the GOT table, which is 8 bytes
* aligned.
*/
- if ((unsigned long)ctl->args & (4-1)) {
+ if ((unsigned long)ctl->args & (4 - 1)) {
pr_err("BUG: args are not 4 bytes aligned: %p\n", ctl->args);
goto err;
}
@@ -1010,8 +988,8 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
p = parasite_size;
- ctl->rsigframe = ctl->remote_map + p;
- ctl->sigframe = ctl->local_map + p;
+ ctl->rsigframe = ctl->remote_map + p;
+ ctl->sigframe = ctl->local_map + p;
p += RESTORE_STACK_SIGFRAME;
p += PARASITE_STACK_SIZE;
@@ -1022,12 +1000,11 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
* It is already the case as RESTORE_STACK_SIGFRAME is a multiple of
* 64, and PARASITE_STACK_SIZE is 0x4000.
*/
- if ((unsigned long)ctl->rstack & (16-1)) {
+ if ((unsigned long)ctl->rstack & (16 - 1)) {
pr_err("BUG: stack is not 16 bytes aligned: %p\n", ctl->rstack);
goto err;
}
-
if (nr_threads > 1) {
p += PARASITE_STACK_SIZE;
ctl->r_thread_stack = ctl->remote_map + p;
@@ -1035,8 +1012,7 @@ int compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned l
ret = arch_fetch_sas(ctl, ctl->rsigframe);
if (ret) {
- pr_err("Can't fetch sigaltstack for task %d (ret %d)\n",
- ctl->rpid, ret);
+ pr_err("Can't fetch sigaltstack for task %d (ret %d)\n", ctl->rpid, ret);
goto err;
}
@@ -1227,14 +1203,12 @@ static void handle_sigchld(int signal, siginfo_t *siginfo, void *data)
if (pid <= 0)
return;
- pr_err("si_code=%d si_pid=%d si_status=%d\n",
- siginfo->si_code, siginfo->si_pid, siginfo->si_status);
+ pr_err("si_code=%d si_pid=%d si_status=%d\n", siginfo->si_code, siginfo->si_pid, siginfo->si_status);
if (WIFEXITED(status))
pr_err("%d exited with %d unexpectedly\n", pid, WEXITSTATUS(status));
else if (WIFSIGNALED(status))
- pr_err("%d was killed by %d unexpectedly: %s\n",
- pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
+ pr_err("%d was killed by %d unexpectedly: %s\n", pid, WTERMSIG(status), strsignal(WTERMSIG(status)));
else if (WIFSTOPPED(status))
pr_err("%d was stopped by %d unexpectedly\n", pid, WSTOPSIG(status));
@@ -1325,9 +1299,8 @@ err:
static bool task_in_parasite(struct parasite_ctl *ctl, user_regs_struct_t *regs)
{
- void *addr = (void *) REG_IP(*regs);
- return addr >= ctl->remote_map &&
- addr < ctl->remote_map + ctl->map_length;
+ void *addr = (void *)REG_IP(*regs);
+ return addr >= ctl->remote_map && addr < ctl->remote_map + ctl->map_length;
}
static int parasite_fini_seized(struct parasite_ctl *ctl)
@@ -1376,13 +1349,11 @@ static int parasite_fini_seized(struct parasite_ctl *ctl)
return -1;
/* Go to sigreturn as closer as we can */
- ret = compel_stop_pie(pid, ctl->sigreturn_addr, &flag,
- ctl->ictx.flags & INFECT_NO_BREAKPOINTS);
+ ret = compel_stop_pie(pid, ctl->sigreturn_addr, &flag, ctl->ictx.flags & INFECT_NO_BREAKPOINTS);
if (ret < 0)
return ret;
- if (compel_stop_on_syscall(1, __NR(rt_sigreturn, 0),
- __NR(rt_sigreturn, 1), flag))
+ if (compel_stop_on_syscall(1, __NR(rt_sigreturn, 0), __NR(rt_sigreturn, 1), flag))
return -1;
if (ptrace_flush_breakpoints(pid))
@@ -1429,15 +1400,13 @@ int compel_cure_remote(struct parasite_ctl *ctl)
if (!ctl->remote_map)
return 0;
- err = compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret,
- (unsigned long)ctl->remote_map, ctl->map_length,
- 0, 0, 0, 0);
+ err = compel_syscall(ctl, __NR(munmap, !compel_mode_native(ctl)), &ret, (unsigned long)ctl->remote_map,
+ ctl->map_length, 0, 0, 0, 0);
if (err)
return err;
if (ret) {
- pr_err("munmap for remote map %p, %lu returned %lu\n",
- ctl->remote_map, ctl->map_length, ret);
+ pr_err("munmap for remote map %p, %lu returned %lu\n", ctl->remote_map, ctl->map_length, ret);
return -1;
}
@@ -1519,8 +1488,7 @@ int compel_unmap(struct parasite_ctl *ctl, unsigned long addr)
if (ret)
goto err;
- ret = compel_stop_on_syscall(1, __NR(munmap, 0),
- __NR(munmap, 1), TRACE_ENTER);
+ ret = compel_stop_on_syscall(1, __NR(munmap, 0), __NR(munmap, 1), TRACE_ENTER);
/*
* Don't touch extended registers here: they were restored
@@ -1576,25 +1544,22 @@ static bool task_is_trapped(int status, pid_t pid)
if (WIFEXITED(status))
pr_err("Task exited with %d\n", WEXITSTATUS(status));
if (WIFSIGNALED(status))
- pr_err("Task signaled with %d: %s\n",
- WTERMSIG(status), strsignal(WTERMSIG(status)));
+ pr_err("Task signaled with %d: %s\n", WTERMSIG(status), strsignal(WTERMSIG(status)));
if (WIFSTOPPED(status))
- pr_err("Task stopped with %d: %s\n",
- WSTOPSIG(status), strsignal(WSTOPSIG(status)));
+ pr_err("Task stopped with %d: %s\n", WSTOPSIG(status), strsignal(WSTOPSIG(status)));
if (WIFCONTINUED(status))
pr_err("Task continued\n");
return false;
}
-static inline int is_required_syscall(user_regs_struct_t *regs, pid_t pid,
- const int sys_nr, const int sys_nr_compat)
+static inline int is_required_syscall(user_regs_struct_t *regs, pid_t pid, const int sys_nr, const int sys_nr_compat)
{
const char *mode = user_regs_native(regs) ? "native" : "compat";
int req_sysnr = user_regs_native(regs) ? sys_nr : sys_nr_compat;
- pr_debug("%d (%s) is going to execute the syscall %lu, required is %d\n",
- pid, mode, REG_SYSCALL_NR(*regs), req_sysnr);
+ pr_debug("%d (%s) is going to execute the syscall %lu, required is %d\n", pid, mode, REG_SYSCALL_NR(*regs),
+ req_sysnr);
return (REG_SYSCALL_NR(*regs) == req_sysnr);
}
@@ -1606,9 +1571,7 @@ static inline int is_required_syscall(user_regs_struct_t *regs, pid_t pid,
* sys_nr - the required syscall number
* sys_nr_compat - the required compatible syscall number
*/
-int compel_stop_on_syscall(int tasks,
- const int sys_nr, const int sys_nr_compat,
- enum trace_flags trace)
+int compel_stop_on_syscall(int tasks, const int sys_nr, const int sys_nr_compat, enum trace_flags trace)
{
user_regs_struct_t regs;
int status, ret;
@@ -1668,7 +1631,7 @@ int compel_stop_on_syscall(int tasks,
tasks--;
continue;
}
-goon:
+ goon:
ret = ptrace(PTRACE_SYSCALL, pid, NULL, NULL);
if (ret) {
pr_perror("ptrace");
@@ -1699,10 +1662,9 @@ k_rtsigset_t *compel_task_sigmask(struct parasite_ctl *ctl)
return thread_ctx_sigmask(&ctl->orig);
}
-int compel_get_thread_regs(struct parasite_thread_ctl *tctl, save_regs_t save, void * arg)
+int compel_get_thread_regs(struct parasite_thread_ctl *tctl, save_regs_t save, void *arg)
{
- return compel_get_task_regs(tctl->tid, &tctl->th.regs, &tctl->th.ext_regs,
- save, arg, tctl->ctl->ictx.flags);
+ return compel_get_task_regs(tctl->tid, &tctl->th.regs, &tctl->th.ext_regs, save, arg, tctl->ctl->ictx.flags);
}
struct infect_ctx *compel_infect_ctx(struct parasite_ctl *ctl)
diff --git a/compel/src/lib/ptrace.c b/compel/src/lib/ptrace.c
index 4c3530c85..49b685d70 100644
--- a/compel/src/lib/ptrace.c
+++ b/compel/src/lib/ptrace.c
@@ -93,8 +93,7 @@ int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes)
if (err) {
int err2;
- pr_err("Can't poke %d @ %p from %p sized %ld\n",
- pid, dst, src, bytes);
+ pr_err("Can't poke %d @ %p from %p sized %ld\n", pid, dst, src, bytes);
err2 = ptrace_poke_area(pid, t, dst, bytes);
if (err2) {
@@ -109,7 +108,8 @@ int ptrace_swap_area(pid_t pid, void *dst, void *src, long bytes)
return 0;
}
-int __attribute__((weak)) ptrace_get_regs(int pid, user_regs_struct_t *regs) {
+int __attribute__((weak)) ptrace_get_regs(int pid, user_regs_struct_t *regs)
+{
struct iovec iov;
iov.iov_base = regs;
diff --git a/compel/src/main.c b/compel/src/main.c
index 2c98659cc..a9a50959f 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -17,44 +17,44 @@
#include "piegen.h"
#include "log.h"
-#define CFLAGS_DEFAULT_SET \
- "-Wstrict-prototypes " \
+#define CFLAGS_DEFAULT_SET \
+ "-Wstrict-prototypes " \
"-fno-stack-protector -nostdlib -fomit-frame-pointer "
-#define COMPEL_CFLAGS_PIE CFLAGS_DEFAULT_SET "-fpie"
-#define COMPEL_CFLAGS_NOPIC CFLAGS_DEFAULT_SET "-fno-pic"
+#define COMPEL_CFLAGS_PIE CFLAGS_DEFAULT_SET "-fpie"
+#define COMPEL_CFLAGS_NOPIC CFLAGS_DEFAULT_SET "-fno-pic"
#ifdef NO_RELOCS
-#define COMPEL_LDFLAGS_COMMON "-z noexecstack -T "
+#define COMPEL_LDFLAGS_COMMON "-z noexecstack -T "
#else
-#define COMPEL_LDFLAGS_COMMON "-r -z noexecstack -T "
+#define COMPEL_LDFLAGS_COMMON "-r -z noexecstack -T "
#endif
typedef struct {
- const char *arch; // dir name under arch/
- const char *cflags;
- const char *cflags_compat;
+ const char *arch; // dir name under arch/
+ const char *cflags;
+ const char *cflags_compat;
} flags_t;
static const flags_t flags = {
#if defined CONFIG_X86_64
- .arch = "x86",
- .cflags = COMPEL_CFLAGS_PIE,
- .cflags_compat = COMPEL_CFLAGS_NOPIC,
+ .arch = "x86",
+ .cflags = COMPEL_CFLAGS_PIE,
+ .cflags_compat = COMPEL_CFLAGS_NOPIC,
#elif defined CONFIG_AARCH64
- .arch = "aarch64",
- .cflags = COMPEL_CFLAGS_PIE,
+ .arch = "aarch64",
+ .cflags = COMPEL_CFLAGS_PIE,
#elif defined(CONFIG_ARMV6) || defined(CONFIG_ARMV7)
- .arch = "arm",
- .cflags = COMPEL_CFLAGS_PIE,
+ .arch = "arm",
+ .cflags = COMPEL_CFLAGS_PIE,
#elif defined CONFIG_PPC64
- .arch = "ppc64",
- .cflags = COMPEL_CFLAGS_PIE,
+ .arch = "ppc64",
+ .cflags = COMPEL_CFLAGS_PIE,
#elif defined CONFIG_S390
- .arch = "s390",
- .cflags = COMPEL_CFLAGS_PIE,
+ .arch = "s390",
+ .cflags = COMPEL_CFLAGS_PIE,
#elif defined CONFIG_MIPS
- .arch = "mips",
+ .arch = "mips",
#else
#error "CONFIG_<ARCH> not defined, or unsupported ARCH"
#endif
@@ -123,23 +123,23 @@ static void cli_log(unsigned int lvl, const char *fmt, va_list parms)
vfprintf(f, fmt, parms);
}
-static int usage(int rc) {
+static int usage(int rc)
+{
FILE *out = (rc == 0) ? stdout : stderr;
fprintf(out,
-"Usage:\n"
-" compel [--compat] includes | cflags | ldflags\n"
-" compel plugins [PLUGIN_NAME ...]\n"
-" compel [--compat] [--static] libs\n"
-" compel -f FILE -o FILE [-p NAME] [-l N] hgen\n"
-" -f, --file FILE input (parasite object) file name\n"
-" -o, --output FILE output (header) file name\n"
-" -p, --prefix NAME prefix for var names\n"
-" -l, --log-level NUM log level (default: %d)\n"
-" compel -h|--help\n"
-" compel -V|--version\n"
-, COMPEL_DEFAULT_LOGLEVEL
-);
+ "Usage:\n"
+ " compel [--compat] includes | cflags | ldflags\n"
+ " compel plugins [PLUGIN_NAME ...]\n"
+ " compel [--compat] [--static] libs\n"
+ " compel -f FILE -o FILE [-p NAME] [-l N] hgen\n"
+ " -f, --file FILE input (parasite object) file name\n"
+ " -o, --output FILE output (header) file name\n"
+ " -p, --prefix NAME prefix for var names\n"
+ " -l, --log-level NUM log level (default: %d)\n"
+ " compel -h|--help\n"
+ " compel -V|--version\n",
+ COMPEL_DEFAULT_LOGLEVEL);
return rc;
}
@@ -182,12 +182,9 @@ static void print_ldflags(bool compat)
printf("%s", COMPEL_LDFLAGS_COMMON);
if (uninst_root) {
- printf("%s/arch/%s/scripts/compel-pack%s.lds.S\n",
- uninst_root, flags.arch, compat_str);
+ printf("%s/arch/%s/scripts/compel-pack%s.lds.S\n", uninst_root, flags.arch, compat_str);
} else {
- printf("%s/compel/scripts/compel-pack%s.lds.S\n",
- LIBEXECDIR, compat_str);
-
+ printf("%s/compel/scripts/compel-pack%s.lds.S\n", LIBEXECDIR, compat_str);
}
}
@@ -196,8 +193,7 @@ static void print_plugin(const char *name)
const char suffix[] = ".lib.a";
if (uninst_root)
- printf("%s/plugins/%s%s\n",
- uninst_root, name, suffix);
+ printf("%s/plugins/%s%s\n", uninst_root, name, suffix);
else
printf("%s/compel/%s%s\n", LIBEXECDIR, name, suffix);
}
@@ -307,15 +303,15 @@ int main(int argc, char *argv[])
static const char short_opts[] = "csf:o:p:hVl:";
static struct option long_opts[] = {
- { "compat", no_argument, 0, 'c' },
- { "static", no_argument, 0, 's' },
- { "file", required_argument, 0, 'f' },
- { "output", required_argument, 0, 'o' },
- { "prefix", required_argument, 0, 'p' },
- { "help", no_argument, 0, 'h' },
- { "version", no_argument, 0, 'V' },
- { "log-level", required_argument, 0, 'l' },
- { },
+ { "compat", no_argument, 0, 'c' },
+ { "static", no_argument, 0, 's' },
+ { "file", required_argument, 0, 'f' },
+ { "output", required_argument, 0, 'o' },
+ { "prefix", required_argument, 0, 'p' },
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { "log-level", required_argument, 0, 'l' },
+ {},
};
uninst_root = getenv("COMPEL_UNINSTALLED_ROOTDIR");
@@ -347,9 +343,7 @@ int main(int argc, char *argv[])
case 'h':
return usage(0);
case 'V':
- printf("Version: %d.%d.%d\n",
- COMPEL_SO_VERSION_MAJOR,
- COMPEL_SO_VERSION_MINOR,
+ printf("Version: %d.%d.%d\n", COMPEL_SO_VERSION_MAJOR, COMPEL_SO_VERSION_MINOR,
COMPEL_SO_VERSION_SUBLEVEL);
exit(0);
break;
diff --git a/compel/test/fdspy/parasite.c b/compel/test/fdspy/parasite.c
index 7933d29ae..2399cc3ba 100644
--- a/compel/test/fdspy/parasite.c
+++ b/compel/test/fdspy/parasite.c
@@ -6,11 +6,19 @@
/*
* Stubs for std compel plugin.
*/
-int compel_main(void *arg_p, unsigned int arg_s) { return 0; }
-int parasite_trap_cmd(int cmd, void *args) { return 0; }
-void parasite_cleanup(void) { }
+int compel_main(void *arg_p, unsigned int arg_s)
+{
+ return 0;
+}
+int parasite_trap_cmd(int cmd, void *args)
+{
+ return 0;
+}
+void parasite_cleanup(void)
+{
+}
-#define PARASITE_CMD_GETFD PARASITE_USER_CMDS
+#define PARASITE_CMD_GETFD PARASITE_USER_CMDS
int parasite_daemon_cmd(int cmd, void *args)
{
diff --git a/compel/test/fdspy/spy.c b/compel/test/fdspy/spy.c
index bbb9eb418..7f20ea2a7 100644
--- a/compel/test/fdspy/spy.c
+++ b/compel/test/fdspy/spy.c
@@ -11,7 +11,7 @@
#include "parasite.h"
-#define PARASITE_CMD_GETFD PARASITE_USER_CMDS
+#define PARASITE_CMD_GETFD PARASITE_USER_CMDS
static void print_vmsg(unsigned int lvl, const char *fmt, va_list parms)
{
@@ -21,7 +21,11 @@ static void print_vmsg(unsigned int lvl, const char *fmt, va_list parms)
static int do_infection(int pid, int *stolen_fd)
{
-#define err_and_ret(msg) do { fprintf(stderr, msg); return -1; } while (0)
+#define err_and_ret(msg) \
+ do { \
+ fprintf(stderr, msg); \
+ return -1; \
+ } while (0)
int state;
struct parasite_ctl *ctl;
@@ -135,14 +139,22 @@ int main(int argc, char **argv)
printf("Run the victim\n");
pid = vfork();
if (pid == 0) {
- close(p_in[1]); dup2(p_in[0], 0); close(p_in[0]);
- close(p_out[0]); dup2(p_out[1], 1); close(p_out[1]);
- close(p_err[0]); dup2(p_err[1], 2); close(p_err[1]);
+ close(p_in[1]);
+ dup2(p_in[0], 0);
+ close(p_in[0]);
+ close(p_out[0]);
+ dup2(p_out[1], 1);
+ close(p_out[1]);
+ close(p_err[0]);
+ dup2(p_err[1], 2);
+ close(p_err[1]);
execl("./victim", "victim", NULL);
exit(1);
}
- close(p_in[0]); close(p_out[1]); close(p_err[1]);
+ close(p_in[0]);
+ close(p_out[1]);
+ close(p_err[1]);
/*
* Now do the infection with parasite.c
diff --git a/compel/test/infect/parasite.c b/compel/test/infect/parasite.c
index f18580966..ad13bd25d 100644
--- a/compel/test/infect/parasite.c
+++ b/compel/test/infect/parasite.c
@@ -6,11 +6,16 @@
/*
* Stubs for std compel plugin.
*/
-int parasite_trap_cmd(int cmd, void *args) { return 0; }
-void parasite_cleanup(void) { }
+int parasite_trap_cmd(int cmd, void *args)
+{
+ return 0;
+}
+void parasite_cleanup(void)
+{
+}
-#define PARASITE_CMD_INC PARASITE_USER_CMDS
-#define PARASITE_CMD_DEC PARASITE_USER_CMDS + 1
+#define PARASITE_CMD_INC PARASITE_USER_CMDS
+#define PARASITE_CMD_DEC PARASITE_USER_CMDS + 1
int parasite_daemon_cmd(int cmd, void *args)
{
diff --git a/compel/test/infect/spy.c b/compel/test/infect/spy.c
index 8be6925c5..e7273b446 100644
--- a/compel/test/infect/spy.c
+++ b/compel/test/infect/spy.c
@@ -8,8 +8,8 @@
#include "parasite.h"
-#define PARASITE_CMD_INC PARASITE_USER_CMDS
-#define PARASITE_CMD_DEC PARASITE_USER_CMDS + 1
+#define PARASITE_CMD_INC PARASITE_USER_CMDS
+#define PARASITE_CMD_DEC PARASITE_USER_CMDS + 1
static void print_vmsg(unsigned int lvl, const char *fmt, va_list parms)
{
@@ -19,7 +19,11 @@ static void print_vmsg(unsigned int lvl, const char *fmt, va_list parms)
static int do_infection(int pid)
{
-#define err_and_ret(msg) do { fprintf(stderr, msg); return -1; } while (0)
+#define err_and_ret(msg) \
+ do { \
+ fprintf(stderr, msg); \
+ return -1; \
+ } while (0)
int state;
struct parasite_ctl *ctl;
@@ -110,14 +114,22 @@ int main(int argc, char **argv)
pid = vfork();
if (pid == 0) {
- close(p_in[1]); dup2(p_in[0], 0); close(p_in[0]);
- close(p_out[0]); dup2(p_out[1], 1); close(p_out[1]);
- close(p_err[0]); dup2(p_err[1], 2); close(p_err[1]);
+ close(p_in[1]);
+ dup2(p_in[0], 0);
+ close(p_in[0]);
+ close(p_out[0]);
+ dup2(p_out[1], 1);
+ close(p_out[1]);
+ close(p_err[0]);
+ dup2(p_err[1], 2);
+ close(p_err[1]);
execl("./victim", "victim", NULL);
exit(1);
}
- close(p_in[0]); close(p_out[1]); close(p_err[1]);
+ close(p_in[0]);
+ close(p_out[1]);
+ close(p_err[1]);
/*
* Tell the little guy some numbers
diff --git a/compel/test/rsys/spy.c b/compel/test/rsys/spy.c
index dd89005f1..4a6fcef29 100644
--- a/compel/test/rsys/spy.c
+++ b/compel/test/rsys/spy.c
@@ -15,7 +15,11 @@ static void print_vmsg(unsigned int lvl, const char *fmt, va_list parms)
static int do_rsetsid(int pid)
{
-#define err_and_ret(msg) do { fprintf(stderr, msg); return -1; } while (0)
+#define err_and_ret(msg) \
+ do { \
+ fprintf(stderr, msg); \
+ return -1; \
+ } while (0)
int state;
long ret;
@@ -85,14 +89,22 @@ int main(int argc, char **argv)
pid = vfork();
if (pid == 0) {
- close(p_in[1]); dup2(p_in[0], 0); close(p_in[0]);
- close(p_out[0]); dup2(p_out[1], 1); close(p_out[1]);
- close(p_err[0]); dup2(p_err[1], 2); close(p_err[1]);
+ close(p_in[1]);
+ dup2(p_in[0], 0);
+ close(p_in[0]);
+ close(p_out[0]);
+ dup2(p_out[1], 1);
+ close(p_out[1]);
+ close(p_err[0]);
+ dup2(p_err[1], 2);
+ close(p_err[1]);
execl("./victim", "victim", NULL);
exit(1);
}
- close(p_in[0]); close(p_out[1]); close(p_err[1]);
+ close(p_in[0]);
+ close(p_out[1]);
+ close(p_err[1]);
sid = getsid(0);
/*