diff --git a/compel/arch/aarch64/plugins/include/asm/syscall-types.h b/compel/arch/aarch64/plugins/include/asm/syscall-types.h index ee0e2185d..45fd57af6 100644 --- a/compel/arch/aarch64/plugins/include/asm/syscall-types.h +++ b/compel/arch/aarch64/plugins/include/asm/syscall-types.h @@ -1,7 +1,7 @@ #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__ #define COMPEL_ARCH_SYSCALL_TYPES_H__ -#define SA_RESTORER 0x04000000 +#define SA_RESTORER 0x04000000 typedef void rt_signalfn_t(int, siginfo_t *, void *); typedef rt_signalfn_t *rt_sighandler_t; @@ -9,20 +9,20 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define _KNSIG 64 -#define _NSIG_BPW 64 +#define _KNSIG 64 +#define _NSIG_BPW 64 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) typedef struct { unsigned long sig[_KNSIG_WORDS]; } k_rtsigset_t; typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; #endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */ diff --git a/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h index 6272bf3a8..3c7124856 100644 --- a/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h +++ b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h @@ -1,3 +1,3 @@ #ifndef __NR_openat -# define __NR_openat 56 +#define __NR_openat 56 #endif diff --git a/compel/arch/aarch64/src/lib/include/handle-elf.h b/compel/arch/aarch64/src/lib/include/handle-elf.h index 0f64b34cb..9f1a75081 100644 --- a/compel/arch/aarch64/src/lib/include/handle-elf.h +++ b/compel/arch/aarch64/src/lib/include/handle-elf.h @@ -3,8 +3,8 @@ #include "elf64-types.h" -#define __handle_elf handle_elf_aarch64 -#define arch_is_machine_supported(e_machine) (e_machine == EM_AARCH64) +#define __handle_elf handle_elf_aarch64 +#define arch_is_machine_supported(e_machine) (e_machine == EM_AARCH64) extern int handle_elf_aarch64(void *mem, size_t size); diff --git a/compel/arch/aarch64/src/lib/include/syscall.h b/compel/arch/aarch64/src/lib/include/syscall.h index 30290667a..13ee906e1 100644 --- a/compel/arch/aarch64/src/lib/include/syscall.h +++ b/compel/arch/aarch64/src/lib/include/syscall.h @@ -1,4 +1,8 @@ #ifndef __COMPEL_SYSCALL_H__ #define __COMPEL_SYSCALL_H__ -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #endif diff --git a/compel/arch/aarch64/src/lib/include/uapi/asm/cpu.h b/compel/arch/aarch64/src/lib/include/uapi/asm/cpu.h index c35460e15..12e749508 100644 --- a/compel/arch/aarch64/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/aarch64/src/lib/include/uapi/asm/cpu.h @@ -1,6 +1,7 @@ #ifndef UAPI_COMPEL_ASM_CPU_H__ #define UAPI_COMPEL_ASM_CPU_H__ -typedef struct { } compel_cpuinfo_t; +typedef struct { +} compel_cpuinfo_t; #endif /* UAPI_COMPEL_ASM_CPU_H__ */ diff --git a/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h b/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h index b52f7a766..f91e73dc4 100644 --- a/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/aarch64/src/lib/include/uapi/asm/infect-types.h @@ -6,8 +6,8 @@ #include #include -#define SIGMAX 64 -#define SIGMAX_OLD 31 +#define SIGMAX 64 +#define SIGMAX_OLD 31 /* * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h @@ -15,23 +15,27 @@ * A thread ARM CPU context */ -typedef struct user_pt_regs user_regs_struct_t; -typedef struct user_fpsimd_state user_fpregs_struct_t; +typedef struct user_pt_regs user_regs_struct_t; +typedef struct user_fpsimd_state user_fpregs_struct_t; #define __compel_arch_fetch_thread_area(tid, th) 0 -#define compel_arch_fetch_thread_area(tctl) 0 +#define compel_arch_fetch_thread_area(tctl) 0 #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) -#define REG_RES(r) ((uint64_t)(r).regs[0]) -#define REG_IP(r) ((uint64_t)(r).pc) -#define REG_SP(r) ((uint64_t)((r).sp)) -#define REG_SYSCALL_NR(r) ((uint64_t)(r).regs[8]) +#define REG_RES(r) ((uint64_t)(r).regs[0]) +#define REG_IP(r) ((uint64_t)(r).pc) +#define REG_SP(r) ((uint64_t)((r).sp)) +#define REG_SYSCALL_NR(r) ((uint64_t)(r).regs[8]) -#define user_regs_native(pregs) true +#define user_regs_native(pregs) true -#define ARCH_SI_TRAP TRAP_BRKPT +#define ARCH_SI_TRAP TRAP_BRKPT -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #endif /* UAPI_COMPEL_ASM_TYPES_H__ */ diff --git a/compel/arch/aarch64/src/lib/include/uapi/asm/sigframe.h b/compel/arch/aarch64/src/lib/include/uapi/asm/sigframe.h index bff714cca..f8ec55d6c 100644 --- a/compel/arch/aarch64/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/aarch64/src/lib/include/uapi/asm/sigframe.h @@ -8,30 +8,31 @@ /* Copied from the kernel header arch/arm64/include/uapi/asm/sigcontext.h */ -#define FPSIMD_MAGIC 0x46508001 +#define FPSIMD_MAGIC 0x46508001 -typedef struct fpsimd_context fpu_state_t; +typedef struct fpsimd_context fpu_state_t; struct aux_context { - struct fpsimd_context fpsimd; + struct fpsimd_context fpsimd; /* additional context to be added before "end" */ - struct _aarch64_ctx end; + struct _aarch64_ctx end; }; // XXX: the idetifier rt_sigcontext is expected to be struct by the CRIU code -#define rt_sigcontext sigcontext +#define rt_sigcontext sigcontext #include /* Copied from the kernel source arch/arm64/kernel/signal.c */ struct rt_sigframe { - siginfo_t info; - ucontext_t uc; - uint64_t fp; - uint64_t lr; + siginfo_t info; + ucontext_t uc; + uint64_t fp; + uint64_t lr; }; +/* clang-format off */ #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \ asm volatile( \ "mov sp, %0 \n" \ @@ -40,30 +41,29 @@ struct rt_sigframe { : \ : "r"(new_sp) \ : "x8", "memory") +/* clang-format on */ /* cr_sigcontext is copied from arch/arm64/include/uapi/asm/sigcontext.h */ struct cr_sigcontext { - __u64 fault_address; - /* AArch64 registers */ - __u64 regs[31]; - __u64 sp; - __u64 pc; - __u64 pstate; - /* 4K reserved for FP/SIMD state and future expansion */ - __u8 __reserved[4096] __attribute__((__aligned__(16))); + __u64 fault_address; + /* AArch64 registers */ + __u64 regs[31]; + __u64 sp; + __u64 pc; + __u64 pstate; + /* 4K reserved for FP/SIMD state and future expansion */ + __u8 __reserved[4096] __attribute__((__aligned__(16))); }; -#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc) -#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.pc) -#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) -#define RT_SIGFRAME_SIGCONTEXT(rt_sigframe) ((struct cr_sigcontext *)&(rt_sigframe)->uc.uc_mcontext) -#define RT_SIGFRAME_AUX_CONTEXT(rt_sigframe) ((struct aux_context*)&(RT_SIGFRAME_SIGCONTEXT(rt_sigframe)->__reserved)) -#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_CONTEXT(rt_sigframe)->fpsimd) -#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 +#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc) +#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.pc) +#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) +#define RT_SIGFRAME_SIGCONTEXT(rt_sigframe) ((struct cr_sigcontext *)&(rt_sigframe)->uc.uc_mcontext) +#define RT_SIGFRAME_AUX_CONTEXT(rt_sigframe) ((struct aux_context *)&(RT_SIGFRAME_SIGCONTEXT(rt_sigframe)->__reserved)) +#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_CONTEXT(rt_sigframe)->fpsimd) +#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 -#define rt_sigframe_erase_sigset(sigframe) \ - memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) -#define rt_sigframe_copy_sigset(sigframe, from) \ - memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) +#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) +#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) #endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */ diff --git a/compel/arch/arm/plugins/include/asm/syscall-types.h b/compel/arch/arm/plugins/include/asm/syscall-types.h index cdb03ef4c..acc03de52 100644 --- a/compel/arch/arm/plugins/include/asm/syscall-types.h +++ b/compel/arch/arm/plugins/include/asm/syscall-types.h @@ -1,7 +1,7 @@ #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__ #define COMPEL_ARCH_SYSCALL_TYPES_H__ -#define SA_RESTORER 0x04000000 +#define SA_RESTORER 0x04000000 typedef void rt_signalfn_t(int, siginfo_t *, void *); typedef rt_signalfn_t *rt_sighandler_t; @@ -9,20 +9,20 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define _KNSIG 64 -#define _NSIG_BPW 32 +#define _KNSIG 64 +#define _NSIG_BPW 32 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) typedef struct { unsigned long sig[_KNSIG_WORDS]; } k_rtsigset_t; typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; #endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */ diff --git a/compel/arch/arm/plugins/std/syscalls/syscall-aux.h b/compel/arch/arm/plugins/std/syscalls/syscall-aux.h index 3d2056b5a..7418546e1 100644 --- a/compel/arch/arm/plugins/std/syscalls/syscall-aux.h +++ b/compel/arch/arm/plugins/std/syscalls/syscall-aux.h @@ -1,27 +1,27 @@ #ifndef __NR_mmap2 -# define __NR_mmap2 192 +#define __NR_mmap2 192 #endif #ifndef __ARM_NR_BASE -# define __ARM_NR_BASE 0x0f0000 +#define __ARM_NR_BASE 0x0f0000 #endif #ifndef __ARM_NR_breakpoint -# define __ARM_NR_breakpoint (__ARM_NR_BASE+1) +#define __ARM_NR_breakpoint (__ARM_NR_BASE + 1) #endif #ifndef __ARM_NR_cacheflush -# define __ARM_NR_cacheflush (__ARM_NR_BASE+2) +#define __ARM_NR_cacheflush (__ARM_NR_BASE + 2) #endif #ifndef __ARM_NR_usr26 -# define __ARM_NR_usr26 (__ARM_NR_BASE+3) +#define __ARM_NR_usr26 (__ARM_NR_BASE + 3) #endif #ifndef __ARM_NR_usr32 -# define __ARM_NR_usr32 (__ARM_NR_BASE+4) +#define __ARM_NR_usr32 (__ARM_NR_BASE + 4) #endif #ifndef __ARM_NR_set_tls -# define __ARM_NR_set_tls (__ARM_NR_BASE+5) +#define __ARM_NR_set_tls (__ARM_NR_BASE + 5) #endif diff --git a/compel/arch/arm/src/lib/include/handle-elf.h b/compel/arch/arm/src/lib/include/handle-elf.h index e5971f37b..4b5e1457a 100644 --- a/compel/arch/arm/src/lib/include/handle-elf.h +++ b/compel/arch/arm/src/lib/include/handle-elf.h @@ -3,8 +3,8 @@ #include "elf32-types.h" -#define __handle_elf handle_elf_arm -#define arch_is_machine_supported(e_machine) (e_machine == EM_ARM) +#define __handle_elf handle_elf_arm +#define arch_is_machine_supported(e_machine) (e_machine == EM_ARM) extern int handle_elf_arm(void *mem, size_t size); diff --git a/compel/arch/arm/src/lib/include/syscall.h b/compel/arch/arm/src/lib/include/syscall.h index 30290667a..13ee906e1 100644 --- a/compel/arch/arm/src/lib/include/syscall.h +++ b/compel/arch/arm/src/lib/include/syscall.h @@ -1,4 +1,8 @@ #ifndef __COMPEL_SYSCALL_H__ #define __COMPEL_SYSCALL_H__ -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #endif diff --git a/compel/arch/arm/src/lib/include/uapi/asm/cpu.h b/compel/arch/arm/src/lib/include/uapi/asm/cpu.h index c35460e15..12e749508 100644 --- a/compel/arch/arm/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/arm/src/lib/include/uapi/asm/cpu.h @@ -1,6 +1,7 @@ #ifndef UAPI_COMPEL_ASM_CPU_H__ #define UAPI_COMPEL_ASM_CPU_H__ -typedef struct { } compel_cpuinfo_t; +typedef struct { +} compel_cpuinfo_t; #endif /* UAPI_COMPEL_ASM_CPU_H__ */ diff --git a/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h b/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h index 5e05ef53d..159b6a9fb 100644 --- a/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/arm/src/lib/include/uapi/asm/infect-types.h @@ -4,8 +4,8 @@ #include #include -#define SIGMAX 64 -#define SIGMAX_OLD 31 +#define SIGMAX 64 +#define SIGMAX_OLD 31 /* * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h @@ -14,58 +14,61 @@ */ typedef struct { - long uregs[18]; + long uregs[18]; } user_regs_struct_t; #define __compel_arch_fetch_thread_area(tid, th) 0 -#define compel_arch_fetch_thread_area(tctl) 0 +#define compel_arch_fetch_thread_area(tctl) 0 #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) -typedef struct user_vfp user_fpregs_struct_t; - -#define ARM_cpsr uregs[16] -#define ARM_pc uregs[15] -#define ARM_lr uregs[14] -#define ARM_sp uregs[13] -#define ARM_ip uregs[12] -#define ARM_fp uregs[11] -#define ARM_r10 uregs[10] -#define ARM_r9 uregs[9] -#define ARM_r8 uregs[8] -#define ARM_r7 uregs[7] -#define ARM_r6 uregs[6] -#define ARM_r5 uregs[5] -#define ARM_r4 uregs[4] -#define ARM_r3 uregs[3] -#define ARM_r2 uregs[2] -#define ARM_r1 uregs[1] -#define ARM_r0 uregs[0] -#define ARM_ORIG_r0 uregs[17] +typedef struct user_vfp user_fpregs_struct_t; +#define ARM_cpsr uregs[16] +#define ARM_pc uregs[15] +#define ARM_lr uregs[14] +#define ARM_sp uregs[13] +#define ARM_ip uregs[12] +#define ARM_fp uregs[11] +#define ARM_r10 uregs[10] +#define ARM_r9 uregs[9] +#define ARM_r8 uregs[8] +#define ARM_r7 uregs[7] +#define ARM_r6 uregs[6] +#define ARM_r5 uregs[5] +#define ARM_r4 uregs[4] +#define ARM_r3 uregs[3] +#define ARM_r2 uregs[2] +#define ARM_r1 uregs[1] +#define ARM_r0 uregs[0] +#define ARM_ORIG_r0 uregs[17] /* Copied from arch/arm/include/asm/user.h */ struct user_vfp { - unsigned long long fpregs[32]; - unsigned long fpscr; + unsigned long long fpregs[32]; + unsigned long fpscr; }; struct user_vfp_exc { - unsigned long fpexc; - unsigned long fpinst; - unsigned long fpinst2; + unsigned long fpexc; + unsigned long fpinst; + unsigned long fpinst2; }; -#define REG_RES(regs) ((regs).ARM_r0) -#define REG_IP(regs) ((regs).ARM_pc) -#define REG_SP(regs) ((regs).ARM_sp) -#define REG_SYSCALL_NR(regs) ((regs).ARM_r7) +#define REG_RES(regs) ((regs).ARM_r0) +#define REG_IP(regs) ((regs).ARM_pc) +#define REG_SP(regs) ((regs).ARM_sp) +#define REG_SYSCALL_NR(regs) ((regs).ARM_r7) -#define user_regs_native(pregs) true +#define user_regs_native(pregs) true -#define ARCH_SI_TRAP TRAP_BRKPT +#define ARCH_SI_TRAP TRAP_BRKPT -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #endif /* UAPI_COMPEL_ASM_TYPES_H__ */ diff --git a/compel/arch/arm/src/lib/include/uapi/asm/processor-flags.h b/compel/arch/arm/src/lib/include/uapi/asm/processor-flags.h index 8745f4459..36edf231a 100644 --- a/compel/arch/arm/src/lib/include/uapi/asm/processor-flags.h +++ b/compel/arch/arm/src/lib/include/uapi/asm/processor-flags.h @@ -6,37 +6,37 @@ /* * PSR bits */ -#define USR26_MODE 0x00000000 -#define FIQ26_MODE 0x00000001 -#define IRQ26_MODE 0x00000002 -#define SVC26_MODE 0x00000003 -#define USR_MODE 0x00000010 -#define FIQ_MODE 0x00000011 -#define IRQ_MODE 0x00000012 -#define SVC_MODE 0x00000013 -#define ABT_MODE 0x00000017 -#define UND_MODE 0x0000001b -#define SYSTEM_MODE 0x0000001f -#define MODE32_BIT 0x00000010 -#define MODE_MASK 0x0000001f -#define PSR_T_BIT 0x00000020 -#define PSR_F_BIT 0x00000040 -#define PSR_I_BIT 0x00000080 -#define PSR_A_BIT 0x00000100 -#define PSR_E_BIT 0x00000200 -#define PSR_J_BIT 0x01000000 -#define PSR_Q_BIT 0x08000000 -#define PSR_V_BIT 0x10000000 -#define PSR_C_BIT 0x20000000 -#define PSR_Z_BIT 0x40000000 -#define PSR_N_BIT 0x80000000 +#define USR26_MODE 0x00000000 +#define FIQ26_MODE 0x00000001 +#define IRQ26_MODE 0x00000002 +#define SVC26_MODE 0x00000003 +#define USR_MODE 0x00000010 +#define FIQ_MODE 0x00000011 +#define IRQ_MODE 0x00000012 +#define SVC_MODE 0x00000013 +#define ABT_MODE 0x00000017 +#define UND_MODE 0x0000001b +#define SYSTEM_MODE 0x0000001f +#define MODE32_BIT 0x00000010 +#define MODE_MASK 0x0000001f +#define PSR_T_BIT 0x00000020 +#define PSR_F_BIT 0x00000040 +#define PSR_I_BIT 0x00000080 +#define PSR_A_BIT 0x00000100 +#define PSR_E_BIT 0x00000200 +#define PSR_J_BIT 0x01000000 +#define PSR_Q_BIT 0x08000000 +#define PSR_V_BIT 0x10000000 +#define PSR_C_BIT 0x20000000 +#define PSR_Z_BIT 0x40000000 +#define PSR_N_BIT 0x80000000 /* * Groups of PSR bits */ -#define PSR_f 0xff000000 /* Flags */ -#define PSR_s 0x00ff0000 /* Status */ -#define PSR_x 0x0000ff00 /* Extension */ -#define PSR_c 0x000000ff /* Control */ +#define PSR_f 0xff000000 /* Flags */ +#define PSR_s 0x00ff0000 /* Status */ +#define PSR_x 0x0000ff00 /* Extension */ +#define PSR_c 0x000000ff /* Control */ #endif diff --git a/compel/arch/arm/src/lib/include/uapi/asm/sigframe.h b/compel/arch/arm/src/lib/include/uapi/asm/sigframe.h index 23ada50aa..3db9978d0 100644 --- a/compel/arch/arm/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/arm/src/lib/include/uapi/asm/sigframe.h @@ -6,42 +6,42 @@ /* Copied from the Linux kernel header arch/arm/include/asm/sigcontext.h */ struct rt_sigcontext { - unsigned long trap_no; - unsigned long error_code; - unsigned long oldmask; - unsigned long arm_r0; - unsigned long arm_r1; - unsigned long arm_r2; - unsigned long arm_r3; - unsigned long arm_r4; - unsigned long arm_r5; - unsigned long arm_r6; - unsigned long arm_r7; - unsigned long arm_r8; - unsigned long arm_r9; - unsigned long arm_r10; - unsigned long arm_fp; - unsigned long arm_ip; - unsigned long arm_sp; - unsigned long arm_lr; - unsigned long arm_pc; - unsigned long arm_cpsr; - unsigned long fault_address; + unsigned long trap_no; + unsigned long error_code; + unsigned long oldmask; + unsigned long arm_r0; + unsigned long arm_r1; + unsigned long arm_r2; + unsigned long arm_r3; + unsigned long arm_r4; + unsigned long arm_r5; + unsigned long arm_r6; + unsigned long arm_r7; + unsigned long arm_r8; + unsigned long arm_r9; + unsigned long arm_r10; + unsigned long arm_fp; + unsigned long arm_ip; + unsigned long arm_sp; + unsigned long arm_lr; + unsigned long arm_pc; + unsigned long arm_cpsr; + unsigned long fault_address; }; /* Copied from the Linux kernel header arch/arm/include/asm/ucontext.h */ -#define VFP_MAGIC 0x56465001 -#define VFP_STORAGE_SIZE sizeof(struct vfp_sigframe) +#define VFP_MAGIC 0x56465001 +#define VFP_STORAGE_SIZE sizeof(struct vfp_sigframe) struct vfp_sigframe { - unsigned long magic; - unsigned long size; - struct user_vfp ufp; - struct user_vfp_exc ufp_exc; + unsigned long magic; + unsigned long size; + struct user_vfp ufp; + struct user_vfp_exc ufp_exc; }; -typedef struct vfp_sigframe fpu_state_t; +typedef struct vfp_sigframe fpu_state_t; struct aux_sigframe { /* @@ -49,23 +49,23 @@ struct aux_sigframe { struct iwmmxt_sigframe iwmmxt; */ - struct vfp_sigframe vfp; - unsigned long end_magic; + struct vfp_sigframe vfp; + unsigned long end_magic; } __attribute__((aligned(8))); #include struct sigframe { - struct rt_ucontext uc; - unsigned long retcode[2]; + struct rt_ucontext uc; + unsigned long retcode[2]; }; struct rt_sigframe { - struct rt_siginfo info; - struct sigframe sig; + struct rt_siginfo info; + struct sigframe sig; }; - +/* clang-format off */ #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \ asm volatile( \ "mov sp, %0 \n" \ @@ -74,17 +74,16 @@ struct rt_sigframe { : \ : "r"(new_sp) \ : "memory") +/* clang-format on */ -#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->sig.uc) -#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->sig.uc.uc_mcontext.arm_ip -#define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1 -#define RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe) ((struct aux_sigframe *)&(rt_sigframe)->sig.uc.uc_regspace) -#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe)->vfp) -#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 +#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->sig.uc) +#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->sig.uc.uc_mcontext.arm_ip +#define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1 +#define RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe) ((struct aux_sigframe *)&(rt_sigframe)->sig.uc.uc_regspace) +#define RT_SIGFRAME_FPU(rt_sigframe) (&RT_SIGFRAME_AUX_SIGFRAME(rt_sigframe)->vfp) +#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 -#define rt_sigframe_erase_sigset(sigframe) \ - memset(&sigframe->sig.uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) -#define rt_sigframe_copy_sigset(sigframe, from) \ - memcpy(&sigframe->sig.uc.uc_sigmask, from, sizeof(k_rtsigset_t)) +#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->sig.uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) +#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->sig.uc.uc_sigmask, from, sizeof(k_rtsigset_t)) #endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */ diff --git a/compel/arch/mips/plugins/include/asm/prologue.h b/compel/arch/mips/plugins/include/asm/prologue.h index 9d812eec9..c19ce54d7 100644 --- a/compel/arch/mips/plugins/include/asm/prologue.h +++ b/compel/arch/mips/plugins/include/asm/prologue.h @@ -9,17 +9,16 @@ #include -#define sys_recv(sockfd, ubuf, size, flags) \ - sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL) +#define sys_recv(sockfd, ubuf, size, flags) sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL) typedef struct prologue_init_args { - struct sockaddr_un ctl_sock_addr; - unsigned int ctl_sock_addr_len; + struct sockaddr_un ctl_sock_addr; + unsigned int ctl_sock_addr_len; - unsigned int arg_s; - void *arg_p; + unsigned int arg_s; + void *arg_p; - void *sigframe; + void *sigframe; } prologue_init_args_t; #endif /* __ASSEMBLY__ */ @@ -29,8 +28,8 @@ typedef struct prologue_init_args { * * FIXME It is rather should be taken from sigframe header. */ -#define PROLOGUE_SGFRAME_SIZE 4096 +#define PROLOGUE_SGFRAME_SIZE 4096 -#define PROLOGUE_INIT_ARGS_SIZE 1024 +#define PROLOGUE_INIT_ARGS_SIZE 1024 #endif /* __ASM_PROLOGUE_H__ */ diff --git a/compel/arch/mips/plugins/include/asm/syscall-types.h b/compel/arch/mips/plugins/include/asm/syscall-types.h index 64daf2c7a..bd7e8dfb3 100644 --- a/compel/arch/mips/plugins/include/asm/syscall-types.h +++ b/compel/arch/mips/plugins/include/asm/syscall-types.h @@ -8,13 +8,13 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define SA_RESTORER 0x04000000 +#define SA_RESTORER 0x04000000 /** refer to linux-3.10/arch/mips/include/uapi/asm/signal.h*/ -#define _KNSIG 128 -#define _NSIG_BPW 64 +#define _KNSIG 128 +#define _NSIG_BPW 64 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) /* * Note: as k_rtsigset_t is the same size for 32-bit and 64-bit, @@ -23,14 +23,14 @@ typedef rt_restorefn_t *rt_sigrestore_t; */ typedef struct { - uint64_t sig[_KNSIG_WORDS]; + uint64_t sig[_KNSIG_WORDS]; } k_rtsigset_t; typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; #endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */ diff --git a/compel/arch/mips/src/lib/include/handle-elf.h b/compel/arch/mips/src/lib/include/handle-elf.h index f28188136..aa650a2f6 100644 --- a/compel/arch/mips/src/lib/include/handle-elf.h +++ b/compel/arch/mips/src/lib/include/handle-elf.h @@ -3,6 +3,6 @@ #include "elf64-types.h" -#define arch_is_machine_supported(e_machine) (e_machine == EM_MIPS) +#define arch_is_machine_supported(e_machine) (e_machine == EM_MIPS) #endif /* COMPEL_HANDLE_ELF_H__ */ diff --git a/compel/arch/mips/src/lib/include/ldsodefs.h b/compel/arch/mips/src/lib/include/ldsodefs.h index 54faa4668..8cfde2496 100644 --- a/compel/arch/mips/src/lib/include/ldsodefs.h +++ b/compel/arch/mips/src/lib/include/ldsodefs.h @@ -28,39 +28,27 @@ struct La_mips_32_retval; struct La_mips_64_regs; struct La_mips_64_retval; -#define ARCH_PLTENTER_MEMBERS \ - Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - struct La_mips_32_regs *, \ - unsigned int *, const char *name, \ - long int *framesizep); \ - Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - struct La_mips_64_regs *, \ - unsigned int *, const char *name, \ - long int *framesizep); \ - Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - struct La_mips_64_regs *, \ - unsigned int *, const char *name, \ - long int *framesizep); +#define ARCH_PLTENTER_MEMBERS \ + Elf32_Addr (*mips_o32_gnu_pltenter)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + struct La_mips_32_regs *, unsigned int *, const char *name, \ + long int *framesizep); \ + Elf32_Addr (*mips_n32_gnu_pltenter)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + struct La_mips_64_regs *, unsigned int *, const char *name, \ + long int *framesizep); \ + Elf64_Addr (*mips_n64_gnu_pltenter)(Elf64_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + struct La_mips_64_regs *, unsigned int *, const char *name, \ + long int *framesizep); -#define ARCH_PLTEXIT_MEMBERS \ - unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - const struct La_mips_32_regs *, \ - struct La_mips_32_retval *, \ - const char *); \ - unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - const struct La_mips_64_regs *, \ - struct La_mips_64_retval *, \ - const char *); \ - unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int, \ - uintptr_t *, uintptr_t *, \ - const struct La_mips_64_regs *, \ - struct La_mips_64_retval *, \ - const char *); +#define ARCH_PLTEXIT_MEMBERS \ + unsigned int (*mips_o32_gnu_pltexit)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + const struct La_mips_32_regs *, struct La_mips_32_retval *, \ + const char *); \ + unsigned int (*mips_n32_gnu_pltexit)(Elf32_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + const struct La_mips_64_regs *, struct La_mips_64_retval *, \ + const char *); \ + unsigned int (*mips_n64_gnu_pltexit)(Elf64_Sym *, unsigned int, uintptr_t *, uintptr_t *, \ + const struct La_mips_64_regs *, struct La_mips_64_retval *, \ + const char *); /* The MIPS ABI specifies that the dynamic section has to be read-only. */ @@ -80,77 +68,63 @@ struct La_mips_64_retval; /* An entry in a 64 bit SHT_REL section. */ -typedef struct -{ - Elf32_Word r_sym; /* Symbol index */ - unsigned char r_ssym; /* Special symbol for 2nd relocation */ - unsigned char r_type3; /* 3rd relocation type */ - unsigned char r_type2; /* 2nd relocation type */ - unsigned char r_type1; /* 1st relocation type */ +typedef struct { + Elf32_Word r_sym; /* Symbol index */ + unsigned char r_ssym; /* Special symbol for 2nd relocation */ + unsigned char r_type3; /* 3rd relocation type */ + unsigned char r_type2; /* 2nd relocation type */ + unsigned char r_type1; /* 1st relocation type */ } _Elf64_Mips_R_Info; -typedef union -{ - Elf64_Xword r_info_number; +typedef union { + Elf64_Xword r_info_number; _Elf64_Mips_R_Info r_info_fields; } _Elf64_Mips_R_Info_union; -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */ +typedef struct { + Elf64_Addr r_offset; /* Address */ + _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */ } Elf64_Mips_Rel; -typedef struct -{ - Elf64_Addr r_offset; /* Address */ - _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */ - Elf64_Sxword r_addend; /* Addend */ +typedef struct { + Elf64_Addr r_offset; /* Address */ + _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */ + Elf64_Sxword r_addend; /* Addend */ } Elf64_Mips_Rela; -#define ELF64_MIPS_R_SYM(i) \ - ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) +#define ELF64_MIPS_R_SYM(i) ((__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) -#define ELF64_MIPS_R_TYPE(i) \ - (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \ - | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ - ).r_info_fields.r_type2 << 8) \ - | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ - ).r_info_fields.r_type3 << 16) \ - | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ - ).r_info_fields.r_ssym << 24)) +#define ELF64_MIPS_R_TYPE(i) \ + (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 | \ + ((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type2 << 8) | \ + ((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type3 << 16) | \ + ((Elf32_Word)(__extension__(_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_ssym << 24)) -#define ELF64_MIPS_R_INFO(sym, type) \ - (__extension__ (_Elf64_Mips_R_Info_union) \ - (__extension__ (_Elf64_Mips_R_Info) \ - { (sym), ELF64_MIPS_R_SSYM (type), \ - ELF64_MIPS_R_TYPE3 (type), \ - ELF64_MIPS_R_TYPE2 (type), \ - ELF64_MIPS_R_TYPE1 (type) \ - }).r_info_number) +#define ELF64_MIPS_R_INFO(sym, type) \ + (__extension__(_Elf64_Mips_R_Info_union)( \ + __extension__(_Elf64_Mips_R_Info){ (sym), ELF64_MIPS_R_SSYM(type), ELF64_MIPS_R_TYPE3(type), \ + ELF64_MIPS_R_TYPE2(type), ELF64_MIPS_R_TYPE1(type) }) \ + .r_info_number) /* * These macros decompose the value returned by ELF64_MIPS_R_TYPE, and * compose it back into a value that it can be used as an argument to * ELF64_MIPS_R_INFO. */ -#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff) +#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff) #define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff) #define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff) -#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff) +#define ELF64_MIPS_R_TYPE1(i) ((i)&0xff) #define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \ - ((type1) \ - | ((Elf32_Word)(type2) << 8) \ - | ((Elf32_Word)(type3) << 16) \ - | ((Elf32_Word)(ssym) << 24)) + ((type1) | ((Elf32_Word)(type2) << 8) | ((Elf32_Word)(type3) << 16) | ((Elf32_Word)(ssym) << 24)) #undef ELF64_R_SYM -#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i) +#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM(i) #undef ELF64_R_TYPE /*fixme*/ -#define ELF64_R_TYPE(i) (ELF64_MIPS_R_TYPE (i) & 0x00ff) +#define ELF64_R_TYPE(i) (ELF64_MIPS_R_TYPE(i) & 0x00ff) #undef ELF64_R_INFO -#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type)) +#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO((sym), (type)) #endif diff --git a/compel/arch/mips/src/lib/include/syscall.h b/compel/arch/mips/src/lib/include/syscall.h index 704080172..6cad7ca73 100644 --- a/compel/arch/mips/src/lib/include/syscall.h +++ b/compel/arch/mips/src/lib/include/syscall.h @@ -2,6 +2,6 @@ #define __COMPEL_SYSCALL_H__ #ifndef SIGSTKFLT -#define SIGSTKFLT 16 +#define SIGSTKFLT 16 #endif #endif diff --git a/compel/arch/mips/src/lib/include/uapi/asm/cpu.h b/compel/arch/mips/src/lib/include/uapi/asm/cpu.h index 329b9529b..e568df789 100644 --- a/compel/arch/mips/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/cpu.h @@ -1,5 +1,6 @@ #ifndef __CR_ASM_CPU_H__ #define __CR_ASM_CPU_H__ -typedef struct { } compel_cpuinfo_t; +typedef struct { +} compel_cpuinfo_t; #endif /* __CR_ASM_CPU_H__ */ diff --git a/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h b/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h index 2a85dd402..70b3f85a5 100644 --- a/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h @@ -6,8 +6,8 @@ #include #include #include -#define SIGMAX 64 -#define SIGMAX_OLD 31 +#define SIGMAX 64 +#define SIGMAX_OLD 31 /* * Copied from the Linux kernel header arch/mips/include/asm/ptrace.h @@ -35,35 +35,33 @@ typedef struct { __u32 fpu_fcr31; __u32 fpu_id; - } user_fpregs_struct_t; -#define MIPS_a0 regs[4] //arguments a0-a3 -#define MIPS_t0 regs[8] //temporaries t0-t7 -#define MIPS_v0 regs[2] -#define MIPS_v1 regs[3] -#define MIPS_sp regs[29] -#define MIPS_ra regs[31] +#define MIPS_a0 regs[4] //arguments a0-a3 +#define MIPS_t0 regs[8] //temporaries t0-t7 +#define MIPS_v0 regs[2] +#define MIPS_v1 regs[3] +#define MIPS_sp regs[29] +#define MIPS_ra regs[31] - -#define NATIVE_MAGIC 0x0A -#define COMPAT_MAGIC 0x0C +#define NATIVE_MAGIC 0x0A +#define COMPAT_MAGIC 0x0C static inline bool user_regs_native(user_regs_struct_t *pregs) { return true; } #define __compel_arch_fetch_thread_area(tid, th) 0 -#define compel_arch_fetch_thread_area(tctl) 0 +#define compel_arch_fetch_thread_area(tctl) 0 #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) -#define REG_RES(regs) ((regs).MIPS_v0) -#define REG_IP(regs) ((regs).cp0_epc) -#define REG_SP(regs) ((regs).MIPS_sp) -#define REG_SYSCALL_NR(regs) ((regs).MIPS_v0) +#define REG_RES(regs) ((regs).MIPS_v0) +#define REG_IP(regs) ((regs).cp0_epc) +#define REG_SP(regs) ((regs).MIPS_sp) +#define REG_SYSCALL_NR(regs) ((regs).MIPS_v0) //#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) -#define __NR(syscall, compat) __NR_##syscall +#define __NR(syscall, compat) __NR_##syscall #endif /* UAPI_COMPEL_ASM_TYPES_H__ */ diff --git a/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h b/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h index c08fe06a3..5d0a0628e 100644 --- a/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h @@ -11,13 +11,12 @@ #define u32 __u32 /* sigcontext defined in /usr/include/asm/sigcontext.h*/ -#define rt_sigcontext sigcontext - +#define rt_sigcontext sigcontext #include /* refer to linux-3.10/include/uapi/asm-generic/ucontext.h */ -struct k_ucontext{ +struct k_ucontext { unsigned long uc_flags; struct k_ucontext *uc_link; stack_t uc_stack; @@ -27,23 +26,21 @@ struct k_ucontext{ /* Copy from the kernel source arch/mips/kernel/signal.c */ struct rt_sigframe { - u32 rs_ass[4]; /* argument save space for o32 */ - u32 rs_pad[2]; /* Was: signal trampoline */ + u32 rs_ass[4]; /* argument save space for o32 */ + u32 rs_pad[2]; /* Was: signal trampoline */ siginfo_t rs_info; struct k_ucontext rs_uc; }; - -#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->rs_uc) -#define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) ((k_rtsigset_t *)(void *)&rt_sigframe->rs_uc.uc_sigmask) -#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)0x00) +#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->rs_uc) +#define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) ((k_rtsigset_t *)(void *)&rt_sigframe->rs_uc.uc_sigmask) +#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)0x00) #define RT_SIGFRAME_FPU(rt_sigframe) #define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1 +#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 -#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 - - +/* clang-format off */ #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \ asm volatile( \ "move $29, %0 \n" \ @@ -52,12 +49,10 @@ struct rt_sigframe { : \ : "r"(new_sp) \ : "$2","memory") +/* clang-format on */ -int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, - struct rt_sigframe *rsigframe); +int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe); -#define rt_sigframe_erase_sigset(sigframe) \ - memset(&sigframe->rs_uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) -#define rt_sigframe_copy_sigset(sigframe, from) \ - memcpy(&sigframe->rs_uc.uc_sigmask, from, sizeof(k_rtsigset_t)) +#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->rs_uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) +#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->rs_uc.uc_sigmask, from, sizeof(k_rtsigset_t)) #endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */ diff --git a/compel/arch/mips/src/lib/include/uapi/asm/siginfo.h b/compel/arch/mips/src/lib/include/uapi/asm/siginfo.h index 519aea1a6..82ae6096b 100644 --- a/compel/arch/mips/src/lib/include/uapi/asm/siginfo.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/siginfo.h @@ -9,8 +9,7 @@ #ifndef _UAPI_ASM_SIGINFO_H #define _UAPI_ASM_SIGINFO_H - -#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2*sizeof(int)) +#define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(long) + 2 * sizeof(int)) #undef __ARCH_SI_TRAPNO /* exception code needs to fill this ... */ #define HAVE_ARCH_SIGINFO_T @@ -25,10 +24,10 @@ #define SI_MAX_SIZE 128 #define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) -#define __ARCH_SI_UID_T __kernel_uid32_t +#define __ARCH_SI_UID_T __kernel_uid32_t #ifndef __ARCH_SI_UID_T -#define __ARCH_SI_UID_T __kernel_uid32_t +#define __ARCH_SI_UID_T __kernel_uid32_t #endif #ifndef __ARCH_SI_BAND_T @@ -53,31 +52,31 @@ typedef struct siginfo { /* kill() */ struct { - __kernel_pid_t _pid; /* sender's pid */ - __ARCH_SI_UID_T _uid; /* sender's uid */ + __kernel_pid_t _pid; /* sender's pid */ + __ARCH_SI_UID_T _uid; /* sender's uid */ } _kill; /* POSIX.1b timers */ struct { - __kernel_timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)]; - sigval_t _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ + __kernel_timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + char _pad[sizeof(__ARCH_SI_UID_T) - sizeof(int)]; + sigval_t _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ } _timer; /* POSIX.1b signals */ struct { - __kernel_pid_t _pid; /* sender's pid */ - __ARCH_SI_UID_T _uid; /* sender's uid */ + __kernel_pid_t _pid; /* sender's pid */ + __ARCH_SI_UID_T _uid; /* sender's uid */ sigval_t _sigval; } _rt; /* SIGCHLD */ struct { - __kernel_pid_t _pid; /* which child */ - __ARCH_SI_UID_T _uid; /* sender's uid */ - int _status; /* exit code */ + __kernel_pid_t _pid; /* which child */ + __ARCH_SI_UID_T _uid; /* sender's uid */ + int _status; /* exit code */ __ARCH_SI_CLOCK_T _utime; __ARCH_SI_CLOCK_T _stime; } _sigchld; @@ -86,7 +85,7 @@ typedef struct siginfo { struct { void *_addr; /* faulting insn/memory ref. */ #ifdef __ARCH_SI_TRAPNO - int _trapno; /* TRAP # which caused the signal */ + int _trapno; /* TRAP # which caused the signal */ #endif short _addr_lsb; /* LSB of the reported address */ #ifndef __GENKSYMS__ @@ -99,15 +98,15 @@ typedef struct siginfo { /* SIGPOLL */ struct { - __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ int _fd; } _sigpoll; /* SIGSYS */ struct { void *_call_addr; /* calling user insn */ - int _syscall; /* triggering system call number */ - unsigned int _arch; /* AUDIT_ARCH_* of syscall */ + int _syscall; /* triggering system call number */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall */ } _sigsys; } _sifields; } __ARCH_SI_ATTRIBUTES siginfo_t; @@ -119,6 +118,6 @@ typedef struct siginfo { #undef SI_ASYNCIO #undef SI_TIMER #undef SI_MESGQ -#define SI_ASYNCIO -2 /* sent by AIO completion */ +#define SI_ASYNCIO -2 /* sent by AIO completion */ #endif /* _UAPI_ASM_SIGINFO_H */ diff --git a/compel/arch/ppc64/plugins/include/asm/syscall-types.h b/compel/arch/ppc64/plugins/include/asm/syscall-types.h index 7754721e2..1bea8496b 100644 --- a/compel/arch/ppc64/plugins/include/asm/syscall-types.h +++ b/compel/arch/ppc64/plugins/include/asm/syscall-types.h @@ -1,7 +1,7 @@ #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__ #define COMPEL_ARCH_SYSCALL_TYPES_H__ -#define SA_RESTORER 0x04000000U +#define SA_RESTORER 0x04000000U typedef void rt_signalfn_t(int, siginfo_t *, void *); typedef rt_signalfn_t *rt_sighandler_t; @@ -9,20 +9,20 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define _KNSIG 64 -#define _NSIG_BPW 64 +#define _KNSIG 64 +#define _NSIG_BPW 64 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) typedef struct { - unsigned long sig[_KNSIG_WORDS]; + unsigned long sig[_KNSIG_WORDS]; } k_rtsigset_t; typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; #endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */ diff --git a/compel/arch/ppc64/src/lib/include/handle-elf.h b/compel/arch/ppc64/src/lib/include/handle-elf.h index 1a8217e6b..ae20186a2 100644 --- a/compel/arch/ppc64/src/lib/include/handle-elf.h +++ b/compel/arch/ppc64/src/lib/include/handle-elf.h @@ -5,8 +5,8 @@ #define ELF_PPC64 -#define __handle_elf handle_elf_ppc64 -#define arch_is_machine_supported(e_machine) (e_machine == EM_PPC64) +#define __handle_elf handle_elf_ppc64 +#define arch_is_machine_supported(e_machine) (e_machine == EM_PPC64) extern int handle_elf_ppc64(void *mem, size_t size); diff --git a/compel/arch/ppc64/src/lib/include/syscall.h b/compel/arch/ppc64/src/lib/include/syscall.h index 30290667a..13ee906e1 100644 --- a/compel/arch/ppc64/src/lib/include/syscall.h +++ b/compel/arch/ppc64/src/lib/include/syscall.h @@ -1,4 +1,8 @@ #ifndef __COMPEL_SYSCALL_H__ #define __COMPEL_SYSCALL_H__ -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #endif diff --git a/compel/arch/ppc64/src/lib/include/uapi/asm/cpu.h b/compel/arch/ppc64/src/lib/include/uapi/asm/cpu.h index 59925868c..475e2bd59 100644 --- a/compel/arch/ppc64/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/ppc64/src/lib/include/uapi/asm/cpu.h @@ -4,7 +4,7 @@ #include typedef struct { - uint64_t hwcap[2]; + uint64_t hwcap[2]; } compel_cpuinfo_t; #endif /* UAPI_COMPEL_ASM_CPU_H__ */ diff --git a/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h b/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h index b65c942ee..fe6192e20 100644 --- a/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/ppc64/src/lib/include/uapi/asm/infect-types.h @@ -5,8 +5,8 @@ #include #include -#define SIGMAX_OLD 31 -#define SIGMAX 64 +#define SIGMAX_OLD 31 +#define SIGMAX 64 /* * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h @@ -15,44 +15,44 @@ typedef struct { unsigned long gpr[32]; unsigned long nip; unsigned long msr; - unsigned long orig_gpr3; /* Used for restarting system calls */ + unsigned long orig_gpr3; /* Used for restarting system calls */ unsigned long ctr; unsigned long link; unsigned long xer; unsigned long ccr; - unsigned long softe; /* Soft enabled/disabled */ - unsigned long trap; /* Reason for being here */ + unsigned long softe; /* Soft enabled/disabled */ + unsigned long trap; /* Reason for being here */ /* * N.B. for critical exceptions on 4xx, the dar and dsisr * fields are overloaded to hold srr0 and srr1. */ - unsigned long dar; /* Fault registers */ - unsigned long dsisr; /* on 4xx/Book-E used for ESR */ - unsigned long result; /* Result of a system call */ + unsigned long dar; /* Fault registers */ + unsigned long dsisr; /* on 4xx/Book-E used for ESR */ + unsigned long result; /* Result of a system call */ } user_regs_struct_t; -#define NVSXREG 32 +#define NVSXREG 32 -#define USER_FPREGS_FL_FP 0x00001 -#define USER_FPREGS_FL_ALTIVEC 0x00002 -#define USER_FPREGS_FL_VSX 0x00004 -#define USER_FPREGS_FL_TM 0x00010 +#define USER_FPREGS_FL_FP 0x00001 +#define USER_FPREGS_FL_ALTIVEC 0x00002 +#define USER_FPREGS_FL_VSX 0x00004 +#define USER_FPREGS_FL_TM 0x00010 #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 -#define MSR_TMA (1UL<<34) /* bit 29 Trans Mem state: Transactional */ -#define MSR_TMS (1UL<<33) /* bit 30 Trans Mem state: Suspended */ -#define MSR_TM (1UL<<32) /* bit 31 Trans Mem Available */ -#define MSR_VEC (1UL<<25) -#define MSR_VSX (1UL<<23) +#define MSR_TMA (1UL << 34) /* bit 29 Trans Mem state: Transactional */ +#define MSR_TMS (1UL << 33) /* bit 30 Trans Mem state: Suspended */ +#define MSR_TM (1UL << 32) /* bit 31 Trans Mem Available */ +#define MSR_VEC (1UL << 25) +#define MSR_VSX (1UL << 23) -#define MSR_TM_ACTIVE(x) ((((x) & MSR_TM) && ((x)&(MSR_TMA|MSR_TMS))) != 0) +#define MSR_TM_ACTIVE(x) ((((x)&MSR_TM) && ((x) & (MSR_TMA | MSR_TMS))) != 0) typedef struct { uint64_t fpregs[NFPREG]; @@ -72,19 +72,23 @@ typedef struct { } tm; } user_fpregs_struct_t; -#define REG_RES(regs) ((uint64_t)(regs).gpr[3]) -#define REG_IP(regs) ((uint64_t)(regs).nip) -#define REG_SP(regs) ((uint64_t)(regs).gpr[1]) -#define REG_SYSCALL_NR(regs) ((uint64_t)(regs).gpr[0]) +#define REG_RES(regs) ((uint64_t)(regs).gpr[3]) +#define REG_IP(regs) ((uint64_t)(regs).nip) +#define REG_SP(regs) ((uint64_t)(regs).gpr[1]) +#define REG_SYSCALL_NR(regs) ((uint64_t)(regs).gpr[0]) -#define user_regs_native(pregs) true +#define user_regs_native(pregs) true #define ARCH_SI_TRAP TRAP_BRKPT -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) #define __compel_arch_fetch_thread_area(tid, th) 0 -#define compel_arch_fetch_thread_area(tctl) 0 +#define compel_arch_fetch_thread_area(tctl) 0 #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) diff --git a/compel/arch/ppc64/src/lib/include/uapi/asm/sigframe.h b/compel/arch/ppc64/src/lib/include/uapi/asm/sigframe.h index 5c98b199d..eb12c9f7c 100644 --- a/compel/arch/ppc64/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/ppc64/src/lib/include/uapi/asm/sigframe.h @@ -19,30 +19,31 @@ #include -#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 +#define RT_SIGFRAME_OFFSET(rt_sigframe) 0 /* Copied from the Linux kernel header arch/powerpc/include/asm/ptrace.h */ -#define USER_REDZONE_SIZE 512 +#define USER_REDZONE_SIZE 512 /* Copied from the Linux kernel source file arch/powerpc/kernel/signal_64.c */ -#define TRAMP_SIZE 6 +#define TRAMP_SIZE 6 /* * ucontext_t defined in /usr/include/powerpc64le-linux-gnu/sys/ucontext.h */ struct rt_sigframe { - /* sys_rt_sigreturn requires the ucontext be the first field */ - ucontext_t uc; - ucontext_t uc_transact; /* Transactional state */ - unsigned long _unused[2]; - unsigned int tramp[TRAMP_SIZE]; - struct rt_siginfo *pinfo; - void *puc; - struct rt_siginfo info; - /* New 64 bit little-endian ABI allows redzone of 512 bytes below sp */ - char abigap[USER_REDZONE_SIZE]; + /* sys_rt_sigreturn requires the ucontext be the first field */ + ucontext_t uc; + ucontext_t uc_transact; /* Transactional state */ + unsigned long _unused[2]; + unsigned int tramp[TRAMP_SIZE]; + struct rt_siginfo *pinfo; + void *puc; + struct rt_siginfo info; + /* New 64 bit little-endian ABI allows redzone of 512 bytes below sp */ + char abigap[USER_REDZONE_SIZE]; } __attribute__((aligned(16))); +/* clang-format off */ #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \ asm volatile( \ "mr 1, %0 \n" \ @@ -51,29 +52,28 @@ struct rt_sigframe { : \ : "r"(new_sp) \ : "memory") +/* clang-format on */ #if _CALL_ELF != 2 -# error Only supporting ABIv2. +#error Only supporting ABIv2. #else -# define FRAME_MIN_SIZE_PARM 96 +#define FRAME_MIN_SIZE_PARM 96 #endif -#define RT_SIGFRAME_UC(rt_sigframe) (&(rt_sigframe)->uc) -#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.gp_regs[PT_NIP]) -#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) -#define RT_SIGFRAME_FPU(rt_sigframe) (&(rt_sigframe)->uc.uc_mcontext) +#define RT_SIGFRAME_UC(rt_sigframe) (&(rt_sigframe)->uc) +#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)(rt_sigframe)->uc.uc_mcontext.gp_regs[PT_NIP]) +#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) +#define RT_SIGFRAME_FPU(rt_sigframe) (&(rt_sigframe)->uc.uc_mcontext) -#define rt_sigframe_erase_sigset(sigframe) \ - memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) -#define rt_sigframe_copy_sigset(sigframe, from) \ - memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) +#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) +#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) -#define MSR_TMA (1UL<<34) /* bit 29 Trans Mem state: Transactional */ -#define MSR_TMS (1UL<<33) /* bit 30 Trans Mem state: Suspended */ -#define MSR_TM (1UL<<32) /* bit 31 Trans Mem Available */ -#define MSR_VEC (1UL<<25) -#define MSR_VSX (1UL<<23) +#define MSR_TMA (1UL << 34) /* bit 29 Trans Mem state: Transactional */ +#define MSR_TMS (1UL << 33) /* bit 30 Trans Mem state: Suspended */ +#define MSR_TM (1UL << 32) /* bit 31 Trans Mem Available */ +#define MSR_VEC (1UL << 25) +#define MSR_VSX (1UL << 23) -#define MSR_TM_ACTIVE(x) ((((x) & MSR_TM) && ((x)&(MSR_TMA|MSR_TMS))) != 0) +#define MSR_TM_ACTIVE(x) ((((x)&MSR_TM) && ((x) & (MSR_TMA | MSR_TMS))) != 0) #endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */ diff --git a/compel/arch/s390/plugins/include/asm/syscall-types.h b/compel/arch/s390/plugins/include/asm/syscall-types.h index 55d7ddb61..dd635399d 100644 --- a/compel/arch/s390/plugins/include/asm/syscall-types.h +++ b/compel/arch/s390/plugins/include/asm/syscall-types.h @@ -1,7 +1,7 @@ #ifndef COMPEL_ARCH_SYSCALL_TYPES_H__ #define COMPEL_ARCH_SYSCALL_TYPES_H__ -#define SA_RESTORER 0x04000000U +#define SA_RESTORER 0x04000000U typedef void rt_signalfn_t(int, siginfo_t *, void *); typedef rt_signalfn_t *rt_sighandler_t; @@ -9,13 +9,13 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define _KNSIG 64 -#define _NSIG_BPW 64 +#define _KNSIG 64 +#define _NSIG_BPW 64 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) typedef struct { - unsigned long sig[_KNSIG_WORDS]; + unsigned long sig[_KNSIG_WORDS]; } k_rtsigset_t; /* @@ -23,10 +23,10 @@ typedef struct { * include/linux/signal.h. */ typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; struct mmap_arg_struct; diff --git a/compel/arch/s390/src/lib/include/handle-elf.h b/compel/arch/s390/src/lib/include/handle-elf.h index cd1357401..597d8059f 100644 --- a/compel/arch/s390/src/lib/include/handle-elf.h +++ b/compel/arch/s390/src/lib/include/handle-elf.h @@ -5,8 +5,8 @@ #define ELF_S390 -#define __handle_elf handle_elf_s390 -#define arch_is_machine_supported(e_machine) (e_machine == EM_S390) +#define __handle_elf handle_elf_s390 +#define arch_is_machine_supported(e_machine) (e_machine == EM_S390) int handle_elf_s390(void *mem, size_t size); diff --git a/compel/arch/s390/src/lib/include/syscall.h b/compel/arch/s390/src/lib/include/syscall.h index 57d49121f..828f29e4b 100644 --- a/compel/arch/s390/src/lib/include/syscall.h +++ b/compel/arch/s390/src/lib/include/syscall.h @@ -1,8 +1,7 @@ #ifndef __COMPEL_SYSCALL_H__ #define __COMPEL_SYSCALL_H__ -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); #endif diff --git a/compel/arch/s390/src/lib/include/uapi/asm/cpu.h b/compel/arch/s390/src/lib/include/uapi/asm/cpu.h index b01db511d..c2652b2f4 100644 --- a/compel/arch/s390/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/s390/src/lib/include/uapi/asm/cpu.h @@ -4,7 +4,7 @@ #include typedef struct { - uint64_t hwcap[2]; + uint64_t hwcap[2]; } compel_cpuinfo_t; #endif /* __CR_ASM_CPU_H__ */ diff --git a/compel/arch/s390/src/lib/include/uapi/asm/infect-types.h b/compel/arch/s390/src/lib/include/uapi/asm/infect-types.h index 807be5a9a..896d70ed1 100644 --- a/compel/arch/s390/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/s390/src/lib/include/uapi/asm/infect-types.h @@ -7,8 +7,8 @@ #include #include "common/page.h" -#define SIGMAX 64 -#define SIGMAX_OLD 31 +#define SIGMAX 64 +#define SIGMAX_OLD 31 /* * Definitions from /usr/include/asm/ptrace.h: @@ -33,28 +33,28 @@ typedef struct { } vector128_t; struct prfpreg { - uint32_t fpc; - uint64_t fprs[16]; + uint32_t fpc; + uint64_t fprs[16]; }; -#define USER_FPREGS_VXRS 0x000000001 +#define USER_FPREGS_VXRS 0x000000001 /* Guarded-storage control block */ -#define USER_GS_CB 0x000000002 +#define USER_GS_CB 0x000000002 /* Guarded-storage broadcast control block */ -#define USER_GS_BC 0x000000004 +#define USER_GS_BC 0x000000004 /* Runtime-instrumentation control block */ -#define USER_RI_CB 0x000000008 +#define USER_RI_CB 0x000000008 /* Runtime-instrumentation bit set */ -#define USER_RI_ON 0x000000010 +#define USER_RI_ON 0x000000010 typedef struct { - uint32_t flags; - struct prfpreg prfpreg; - uint64_t vxrs_low[16]; - vector128_t vxrs_high[16]; - uint64_t gs_cb[4]; - uint64_t gs_bc[4]; - uint64_t ri_cb[8]; + uint32_t flags; + struct prfpreg prfpreg; + uint64_t vxrs_low[16]; + vector128_t vxrs_high[16]; + uint64_t gs_cb[4]; + uint64_t gs_bc[4]; + uint64_t ri_cb[8]; } user_fpregs_struct_t; typedef struct { @@ -62,18 +62,22 @@ typedef struct { uint32_t system_call; } user_regs_struct_t; -#define REG_RES(r) ((uint64_t)(r).prstatus.gprs[2]) -#define REG_IP(r) ((uint64_t)(r).prstatus.psw.addr) -#define REG_SP(r) ((uint64_t)(r).prstatus.gprs[15]) +#define REG_RES(r) ((uint64_t)(r).prstatus.gprs[2]) +#define REG_IP(r) ((uint64_t)(r).prstatus.psw.addr) +#define REG_SP(r) ((uint64_t)(r).prstatus.gprs[15]) /* * We assume that REG_SYSCALL_NR() is only used for pie code where we * always use svc 0 with opcode in %r1. */ -#define REG_SYSCALL_NR(r) ((uint64_t)(r).prstatus.gprs[1]) +#define REG_SYSCALL_NR(r) ((uint64_t)(r).prstatus.gprs[1]) -#define user_regs_native(pregs) true +#define user_regs_native(pregs) true -#define __NR(syscall, compat) ({ (void)compat; __NR_##syscall; }) +#define __NR(syscall, compat) \ + ({ \ + (void)compat; \ + __NR_##syscall; \ + }) struct mmap_arg_struct { unsigned long addr; @@ -85,7 +89,7 @@ struct mmap_arg_struct { }; #define __compel_arch_fetch_thread_area(tid, th) 0 -#define compel_arch_fetch_thread_area(tctl) 0 +#define compel_arch_fetch_thread_area(tctl) 0 #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) diff --git a/compel/arch/s390/src/lib/include/uapi/asm/sigframe.h b/compel/arch/s390/src/lib/include/uapi/asm/sigframe.h index c599ef3ab..965fef102 100644 --- a/compel/arch/s390/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/s390/src/lib/include/uapi/asm/sigframe.h @@ -36,14 +36,14 @@ typedef struct { * From /usr/include/uapi/asm/ucontext.h */ struct ucontext_extended { - unsigned long uc_flags; - ucontext_t *uc_link; - stack_t uc_stack; - _sigregs uc_mcontext; - sigset_t uc_sigmask; + unsigned long uc_flags; + ucontext_t *uc_link; + stack_t uc_stack; + _sigregs uc_mcontext; + sigset_t uc_sigmask; /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ - unsigned char __unused[128 - sizeof(sigset_t)]; - _sigregs_ext uc_mcontext_ext; + unsigned char __unused[128 - sizeof(sigset_t)]; + _sigregs_ext uc_mcontext_ext; }; /* @@ -59,6 +59,7 @@ struct rt_sigframe { /* * Do rt_sigreturn SVC */ +/* clang-format off */ #define ARCH_RT_SIGRETURN(new_sp, rt_sigframe) \ asm volatile( \ "lgr %%r15,%0\n" \ @@ -67,14 +68,13 @@ struct rt_sigframe { : \ : "d" (new_sp) \ : "memory") +/* clang-format on */ -#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc) -#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.regs.psw.addr -#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) +#define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->uc) +#define RT_SIGFRAME_REGIP(rt_sigframe) (rt_sigframe)->uc.uc_mcontext.regs.psw.addr +#define RT_SIGFRAME_HAS_FPU(rt_sigframe) (1) -#define rt_sigframe_erase_sigset(sigframe) \ - memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) -#define rt_sigframe_copy_sigset(sigframe, from) \ - memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) +#define rt_sigframe_erase_sigset(sigframe) memset(&sigframe->uc.uc_sigmask, 0, sizeof(k_rtsigset_t)) +#define rt_sigframe_copy_sigset(sigframe, from) memcpy(&sigframe->uc.uc_sigmask, from, sizeof(k_rtsigset_t)) #endif /* UAPI_COMPEL_ASM_SIGFRAME_H__ */ diff --git a/compel/arch/x86/plugins/include/asm/prologue.h b/compel/arch/x86/plugins/include/asm/prologue.h index 9d812eec9..c19ce54d7 100644 --- a/compel/arch/x86/plugins/include/asm/prologue.h +++ b/compel/arch/x86/plugins/include/asm/prologue.h @@ -9,17 +9,16 @@ #include -#define sys_recv(sockfd, ubuf, size, flags) \ - sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL) +#define sys_recv(sockfd, ubuf, size, flags) sys_recvfrom(sockfd, ubuf, size, flags, NULL, NULL) typedef struct prologue_init_args { - struct sockaddr_un ctl_sock_addr; - unsigned int ctl_sock_addr_len; + struct sockaddr_un ctl_sock_addr; + unsigned int ctl_sock_addr_len; - unsigned int arg_s; - void *arg_p; + unsigned int arg_s; + void *arg_p; - void *sigframe; + void *sigframe; } prologue_init_args_t; #endif /* __ASSEMBLY__ */ @@ -29,8 +28,8 @@ typedef struct prologue_init_args { * * FIXME It is rather should be taken from sigframe header. */ -#define PROLOGUE_SGFRAME_SIZE 4096 +#define PROLOGUE_SGFRAME_SIZE 4096 -#define PROLOGUE_INIT_ARGS_SIZE 1024 +#define PROLOGUE_INIT_ARGS_SIZE 1024 #endif /* __ASM_PROLOGUE_H__ */ diff --git a/compel/arch/x86/plugins/include/asm/syscall-types.h b/compel/arch/x86/plugins/include/asm/syscall-types.h index 9874fd0be..101d1eb6e 100644 --- a/compel/arch/x86/plugins/include/asm/syscall-types.h +++ b/compel/arch/x86/plugins/include/asm/syscall-types.h @@ -8,12 +8,12 @@ typedef rt_signalfn_t *rt_sighandler_t; typedef void rt_restorefn_t(void); typedef rt_restorefn_t *rt_sigrestore_t; -#define SA_RESTORER 0x04000000 +#define SA_RESTORER 0x04000000 -#define _KNSIG 64 -#define _NSIG_BPW 64 +#define _KNSIG 64 +#define _NSIG_BPW 64 -#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) +#define _KNSIG_WORDS (_KNSIG / _NSIG_BPW) /* * Note: as k_rtsigset_t is the same size for 32-bit and 64-bit, @@ -21,14 +21,14 @@ typedef rt_restorefn_t *rt_sigrestore_t; * purpose if we ever going to support native 32-bit compilation. */ typedef struct { - uint64_t sig[_KNSIG_WORDS]; + uint64_t sig[_KNSIG_WORDS]; } k_rtsigset_t; typedef struct { - rt_sighandler_t rt_sa_handler; - unsigned long rt_sa_flags; - rt_sigrestore_t rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + rt_sighandler_t rt_sa_handler; + unsigned long rt_sa_flags; + rt_sigrestore_t rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t; /* @@ -37,24 +37,24 @@ typedef struct { * with unaligned rt_sa_mask. */ typedef struct __attribute__((packed)) { - unsigned int rt_sa_handler; - unsigned int rt_sa_flags; - unsigned int rt_sa_restorer; - k_rtsigset_t rt_sa_mask; + unsigned int rt_sa_handler; + unsigned int rt_sa_flags; + unsigned int rt_sa_restorer; + k_rtsigset_t rt_sa_mask; } rt_sigaction_t_compat; /* Types for set_thread_area, get_thread_area syscalls */ typedef struct { - unsigned int entry_number; - unsigned int base_addr; - unsigned int limit; - unsigned int seg_32bit:1; - unsigned int contents:2; - unsigned int read_exec_only:1; - unsigned int limit_in_pages:1; - unsigned int seg_not_present:1; - unsigned int useable:1; - unsigned int lm:1; + unsigned int entry_number; + unsigned int base_addr; + unsigned int limit; + unsigned int seg_32bit : 1; + unsigned int contents : 2; + unsigned int read_exec_only : 1; + unsigned int limit_in_pages : 1; + unsigned int seg_not_present : 1; + unsigned int useable : 1; + unsigned int lm : 1; } user_desc_t; #endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */ diff --git a/compel/arch/x86/src/lib/include/cpu.h b/compel/arch/x86/src/lib/include/cpu.h index 60b7d24d4..de3b0a0ff 100644 --- a/compel/arch/x86/src/lib/include/cpu.h +++ b/compel/arch/x86/src/lib/include/cpu.h @@ -1,31 +1,21 @@ #ifndef __COMPEL_ASM_CPU_H__ #define __COMPEL_ASM_CPU_H__ -static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { /* ecx is often an input as well as an output. */ - asm volatile("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (*eax), "2" (*ecx) - : "memory"); + asm volatile("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(*eax), "2"(*ecx) : "memory"); } -static inline void cpuid(unsigned int op, - unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { *eax = op; *ecx = 0; native_cpuid(eax, ebx, ecx, edx); } -static inline void cpuid_count(unsigned int op, int count, - unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +static inline void cpuid_count(unsigned int op, int count, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, + unsigned int *edx) { *eax = op; *ecx = count; diff --git a/compel/arch/x86/src/lib/include/handle-elf.h b/compel/arch/x86/src/lib/include/handle-elf.h index e68fe3bcf..f3150f3f1 100644 --- a/compel/arch/x86/src/lib/include/handle-elf.h +++ b/compel/arch/x86/src/lib/include/handle-elf.h @@ -6,15 +6,15 @@ #define ELF_X86_64 #ifndef R_X86_64_GOTPCRELX -# define R_X86_64_GOTPCRELX 41 +#define R_X86_64_GOTPCRELX 41 #endif #ifndef R_X86_64_REX_GOTPCRELX -# define R_X86_64_REX_GOTPCRELX 42 +#define R_X86_64_REX_GOTPCRELX 42 #endif -#define __handle_elf handle_elf_x86_64 -#define arch_is_machine_supported(e_machine) (e_machine == EM_X86_64) +#define __handle_elf handle_elf_x86_64 +#define arch_is_machine_supported(e_machine) (e_machine == EM_X86_64) extern int handle_elf_x86_32(void *mem, size_t size); extern int handle_elf_x86_64(void *mem, size_t size); diff --git a/compel/arch/x86/src/lib/include/syscall.h b/compel/arch/x86/src/lib/include/syscall.h index 9af1b1f99..a1b742b11 100644 --- a/compel/arch/x86/src/lib/include/syscall.h +++ b/compel/arch/x86/src/lib/include/syscall.h @@ -1,6 +1,6 @@ #ifndef __COMPEL_SYSCALL_H__ #define __COMPEL_SYSCALL_H__ -#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) +#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) /* * For x86_32 __NR_mmap inside the kernel represents old_mmap system diff --git a/compel/arch/x86/src/lib/include/uapi/asm/cpu.h b/compel/arch/x86/src/lib/include/uapi/asm/cpu.h index bb1914da4..8d54516af 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/cpu.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/cpu.h @@ -15,334 +15,334 @@ * to keep it here, since it's an ABI now. */ enum cpuid_leafs { - CPUID_1_EDX = 0, - CPUID_8000_0001_EDX = 1, - CPUID_8086_0001_EDX = 2, - CPUID_LNX_1 = 3, - CPUID_1_ECX = 4, - CPUID_C000_0001_EDX = 5, - CPUID_8000_0001_ECX = 6, - CPUID_LNX_2 = 7, - CPUID_LNX_3 = 8, - CPUID_7_0_EBX = 9, - CPUID_D_1_EAX = 10, - CPUID_7_0_ECX = 11, - CPUID_F_1_EDX = 12, - CPUID_8000_0008_EBX = 13, - CPUID_6_EAX = 14, - CPUID_8000_000A_EDX = 15, - CPUID_F_0_EDX = 16, - CPUID_8000_0007_EBX = 17, - CPUID_7_0_EDX = 18, + CPUID_1_EDX = 0, + CPUID_8000_0001_EDX = 1, + CPUID_8086_0001_EDX = 2, + CPUID_LNX_1 = 3, + CPUID_1_ECX = 4, + CPUID_C000_0001_EDX = 5, + CPUID_8000_0001_ECX = 6, + CPUID_LNX_2 = 7, + CPUID_LNX_3 = 8, + CPUID_7_0_EBX = 9, + CPUID_D_1_EAX = 10, + CPUID_7_0_ECX = 11, + CPUID_F_1_EDX = 12, + CPUID_8000_0008_EBX = 13, + CPUID_6_EAX = 14, + CPUID_8000_000A_EDX = 15, + CPUID_F_0_EDX = 16, + CPUID_8000_0007_EBX = 17, + CPUID_7_0_EDX = 18, }; -#define NCAPINTS_V1 12 -#define NCAPINTS_V2 19 +#define NCAPINTS_V1 12 +#define NCAPINTS_V2 19 -#define NCAPINTS (NCAPINTS_V2) /* N 32-bit words worth of info */ -#define NCAPINTS_BITS (NCAPINTS * 32) +#define NCAPINTS (NCAPINTS_V2) /* N 32-bit words worth of info */ +#define NCAPINTS_BITS (NCAPINTS * 32) /* Intel-defined CPU features, CPUID level 0x00000001 (EDX), word 0 */ -#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */ -#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */ -#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */ -#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */ -#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */ -#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers */ -#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */ -#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Exception */ -#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */ -#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */ -#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */ -#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */ -#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */ -#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */ -#define X86_FEATURE_CMOV (0*32+15) /* CMOV instructions (plus FCMOVcc, FCOMI with FPU) */ -#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */ -#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */ -#define X86_FEATURE_PN (0*32+18) /* Processor serial number */ -#define X86_FEATURE_CLFLUSH (0*32+19) /* CLFLUSH instruction */ -#define X86_FEATURE_DS (0*32+21) /* "dts" Debug Store */ -#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */ -#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ -#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE/FXRSTOR, CR4.OSFXSR */ -#define X86_FEATURE_XMM (0*32+25) /* "sse" */ -#define X86_FEATURE_XMM2 (0*32+26) /* "sse2" */ -#define X86_FEATURE_SELFSNOOP (0*32+27) /* "ss" CPU self snoop */ -#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */ -#define X86_FEATURE_ACC (0*32+29) /* "tm" Automatic clock control */ -#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */ -#define X86_FEATURE_PBE (0*32+31) /* Pending Break Enable */ +#define X86_FEATURE_FPU (0 * 32 + 0) /* Onboard FPU */ +#define X86_FEATURE_VME (0 * 32 + 1) /* Virtual Mode Extensions */ +#define X86_FEATURE_DE (0 * 32 + 2) /* Debugging Extensions */ +#define X86_FEATURE_PSE (0 * 32 + 3) /* Page Size Extensions */ +#define X86_FEATURE_TSC (0 * 32 + 4) /* Time Stamp Counter */ +#define X86_FEATURE_MSR (0 * 32 + 5) /* Model-Specific Registers */ +#define X86_FEATURE_PAE (0 * 32 + 6) /* Physical Address Extensions */ +#define X86_FEATURE_MCE (0 * 32 + 7) /* Machine Check Exception */ +#define X86_FEATURE_CX8 (0 * 32 + 8) /* CMPXCHG8 instruction */ +#define X86_FEATURE_APIC (0 * 32 + 9) /* Onboard APIC */ +#define X86_FEATURE_SEP (0 * 32 + 11) /* SYSENTER/SYSEXIT */ +#define X86_FEATURE_MTRR (0 * 32 + 12) /* Memory Type Range Registers */ +#define X86_FEATURE_PGE (0 * 32 + 13) /* Page Global Enable */ +#define X86_FEATURE_MCA (0 * 32 + 14) /* Machine Check Architecture */ +#define X86_FEATURE_CMOV (0 * 32 + 15) /* CMOV instructions (plus FCMOVcc, FCOMI with FPU) */ +#define X86_FEATURE_PAT (0 * 32 + 16) /* Page Attribute Table */ +#define X86_FEATURE_PSE36 (0 * 32 + 17) /* 36-bit PSEs */ +#define X86_FEATURE_PN (0 * 32 + 18) /* Processor serial number */ +#define X86_FEATURE_CLFLUSH (0 * 32 + 19) /* CLFLUSH instruction */ +#define X86_FEATURE_DS (0 * 32 + 21) /* "dts" Debug Store */ +#define X86_FEATURE_ACPI (0 * 32 + 22) /* ACPI via MSR */ +#define X86_FEATURE_MMX (0 * 32 + 23) /* Multimedia Extensions */ +#define X86_FEATURE_FXSR (0 * 32 + 24) /* FXSAVE/FXRSTOR, CR4.OSFXSR */ +#define X86_FEATURE_XMM (0 * 32 + 25) /* "sse" */ +#define X86_FEATURE_XMM2 (0 * 32 + 26) /* "sse2" */ +#define X86_FEATURE_SELFSNOOP (0 * 32 + 27) /* "ss" CPU self snoop */ +#define X86_FEATURE_HT (0 * 32 + 28) /* Hyper-Threading */ +#define X86_FEATURE_ACC (0 * 32 + 29) /* "tm" Automatic clock control */ +#define X86_FEATURE_IA64 (0 * 32 + 30) /* IA-64 processor */ +#define X86_FEATURE_PBE (0 * 32 + 31) /* Pending Break Enable */ /* AMD-defined CPU features, CPUID level 0x80000001, word 1 */ /* Don't duplicate feature flags which are redundant with Intel! */ -#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */ -#define X86_FEATURE_MP (1*32+19) /* MP Capable */ -#define X86_FEATURE_NX (1*32+20) /* Execute Disable */ -#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ -#define X86_FEATURE_FXSR_OPT (1*32+25) /* FXSAVE/FXRSTOR optimizations */ -#define X86_FEATURE_GBPAGES (1*32+26) /* "pdpe1gb" GB pages */ -#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */ -#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64, 64-bit support) */ -#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow extensions */ -#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow */ +#define X86_FEATURE_SYSCALL (1 * 32 + 11) /* SYSCALL/SYSRET */ +#define X86_FEATURE_MP (1 * 32 + 19) /* MP Capable */ +#define X86_FEATURE_NX (1 * 32 + 20) /* Execute Disable */ +#define X86_FEATURE_MMXEXT (1 * 32 + 22) /* AMD MMX extensions */ +#define X86_FEATURE_FXSR_OPT (1 * 32 + 25) /* FXSAVE/FXRSTOR optimizations */ +#define X86_FEATURE_GBPAGES (1 * 32 + 26) /* "pdpe1gb" GB pages */ +#define X86_FEATURE_RDTSCP (1 * 32 + 27) /* RDTSCP */ +#define X86_FEATURE_LM (1 * 32 + 29) /* Long Mode (x86-64, 64-bit support) */ +#define X86_FEATURE_3DNOWEXT (1 * 32 + 30) /* AMD 3DNow extensions */ +#define X86_FEATURE_3DNOW (1 * 32 + 31) /* 3DNow */ /* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */ -#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */ -#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */ -#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */ +#define X86_FEATURE_RECOVERY (2 * 32 + 0) /* CPU in recovery mode */ +#define X86_FEATURE_LONGRUN (2 * 32 + 1) /* Longrun power control */ +#define X86_FEATURE_LRTI (2 * 32 + 3) /* LongRun table interface */ /* Other features, Linux-defined mapping, word 3 */ /* This range is used for feature bits which conflict or are synthesized */ -#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */ -#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */ -#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */ -#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */ +#define X86_FEATURE_CXMMX (3 * 32 + 0) /* Cyrix MMX extensions */ +#define X86_FEATURE_K6_MTRR (3 * 32 + 1) /* AMD K6 nonstandard MTRRs */ +#define X86_FEATURE_CYRIX_ARR (3 * 32 + 2) /* Cyrix ARRs (= MTRRs) */ +#define X86_FEATURE_CENTAUR_MCR (3 * 32 + 3) /* Centaur MCRs (= MTRRs) */ /* CPU types for specific tunings: */ -#define X86_FEATURE_K8 (3*32+ 4) /* "" Opteron, Athlon64 */ -#define X86_FEATURE_K7 (3*32+ 5) /* "" Athlon */ -#define X86_FEATURE_P3 (3*32+ 6) /* "" P3 */ -#define X86_FEATURE_P4 (3*32+ 7) /* "" P4 */ -#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */ -#define X86_FEATURE_UP (3*32+ 9) /* SMP kernel running on UP */ -#define X86_FEATURE_ART (3*32+10) /* Always running timer (ART) */ -#define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */ -#define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */ -#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */ -#define X86_FEATURE_SYSCALL32 (3*32+14) /* "" syscall in IA32 userspace */ -#define X86_FEATURE_SYSENTER32 (3*32+15) /* "" sysenter in IA32 userspace */ -#define X86_FEATURE_REP_GOOD (3*32+16) /* REP microcode works well */ -#define X86_FEATURE_MFENCE_RDTSC (3*32+17) /* "" MFENCE synchronizes RDTSC */ -#define X86_FEATURE_LFENCE_RDTSC (3*32+18) /* "" LFENCE synchronizes RDTSC */ -#define X86_FEATURE_ACC_POWER (3*32+19) /* AMD Accumulated Power Mechanism */ -#define X86_FEATURE_NOPL (3*32+20) /* The NOPL (0F 1F) instructions */ -#define X86_FEATURE_ALWAYS (3*32+21) /* "" Always-present feature */ -#define X86_FEATURE_XTOPOLOGY (3*32+22) /* CPU topology enum extensions */ -#define X86_FEATURE_TSC_RELIABLE (3*32+23) /* TSC is known to be reliable */ -#define X86_FEATURE_NONSTOP_TSC (3*32+24) /* TSC does not stop in C states */ -#define X86_FEATURE_CPUID (3*32+25) /* CPU has CPUID instruction itself */ -#define X86_FEATURE_EXTD_APICID (3*32+26) /* Extended APICID (8 bits) */ -#define X86_FEATURE_AMD_DCM (3*32+27) /* AMD multi-node processor */ -#define X86_FEATURE_APERFMPERF (3*32+28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */ -#define X86_FEATURE_NONSTOP_TSC_S3 (3*32+30) /* TSC doesn't stop in S3 state */ -#define X86_FEATURE_TSC_KNOWN_FREQ (3*32+31) /* TSC has known frequency */ +#define X86_FEATURE_K8 (3 * 32 + 4) /* "" Opteron, Athlon64 */ +#define X86_FEATURE_K7 (3 * 32 + 5) /* "" Athlon */ +#define X86_FEATURE_P3 (3 * 32 + 6) /* "" P3 */ +#define X86_FEATURE_P4 (3 * 32 + 7) /* "" P4 */ +#define X86_FEATURE_CONSTANT_TSC (3 * 32 + 8) /* TSC ticks at a constant rate */ +#define X86_FEATURE_UP (3 * 32 + 9) /* SMP kernel running on UP */ +#define X86_FEATURE_ART (3 * 32 + 10) /* Always running timer (ART) */ +#define X86_FEATURE_ARCH_PERFMON (3 * 32 + 11) /* Intel Architectural PerfMon */ +#define X86_FEATURE_PEBS (3 * 32 + 12) /* Precise-Event Based Sampling */ +#define X86_FEATURE_BTS (3 * 32 + 13) /* Branch Trace Store */ +#define X86_FEATURE_SYSCALL32 (3 * 32 + 14) /* "" syscall in IA32 userspace */ +#define X86_FEATURE_SYSENTER32 (3 * 32 + 15) /* "" sysenter in IA32 userspace */ +#define X86_FEATURE_REP_GOOD (3 * 32 + 16) /* REP microcode works well */ +#define X86_FEATURE_MFENCE_RDTSC (3 * 32 + 17) /* "" MFENCE synchronizes RDTSC */ +#define X86_FEATURE_LFENCE_RDTSC (3 * 32 + 18) /* "" LFENCE synchronizes RDTSC */ +#define X86_FEATURE_ACC_POWER (3 * 32 + 19) /* AMD Accumulated Power Mechanism */ +#define X86_FEATURE_NOPL (3 * 32 + 20) /* The NOPL (0F 1F) instructions */ +#define X86_FEATURE_ALWAYS (3 * 32 + 21) /* "" Always-present feature */ +#define X86_FEATURE_XTOPOLOGY (3 * 32 + 22) /* CPU topology enum extensions */ +#define X86_FEATURE_TSC_RELIABLE (3 * 32 + 23) /* TSC is known to be reliable */ +#define X86_FEATURE_NONSTOP_TSC (3 * 32 + 24) /* TSC does not stop in C states */ +#define X86_FEATURE_CPUID (3 * 32 + 25) /* CPU has CPUID instruction itself */ +#define X86_FEATURE_EXTD_APICID (3 * 32 + 26) /* Extended APICID (8 bits) */ +#define X86_FEATURE_AMD_DCM (3 * 32 + 27) /* AMD multi-node processor */ +#define X86_FEATURE_APERFMPERF (3 * 32 + 28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */ +#define X86_FEATURE_NONSTOP_TSC_S3 (3 * 32 + 30) /* TSC doesn't stop in S3 state */ +#define X86_FEATURE_TSC_KNOWN_FREQ (3 * 32 + 31) /* TSC has known frequency */ /* Intel-defined CPU features, CPUID level 0x00000001 (ECX), word 4 */ -#define X86_FEATURE_XMM3 (4*32+ 0) /* "pni" SSE-3 */ -#define X86_FEATURE_PCLMULQDQ (4*32+ 1) /* PCLMULQDQ instruction */ -#define X86_FEATURE_DTES64 (4*32+ 2) /* 64-bit Debug Store */ -#define X86_FEATURE_MWAIT (4*32+ 3) /* "monitor" MONITOR/MWAIT support */ -#define X86_FEATURE_DSCPL (4*32+ 4) /* "ds_cpl" CPL-qualified (filtered) Debug Store */ -#define X86_FEATURE_VMX (4*32+ 5) /* Hardware virtualization */ -#define X86_FEATURE_SMX (4*32+ 6) /* Safer Mode eXtensions */ -#define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */ -#define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */ -#define X86_FEATURE_SSSE3 (4*32+ 9) /* Supplemental SSE-3 */ -#define X86_FEATURE_CID (4*32+10) /* Context ID */ -#define X86_FEATURE_SDBG (4*32+11) /* Silicon Debug */ -#define X86_FEATURE_FMA (4*32+12) /* Fused multiply-add */ -#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B instruction */ -#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */ -#define X86_FEATURE_PDCM (4*32+15) /* Perf/Debug Capabilities MSR */ -#define X86_FEATURE_PCID (4*32+17) /* Process Context Identifiers */ -#define X86_FEATURE_DCA (4*32+18) /* Direct Cache Access */ -#define X86_FEATURE_XMM4_1 (4*32+19) /* "sse4_1" SSE-4.1 */ -#define X86_FEATURE_XMM4_2 (4*32+20) /* "sse4_2" SSE-4.2 */ -#define X86_FEATURE_X2APIC (4*32+21) /* X2APIC */ -#define X86_FEATURE_MOVBE (4*32+22) /* MOVBE instruction */ -#define X86_FEATURE_POPCNT (4*32+23) /* POPCNT instruction */ -#define X86_FEATURE_TSC_DEADLINE_TIMER (4*32+24) /* TSC deadline timer */ -#define X86_FEATURE_AES (4*32+25) /* AES instructions */ -#define X86_FEATURE_XSAVE (4*32+26) /* XSAVE/XRSTOR/XSETBV/XGETBV instructions */ -#define X86_FEATURE_OSXSAVE (4*32+27) /* "" XSAVE instruction enabled in the OS */ -#define X86_FEATURE_AVX (4*32+28) /* Advanced Vector Extensions */ -#define X86_FEATURE_F16C (4*32+29) /* 16-bit FP conversions */ -#define X86_FEATURE_RDRAND (4*32+30) /* RDRAND instruction */ -#define X86_FEATURE_HYPERVISOR (4*32+31) /* Running on a hypervisor */ +#define X86_FEATURE_XMM3 (4 * 32 + 0) /* "pni" SSE-3 */ +#define X86_FEATURE_PCLMULQDQ (4 * 32 + 1) /* PCLMULQDQ instruction */ +#define X86_FEATURE_DTES64 (4 * 32 + 2) /* 64-bit Debug Store */ +#define X86_FEATURE_MWAIT (4 * 32 + 3) /* "monitor" MONITOR/MWAIT support */ +#define X86_FEATURE_DSCPL (4 * 32 + 4) /* "ds_cpl" CPL-qualified (filtered) Debug Store */ +#define X86_FEATURE_VMX (4 * 32 + 5) /* Hardware virtualization */ +#define X86_FEATURE_SMX (4 * 32 + 6) /* Safer Mode eXtensions */ +#define X86_FEATURE_EST (4 * 32 + 7) /* Enhanced SpeedStep */ +#define X86_FEATURE_TM2 (4 * 32 + 8) /* Thermal Monitor 2 */ +#define X86_FEATURE_SSSE3 (4 * 32 + 9) /* Supplemental SSE-3 */ +#define X86_FEATURE_CID (4 * 32 + 10) /* Context ID */ +#define X86_FEATURE_SDBG (4 * 32 + 11) /* Silicon Debug */ +#define X86_FEATURE_FMA (4 * 32 + 12) /* Fused multiply-add */ +#define X86_FEATURE_CX16 (4 * 32 + 13) /* CMPXCHG16B instruction */ +#define X86_FEATURE_XTPR (4 * 32 + 14) /* Send Task Priority Messages */ +#define X86_FEATURE_PDCM (4 * 32 + 15) /* Perf/Debug Capabilities MSR */ +#define X86_FEATURE_PCID (4 * 32 + 17) /* Process Context Identifiers */ +#define X86_FEATURE_DCA (4 * 32 + 18) /* Direct Cache Access */ +#define X86_FEATURE_XMM4_1 (4 * 32 + 19) /* "sse4_1" SSE-4.1 */ +#define X86_FEATURE_XMM4_2 (4 * 32 + 20) /* "sse4_2" SSE-4.2 */ +#define X86_FEATURE_X2APIC (4 * 32 + 21) /* X2APIC */ +#define X86_FEATURE_MOVBE (4 * 32 + 22) /* MOVBE instruction */ +#define X86_FEATURE_POPCNT (4 * 32 + 23) /* POPCNT instruction */ +#define X86_FEATURE_TSC_DEADLINE_TIMER (4 * 32 + 24) /* TSC deadline timer */ +#define X86_FEATURE_AES (4 * 32 + 25) /* AES instructions */ +#define X86_FEATURE_XSAVE (4 * 32 + 26) /* XSAVE/XRSTOR/XSETBV/XGETBV instructions */ +#define X86_FEATURE_OSXSAVE (4 * 32 + 27) /* "" XSAVE instruction enabled in the OS */ +#define X86_FEATURE_AVX (4 * 32 + 28) /* Advanced Vector Extensions */ +#define X86_FEATURE_F16C (4 * 32 + 29) /* 16-bit FP conversions */ +#define X86_FEATURE_RDRAND (4 * 32 + 30) /* RDRAND instruction */ +#define X86_FEATURE_HYPERVISOR (4 * 32 + 31) /* Running on a hypervisor */ /* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */ -#define X86_FEATURE_XSTORE (5*32+ 2) /* "rng" RNG present (xstore) */ -#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* "rng_en" RNG enabled */ -#define X86_FEATURE_XCRYPT (5*32+ 6) /* "ace" on-CPU crypto (xcrypt) */ -#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* "ace_en" on-CPU crypto enabled */ -#define X86_FEATURE_ACE2 (5*32+ 8) /* Advanced Cryptography Engine v2 */ -#define X86_FEATURE_ACE2_EN (5*32+ 9) /* ACE v2 enabled */ -#define X86_FEATURE_PHE (5*32+10) /* PadLock Hash Engine */ -#define X86_FEATURE_PHE_EN (5*32+11) /* PHE enabled */ -#define X86_FEATURE_PMM (5*32+12) /* PadLock Montgomery Multiplier */ -#define X86_FEATURE_PMM_EN (5*32+13) /* PMM enabled */ +#define X86_FEATURE_XSTORE (5 * 32 + 2) /* "rng" RNG present (xstore) */ +#define X86_FEATURE_XSTORE_EN (5 * 32 + 3) /* "rng_en" RNG enabled */ +#define X86_FEATURE_XCRYPT (5 * 32 + 6) /* "ace" on-CPU crypto (xcrypt) */ +#define X86_FEATURE_XCRYPT_EN (5 * 32 + 7) /* "ace_en" on-CPU crypto enabled */ +#define X86_FEATURE_ACE2 (5 * 32 + 8) /* Advanced Cryptography Engine v2 */ +#define X86_FEATURE_ACE2_EN (5 * 32 + 9) /* ACE v2 enabled */ +#define X86_FEATURE_PHE (5 * 32 + 10) /* PadLock Hash Engine */ +#define X86_FEATURE_PHE_EN (5 * 32 + 11) /* PHE enabled */ +#define X86_FEATURE_PMM (5 * 32 + 12) /* PadLock Montgomery Multiplier */ +#define X86_FEATURE_PMM_EN (5 * 32 + 13) /* PMM enabled */ /* More extended AMD flags: CPUID level 0x80000001, ECX, word 6 */ -#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */ -#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */ -#define X86_FEATURE_SVM (6*32+ 2) /* Secure Virtual Machine */ -#define X86_FEATURE_EXTAPIC (6*32+ 3) /* Extended APIC space */ -#define X86_FEATURE_CR8_LEGACY (6*32+ 4) /* CR8 in 32-bit mode */ -#define X86_FEATURE_ABM (6*32+ 5) /* Advanced bit manipulation */ -#define X86_FEATURE_SSE4A (6*32+ 6) /* SSE-4A */ -#define X86_FEATURE_MISALIGNSSE (6*32+ 7) /* Misaligned SSE mode */ -#define X86_FEATURE_3DNOWPREFETCH (6*32+ 8) /* 3DNow prefetch instructions */ -#define X86_FEATURE_OSVW (6*32+ 9) /* OS Visible Workaround */ -#define X86_FEATURE_IBS (6*32+10) /* Instruction Based Sampling */ -#define X86_FEATURE_XOP (6*32+11) /* extended AVX instructions */ -#define X86_FEATURE_SKINIT (6*32+12) /* SKINIT/STGI instructions */ -#define X86_FEATURE_WDT (6*32+13) /* Watchdog timer */ -#define X86_FEATURE_LWP (6*32+15) /* Light Weight Profiling */ -#define X86_FEATURE_FMA4 (6*32+16) /* 4 operands MAC instructions */ -#define X86_FEATURE_TCE (6*32+17) /* Translation Cache Extension */ -#define X86_FEATURE_NODEID_MSR (6*32+19) /* NodeId MSR */ -#define X86_FEATURE_TBM (6*32+21) /* Trailing Bit Manipulations */ -#define X86_FEATURE_TOPOEXT (6*32+22) /* Topology extensions CPUID leafs */ -#define X86_FEATURE_PERFCTR_CORE (6*32+23) /* Core performance counter extensions */ -#define X86_FEATURE_PERFCTR_NB (6*32+24) /* NB performance counter extensions */ -#define X86_FEATURE_BPEXT (6*32+26) /* Data breakpoint extension */ -#define X86_FEATURE_PTSC (6*32+27) /* Performance time-stamp counter */ -#define X86_FEATURE_PERFCTR_LLC (6*32+28) /* Last Level Cache performance counter extensions */ -#define X86_FEATURE_MWAITX (6*32+29) /* MWAIT extension (MONITORX/MWAITX instructions) */ +#define X86_FEATURE_LAHF_LM (6 * 32 + 0) /* LAHF/SAHF in long mode */ +#define X86_FEATURE_CMP_LEGACY (6 * 32 + 1) /* If yes HyperThreading not valid */ +#define X86_FEATURE_SVM (6 * 32 + 2) /* Secure Virtual Machine */ +#define X86_FEATURE_EXTAPIC (6 * 32 + 3) /* Extended APIC space */ +#define X86_FEATURE_CR8_LEGACY (6 * 32 + 4) /* CR8 in 32-bit mode */ +#define X86_FEATURE_ABM (6 * 32 + 5) /* Advanced bit manipulation */ +#define X86_FEATURE_SSE4A (6 * 32 + 6) /* SSE-4A */ +#define X86_FEATURE_MISALIGNSSE (6 * 32 + 7) /* Misaligned SSE mode */ +#define X86_FEATURE_3DNOWPREFETCH (6 * 32 + 8) /* 3DNow prefetch instructions */ +#define X86_FEATURE_OSVW (6 * 32 + 9) /* OS Visible Workaround */ +#define X86_FEATURE_IBS (6 * 32 + 10) /* Instruction Based Sampling */ +#define X86_FEATURE_XOP (6 * 32 + 11) /* extended AVX instructions */ +#define X86_FEATURE_SKINIT (6 * 32 + 12) /* SKINIT/STGI instructions */ +#define X86_FEATURE_WDT (6 * 32 + 13) /* Watchdog timer */ +#define X86_FEATURE_LWP (6 * 32 + 15) /* Light Weight Profiling */ +#define X86_FEATURE_FMA4 (6 * 32 + 16) /* 4 operands MAC instructions */ +#define X86_FEATURE_TCE (6 * 32 + 17) /* Translation Cache Extension */ +#define X86_FEATURE_NODEID_MSR (6 * 32 + 19) /* NodeId MSR */ +#define X86_FEATURE_TBM (6 * 32 + 21) /* Trailing Bit Manipulations */ +#define X86_FEATURE_TOPOEXT (6 * 32 + 22) /* Topology extensions CPUID leafs */ +#define X86_FEATURE_PERFCTR_CORE (6 * 32 + 23) /* Core performance counter extensions */ +#define X86_FEATURE_PERFCTR_NB (6 * 32 + 24) /* NB performance counter extensions */ +#define X86_FEATURE_BPEXT (6 * 32 + 26) /* Data breakpoint extension */ +#define X86_FEATURE_PTSC (6 * 32 + 27) /* Performance time-stamp counter */ +#define X86_FEATURE_PERFCTR_LLC (6 * 32 + 28) /* Last Level Cache performance counter extensions */ +#define X86_FEATURE_MWAITX (6 * 32 + 29) /* MWAIT extension (MONITORX/MWAITX instructions) */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ -#define X86_FEATURE_FSGSBASE (9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/ -#define X86_FEATURE_TSC_ADJUST (9*32+ 1) /* TSC adjustment MSR 0x3B */ -#define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */ -#define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */ -#define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */ -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */ -#define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */ -#define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB instructions */ -#define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */ -#define X86_FEATURE_RTM (9*32+11) /* Restricted Transactional Memory */ -#define X86_FEATURE_CQM (9*32+12) /* Cache QoS Monitoring */ -#define X86_FEATURE_MPX (9*32+14) /* Memory Protection Extension */ -#define X86_FEATURE_RDT_A (9*32+15) /* Resource Director Technology Allocation */ -#define X86_FEATURE_AVX512F (9*32+16) /* AVX-512 Foundation */ -#define X86_FEATURE_AVX512DQ (9*32+17) /* AVX-512 DQ (Double/Quad granular) Instructions */ -#define X86_FEATURE_RDSEED (9*32+18) /* RDSEED instruction */ -#define X86_FEATURE_ADX (9*32+19) /* ADCX and ADOX instructions */ -#define X86_FEATURE_SMAP (9*32+20) /* Supervisor Mode Access Prevention */ -#define X86_FEATURE_AVX512IFMA (9*32+21) /* AVX-512 Integer Fused Multiply-Add instructions */ -#define X86_FEATURE_CLFLUSHOPT (9*32+23) /* CLFLUSHOPT instruction */ -#define X86_FEATURE_CLWB (9*32+24) /* CLWB instruction */ -#define X86_FEATURE_INTEL_PT (9*32+25) /* Intel Processor Trace */ -#define X86_FEATURE_AVX512PF (9*32+26) /* AVX-512 Prefetch */ -#define X86_FEATURE_AVX512ER (9*32+27) /* AVX-512 Exponential and Reciprocal */ -#define X86_FEATURE_AVX512CD (9*32+28) /* AVX-512 Conflict Detection */ -#define X86_FEATURE_SHA_NI (9*32+29) /* SHA1/SHA256 Instruction Extensions */ -#define X86_FEATURE_AVX512BW (9*32+30) /* AVX-512 BW (Byte/Word granular) Instructions */ -#define X86_FEATURE_AVX512VL (9*32+31) /* AVX-512 VL (128/256 Vector Length) Extensions */ +#define X86_FEATURE_FSGSBASE (9 * 32 + 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/ +#define X86_FEATURE_TSC_ADJUST (9 * 32 + 1) /* TSC adjustment MSR 0x3B */ +#define X86_FEATURE_BMI1 (9 * 32 + 3) /* 1st group bit manipulation extensions */ +#define X86_FEATURE_HLE (9 * 32 + 4) /* Hardware Lock Elision */ +#define X86_FEATURE_AVX2 (9 * 32 + 5) /* AVX2 instructions */ +#define X86_FEATURE_SMEP (9 * 32 + 7) /* Supervisor Mode Execution Protection */ +#define X86_FEATURE_BMI2 (9 * 32 + 8) /* 2nd group bit manipulation extensions */ +#define X86_FEATURE_ERMS (9 * 32 + 9) /* Enhanced REP MOVSB/STOSB instructions */ +#define X86_FEATURE_INVPCID (9 * 32 + 10) /* Invalidate Processor Context ID */ +#define X86_FEATURE_RTM (9 * 32 + 11) /* Restricted Transactional Memory */ +#define X86_FEATURE_CQM (9 * 32 + 12) /* Cache QoS Monitoring */ +#define X86_FEATURE_MPX (9 * 32 + 14) /* Memory Protection Extension */ +#define X86_FEATURE_RDT_A (9 * 32 + 15) /* Resource Director Technology Allocation */ +#define X86_FEATURE_AVX512F (9 * 32 + 16) /* AVX-512 Foundation */ +#define X86_FEATURE_AVX512DQ (9 * 32 + 17) /* AVX-512 DQ (Double/Quad granular) Instructions */ +#define X86_FEATURE_RDSEED (9 * 32 + 18) /* RDSEED instruction */ +#define X86_FEATURE_ADX (9 * 32 + 19) /* ADCX and ADOX instructions */ +#define X86_FEATURE_SMAP (9 * 32 + 20) /* Supervisor Mode Access Prevention */ +#define X86_FEATURE_AVX512IFMA (9 * 32 + 21) /* AVX-512 Integer Fused Multiply-Add instructions */ +#define X86_FEATURE_CLFLUSHOPT (9 * 32 + 23) /* CLFLUSHOPT instruction */ +#define X86_FEATURE_CLWB (9 * 32 + 24) /* CLWB instruction */ +#define X86_FEATURE_INTEL_PT (9 * 32 + 25) /* Intel Processor Trace */ +#define X86_FEATURE_AVX512PF (9 * 32 + 26) /* AVX-512 Prefetch */ +#define X86_FEATURE_AVX512ER (9 * 32 + 27) /* AVX-512 Exponential and Reciprocal */ +#define X86_FEATURE_AVX512CD (9 * 32 + 28) /* AVX-512 Conflict Detection */ +#define X86_FEATURE_SHA_NI (9 * 32 + 29) /* SHA1/SHA256 Instruction Extensions */ +#define X86_FEATURE_AVX512BW (9 * 32 + 30) /* AVX-512 BW (Byte/Word granular) Instructions */ +#define X86_FEATURE_AVX512VL (9 * 32 + 31) /* AVX-512 VL (128/256 Vector Length) Extensions */ /* Extended state features, CPUID level 0x0000000d:1 (EAX), word 10 */ -#define X86_FEATURE_XSAVEOPT (10*32+ 0) /* XSAVEOPT instruction */ -#define X86_FEATURE_XSAVEC (10*32+ 1) /* XSAVEC instruction */ -#define X86_FEATURE_XGETBV1 (10*32+ 2) /* XGETBV with ECX = 1 instruction */ -#define X86_FEATURE_XSAVES (10*32+ 3) /* XSAVES/XRSTORS instructions */ +#define X86_FEATURE_XSAVEOPT (10 * 32 + 0) /* XSAVEOPT instruction */ +#define X86_FEATURE_XSAVEC (10 * 32 + 1) /* XSAVEC instruction */ +#define X86_FEATURE_XGETBV1 (10 * 32 + 2) /* XGETBV with ECX = 1 instruction */ +#define X86_FEATURE_XSAVES (10 * 32 + 3) /* XSAVES/XRSTORS instructions */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (ECX), word 11 */ -#define X86_FEATURE_PREFETCHWT1 (11*32+ 0) /* PREFETCHWT1 Intel® Xeon PhiTM only */ -#define X86_FEATURE_AVX512VBMI (11*32+ 1) /* AVX512 Vector Bit Manipulation instructions*/ -#define X86_FEATURE_UMIP (11*32+ 2) /* User Mode Instruction Protection */ -#define X86_FEATURE_PKU (11*32+ 3) /* Protection Keys for Userspace */ -#define X86_FEATURE_OSPKE (11*32+ 4) /* OS Protection Keys Enable */ -#define X86_FEATURE_AVX512_VBMI2 (11*32+ 6) /* Additional AVX512 Vector Bit Manipulation Instructions */ -#define X86_FEATURE_GFNI (11*32+ 8) /* Galois Field New Instructions */ -#define X86_FEATURE_VAES (11*32+ 9) /* Vector AES */ -#define X86_FEATURE_VPCLMULQDQ (11*32+10) /* Carry-Less Multiplication Double Quadword */ -#define X86_FEATURE_AVX512_VNNI (11*32+11) /* Vector Neural Network Instructions */ -#define X86_FEATURE_AVX512_BITALG (11*32+12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */ -#define X86_FEATURE_TME (11*32+13) /* Intel Total Memory Encryption */ -#define X86_FEATURE_AVX512_VPOPCNTDQ (11*32+14) /* POPCNT for vectors of DW/QW */ -#define X86_FEATURE_LA57 (11*32+16) /* 5-level page tables */ -#define X86_FEATURE_RDPID (11*32+22) /* RDPID instruction */ -#define X86_FEATURE_CLDEMOTE (11*32+25) /* CLDEMOTE instruction */ +#define X86_FEATURE_PREFETCHWT1 (11 * 32 + 0) /* PREFETCHWT1 Intel® Xeon PhiTM only */ +#define X86_FEATURE_AVX512VBMI (11 * 32 + 1) /* AVX512 Vector Bit Manipulation instructions*/ +#define X86_FEATURE_UMIP (11 * 32 + 2) /* User Mode Instruction Protection */ +#define X86_FEATURE_PKU (11 * 32 + 3) /* Protection Keys for Userspace */ +#define X86_FEATURE_OSPKE (11 * 32 + 4) /* OS Protection Keys Enable */ +#define X86_FEATURE_AVX512_VBMI2 (11 * 32 + 6) /* Additional AVX512 Vector Bit Manipulation Instructions */ +#define X86_FEATURE_GFNI (11 * 32 + 8) /* Galois Field New Instructions */ +#define X86_FEATURE_VAES (11 * 32 + 9) /* Vector AES */ +#define X86_FEATURE_VPCLMULQDQ (11 * 32 + 10) /* Carry-Less Multiplication Double Quadword */ +#define X86_FEATURE_AVX512_VNNI (11 * 32 + 11) /* Vector Neural Network Instructions */ +#define X86_FEATURE_AVX512_BITALG (11 * 32 + 12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */ +#define X86_FEATURE_TME (11 * 32 + 13) /* Intel Total Memory Encryption */ +#define X86_FEATURE_AVX512_VPOPCNTDQ (11 * 32 + 14) /* POPCNT for vectors of DW/QW */ +#define X86_FEATURE_LA57 (11 * 32 + 16) /* 5-level page tables */ +#define X86_FEATURE_RDPID (11 * 32 + 22) /* RDPID instruction */ +#define X86_FEATURE_CLDEMOTE (11 * 32 + 25) /* CLDEMOTE instruction */ /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (EDX), word 12 */ -#define X86_FEATURE_CQM_OCCUP_LLC (12*32+ 0) /* LLC occupancy monitoring */ -#define X86_FEATURE_CQM_MBM_TOTAL (12*32+ 1) /* LLC Total MBM monitoring */ -#define X86_FEATURE_CQM_MBM_LOCAL (12*32+ 2) /* LLC Local MBM monitoring */ +#define X86_FEATURE_CQM_OCCUP_LLC (12 * 32 + 0) /* LLC occupancy monitoring */ +#define X86_FEATURE_CQM_MBM_TOTAL (12 * 32 + 1) /* LLC Total MBM monitoring */ +#define X86_FEATURE_CQM_MBM_LOCAL (12 * 32 + 2) /* LLC Local MBM monitoring */ /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */ -#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */ -#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */ -#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */ -#define X86_FEATURE_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */ -#define X86_FEATURE_IBRS (13*32+14) /* Indirect Branch Restricted Speculation */ -#define X86_FEATURE_STIBP (13*32+15) /* Single Thread Indirect Branch Predictors */ +#define X86_FEATURE_CLZERO (13 * 32 + 0) /* CLZERO instruction */ +#define X86_FEATURE_IRPERF (13 * 32 + 1) /* Instructions Retired Count */ +#define X86_FEATURE_XSAVEERPTR (13 * 32 + 2) /* Always save/restore FP error pointers */ +#define X86_FEATURE_IBPB (13 * 32 + 12) /* Indirect Branch Prediction Barrier */ +#define X86_FEATURE_IBRS (13 * 32 + 14) /* Indirect Branch Restricted Speculation */ +#define X86_FEATURE_STIBP (13 * 32 + 15) /* Single Thread Indirect Branch Predictors */ /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */ -#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */ -#define X86_FEATURE_IDA (14*32+ 1) /* Intel Dynamic Acceleration */ -#define X86_FEATURE_ARAT (14*32+ 2) /* Always Running APIC Timer */ -#define X86_FEATURE_PLN (14*32+ 4) /* Intel Power Limit Notification */ -#define X86_FEATURE_PTS (14*32+ 6) /* Intel Package Thermal Status */ -#define X86_FEATURE_HWP (14*32+ 7) /* Intel Hardware P-states */ -#define X86_FEATURE_HWP_NOTIFY (14*32+ 8) /* HWP Notification */ -#define X86_FEATURE_HWP_ACT_WINDOW (14*32+ 9) /* HWP Activity Window */ -#define X86_FEATURE_HWP_EPP (14*32+10) /* HWP Energy Perf. Preference */ -#define X86_FEATURE_HWP_PKG_REQ (14*32+11) /* HWP Package Level Request */ -#define X86_FEATURE_HDC (14*32+13) /* HDC base registers present */ +#define X86_FEATURE_DTHERM (14 * 32 + 0) /* Digital Thermal Sensor */ +#define X86_FEATURE_IDA (14 * 32 + 1) /* Intel Dynamic Acceleration */ +#define X86_FEATURE_ARAT (14 * 32 + 2) /* Always Running APIC Timer */ +#define X86_FEATURE_PLN (14 * 32 + 4) /* Intel Power Limit Notification */ +#define X86_FEATURE_PTS (14 * 32 + 6) /* Intel Package Thermal Status */ +#define X86_FEATURE_HWP (14 * 32 + 7) /* Intel Hardware P-states */ +#define X86_FEATURE_HWP_NOTIFY (14 * 32 + 8) /* HWP Notification */ +#define X86_FEATURE_HWP_ACT_WINDOW (14 * 32 + 9) /* HWP Activity Window */ +#define X86_FEATURE_HWP_EPP (14 * 32 + 10) /* HWP Energy Perf. Preference */ +#define X86_FEATURE_HWP_PKG_REQ (14 * 32 + 11) /* HWP Package Level Request */ +#define X86_FEATURE_HDC (14 * 32 + 13) /* HDC base registers present */ /* AMD SVM Feature Identification, CPUID level 0x8000000a (EDX), word 15 */ -#define X86_FEATURE_NPT (15*32+ 0) /* Nested Page Table support */ -#define X86_FEATURE_LBRV (15*32+ 1) /* LBR Virtualization support */ -#define X86_FEATURE_SVML (15*32+ 2) /* "svm_lock" SVM locking MSR */ -#define X86_FEATURE_NRIPS (15*32+ 3) /* "nrip_save" SVM next_rip save */ -#define X86_FEATURE_TSCRATEMSR (15*32+ 4) /* "tsc_scale" TSC scaling support */ -#define X86_FEATURE_VMCBCLEAN (15*32+ 5) /* "vmcb_clean" VMCB clean bits support */ -#define X86_FEATURE_FLUSHBYASID (15*32+ 6) /* flush-by-ASID support */ -#define X86_FEATURE_DECODEASSISTS (15*32+ 7) /* Decode Assists support */ -#define X86_FEATURE_PAUSEFILTER (15*32+10) /* filtered pause intercept */ -#define X86_FEATURE_PFTHRESHOLD (15*32+12) /* pause filter threshold */ -#define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ -#define X86_FEATURE_V_VMSAVE_VMLOAD (15*32+15) /* Virtual VMSAVE VMLOAD */ -#define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ +#define X86_FEATURE_NPT (15 * 32 + 0) /* Nested Page Table support */ +#define X86_FEATURE_LBRV (15 * 32 + 1) /* LBR Virtualization support */ +#define X86_FEATURE_SVML (15 * 32 + 2) /* "svm_lock" SVM locking MSR */ +#define X86_FEATURE_NRIPS (15 * 32 + 3) /* "nrip_save" SVM next_rip save */ +#define X86_FEATURE_TSCRATEMSR (15 * 32 + 4) /* "tsc_scale" TSC scaling support */ +#define X86_FEATURE_VMCBCLEAN (15 * 32 + 5) /* "vmcb_clean" VMCB clean bits support */ +#define X86_FEATURE_FLUSHBYASID (15 * 32 + 6) /* flush-by-ASID support */ +#define X86_FEATURE_DECODEASSISTS (15 * 32 + 7) /* Decode Assists support */ +#define X86_FEATURE_PAUSEFILTER (15 * 32 + 10) /* filtered pause intercept */ +#define X86_FEATURE_PFTHRESHOLD (15 * 32 + 12) /* pause filter threshold */ +#define X86_FEATURE_AVIC (15 * 32 + 13) /* Virtual Interrupt Controller */ +#define X86_FEATURE_V_VMSAVE_VMLOAD (15 * 32 + 15) /* Virtual VMSAVE VMLOAD */ +#define X86_FEATURE_VGIF (15 * 32 + 16) /* Virtual GIF */ /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (EDX), word 16 */ -#define X86_FEATURE_CQM_LLC (16*32+ 1) /* LLC QoS if 1 */ +#define X86_FEATURE_CQM_LLC (16 * 32 + 1) /* LLC QoS if 1 */ /* AMD-defined CPU features, CPUID level 0x80000007 (EBX), word 17 */ -#define X86_FEATURE_OVERFLOW_RECOV (17*32+ 0) /* MCA overflow recovery support */ -#define X86_FEATURE_SUCCOR (17*32+ 1) /* Uncorrectable error containment and recovery */ -#define X86_FEATURE_SMCA (17*32+ 3) /* Scalable MCA */ +#define X86_FEATURE_OVERFLOW_RECOV (17 * 32 + 0) /* MCA overflow recovery support */ +#define X86_FEATURE_SUCCOR (17 * 32 + 1) /* Uncorrectable error containment and recovery */ +#define X86_FEATURE_SMCA (17 * 32 + 3) /* Scalable MCA */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ -#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ -#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ -#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ -#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */ -#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */ -#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */ -#define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31) /* "" Speculative Store Bypass Disable */ +#define X86_FEATURE_AVX512_4VNNIW (18 * 32 + 2) /* AVX-512 Neural Network Instructions */ +#define X86_FEATURE_AVX512_4FMAPS (18 * 32 + 3) /* AVX-512 Multiply Accumulation Single precision */ +#define X86_FEATURE_PCONFIG (18 * 32 + 18) /* Intel PCONFIG */ +#define X86_FEATURE_SPEC_CTRL (18 * 32 + 26) /* "" Speculation Control (IBRS + IBPB) */ +#define X86_FEATURE_INTEL_STIBP (18 * 32 + 27) /* "" Single Thread Indirect Branch Predictors */ +#define X86_FEATURE_ARCH_CAPABILITIES (18 * 32 + 29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */ +#define X86_FEATURE_SPEC_CTRL_SSBD (18 * 32 + 31) /* "" Speculative Store Bypass Disable */ enum { - X86_VENDOR_INTEL = 0, - X86_VENDOR_AMD = 1, + X86_VENDOR_INTEL = 0, + X86_VENDOR_AMD = 1, X86_VENDOR_MAX }; struct cpuinfo_x86 { /* cpu context */ - uint8_t x86_family; - uint8_t x86_vendor; - uint8_t x86_model; - uint8_t x86_mask; - uint32_t x86_capability[NCAPINTS]; - uint32_t x86_power; - uint32_t extended_cpuid_level; - int cpuid_level; - char x86_vendor_id[16]; - char x86_model_id[64]; + uint8_t x86_family; + uint8_t x86_vendor; + uint8_t x86_model; + uint8_t x86_mask; + uint32_t x86_capability[NCAPINTS]; + uint32_t x86_power; + uint32_t extended_cpuid_level; + int cpuid_level; + char x86_vendor_id[16]; + char x86_model_id[64]; /* fpu context */ - uint64_t xfeatures_mask; - uint32_t xsave_size_max; - uint32_t xsave_size; - uint32_t xstate_offsets[XFEATURE_MAX]; - uint32_t xstate_sizes[XFEATURE_MAX]; + uint64_t xfeatures_mask; + uint32_t xsave_size_max; + uint32_t xsave_size; + uint32_t xstate_offsets[XFEATURE_MAX]; + uint32_t xstate_sizes[XFEATURE_MAX]; - uint32_t xsaves_size; - uint32_t xstate_comp_offsets[XFEATURE_MAX]; - uint32_t xstate_comp_sizes[XFEATURE_MAX]; + uint32_t xsaves_size; + uint32_t xstate_comp_offsets[XFEATURE_MAX]; + uint32_t xstate_comp_sizes[XFEATURE_MAX]; }; typedef struct cpuinfo_x86 compel_cpuinfo_t; diff --git a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h index 8985ad7f6..d740e3c04 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/fpu.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/fpu.h @@ -7,27 +7,27 @@ #include -#define FP_MIN_ALIGN_BYTES 64 -#define FXSAVE_ALIGN_BYTES 16 +#define FP_MIN_ALIGN_BYTES 64 +#define FXSAVE_ALIGN_BYTES 16 -#define FP_XSTATE_MAGIC1 0x46505853U -#define FP_XSTATE_MAGIC2 0x46505845U +#define FP_XSTATE_MAGIC1 0x46505853U +#define FP_XSTATE_MAGIC2 0x46505845U #ifndef FP_XSTATE_MAGIC2_SIZE -#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) +#define FP_XSTATE_MAGIC2_SIZE sizeof(FP_XSTATE_MAGIC2) #endif -#define XSTATE_FP 0x1 -#define XSTATE_SSE 0x2 -#define XSTATE_YMM 0x4 +#define XSTATE_FP 0x1 +#define XSTATE_SSE 0x2 +#define XSTATE_YMM 0x4 -#define FXSAVE_SIZE 512 -#define XSAVE_SIZE 4096 +#define FXSAVE_SIZE 512 +#define XSAVE_SIZE 4096 -#define XSAVE_HDR_SIZE 64 -#define XSAVE_HDR_OFFSET FXSAVE_SIZE +#define XSAVE_HDR_SIZE 64 +#define XSAVE_HDR_OFFSET FXSAVE_SIZE -#define XSAVE_YMM_SIZE 256 -#define XSAVE_YMM_OFFSET (XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET) +#define XSAVE_YMM_SIZE 256 +#define XSAVE_YMM_OFFSET (XSAVE_HDR_SIZE + XSAVE_HDR_OFFSET) /* * List of XSAVE features Linux knows about: @@ -52,91 +52,88 @@ enum xfeature { XFEATURE_MAX, }; -#define XSTATE_CPUID 0x0000000d +#define XSTATE_CPUID 0x0000000d -#define XFEATURE_MASK_FP (1 << XFEATURE_FP) -#define XFEATURE_MASK_SSE (1 << XFEATURE_SSE) -#define XFEATURE_MASK_YMM (1 << XFEATURE_YMM) -#define XFEATURE_MASK_BNDREGS (1 << XFEATURE_BNDREGS) -#define XFEATURE_MASK_BNDCSR (1 << XFEATURE_BNDCSR) -#define XFEATURE_MASK_OPMASK (1 << XFEATURE_OPMASK) -#define XFEATURE_MASK_ZMM_Hi256 (1 << XFEATURE_ZMM_Hi256) -#define XFEATURE_MASK_Hi16_ZMM (1 << XFEATURE_Hi16_ZMM) -#define XFEATURE_MASK_PT (1 << XFEATURE_PT) -#define XFEATURE_MASK_PKRU (1 << XFEATURE_PKRU) -#define XFEATURE_MASK_HDC (1 << XFEATURE_HDC) -#define XFEATURE_MASK_MAX (1 << XFEATURE_MAX) +#define XFEATURE_MASK_FP (1 << XFEATURE_FP) +#define XFEATURE_MASK_SSE (1 << XFEATURE_SSE) +#define XFEATURE_MASK_YMM (1 << XFEATURE_YMM) +#define XFEATURE_MASK_BNDREGS (1 << XFEATURE_BNDREGS) +#define XFEATURE_MASK_BNDCSR (1 << XFEATURE_BNDCSR) +#define XFEATURE_MASK_OPMASK (1 << XFEATURE_OPMASK) +#define XFEATURE_MASK_ZMM_Hi256 (1 << XFEATURE_ZMM_Hi256) +#define XFEATURE_MASK_Hi16_ZMM (1 << XFEATURE_Hi16_ZMM) +#define XFEATURE_MASK_PT (1 << XFEATURE_PT) +#define XFEATURE_MASK_PKRU (1 << XFEATURE_PKRU) +#define XFEATURE_MASK_HDC (1 << XFEATURE_HDC) +#define XFEATURE_MASK_MAX (1 << XFEATURE_MAX) -#define XFEATURE_MASK_FPSSE (XFEATURE_MASK_FP | XFEATURE_MASK_SSE) -#define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK | XFEATURE_MASK_ZMM_Hi256 | XFEATURE_MASK_Hi16_ZMM) +#define XFEATURE_MASK_FPSSE (XFEATURE_MASK_FP | XFEATURE_MASK_SSE) +#define XFEATURE_MASK_AVX512 (XFEATURE_MASK_OPMASK | XFEATURE_MASK_ZMM_Hi256 | XFEATURE_MASK_Hi16_ZMM) -#define FIRST_EXTENDED_XFEATURE XFEATURE_YMM +#define FIRST_EXTENDED_XFEATURE XFEATURE_YMM /* Supervisor features */ -#define XFEATURE_MASK_SUPERVISOR (XFEATURE_MASK_PT | XFEATURE_HDC) +#define XFEATURE_MASK_SUPERVISOR (XFEATURE_MASK_PT | XFEATURE_HDC) /* All currently supported features */ -#define XFEATURE_MASK_USER \ - (XFEATURE_MASK_FP | XFEATURE_MASK_SSE | \ - XFEATURE_MASK_YMM | XFEATURE_MASK_OPMASK | \ - XFEATURE_MASK_ZMM_Hi256 | XFEATURE_MASK_Hi16_ZMM | \ - XFEATURE_MASK_PKRU | XFEATURE_MASK_BNDREGS | \ - XFEATURE_MASK_BNDCSR) +#define XFEATURE_MASK_USER \ + (XFEATURE_MASK_FP | XFEATURE_MASK_SSE | XFEATURE_MASK_YMM | XFEATURE_MASK_OPMASK | XFEATURE_MASK_ZMM_Hi256 | \ + XFEATURE_MASK_Hi16_ZMM | XFEATURE_MASK_PKRU | XFEATURE_MASK_BNDREGS | XFEATURE_MASK_BNDCSR) struct fpx_sw_bytes { - uint32_t magic1; - uint32_t extended_size; - uint64_t xstate_bv; - uint32_t xstate_size; - uint32_t padding[7]; + uint32_t magic1; + uint32_t extended_size; + uint64_t xstate_bv; + uint32_t xstate_size; + uint32_t padding[7]; }; struct i387_fxsave_struct { - uint16_t cwd; /* Control Word */ - uint16_t swd; /* Status Word */ - uint16_t twd; /* Tag Word */ - uint16_t fop; /* Last Instruction Opcode */ + uint16_t cwd; /* Control Word */ + uint16_t swd; /* Status Word */ + uint16_t twd; /* Tag Word */ + uint16_t fop; /* Last Instruction Opcode */ union { struct { - uint64_t rip; /* Instruction Pointer */ - uint64_t rdp; /* Data Pointer */ + uint64_t rip; /* Instruction Pointer */ + uint64_t rdp; /* Data Pointer */ }; struct { - uint32_t fip; /* FPU IP Offset */ - uint32_t fcs; /* FPU IP Selector */ - uint32_t foo; /* FPU Operand Offset */ - uint32_t fos; /* FPU Operand Selector */ + uint32_t fip; /* FPU IP Offset */ + uint32_t fcs; /* FPU IP Selector */ + uint32_t foo; /* FPU Operand Offset */ + uint32_t fos; /* FPU Operand Selector */ }; }; - uint32_t mxcsr; /* MXCSR Register State */ - uint32_t mxcsr_mask; /* MXCSR Mask */ + uint32_t mxcsr; /* MXCSR Register State */ + uint32_t mxcsr_mask; /* MXCSR Mask */ /* 8*16 bytes for each FP-reg = 128 bytes */ - uint32_t st_space[32]; + uint32_t st_space[32]; /* 16*16 bytes for each XMM-reg = 256 bytes */ - uint32_t xmm_space[64]; + uint32_t xmm_space[64]; - uint32_t padding[12]; + uint32_t padding[12]; union { - uint32_t padding1[12]; - uint32_t sw_reserved[12]; + uint32_t padding1[12]; + uint32_t sw_reserved[12]; }; } __aligned(FXSAVE_ALIGN_BYTES); struct xsave_hdr_struct { - uint64_t xstate_bv; - uint64_t xcomp_bv; - uint64_t reserved[6]; + uint64_t xstate_bv; + uint64_t xcomp_bv; + uint64_t reserved[6]; } __packed; /* * xstate_header.xcomp_bv[63] indicates that the extended_state_area * is in compacted format. */ -#define XCOMP_BV_COMPACTED_FORMAT ((uint64_t)1 << 63) +#define XCOMP_BV_COMPACTED_FORMAT ((uint64_t)1 << 63) /* * State component 2: @@ -149,21 +146,21 @@ struct xsave_hdr_struct { * The high 128 bits are stored here. */ struct ymmh_struct { - uint32_t ymmh_space[64]; + uint32_t ymmh_space[64]; } __packed; /* Intel MPX support: */ struct mpx_bndreg { - uint64_t lower_bound; - uint64_t upper_bound; + uint64_t lower_bound; + uint64_t upper_bound; } __packed; /* * State component 3 is used for the 4 128-bit bounds registers */ struct mpx_bndreg_state { - struct mpx_bndreg bndreg[4]; + struct mpx_bndreg bndreg[4]; } __packed; /* @@ -172,8 +169,8 @@ struct mpx_bndreg_state { * register BNDSTATUS. We call the pair "BNDCSR". */ struct mpx_bndcsr { - uint64_t bndcfgu; - uint64_t bndstatus; + uint64_t bndcfgu; + uint64_t bndstatus; } __packed; /* @@ -181,8 +178,8 @@ struct mpx_bndcsr { */ struct mpx_bndcsr_state { union { - struct mpx_bndcsr bndcsr; - uint8_t pad_to_64_bytes[64]; + struct mpx_bndcsr bndcsr; + uint8_t pad_to_64_bytes[64]; }; } __packed; @@ -193,7 +190,7 @@ struct mpx_bndcsr_state { * k0-k7 (opmask state). */ struct avx_512_opmask_state { - uint64_t opmask_reg[8]; + uint64_t opmask_reg[8]; } __packed; /* @@ -202,7 +199,7 @@ struct avx_512_opmask_state { * ZMM0_H-ZMM15_H (ZMM_Hi256 state). */ struct avx_512_zmm_uppers_state { - uint64_t zmm_upper[16 * 4]; + uint64_t zmm_upper[16 * 4]; } __packed; /* @@ -210,7 +207,7 @@ struct avx_512_zmm_uppers_state { * ZMM16-ZMM31 (Hi16_ZMM state). */ struct avx_512_hi16_state { - uint64_t hi16_zmm[16 * 8]; + uint64_t hi16_zmm[16 * 8]; } __packed; /* @@ -218,8 +215,8 @@ struct avx_512_hi16_state { * 8 bytes long but only 4 bytes is used currently. */ struct pkru_state { - uint32_t pkru; - uint32_t pad; + uint32_t pkru; + uint32_t pad; } __packed; /* @@ -234,34 +231,34 @@ struct pkru_state { * * One page should be enough for the whole xsave state ;-) */ -#define EXTENDED_STATE_AREA_SIZE (4096 - sizeof(struct i387_fxsave_struct) - sizeof(struct xsave_hdr_struct)) +#define EXTENDED_STATE_AREA_SIZE (4096 - sizeof(struct i387_fxsave_struct) - sizeof(struct xsave_hdr_struct)) /* * cpu requires it to be 64 byte aligned */ struct xsave_struct { - struct i387_fxsave_struct i387; - struct xsave_hdr_struct xsave_hdr; + struct i387_fxsave_struct i387; + struct xsave_hdr_struct xsave_hdr; union { /* * This ymmh is unndeed, for * backward compatibility. */ - struct ymmh_struct ymmh; - uint8_t extended_state_area[EXTENDED_STATE_AREA_SIZE]; + struct ymmh_struct ymmh; + uint8_t extended_state_area[EXTENDED_STATE_AREA_SIZE]; }; } __aligned(FP_MIN_ALIGN_BYTES) __packed; struct xsave_struct_ia32 { - struct i387_fxsave_struct i387; - struct xsave_hdr_struct xsave_hdr; + struct i387_fxsave_struct i387; + struct xsave_hdr_struct xsave_hdr; union { /* * This ymmh is unndeed, for * backward compatibility. */ - struct ymmh_struct ymmh; - uint8_t extended_state_area[EXTENDED_STATE_AREA_SIZE]; + struct ymmh_struct ymmh; + uint8_t extended_state_area[EXTENDED_STATE_AREA_SIZE]; }; }; @@ -272,34 +269,34 @@ typedef struct { */ union { - struct xsave_struct xsave; - uint8_t __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE]; + struct xsave_struct xsave; + uint8_t __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE]; }; uint8_t has_fpu; } fpu_state_64_t; struct user_i387_ia32_struct { - uint32_t cwd; /* FPU Control Word */ - uint32_t swd; /* FPU Status Word */ - uint32_t twd; /* FPU Tag Word */ - uint32_t fip; /* FPU IP Offset */ - uint32_t fcs; /* FPU IP Selector */ - uint32_t foo; /* FPU Operand Pointer Offset */ - uint32_t fos; /* FPU Operand Pointer Selector */ - uint32_t st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ + uint32_t cwd; /* FPU Control Word */ + uint32_t swd; /* FPU Status Word */ + uint32_t twd; /* FPU Tag Word */ + uint32_t fip; /* FPU IP Offset */ + uint32_t fcs; /* FPU IP Selector */ + uint32_t foo; /* FPU Operand Pointer Offset */ + uint32_t fos; /* FPU Operand Pointer Selector */ + uint32_t st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ }; typedef struct { struct { - struct user_i387_ia32_struct i387_ia32; + struct user_i387_ia32_struct i387_ia32; /* Software status information [not touched by FSAVE]: */ - uint32_t status; + uint32_t status; } fregs_state; union { - struct xsave_struct_ia32 xsave; - uint8_t __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE]; + struct xsave_struct_ia32 xsave; + uint8_t __pad[sizeof(struct xsave_struct) + FP_XSTATE_MAGIC2_SIZE]; } __aligned(FXSAVE_ALIGN_BYTES); } __aligned(FXSAVE_ALIGN_BYTES) fpu_state_ia32_t; @@ -308,18 +305,17 @@ typedef struct { */ typedef struct { union { - fpu_state_64_t fpu_state_64; + fpu_state_64_t fpu_state_64; struct { /* fpu_state_ia32->xsave has to be 64-byte aligned. */ - uint32_t __pad[2]; - fpu_state_ia32_t fpu_state_ia32; + uint32_t __pad[2]; + fpu_state_ia32_t fpu_state_ia32; }; }; uint8_t has_fpu; } fpu_state_t; -extern void compel_convert_from_fxsr(struct user_i387_ia32_struct *env, - struct i387_fxsave_struct *fxsave); +extern void compel_convert_from_fxsr(struct user_i387_ia32_struct *env, struct i387_fxsave_struct *fxsave); #endif /* __CR_ASM_FPU_H__ */ diff --git a/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h b/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h index 470a1b0fd..34b3ad061 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/infect-types.h @@ -6,8 +6,8 @@ #include #include -#define SIGMAX 64 -#define SIGMAX_OLD 31 +#define SIGMAX 64 +#define SIGMAX_OLD 31 #define ARCH_HAS_PTRACE_GET_THREAD_AREA @@ -17,11 +17,11 @@ * For 64-bit x86 those GDT offsets are the same * for native and compat tasks. */ -#define GDT_ENTRY_TLS_MIN 12 -#define GDT_ENTRY_TLS_MAX 14 -#define GDT_ENTRY_TLS_NUM 3 +#define GDT_ENTRY_TLS_MIN 12 +#define GDT_ENTRY_TLS_MAX 14 +#define GDT_ENTRY_TLS_NUM 3 typedef struct { - user_desc_t desc[GDT_ENTRY_TLS_NUM]; + user_desc_t desc[GDT_ENTRY_TLS_NUM]; } tls_t; struct thread_ctx; @@ -33,53 +33,53 @@ extern void compel_arch_get_tls_thread(struct parasite_thread_ctl *tctl, tls_t * extern void compel_arch_get_tls_task(struct parasite_ctl *ctl, tls_t *out); typedef struct { - uint64_t r15; - uint64_t r14; - uint64_t r13; - uint64_t r12; - uint64_t bp; - uint64_t bx; - uint64_t r11; - uint64_t r10; - uint64_t r9; - uint64_t r8; - uint64_t ax; - uint64_t cx; - uint64_t dx; - uint64_t si; - uint64_t di; - uint64_t orig_ax; - uint64_t ip; - uint64_t cs; - uint64_t flags; - uint64_t sp; - uint64_t ss; - uint64_t fs_base; - uint64_t gs_base; - uint64_t ds; - uint64_t es; - uint64_t fs; - uint64_t gs; + uint64_t r15; + uint64_t r14; + uint64_t r13; + uint64_t r12; + uint64_t bp; + uint64_t bx; + uint64_t r11; + uint64_t r10; + uint64_t r9; + uint64_t r8; + uint64_t ax; + uint64_t cx; + uint64_t dx; + uint64_t si; + uint64_t di; + uint64_t orig_ax; + uint64_t ip; + uint64_t cs; + uint64_t flags; + uint64_t sp; + uint64_t ss; + uint64_t fs_base; + uint64_t gs_base; + uint64_t ds; + uint64_t es; + uint64_t fs; + uint64_t gs; } user_regs_struct64; typedef struct { - uint32_t bx; - uint32_t cx; - uint32_t dx; - uint32_t si; - uint32_t di; - uint32_t bp; - uint32_t ax; - uint32_t ds; - uint32_t es; - uint32_t fs; - uint32_t gs; - uint32_t orig_ax; - uint32_t ip; - uint32_t cs; - uint32_t flags; - uint32_t sp; - uint32_t ss; + uint32_t bx; + uint32_t cx; + uint32_t dx; + uint32_t si; + uint32_t di; + uint32_t bp; + uint32_t ax; + uint32_t ds; + uint32_t es; + uint32_t fs; + uint32_t gs; + uint32_t orig_ax; + uint32_t ip; + uint32_t cs; + uint32_t flags; + uint32_t sp; + uint32_t ss; } user_regs_struct32; /* @@ -96,22 +96,17 @@ typedef struct { short __is_native; /* use user_regs_native macro to check it */ } user_regs_struct_t; -#define NATIVE_MAGIC 0x0A -#define COMPAT_MAGIC 0x0C +#define NATIVE_MAGIC 0x0A +#define COMPAT_MAGIC 0x0C static inline bool user_regs_native(user_regs_struct_t *pregs) { return pregs->__is_native == NATIVE_MAGIC; } -#define get_user_reg(pregs, name) \ - ((user_regs_native(pregs)) ? \ - ((pregs)->native.name) : \ - ((pregs)->compat.name)) +#define get_user_reg(pregs, name) ((user_regs_native(pregs)) ? ((pregs)->native.name) : ((pregs)->compat.name)) -#define set_user_reg(pregs, name, val) \ - ((user_regs_native(pregs)) ? \ - ((pregs)->native.name = (val)) : \ - ((pregs)->compat.name = (val))) +#define set_user_reg(pregs, name, val) \ + ((user_regs_native(pregs)) ? ((pregs)->native.name = (val)) : ((pregs)->compat.name = (val))) #if 0 typedef struct { @@ -132,12 +127,12 @@ typedef struct { typedef struct xsave_struct user_fpregs_struct_t; -#define REG_RES(regs) get_user_reg(®s, ax) -#define REG_IP(regs) get_user_reg(®s, ip) -#define REG_SP(regs) get_user_reg(®s, sp) -#define REG_SYSCALL_NR(regs) get_user_reg(®s, orig_ax) +#define REG_RES(regs) get_user_reg(®s, ax) +#define REG_IP(regs) get_user_reg(®s, ip) +#define REG_SP(regs) get_user_reg(®s, sp) +#define REG_SYSCALL_NR(regs) get_user_reg(®s, orig_ax) -#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) +#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) /* * For x86_32 __NR_mmap inside the kernel represents old_mmap system diff --git a/compel/arch/x86/src/lib/include/uapi/asm/processor-flags.h b/compel/arch/x86/src/lib/include/uapi/asm/processor-flags.h index 9f1bccdbe..caa784557 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/processor-flags.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/processor-flags.h @@ -7,7 +7,7 @@ * EFLAGS bits */ #define X86_EFLAGS_CF 0x00000001 /* Carry Flag */ -#define X86_EFLAGS_BIT1 0x00000002 /* Bit 1 - always on */ +#define X86_EFLAGS_BIT1 0x00000002 /* Bit 1 - always on */ #define X86_EFLAGS_PF 0x00000004 /* Parity Flag */ #define X86_EFLAGS_AF 0x00000010 /* Auxiliary carry Flag */ #define X86_EFLAGS_ZF 0x00000040 /* Zero Flag */ @@ -16,7 +16,7 @@ #define X86_EFLAGS_IF 0x00000200 /* Interrupt Flag */ #define X86_EFLAGS_DF 0x00000400 /* Direction Flag */ #define X86_EFLAGS_OF 0x00000800 /* Overflow Flag */ -#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */ +#define X86_EFLAGS_IOPL 0x00003000 /* IOPL mask */ #define X86_EFLAGS_NT 0x00004000 /* Nested Task */ #define X86_EFLAGS_RF 0x00010000 /* Resume Flag */ #define X86_EFLAGS_VM 0x00020000 /* Virtual Mode */ diff --git a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h index 486c0c8e0..ec8c156fa 100644 --- a/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/x86/src/lib/include/uapi/asm/sigframe.h @@ -11,60 +11,60 @@ #define SIGFRAME_MAX_OFFSET 8 struct rt_sigcontext { - uint64_t r8; - uint64_t r9; - uint64_t r10; - uint64_t r11; - uint64_t r12; - uint64_t r13; - uint64_t r14; - uint64_t r15; - uint64_t rdi; - uint64_t rsi; - uint64_t rbp; - uint64_t rbx; - uint64_t rdx; - uint64_t rax; - uint64_t rcx; - uint64_t rsp; - uint64_t rip; - uint64_t eflags; - uint16_t cs; - uint16_t gs; - uint16_t fs; - uint16_t ss; - uint64_t err; - uint64_t trapno; - uint64_t oldmask; - uint64_t cr2; - uint64_t fpstate; - uint64_t reserved1[8]; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + uint64_t rdi; + uint64_t rsi; + uint64_t rbp; + uint64_t rbx; + uint64_t rdx; + uint64_t rax; + uint64_t rcx; + uint64_t rsp; + uint64_t rip; + uint64_t eflags; + uint16_t cs; + uint16_t gs; + uint16_t fs; + uint16_t ss; + uint64_t err; + uint64_t trapno; + uint64_t oldmask; + uint64_t cr2; + uint64_t fpstate; + uint64_t reserved1[8]; }; struct rt_sigcontext_32 { - uint32_t gs; - uint32_t fs; - uint32_t es; - uint32_t ds; - uint32_t di; - uint32_t si; - uint32_t bp; - uint32_t sp; - uint32_t bx; - uint32_t dx; - uint32_t cx; - uint32_t ax; - uint32_t trapno; - uint32_t err; - uint32_t ip; - uint32_t cs; - uint32_t flags; - uint32_t sp_at_signal; - uint32_t ss; + uint32_t gs; + uint32_t fs; + uint32_t es; + uint32_t ds; + uint32_t di; + uint32_t si; + uint32_t bp; + uint32_t sp; + uint32_t bx; + uint32_t dx; + uint32_t cx; + uint32_t ax; + uint32_t trapno; + uint32_t err; + uint32_t ip; + uint32_t cs; + uint32_t flags; + uint32_t sp_at_signal; + uint32_t ss; - uint32_t fpstate; - uint32_t oldmask; - uint32_t cr2; + uint32_t fpstate; + uint32_t oldmask; + uint32_t cr2; }; #include @@ -74,71 +74,70 @@ struct rt_sigcontext_32 { * when (if) other architectures will support compatible C/R */ -typedef uint32_t compat_uptr_t; -typedef uint32_t compat_size_t; -typedef uint32_t compat_sigset_word; +typedef uint32_t compat_uptr_t; +typedef uint32_t compat_size_t; +typedef uint32_t compat_sigset_word; typedef struct compat_siginfo { - int si_signo; - int si_errno; - int si_code; - int _pad[128/sizeof(int) - 3]; + int si_signo; + int si_errno; + int si_code; + int _pad[128 / sizeof(int) - 3]; } compat_siginfo_t; typedef struct compat_sigaltstack { - compat_uptr_t ss_sp; - int ss_flags; - compat_size_t ss_size; + compat_uptr_t ss_sp; + int ss_flags; + compat_size_t ss_size; } compat_stack_t; -#define _COMPAT_NSIG 64 -#define _COMPAT_NSIG_BPW 32 -#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) +#define _COMPAT_NSIG 64 +#define _COMPAT_NSIG_BPW 32 +#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) typedef struct { - compat_sigset_word sig[_COMPAT_NSIG_WORDS]; + compat_sigset_word sig[_COMPAT_NSIG_WORDS]; } compat_sigset_t; struct ucontext_ia32 { - unsigned int uc_flags; - unsigned int uc_link; - compat_stack_t uc_stack; - struct rt_sigcontext_32 uc_mcontext; - compat_sigset_t uc_sigmask; /* mask last for extensibility */ + unsigned int uc_flags; + unsigned int uc_link; + compat_stack_t uc_stack; + struct rt_sigcontext_32 uc_mcontext; + compat_sigset_t uc_sigmask; /* mask last for extensibility */ }; struct rt_sigframe_ia32 { - uint32_t pretcode; - int32_t sig; - uint32_t pinfo; - uint32_t puc; - compat_siginfo_t info; - struct ucontext_ia32 uc; - char retcode[8]; + uint32_t pretcode; + int32_t sig; + uint32_t pinfo; + uint32_t puc; + compat_siginfo_t info; + struct ucontext_ia32 uc; + char retcode[8]; /* fp state follows here */ - fpu_state_t fpu_state; + fpu_state_t fpu_state; }; struct rt_sigframe_64 { - char *pretcode; - struct rt_ucontext uc; - struct rt_siginfo info; + char *pretcode; + struct rt_ucontext uc; + struct rt_siginfo info; /* fp state follows here */ - fpu_state_t fpu_state; + fpu_state_t fpu_state; }; struct rt_sigframe { union { - struct rt_sigframe_ia32 compat; - struct rt_sigframe_64 native; + struct rt_sigframe_ia32 compat; + struct rt_sigframe_64 native; }; bool is_native; }; -static inline -void rt_sigframe_copy_sigset(struct rt_sigframe *to, k_rtsigset_t *from) +static inline void rt_sigframe_copy_sigset(struct rt_sigframe *to, k_rtsigset_t *from) { size_t sz = sizeof(k_rtsigset_t); @@ -149,8 +148,7 @@ void rt_sigframe_copy_sigset(struct rt_sigframe *to, k_rtsigset_t *from) memcpy(&to->compat.uc.uc_sigmask, from, sz); } -static inline -void rt_sigframe_erase_sigset(struct rt_sigframe *sigframe) +static inline void rt_sigframe_erase_sigset(struct rt_sigframe *sigframe) { size_t sz = sizeof(k_rtsigset_t); @@ -160,15 +158,11 @@ void rt_sigframe_erase_sigset(struct rt_sigframe *sigframe) memset(&sigframe->compat.uc.uc_sigmask, 0, sz); } -#define RT_SIGFRAME_REGIP(rt_sigframe) \ - ((rt_sigframe->is_native) ? \ - (rt_sigframe)->native.uc.uc_mcontext.rip : \ - (rt_sigframe)->compat.uc.uc_mcontext.ip) +#define RT_SIGFRAME_REGIP(rt_sigframe) \ + ((rt_sigframe->is_native) ? (rt_sigframe)->native.uc.uc_mcontext.rip : (rt_sigframe)->compat.uc.uc_mcontext.ip) -#define RT_SIGFRAME_FPU(rt_sigframe) \ - ((rt_sigframe->is_native) ? \ - (&(rt_sigframe)->native.fpu_state) : \ - (&(rt_sigframe)->compat.fpu_state)) +#define RT_SIGFRAME_FPU(rt_sigframe) \ + ((rt_sigframe->is_native) ? (&(rt_sigframe)->native.fpu_state) : (&(rt_sigframe)->compat.fpu_state)) #define RT_SIGFRAME_HAS_FPU(rt_sigframe) (RT_SIGFRAME_FPU(rt_sigframe)->has_fpu) @@ -178,10 +172,11 @@ void rt_sigframe_erase_sigset(struct rt_sigframe *sigframe) * - compatible is in sys32_rt_sigreturn at arch/x86/ia32/ia32_signal.c * - native is in sys_rt_sigreturn at arch/x86/kernel/signal.c */ -#define RT_SIGFRAME_OFFSET(rt_sigframe) (((rt_sigframe)->is_native) ? 8 : 4 ) +#define RT_SIGFRAME_OFFSET(rt_sigframe) (((rt_sigframe)->is_native) ? 8 : 4) -#define USER32_CS 0x23 +#define USER32_CS 0x23 +/* clang-format off */ #define ARCH_RT_SIGRETURN_NATIVE(new_sp) \ asm volatile( \ "movq %0, %%rax \n" \ @@ -215,6 +210,7 @@ do { \ else \ ARCH_RT_SIGRETURN_COMPAT(new_sp); \ } while (0) +/* clang-format off */ int sigreturn_prep_fpu_frame(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe); diff --git a/compel/include/elf32-types.h b/compel/include/elf32-types.h index b516ba17e..8f6c59960 100644 --- a/compel/include/elf32-types.h +++ b/compel/include/elf32-types.h @@ -1,16 +1,16 @@ #ifndef COMPEL_ELF32_TYPES_H__ #define COMPEL_ELF32_TYPES_H__ -#define Elf_Ehdr Elf32_Ehdr -#define Elf_Shdr Elf32_Shdr -#define Elf_Sym Elf32_Sym -#define Elf_Rel Elf32_Rel -#define Elf_Rela Elf32_Rela +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Shdr Elf32_Shdr +#define Elf_Sym Elf32_Sym +#define Elf_Rel Elf32_Rel +#define Elf_Rela Elf32_Rela -#define ELF_ST_TYPE ELF32_ST_TYPE -#define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_ST_BIND ELF32_ST_BIND -#define ELF_R_SYM ELF32_R_SYM -#define ELF_R_TYPE ELF32_R_TYPE +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE #endif /* COMPEL_ELF32_TYPES_H__ */ diff --git a/compel/include/elf64-types.h b/compel/include/elf64-types.h index c4d5f1c72..ce11a2a61 100644 --- a/compel/include/elf64-types.h +++ b/compel/include/elf64-types.h @@ -1,16 +1,16 @@ #ifndef COMPEL_ELF64_TYPES_H__ #define COMPEL_ELF64_TYPES_H__ -#define Elf_Ehdr Elf64_Ehdr -#define Elf_Shdr Elf64_Shdr -#define Elf_Sym Elf64_Sym -#define Elf_Rel Elf64_Rel -#define Elf_Rela Elf64_Rela +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Shdr Elf64_Shdr +#define Elf_Sym Elf64_Sym +#define Elf_Rel Elf64_Rel +#define Elf_Rela Elf64_Rela -#define ELF_ST_TYPE ELF64_ST_TYPE -#define ELF_ST_BIND ELF64_ST_BIND +#define ELF_ST_TYPE ELF64_ST_TYPE +#define ELF_ST_BIND ELF64_ST_BIND -#define ELF_R_SYM ELF64_R_SYM -#define ELF_R_TYPE ELF64_R_TYPE +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE #endif /* COMPEL_ELF64_TYPES_H__ */ diff --git a/compel/include/errno.h b/compel/include/errno.h index d41fd5391..b4ad1f086 100644 --- a/compel/include/errno.h +++ b/compel/include/errno.h @@ -1,9 +1,9 @@ #ifndef __COMPEL_ERRNO_H__ #define __COMPEL_ERRNO_H__ -#define ERESTARTSYS 512 -#define ERESTARTNOINTR 513 -#define ERESTARTNOHAND 514 -#define ERESTART_RESTARTBLOCK 516 +#define ERESTARTSYS 512 +#define ERESTARTNOINTR 513 +#define ERESTARTNOHAND 514 +#define ERESTART_RESTARTBLOCK 516 #endif /* __CR_ERRNO_H__ */ diff --git a/compel/include/infect-priv.h b/compel/include/infect-priv.h index d4f19307d..1c03f4486 100644 --- a/compel/include/infect-priv.h +++ b/compel/include/infect-priv.h @@ -3,64 +3,63 @@ #include -#define BUILTIN_SYSCALL_SIZE 8 +#define BUILTIN_SYSCALL_SIZE 8 struct thread_ctx { - k_rtsigset_t sigmask; - user_regs_struct_t regs; + k_rtsigset_t sigmask; + user_regs_struct_t regs; #ifdef ARCH_HAS_PTRACE_GET_THREAD_AREA - tls_t tls; + tls_t tls; #endif - user_fpregs_struct_t ext_regs; + user_fpregs_struct_t ext_regs; }; /* parasite control block */ struct parasite_ctl { - int rpid; /* Real pid of the victim */ - void *remote_map; - void *local_map; - void *sigreturn_addr; /* A place for the breakpoint */ - unsigned long map_length; + int rpid; /* Real pid of the victim */ + void *remote_map; + void *local_map; + void *sigreturn_addr; /* A place for the breakpoint */ + unsigned long map_length; - struct infect_ctx ictx; + struct infect_ctx ictx; /* thread leader data */ - bool daemonized; + bool daemonized; - struct thread_ctx orig; + struct thread_ctx orig; - void *rstack; /* thread leader stack*/ - struct rt_sigframe *sigframe; - struct rt_sigframe *rsigframe; /* address in a parasite */ + void *rstack; /* thread leader stack*/ + struct rt_sigframe *sigframe; + struct rt_sigframe *rsigframe; /* address in a parasite */ - void *r_thread_stack; /* stack for non-leader threads */ + void *r_thread_stack; /* stack for non-leader threads */ - unsigned long parasite_ip; /* service routine start ip */ + unsigned long parasite_ip; /* service routine start ip */ - unsigned int *cmd; /* address for command */ - void *args; /* address for arguments */ - unsigned long args_size; - int tsock; /* transport socket for transferring fds */ + unsigned int *cmd; /* address for command */ + void *args; /* address for arguments */ + unsigned long args_size; + int tsock; /* transport socket for transferring fds */ struct parasite_blob_desc pblob; }; struct parasite_thread_ctl { - int tid; - struct parasite_ctl *ctl; - struct thread_ctx th; + int tid; + struct parasite_ctl *ctl; + struct thread_ctx th; }; -#define MEMFD_FNAME "CRIUMFD" -#define MEMFD_FNAME_SZ sizeof(MEMFD_FNAME) +#define MEMFD_FNAME "CRIUMFD" +#define MEMFD_FNAME_SZ sizeof(MEMFD_FNAME) struct ctl_msg; int parasite_wait_ack(int sockfd, unsigned int cmd, struct ctl_msg *m); extern void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs); -extern void *remote_mmap(struct parasite_ctl *ctl, - void *addr, size_t length, int prot, - int flags, int fd, off_t offset); +extern void *remote_mmap(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, + off_t offset); extern bool arch_can_dump_task(struct parasite_ctl *ctl); /* * @regs: general purpose registers @@ -70,16 +69,12 @@ extern bool arch_can_dump_task(struct parasite_ctl *ctl); * @flags: see INFECT_* in infect_ctx::flags * @pid: mystery */ -extern 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); +extern 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); extern int compel_set_task_ext_regs(pid_t pid, user_fpregs_struct_t *ext_regs); extern int arch_fetch_sas(struct parasite_ctl *ctl, struct rt_sigframe *s); -extern int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, - user_regs_struct_t *regs, +extern int sigreturn_prep_regs_plain(struct rt_sigframe *sigframe, user_regs_struct_t *regs, user_fpregs_struct_t *fpregs); -extern int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, - struct rt_sigframe *rsigframe); -extern int compel_execute_syscall(struct parasite_ctl *ctl, - user_regs_struct_t *regs, const char *code_syscall); +extern int sigreturn_prep_fpu_frame_plain(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe); +extern int compel_execute_syscall(struct parasite_ctl *ctl, user_regs_struct_t *regs, const char *code_syscall); #endif diff --git a/compel/include/log.h b/compel/include/log.h index 49e65bb50..0e33976b1 100644 --- a/compel/include/log.h +++ b/compel/include/log.h @@ -4,60 +4,47 @@ #include "uapi/compel/log.h" #ifndef LOG_PREFIX -# define LOG_PREFIX +#define LOG_PREFIX #endif static inline int pr_quelled(unsigned int loglevel) { - return compel_log_get_loglevel() < loglevel - && loglevel != COMPEL_LOG_MSG; + return compel_log_get_loglevel() < loglevel && loglevel != COMPEL_LOG_MSG; } -extern void compel_print_on_level(unsigned int loglevel, - const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); +extern void compel_print_on_level(unsigned int loglevel, const char *format, ...) + __attribute__((__format__(__printf__, 2, 3))); -#define pr_msg(fmt, ...) \ - compel_print_on_level(COMPEL_LOG_MSG, \ - fmt, ##__VA_ARGS__) +#define pr_msg(fmt, ...) compel_print_on_level(COMPEL_LOG_MSG, fmt, ##__VA_ARGS__) -#define pr_info(fmt, ...) \ - compel_print_on_level(COMPEL_LOG_INFO, \ - LOG_PREFIX fmt, ##__VA_ARGS__) +#define pr_info(fmt, ...) compel_print_on_level(COMPEL_LOG_INFO, LOG_PREFIX fmt, ##__VA_ARGS__) -#define pr_err(fmt, ...) \ - compel_print_on_level(COMPEL_LOG_ERROR, \ - "Error (%s:%d): " LOG_PREFIX fmt, \ - __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_err(fmt, ...) \ + compel_print_on_level(COMPEL_LOG_ERROR, "Error (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__) -#define pr_err_once(fmt, ...) \ - do { \ - static bool __printed; \ - if (!__printed) { \ - pr_err(fmt, ##__VA_ARGS__); \ - __printed = 1; \ - } \ +#define pr_err_once(fmt, ...) \ + do { \ + static bool __printed; \ + if (!__printed) { \ + pr_err(fmt, ##__VA_ARGS__); \ + __printed = 1; \ + } \ } while (0) -#define pr_warn(fmt, ...) \ - compel_print_on_level(COMPEL_LOG_WARN, \ - "Warn (%s:%d): " LOG_PREFIX fmt, \ - __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_warn(fmt, ...) \ + compel_print_on_level(COMPEL_LOG_WARN, "Warn (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__) -#define pr_warn_once(fmt, ...) \ - do { \ - static bool __printed; \ - if (!__printed) { \ - pr_warn(fmt, ##__VA_ARGS__); \ - __printed = 1; \ - } \ +#define pr_warn_once(fmt, ...) \ + do { \ + static bool __printed; \ + if (!__printed) { \ + pr_warn(fmt, ##__VA_ARGS__); \ + __printed = 1; \ + } \ } while (0) -#define pr_debug(fmt, ...) \ - compel_print_on_level(COMPEL_LOG_DEBUG, \ - LOG_PREFIX fmt, ##__VA_ARGS__) +#define pr_debug(fmt, ...) compel_print_on_level(COMPEL_LOG_DEBUG, LOG_PREFIX fmt, ##__VA_ARGS__) -#define pr_perror(fmt, ...) \ - pr_err(fmt ": %m\n", ##__VA_ARGS__) +#define pr_perror(fmt, ...) pr_err(fmt ": %m\n", ##__VA_ARGS__) #endif /* COMPEL_LOG_H__ */ diff --git a/compel/include/piegen.h b/compel/include/piegen.h index fd72f9c22..d445d5349 100644 --- a/compel/include/piegen.h +++ b/compel/include/piegen.h @@ -9,19 +9,19 @@ #include "common/compiler.h" typedef struct { - char *input_filename; - char *output_filename; - char *prefix; - FILE *fout; + char *input_filename; + char *output_filename; + char *prefix; + FILE *fout; } piegen_opt_t; extern piegen_opt_t opts; -#define pr_out(fmt, ...) \ -do { \ - if (opts.fout) \ - fprintf(opts.fout, fmt, ##__VA_ARGS__); \ -} while (0) +#define pr_out(fmt, ...) \ + do { \ + if (opts.fout) \ + fprintf(opts.fout, fmt, ##__VA_ARGS__); \ + } while (0) extern int handle_binary(void *mem, size_t size); diff --git a/compel/include/ptrace.h b/compel/include/ptrace.h index 01f55c45a..bf2701e63 100644 --- a/compel/include/ptrace.h +++ b/compel/include/ptrace.h @@ -5,7 +5,7 @@ #include #include -#define PTRACE_SI_EVENT(_si_code) (((_si_code) & 0xFFFF) >> 8) +#define PTRACE_SI_EVENT(_si_code) (((_si_code)&0xFFFF) >> 8) extern int ptrace_get_regs(pid_t pid, user_regs_struct_t *regs); extern int ptrace_set_regs(pid_t pid, user_regs_struct_t *regs); diff --git a/compel/include/rpc-pie-priv.h b/compel/include/rpc-pie-priv.h index 15f5b14ca..2a239c613 100644 --- a/compel/include/rpc-pie-priv.h +++ b/compel/include/rpc-pie-priv.h @@ -1,16 +1,22 @@ #ifndef __COMPEL_RPC_H__ #define __COMPEL_RPC_H__ struct ctl_msg { - uint32_t cmd; /* command itself */ - uint32_t ack; /* ack on command */ - int32_t err; /* error code on reply */ + uint32_t cmd; /* command itself */ + uint32_t ack; /* ack on command */ + int32_t err; /* error code on reply */ }; -#define ctl_msg_cmd(_cmd) \ - (struct ctl_msg){.cmd = _cmd, } +#define ctl_msg_cmd(_cmd) \ + (struct ctl_msg) \ + { \ + .cmd = _cmd, \ + } -#define ctl_msg_ack(_cmd, _err) \ - (struct ctl_msg){.cmd = _cmd, .ack = _cmd, .err = _err, } +#define ctl_msg_ack(_cmd, _err) \ + (struct ctl_msg) \ + { \ + .cmd = _cmd, .ack = _cmd, .err = _err, \ + } /* * NOTE: each command's args should be arch-independed sized. @@ -18,7 +24,7 @@ struct ctl_msg { * alternative type for compatible tasks in parasite-compat.h */ enum { - PARASITE_CMD_IDLE = 0, + PARASITE_CMD_IDLE = 0, PARASITE_CMD_ACK, PARASITE_CMD_INIT_DAEMON, @@ -32,19 +38,19 @@ enum { }; struct parasite_init_args { - int32_t h_addr_len; - struct sockaddr_un h_addr; - int32_t log_level; - uint64_t sigreturn_addr; - uint64_t sigframe; /* pointer to sigframe */ - futex_t daemon_connected; + int32_t h_addr_len; + struct sockaddr_un h_addr; + int32_t log_level; + uint64_t sigreturn_addr; + uint64_t sigframe; /* pointer to sigframe */ + futex_t daemon_connected; #ifdef ARCH_HAS_LONG_PAGES - uint32_t page_size; + uint32_t page_size; #endif }; struct parasite_unmap_args { - uint64_t parasite_start; - uint64_t parasite_len; + uint64_t parasite_start; + uint64_t parasite_len; }; #endif diff --git a/compel/include/shmem.h b/compel/include/shmem.h index b6f994617..a38599625 100644 --- a/compel/include/shmem.h +++ b/compel/include/shmem.h @@ -7,4 +7,3 @@ struct shmem_plugin_msg { }; #endif /* __COMPEL_PLUGIN_SHMEM_PRIV_H__ */ - diff --git a/compel/include/uapi/handle-elf.h b/compel/include/uapi/handle-elf.h index ba40be57f..3b6d5bfee 100644 --- a/compel/include/uapi/handle-elf.h +++ b/compel/include/uapi/handle-elf.h @@ -1,22 +1,22 @@ #ifndef __COMPEL_UAPI_HANDLE_ELF__ #define __COMPEL_UAPI_HANDLE_ELF__ -#define COMPEL_TYPE_INT (1u << 0) -#define COMPEL_TYPE_LONG (1u << 1) -#define COMPEL_TYPE_GOTPCREL (1u << 2) +#define COMPEL_TYPE_INT (1u << 0) +#define COMPEL_TYPE_LONG (1u << 1) +#define COMPEL_TYPE_GOTPCREL (1u << 2) #ifdef CONFIG_MIPS -#define COMPEL_TYPE_MIPS_26 (1u << 3) -#define COMPEL_TYPE_MIPS_HI16 (1u << 4) -#define COMPEL_TYPE_MIPS_LO16 (1u << 5) -#define COMPEL_TYPE_MIPS_HIGHER (1u << 6) -#define COMPEL_TYPE_MIPS_HIGHEST (1u << 7) -#define COMPEL_TYPE_MIPS_64 (1u << 8) +#define COMPEL_TYPE_MIPS_26 (1u << 3) +#define COMPEL_TYPE_MIPS_HI16 (1u << 4) +#define COMPEL_TYPE_MIPS_LO16 (1u << 5) +#define COMPEL_TYPE_MIPS_HIGHER (1u << 6) +#define COMPEL_TYPE_MIPS_HIGHEST (1u << 7) +#define COMPEL_TYPE_MIPS_64 (1u << 8) #endif typedef struct { - unsigned int offset; - unsigned int type; - long addend; - long value; + unsigned int offset; + unsigned int type; + long addend; + long value; } compel_reloc_t; #endif diff --git a/compel/include/uapi/infect-rpc.h b/compel/include/uapi/infect-rpc.h index 5fcdb56ff..d0f853859 100644 --- a/compel/include/uapi/infect-rpc.h +++ b/compel/include/uapi/infect-rpc.h @@ -13,7 +13,6 @@ extern int __must_check compel_rpc_call(unsigned int cmd, struct parasite_ctl *c extern int __must_check compel_rpc_call_sync(unsigned int cmd, struct parasite_ctl *ctl); extern int compel_rpc_sock(struct parasite_ctl *ctl); -#define PARASITE_USER_CMDS 64 - +#define PARASITE_USER_CMDS 64 #endif diff --git a/compel/include/uapi/infect.h b/compel/include/uapi/infect.h index 65564ae8f..c3d2ee6a6 100644 --- a/compel/include/uapi/infect.h +++ b/compel/include/uapi/infect.h @@ -11,23 +11,23 @@ #include "common/compiler.h" -#define PARASITE_START_AREA_MIN (4096) +#define PARASITE_START_AREA_MIN (4096) extern int __must_check compel_interrupt_task(int pid); struct seize_task_status { - unsigned long long sigpnd; - unsigned long long shdpnd; - char state; - int vpid; - int ppid; - int seccomp_mode; + unsigned long long sigpnd; + unsigned long long shdpnd; + char state; + int vpid; + int ppid; + int seccomp_mode; }; extern int __must_check compel_wait_task(int pid, int ppid, - int (*get_status)(int pid, struct seize_task_status *, void *data), - void (*free_status)(int pid, struct seize_task_status *, void *data), - struct seize_task_status *st, void *data); + int (*get_status)(int pid, struct seize_task_status *, void *data), + void (*free_status)(int pid, struct seize_task_status *, void *data), + struct seize_task_status *st, void *data); extern int __must_check compel_stop_task(int pid); extern int compel_resume_task(pid_t pid, int orig_state, int state); @@ -37,8 +37,7 @@ struct parasite_thread_ctl; extern struct parasite_ctl __must_check *compel_prepare(int pid); extern struct parasite_ctl __must_check *compel_prepare_noctx(int pid); -extern int __must_check compel_infect(struct parasite_ctl *ctl, - unsigned long nr_threads, unsigned long args_size); +extern int __must_check compel_infect(struct parasite_ctl *ctl, unsigned long nr_threads, unsigned long args_size); extern struct parasite_thread_ctl __must_check *compel_prepare_thread(struct parasite_ctl *ctl, int pid); extern void compel_release_thread(struct parasite_thread_ctl *); @@ -47,27 +46,22 @@ extern int __must_check compel_cure_remote(struct parasite_ctl *ctl); extern int __must_check compel_cure_local(struct parasite_ctl *ctl); extern int __must_check compel_cure(struct parasite_ctl *ctl); -#define PARASITE_ARG_SIZE_MIN ( 1 << 12) +#define PARASITE_ARG_SIZE_MIN (1 << 12) -#define compel_parasite_args(ctl, type) \ - ({ \ - void *___ret; \ - BUILD_BUG_ON(sizeof(type) > PARASITE_ARG_SIZE_MIN); \ - ___ret = compel_parasite_args_p(ctl); \ - ___ret; \ +#define compel_parasite_args(ctl, type) \ + ({ \ + void *___ret; \ + BUILD_BUG_ON(sizeof(type) > PARASITE_ARG_SIZE_MIN); \ + ___ret = compel_parasite_args_p(ctl); \ + ___ret; \ }) extern void *compel_parasite_args_p(struct parasite_ctl *ctl); extern void *compel_parasite_args_s(struct parasite_ctl *ctl, unsigned long args_size); -extern int __must_check 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); +extern int __must_check 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); extern int __must_check compel_run_in_thread(struct parasite_thread_ctl *tctl, unsigned int cmd); extern int __must_check compel_run_at(struct parasite_ctl *ctl, unsigned long ip, user_regs_struct_t *ret_regs); @@ -83,11 +77,9 @@ enum trace_flags { TRACE_EXIT, }; -extern int __must_check compel_stop_on_syscall(int tasks, int sys_nr, - int sys_nr_compat, enum trace_flags trace); +extern int __must_check compel_stop_on_syscall(int tasks, int sys_nr, int sys_nr_compat, enum trace_flags trace); -extern int __must_check compel_stop_pie(pid_t pid, void *addr, - enum trace_flags *tf, bool no_bp); +extern int __must_check compel_stop_pie(pid_t pid, void *addr, enum trace_flags *tf, bool no_bp); extern int __must_check compel_unmap(struct parasite_ctl *ctl, unsigned long addr); @@ -98,69 +90,68 @@ extern k_rtsigset_t *compel_thread_sigmask(struct parasite_thread_ctl *tctl); struct rt_sigframe; -typedef int (*open_proc_fn)(int pid, int mode, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); +typedef int (*open_proc_fn)(int pid, int mode, const char *fmt, ...) __attribute__((__format__(__printf__, 3, 4))); typedef int (*save_regs_t)(void *, user_regs_struct_t *, user_fpregs_struct_t *); typedef int (*make_sigframe_t)(void *, struct rt_sigframe *, struct rt_sigframe *, k_rtsigset_t *); struct infect_ctx { - int sock; + int sock; /* * Regs manipulation context. */ - save_regs_t save_regs; - make_sigframe_t make_sigframe; + save_regs_t save_regs; + make_sigframe_t make_sigframe; void *regs_arg; - unsigned long task_size; - unsigned long syscall_ip; /* entry point of infection */ - unsigned long flags; /* fine-tune (e.g. faults) */ + unsigned long task_size; + unsigned long syscall_ip; /* entry point of infection */ + unsigned long flags; /* fine-tune (e.g. faults) */ - void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */ - struct sigaction orig_handler; + void (*child_handler)(int, siginfo_t *, void *); /* hander for SIGCHLD deaths */ + struct sigaction orig_handler; open_proc_fn open_proc; - int log_fd; /* fd for parasite code to send messages to */ + int log_fd; /* fd for parasite code to send messages to */ }; extern struct infect_ctx *compel_infect_ctx(struct parasite_ctl *); /* Don't use memfd() */ -#define INFECT_NO_MEMFD (1UL << 0) +#define INFECT_NO_MEMFD (1UL << 0) /* Make parasite connect() fail */ -#define INFECT_FAIL_CONNECT (1UL << 1) +#define INFECT_FAIL_CONNECT (1UL << 1) /* No breakpoints in pie tracking */ -#define INFECT_NO_BREAKPOINTS (1UL << 2) +#define INFECT_NO_BREAKPOINTS (1UL << 2) /* Can run parasite inside compat tasks */ -#define INFECT_COMPATIBLE (1UL << 3) +#define INFECT_COMPATIBLE (1UL << 3) /* Workaround for ptrace bug on Skylake CPUs with kernels older than v4.14 */ -#define INFECT_X86_PTRACE_MXCSR_BUG (1UL << 4) +#define INFECT_X86_PTRACE_MXCSR_BUG (1UL << 4) /* After infecting - corrupt extended registers (fault-injection) */ -#define INFECT_CORRUPT_EXTREGS (1UL << 5) +#define INFECT_CORRUPT_EXTREGS (1UL << 5) /* * There are several ways to describe a blob to compel * library. The simplest one derived from criu is to * provide it from .h files. */ -#define COMPEL_BLOB_CHEADER 0x1 +#define COMPEL_BLOB_CHEADER 0x1 struct parasite_blob_desc { - unsigned parasite_type; + unsigned parasite_type; union { struct { - const void *mem; - size_t bsize; - unsigned long parasite_ip_off; - unsigned long cmd_off; - unsigned long args_ptr_off; - unsigned long got_off; - unsigned long args_off; - unsigned long data_off; - compel_reloc_t *relocs; - unsigned int nr_relocs; + const void *mem; + size_t bsize; + unsigned long parasite_ip_off; + unsigned long cmd_off; + unsigned long args_ptr_off; + unsigned long got_off; + unsigned long args_off; + unsigned long data_off; + compel_reloc_t *relocs; + unsigned int nr_relocs; } hdr; }; }; diff --git a/compel/include/uapi/loglevels.h b/compel/include/uapi/loglevels.h index 7bf88475d..e76c15657 100644 --- a/compel/include/uapi/loglevels.h +++ b/compel/include/uapi/loglevels.h @@ -6,15 +6,14 @@ * also by log functions in the std plugin. */ -enum __compel_log_levels -{ - COMPEL_LOG_MSG, /* Print message regardless of log level */ - COMPEL_LOG_ERROR, /* Errors only, when we're in trouble */ - COMPEL_LOG_WARN, /* Warnings */ - COMPEL_LOG_INFO, /* Informative, everything is fine */ - COMPEL_LOG_DEBUG, /* Debug only */ +enum __compel_log_levels { + COMPEL_LOG_MSG, /* Print message regardless of log level */ + COMPEL_LOG_ERROR, /* Errors only, when we're in trouble */ + COMPEL_LOG_WARN, /* Warnings */ + COMPEL_LOG_INFO, /* Informative, everything is fine */ + COMPEL_LOG_DEBUG, /* Debug only */ - COMPEL_DEFAULT_LOGLEVEL = COMPEL_LOG_WARN + COMPEL_DEFAULT_LOGLEVEL = COMPEL_LOG_WARN }; #endif /* UAPI_COMPEL_LOGLEVELS_H__ */ diff --git a/compel/include/uapi/plugins.h b/compel/include/uapi/plugins.h index e9ebfb67f..658c95fc9 100644 --- a/compel/include/uapi/plugins.h +++ b/compel/include/uapi/plugins.h @@ -1,33 +1,31 @@ #ifndef UAPI_COMPEL_PLUGIN_H__ #define UAPI_COMPEL_PLUGIN_H__ -#define __init __attribute__((__used__)) __attribute__ ((__section__(".compel.init"))) -#define __exit __attribute__((__used__)) __attribute__ ((__section__(".compel.exit"))) +#define __init __attribute__((__used__)) __attribute__((__section__(".compel.init"))) +#define __exit __attribute__((__used__)) __attribute__((__section__(".compel.exit"))) #ifndef __ASSEMBLY__ typedef struct { - const char *name; - int (*init)(void); - void (*exit)(void); + const char *name; + int (*init)(void); + void (*exit)(void); } plugin_init_t; -#define plugin_register(___desc) \ - static const plugin_init_t * const \ - ___ptr__##___desc __init = &___desc; +#define plugin_register(___desc) static const plugin_init_t *const ___ptr__##___desc __init = &___desc; -#define PLUGIN_REGISTER(___id, ___name, ___init, ___exit) \ - static const plugin_init_t __plugin_desc_##___id = { \ - .name = ___name, \ - .init = ___init, \ - .exit = ___exit, \ - }; \ +#define PLUGIN_REGISTER(___id, ___name, ___init, ___exit) \ + static const plugin_init_t __plugin_desc_##___id = { \ + .name = ___name, \ + .init = ___init, \ + .exit = ___exit, \ + }; \ plugin_register(__plugin_desc_##___id); -#define PLUGIN_REGISTER_DUMMY(___id) \ - static const plugin_init_t __plugin_desc_##___id = { \ - .name = #___id, \ - }; \ +#define PLUGIN_REGISTER_DUMMY(___id) \ + static const plugin_init_t __plugin_desc_##___id = { \ + .name = #___id, \ + }; \ plugin_register(__plugin_desc_##___id); #endif /* __ASSEMBLY__ */ diff --git a/compel/include/uapi/ptrace.h b/compel/include/uapi/ptrace.h index 13eed7232..c5291d20d 100644 --- a/compel/include/uapi/ptrace.h +++ b/compel/include/uapi/ptrace.h @@ -19,40 +19,40 @@ */ #ifndef PTRACE_SEIZE -# define PTRACE_SEIZE 0x4206 +#define PTRACE_SEIZE 0x4206 #endif #ifndef PTRACE_O_SUSPEND_SECCOMP -# define PTRACE_O_SUSPEND_SECCOMP (1 << 21) +#define PTRACE_O_SUSPEND_SECCOMP (1 << 21) #endif #ifndef PTRACE_INTERRUPT -# define PTRACE_INTERRUPT 0x4207 +#define PTRACE_INTERRUPT 0x4207 #endif #ifndef PTRACE_PEEKSIGINFO -#define PTRACE_PEEKSIGINFO 0x4209 +#define PTRACE_PEEKSIGINFO 0x4209 /* Read signals from a shared (process wide) queue */ -#define PTRACE_PEEKSIGINFO_SHARED (1 << 0) +#define PTRACE_PEEKSIGINFO_SHARED (1 << 0) #endif #ifndef PTRACE_GETREGSET -# define PTRACE_GETREGSET 0x4204 -# define PTRACE_SETREGSET 0x4205 +#define PTRACE_GETREGSET 0x4204 +#define PTRACE_SETREGSET 0x4205 #endif #ifndef PTRACE_GETSIGMASK -# define PTRACE_GETSIGMASK 0x420a -# define PTRACE_SETSIGMASK 0x420b +#define PTRACE_GETSIGMASK 0x420a +#define PTRACE_SETSIGMASK 0x420b #endif #ifndef PTRACE_SECCOMP_GET_FILTER -#define PTRACE_SECCOMP_GET_FILTER 0x420c +#define PTRACE_SECCOMP_GET_FILTER 0x420c #endif #ifndef PTRACE_SECCOMP_GET_METADATA -# define PTRACE_SECCOMP_GET_METADATA 0x420d +#define PTRACE_SECCOMP_GET_METADATA 0x420d #endif /* PTRACE_SECCOMP_GET_METADATA */ /* @@ -61,17 +61,17 @@ * own identical definition for a while. */ typedef struct { - uint64_t filter_off; /* Input: which filter */ - uint64_t flags; /* Output: filter's flags */ + uint64_t filter_off; /* Input: which filter */ + uint64_t flags; /* Output: filter's flags */ } seccomp_metadata_t; #ifdef PTRACE_EVENT_STOP -# if PTRACE_EVENT_STOP == 7 /* Bad value from Linux 3.1-3.3, fixed in 3.4 */ -# undef PTRACE_EVENT_STOP -# endif +#if PTRACE_EVENT_STOP == 7 /* Bad value from Linux 3.1-3.3, fixed in 3.4 */ +#undef PTRACE_EVENT_STOP +#endif #endif #ifndef PTRACE_EVENT_STOP -# define PTRACE_EVENT_STOP 128 +#define PTRACE_EVENT_STOP 128 #endif extern int ptrace_suspend_seccomp(pid_t pid); diff --git a/compel/include/uapi/sigframe-common.h b/compel/include/uapi/sigframe-common.h index 177bf4c48..3062d1d38 100644 --- a/compel/include/uapi/sigframe-common.h +++ b/compel/include/uapi/sigframe-common.h @@ -5,7 +5,7 @@ #define UAPI_COMPEL_SIGFRAME_COMMON_H__ #ifndef UAPI_COMPEL_ASM_SIGFRAME_H__ -# error "Direct inclusion is forbidden, use instead" +#error "Direct inclusion is forbidden, use instead" #endif #include "common/compiler.h" @@ -15,49 +15,47 @@ struct rt_sigframe; #ifndef SIGFRAME_MAX_OFFSET -# define SIGFRAME_MAX_OFFSET RT_SIGFRAME_OFFSET(0) +#define SIGFRAME_MAX_OFFSET RT_SIGFRAME_OFFSET(0) #endif -#define RESTORE_STACK_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define RESTORE_STACK_ALIGN(x, a) (((x) + (a)-1) & ~((a)-1)) /* sigframe should be aligned on 64 byte for x86 and 8 bytes for arm */ -#define RESTORE_STACK_SIGFRAME \ - RESTORE_STACK_ALIGN(sizeof(struct rt_sigframe) + SIGFRAME_MAX_OFFSET, 64) +#define RESTORE_STACK_SIGFRAME RESTORE_STACK_ALIGN(sizeof(struct rt_sigframe) + SIGFRAME_MAX_OFFSET, 64) #ifndef __ARCH_SI_PREAMBLE_SIZE -# define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) +#define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) #endif -#define SI_MAX_SIZE 128 +#define SI_MAX_SIZE 128 #ifndef SI_PAD_SIZE -# define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) +#define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) #endif typedef struct rt_siginfo { - int si_signo; - int si_errno; - int si_code; - int _pad[SI_PAD_SIZE]; + int si_signo; + int si_errno; + int si_code; + int _pad[SI_PAD_SIZE]; } rt_siginfo_t; typedef struct rt_sigaltstack { - void *ss_sp; - int ss_flags; - size_t ss_size; + void *ss_sp; + int ss_flags; + size_t ss_size; } rt_stack_t; struct rt_ucontext { - unsigned long uc_flags; - struct rt_ucontext *uc_link; - rt_stack_t uc_stack; - struct rt_sigcontext uc_mcontext; - k_rtsigset_t uc_sigmask; /* mask last for extensibility */ - int _unused[32 - (sizeof (k_rtsigset_t) / sizeof (int))]; - unsigned long uc_regspace[128] __attribute__((aligned(8))); + unsigned long uc_flags; + struct rt_ucontext *uc_link; + rt_stack_t uc_stack; + struct rt_sigcontext uc_mcontext; + k_rtsigset_t uc_sigmask; /* mask last for extensibility */ + int _unused[32 - (sizeof(k_rtsigset_t) / sizeof(int))]; + unsigned long uc_regspace[128] __attribute__((aligned(8))); }; -extern int __must_check sigreturn_prep_fpu_frame(struct rt_sigframe *frame, - struct rt_sigframe *rframe); +extern int __must_check sigreturn_prep_fpu_frame(struct rt_sigframe *frame, struct rt_sigframe *rframe); #endif /* UAPI_COMPEL_SIGFRAME_COMMON_H__ */ diff --git a/compel/include/uapi/task-state.h b/compel/include/uapi/task-state.h index 84a2a0ba5..ac1baafb5 100644 --- a/compel/include/uapi/task-state.h +++ b/compel/include/uapi/task-state.h @@ -5,15 +5,14 @@ * Task state, as returned by compel_wait_task() * and used in arguments to compel_resume_task(). */ -enum __compel_task_state -{ - COMPEL_TASK_ALIVE = 0x01, - COMPEL_TASK_DEAD = 0x02, - COMPEL_TASK_STOPPED = 0x03, - COMPEL_TASK_ZOMBIE = 0x06, +enum __compel_task_state { + COMPEL_TASK_ALIVE = 0x01, + COMPEL_TASK_DEAD = 0x02, + COMPEL_TASK_STOPPED = 0x03, + COMPEL_TASK_ZOMBIE = 0x06, /* Don't ever change the above values, they are used by CRIU! */ - COMPEL_TASK_MAX = 0x7f + COMPEL_TASK_MAX = 0x7f }; #endif /* __COMPEL_UAPI_TASK_STATE_H__ */ diff --git a/compel/plugins/include/uapi/std/infect.h b/compel/plugins/include/uapi/std/infect.h index 78de781b2..08a5a7a80 100644 --- a/compel/plugins/include/uapi/std/infect.h +++ b/compel/plugins/include/uapi/std/infect.h @@ -6,7 +6,7 @@ extern int parasite_get_rpc_sock(void); extern unsigned int __export_parasite_service_cmd; -extern void * __export_parasite_service_args_ptr; +extern void *__export_parasite_service_args_ptr; extern int __must_check parasite_service(void); /* diff --git a/compel/plugins/include/uapi/std/log.h b/compel/plugins/include/uapi/std/log.h index 91462c85b..0b53567a0 100644 --- a/compel/plugins/include/uapi/std/log.h +++ b/compel/plugins/include/uapi/std/log.h @@ -4,7 +4,7 @@ #include "compel/loglevels.h" #include "common/compiler.h" -#define STD_LOG_SIMPLE_CHUNK 256 +#define STD_LOG_SIMPLE_CHUNK 256 extern void std_log_set_fd(int fd); extern void std_log_set_loglevel(enum __compel_log_levels level); @@ -23,8 +23,8 @@ extern int std_gettimeofday(struct timeval *tv, struct timezone *tz); extern int std_vprint_num(char *buf, int blen, int num, char **ps); extern void std_sprintf(char output[STD_LOG_SIMPLE_CHUNK], const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__((__format__(__printf__, 2, 3))); extern void print_on_level(unsigned int loglevel, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__((__format__(__printf__, 2, 3))); #endif /* COMPEL_PLUGIN_STD_LOG_H__ */ diff --git a/compel/plugins/include/uapi/std/string.h b/compel/plugins/include/uapi/std/string.h index c2e4b9345..1c68cb5f4 100644 --- a/compel/plugins/include/uapi/std/string.h +++ b/compel/plugins/include/uapi/std/string.h @@ -6,20 +6,18 @@ #include /* Standard file descriptors. */ -#define STDIN_FILENO 0 /* Standard input. */ -#define STDOUT_FILENO 1 /* Standard output. */ -#define STDERR_FILENO 2 /* Standard error output. */ - +#define STDIN_FILENO 0 /* Standard input. */ +#define STDOUT_FILENO 1 /* Standard output. */ +#define STDERR_FILENO 2 /* Standard error output. */ extern void std_dputc(int fd, char c); extern void std_dputs(int fd, const char *s); extern void std_vdprintf(int fd, const char *format, va_list args); -extern void std_dprintf(int fd, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); +extern void std_dprintf(int fd, const char *format, ...) __attribute__((__format__(__printf__, 2, 3))); -#define std_printf(fmt, ...) std_dprintf(STDOUT_FILENO, fmt, ##__VA_ARGS__) -#define std_puts(s) std_dputs(STDOUT_FILENO, s) -#define std_putchar(c) std_dputc(STDOUT_FILENO, c) +#define std_printf(fmt, ...) std_dprintf(STDOUT_FILENO, fmt, ##__VA_ARGS__) +#define std_puts(s) std_dputs(STDOUT_FILENO, s) +#define std_putchar(c) std_dputc(STDOUT_FILENO, c) extern unsigned long std_strtoul(const char *nptr, char **endptr, int base); extern int std_strcmp(const char *cs, const char *ct); diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h index 031e773bb..cc1969c01 100644 --- a/compel/plugins/include/uapi/std/syscall-types.h +++ b/compel/plugins/include/uapi/std/syscall-types.h @@ -44,7 +44,7 @@ struct clone_args; typedef unsigned long aio_context_t; #ifndef F_GETFD -# define F_GETFD 1 +#define F_GETFD 1 #endif struct krlimit { @@ -57,7 +57,6 @@ typedef int kernel_timer_t; #include - extern long sys_preadv_raw(int fd, struct iovec *iov, unsigned long nr, unsigned long pos_l, unsigned long pos_h); static inline long sys_preadv(int fd, struct iovec *iov, unsigned long nr, off_t off) @@ -67,7 +66,7 @@ static inline long sys_preadv(int fd, struct iovec *iov, unsigned long nr, off_t #elif BITS_PER_LONG == 32 return sys_preadv_raw(fd, iov, nr, off, ((uint64_t)off) >> 32); #else -# error "BITS_PER_LONG isn't defined" +#error "BITS_PER_LONG isn't defined" #endif } diff --git a/criu/arch/aarch64/include/asm/dump.h b/criu/arch/aarch64/include/asm/dump.h index bc3dbcf3a..90cd8bca8 100644 --- a/criu/arch/aarch64/include/asm/dump.h +++ b/criu/arch/aarch64/include/asm/dump.h @@ -5,7 +5,6 @@ extern int save_task_regs(void *, user_regs_struct_t *, user_fpregs_struct_t *); extern int arch_alloc_thread_info(CoreEntry *core); extern void arch_free_thread_info(CoreEntry *core); - static inline void core_put_tls(CoreEntry *core, tls_t tls) { core->ti_aarch64->tls = tls; diff --git a/criu/arch/aarch64/include/asm/kerndat.h b/criu/arch/aarch64/include/asm/kerndat.h index 60956b573..bb70cf6cf 100644 --- a/criu/arch/aarch64/include/asm/kerndat.h +++ b/criu/arch/aarch64/include/asm/kerndat.h @@ -1,7 +1,7 @@ #ifndef __CR_ASM_KERNDAT_H__ #define __CR_ASM_KERNDAT_H__ -#define kdat_compatible_cr() 0 -#define kdat_can_map_vdso() 0 +#define kdat_compatible_cr() 0 +#define kdat_can_map_vdso() 0 #endif /* __CR_ASM_KERNDAT_H__ */ diff --git a/criu/arch/aarch64/include/asm/parasite.h b/criu/arch/aarch64/include/asm/parasite.h index 2a1e1c12e..cdcbc7909 100644 --- a/criu/arch/aarch64/include/asm/parasite.h +++ b/criu/arch/aarch64/include/asm/parasite.h @@ -4,7 +4,7 @@ static inline void arch_get_tls(tls_t *ptls) { tls_t tls; - asm("mrs %0, tpidr_el0" : "=r" (tls)); + asm("mrs %0, tpidr_el0" : "=r"(tls)); *ptls = tls; } diff --git a/criu/arch/aarch64/include/asm/restore.h b/criu/arch/aarch64/include/asm/restore.h index 3d794ffb5..75e87996a 100644 --- a/criu/arch/aarch64/include/asm/restore.h +++ b/criu/arch/aarch64/include/asm/restore.h @@ -5,6 +5,7 @@ #include "images/core.pb-c.h" +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \ task_args) \ asm volatile( \ @@ -16,13 +17,13 @@ "r"(restore_task_exec_start), \ "r"(task_args) \ : "x0", "memory") +/* clang-format on */ static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) { *ptls = pcore->ti_aarch64->tls; } - int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core); #endif diff --git a/criu/arch/aarch64/include/asm/restorer.h b/criu/arch/aarch64/include/asm/restorer.h index 120fa8fb2..64a9c24eb 100644 --- a/criu/arch/aarch64/include/asm/restorer.h +++ b/criu/arch/aarch64/include/asm/restorer.h @@ -9,6 +9,7 @@ #include +/* clang-format off */ #define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ asm volatile( \ @@ -112,20 +113,25 @@ : \ : "r"(ret) \ : "sp", "x0", "memory") +/* clang-format on */ - -#define arch_map_vdso(map, compat) -1 +#define arch_map_vdso(map, compat) -1 int restore_gpregs(struct rt_sigframe *f, UserAarch64RegsEntry *r); int restore_nonsigframe_gpregs(UserAarch64RegsEntry *r); static inline void restore_tls(tls_t *ptls) { - asm("msr tpidr_el0, %0" : : "r" (*ptls)); + asm("msr tpidr_el0, %0" : : "r"(*ptls)); } -static inline void *alloc_compat_syscall_stack(void) { return NULL; } -static inline void free_compat_syscall_stack(void *stack32) { } +static inline void *alloc_compat_syscall_stack(void) +{ + return NULL; +} +static inline void free_compat_syscall_stack(void *stack32) +{ +} static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h index e79f86698..c860af1cf 100644 --- a/criu/arch/aarch64/include/asm/types.h +++ b/criu/arch/aarch64/include/asm/types.h @@ -12,7 +12,7 @@ #include -#define core_is_compat(core) false +#define core_is_compat(core) false typedef UserAarch64RegsEntry UserRegsEntry; @@ -22,8 +22,14 @@ typedef UserAarch64RegsEntry UserRegsEntry; #define TI_SP(core) ((core)->ti_aarch64->gpregs->sp) -static inline void *decode_pointer(uint64_t v) { return (void*)v; } -static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; } +static inline void *decode_pointer(uint64_t v) +{ + return (void *)v; +} +static inline uint64_t encode_pointer(void *p) +{ + return (uint64_t)p; +} #define AT_VECTOR_SIZE 40 typedef uint64_t auxv_t; diff --git a/criu/arch/aarch64/include/asm/vdso.h b/criu/arch/aarch64/include/asm/vdso.h index 97a2440ee..e77d04cd5 100644 --- a/criu/arch/aarch64/include/asm/vdso.h +++ b/criu/arch/aarch64/include/asm/vdso.h @@ -9,24 +9,20 @@ * This is a minimal amount of symbols * we should support at the moment. */ -#define VDSO_SYMBOL_MAX 4 -#define VDSO_SYMBOL_GTOD 2 +#define VDSO_SYMBOL_MAX 4 +#define VDSO_SYMBOL_GTOD 2 /* * Workaround for VDSO array symbol table's relocation. * XXX: remove when compel/piegen will support aarch64. */ -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \ - const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ - const char* aarch_vdso_symbol3 = "__kernel_gettimeofday"; \ - const char* aarch_vdso_symbol4 = "__kernel_rt_sigreturn"; +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__kernel_clock_getres"; \ + const char *aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ + const char *aarch_vdso_symbol3 = "__kernel_gettimeofday"; \ + const char *aarch_vdso_symbol4 = "__kernel_rt_sigreturn"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, \ - aarch_vdso_symbol3, \ - aarch_vdso_symbol4 +#define ARCH_VDSO_SYMBOLS aarch_vdso_symbol1, aarch_vdso_symbol2, aarch_vdso_symbol3, aarch_vdso_symbol4 extern void write_intraprocedure_branch(unsigned long to, unsigned long from); diff --git a/criu/arch/arm/include/asm/dump.h b/criu/arch/arm/include/asm/dump.h index 2382ba42c..485986065 100644 --- a/criu/arch/arm/include/asm/dump.h +++ b/criu/arch/arm/include/asm/dump.h @@ -5,7 +5,6 @@ extern int save_task_regs(void *, user_regs_struct_t *, user_fpregs_struct_t *); extern int arch_alloc_thread_info(CoreEntry *core); extern void arch_free_thread_info(CoreEntry *core); - static inline void core_put_tls(CoreEntry *core, tls_t tls) { core->ti_arm->tls = tls; diff --git a/criu/arch/arm/include/asm/kerndat.h b/criu/arch/arm/include/asm/kerndat.h index 60956b573..bb70cf6cf 100644 --- a/criu/arch/arm/include/asm/kerndat.h +++ b/criu/arch/arm/include/asm/kerndat.h @@ -1,7 +1,7 @@ #ifndef __CR_ASM_KERNDAT_H__ #define __CR_ASM_KERNDAT_H__ -#define kdat_compatible_cr() 0 -#define kdat_can_map_vdso() 0 +#define kdat_compatible_cr() 0 +#define kdat_can_map_vdso() 0 #endif /* __CR_ASM_KERNDAT_H__ */ diff --git a/criu/arch/arm/include/asm/parasite.h b/criu/arch/arm/include/asm/parasite.h index 7f1e219c6..5911ef6b7 100644 --- a/criu/arch/arm/include/asm/parasite.h +++ b/criu/arch/arm/include/asm/parasite.h @@ -4,7 +4,7 @@ /* kuser_get_tls() kernel-provided user-helper, the address is emulated */ static inline void arch_get_tls(tls_t *ptls) { - *ptls = ((tls_t (*)(void))0xffff0fe0)(); + *ptls = ((tls_t(*)(void))0xffff0fe0)(); } #endif diff --git a/criu/arch/arm/include/asm/restore.h b/criu/arch/arm/include/asm/restore.h index c3b64c5b7..09ff691a5 100644 --- a/criu/arch/arm/include/asm/restore.h +++ b/criu/arch/arm/include/asm/restore.h @@ -5,6 +5,7 @@ #include "images/core.pb-c.h" +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \ task_args) \ asm volatile( \ @@ -17,13 +18,13 @@ "r"(restore_task_exec_start), \ "r"(task_args) \ : "r0", "r1", "memory") +/* clang-format on */ static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) { *ptls = pcore->ti_arm->tls; } - int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core); #endif diff --git a/criu/arch/arm/include/asm/restorer.h b/criu/arch/arm/include/asm/restorer.h index 13ed15b26..d35fda4bc 100644 --- a/criu/arch/arm/include/asm/restorer.h +++ b/criu/arch/arm/include/asm/restorer.h @@ -6,6 +6,7 @@ #include +/* clang-format off */ #define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ asm volatile( \ @@ -108,32 +109,35 @@ : \ : "r"(ret) \ : "memory") +/* clang-format on */ - -#define arch_map_vdso(map, compat) -1 +#define arch_map_vdso(map, compat) -1 int restore_gpregs(struct rt_sigframe *f, UserArmRegsEntry *r); int restore_nonsigframe_gpregs(UserArmRegsEntry *r); #define ARCH_HAS_SHMAT_HOOK -unsigned long arch_shmat(int shmid, void *shmaddr, - int shmflg, unsigned long size); +unsigned long arch_shmat(int shmid, void *shmaddr, int shmflg, unsigned long size); -static inline void restore_tls(tls_t *ptls) { - asm ( - "mov r7, #15 \n" - "lsl r7, #16 \n" - "mov r0, #5 \n" - "add r7, r0 \n" /* r7 = 0xF005 */ - "ldr r0, [%0] \n" - "svc #0 \n" - : - : "r"(ptls) - : "r0", "r7" - ); +static inline void restore_tls(tls_t *ptls) +{ + asm("mov r7, #15 \n" + "lsl r7, #16 \n" + "mov r0, #5 \n" + "add r7, r0 \n" /* r7 = 0xF005 */ + "ldr r0, [%0] \n" + "svc #0 \n" + : + : "r"(ptls) + : "r0", "r7"); } -static inline void *alloc_compat_syscall_stack(void) { return NULL; } -static inline void free_compat_syscall_stack(void *stack32) { } +static inline void *alloc_compat_syscall_stack(void) +{ + return NULL; +} +static inline void free_compat_syscall_stack(void *stack32) +{ +} static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h index 32612a692..cfcb8a136 100644 --- a/criu/arch/arm/include/asm/types.h +++ b/criu/arch/arm/include/asm/types.h @@ -11,7 +11,7 @@ #include -#define core_is_compat(core) false +#define core_is_compat(core) false typedef UserArmRegsEntry UserRegsEntry; @@ -21,10 +21,16 @@ typedef UserArmRegsEntry UserRegsEntry; #define TI_SP(core) ((core)->ti_arm->gpregs->sp) -static inline void *decode_pointer(u64 v) { return (void*)(u32)v; } -static inline u64 encode_pointer(void *p) { return (u32)p; } +static inline void *decode_pointer(u64 v) +{ + return (void *)(u32)v; +} +static inline u64 encode_pointer(void *p) +{ + return (u32)p; +} -#define AT_VECTOR_SIZE 40 +#define AT_VECTOR_SIZE 40 typedef uint32_t auxv_t; typedef uint32_t tls_t; diff --git a/criu/arch/arm/include/asm/vdso.h b/criu/arch/arm/include/asm/vdso.h index e96514e0e..5787bfe17 100644 --- a/criu/arch/arm/include/asm/vdso.h +++ b/criu/arch/arm/include/asm/vdso.h @@ -9,13 +9,11 @@ * * Poke from kernel file arch/arm/vdso/vdso.lds.S */ -#define VDSO_SYMBOL_MAX 2 -#define VDSO_SYMBOL_GTOD 1 -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ - const char* aarch_vdso_symbol2 = "__vdso_gettimeofday"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, +#define VDSO_SYMBOL_MAX 2 +#define VDSO_SYMBOL_GTOD 1 +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ + const char *aarch_vdso_symbol2 = "__vdso_gettimeofday"; +#define ARCH_VDSO_SYMBOLS aarch_vdso_symbol1, aarch_vdso_symbol2, #endif /* __CR_ASM_VDSO_H__ */ diff --git a/criu/arch/mips/include/asm/kerndat.h b/criu/arch/mips/include/asm/kerndat.h index 60956b573..bb70cf6cf 100644 --- a/criu/arch/mips/include/asm/kerndat.h +++ b/criu/arch/mips/include/asm/kerndat.h @@ -1,7 +1,7 @@ #ifndef __CR_ASM_KERNDAT_H__ #define __CR_ASM_KERNDAT_H__ -#define kdat_compatible_cr() 0 -#define kdat_can_map_vdso() 0 +#define kdat_compatible_cr() 0 +#define kdat_can_map_vdso() 0 #endif /* __CR_ASM_KERNDAT_H__ */ diff --git a/criu/arch/mips/include/asm/restore.h b/criu/arch/mips/include/asm/restore.h index 04a9551a0..c40b46999 100644 --- a/criu/arch/mips/include/asm/restore.h +++ b/criu/arch/mips/include/asm/restore.h @@ -4,6 +4,7 @@ #include "asm/restorer.h" #include "images/core.pb-c.h" +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, task_args) \ asm volatile( \ "move $4, %0 \n" \ @@ -16,13 +17,13 @@ :"r"(task_args),"r"(restore_task_exec_start), \ "g"(new_sp) \ : "$25", "$4","$5") +/* clang-format on */ static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) { *ptls = pcore->ti_mips->tls; } - int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core); #endif diff --git a/criu/arch/mips/include/asm/restorer.h b/criu/arch/mips/include/asm/restorer.h index 28a9c523f..ac4258eae 100644 --- a/criu/arch/mips/include/asm/restorer.h +++ b/criu/arch/mips/include/asm/restorer.h @@ -7,14 +7,16 @@ #include #include -static inline void restore_tls(tls_t *ptls) { - asm volatile( - "move $4, %0 \n" - "li $2, "__stringify(__NR_set_thread_area)" \n" - "syscall \n" +static inline void restore_tls(tls_t *ptls) +{ + /* clang-format off */ + asm volatile("move $4, %0 \n" + "li $2, " __stringify(__NR_set_thread_area) " \n" + "syscall \n" : : "r"(*ptls) - : "$4","$2","memory"); + : "$4", "$2", "memory"); + /* clang-format on */ } static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { @@ -25,6 +27,7 @@ static inline int set_compat_robust_list(uint32_t head_ptr, uint32_t len) return -1; } +/* clang-format off */ #define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ asm volatile( \ @@ -67,17 +70,22 @@ static inline int set_compat_robust_list(uint32_t head_ptr, uint32_t len) pr_err("This architecture does not support clone3() with set_tid, yet!\n"); \ ret = -1; \ } while (0) +/* clang-format on */ -#define kdat_compatible_cr() 0 -#define arch_map_vdso(map, compat) -1 +#define kdat_compatible_cr() 0 +#define arch_map_vdso(map, compat) -1 -static inline void *alloc_compat_syscall_stack(void) { return NULL; } -static inline void free_compat_syscall_stack(void *stack32) { } +static inline void *alloc_compat_syscall_stack(void) +{ + return NULL; +} +static inline void free_compat_syscall_stack(void *stack32) +{ +} int restore_gpregs(struct rt_sigframe *f, UserMipsRegsEntry *r); int restore_nonsigframe_gpregs(UserMipsRegsEntry *r); #define ARCH_HAS_SHMAT_HOOK -unsigned long arch_shmat(int shmid, void *shmaddr, - int shmflg, unsigned long size); +unsigned long arch_shmat(int shmid, void *shmaddr, int shmflg, unsigned long size); #endif diff --git a/criu/arch/mips/include/asm/types.h b/criu/arch/mips/include/asm/types.h index 8366e0540..237471f3c 100644 --- a/criu/arch/mips/include/asm/types.h +++ b/criu/arch/mips/include/asm/types.h @@ -12,7 +12,7 @@ #include "images/core.pb-c.h" -#define core_is_compat(core) false +#define core_is_compat(core) false #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__MIPS @@ -20,11 +20,16 @@ typedef UserMipsRegsEntry UserRegsEntry; -static inline u64 encode_pointer(void *p) { return (u64)p; } -static inline void *decode_pointer(u64 v) { return (void*)v; } +static inline u64 encode_pointer(void *p) +{ + return (u64)p; +} +static inline void *decode_pointer(u64 v) +{ + return (void *)v; +} - -#define AT_VECTOR_SIZE 44 +#define AT_VECTOR_SIZE 44 typedef uint64_t auxv_t; typedef unsigned long tls_t; diff --git a/criu/arch/mips/include/asm/vdso.h b/criu/arch/mips/include/asm/vdso.h index c3e9b0176..294c369ca 100644 --- a/criu/arch/mips/include/asm/vdso.h +++ b/criu/arch/mips/include/asm/vdso.h @@ -12,16 +12,12 @@ * This is a minimal amount of symbols * we should support at the moment. */ -#define VDSO_SYMBOL_MAX 3 -#define VDSO_SYMBOL_GTOD 0 -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ - const char* aarch_vdso_symbol2 = "__vdso_gettimeofday"; \ - const char* aarch_vdso_symbol3 = "__vdso_clock_getres"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, \ - aarch_vdso_symbol3, - +#define VDSO_SYMBOL_MAX 3 +#define VDSO_SYMBOL_GTOD 0 +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ + const char *aarch_vdso_symbol2 = "__vdso_gettimeofday"; \ + const char *aarch_vdso_symbol3 = "__vdso_clock_getres"; +#define ARCH_VDSO_SYMBOLS aarch_vdso_symbol1, aarch_vdso_symbol2, aarch_vdso_symbol3, #endif /* __CR_ASM_VDSO_H__ */ diff --git a/criu/arch/ppc64/include/asm/dump.h b/criu/arch/ppc64/include/asm/dump.h index a81ee02bd..eb488900a 100644 --- a/criu/arch/ppc64/include/asm/dump.h +++ b/criu/arch/ppc64/include/asm/dump.h @@ -5,7 +5,6 @@ extern int save_task_regs(void *, user_regs_struct_t *, user_fpregs_struct_t *); extern int arch_alloc_thread_info(CoreEntry *core); extern void arch_free_thread_info(CoreEntry *core); - #define core_put_tls(core, tls) #define get_task_futex_robust_list_compat(pid, info) -1 diff --git a/criu/arch/ppc64/include/asm/kerndat.h b/criu/arch/ppc64/include/asm/kerndat.h index 60956b573..bb70cf6cf 100644 --- a/criu/arch/ppc64/include/asm/kerndat.h +++ b/criu/arch/ppc64/include/asm/kerndat.h @@ -1,7 +1,7 @@ #ifndef __CR_ASM_KERNDAT_H__ #define __CR_ASM_KERNDAT_H__ -#define kdat_compatible_cr() 0 -#define kdat_can_map_vdso() 0 +#define kdat_compatible_cr() 0 +#define kdat_can_map_vdso() 0 #endif /* __CR_ASM_KERNDAT_H__ */ diff --git a/criu/arch/ppc64/include/asm/parasite.h b/criu/arch/ppc64/include/asm/parasite.h index fdbc340b0..45cfc632d 100644 --- a/criu/arch/ppc64/include/asm/parasite.h +++ b/criu/arch/ppc64/include/asm/parasite.h @@ -2,6 +2,9 @@ #define __ASM_PARASITE_H__ /* TLS is accessed through r13, which is already processed */ -static inline void arch_get_tls(tls_t *ptls) { (void)ptls; } +static inline void arch_get_tls(tls_t *ptls) +{ + (void)ptls; +} #endif diff --git a/criu/arch/ppc64/include/asm/restore.h b/criu/arch/ppc64/include/asm/restore.h index f065ec3a0..8148015fd 100644 --- a/criu/arch/ppc64/include/asm/restore.h +++ b/criu/arch/ppc64/include/asm/restore.h @@ -9,6 +9,7 @@ * Set R2 to blob + 8000 which is the default value * Jump to restore_task_exec_start + 8 since R2 is already set (local call) */ +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \ task_args) \ asm volatile( \ @@ -22,6 +23,7 @@ "r"((unsigned long)restore_task_exec_start), \ "r"(task_args) \ : "3", "12") +/* clang-format on */ /* There is nothing to do since TLS is accessed through r13 */ #define core_get_tls(pcore, ptls) diff --git a/criu/arch/ppc64/include/asm/restorer.h b/criu/arch/ppc64/include/asm/restorer.h index c447eefea..1ca91140b 100644 --- a/criu/arch/ppc64/include/asm/restorer.h +++ b/criu/arch/ppc64/include/asm/restorer.h @@ -14,9 +14,10 @@ * * See glibc sysdeps/powerpc/powerpc64/sysdep.h for FRAME_MIN_SIZE defines */ -#define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ +/* clang-format off */ +#define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ - asm volatile( \ + asm volatile( \ "clone_emul: \n" \ "/* Save fn, args, stack across syscall. */ \n" \ "mr 14, %5 /* clone_restore_fn in r14 */ \n" \ @@ -88,22 +89,31 @@ "r"(clone_restore_fn), /* %3 */ \ "r"(args) /* %4 */ \ : "memory","0","3","4","5","14","15") +/* clang-format on */ -#define arch_map_vdso(map, compat) -1 +#define arch_map_vdso(map, compat) -1 int restore_gpregs(struct rt_sigframe *f, UserPpc64RegsEntry *r); int restore_nonsigframe_gpregs(UserPpc64RegsEntry *r); /* Nothing to do, TLS is accessed through r13 */ -static inline void restore_tls(tls_t *ptls) { (void)ptls; } +static inline void restore_tls(tls_t *ptls) +{ + (void)ptls; +} /* * Defined in arch/ppc64/syscall-common-ppc64.S */ unsigned long sys_shmat(int shmid, const void *shmaddr, int shmflg); -static inline void *alloc_compat_syscall_stack(void) { return NULL; } -static inline void free_compat_syscall_stack(void *stack32) { } +static inline void *alloc_compat_syscall_stack(void) +{ + return NULL; +} +static inline void free_compat_syscall_stack(void *stack32) +{ +} static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h index 8f3af86a9..fedeff22a 100644 --- a/criu/arch/ppc64/include/asm/types.h +++ b/criu/arch/ppc64/include/asm/types.h @@ -13,14 +13,20 @@ typedef UserPpc64RegsEntry UserRegsEntry; -#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__PPC64 +#define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__PPC64 -#define core_is_compat(core) false +#define core_is_compat(core) false #define CORE_THREAD_ARCH_INFO(core) core->ti_ppc64 -static inline void *decode_pointer(uint64_t v) { return (void*)v; } -static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; } +static inline void *decode_pointer(uint64_t v) +{ + return (void *)v; +} +static inline uint64_t encode_pointer(void *p) +{ + return (uint64_t)p; +} /* * Copied from the following kernel header files : @@ -28,11 +34,11 @@ static inline uint64_t encode_pointer(void *p) { return (uint64_t)p; } * arch/powerpc/include/uapi/asm/auxvec.h * include/linux/mm_types.h */ -#define AT_VECTOR_SIZE_BASE 20 +#define AT_VECTOR_SIZE_BASE 20 #if !defined AT_VECTOR_SIZE_ARCH -#define AT_VECTOR_SIZE_ARCH 6 +#define AT_VECTOR_SIZE_ARCH 6 #endif -#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) +#define AT_VECTOR_SIZE (2 * (AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) typedef uint64_t auxv_t; diff --git a/criu/arch/ppc64/include/asm/vdso.h b/criu/arch/ppc64/include/asm/vdso.h index fe0433665..b73927bb6 100644 --- a/criu/arch/ppc64/include/asm/vdso.h +++ b/criu/arch/ppc64/include/asm/vdso.h @@ -12,30 +12,22 @@ * Note that '__kernel_datapage_offset' is not a service but mostly a data * inside the text page which should not be used as is from user space. */ -#define VDSO_SYMBOL_MAX 10 -#define VDSO_SYMBOL_GTOD 5 -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__kernel_clock_getres"; \ - const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ - const char* aarch_vdso_symbol3 = "__kernel_get_syscall_map"; \ - const char* aarch_vdso_symbol4 = "__kernel_get_tbfreq"; \ - const char* aarch_vdso_symbol5 = "__kernel_getcpu"; \ - const char* aarch_vdso_symbol6 = "__kernel_gettimeofday"; \ - const char* aarch_vdso_symbol7 = "__kernel_sigtramp_rt64"; \ - const char* aarch_vdso_symbol8 = "__kernel_sync_dicache"; \ - const char* aarch_vdso_symbol9 = "__kernel_sync_dicache_p5"; \ - const char* aarch_vdso_symbol10 = "__kernel_time"; +#define VDSO_SYMBOL_MAX 10 +#define VDSO_SYMBOL_GTOD 5 +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__kernel_clock_getres"; \ + const char *aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ + const char *aarch_vdso_symbol3 = "__kernel_get_syscall_map"; \ + const char *aarch_vdso_symbol4 = "__kernel_get_tbfreq"; \ + const char *aarch_vdso_symbol5 = "__kernel_getcpu"; \ + const char *aarch_vdso_symbol6 = "__kernel_gettimeofday"; \ + const char *aarch_vdso_symbol7 = "__kernel_sigtramp_rt64"; \ + const char *aarch_vdso_symbol8 = "__kernel_sync_dicache"; \ + const char *aarch_vdso_symbol9 = "__kernel_sync_dicache_p5"; \ + const char *aarch_vdso_symbol10 = "__kernel_time"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, \ - aarch_vdso_symbol3, \ - aarch_vdso_symbol4, \ - aarch_vdso_symbol5, \ - aarch_vdso_symbol6, \ - aarch_vdso_symbol7, \ - aarch_vdso_symbol8, \ - aarch_vdso_symbol9, \ - aarch_vdso_symbol10 +#define ARCH_VDSO_SYMBOLS \ + aarch_vdso_symbol1, aarch_vdso_symbol2, aarch_vdso_symbol3, aarch_vdso_symbol4, aarch_vdso_symbol5, \ + aarch_vdso_symbol6, aarch_vdso_symbol7, aarch_vdso_symbol8, aarch_vdso_symbol9, aarch_vdso_symbol10 #endif /* __CR_ASM_VDSO_H__ */ diff --git a/criu/arch/s390/include/asm/dump.h b/criu/arch/s390/include/asm/dump.h index 53aaac9c4..c200724d7 100644 --- a/criu/arch/s390/include/asm/dump.h +++ b/criu/arch/s390/include/asm/dump.h @@ -5,7 +5,9 @@ int save_task_regs(void *arg, user_regs_struct_t *u, user_fpregs_struct_t *f); int arch_alloc_thread_info(CoreEntry *core); void arch_free_thread_info(CoreEntry *core); -static inline void core_put_tls(CoreEntry *core, tls_t tls) { } +static inline void core_put_tls(CoreEntry *core, tls_t tls) +{ +} #define get_task_futex_robust_list_compat(pid, info) -1 diff --git a/criu/arch/s390/include/asm/kerndat.h b/criu/arch/s390/include/asm/kerndat.h index 60956b573..bb70cf6cf 100644 --- a/criu/arch/s390/include/asm/kerndat.h +++ b/criu/arch/s390/include/asm/kerndat.h @@ -1,7 +1,7 @@ #ifndef __CR_ASM_KERNDAT_H__ #define __CR_ASM_KERNDAT_H__ -#define kdat_compatible_cr() 0 -#define kdat_can_map_vdso() 0 +#define kdat_compatible_cr() 0 +#define kdat_can_map_vdso() 0 #endif /* __CR_ASM_KERNDAT_H__ */ diff --git a/criu/arch/s390/include/asm/parasite.h b/criu/arch/s390/include/asm/parasite.h index 0b0268936..752753023 100644 --- a/criu/arch/s390/include/asm/parasite.h +++ b/criu/arch/s390/include/asm/parasite.h @@ -2,6 +2,9 @@ #define __ASM_PARASITE_H__ /* TLS is accessed through %a01, which is already processed */ -static inline void arch_get_tls(tls_t *ptls) { (void)ptls; } +static inline void arch_get_tls(tls_t *ptls) +{ + (void)ptls; +} #endif diff --git a/criu/arch/s390/include/asm/restore.h b/criu/arch/s390/include/asm/restore.h index b77e36c77..07ff49246 100644 --- a/criu/arch/s390/include/asm/restore.h +++ b/criu/arch/s390/include/asm/restore.h @@ -7,6 +7,7 @@ /* * Load stack to %r15, return address in %r14 and argument 1 into %r2 */ +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \ task_args) \ asm volatile( \ @@ -19,6 +20,7 @@ "d"((unsigned long)restore_task_exec_start), \ "d" (task_args) \ : "2", "14", "memory") +/* clang-format on */ /* There is nothing to do since TLS is accessed through %a01 */ #define core_get_tls(pcore, ptls) diff --git a/criu/arch/s390/include/asm/restorer.h b/criu/arch/s390/include/asm/restorer.h index 2fc266535..668f9a413 100644 --- a/criu/arch/s390/include/asm/restorer.h +++ b/criu/arch/s390/include/asm/restorer.h @@ -11,6 +11,7 @@ /* * Clone trampoline - see glibc sysdeps/unix/sysv/linux/s390/s390-64/clone.S */ +/* clang-format off */ #define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ asm volatile( \ @@ -75,20 +76,28 @@ "d"(clone_restore_fn), \ "d"(args) \ : "0", "1", "2", "3", "4", "5", "cc", "memory") +/* clang-format on */ -#define arch_map_vdso(map, compat) -1 +#define arch_map_vdso(map, compat) -1 int restore_gpregs(struct rt_sigframe *f, UserS390RegsEntry *r); int restore_nonsigframe_gpregs(UserS390RegsEntry *r); unsigned long sys_shmat(int shmid, const void *shmaddr, int shmflg); -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); -static inline void restore_tls(tls_t *ptls) { (void)ptls; } -static inline void *alloc_compat_syscall_stack(void) { return NULL; } -static inline void free_compat_syscall_stack(void *stack32) { } +static inline void restore_tls(tls_t *ptls) +{ + (void)ptls; +} +static inline void *alloc_compat_syscall_stack(void) +{ + return NULL; +} +static inline void free_compat_syscall_stack(void *stack32) +{ +} static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; diff --git a/criu/arch/s390/include/asm/types.h b/criu/arch/s390/include/asm/types.h index 4f36c1309..7522cf2cd 100644 --- a/criu/arch/s390/include/asm/types.h +++ b/criu/arch/s390/include/asm/types.h @@ -15,21 +15,27 @@ typedef UserS390RegsEntry UserRegsEntry; #define CORE_ENTRY__MARCH CORE_ENTRY__MARCH__S390 -#define core_is_compat(core) false +#define core_is_compat(core) false #define CORE_THREAD_ARCH_INFO(core) core->ti_s390 -static inline u64 encode_pointer(void *p) { return (u64) p; } -static inline void *decode_pointer(u64 v) { return (void *) v; } +static inline u64 encode_pointer(void *p) +{ + return (u64)p; +} +static inline void *decode_pointer(u64 v) +{ + return (void *)v; +} /* * See also: * * arch/s390/include/uapi/asm/auxvec.h * * include/linux/auxvec.h */ -#define AT_VECTOR_SIZE_BASE 20 -#define AT_VECTOR_SIZE_ARCH 1 -#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) +#define AT_VECTOR_SIZE_BASE 20 +#define AT_VECTOR_SIZE_ARCH 1 +#define AT_VECTOR_SIZE (2 * (AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1)) typedef uint64_t auxv_t; typedef uint64_t tls_t; diff --git a/criu/arch/s390/include/asm/vdso.h b/criu/arch/s390/include/asm/vdso.h index ac71f5981..72b3dca97 100644 --- a/criu/arch/s390/include/asm/vdso.h +++ b/criu/arch/s390/include/asm/vdso.h @@ -8,22 +8,18 @@ * This is a minimal amount of symbols * we should support at the moment. */ -#define VDSO_SYMBOL_MAX 4 -#define VDSO_SYMBOL_GTOD 0 +#define VDSO_SYMBOL_MAX 4 +#define VDSO_SYMBOL_GTOD 0 /* * These definitions are used in pie/util-vdso.c to initialize the vdso symbol * name string table 'vdso_symbols' */ -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__kernel_gettimeofday"; \ - const char* aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ - const char* aarch_vdso_symbol3 = "__kernel_clock_getres"; \ - const char* aarch_vdso_symbol4 = "__kernel_getcpu"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, \ - aarch_vdso_symbol3, \ - aarch_vdso_symbol4 +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__kernel_gettimeofday"; \ + const char *aarch_vdso_symbol2 = "__kernel_clock_gettime"; \ + const char *aarch_vdso_symbol3 = "__kernel_clock_getres"; \ + const char *aarch_vdso_symbol4 = "__kernel_getcpu"; +#define ARCH_VDSO_SYMBOLS aarch_vdso_symbol1, aarch_vdso_symbol2, aarch_vdso_symbol3, aarch_vdso_symbol4 #endif /* __CR_ASM_VDSO_H__ */ diff --git a/criu/arch/x86/include/asm/compat.h b/criu/arch/x86/include/asm/compat.h index acd552fb3..867357fa2 100644 --- a/criu/arch/x86/include/asm/compat.h +++ b/criu/arch/x86/include/asm/compat.h @@ -2,19 +2,19 @@ #define __CR_ASM_COMPAT_H__ #ifdef CR_NOGLIBC -# include -# include +#include +#include #else -# define sys_mmap mmap -# define sys_munmap munmap +#define sys_mmap mmap +#define sys_munmap munmap #endif #include static inline void *alloc_compat_syscall_stack(void) { - void *mem = (void*)sys_mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, - MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + void *mem = (void *)sys_mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_32BIT | MAP_ANONYMOUS | MAP_PRIVATE, + -1, 0); if ((uintptr_t)mem % PAGE_SIZE) { int err = (~(uint32_t)(uintptr_t)mem) + 1; @@ -30,8 +30,7 @@ static inline void free_compat_syscall_stack(void *mem) long int ret = sys_munmap(mem, PAGE_SIZE); if (ret) - pr_err("munmap() of compat addr %p failed with %ld\n", - mem, ret); + pr_err("munmap() of compat addr %p failed with %ld\n", mem, ret); } struct syscall_args32 { @@ -65,23 +64,22 @@ static inline uint32_t do_full_int80(struct syscall_args32 *args) */ uint32_t ret; - asm volatile ("sub $128, %%rsp\n\t" - "pushq %%rbp\n\t" - "mov %7, %%ebp\n\t" - "int $0x80\n\t" - "popq %%rbp\n\t" - "add $128, %%rsp\n\t" - : "=a" (ret) - : "a" (args->nr), - "b" (args->arg0), "c" (args->arg1), "d" (args->arg2), - "S" (args->arg3), "D" (args->arg4), "g" (args->arg5) - : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); + asm volatile("sub $128, %%rsp\n\t" + "pushq %%rbp\n\t" + "mov %7, %%ebp\n\t" + "int $0x80\n\t" + "popq %%rbp\n\t" + "add $128, %%rsp\n\t" + : "=a"(ret) + : "a"(args->nr), "b"(args->arg0), "c"(args->arg1), "d"(args->arg2), "S"(args->arg3), + "D"(args->arg4), "g"(args->arg5) + : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); return ret; } #ifndef CR_NOGLIBC -# undef sys_mmap -# undef sys_munmap +#undef sys_mmap +#undef sys_munmap #endif #endif diff --git a/criu/arch/x86/include/asm/dump.h b/criu/arch/x86/include/asm/dump.h index c79e0dfa9..03715e003 100644 --- a/criu/arch/x86/include/asm/dump.h +++ b/criu/arch/x86/include/asm/dump.h @@ -11,8 +11,7 @@ static inline void core_put_tls(CoreEntry *core, tls_t tls) ThreadInfoX86 *ti = core->thread_info; int i; - for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) - { + for (i = 0; i < GDT_ENTRY_TLS_NUM; i++) { user_desc_t *from = &tls.desc[i]; UserDescT *to = ti->tls[i]; diff --git a/criu/arch/x86/include/asm/parasite.h b/criu/arch/x86/include/asm/parasite.h index 678fc75e2..7064f1df1 100644 --- a/criu/arch/x86/include/asm/parasite.h +++ b/criu/arch/x86/include/asm/parasite.h @@ -5,6 +5,9 @@ * TLS is accessed through PTRACE_GET_THREAD_AREA, * see compel_arch_fetch_thread_area(). */ -static inline void arch_get_tls(tls_t *ptls) { (void)ptls; } +static inline void arch_get_tls(tls_t *ptls) +{ + (void)ptls; +} #endif diff --git a/criu/arch/x86/include/asm/restore.h b/criu/arch/x86/include/asm/restore.h index 21787a7c8..7cb725d98 100644 --- a/criu/arch/x86/include/asm/restore.h +++ b/criu/arch/x86/include/asm/restore.h @@ -5,6 +5,7 @@ #include "images/core.pb-c.h" +/* clang-format off */ #define JUMP_TO_RESTORER_BLOB(new_sp, restore_task_exec_start, \ task_args) \ asm volatile( \ @@ -18,6 +19,7 @@ "g"(restore_task_exec_start), \ "g"(task_args) \ : "rdi", "rsi", "rbx", "rax", "memory") +/* clang-format on */ static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) { @@ -52,7 +54,6 @@ static inline void core_get_tls(CoreEntry *pcore, tls_t *ptls) } } - int restore_fpu(struct rt_sigframe *sigframe, CoreEntry *core); #endif diff --git a/criu/arch/x86/include/asm/restorer.h b/criu/arch/x86/include/asm/restorer.h index 6ba074020..23438314f 100644 --- a/criu/arch/x86/include/asm/restorer.h +++ b/criu/arch/x86/include/asm/restorer.h @@ -11,11 +11,12 @@ #ifdef CONFIG_COMPAT extern void restore_tls(tls_t *ptls); -extern int arch_compat_rt_sigaction(void *stack32, int sig, - rt_sigaction_t_compat *act); +extern int arch_compat_rt_sigaction(void *stack32, int sig, rt_sigaction_t_compat *act); extern int set_compat_robust_list(uint32_t head_ptr, uint32_t len); #else /* CONFIG_COMPAT */ -static inline void restore_tls(tls_t *ptls) { } +static inline void restore_tls(tls_t *ptls) +{ +} static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) { return -1; @@ -41,6 +42,7 @@ static inline int set_compat_robust_list(uint32_t head_ptr, uint32_t len) * unsigned long tls); */ +/* clang-format off */ #define RUN_CLONE_RESTORE_FN(ret, clone_flags, new_sp, parent_tid, \ thread_args, clone_restore_fn) \ asm volatile( \ @@ -143,7 +145,7 @@ static inline int set_compat_robust_list(uint32_t head_ptr, uint32_t len) */ \ \ "clone3_end: \n" \ - : "=r"(ret) \ + : "=r"(ret) \ /* * This uses the "r" modifier for all parameters * as clang complained if using "g". @@ -164,30 +166,29 @@ static inline int set_compat_robust_list(uint32_t head_ptr, uint32_t len) : \ : "r"(ret) \ : "memory") +/* clang-format on */ -static inline void -__setup_sas_compat(struct ucontext_ia32* uc, ThreadSasEntry *sas) +static inline void __setup_sas_compat(struct ucontext_ia32 *uc, ThreadSasEntry *sas) { - uc->uc_stack.ss_sp = (compat_uptr_t)(sas)->ss_sp; - uc->uc_stack.ss_flags = (int)(sas)->ss_flags; - uc->uc_stack.ss_size = (compat_size_t)(sas)->ss_size; + uc->uc_stack.ss_sp = (compat_uptr_t)(sas)->ss_sp; + uc->uc_stack.ss_flags = (int)(sas)->ss_flags; + uc->uc_stack.ss_size = (compat_size_t)(sas)->ss_size; } -static inline void -__setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas) +static inline void __setup_sas(struct rt_sigframe *sigframe, ThreadSasEntry *sas) { if (sigframe->is_native) { - struct rt_ucontext *uc = &sigframe->native.uc; + struct rt_ucontext *uc = &sigframe->native.uc; - uc->uc_stack.ss_sp = (void *)decode_pointer((sas)->ss_sp); - uc->uc_stack.ss_flags = (int)(sas)->ss_flags; - uc->uc_stack.ss_size = (size_t)(sas)->ss_size; + uc->uc_stack.ss_sp = (void *)decode_pointer((sas)->ss_sp); + uc->uc_stack.ss_flags = (int)(sas)->ss_flags; + uc->uc_stack.ss_size = (size_t)(sas)->ss_size; } else { __setup_sas_compat(&sigframe->compat.uc, sas); } } -static inline void _setup_sas(struct rt_sigframe* sigframe, ThreadSasEntry *sas) +static inline void _setup_sas(struct rt_sigframe *sigframe, ThreadSasEntry *sas) { if (sas) __setup_sas(sigframe, sas); diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h index 012358949..a0a8ed987 100644 --- a/criu/arch/x86/include/asm/types.h +++ b/criu/arch/x86/include/asm/types.h @@ -15,12 +15,12 @@ static inline int core_is_compat(CoreEntry *c) { switch (c->thread_info->gpregs->mode) { - case USER_X86_REGS_MODE__NATIVE: - return 0; - case USER_X86_REGS_MODE__COMPAT: - return 1; - default: - return -1; + case USER_X86_REGS_MODE__NATIVE: + return 0; + case USER_X86_REGS_MODE__COMPAT: + return 1; + default: + return -1; } } @@ -30,10 +30,16 @@ static inline int core_is_compat(CoreEntry *c) typedef UserX86RegsEntry UserRegsEntry; -static inline u64 encode_pointer(void *p) { return (u64)(long)p; } -static inline void *decode_pointer(u64 v) { return (void*)(long)v; } +static inline u64 encode_pointer(void *p) +{ + return (u64)(long)p; +} +static inline void *decode_pointer(u64 v) +{ + return (void *)(long)v; +} -#define AT_VECTOR_SIZE 44 +#define AT_VECTOR_SIZE 44 typedef uint64_t auxv_t; #endif /* __CR_ASM_TYPES_H__ */ diff --git a/criu/arch/x86/include/asm/vdso.h b/criu/arch/x86/include/asm/vdso.h index 54d1fba69..3b3f292bd 100644 --- a/criu/arch/x86/include/asm/vdso.h +++ b/criu/arch/x86/include/asm/vdso.h @@ -12,8 +12,8 @@ * This is a minimal amount of symbols * we should support at the moment. */ -#define VDSO_SYMBOL_MAX 6 -#define VDSO_SYMBOL_GTOD 2 +#define VDSO_SYMBOL_MAX 6 +#define VDSO_SYMBOL_GTOD 2 /* * XXX: we don't patch __kernel_vsyscall as it's too small: @@ -36,41 +36,34 @@ * https://github.com/checkpoint-restore/criu/issues/512 */ -#define ARCH_VDSO_SYMBOLS_LIST \ - const char* aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ - const char* aarch_vdso_symbol2 = "__vdso_getcpu"; \ - const char* aarch_vdso_symbol3 = "__vdso_gettimeofday"; \ - const char* aarch_vdso_symbol4 = "__vdso_time"; \ - const char* aarch_vdso_symbol5 = "__kernel_sigreturn"; \ - const char* aarch_vdso_symbol6 = "__kernel_rt_sigreturn"; +#define ARCH_VDSO_SYMBOLS_LIST \ + const char *aarch_vdso_symbol1 = "__vdso_clock_gettime"; \ + const char *aarch_vdso_symbol2 = "__vdso_getcpu"; \ + const char *aarch_vdso_symbol3 = "__vdso_gettimeofday"; \ + const char *aarch_vdso_symbol4 = "__vdso_time"; \ + const char *aarch_vdso_symbol5 = "__kernel_sigreturn"; \ + const char *aarch_vdso_symbol6 = "__kernel_rt_sigreturn"; -#define ARCH_VDSO_SYMBOLS \ - aarch_vdso_symbol1, \ - aarch_vdso_symbol2, \ - aarch_vdso_symbol3, \ - aarch_vdso_symbol4, \ - aarch_vdso_symbol5, \ - aarch_vdso_symbol6 +#define ARCH_VDSO_SYMBOLS \ + aarch_vdso_symbol1, aarch_vdso_symbol2, aarch_vdso_symbol3, aarch_vdso_symbol4, aarch_vdso_symbol5, \ + aarch_vdso_symbol6 /* "__kernel_vsyscall", */ #ifndef ARCH_MAP_VDSO_32 -# define ARCH_MAP_VDSO_32 0x2002 +#define ARCH_MAP_VDSO_32 0x2002 #endif #ifndef ARCH_MAP_VDSO_64 -# define ARCH_MAP_VDSO_64 0x2003 +#define ARCH_MAP_VDSO_64 0x2003 #endif #if defined(CONFIG_COMPAT) && !defined(__ASSEMBLY__) struct vdso_symtable; -extern int vdso_fill_symtable(uintptr_t mem, size_t size, - struct vdso_symtable *t); -extern int vdso_fill_symtable_compat(uintptr_t mem, size_t size, - struct vdso_symtable *t); +extern int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t); +extern int vdso_fill_symtable_compat(uintptr_t mem, size_t size, struct vdso_symtable *t); -static inline int __vdso_fill_symtable(uintptr_t mem, size_t size, - struct vdso_symtable *t, bool compat_vdso) +static inline int __vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t, bool compat_vdso) { if (compat_vdso) return vdso_fill_symtable_compat(mem, size, t); diff --git a/criu/include/aio.h b/criu/include/aio.h index 858ccd3cf..f8a59dfdf 100644 --- a/criu/include/aio.h +++ b/criu/include/aio.h @@ -13,18 +13,18 @@ struct task_restore_args; int prepare_aios(struct pstree_item *t, struct task_restore_args *ta); struct aio_ring { - unsigned id; /* kernel internal index number */ - unsigned nr; /* number of io_events */ - unsigned head; /* Written to by userland or under ring_lock + unsigned id; /* kernel internal index number */ + unsigned nr; /* number of io_events */ + unsigned head; /* Written to by userland or under ring_lock * mutex by aio_read_events_ring(). */ - unsigned tail; + unsigned tail; - unsigned magic; - unsigned compat_features; - unsigned incompat_features; - unsigned header_length; /* size of aio_ring */ + unsigned magic; + unsigned compat_features; + unsigned incompat_features; + unsigned header_length; /* size of aio_ring */ - struct io_event io_events[0]; + struct io_event io_events[0]; }; struct rst_aio_ring { diff --git a/criu/include/asm-generic/int.h b/criu/include/asm-generic/int.h index ac3088d5a..5bf484776 100644 --- a/criu/include/asm-generic/int.h +++ b/criu/include/asm-generic/int.h @@ -3,13 +3,13 @@ #include -typedef uint64_t u64; -typedef int64_t s64; -typedef uint32_t u32; -typedef int32_t s32; -typedef uint16_t u16; -typedef int16_t s16; -typedef uint8_t u8; -typedef int8_t s8; +typedef uint64_t u64; +typedef int64_t s64; +typedef uint32_t u32; +typedef int32_t s32; +typedef uint16_t u16; +typedef int16_t s16; +typedef uint8_t u8; +typedef int8_t s8; #endif /* __CR_INT_H__ */ diff --git a/criu/include/asm-generic/vdso.h b/criu/include/asm-generic/vdso.h index 6c3e3d137..cddd1a7f0 100644 --- a/criu/include/asm-generic/vdso.h +++ b/criu/include/asm-generic/vdso.h @@ -1,15 +1,15 @@ #ifndef __CR_ASM_GENERIC_VDSO_H__ #define __CR_ASM_GENERIC_VDSO_H__ -#define VDSO_PROT (PROT_READ | PROT_EXEC) -#define VVAR_PROT (PROT_READ) +#define VDSO_PROT (PROT_READ | PROT_EXEC) +#define VVAR_PROT (PROT_READ) /* Just in case of LPAE system PFN is u64. */ -#define VDSO_BAD_PFN (-1ull) -#define VVAR_BAD_PFN (-1ull) -#define VDSO_BAD_ADDR (-1ul) -#define VVAR_BAD_ADDR (-1ul) -#define VDSO_BAD_SIZE (-1ul) -#define VVAR_BAD_SIZE (-1ul) +#define VDSO_BAD_PFN (-1ull) +#define VVAR_BAD_PFN (-1ull) +#define VDSO_BAD_ADDR (-1ul) +#define VVAR_BAD_ADDR (-1ul) +#define VDSO_BAD_SIZE (-1ul) +#define VVAR_BAD_SIZE (-1ul) #endif /* __CR_ASM_GENERIC_VDSO_H__ */ diff --git a/criu/include/autofs.h b/criu/include/autofs.h index c4618859b..c4e0f23ed 100644 --- a/criu/include/autofs.h +++ b/criu/include/autofs.h @@ -2,7 +2,7 @@ #define __CR_AUTOFS_H__ #ifndef AUTOFS_MINOR -#define AUTOFS_MINOR 235 +#define AUTOFS_MINOR 235 #endif #include @@ -12,78 +12,76 @@ bool is_autofs_pipe(unsigned long inode); struct mount_info; int autofs_parse(struct mount_info *pm); int autofs_dump(struct mount_info *pm); -int autofs_mount(struct mount_info *mi, const char *source, const - char *filesystemtype, unsigned long mountflags); +int autofs_mount(struct mount_info *mi, const char *source, const char *filesystemtype, unsigned long mountflags); #include #include #include -#define AUTOFS_DEVICE_NAME "autofs" +#define AUTOFS_DEVICE_NAME "autofs" #define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1 #define AUTOFS_DEV_IOCTL_VERSION_MINOR 0 -#define AUTOFS_DEVID_LEN 16 +#define AUTOFS_DEVID_LEN 16 -#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl) /* * An ioctl interface for autofs mount point control. */ struct args_protover { - __u32 version; + __u32 version; }; struct args_protosubver { - __u32 sub_version; + __u32 sub_version; }; struct args_openmount { - __u32 devid; + __u32 devid; }; struct args_ready { - __u32 token; + __u32 token; }; struct args_fail { - __u32 token; - __s32 status; + __u32 token; + __s32 status; }; struct args_setpipefd { - __s32 pipefd; + __s32 pipefd; }; struct args_timeout { - __u64 timeout; + __u64 timeout; }; struct args_requester { - __u32 uid; - __u32 gid; + __u32 uid; + __u32 gid; }; struct args_expire { - __u32 how; + __u32 how; }; - struct args_askumount { - __u32 may_umount; + __u32 may_umount; }; struct args_ismountpoint { union { struct args_in { - __u32 type; + __u32 type; } in; struct args_out { - __u32 devid; - __u32 magic; + __u32 devid; + __u32 magic; } out; }; }; @@ -98,24 +96,24 @@ struct args_ismountpoint { struct autofs_dev_ioctl { __u32 ver_major; __u32 ver_minor; - __u32 size; /* total size of data passed in + __u32 size; /* total size of data passed in * including this struct */ - __s32 ioctlfd; /* automount command fd */ + __s32 ioctlfd; /* automount command fd */ /* Command parameters */ union { - struct args_protover protover; - struct args_protosubver protosubver; - struct args_openmount openmount; - struct args_ready ready; - struct args_fail fail; - struct args_setpipefd setpipefd; - struct args_timeout timeout; - struct args_requester requester; - struct args_expire expire; - struct args_askumount askumount; - struct args_ismountpoint ismountpoint; + struct args_protover protover; + struct args_protosubver protosubver; + struct args_openmount openmount; + struct args_ready ready; + struct args_fail fail; + struct args_setpipefd setpipefd; + struct args_timeout timeout; + struct args_requester requester; + struct args_expire expire; + struct args_askumount askumount; + struct args_ismountpoint ismountpoint; }; char path[0]; @@ -131,7 +129,6 @@ static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in) return; } - /* * If you change this make sure you make the corresponding change * to autofs-dev-ioctl.c:lookup_ioctl() @@ -174,61 +171,32 @@ enum { #define AUTOFS_IOCTL 0x93 -#define AUTOFS_DEV_IOCTL_VERSION \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_VERSION _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_PROTOVER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_PROTOVER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_PROTOSUBVER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_PROTOSUBVER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_OPENMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_OPENMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_CLOSEMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_CLOSEMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_READY _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_READY \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_FAIL _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_FAIL \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_SETPIPEFD _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_SETPIPEFD \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_CATATONIC _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_CATATONIC \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_TIMEOUT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_TIMEOUT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_REQUESTER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_REQUESTER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_EXPIRE _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_EXPIRE \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_ASKUMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_ASKUMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl) - -#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl) #endif diff --git a/criu/include/bfd.h b/criu/include/bfd.h index 9f4bdb27b..4268f74d4 100644 --- a/criu/include/bfd.h +++ b/criu/include/bfd.h @@ -5,9 +5,9 @@ struct bfd_buf; struct xbuf { - char *mem; /* buffer */ - char *data; /* position we see bytes at */ - unsigned int sz; /* bytes sitting after b->pos */ + char *mem; /* buffer */ + char *data; /* position we see bytes at */ + unsigned int sz; /* bytes sitting after b->pos */ struct bfd_buf *buf; }; diff --git a/criu/include/bpfmap.h b/criu/include/bpfmap.h index 2d83f44d2..8ab2d3ce6 100644 --- a/criu/include/bpfmap.h +++ b/criu/include/bpfmap.h @@ -6,24 +6,24 @@ #include "bpfmap-data.pb-c.h" struct bpfmap_file_info { - BpfmapFileEntry *bpfe; - struct file_desc d; + BpfmapFileEntry *bpfe; + struct file_desc d; }; struct bpfmap_data_rst { - BpfmapDataEntry *bde; - void *data; - struct bpfmap_data_rst *next; + BpfmapDataEntry *bde; + void *data; + struct bpfmap_data_rst *next; }; -#define BPFMAP_DATA_HASH_BITS 5 -#define BPFMAP_DATA_TABLE_SIZE (1 << BPFMAP_DATA_HASH_BITS) -#define BPFMAP_DATA_HASH_MASK (BPFMAP_DATA_TABLE_SIZE - 1) +#define BPFMAP_DATA_HASH_BITS 5 +#define BPFMAP_DATA_TABLE_SIZE (1 << BPFMAP_DATA_HASH_BITS) +#define BPFMAP_DATA_HASH_MASK (BPFMAP_DATA_TABLE_SIZE - 1) extern int is_bpfmap_link(char *link); extern int dump_one_bpfmap_data(BpfmapFileEntry *bpf, int lfd, const struct fd_parms *p); -extern int do_collect_bpfmap_data(struct bpfmap_data_rst *, ProtobufCMessage *, - struct cr_img *, struct bpfmap_data_rst **); +extern int do_collect_bpfmap_data(struct bpfmap_data_rst *, ProtobufCMessage *, struct cr_img *, + struct bpfmap_data_rst **); extern int restore_bpfmap_data(int, uint32_t, struct bpfmap_data_rst **); extern const struct fdtype_ops bpfmap_dump_ops; diff --git a/criu/include/cgroup-props.h b/criu/include/cgroup-props.h index 0e5201098..11b677548 100644 --- a/criu/include/cgroup-props.h +++ b/criu/include/cgroup-props.h @@ -4,9 +4,9 @@ #include typedef struct { - const char *name; - size_t nr_props; - const char **props; + const char *name; + size_t nr_props; + const char **props; } cgp_t; extern cgp_t cgp_global; diff --git a/criu/include/cgroup.h b/criu/include/cgroup.h index 949266d40..2e9b8933c 100644 --- a/criu/include/cgroup.h +++ b/criu/include/cgroup.h @@ -19,47 +19,47 @@ void fini_cgroup(void); struct cg_controller; struct cgroup_prop { - char *name; - char *value; - mode_t mode; - uid_t uid; - gid_t gid; - struct list_head list; + char *name; + char *value; + mode_t mode; + uid_t uid; + gid_t gid; + struct list_head list; }; /* This describes a particular cgroup path, e.g. the '/lxc/u1' part of * 'blkio/lxc/u1' and any properties it has. */ struct cgroup_dir { - char *path; - mode_t mode; - uid_t uid; - gid_t gid; + char *path; + mode_t mode; + uid_t uid; + gid_t gid; - struct list_head properties; - unsigned int n_properties; + struct list_head properties; + unsigned int n_properties; /* this is how children are linked together */ - struct list_head siblings; + struct list_head siblings; /* more cgroup_dirs */ - struct list_head children; - unsigned int n_children; + struct list_head children; + unsigned int n_children; }; /* This describes a particular cgroup controller, e.g. blkio or cpuset. * The heads are subdirectories organized in their tree format. */ struct cg_controller { - unsigned int n_controllers; - char **controllers; + unsigned int n_controllers; + char **controllers; /* cgroup_dirs */ - struct list_head heads; - unsigned int n_heads; + struct list_head heads; + unsigned int n_heads; /* for cgroup list in cgroup.c */ - struct list_head l; + struct list_head l; }; struct cg_controller *new_controller(const char *name); diff --git a/criu/include/clone-noasan.h b/criu/include/clone-noasan.h index 0cfdaa1d9..aff773296 100644 --- a/criu/include/clone-noasan.h +++ b/criu/include/clone-noasan.h @@ -2,7 +2,6 @@ #define __CR_CLONE_NOASAN_H__ int clone_noasan(int (*fn)(void *), int flags, void *arg); -int clone3_with_pid_noasan(int (*fn)(void *), void *arg, int flags, - int exit_signal, pid_t pid); +int clone3_with_pid_noasan(int (*fn)(void *), void *arg, int flags, int exit_signal, pid_t pid); #endif /* __CR_CLONE_NOASAN_H__ */ diff --git a/criu/include/cr-errno.h b/criu/include/cr-errno.h index 1f94988cf..0c7c1796e 100644 --- a/criu/include/cr-errno.h +++ b/criu/include/cr-errno.h @@ -11,7 +11,7 @@ int get_cr_errno(void); * EBADRQC - bad options */ -#define set_task_cr_err(new_err) atomic_cmpxchg(&task_entries->cr_err, 0, new_err) -#define get_task_cr_err() atomic_read(&task_entries->cr_err) +#define set_task_cr_err(new_err) atomic_cmpxchg(&task_entries->cr_err, 0, new_err) +#define get_task_cr_err() atomic_read(&task_entries->cr_err) #endif /* __CR_ERRNO_H__ */ diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h index dc6c95503..6836e8114 100644 --- a/criu/include/cr_options.h +++ b/criu/include/cr_options.h @@ -7,13 +7,13 @@ #include "common/list.h" /* Configuration and CLI parsing order defines */ -#define PARSING_GLOBAL_CONF 1 -#define PARSING_USER_CONF 2 -#define PARSING_ENV_CONF 3 -#define PARSING_CMDLINE_CONF 4 -#define PARSING_ARGV 5 -#define PARSING_RPC_CONF 6 -#define PARSING_LAST 7 +#define PARSING_GLOBAL_CONF 1 +#define PARSING_USER_CONF 2 +#define PARSING_ENV_CONF 3 +#define PARSING_CMDLINE_CONF 4 +#define PARSING_ARGV 5 +#define PARSING_RPC_CONF 6 +#define PARSING_LAST 7 #define SET_CHAR_OPTS(__dest, __src) \ do { \ @@ -25,13 +25,13 @@ /* * CPU capability options. */ -#define CPU_CAP_NONE (0u << 0) /* Don't check capability at all */ -#define CPU_CAP_FPU (1u << 0) /* Only FPU capability required */ -#define CPU_CAP_CPU (1u << 1) /* Strict CPU capability required */ -#define CPU_CAP_INS (1u << 2) /* Instructions CPU capability */ -#define CPU_CAP_IMAGE (1u << 3) /* Write capability on dump and read on restore*/ -#define CPU_CAP_ALL (CPU_CAP_FPU | CPU_CAP_CPU | CPU_CAP_INS) -#define CPU_CAP_DEFAULT (CPU_CAP_FPU | CPU_CAP_INS) +#define CPU_CAP_NONE (0u << 0) /* Don't check capability at all */ +#define CPU_CAP_FPU (1u << 0) /* Only FPU capability required */ +#define CPU_CAP_CPU (1u << 1) /* Strict CPU capability required */ +#define CPU_CAP_INS (1u << 2) /* Instructions CPU capability */ +#define CPU_CAP_IMAGE (1u << 3) /* Write capability on dump and read on restore*/ +#define CPU_CAP_ALL (CPU_CAP_FPU | CPU_CAP_CPU | CPU_CAP_INS) +#define CPU_CAP_DEFAULT (CPU_CAP_FPU | CPU_CAP_INS) struct cg_root_opt { struct list_head node; @@ -42,30 +42,29 @@ struct cg_root_opt { /* * Pre-dump variants */ -#define PRE_DUMP_SPLICE 1 /* Pre-dump using parasite */ -#define PRE_DUMP_READ 2 /* Pre-dump using process_vm_readv syscall */ +#define PRE_DUMP_SPLICE 1 /* Pre-dump using parasite */ +#define PRE_DUMP_READ 2 /* Pre-dump using process_vm_readv syscall */ /* * Cgroup management options. */ -#define CG_MODE_IGNORE (0u << 0) /* Zero is important here */ -#define CG_MODE_NONE (1u << 0) -#define CG_MODE_PROPS (1u << 1) -#define CG_MODE_SOFT (1u << 2) -#define CG_MODE_FULL (1u << 3) -#define CG_MODE_STRICT (1u << 4) +#define CG_MODE_IGNORE (0u << 0) /* Zero is important here */ +#define CG_MODE_NONE (1u << 0) +#define CG_MODE_PROPS (1u << 1) +#define CG_MODE_SOFT (1u << 2) +#define CG_MODE_FULL (1u << 3) +#define CG_MODE_STRICT (1u << 4) -#define CG_MODE_DEFAULT (CG_MODE_SOFT) +#define CG_MODE_DEFAULT (CG_MODE_SOFT) /* * Ghost file size we allow to carry by default. */ -#define DEFAULT_GHOST_LIMIT (1 << 20) +#define DEFAULT_GHOST_LIMIT (1 << 20) -#define DEFAULT_TIMEOUT 10 +#define DEFAULT_TIMEOUT 10 -enum FILE_VALIDATION_OPTIONS -{ +enum FILE_VALIDATION_OPTIONS { /* * This constant indicates that the file validation should be tried with the * file size method by default. @@ -80,7 +79,7 @@ enum FILE_VALIDATION_OPTIONS }; /* This constant dictates which file validation method should be tried by default. */ -#define FILE_VALIDATION_DEFAULT FILE_VALIDATION_BUILD_ID +#define FILE_VALIDATION_DEFAULT FILE_VALIDATION_BUILD_ID struct irmap; @@ -90,67 +89,67 @@ struct irmap_path_opt { }; struct cr_options { - int final_state; - int check_extra_features; - int check_experimental_features; + int final_state; + int check_extra_features; + int check_experimental_features; union { - int restore_detach; - bool daemon_mode; + int restore_detach; + bool daemon_mode; }; - int restore_sibling; - bool ext_unix_sk; - int shell_job; - int handle_file_locks; - int tcp_established_ok; - int tcp_close; - int evasive_devices; - int link_remap_ok; - int log_file_per_pid; - int pre_dump_mode; - bool swrk_restore; - char *output; - char *root; - char *pidfile; - char *freeze_cgroup; - struct list_head ext_mounts; - struct list_head inherit_fds; - struct list_head external; - struct list_head join_ns; - char *libdir; - int use_page_server; - unsigned short port; - char *addr; - int ps_socket; - int track_mem; - char *img_parent; - int auto_dedup; - unsigned int cpu_cap; - int force_irmap; - char **exec_cmd; - unsigned int manage_cgroups; - char *new_global_cg_root; - char *cgroup_props; - char *cgroup_props_file; - struct list_head new_cgroup_roots; - char *cgroup_yard; - bool autodetect_ext_mounts; - int enable_external_sharing; - int enable_external_masters; - bool aufs; /* auto-detected, not via cli */ - bool overlayfs; + int restore_sibling; + bool ext_unix_sk; + int shell_job; + int handle_file_locks; + int tcp_established_ok; + int tcp_close; + int evasive_devices; + int link_remap_ok; + int log_file_per_pid; + int pre_dump_mode; + bool swrk_restore; + char *output; + char *root; + char *pidfile; + char *freeze_cgroup; + struct list_head ext_mounts; + struct list_head inherit_fds; + struct list_head external; + struct list_head join_ns; + char *libdir; + int use_page_server; + unsigned short port; + char *addr; + int ps_socket; + int track_mem; + char *img_parent; + int auto_dedup; + unsigned int cpu_cap; + int force_irmap; + char **exec_cmd; + unsigned int manage_cgroups; + char *new_global_cg_root; + char *cgroup_props; + char *cgroup_props_file; + struct list_head new_cgroup_roots; + char *cgroup_yard; + bool autodetect_ext_mounts; + int enable_external_sharing; + int enable_external_masters; + bool aufs; /* auto-detected, not via cli */ + bool overlayfs; #ifdef CONFIG_BINFMT_MISC_VIRTUALIZED - bool has_binfmt_misc; /* auto-detected */ + bool has_binfmt_misc; /* auto-detected */ #endif - size_t ghost_limit; - struct list_head irmap_scan_paths; - bool lsm_supplied; - char *lsm_profile; - char *lsm_mount_context; - unsigned int timeout; - unsigned int empty_ns; - int tcp_skip_in_flight; - bool lazy_pages; - char *work_dir; + size_t ghost_limit; + struct list_head irmap_scan_paths; + bool lsm_supplied; + char *lsm_profile; + char *lsm_mount_context; + unsigned int timeout; + unsigned int empty_ns; + int tcp_skip_in_flight; + bool lazy_pages; + char *work_dir; /* * When we scheduler for removal some functionality we first @@ -158,24 +157,24 @@ struct cr_options { * the deprecated stuff is not working, but it's still possible * to turn one ON while the code is in. */ - int deprecated_ok; - int display_stats; - int weak_sysctls; - int status_fd; - bool orphan_pts_master; - int stream; - pid_t tree_id; - int log_level; - char *imgs_dir; - char *tls_cacert; - char *tls_cacrl; - char *tls_cert; - char *tls_key; - int tls; - int tls_no_cn_verify; + int deprecated_ok; + int display_stats; + int weak_sysctls; + int status_fd; + bool orphan_pts_master; + int stream; + pid_t tree_id; + int log_level; + char *imgs_dir; + char *tls_cacert; + char *tls_cacrl; + char *tls_cert; + char *tls_key; + int tls; + int tls_no_cn_verify; /* This stores which method to use for file validation. */ - int file_validation_method; + int file_validation_method; }; extern struct cr_options opts; diff --git a/criu/include/criu-plugin.h b/criu/include/criu-plugin.h index b76f5f839..897666ecd 100644 --- a/criu/include/criu-plugin.h +++ b/criu/include/criu-plugin.h @@ -23,38 +23,35 @@ #include #include -#define CRIU_PLUGIN_GEN_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -#define CRIU_PLUGIN_VERSION_MAJOR 0 -#define CRIU_PLUGIN_VERSION_MINOR 2 -#define CRIU_PLUGIN_VERSION_SUBLEVEL 0 +#define CRIU_PLUGIN_GEN_VERSION(a, b, c) (((a) << 16) + ((b) << 8) + (c)) +#define CRIU_PLUGIN_VERSION_MAJOR 0 +#define CRIU_PLUGIN_VERSION_MINOR 2 +#define CRIU_PLUGIN_VERSION_SUBLEVEL 0 -#define CRIU_PLUGIN_VERSION_OLD CRIU_PLUGIN_GEN_VERSION(0,1,0) +#define CRIU_PLUGIN_VERSION_OLD CRIU_PLUGIN_GEN_VERSION(0, 1, 0) -#define CRIU_PLUGIN_VERSION \ - CRIU_PLUGIN_GEN_VERSION(CRIU_PLUGIN_VERSION_MAJOR, \ - CRIU_PLUGIN_VERSION_MINOR, \ - CRIU_PLUGIN_VERSION_SUBLEVEL) +#define CRIU_PLUGIN_VERSION \ + CRIU_PLUGIN_GEN_VERSION(CRIU_PLUGIN_VERSION_MAJOR, CRIU_PLUGIN_VERSION_MINOR, CRIU_PLUGIN_VERSION_SUBLEVEL) /* * Plugin hook points and their arguments in hooks. */ enum { - CR_PLUGIN_HOOK__DUMP_UNIX_SK = 0, - CR_PLUGIN_HOOK__RESTORE_UNIX_SK = 1, + CR_PLUGIN_HOOK__DUMP_UNIX_SK = 0, + CR_PLUGIN_HOOK__RESTORE_UNIX_SK = 1, - CR_PLUGIN_HOOK__DUMP_EXT_FILE = 2, - CR_PLUGIN_HOOK__RESTORE_EXT_FILE = 3, + CR_PLUGIN_HOOK__DUMP_EXT_FILE = 2, + CR_PLUGIN_HOOK__RESTORE_EXT_FILE = 3, - CR_PLUGIN_HOOK__DUMP_EXT_MOUNT = 4, - CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT = 5, + CR_PLUGIN_HOOK__DUMP_EXT_MOUNT = 4, + CR_PLUGIN_HOOK__RESTORE_EXT_MOUNT = 5, - CR_PLUGIN_HOOK__DUMP_EXT_LINK = 6, + CR_PLUGIN_HOOK__DUMP_EXT_LINK = 6, CR_PLUGIN_HOOK__MAX }; -#define DECLARE_PLUGIN_HOOK_ARGS(__hook, ...) \ - typedef int (__hook ##_t)(__VA_ARGS__) +#define DECLARE_PLUGIN_HOOK_ARGS(__hook, ...) typedef int(__hook##_t)(__VA_ARGS__) DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__DUMP_UNIX_SK, int fd, int id); DECLARE_PLUGIN_HOOK_ARGS(CR_PLUGIN_HOOK__RESTORE_UNIX_SK, int id); @@ -76,42 +73,47 @@ enum { * Plugin descriptor. */ typedef struct { - const char *name; - int (*init)(int stage); - void (*exit)(int stage, int ret); - unsigned int version; - unsigned int max_hooks; - void *hooks[CR_PLUGIN_HOOK__MAX]; + const char *name; + int (*init)(int stage); + void (*exit)(int stage, int ret); + unsigned int version; + unsigned int max_hooks; + void *hooks[CR_PLUGIN_HOOK__MAX]; } cr_plugin_desc_t; extern cr_plugin_desc_t CR_PLUGIN_DESC; -#define CR_PLUGIN_REGISTER(___name, ___init, ___exit) \ - cr_plugin_desc_t CR_PLUGIN_DESC = { \ - .name = ___name, \ - .init = ___init, \ - .exit = ___exit, \ - .version = CRIU_PLUGIN_VERSION, \ - .max_hooks = CR_PLUGIN_HOOK__MAX, \ +#define CR_PLUGIN_REGISTER(___name, ___init, ___exit) \ + cr_plugin_desc_t CR_PLUGIN_DESC = { \ + .name = ___name, \ + .init = ___init, \ + .exit = ___exit, \ + .version = CRIU_PLUGIN_VERSION, \ + .max_hooks = CR_PLUGIN_HOOK__MAX, \ }; -static inline int cr_plugin_dummy_init(int stage) { return 0; } -static inline void cr_plugin_dummy_exit(int stage, int ret) { } - -#define CR_PLUGIN_REGISTER_DUMMY(___name) \ - cr_plugin_desc_t CR_PLUGIN_DESC = { \ - .name = ___name, \ - .init = cr_plugin_dummy_init, \ - .exit = cr_plugin_dummy_exit, \ - .version = CRIU_PLUGIN_VERSION, \ - .max_hooks = CR_PLUGIN_HOOK__MAX, \ - }; - -#define CR_PLUGIN_REGISTER_HOOK(__hook, __func) \ -static void __attribute__((constructor)) cr_plugin_register_hook_##__func (void) \ -{ \ - CR_PLUGIN_DESC.hooks[__hook] = (void *)__func; \ +static inline int cr_plugin_dummy_init(int stage) +{ + return 0; } +static inline void cr_plugin_dummy_exit(int stage, int ret) +{ +} + +#define CR_PLUGIN_REGISTER_DUMMY(___name) \ + cr_plugin_desc_t CR_PLUGIN_DESC = { \ + .name = ___name, \ + .init = cr_plugin_dummy_init, \ + .exit = cr_plugin_dummy_exit, \ + .version = CRIU_PLUGIN_VERSION, \ + .max_hooks = CR_PLUGIN_HOOK__MAX, \ + }; + +#define CR_PLUGIN_REGISTER_HOOK(__hook, __func) \ + static void __attribute__((constructor)) cr_plugin_register_hook_##__func(void) \ + { \ + CR_PLUGIN_DESC.hooks[__hook] = (void *)__func; \ + } /* Public API */ extern int criu_get_image_dir(void); @@ -119,14 +121,14 @@ extern int criu_get_image_dir(void); /* * Deprecated, will be removed in next version. */ -typedef int (cr_plugin_init_t)(void); -typedef void (cr_plugin_fini_t)(void); -typedef int (cr_plugin_dump_unix_sk_t)(int fd, int id); -typedef int (cr_plugin_restore_unix_sk_t)(int id); -typedef int (cr_plugin_dump_file_t)(int fd, int id); -typedef int (cr_plugin_restore_file_t)(int id); -typedef int (cr_plugin_dump_ext_mount_t)(char *mountpoint, int id); -typedef int (cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file); -typedef int (cr_plugin_dump_ext_link_t)(int index, int type, char *kind); +typedef int(cr_plugin_init_t)(void); +typedef void(cr_plugin_fini_t)(void); +typedef int(cr_plugin_dump_unix_sk_t)(int fd, int id); +typedef int(cr_plugin_restore_unix_sk_t)(int id); +typedef int(cr_plugin_dump_file_t)(int fd, int id); +typedef int(cr_plugin_restore_file_t)(int id); +typedef int(cr_plugin_dump_ext_mount_t)(char *mountpoint, int id); +typedef int(cr_plugin_restore_ext_mount_t)(int id, char *mountpoint, char *old_root, int *is_file); +typedef int(cr_plugin_dump_ext_link_t)(int index, int type, char *kind); #endif /* __CRIU_PLUGIN_H__ */ diff --git a/criu/include/crtools.h b/criu/include/crtools.h index 740bf1737..b9309654f 100644 --- a/criu/include/crtools.h +++ b/criu/include/crtools.h @@ -8,7 +8,7 @@ #include "images/inventory.pb-c.h" -#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) +#define CR_FD_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) extern int check_img_inventory(bool restore); extern int write_img_inventory(InventoryEntry *he); @@ -32,16 +32,18 @@ extern int cr_lazy_pages(bool daemon); extern int check_add_feature(char *arg); extern void pr_check_features(const char *offset, const char *sep, int width); -#define PPREP_HEAD_INACTIVE ((struct pprep_head *)-1) +#define PPREP_HEAD_INACTIVE ((struct pprep_head *)-1) -#define add_post_prepare_cb_once(phead) do { \ - if ((phead)->next == PPREP_HEAD_INACTIVE)\ - add_post_prepare_cb(phead); \ +#define add_post_prepare_cb_once(phead) \ + do { \ + if ((phead)->next == PPREP_HEAD_INACTIVE) \ + add_post_prepare_cb(phead); \ } while (0) -#define MAKE_PPREP_HEAD(name) struct pprep_head name = { \ - .next = PPREP_HEAD_INACTIVE, \ - .actor = name##_cb, \ +#define MAKE_PPREP_HEAD(name) \ + struct pprep_head name = { \ + .next = PPREP_HEAD_INACTIVE, \ + .actor = name##_cb, \ } #endif /* __CR_CRTOOLS_H__ */ diff --git a/criu/include/fault-injection.h b/criu/include/fault-injection.h index 0fd9b512d..f33918de8 100644 --- a/criu/include/fault-injection.h +++ b/criu/include/fault-injection.h @@ -35,12 +35,12 @@ static inline bool __fault_injected(enum faults f, enum faults fi_strategy) return fi_strategy == f; } -#define FI_HUGE_ANON_SHMEM_ID_BASE (0xfffffffflu) +#define FI_HUGE_ANON_SHMEM_ID_BASE (0xfffffffflu) #ifndef CR_NOGLIBC extern enum faults fi_strategy; -#define fault_injected(f) __fault_injected(f, fi_strategy) +#define fault_injected(f) __fault_injected(f, fi_strategy) extern int fault_injection_init(void); diff --git a/criu/include/fcntl.h b/criu/include/fcntl.h index ea9d48c72..35f880523 100644 --- a/criu/include/fcntl.h +++ b/criu/include/fcntl.h @@ -5,49 +5,49 @@ #include #ifndef F_SETOWN_EX -#define F_SETOWN_EX 15 -#define F_GETOWN_EX 16 +#define F_SETOWN_EX 15 +#define F_GETOWN_EX 16 struct f_owner_ex { - int type; - pid_t pid; + int type; + pid_t pid; }; #endif #ifndef F_GETOWNER_UIDS -#define F_GETOWNER_UIDS 17 +#define F_GETOWNER_UIDS 17 #endif /* * These things are required to compile on CentOS-6 */ #ifndef F_LINUX_SPECIFIC_BASE -# define F_LINUX_SPECIFIC_BASE 1024 +#define F_LINUX_SPECIFIC_BASE 1024 #endif #ifndef F_SETPIPE_SZ -# define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) +#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7) #endif #ifndef F_GETPIPE_SZ -# define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) +#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8) #endif #ifndef F_ADD_SEALS -# define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9) #endif #ifndef F_GET_SEALS -# define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10) #endif #ifndef O_PATH -# define O_PATH 010000000 +#define O_PATH 010000000 #endif #ifndef __O_TMPFILE -#define __O_TMPFILE 020000000 +#define __O_TMPFILE 020000000 #endif #ifndef O_TMPFILE diff --git a/criu/include/file-ids.h b/criu/include/file-ids.h index 9a39f0d2d..4479a9b37 100644 --- a/criu/include/file-ids.h +++ b/criu/include/file-ids.h @@ -6,8 +6,8 @@ #include "images/fdinfo.pb-c.h" -#define FD_PID_INVALID (-2U) -#define FD_DESC_INVALID (-3U) +#define FD_PID_INVALID (-2U) +#define FD_DESC_INVALID (-3U) struct fdinfo_entry; struct stat; diff --git a/criu/include/file-lock.h b/criu/include/file-lock.h index dc4f38216..0ce2fa340 100644 --- a/criu/include/file-lock.h +++ b/criu/include/file-lock.h @@ -6,57 +6,58 @@ #include "protobuf.h" #include "images/file-lock.pb-c.h" -#define FL_UNKNOWN -1 -#define FL_POSIX 1 -#define FL_FLOCK 2 -#define FL_OFD 4 -#define FL_LEASE 8 +#define FL_UNKNOWN -1 +#define FL_POSIX 1 +#define FL_FLOCK 2 +#define FL_OFD 4 +#define FL_LEASE 8 /* for posix fcntl() and lockf() */ #ifndef F_RDLCK -#define F_RDLCK 0 -#define F_WRLCK 1 -#define F_UNLCK 2 +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 #endif /* for OFD locks fcntl() */ #ifndef F_OFD_GETLK -#define F_OFD_GETLK 36 -#define F_OFD_SETLK 37 -#define F_OFD_SETLKW 38 +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 #endif /* operations for bsd flock(), also used by the kernel implementation */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* or'd with one of the above to prevent +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB \ + 4 /* or'd with one of the above to prevent blocking */ -#define LOCK_UN 8 /* remove lock */ +#define LOCK_UN 8 /* remove lock */ -#define LOCK_MAND 32 /* This is a mandatory flock ... */ -#define LOCK_READ 64 /* which allows concurrent read operations */ -#define LOCK_WRITE 128 /* which allows concurrent write operations */ -#define LOCK_RW 192 /* which allows concurrent read & write ops */ +#define LOCK_MAND 32 /* This is a mandatory flock ... */ +#define LOCK_READ 64 /* which allows concurrent read operations */ +#define LOCK_WRITE 128 /* which allows concurrent write operations */ +#define LOCK_RW 192 /* which allows concurrent read & write ops */ /* for leases */ -#define LEASE_BREAKING 4 +#define LEASE_BREAKING 4 struct file_lock { - long long fl_id; - int fl_kind; - int fl_ltype; + long long fl_id; + int fl_kind; + int fl_ltype; - pid_t fl_owner; /* process, which created the lock */ - pid_t fl_holder; /* pid of fd on whose the lock is found */ - int maj, min; - unsigned long i_no; - long long start; - char end[32]; + pid_t fl_owner; /* process, which created the lock */ + pid_t fl_holder; /* pid of fd on whose the lock is found */ + int maj, min; + unsigned long i_no; + long long start; + char end[32]; - struct list_head list; /* list of all file locks */ + struct list_head list; /* list of all file locks */ - int real_owner; - int owners_fd; + int real_owner; + int owners_fd; }; extern struct list_head file_lock_list; @@ -74,6 +75,6 @@ extern int correct_file_leases_type(struct pid *, int fd, int lfd); extern int note_file_lock(struct pid *, int fd, int lfd, struct fd_parms *); extern int dump_file_locks(void); -#define OPT_FILE_LOCKS "file-locks" +#define OPT_FILE_LOCKS "file-locks" #endif /* __FILE_LOCK_H__ */ diff --git a/criu/include/files-reg.h b/criu/include/files-reg.h index 0cb67c51a..953d50288 100644 --- a/criu/include/files-reg.h +++ b/criu/include/files-reg.h @@ -13,24 +13,23 @@ struct fd_parms; struct file_remap { char *rpath; bool is_dir; - int rmnt_id; + int rmnt_id; uid_t uid; gid_t gid; }; struct reg_file_info { - struct file_desc d; - RegFileEntry *rfe; - struct file_remap *remap; - bool size_mode_checked; - bool is_dir; - char *path; + struct file_desc d; + RegFileEntry *rfe; + struct file_remap *remap; + bool size_mode_checked; + bool is_dir; + char *path; }; extern int open_reg_by_id(u32 id); extern int open_reg_fd(struct file_desc *); -extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd, - struct reg_file_info *, void *), void *arg); +extern int open_path(struct file_desc *, int (*open_cb)(int ns_root_fd, struct reg_file_info *, void *), void *arg); extern const struct fdtype_ops regfile_dump_ops; extern int do_open_reg_noseek_flags(int ns_root_fd, struct reg_file_info *rfi, void *arg); @@ -39,7 +38,7 @@ extern int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p); extern struct file_remap *lookup_ghost_remap(u32 dev, u32 ino); extern struct file_desc *try_collect_special_file(u32 id, int optional); -#define collect_special_file(id) try_collect_special_file(id, 0) +#define collect_special_file(id) try_collect_special_file(id, 0) extern int collect_filemap(struct vma_area *); extern void filemap_ctx_init(bool auto_close); extern void filemap_ctx_fini(void); diff --git a/criu/include/files.h b/criu/include/files.h index 2c1e1e723..96face71b 100644 --- a/criu/include/files.h +++ b/criu/include/files.h @@ -26,8 +26,8 @@ struct fd_link { union { /* Link info for generic file (path) */ struct { - char name[PATH_MAX]; - size_t len; + char name[PATH_MAX]; + size_t len; }; /* Link info for proc-ns file */ @@ -39,28 +39,26 @@ struct fd_link { }; struct fd_parms { - int fd; - off_t pos; - unsigned int flags; - char fd_flags; - struct stat stat; - pid_t pid; - FownEntry fown; - struct fd_link *link; - long fs_type; - int mnt_id; + int fd; + off_t pos; + unsigned int flags; + char fd_flags; + struct stat stat; + pid_t pid; + FownEntry fown; + struct fd_link *link; + long fs_type; + int mnt_id; struct parasite_ctl *fd_ctl; struct parasite_drain_fd *dfds; }; -#define FD_PARMS_INIT \ -(struct fd_parms) { \ - .fd = FD_DESC_INVALID, \ - .fown = FOWN_ENTRY__INIT, \ - .link = NULL, \ - .mnt_id = -1, \ -} +#define FD_PARMS_INIT \ + (struct fd_parms) \ + { \ + .fd = FD_DESC_INVALID, .fown = FOWN_ENTRY__INIT, .link = NULL, .mnt_id = -1, \ + } extern int fill_fdlink(int lfd, const struct fd_parms *p, struct fd_link *link); extern uint32_t make_gen_id(uint32_t st_dev, uint32_t st_ino, uint64_t pos); @@ -83,15 +81,15 @@ enum { }; struct fdinfo_list_entry { - struct list_head desc_list; /* To chain on @fd_info_head */ - struct file_desc *desc; /* Associated file descriptor */ - struct list_head ps_list; /* To chain per-task files */ - struct pstree_item *task; - FdinfoEntry *fe; - int pid; - u8 received:1; - u8 stage:3; - u8 fake:1; + struct list_head desc_list; /* To chain on @fd_info_head */ + struct file_desc *desc; /* Associated file descriptor */ + struct list_head ps_list; /* To chain per-task files */ + struct pstree_item *task; + FdinfoEntry *fe; + int pid; + u8 received : 1; + u8 stage : 3; + u8 fake : 1; }; extern int inh_fd_max; @@ -99,55 +97,50 @@ extern int inh_fd_max; /* reports whether fd_a takes prio over fd_b */ static inline int fdinfo_rst_prio(struct fdinfo_list_entry *fd_a, struct fdinfo_list_entry *fd_b) { - return pid_rst_prio(fd_a->pid, fd_b->pid) || - ((fd_a->pid == fd_b->pid) && (fd_a->fe->fd < fd_b->fe->fd)); + return pid_rst_prio(fd_a->pid, fd_b->pid) || ((fd_a->pid == fd_b->pid) && (fd_a->fe->fd < fd_b->fe->fd)); } struct file_desc_ops { /* fd_types from images/fdinfo.proto */ - unsigned int type; + unsigned int type; /* * Opens a file by whatever syscall is required for that. * The returned descriptor may be closed (dup2-ed to another) * so it shouldn't be saved for any post-actions. */ - int (*open)(struct file_desc *d, int *new_fd); - char * (*name)(struct file_desc *, char *b, size_t s); + int (*open)(struct file_desc *d, int *new_fd); + char *(*name)(struct file_desc *, char *b, size_t s); }; int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info, bool ghost); -struct fdinfo_list_entry *collect_fd_to(int pid, FdinfoEntry *e, - struct rst_info *rst_info, struct file_desc *fdesc, - bool fake, bool force_master); +struct fdinfo_list_entry *collect_fd_to(int pid, FdinfoEntry *e, struct rst_info *rst_info, struct file_desc *fdesc, + bool fake, bool force_master); u32 find_unused_file_desc_id(void); unsigned int find_unused_fd(struct pstree_item *, int hint_fd); struct fdinfo_list_entry *find_used_fd(struct pstree_item *, int fd); struct file_desc { - u32 id; /* File id, unique */ - struct hlist_node hash; /* Descriptor hashing and lookup */ - struct list_head fd_info_head; /* Chain of fdinfo_list_entry-s with same ID and type but different pids */ - struct file_desc_ops *ops; /* Associated operations */ - struct list_head fake_master_list;/* To chain in the list of file_desc, which don't + u32 id; /* File id, unique */ + struct hlist_node hash; /* Descriptor hashing and lookup */ + struct list_head fd_info_head; /* Chain of fdinfo_list_entry-s with same ID and type but different pids */ + struct file_desc_ops *ops; /* Associated operations */ + struct list_head fake_master_list; /* To chain in the list of file_desc, which don't have a fle in a task, that having permissions */ }; struct fdtype_ops { - unsigned int type; - int (*dump)(int lfd, u32 id, const struct fd_parms *p); - int (*pre_dump)(int pid, int lfd); + unsigned int type; + int (*dump)(int lfd, u32 id, const struct fd_parms *p); + int (*pre_dump)(int pid, int lfd); }; struct cr_img; extern int dump_my_file(int lfd, u32 *, int *type); -extern int do_dump_gen_file(struct fd_parms *p, int lfd, - const struct fdtype_ops *ops, - FdinfoEntry *e); +extern int do_dump_gen_file(struct fd_parms *p, int lfd, const struct fdtype_ops *ops, FdinfoEntry *e); struct parasite_drain_fd; -int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item, - struct parasite_drain_fd *dfds); +int dump_task_files_seized(struct parasite_ctl *ctl, struct pstree_item *item, struct parasite_drain_fd *dfds); int predump_task_files(int pid); extern void file_desc_init(struct file_desc *d, u32 id, struct file_desc_ops *ops); @@ -179,13 +172,12 @@ extern int close_old_fds(void); #define AT_EMPTY_PATH 0x1000 #endif -#define LREMAP_PARAM "link-remap" +#define LREMAP_PARAM "link-remap" extern int shared_fdt_prepare(struct pstree_item *item); extern struct collect_image_info ext_file_cinfo; -extern int dump_unsupp_fd(struct fd_parms *p, int lfd, - char *more, char *info, FdinfoEntry *); +extern int dump_unsupp_fd(struct fd_parms *p, int lfd, char *more, char *info, FdinfoEntry *); extern int inherit_fd_parse(char *optarg); extern int inherit_fd_add(int fd, char *key); @@ -197,8 +189,7 @@ extern int inherit_fd_lookup_id(char *id); extern bool inherited_fd(struct file_desc *, int *fdp); extern FdinfoEntry *dup_fdinfo(FdinfoEntry *old, int fd, unsigned flags); -int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple, - int fd, unsigned flags); +int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple, int fd, unsigned flags); extern int open_transport_socket(void); extern int set_fds_event(pid_t virt); diff --git a/criu/include/filesystems.h b/criu/include/filesystems.h index bd798062d..251e9e2aa 100644 --- a/criu/include/filesystems.h +++ b/criu/include/filesystems.h @@ -5,8 +5,7 @@ extern struct fstype *decode_fstype(u32 fst); extern bool add_fsname_auto(const char *names); struct mount_info; -typedef int (*mount_fn_t)(struct mount_info *mi, const char *src, const - char *fstype, unsigned long mountflags); +typedef int (*mount_fn_t)(struct mount_info *mi, const char *src, const char *fstype, unsigned long mountflags); struct fstype { char *name; diff --git a/criu/include/fs-magic.h b/criu/include/fs-magic.h index ced3377f9..46ac8aa27 100644 --- a/criu/include/fs-magic.h +++ b/criu/include/fs-magic.h @@ -10,47 +10,47 @@ */ #ifndef NFS_SUPER_MAGIC -# define NFS_SUPER_MAGIC 0x6969 +#define NFS_SUPER_MAGIC 0x6969 #endif #ifndef PIPEFS_MAGIC -# define PIPEFS_MAGIC 0x50495045 +#define PIPEFS_MAGIC 0x50495045 #endif #ifndef ANON_INODE_FS_MAGIC -# define ANON_INODE_FS_MAGIC 0x09041934 +#define ANON_INODE_FS_MAGIC 0x09041934 #endif #ifndef TMPFS_MAGIC -# define TMPFS_MAGIC 0x01021994 +#define TMPFS_MAGIC 0x01021994 #endif #ifndef SOCKFS_MAGIC -# define SOCKFS_MAGIC 0x534f434b +#define SOCKFS_MAGIC 0x534f434b #endif #ifndef DEVPTS_SUPER_MAGIC -#define DEVPTS_SUPER_MAGIC 0x1cd1 +#define DEVPTS_SUPER_MAGIC 0x1cd1 #endif #ifndef BTRFS_SUPER_MAGIC -#define BTRFS_SUPER_MAGIC 0x9123683E +#define BTRFS_SUPER_MAGIC 0x9123683E #endif #ifndef AUFS_SUPER_MAGIC -#define AUFS_SUPER_MAGIC 0x61756673 +#define AUFS_SUPER_MAGIC 0x61756673 #endif #ifndef PROC_SUPER_MAGIC -#define PROC_SUPER_MAGIC 0x9fa0 +#define PROC_SUPER_MAGIC 0x9fa0 #endif #ifndef BINFMTFS_MAGIC -#define BINFMTFS_MAGIC 0x42494e4d +#define BINFMTFS_MAGIC 0x42494e4d #endif #ifndef AUTOFS_SUPER_MAGIC -#define AUTOFS_SUPER_MAGIC 0x0187 +#define AUTOFS_SUPER_MAGIC 0x0187 #endif #endif /* __CR_FS_MAGIC_H__ */ diff --git a/criu/include/fsnotify.h b/criu/include/fsnotify.h index 935dd60f4..3435f0c86 100644 --- a/criu/include/fsnotify.h +++ b/criu/include/fsnotify.h @@ -9,7 +9,7 @@ #define KERNEL_FS_EVENT_ON_CHILD 0x08000000 #ifndef INOTIFY_IOC_SETNEXTWD -#define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, __s32) +#define INOTIFY_IOC_SETNEXTWD _IOW('I', 0, __s32) #endif extern int is_inotify_link(char *link); diff --git a/criu/include/image-desc.h b/criu/include/image-desc.h index f69cc5824..384d6d07b 100644 --- a/criu/include/image-desc.h +++ b/criu/include/image-desc.h @@ -120,9 +120,9 @@ enum { /* file descriptors template */ struct cr_fd_desc_tmpl { - const char *fmt; /* format for the name */ - u32 magic; /* magic in the header */ - int oflags; /* flags for image_open */ + const char *fmt; /* format for the name */ + u32 magic; /* magic in the header */ + int oflags; /* flags for image_open */ }; extern struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX]; diff --git a/criu/include/image.h b/criu/include/image.h index 7c45381db..14659dbd2 100644 --- a/criu/include/image.h +++ b/criu/include/image.h @@ -12,14 +12,14 @@ #include "log.h" #include "common/bug.h" -#define PAGE_RSS 1 -#define PAGE_ANON 2 +#define PAGE_RSS 1 +#define PAGE_ANON 2 /* * Top bit set in the tgt id means we've remapped * to a ghost file. */ -#define REMAP_GHOST (1 << 31) +#define REMAP_GHOST (1 << 31) /* * VMA_AREA status: @@ -67,30 +67,30 @@ * are part of image ABI, this particular one must never * be used in image. */ -#define VMA_AREA_NONE (0 << 0) -#define VMA_AREA_REGULAR (1 << 0) -#define VMA_AREA_STACK (1 << 1) -#define VMA_AREA_VSYSCALL (1 << 2) -#define VMA_AREA_VDSO (1 << 3) -#define VMA_AREA_HEAP (1 << 5) +#define VMA_AREA_NONE (0 << 0) +#define VMA_AREA_REGULAR (1 << 0) +#define VMA_AREA_STACK (1 << 1) +#define VMA_AREA_VSYSCALL (1 << 2) +#define VMA_AREA_VDSO (1 << 3) +#define VMA_AREA_HEAP (1 << 5) -#define VMA_FILE_PRIVATE (1 << 6) -#define VMA_FILE_SHARED (1 << 7) -#define VMA_ANON_SHARED (1 << 8) -#define VMA_ANON_PRIVATE (1 << 9) +#define VMA_FILE_PRIVATE (1 << 6) +#define VMA_FILE_SHARED (1 << 7) +#define VMA_ANON_SHARED (1 << 8) +#define VMA_ANON_PRIVATE (1 << 9) -#define VMA_AREA_SYSVIPC (1 << 10) -#define VMA_AREA_SOCKET (1 << 11) -#define VMA_AREA_VVAR (1 << 12) -#define VMA_AREA_AIORING (1 << 13) -#define VMA_AREA_MEMFD (1 << 14) +#define VMA_AREA_SYSVIPC (1 << 10) +#define VMA_AREA_SOCKET (1 << 11) +#define VMA_AREA_VVAR (1 << 12) +#define VMA_AREA_AIORING (1 << 13) +#define VMA_AREA_MEMFD (1 << 14) -#define VMA_CLOSE (1 << 28) -#define VMA_NO_PROT_WRITE (1 << 29) -#define VMA_PREMMAPED (1 << 30) -#define VMA_UNSUPP (1 << 31) +#define VMA_CLOSE (1 << 28) +#define VMA_NO_PROT_WRITE (1 << 29) +#define VMA_PREMMAPED (1 << 30) +#define VMA_UNSUPP (1 << 31) -#define CR_CAP_SIZE 2 +#define CR_CAP_SIZE 2 #define TASK_COMM_LEN 16 @@ -99,11 +99,11 @@ extern bool ns_per_id; extern bool img_common_magic; -#define O_NOBUF (O_DIRECT) -#define O_SERVICE (O_DIRECTORY) -#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC) -#define O_RSTR (O_RDONLY) -#define O_FORCE_LOCAL (O_SYNC) +#define O_NOBUF (O_DIRECT) +#define O_SERVICE (O_DIRECTORY) +#define O_DUMP (O_WRONLY | O_CREAT | O_TRUNC) +#define O_RSTR (O_RDONLY) +#define O_FORCE_LOCAL (O_SYNC) struct cr_img { union { @@ -117,8 +117,8 @@ struct cr_img { }; }; -#define EMPTY_IMG_FD (-404) -#define LAZY_IMG_FD (-505) +#define EMPTY_IMG_FD (-404) +#define LAZY_IMG_FD (-505) static inline bool empty_image(struct cr_img *img) { @@ -164,11 +164,11 @@ extern void up_page_ids_base(void); extern struct cr_img *img_from_fd(int fd); /* for cr-show mostly */ extern int write_img_buf(struct cr_img *, const void *ptr, int size); -#define write_img(img, ptr) write_img_buf((img), (ptr), sizeof(*(ptr))) +#define write_img(img, ptr) write_img_buf((img), (ptr), sizeof(*(ptr))) extern int read_img_buf_eof(struct cr_img *, void *ptr, int size); -#define read_img_eof(img, ptr) read_img_buf_eof((img), (ptr), sizeof(*(ptr))) +#define read_img_eof(img, ptr) read_img_buf_eof((img), (ptr), sizeof(*(ptr))) extern int read_img_buf(struct cr_img *, void *ptr, int size); -#define read_img(img, ptr) read_img_buf((img), (ptr), sizeof(*(ptr))) +#define read_img(img, ptr) read_img_buf((img), (ptr), sizeof(*(ptr))) extern int read_img_str(struct cr_img *, char **pstr, int size); extern void close_image(struct cr_img *); diff --git a/criu/include/imgset.h b/criu/include/imgset.h index 02ad169df..9846f6cdc 100644 --- a/criu/include/imgset.h +++ b/criu/include/imgset.h @@ -27,10 +27,8 @@ extern struct cr_imgset *glob_imgset; extern struct cr_fd_desc_tmpl imgset_template[CR_FD_MAX]; extern struct cr_imgset *cr_task_imgset_open(int pid, int mode); -extern struct cr_imgset *cr_imgset_open_range(int pid, int from, int to, - unsigned long flags); -#define cr_imgset_open(pid, type, flags) cr_imgset_open_range(pid, \ - _CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags) +extern struct cr_imgset *cr_imgset_open_range(int pid, int from, int to, unsigned long flags); +#define cr_imgset_open(pid, type, flags) cr_imgset_open_range(pid, _CR_FD_##type##_FROM, _CR_FD_##type##_TO, flags) extern struct cr_imgset *cr_glob_imgset_open(int mode); extern void close_cr_imgset(struct cr_imgset **cr_imgset); diff --git a/criu/include/inet_diag.h b/criu/include/inet_diag.h index 95be2c19d..ea6f5e14e 100644 --- a/criu/include/inet_diag.h +++ b/criu/include/inet_diag.h @@ -4,42 +4,42 @@ #include /* Just some random number */ -#define TCPDIAG_GETSOCK 18 +#define TCPDIAG_GETSOCK 18 #define DCCPDIAG_GETSOCK 19 #define INET_DIAG_GETSOCK_MAX 24 /* Socket identity */ struct inet_diag_sockid { - __be16 idiag_sport; - __be16 idiag_dport; - __be32 idiag_src[4]; - __be32 idiag_dst[4]; - __u32 idiag_if; - __u32 idiag_cookie[2]; + __be16 idiag_sport; + __be16 idiag_dport; + __be32 idiag_src[4]; + __be32 idiag_dst[4]; + __u32 idiag_if; + __u32 idiag_cookie[2]; #define INET_DIAG_NOCOOKIE (~0U) }; /* Request structure */ struct inet_diag_req_compat { - __u8 idiag_family; /* Family of addresses. */ - __u8 idiag_src_len; - __u8 idiag_dst_len; - __u8 idiag_ext; /* Query extended information */ + __u8 idiag_family; /* Family of addresses. */ + __u8 idiag_src_len; + __u8 idiag_dst_len; + __u8 idiag_ext; /* Query extended information */ struct inet_diag_sockid id; - __u32 idiag_states; /* States to dump */ - __u32 idiag_dbs; /* Tables to dump (NI) */ + __u32 idiag_states; /* States to dump */ + __u32 idiag_dbs; /* Tables to dump (NI) */ }; struct inet_diag_req_v2 { - __u8 sdiag_family; - __u8 sdiag_protocol; - __u8 idiag_ext; - __u8 pad; - __u32 idiag_states; + __u8 sdiag_family; + __u8 sdiag_protocol; + __u8 idiag_ext; + __u8 pad; + __u32 idiag_states; struct inet_diag_sockid id; }; @@ -57,9 +57,9 @@ enum { */ struct inet_diag_bc_op { - unsigned char code; - unsigned char yes; - unsigned short no; + unsigned char code; + unsigned char yes; + unsigned short no; }; enum { @@ -75,27 +75,27 @@ enum { }; struct inet_diag_hostcond { - __u8 family; - __u8 prefix_len; - int port; - __be32 addr[0]; + __u8 family; + __u8 prefix_len; + int port; + __be32 addr[0]; }; /* Base info structure. It contains socket identity (addrs/ports/cookie) * and, alas, the information shown by netstat. */ struct inet_diag_msg { - __u8 idiag_family; - __u8 idiag_state; - __u8 idiag_timer; - __u8 idiag_retrans; + __u8 idiag_family; + __u8 idiag_state; + __u8 idiag_timer; + __u8 idiag_retrans; struct inet_diag_sockid id; - __u32 idiag_expires; - __u32 idiag_rqueue; - __u32 idiag_wqueue; - __u32 idiag_uid; - __u32 idiag_inode; + __u32 idiag_expires; + __u32 idiag_rqueue; + __u32 idiag_wqueue; + __u32 idiag_uid; + __u32 idiag_inode; }; /* Extensions */ @@ -114,23 +114,22 @@ enum { #define INET_DIAG_MAX INET_DIAG_SHUTDOWN - /* INET_DIAG_MEM */ struct inet_diag_meminfo { - __u32 idiag_rmem; - __u32 idiag_wmem; - __u32 idiag_fmem; - __u32 idiag_tmem; + __u32 idiag_rmem; + __u32 idiag_wmem; + __u32 idiag_fmem; + __u32 idiag_tmem; }; /* INET_DIAG_VEGASINFO */ struct tcpvegas_info { - __u32 tcpv_enabled; - __u32 tcpv_rttcnt; - __u32 tcpv_rtt; - __u32 tcpv_minrtt; + __u32 tcpv_enabled; + __u32 tcpv_rttcnt; + __u32 tcpv_rtt; + __u32 tcpv_minrtt; }; #endif /* __CR_INET_DIAG_H__ */ diff --git a/criu/include/irmap.h b/criu/include/irmap.h index 188d753f4..e668952b8 100644 --- a/criu/include/irmap.h +++ b/criu/include/irmap.h @@ -4,12 +4,10 @@ #include "images/fh.pb-c.h" char *irmap_lookup(unsigned int s_dev, unsigned long i_ino); -int irmap_queue_cache(unsigned int dev, unsigned long ino, - FhEntry *fh); +int irmap_queue_cache(unsigned int dev, unsigned long ino, FhEntry *fh); int irmap_predump_prep(void); int irmap_predump_run(void); -int check_open_handle(unsigned int s_dev, unsigned long i_ino, - FhEntry *f_handle); +int check_open_handle(unsigned int s_dev, unsigned long i_ino, FhEntry *f_handle); int irmap_load_cache(void); int irmap_scan_path_add(char *path); #endif diff --git a/criu/include/kcmp-ids.h b/criu/include/kcmp-ids.h index a37622c50..b6cdbb262 100644 --- a/criu/include/kcmp-ids.h +++ b/criu/include/kcmp-ids.h @@ -7,30 +7,26 @@ #include "kcmp.h" struct kid_tree { - struct rb_root root; - unsigned int kcmp_type; - unsigned long subid; - + struct rb_root root; + unsigned int kcmp_type; + unsigned long subid; }; -#define DECLARE_KCMP_TREE(name, type) \ - struct kid_tree name = { \ - .root = RB_ROOT, \ - .kcmp_type = type, \ - .subid = 1, \ +#define DECLARE_KCMP_TREE(name, type) \ + struct kid_tree name = { \ + .root = RB_ROOT, \ + .kcmp_type = type, \ + .subid = 1, \ } struct kid_elem { - pid_t pid; - unsigned int genid; - unsigned int idx; + pid_t pid; + unsigned int genid; + unsigned int idx; }; -extern uint32_t kid_generate_gen(struct kid_tree *tree, - struct kid_elem *elem, int *new_id); +extern uint32_t kid_generate_gen(struct kid_tree *tree, struct kid_elem *elem, int *new_id); -extern struct kid_elem *kid_lookup_epoll_tfd(struct kid_tree *tree, - struct kid_elem *elem, - kcmp_epoll_slot_t *slot); +extern struct kid_elem *kid_lookup_epoll_tfd(struct kid_tree *tree, struct kid_elem *elem, kcmp_epoll_slot_t *slot); #endif /* __CR_KCMP_IDS_H__ */ diff --git a/criu/include/kcmp.h b/criu/include/kcmp.h index f1c898d71..a6774be47 100644 --- a/criu/include/kcmp.h +++ b/criu/include/kcmp.h @@ -18,9 +18,9 @@ enum kcmp_type { /* Slot for KCMP_EPOLL_TFD */ typedef struct { - uint32_t efd; /* epoll file descriptor */ - uint32_t tfd; /* target file number */ - uint32_t toff; /* target offset within same numbered sequence */ + uint32_t efd; /* epoll file descriptor */ + uint32_t tfd; /* target file number */ + uint32_t toff; /* target offset within same numbered sequence */ } kcmp_epoll_slot_t; #endif /* __CR_KCMP_H__ */ diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h index 97dbd17b3..3fb3b2492 100644 --- a/criu/include/kerndat.h +++ b/criu/include/kerndat.h @@ -18,8 +18,8 @@ extern int kerndat_init(void); enum pagemap_func { PM_UNKNOWN, - PM_DISABLED, /* /proc/pid/pagemap doesn't open (user mode) */ - PM_FLAGS_ONLY, /* pagemap zeroes pfn part (user mode) */ + PM_DISABLED, /* /proc/pid/pagemap doesn't open (user mode) */ + PM_FLAGS_ONLY, /* pagemap zeroes pfn part (user mode) */ PM_FULL, }; @@ -55,9 +55,9 @@ struct kerndat_s { bool has_thp_disable; bool can_map_vdso; bool vdso_hint_reliable; - struct vdso_symtable vdso_sym; + struct vdso_symtable vdso_sym; #ifdef CONFIG_COMPAT - struct vdso_symtable vdso_sym_compat; + struct vdso_symtable vdso_sym_compat; #endif bool has_nsid; bool has_link_nsid; diff --git a/criu/include/libnetlink.h b/criu/include/libnetlink.h index f21a0e750..2cdb543c0 100644 --- a/criu/include/libnetlink.h +++ b/criu/include/libnetlink.h @@ -1,24 +1,21 @@ #ifndef __CR_LIBNETLINK_H__ #define __CR_LIBNETLINK_H__ -#define CR_NLMSG_SEQ 24680 /* arbitrary chosen */ +#define CR_NLMSG_SEQ 24680 /* arbitrary chosen */ struct ns_id; extern int do_rtnl_req(int nl, void *req, int size, - int (*receive_callback)(struct nlmsghdr *h, struct ns_id *ns, void *), - int (*error_callback)(int err, struct ns_id *ns, void *), struct ns_id *ns, void *); + int (*receive_callback)(struct nlmsghdr *h, struct ns_id *ns, void *), + int (*error_callback)(int err, struct ns_id *ns, void *), struct ns_id *ns, void *); -extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, - const void *data, int alen); +extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen); extern int32_t nla_get_s32(const struct nlattr *nla); -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) +#define NLMSG_TAIL(nmsg) ((struct rtattr *)(((void *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) #ifndef NETNS_RTA -#define NETNS_RTA(r) \ - ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) +#define NETNS_RTA(r) ((struct rtattr *)(((char *)(r)) + NLMSG_ALIGN(sizeof(struct rtgenmsg)))) #endif #endif /* __CR_LIBNETLINK_H__ */ diff --git a/criu/include/linux/mount.h b/criu/include/linux/mount.h index aa6be69ec..840d6277e 100644 --- a/criu/include/linux/mount.h +++ b/criu/include/linux/mount.h @@ -8,14 +8,14 @@ #include #else enum fsconfig_command { - FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ - FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ - FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ - FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ - FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ - FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ - FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ - FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ + FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */ + FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */ + FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */ + FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */ + FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */ + FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */ + FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */ + FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */ }; #endif diff --git a/criu/include/linux/userfaultfd.h b/criu/include/linux/userfaultfd.h index 3b059530d..cfcf48571 100644 --- a/criu/include/linux/userfaultfd.h +++ b/criu/include/linux/userfaultfd.h @@ -18,23 +18,12 @@ * means the userland is reading). */ #define UFFD_API ((__u64)0xAA) -#define UFFD_API_FEATURES (UFFD_FEATURE_EVENT_FORK | \ - UFFD_FEATURE_EVENT_REMAP | \ - UFFD_FEATURE_EVENT_REMOVE | \ - UFFD_FEATURE_EVENT_UNMAP | \ - UFFD_FEATURE_MISSING_HUGETLBFS | \ - UFFD_FEATURE_MISSING_SHMEM) -#define UFFD_API_IOCTLS \ - ((__u64)1 << _UFFDIO_REGISTER | \ - (__u64)1 << _UFFDIO_UNREGISTER | \ - (__u64)1 << _UFFDIO_API) -#define UFFD_API_RANGE_IOCTLS \ - ((__u64)1 << _UFFDIO_WAKE | \ - (__u64)1 << _UFFDIO_COPY | \ - (__u64)1 << _UFFDIO_ZEROPAGE) -#define UFFD_API_RANGE_IOCTLS_BASIC \ - ((__u64)1 << _UFFDIO_WAKE | \ - (__u64)1 << _UFFDIO_COPY) +#define UFFD_API_FEATURES \ + (UFFD_FEATURE_EVENT_FORK | UFFD_FEATURE_EVENT_REMAP | UFFD_FEATURE_EVENT_REMOVE | UFFD_FEATURE_EVENT_UNMAP | \ + UFFD_FEATURE_MISSING_HUGETLBFS | UFFD_FEATURE_MISSING_SHMEM) +#define UFFD_API_IOCTLS ((__u64)1 << _UFFDIO_REGISTER | (__u64)1 << _UFFDIO_UNREGISTER | (__u64)1 << _UFFDIO_API) +#define UFFD_API_RANGE_IOCTLS ((__u64)1 << _UFFDIO_WAKE | (__u64)1 << _UFFDIO_COPY | (__u64)1 << _UFFDIO_ZEROPAGE) +#define UFFD_API_RANGE_IOCTLS_BASIC ((__u64)1 << _UFFDIO_WAKE | (__u64)1 << _UFFDIO_COPY) /* * Valid ioctl command number range with this API is from 0x00 to @@ -44,62 +33,56 @@ * which ioctl the running kernel implements through the ioctl command * bitmask written by the UFFDIO_API. */ -#define _UFFDIO_REGISTER (0x00) -#define _UFFDIO_UNREGISTER (0x01) -#define _UFFDIO_WAKE (0x02) -#define _UFFDIO_COPY (0x03) -#define _UFFDIO_ZEROPAGE (0x04) -#define _UFFDIO_API (0x3F) +#define _UFFDIO_REGISTER (0x00) +#define _UFFDIO_UNREGISTER (0x01) +#define _UFFDIO_WAKE (0x02) +#define _UFFDIO_COPY (0x03) +#define _UFFDIO_ZEROPAGE (0x04) +#define _UFFDIO_API (0x3F) /* userfaultfd ioctl ids */ -#define UFFDIO 0xAA -#define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, \ - struct uffdio_api) -#define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, \ - struct uffdio_register) -#define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, \ - struct uffdio_range) -#define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, \ - struct uffdio_range) -#define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, \ - struct uffdio_copy) -#define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, \ - struct uffdio_zeropage) +#define UFFDIO 0xAA +#define UFFDIO_API _IOWR(UFFDIO, _UFFDIO_API, struct uffdio_api) +#define UFFDIO_REGISTER _IOWR(UFFDIO, _UFFDIO_REGISTER, struct uffdio_register) +#define UFFDIO_UNREGISTER _IOR(UFFDIO, _UFFDIO_UNREGISTER, struct uffdio_range) +#define UFFDIO_WAKE _IOR(UFFDIO, _UFFDIO_WAKE, struct uffdio_range) +#define UFFDIO_COPY _IOWR(UFFDIO, _UFFDIO_COPY, struct uffdio_copy) +#define UFFDIO_ZEROPAGE _IOWR(UFFDIO, _UFFDIO_ZEROPAGE, struct uffdio_zeropage) /* read() structure */ struct uffd_msg { - __u8 event; + __u8 event; - __u8 reserved1; - __u16 reserved2; - __u32 reserved3; + __u8 reserved1; + __u16 reserved2; + __u32 reserved3; union { struct { - __u64 flags; - __u64 address; + __u64 flags; + __u64 address; } pagefault; struct { - __u32 ufd; + __u32 ufd; } fork; struct { - __u64 from; - __u64 to; - __u64 len; + __u64 from; + __u64 to; + __u64 len; } remap; struct { - __u64 start; - __u64 end; + __u64 start; + __u64 end; } remove; struct { /* unused reserved fields */ - __u64 reserved1; - __u64 reserved2; - __u64 reserved3; + __u64 reserved1; + __u64 reserved2; + __u64 reserved3; } reserved; } arg; } __packed; @@ -107,15 +90,15 @@ struct uffd_msg { /* * Start at 0x12 and not at 0 to be more strict against bugs. */ -#define UFFD_EVENT_PAGEFAULT 0x12 -#define UFFD_EVENT_FORK 0x13 -#define UFFD_EVENT_REMAP 0x14 -#define UFFD_EVENT_REMOVE 0x15 -#define UFFD_EVENT_UNMAP 0x16 +#define UFFD_EVENT_PAGEFAULT 0x12 +#define UFFD_EVENT_FORK 0x13 +#define UFFD_EVENT_REMAP 0x14 +#define UFFD_EVENT_REMOVE 0x15 +#define UFFD_EVENT_UNMAP 0x16 /* flags for UFFD_EVENT_PAGEFAULT */ -#define UFFD_PAGEFAULT_FLAG_WRITE (1<<0) /* If this was a write fault */ -#define UFFD_PAGEFAULT_FLAG_WP (1<<1) /* If reason is VM_UFFD_WP */ +#define UFFD_PAGEFAULT_FLAG_WRITE (1 << 0) /* If this was a write fault */ +#define UFFD_PAGEFAULT_FLAG_WP (1 << 1) /* If reason is VM_UFFD_WP */ struct uffdio_api { /* userland asks for an API number and the features to enable */ @@ -154,13 +137,13 @@ struct uffdio_api { * UFFD_FEATURE_MISSING_HUGETLBFS, but it applies to shmem * (i.e. tmpfs and other shmem based APIs). */ -#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) -#define UFFD_FEATURE_EVENT_FORK (1<<1) -#define UFFD_FEATURE_EVENT_REMAP (1<<2) -#define UFFD_FEATURE_EVENT_REMOVE (1<<3) -#define UFFD_FEATURE_MISSING_HUGETLBFS (1<<4) -#define UFFD_FEATURE_MISSING_SHMEM (1<<5) -#define UFFD_FEATURE_EVENT_UNMAP (1<<6) +#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1 << 0) +#define UFFD_FEATURE_EVENT_FORK (1 << 1) +#define UFFD_FEATURE_EVENT_REMAP (1 << 2) +#define UFFD_FEATURE_EVENT_REMOVE (1 << 3) +#define UFFD_FEATURE_MISSING_HUGETLBFS (1 << 4) +#define UFFD_FEATURE_MISSING_SHMEM (1 << 5) +#define UFFD_FEATURE_EVENT_UNMAP (1 << 6) __u64 features; __u64 ioctls; @@ -173,8 +156,8 @@ struct uffdio_range { struct uffdio_register { struct uffdio_range range; -#define UFFDIO_REGISTER_MODE_MISSING ((__u64)1<<0) -#define UFFDIO_REGISTER_MODE_WP ((__u64)1<<1) +#define UFFDIO_REGISTER_MODE_MISSING ((__u64)1 << 0) +#define UFFDIO_REGISTER_MODE_WP ((__u64)1 << 1) __u64 mode; /* @@ -194,7 +177,7 @@ struct uffdio_copy { * available if the wrprotection ioctl are implemented for the * range according to the uffdio_register.ioctls. */ -#define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1<<0) +#define UFFDIO_COPY_MODE_DONTWAKE ((__u64)1 << 0) __u64 mode; /* @@ -206,7 +189,7 @@ struct uffdio_copy { struct uffdio_zeropage { struct uffdio_range range; -#define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64)1<<0) +#define UFFDIO_ZEROPAGE_MODE_DONTWAKE ((__u64)1 << 0) __u64 mode; /* diff --git a/criu/include/log.h b/criu/include/log.h index 58d012337..85e6dc2e7 100644 --- a/criu/include/log.h +++ b/criu/include/log.h @@ -11,71 +11,54 @@ #endif /* CR_NOGLIBC */ -#define LOG_UNSET (-1) -#define LOG_MSG (0) /* Print message regardless of log level */ -#define LOG_ERROR (1) /* Errors only, when we're in trouble */ -#define LOG_WARN (2) /* Warnings, dazen and confused but trying to continue */ -#define LOG_INFO (3) /* Informative, everything is fine */ -#define LOG_DEBUG (4) /* Debug only */ +#define LOG_UNSET (-1) +#define LOG_MSG (0) /* Print message regardless of log level */ +#define LOG_ERROR (1) /* Errors only, when we're in trouble */ +#define LOG_WARN (2) /* Warnings, dazen and confused but trying to continue */ +#define LOG_INFO (3) /* Informative, everything is fine */ +#define LOG_DEBUG (4) /* Debug only */ -#define DEFAULT_LOGLEVEL LOG_WARN +#define DEFAULT_LOGLEVEL LOG_WARN /* * This is low-level printing helper, try hard not to use it directly * and use the pr_foo() helpers below. */ extern void print_on_level(unsigned int loglevel, const char *format, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); + __attribute__((__format__(__printf__, 2, 3))); #ifndef LOG_PREFIX -# define LOG_PREFIX +#define LOG_PREFIX #endif void flush_early_log_buffer(int fd); -#define print_once(loglevel, fmt, ...) \ - do { \ - static bool __printed; \ - if (!__printed) { \ - print_on_level(loglevel, fmt, ##__VA_ARGS__); \ - __printed = 1; \ - } \ +#define print_once(loglevel, fmt, ...) \ + do { \ + static bool __printed; \ + if (!__printed) { \ + print_on_level(loglevel, fmt, ##__VA_ARGS__); \ + __printed = 1; \ + } \ } while (0) -#define pr_msg(fmt, ...) \ - print_on_level(LOG_MSG, \ - fmt, ##__VA_ARGS__) +#define pr_msg(fmt, ...) print_on_level(LOG_MSG, fmt, ##__VA_ARGS__) -#define pr_info(fmt, ...) \ - print_on_level(LOG_INFO, \ - LOG_PREFIX fmt, ##__VA_ARGS__) +#define pr_info(fmt, ...) print_on_level(LOG_INFO, LOG_PREFIX fmt, ##__VA_ARGS__) -#define pr_err(fmt, ...) \ - print_on_level(LOG_ERROR, \ - "Error (%s:%d): " LOG_PREFIX fmt, \ - __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_err(fmt, ...) print_on_level(LOG_ERROR, "Error (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__) -#define pr_err_once(fmt, ...) \ - print_once(LOG_ERROR, fmt, ##__VA_ARGS__) +#define pr_err_once(fmt, ...) print_once(LOG_ERROR, fmt, ##__VA_ARGS__) -#define pr_warn(fmt, ...) \ - print_on_level(LOG_WARN, \ - "Warn (%s:%d): " LOG_PREFIX fmt, \ - __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_warn(fmt, ...) print_on_level(LOG_WARN, "Warn (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__) -#define pr_warn_once(fmt, ...) \ - print_once(LOG_WARN, \ - "Warn (%s:%d): " LOG_PREFIX fmt, \ - __FILE__, __LINE__, ##__VA_ARGS__) +#define pr_warn_once(fmt, ...) print_once(LOG_WARN, "Warn (%s:%d): " LOG_PREFIX fmt, __FILE__, __LINE__, ##__VA_ARGS__) -#define pr_debug(fmt, ...) \ - print_on_level(LOG_DEBUG, \ - LOG_PREFIX fmt, ##__VA_ARGS__) +#define pr_debug(fmt, ...) print_on_level(LOG_DEBUG, LOG_PREFIX fmt, ##__VA_ARGS__) #ifndef CR_NOGLIBC -#define pr_perror(fmt, ...) \ - pr_err(fmt ": %s\n", ##__VA_ARGS__, strerror(errno)) +#define pr_perror(fmt, ...) pr_err(fmt ": %s\n", ##__VA_ARGS__, strerror(errno)) #endif /* CR_NOGLIBC */ diff --git a/criu/include/lsm.h b/criu/include/lsm.h index a41915a4c..0004caafb 100644 --- a/criu/include/lsm.h +++ b/criu/include/lsm.h @@ -41,13 +41,16 @@ int dump_xattr_security_selinux(int fd, FdinfoEntry *e); int run_setsockcreatecon(FdinfoEntry *e); int reset_setsockcreatecon(void); #else -static inline int dump_xattr_security_selinux(int fd, FdinfoEntry *e) { +static inline int dump_xattr_security_selinux(int fd, FdinfoEntry *e) +{ return 0; } -static inline int run_setsockcreatecon(FdinfoEntry *e) { +static inline int run_setsockcreatecon(FdinfoEntry *e) +{ return 0; } -static inline int reset_setsockcreatecon(void) { +static inline int reset_setsockcreatecon(void) +{ return 0; } #endif diff --git a/criu/include/magic.h b/criu/include/magic.h index ec87c82bf..50e3b6b35 100644 --- a/criu/include/magic.h +++ b/criu/include/magic.h @@ -5,127 +5,127 @@ * Basic multi-file images */ -#define CRTOOLS_IMAGES_V1 1 +#define CRTOOLS_IMAGES_V1 1 /* * v1.1 has common magic in the head of each image file, * except for inventory */ -#define CRTOOLS_IMAGES_V1_1 2 +#define CRTOOLS_IMAGES_V1_1 2 /* * Raw images are images in which data is stored in some * non-crtool format (ip tool dumps, tarballs, etc.) */ -#define RAW_IMAGE_MAGIC 0x0 +#define RAW_IMAGE_MAGIC 0x0 /* * Images have the IMG_COMMON_MAGIC in the head. Service files * such as stats and irmap-cache have the IMG_SERVICE_MAGIC. */ -#define IMG_COMMON_MAGIC 0x54564319 /* Sarov (a.k.a. Arzamas-16) */ -#define IMG_SERVICE_MAGIC 0x55105940 /* Zlatoust */ +#define IMG_COMMON_MAGIC 0x54564319 /* Sarov (a.k.a. Arzamas-16) */ +#define IMG_SERVICE_MAGIC 0x55105940 /* Zlatoust */ /* * The magic-s below correspond to coordinates * of various Russian towns in the NNNNEEEE form. */ -#define INVENTORY_MAGIC 0x58313116 /* Veliky Novgorod */ -#define PSTREE_MAGIC 0x50273030 /* Kyiv */ -#define FDINFO_MAGIC 0x56213732 /* Dmitrov */ -#define PAGEMAP_MAGIC 0x56084025 /* Vladimir */ -#define SHMEM_PAGEMAP_MAGIC PAGEMAP_MAGIC -#define PAGES_MAGIC RAW_IMAGE_MAGIC -#define CORE_MAGIC 0x55053847 /* Kolomna */ -#define IDS_MAGIC 0x54432030 /* Konigsberg */ -#define VMAS_MAGIC 0x54123737 /* Tula */ -#define PIPES_MAGIC 0x56513555 /* Tver */ -#define PIPES_DATA_MAGIC 0x56453709 /* Dubna */ -#define FIFO_MAGIC 0x58364939 /* Kirov */ -#define FIFO_DATA_MAGIC 0x59333054 /* Tosno */ -#define SIGACT_MAGIC 0x55344201 /* Murom */ -#define UNIXSK_MAGIC 0x54373943 /* Ryazan */ -#define INETSK_MAGIC 0x56443851 /* Pereslavl */ -#define PACKETSK_MAGIC 0x60454618 /* Veliky Ustyug */ -#define ITIMERS_MAGIC 0x57464056 /* Kostroma */ -#define POSIX_TIMERS_MAGIC 0x52603957 /* Lipetsk */ -#define SK_QUEUES_MAGIC 0x56264026 /* Suzdal */ -#define UTSNS_MAGIC 0x54473203 /* Smolensk */ -#define CREDS_MAGIC 0x54023547 /* Kozelsk */ -#define IPC_VAR_MAGIC 0x53115007 /* Samara */ -#define IPCNS_SHM_MAGIC 0x46283044 /* Odessa */ -#define IPCNS_MSG_MAGIC 0x55453737 /* Moscow */ -#define IPCNS_SEM_MAGIC 0x59573019 /* St. Petersburg */ -#define REG_FILES_MAGIC 0x50363636 /* Belgorod */ -#define EXT_FILES_MAGIC 0x59255641 /* Usolye */ -#define FS_MAGIC 0x51403912 /* Voronezh */ -#define MM_MAGIC 0x57492820 /* Pskov */ -#define REMAP_FPATH_MAGIC 0x59133954 /* Vologda */ -#define GHOST_FILE_MAGIC 0x52583605 /* Oryol */ -#define TCP_STREAM_MAGIC 0x51465506 /* Orenburg */ -#define EVENTFD_FILE_MAGIC 0x44523722 /* Anapa */ -#define EVENTPOLL_FILE_MAGIC 0x45023858 /* Krasnodar */ -#define EVENTPOLL_TFD_MAGIC 0x44433746 /* Novorossiysk */ -#define SIGNALFD_MAGIC 0x57323820 /* Uglich */ -#define INOTIFY_FILE_MAGIC 0x48424431 /* Volgograd */ -#define INOTIFY_WD_MAGIC 0x54562009 /* Svetlogorsk (Rauschen) */ -#define MNTS_MAGIC 0x55563928 /* Petushki */ -#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */ -#define NETNS_MAGIC 0x55933752 /* Dolgoprudny */ -#define TTY_FILES_MAGIC 0x59433025 /* Pushkin */ -#define TTY_INFO_MAGIC 0x59453036 /* Kolpino */ -#define TTY_DATA_MAGIC 0x59413026 /* Pavlovsk */ -#define FILE_LOCKS_MAGIC 0x54323616 /* Kaluga */ -#define RLIMIT_MAGIC 0x57113925 /* Rostov */ -#define FANOTIFY_FILE_MAGIC 0x55096122 /* Chelyabinsk */ -#define FANOTIFY_MARK_MAGIC 0x56506035 /* Yekaterinburg */ -#define SIGNAL_MAGIC 0x59255647 /* Berezniki */ -#define PSIGNAL_MAGIC SIGNAL_MAGIC -#define NETLINK_SK_MAGIC 0x58005614 /* Perm */ -#define NS_FILES_MAGIC 0x61394011 /* Nyandoma */ -#define TUNFILE_MAGIC 0x57143751 /* Kalyazin */ -#define CGROUP_MAGIC 0x59383330 /* Tikhvin */ -#define TIMERFD_MAGIC 0x50493712 /* Korocha */ -#define CPUINFO_MAGIC 0x61404013 /* Nyandoma */ -#define USERNS_MAGIC 0x55474906 /* Kazan */ -#define SECCOMP_MAGIC 0x64413049 /* Kostomuksha */ -#define BINFMT_MISC_MAGIC 0x67343323 /* Apatity */ -#define AUTOFS_MAGIC 0x49353943 /* Sochi */ -#define FILES_MAGIC 0x56303138 /* Toropets */ -#define MEMFD_INODE_MAGIC 0x48453499 /* Dnipro */ -#define TIMENS_MAGIC 0x43114433 /* Beslan */ -#define PIDNS_MAGIC 0x61157326 /* Surgut */ -#define BPFMAP_FILE_MAGIC 0x57506142 /* Alapayevsk */ -#define BPFMAP_DATA_MAGIC 0x64324033 /* Arkhangelsk */ +#define INVENTORY_MAGIC 0x58313116 /* Veliky Novgorod */ +#define PSTREE_MAGIC 0x50273030 /* Kyiv */ +#define FDINFO_MAGIC 0x56213732 /* Dmitrov */ +#define PAGEMAP_MAGIC 0x56084025 /* Vladimir */ +#define SHMEM_PAGEMAP_MAGIC PAGEMAP_MAGIC +#define PAGES_MAGIC RAW_IMAGE_MAGIC +#define CORE_MAGIC 0x55053847 /* Kolomna */ +#define IDS_MAGIC 0x54432030 /* Konigsberg */ +#define VMAS_MAGIC 0x54123737 /* Tula */ +#define PIPES_MAGIC 0x56513555 /* Tver */ +#define PIPES_DATA_MAGIC 0x56453709 /* Dubna */ +#define FIFO_MAGIC 0x58364939 /* Kirov */ +#define FIFO_DATA_MAGIC 0x59333054 /* Tosno */ +#define SIGACT_MAGIC 0x55344201 /* Murom */ +#define UNIXSK_MAGIC 0x54373943 /* Ryazan */ +#define INETSK_MAGIC 0x56443851 /* Pereslavl */ +#define PACKETSK_MAGIC 0x60454618 /* Veliky Ustyug */ +#define ITIMERS_MAGIC 0x57464056 /* Kostroma */ +#define POSIX_TIMERS_MAGIC 0x52603957 /* Lipetsk */ +#define SK_QUEUES_MAGIC 0x56264026 /* Suzdal */ +#define UTSNS_MAGIC 0x54473203 /* Smolensk */ +#define CREDS_MAGIC 0x54023547 /* Kozelsk */ +#define IPC_VAR_MAGIC 0x53115007 /* Samara */ +#define IPCNS_SHM_MAGIC 0x46283044 /* Odessa */ +#define IPCNS_MSG_MAGIC 0x55453737 /* Moscow */ +#define IPCNS_SEM_MAGIC 0x59573019 /* St. Petersburg */ +#define REG_FILES_MAGIC 0x50363636 /* Belgorod */ +#define EXT_FILES_MAGIC 0x59255641 /* Usolye */ +#define FS_MAGIC 0x51403912 /* Voronezh */ +#define MM_MAGIC 0x57492820 /* Pskov */ +#define REMAP_FPATH_MAGIC 0x59133954 /* Vologda */ +#define GHOST_FILE_MAGIC 0x52583605 /* Oryol */ +#define TCP_STREAM_MAGIC 0x51465506 /* Orenburg */ +#define EVENTFD_FILE_MAGIC 0x44523722 /* Anapa */ +#define EVENTPOLL_FILE_MAGIC 0x45023858 /* Krasnodar */ +#define EVENTPOLL_TFD_MAGIC 0x44433746 /* Novorossiysk */ +#define SIGNALFD_MAGIC 0x57323820 /* Uglich */ +#define INOTIFY_FILE_MAGIC 0x48424431 /* Volgograd */ +#define INOTIFY_WD_MAGIC 0x54562009 /* Svetlogorsk (Rauschen) */ +#define MNTS_MAGIC 0x55563928 /* Petushki */ +#define NETDEV_MAGIC 0x57373951 /* Yaroslavl */ +#define NETNS_MAGIC 0x55933752 /* Dolgoprudny */ +#define TTY_FILES_MAGIC 0x59433025 /* Pushkin */ +#define TTY_INFO_MAGIC 0x59453036 /* Kolpino */ +#define TTY_DATA_MAGIC 0x59413026 /* Pavlovsk */ +#define FILE_LOCKS_MAGIC 0x54323616 /* Kaluga */ +#define RLIMIT_MAGIC 0x57113925 /* Rostov */ +#define FANOTIFY_FILE_MAGIC 0x55096122 /* Chelyabinsk */ +#define FANOTIFY_MARK_MAGIC 0x56506035 /* Yekaterinburg */ +#define SIGNAL_MAGIC 0x59255647 /* Berezniki */ +#define PSIGNAL_MAGIC SIGNAL_MAGIC +#define NETLINK_SK_MAGIC 0x58005614 /* Perm */ +#define NS_FILES_MAGIC 0x61394011 /* Nyandoma */ +#define TUNFILE_MAGIC 0x57143751 /* Kalyazin */ +#define CGROUP_MAGIC 0x59383330 /* Tikhvin */ +#define TIMERFD_MAGIC 0x50493712 /* Korocha */ +#define CPUINFO_MAGIC 0x61404013 /* Nyandoma */ +#define USERNS_MAGIC 0x55474906 /* Kazan */ +#define SECCOMP_MAGIC 0x64413049 /* Kostomuksha */ +#define BINFMT_MISC_MAGIC 0x67343323 /* Apatity */ +#define AUTOFS_MAGIC 0x49353943 /* Sochi */ +#define FILES_MAGIC 0x56303138 /* Toropets */ +#define MEMFD_INODE_MAGIC 0x48453499 /* Dnipro */ +#define TIMENS_MAGIC 0x43114433 /* Beslan */ +#define PIDNS_MAGIC 0x61157326 /* Surgut */ +#define BPFMAP_FILE_MAGIC 0x57506142 /* Alapayevsk */ +#define BPFMAP_DATA_MAGIC 0x64324033 /* Arkhangelsk */ -#define IFADDR_MAGIC RAW_IMAGE_MAGIC -#define ROUTE_MAGIC RAW_IMAGE_MAGIC -#define ROUTE6_MAGIC RAW_IMAGE_MAGIC -#define RULE_MAGIC RAW_IMAGE_MAGIC -#define TMPFS_IMG_MAGIC RAW_IMAGE_MAGIC -#define TMPFS_DEV_MAGIC RAW_IMAGE_MAGIC -#define IPTABLES_MAGIC RAW_IMAGE_MAGIC -#define IP6TABLES_MAGIC RAW_IMAGE_MAGIC -#define NFTABLES_MAGIC RAW_IMAGE_MAGIC -#define NETNF_CT_MAGIC RAW_IMAGE_MAGIC -#define NETNF_EXP_MAGIC RAW_IMAGE_MAGIC +#define IFADDR_MAGIC RAW_IMAGE_MAGIC +#define ROUTE_MAGIC RAW_IMAGE_MAGIC +#define ROUTE6_MAGIC RAW_IMAGE_MAGIC +#define RULE_MAGIC RAW_IMAGE_MAGIC +#define TMPFS_IMG_MAGIC RAW_IMAGE_MAGIC +#define TMPFS_DEV_MAGIC RAW_IMAGE_MAGIC +#define IPTABLES_MAGIC RAW_IMAGE_MAGIC +#define IP6TABLES_MAGIC RAW_IMAGE_MAGIC +#define NFTABLES_MAGIC RAW_IMAGE_MAGIC +#define NETNF_CT_MAGIC RAW_IMAGE_MAGIC +#define NETNF_EXP_MAGIC RAW_IMAGE_MAGIC -#define PAGES_OLD_MAGIC PAGEMAP_MAGIC -#define SHM_PAGES_OLD_MAGIC PAGEMAP_MAGIC -#define BINFMT_MISC_OLD_MAGIC BINFMT_MISC_MAGIC +#define PAGES_OLD_MAGIC PAGEMAP_MAGIC +#define SHM_PAGES_OLD_MAGIC PAGEMAP_MAGIC +#define BINFMT_MISC_OLD_MAGIC BINFMT_MISC_MAGIC /* * These are special files, not exactly images */ -#define STATS_MAGIC 0x57093306 /* Ostashkov */ -#define IRMAP_CACHE_MAGIC 0x57004059 /* Ivanovo */ +#define STATS_MAGIC 0x57093306 /* Ostashkov */ +#define IRMAP_CACHE_MAGIC 0x57004059 /* Ivanovo */ /* * Main magic for kerndat_s structure. */ -#define KDAT_MAGIC 0x57023458 /* Torzhok */ +#define KDAT_MAGIC 0x57023458 /* Torzhok */ #endif /* __CR_MAGIC_H__ */ diff --git a/criu/include/mem.h b/criu/include/mem.h index 251cb1a9e..03574ea3d 100644 --- a/criu/include/mem.h +++ b/criu/include/mem.h @@ -15,10 +15,10 @@ struct pstree_item; struct vma_area; struct mem_dump_ctl { - bool pre_dump; - bool lazy; - struct proc_pid_stat *stat; - InventoryEntry *parent_ie; + bool pre_dump; + bool lazy; + struct proc_pid_stat *stat; + InventoryEntry *parent_ie; }; extern bool vma_has_guard_gap_hidden(struct vma_area *vma); @@ -28,21 +28,19 @@ extern int prepare_mm_pid(struct pstree_item *i); extern void prepare_cow_vmas(void); extern int do_task_reset_dirty_track(int pid); extern unsigned long dump_pages_args_size(struct vm_area_list *vmas); -extern int parasite_dump_pages_seized(struct pstree_item *item, - struct vm_area_list *vma_area_list, - struct mem_dump_ctl *mdc, - struct parasite_ctl *ctl); +extern int parasite_dump_pages_seized(struct pstree_item *item, struct vm_area_list *vma_area_list, + struct mem_dump_ctl *mdc, struct parasite_ctl *ctl); -#define PME_PRESENT (1ULL << 63) -#define PME_SWAP (1ULL << 62) -#define PME_FILE (1ULL << 61) -#define PME_SOFT_DIRTY (1ULL << 55) -#define PME_PSHIFT_BITS (6) -#define PME_STATUS_BITS (3) -#define PME_STATUS_OFFSET (64 - PME_STATUS_BITS) -#define PME_PSHIFT_OFFSET (PME_STATUS_OFFSET - PME_PSHIFT_BITS) -#define PME_PFRAME_MASK ((1ULL << PME_PSHIFT_OFFSET) - 1) -#define PME_PFRAME(x) ((x) & PME_PFRAME_MASK) +#define PME_PRESENT (1ULL << 63) +#define PME_SWAP (1ULL << 62) +#define PME_FILE (1ULL << 61) +#define PME_SOFT_DIRTY (1ULL << 55) +#define PME_PSHIFT_BITS (6) +#define PME_STATUS_BITS (3) +#define PME_STATUS_OFFSET (64 - PME_STATUS_BITS) +#define PME_PSHIFT_OFFSET (PME_STATUS_OFFSET - PME_PSHIFT_BITS) +#define PME_PFRAME_MASK ((1ULL << PME_PSHIFT_OFFSET) - 1) +#define PME_PFRAME(x) ((x)&PME_PFRAME_MASK) struct task_restore_args; int open_vmas(struct pstree_item *t); diff --git a/criu/include/memfd.h b/criu/include/memfd.h index 3074a5c0f..1b1dc79bb 100644 --- a/criu/include/memfd.h +++ b/criu/include/memfd.h @@ -20,10 +20,10 @@ extern int apply_memfd_seals(void); extern int prepare_memfd_inodes(void); #ifdef CONFIG_HAS_MEMFD_CREATE -# include +#include #else -# include -# include +#include +#include static inline int memfd_create(const char *name, unsigned int flags) { return syscall(SYS_memfd_create, name, flags); diff --git a/criu/include/mman.h b/criu/include/mman.h index 340d36927..8ca71fadf 100644 --- a/criu/include/mman.h +++ b/criu/include/mman.h @@ -2,16 +2,16 @@ #define __CR_MMAN_H__ #ifndef MAP_HUGETLB -# define MAP_HUGETLB 0x40000 +#define MAP_HUGETLB 0x40000 #endif #ifndef MADV_HUGEPAGE -# define MADV_HUGEPAGE 14 +#define MADV_HUGEPAGE 14 #endif #ifndef MADV_NOHUGEPAGE -# define MADV_NOHUGEPAGE 15 +#define MADV_NOHUGEPAGE 15 #endif #ifndef MADV_DONTDUMP -# define MADV_DONTDUMP 16 +#define MADV_DONTDUMP 16 #endif #endif /* __CR_MMAN_H__ */ diff --git a/criu/include/mount.h b/criu/include/mount.h index d204e40d6..29d80c2a7 100644 --- a/criu/include/mount.h +++ b/criu/include/mount.h @@ -10,7 +10,7 @@ struct pstree_item; struct fstype; struct ns_id; -#define MOUNT_INVALID_DEV (0) +#define MOUNT_INVALID_DEV (0) #define MNT_UNREACHABLE INT_MIN @@ -27,11 +27,11 @@ struct ns_id; #define REMOUNTED_RW_SERVICE 2 struct mount_info { - int mnt_id; - int parent_mnt_id; - unsigned int s_dev; - unsigned int s_dev_rt; - char *root; + int mnt_id; + int parent_mnt_id; + unsigned int s_dev; + unsigned int s_dev_rt; + char *root; /* * During dump mountpoint contains path with dot at the * beginning. It allows to use openat, statat, etc without @@ -42,51 +42,51 @@ struct mount_info { * mount tree is constructed. Check mnt_roots for details. * The ns_mountpoint contains path w/o this prefix. */ - char *mountpoint; - char *ns_mountpoint; - int fd; - unsigned flags; - unsigned sb_flags; - int master_id; - int shared_id; - struct fstype *fstype; - char *source; - char *options; - char *fsname; + char *mountpoint; + char *ns_mountpoint; + int fd; + unsigned flags; + unsigned sb_flags; + int master_id; + int shared_id; + struct fstype *fstype; + char *source; + char *options; + char *fsname; union { - bool mounted; - bool dumped; + bool mounted; + bool dumped; }; - bool need_plugin; - bool is_ns_root; - bool deleted; - struct mount_info *next; - struct ns_id *nsid; + bool need_plugin; + bool is_ns_root; + bool deleted; + struct mount_info *next; + struct ns_id *nsid; - char *external; - bool internal_sharing; + char *external; + bool internal_sharing; /* tree linkage */ - struct mount_info *parent; - struct mount_info *bind; - struct list_head children; - struct list_head siblings; + struct mount_info *parent; + struct mount_info *bind; + struct list_head children; + struct list_head siblings; - struct list_head mnt_bind; /* circular list of derivatives of one real mount */ - struct list_head mnt_share; /* circular list of shared mounts */ - struct list_head mnt_slave_list; /* list of slave mounts */ - struct list_head mnt_slave; /* slave list entry */ - struct mount_info *mnt_master; /* slave is on master->mnt_slave_list */ - struct list_head mnt_propagate; /* circular list of mounts which propagate from each other */ - struct list_head mnt_notprop; /* temporary list used in can_mount_now */ - struct list_head mnt_unbindable; /* list of mounts with delayed unbindable */ + struct list_head mnt_bind; /* circular list of derivatives of one real mount */ + struct list_head mnt_share; /* circular list of shared mounts */ + struct list_head mnt_slave_list; /* list of slave mounts */ + struct list_head mnt_slave; /* slave list entry */ + struct mount_info *mnt_master; /* slave is on master->mnt_slave_list */ + struct list_head mnt_propagate; /* circular list of mounts which propagate from each other */ + struct list_head mnt_notprop; /* temporary list used in can_mount_now */ + struct list_head mnt_unbindable; /* list of mounts with delayed unbindable */ - struct list_head postpone; + struct list_head postpone; - int is_overmounted; - int remounted_rw; + int is_overmounted; + int remounted_rw; - void *private; /* associated filesystem data */ + void *private; /* associated filesystem data */ }; extern struct mount_info *mntinfo; @@ -94,7 +94,10 @@ extern struct ns_desc mnt_ns_desc; #ifdef CONFIG_BINFMT_MISC_VIRTUALIZED extern int collect_binfmt_misc(void); #else -static inline int collect_binfmt_misc(void) { return 0; } +static inline int collect_binfmt_misc(void) +{ + return 0; +} #endif extern struct mount_info *mnt_entry_alloc(void); @@ -115,14 +118,12 @@ extern int prepare_mnt_ns(void); extern int pivot_root(const char *new_root, const char *put_old); -extern struct mount_info *lookup_overlayfs(char *rpath, unsigned int s_dev, - unsigned int st_ino, unsigned int mnt_id); +extern struct mount_info *lookup_overlayfs(char *rpath, unsigned int s_dev, unsigned int st_ino, unsigned int mnt_id); extern struct mount_info *lookup_mnt_id(unsigned int id); extern struct mount_info *lookup_mnt_sdev(unsigned int s_dev); extern dev_t phys_stat_resolve_dev(struct ns_id *, dev_t st_dev, const char *path); -extern bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev, - struct ns_id *, const char *path); +extern bool phys_stat_dev_match(dev_t st_dev, dev_t phys_dev, struct ns_id *, const char *path); extern int restore_task_mnt_ns(struct pstree_item *current); extern void fini_restore_mntns(void); diff --git a/criu/include/namespaces.h b/criu/include/namespaces.h index e570aa0ab..ddf0dbabb 100644 --- a/criu/include/namespaces.h +++ b/criu/include/namespaces.h @@ -7,67 +7,67 @@ #include "images/netdev.pb-c.h" #ifndef CLONE_NEWNS -#define CLONE_NEWNS 0x00020000 +#define CLONE_NEWNS 0x00020000 #endif #ifndef CLONE_NEWPID -#define CLONE_NEWPID 0x20000000 +#define CLONE_NEWPID 0x20000000 #endif #ifndef CLONE_NEWUTS -#define CLONE_NEWUTS 0x04000000 +#define CLONE_NEWUTS 0x04000000 #endif #ifndef CLONE_NEWIPC -#define CLONE_NEWIPC 0x08000000 +#define CLONE_NEWIPC 0x08000000 #endif #ifndef CLONE_NEWNET -#define CLONE_NEWNET 0x40000000 +#define CLONE_NEWNET 0x40000000 #endif #ifndef CLONE_NEWUSER -#define CLONE_NEWUSER 0x10000000 +#define CLONE_NEWUSER 0x10000000 #endif #ifndef CLONE_NEWCGROUP -#define CLONE_NEWCGROUP 0x02000000 +#define CLONE_NEWCGROUP 0x02000000 #endif #ifndef CLONE_NEWTIME -#define CLONE_NEWTIME 0x00000080 +#define CLONE_NEWTIME 0x00000080 #endif -#define CLONE_ALLNS (CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWIPC | \ - CLONE_NEWUTS | CLONE_NEWNS | CLONE_NEWUSER | \ - CLONE_NEWCGROUP | CLONE_NEWTIME) +#define CLONE_ALLNS \ + (CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_NEWNS | CLONE_NEWUSER | CLONE_NEWCGROUP | \ + CLONE_NEWTIME) /* Nested namespaces are supported only for these types */ -#define CLONE_SUBNS (CLONE_NEWNS | CLONE_NEWNET) +#define CLONE_SUBNS (CLONE_NEWNS | CLONE_NEWNET) -#define EXTRA_SIZE 20 +#define EXTRA_SIZE 20 struct ns_desc { - unsigned int cflag; - char *str; - size_t len; + unsigned int cflag; + char *str; + size_t len; }; struct user_ns_extra { - char *uid; - char *gid; + char *uid; + char *gid; }; /* struct join_ns is used for storing parameters specified by --join-ns */ struct join_ns { - struct list_head list; - char *ns_file; - struct ns_desc *nd; /* namespace descriptor */ - int ns_fd; + struct list_head list; + char *ns_file; + struct ns_desc *nd; /* namespace descriptor */ + int ns_fd; /* extra options of --join-ns, like uid&gid in user namespace */ union { - struct user_ns_extra user_extra; - char *common_extra; + struct user_ns_extra user_extra; + char *common_extra; } extra_opts; }; @@ -79,15 +79,15 @@ enum ns_type { }; struct netns_id { - unsigned target_ns_id; - unsigned netnsid_value; - struct list_head node; + unsigned target_ns_id; + unsigned netnsid_value; + struct list_head node; }; struct net_link { - NetDeviceEntry *nde; - bool created; - struct list_head node; + NetDeviceEntry *nde; + bool created; + struct list_head node; }; struct ns_id { @@ -116,7 +116,6 @@ struct ns_id { } mnt; struct { - /* * ns_fd is used when network namespaces are being * restored. On this stage we access these file @@ -128,11 +127,11 @@ struct ns_id { * with restored file descriptors. */ union { - int nsfd_id; /* a namespace descriptor id in fdstore */ - int ns_fd; /* a namespace file descriptor */ + int nsfd_id; /* a namespace descriptor id in fdstore */ + int ns_fd; /* a namespace file descriptor */ }; - int nlsk; /* for sockets collection */ - int seqsk; /* to talk to parasite daemons */ + int nlsk; /* for sockets collection */ + int seqsk; /* to talk to parasite daemons */ struct list_head ids; struct list_head links; NetnsEntry *netns; @@ -141,11 +140,9 @@ struct ns_id { }; extern struct ns_id *ns_ids; -#define NS_DESC_ENTRY(_cflag, _str) \ - { \ - .cflag = _cflag, \ - .str = _str, \ - .len = sizeof(_str) - 1, \ +#define NS_DESC_ENTRY(_cflag, _str) \ + { \ + .cflag = _cflag, .str = _str, .len = sizeof(_str) - 1, \ } extern bool check_ns_proc(struct fd_link *link); @@ -197,12 +194,12 @@ typedef int (*uns_call_t)(void *arg, int fd, pid_t pid); * W/o flag the call is synchronous -- this function returns * strictly after the call finishes. */ -#define UNS_ASYNC 0x1 +#define UNS_ASYNC 0x1 /* * The call returns an FD which should be sent back. Conflicts * with UNS_ASYNC. */ -#define UNS_FDOUT 0x2 +#define UNS_FDOUT 0x2 #define MAX_UNSFD_MSG_SIZE 8192 @@ -215,12 +212,10 @@ typedef int (*uns_call_t)(void *arg, int fd, pid_t pid); * In case we're not in userns, just call the callback immediately * in the context of calling task. */ -extern int __userns_call(const char *func_name, uns_call_t call, int flags, - void *arg, size_t arg_size, int fd); +extern int __userns_call(const char *func_name, uns_call_t call, int flags, void *arg, size_t arg_size, int fd); -#define userns_call(__call, __flags, __arg, __arg_size, __fd) \ - __userns_call(__stringify(__call), __call, __flags, \ - __arg, __arg_size, __fd) +#define userns_call(__call, __flags, __arg, __arg_size, __fd) \ + __userns_call(__stringify(__call), __call, __flags, __arg, __arg_size, __fd) extern int add_ns_shared_cb(int (*actor)(void *data), void *data); diff --git a/criu/include/net.h b/criu/include/net.h index c83c79377..0da4cad13 100644 --- a/criu/include/net.h +++ b/criu/include/net.h @@ -7,7 +7,7 @@ #include "external.h" #ifndef RTM_GETNSID -#define RTM_GETNSID 90 +#define RTM_GETNSID 90 #endif struct cr_imgset; diff --git a/criu/include/netlink_diag.h b/criu/include/netlink_diag.h index 14ca403b8..65ff938c0 100644 --- a/criu/include/netlink_diag.h +++ b/criu/include/netlink_diag.h @@ -4,25 +4,25 @@ #include struct netlink_diag_req { - __u8 sdiag_family; - __u8 sdiag_protocol; - __u16 pad; - __u32 ndiag_ino; - __u32 ndiag_show; - __u32 ndiag_cookie[2]; + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 ndiag_ino; + __u32 ndiag_show; + __u32 ndiag_cookie[2]; }; struct netlink_diag_msg { - __u8 ndiag_family; - __u8 ndiag_type; - __u8 ndiag_protocol; - __u8 ndiag_state; + __u8 ndiag_family; + __u8 ndiag_type; + __u8 ndiag_protocol; + __u8 ndiag_state; - __u32 ndiag_portid; - __u32 ndiag_dst_portid; - __u32 ndiag_dst_group; - __u32 ndiag_ino; - __u32 ndiag_cookie[2]; + __u32 ndiag_portid; + __u32 ndiag_dst_portid; + __u32 ndiag_dst_group; + __u32 ndiag_ino; + __u32 ndiag_cookie[2]; }; enum { @@ -34,9 +34,9 @@ enum { #define NETLINK_DIAG_MAX (__NETLINK_DIAG_MAX - 1) -#define NDIAG_PROTO_ALL ((__u8) ~0) +#define NDIAG_PROTO_ALL ((__u8)~0) -#define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */ -#define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */ +#define NDIAG_SHOW_MEMINFO 0x00000001 /* show memory info of a socket */ +#define NDIAG_SHOW_GROUPS 0x00000002 /* show groups of a netlink socket */ #endif /* __CR_NETLINK_DIAG_H__ */ diff --git a/criu/include/packet_diag.h b/criu/include/packet_diag.h index 287de84ec..69e317adc 100644 --- a/criu/include/packet_diag.h +++ b/criu/include/packet_diag.h @@ -4,26 +4,26 @@ #include struct packet_diag_req { - __u8 sdiag_family; - __u8 sdiag_protocol; - __u16 pad; - __u32 pdiag_ino; - __u32 pdiag_show; - __u32 pdiag_cookie[2]; + __u8 sdiag_family; + __u8 sdiag_protocol; + __u16 pad; + __u32 pdiag_ino; + __u32 pdiag_show; + __u32 pdiag_cookie[2]; }; -#define PACKET_SHOW_INFO 0x00000001 /* Basic packet_sk information */ -#define PACKET_SHOW_MCLIST 0x00000002 /* A set of packet_diag_mclist-s */ -#define PACKET_SHOW_RING_CFG 0x00000004 /* Rings configuration parameters */ -#define PACKET_SHOW_FANOUT 0x00000008 +#define PACKET_SHOW_INFO 0x00000001 /* Basic packet_sk information */ +#define PACKET_SHOW_MCLIST 0x00000002 /* A set of packet_diag_mclist-s */ +#define PACKET_SHOW_RING_CFG 0x00000004 /* Rings configuration parameters */ +#define PACKET_SHOW_FANOUT 0x00000008 struct packet_diag_msg { - __u8 pdiag_family; - __u8 pdiag_type; - __u16 pdiag_num; + __u8 pdiag_family; + __u8 pdiag_type; + __u16 pdiag_num; - __u32 pdiag_ino; - __u32 pdiag_cookie[2]; + __u32 pdiag_ino; + __u32 pdiag_cookie[2]; }; enum { @@ -37,40 +37,40 @@ enum { }; struct packet_diag_info { - __u32 pdi_index; - __u32 pdi_version; - __u32 pdi_reserve; - __u32 pdi_copy_thresh; - __u32 pdi_tstamp; - __u32 pdi_flags; + __u32 pdi_index; + __u32 pdi_version; + __u32 pdi_reserve; + __u32 pdi_copy_thresh; + __u32 pdi_tstamp; + __u32 pdi_flags; -#define PDI_RUNNING 0x1 -#define PDI_AUXDATA 0x2 -#define PDI_ORIGDEV 0x4 -#define PDI_VNETHDR 0x8 -#define PDI_LOSS 0x10 +#define PDI_RUNNING 0x1 +#define PDI_AUXDATA 0x2 +#define PDI_ORIGDEV 0x4 +#define PDI_VNETHDR 0x8 +#define PDI_LOSS 0x10 }; #ifndef MAX_ADDR_LEN -#define MAX_ADDR_LEN 32 +#define MAX_ADDR_LEN 32 #endif struct packet_diag_mclist { - __u32 pdmc_index; - __u32 pdmc_count; - __u16 pdmc_type; - __u16 pdmc_alen; - __u8 pdmc_addr[MAX_ADDR_LEN]; + __u32 pdmc_index; + __u32 pdmc_count; + __u16 pdmc_type; + __u16 pdmc_alen; + __u8 pdmc_addr[MAX_ADDR_LEN]; }; struct packet_diag_ring { - __u32 pdr_block_size; - __u32 pdr_block_nr; - __u32 pdr_frame_size; - __u32 pdr_frame_nr; - __u32 pdr_retire_tmo; - __u32 pdr_sizeof_priv; - __u32 pdr_features; + __u32 pdr_block_size; + __u32 pdr_block_nr; + __u32 pdr_frame_size; + __u32 pdr_frame_nr; + __u32 pdr_retire_tmo; + __u32 pdr_sizeof_priv; + __u32 pdr_features; }; #endif /* __CR_PACKET_DIAG_H__ */ diff --git a/criu/include/page-pipe.h b/criu/include/page-pipe.h index decd14321..a5f97678e 100644 --- a/criu/include/page-pipe.h +++ b/criu/include/page-pipe.h @@ -19,8 +19,7 @@ struct kernel_pipe_buffer { * fails very often, so we need to restrict the pipe capacity to not * allocate big chunks. */ -#define PIPE_MAX_SIZE ((1 << PAGE_ALLOC_COSTLY_ORDER) * PAGE_SIZE / \ - sizeof(struct kernel_pipe_buffer)) +#define PIPE_MAX_SIZE ((1 << PAGE_ALLOC_COSTLY_ORDER) * PAGE_SIZE / sizeof(struct kernel_pipe_buffer)) /* The number of pipes for one chunk */ #define NR_PIPES_PER_CHUNK 8 @@ -91,15 +90,15 @@ struct kernel_pipe_buffer { */ struct page_pipe_buf { - int p[2]; /* pipe with pages */ - unsigned int pipe_size; /* how many pages can be fit into pipe */ - unsigned int pipe_off; /* where this buf is started in a pipe */ - unsigned int pages_in; /* how many pages are there */ - unsigned int nr_segs; /* how many iov-s are busy */ + int p[2]; /* pipe with pages */ + unsigned int pipe_size; /* how many pages can be fit into pipe */ + unsigned int pipe_off; /* where this buf is started in a pipe */ + unsigned int pages_in; /* how many pages are there */ + unsigned int nr_segs; /* how many iov-s are busy */ #define PPB_LAZY (1 << 0) - unsigned int flags; - struct iovec *iov; /* vaddr:len map */ - struct list_head l; /* links into page_pipe->bufs */ + unsigned int flags; + struct iovec *iov; /* vaddr:len map */ + struct list_head l; /* links into page_pipe->bufs */ }; /* @@ -109,38 +108,37 @@ struct page_pipe_buf { * Currently we have 2 types: the buffers that are always stored in * the images and the buffers that are lazily migrated */ -#define PP_PIPE_TYPES 2 +#define PP_PIPE_TYPES 2 #define PP_HOLE_PARENT (1 << 0) struct page_pipe { - unsigned int nr_pipes; /* how many page_pipe_bufs in there */ - struct list_head bufs; /* list of bufs */ - struct list_head free_bufs; /* list of bufs */ - struct page_pipe_buf *prev[PP_PIPE_TYPES]; /* last ppb of each type for pipe sharing */ - unsigned int nr_iovs; /* number of iovs */ - unsigned int free_iov; /* first free iov */ + unsigned int nr_pipes; /* how many page_pipe_bufs in there */ + struct list_head bufs; /* list of bufs */ + struct list_head free_bufs; /* list of bufs */ + struct page_pipe_buf *prev[PP_PIPE_TYPES]; /* last ppb of each type for pipe sharing */ + unsigned int nr_iovs; /* number of iovs */ + unsigned int free_iov; /* first free iov */ - struct iovec *iovs; /* iovs. They are provided into create_page_pipe + struct iovec *iovs; /* iovs. They are provided into create_page_pipe and all bufs have their iov-s in there */ - unsigned int nr_holes; /* number of holes allocated */ - unsigned int free_hole; /* number of holes in use */ - struct iovec *holes; /* holes */ - unsigned int *hole_flags; - unsigned int flags; /* PP_FOO flags below */ + unsigned int nr_holes; /* number of holes allocated */ + unsigned int free_hole; /* number of holes in use */ + struct iovec *holes; /* holes */ + unsigned int *hole_flags; + unsigned int flags; /* PP_FOO flags below */ }; -#define PP_CHUNK_MODE 0x1 /* Restrict the maximum buffer size of pipes +#define PP_CHUNK_MODE \ + 0x1 /* Restrict the maximum buffer size of pipes and dump memory for a few iterations */ -#define PP_OWN_IOVS 0x4 /* create_page_pipe allocated IOVs memory */ +#define PP_OWN_IOVS 0x4 /* create_page_pipe allocated IOVs memory */ struct page_pipe *create_page_pipe(unsigned int nr_segs, struct iovec *iovs, unsigned flags); extern void destroy_page_pipe(struct page_pipe *p); -extern int page_pipe_add_page(struct page_pipe *p, unsigned long addr, - unsigned int flags); -extern int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr, - unsigned int flags); +extern int page_pipe_add_page(struct page_pipe *p, unsigned long addr, unsigned int flags); +extern int page_pipe_add_hole(struct page_pipe *pp, unsigned long addr, unsigned int flags); extern void debug_show_page_pipe(struct page_pipe *pp); void page_pipe_reinit(struct page_pipe *pp); @@ -153,8 +151,7 @@ struct pipe_read_dest { }; extern int pipe_read_dest_init(struct pipe_read_dest *prd); -extern int page_pipe_read(struct page_pipe *pp, struct pipe_read_dest *prd, - unsigned long addr, unsigned int *nr_pages, +extern int page_pipe_read(struct page_pipe *pp, struct pipe_read_dest *prd, unsigned long addr, unsigned int *nr_pages, unsigned int ppb_flags); #endif /* __CR_PAGE_PIPE_H__ */ diff --git a/criu/include/page-xfer.h b/criu/include/page-xfer.h index 98061e2d3..e0303dfe0 100644 --- a/criu/include/page-xfer.h +++ b/criu/include/page-xfer.h @@ -36,7 +36,7 @@ struct page_xfer { union { struct /* local */ { struct cr_img *pmi; /* pagemaps */ - struct cr_img *pi; /* pages */ + struct cr_img *pi; /* pages */ }; struct /* page-server */ { @@ -72,7 +72,6 @@ extern int check_parent_page_xfer(int fd_type, unsigned long id); extern int request_remote_pages(unsigned long img_id, unsigned long addr, int nr_pages); typedef int (*ps_async_read_complete)(unsigned long img_id, unsigned long vaddr, int nr_pages, void *); -extern int page_server_start_read(void *buf, int nr_pages, - ps_async_read_complete complete, void *priv, unsigned flags); +extern int page_server_start_read(void *buf, int nr_pages, ps_async_read_complete complete, void *priv, unsigned flags); #endif /* __CR_PAGE_XFER__H__ */ diff --git a/criu/include/pagemap-cache.h b/criu/include/pagemap-cache.h index d3ace242a..7612ee0f4 100644 --- a/criu/include/pagemap-cache.h +++ b/criu/include/pagemap-cache.h @@ -8,19 +8,22 @@ struct vma_area; -#define PAGEMAP_PFN_OFF(addr) (PAGE_PFN(addr) * sizeof(u64)) +#define PAGEMAP_PFN_OFF(addr) (PAGE_PFN(addr) * sizeof(u64)) typedef struct { - pid_t pid; /* which process it belongs */ - unsigned long start; /* start of area */ - unsigned long end; /* end of area */ - const struct list_head *vma_head; /* list head of VMAs we're serving */ - u64 *map; /* local buffer */ - size_t map_len; /* length of a buffer */ - int fd; /* file to read PMs from */ + pid_t pid; /* which process it belongs */ + unsigned long start; /* start of area */ + unsigned long end; /* end of area */ + const struct list_head *vma_head; /* list head of VMAs we're serving */ + u64 *map; /* local buffer */ + size_t map_len; /* length of a buffer */ + int fd; /* file to read PMs from */ } pmc_t; -#define PMC_INIT (pmc_t){ } +#define PMC_INIT \ + (pmc_t) \ + { \ + } extern int pmc_init(pmc_t *pmc, pid_t pid, const struct list_head *vma_head, size_t size); extern u64 *pmc_get_map(pmc_t *pmc, const struct vma_area *vma); diff --git a/criu/include/pagemap.h b/criu/include/pagemap.h index 45284b87d..c39c25d0c 100644 --- a/criu/include/pagemap.h +++ b/criu/include/pagemap.h @@ -44,8 +44,7 @@ struct page_read { /* reads page from current pagemap */ - int (*read_pages)(struct page_read *, unsigned long vaddr, int nr, - void *, unsigned flags); + int (*read_pages)(struct page_read *, unsigned long vaddr, int nr, void *, unsigned flags); /* Advance page_read to the next entry */ int (*advance)(struct page_read *pr); void (*close)(struct page_read *); @@ -54,8 +53,7 @@ struct page_read { int (*seek_pagemap)(struct page_read *pr, unsigned long vaddr); void (*reset)(struct page_read *pr); int (*io_complete)(struct page_read *, unsigned long vaddr, int nr); - int (*maybe_read_page)(struct page_read *pr, unsigned long vaddr, - int nr, void *buf, unsigned flags); + int (*maybe_read_page)(struct page_read *pr, unsigned long vaddr, int nr, void *buf, unsigned flags); /* Whether or not pages can be read in PIE code */ bool pieok; @@ -65,37 +63,37 @@ struct page_read { struct cr_img *pi; u32 pages_img_id; - PagemapEntry *pe; /* current pagemap we are on */ - struct page_read *parent; /* parent pagemap (if ->in_parent + PagemapEntry *pe; /* current pagemap we are on */ + struct page_read *parent; /* parent pagemap (if ->in_parent pagemap is met in image, then go to this guy for page, see read_pagemap_page */ - unsigned long cvaddr; /* vaddr we are on */ - off_t pi_off; /* current offset in pages file */ + unsigned long cvaddr; /* vaddr we are on */ + off_t pi_off; /* current offset in pages file */ - struct iovec bunch; /* record consequent neighbour + struct iovec bunch; /* record consequent neighbour iovecs to punch together */ - unsigned id; /* for logging */ - unsigned long img_id; /* pagemap image file ID */ + unsigned id; /* for logging */ + unsigned long img_id; /* pagemap image file ID */ PagemapEntry **pmes; int nr_pmes; int curr_pme; - struct list_head async; + struct list_head async; }; /* flags for ->read_pages */ -#define PR_ASYNC 0x1 /* may exit w/o data in the buffer */ -#define PR_ASAP 0x2 /* PR_ASYNC, but start the IO right now */ +#define PR_ASYNC 0x1 /* may exit w/o data in the buffer */ +#define PR_ASAP 0x2 /* PR_ASYNC, but start the IO right now */ /* flags for open_page_read */ -#define PR_SHMEM 0x1 -#define PR_TASK 0x2 +#define PR_SHMEM 0x1 +#define PR_TASK 0x2 -#define PR_TYPE_MASK 0x3 -#define PR_MOD 0x4 /* Will need to modify */ -#define PR_REMOTE 0x8 +#define PR_TYPE_MASK 0x3 +#define PR_MOD 0x4 /* Will need to modify */ +#define PR_REMOTE 0x8 /* * -1 -- error @@ -103,13 +101,11 @@ struct page_read { * 1 -- opened */ extern int open_page_read(unsigned long id, struct page_read *, int pr_flags); -extern int open_page_read_at(int dfd, unsigned long id, struct page_read *pr, - int pr_flags); +extern int open_page_read_at(int dfd, unsigned long id, struct page_read *pr, int pr_flags); struct task_restore_args; -int pagemap_enqueue_iovec(struct page_read *pr, void *buf, - unsigned long len, struct list_head *to); +int pagemap_enqueue_iovec(struct page_read *pr, void *buf, unsigned long len, struct list_head *to); int pagemap_render_iovec(struct list_head *from, struct task_restore_args *ta); /* @@ -119,8 +115,7 @@ int pagemap_render_iovec(struct list_head *from, struct task_restore_args *ta); */ extern void dup_page_read(struct page_read *src, struct page_read *dst); -extern int dedup_one_iovec(struct page_read *pr, unsigned long base, - unsigned long len); +extern int dedup_one_iovec(struct page_read *pr, unsigned long base, unsigned long len); static inline unsigned long pagemap_len(PagemapEntry *pe) { @@ -133,9 +128,9 @@ static inline bool page_read_has_parent(struct page_read *pr) } /* Pagemap flags */ -#define PE_PARENT (1 << 0) /* pages are in parent snapshot */ -#define PE_LAZY (1 << 1) /* pages can be lazily restored */ -#define PE_PRESENT (1 << 2) /* pages are present in pages*img */ +#define PE_PARENT (1 << 0) /* pages are in parent snapshot */ +#define PE_LAZY (1 << 1) /* pages can be lazily restored */ +#define PE_PRESENT (1 << 2) /* pages are present in pages*img */ static inline bool pagemap_in_parent(PagemapEntry *pe) { diff --git a/criu/include/parasite-syscall.h b/criu/include/parasite-syscall.h index afba95a9e..4540e11ee 100644 --- a/criu/include/parasite-syscall.h +++ b/criu/include/parasite-syscall.h @@ -25,25 +25,21 @@ extern int parasite_dump_sigacts_seized(struct parasite_ctl *ctl, struct pstree_ extern int parasite_dump_itimers_seized(struct parasite_ctl *ctl, struct pstree_item *); struct proc_posix_timers_stat; -extern int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args, - struct parasite_ctl *ctl, struct pstree_item *); +extern int parasite_dump_posix_timers_seized(struct proc_posix_timers_stat *proc_args, struct parasite_ctl *ctl, + struct pstree_item *); extern int parasite_dump_misc_seized(struct parasite_ctl *ctl, struct parasite_dump_misc *misc); extern int parasite_dump_creds(struct parasite_ctl *ctl, CredsEntry *ce); extern int parasite_dump_thread_leader_seized(struct parasite_ctl *ctl, int pid, CoreEntry *core); -extern int parasite_dump_thread_seized(struct parasite_thread_ctl *tctl, - struct parasite_ctl *ctl, int id, +extern int parasite_dump_thread_seized(struct parasite_thread_ctl *tctl, struct parasite_ctl *ctl, int id, struct pid *tid, CoreEntry *core); -extern int dump_thread_core(int pid, CoreEntry *core, - const struct parasite_dump_thread *dt); +extern int dump_thread_core(int pid, CoreEntry *core, const struct parasite_dump_thread *dt); -extern int parasite_drain_fds_seized(struct parasite_ctl *ctl, - struct parasite_drain_fd *dfds, int nr_fds, int off, - int *lfds, struct fd_opts *flags); +extern int parasite_drain_fds_seized(struct parasite_ctl *ctl, struct parasite_drain_fd *dfds, int nr_fds, int off, + int *lfds, struct fd_opts *flags); extern int parasite_get_proc_fd_seized(struct parasite_ctl *ctl); -extern struct parasite_ctl *parasite_infect_seized(pid_t pid, - struct pstree_item *item, +extern struct parasite_ctl *parasite_infect_seized(pid_t pid, struct pstree_item *item, struct vm_area_list *vma_area_list); extern void parasite_ensure_args_size(unsigned long sz); extern unsigned long get_exec_start(struct vm_area_list *); diff --git a/criu/include/parasite-vdso.h b/criu/include/parasite-vdso.h index 9ee32f2a7..a50594d2a 100644 --- a/criu/include/parasite-vdso.h +++ b/criu/include/parasite-vdso.h @@ -32,28 +32,28 @@ static inline bool vdso_symbol_empty(struct vdso_symbol *s) * from list of VMAs to save in images, we save rt-vvar address also. */ struct vdso_mark { - u64 signature; - unsigned long orig_vdso_addr; - unsigned long version; - unsigned long orig_vvar_addr; - unsigned long rt_vvar_addr; + u64 signature; + unsigned long orig_vdso_addr; + unsigned long version; + unsigned long orig_vvar_addr; + unsigned long rt_vvar_addr; }; -#define VDSO_MARK_SIGNATURE_V1 (0x6f73647675697263ULL) /* Magic number (criuvdso) */ -#define VDSO_MARK_SIGNATURE_V2 (0x4f53447675697263ULL) /* Magic number (criuvDSO) */ -#define VDSO_MARK_SIGNATURE_V3 (0x4f53447655495243ULL) /* Magic number (CRIUvDSO) */ -#define VDSO_MARK_CUR_VERSION (3) +#define VDSO_MARK_SIGNATURE_V1 (0x6f73647675697263ULL) /* Magic number (criuvdso) */ +#define VDSO_MARK_SIGNATURE_V2 (0x4f53447675697263ULL) /* Magic number (criuvDSO) */ +#define VDSO_MARK_SIGNATURE_V3 (0x4f53447655495243ULL) /* Magic number (CRIUvDSO) */ +#define VDSO_MARK_CUR_VERSION (3) -static inline void vdso_put_mark(void *where, unsigned long rt_vvar_addr, - unsigned long orig_vdso_addr, unsigned long orig_vvar_addr) +static inline void vdso_put_mark(void *where, unsigned long rt_vvar_addr, unsigned long orig_vdso_addr, + unsigned long orig_vvar_addr) { struct vdso_mark *m = where; - m->signature = VDSO_MARK_SIGNATURE_V3; - m->orig_vdso_addr = orig_vdso_addr; - m->version = VDSO_MARK_CUR_VERSION; - m->orig_vvar_addr = orig_vvar_addr; - m->rt_vvar_addr = rt_vvar_addr; + m->signature = VDSO_MARK_SIGNATURE_V3; + m->orig_vdso_addr = orig_vdso_addr; + m->version = VDSO_MARK_CUR_VERSION; + m->orig_vvar_addr = orig_vvar_addr; + m->rt_vvar_addr = rt_vvar_addr; } static inline bool is_vdso_mark(void *addr) @@ -68,13 +68,11 @@ static inline bool is_vdso_mark(void *addr) * to the version we support. */ case VDSO_MARK_SIGNATURE_V2: - vdso_put_mark(m, VVAR_BAD_ADDR, - m->orig_vdso_addr, m->orig_vvar_addr); + vdso_put_mark(m, VVAR_BAD_ADDR, m->orig_vdso_addr, m->orig_vvar_addr); return true; case VDSO_MARK_SIGNATURE_V1: - vdso_put_mark(m, VVAR_BAD_ADDR, - m->orig_vdso_addr, VVAR_BAD_ADDR); + vdso_put_mark(m, VVAR_BAD_ADDR, m->orig_vdso_addr, VVAR_BAD_ADDR); return true; } @@ -82,14 +80,11 @@ static inline bool is_vdso_mark(void *addr) } extern void vdso_update_gtod_addr(struct vdso_maps *rt); -extern int vdso_do_park(struct vdso_maps *rt, unsigned long park_at, - unsigned long park_size); +extern int vdso_do_park(struct vdso_maps *rt, unsigned long park_at, unsigned long park_size); extern int vdso_map_compat(unsigned long map_at); -extern int vdso_proxify(struct vdso_maps *rt, bool *added_proxy, - VmaEntry *vmas, size_t nr_vmas, - bool compat_vdso, bool force_trampolines); -extern int vdso_redirect_calls(unsigned long base_to, unsigned long base_from, - struct vdso_symtable *to, struct vdso_symtable *from, - bool compat_vdso); +extern int vdso_proxify(struct vdso_maps *rt, bool *added_proxy, VmaEntry *vmas, size_t nr_vmas, bool compat_vdso, + bool force_trampolines); +extern int vdso_redirect_calls(unsigned long base_to, unsigned long base_from, struct vdso_symtable *to, + struct vdso_symtable *from, bool compat_vdso); #endif /* __CR_PARASITE_VDSO_H__ */ diff --git a/criu/include/parasite.h b/criu/include/parasite.h index d9570948a..8107aa49d 100644 --- a/criu/include/parasite.h +++ b/criu/include/parasite.h @@ -1,7 +1,7 @@ #ifndef __CR_PARASITE_H__ #define __CR_PARASITE_H__ -#define PARASITE_MAX_SIZE (64 << 10) +#define PARASITE_MAX_SIZE (64 << 10) #ifndef __ASSEMBLY__ @@ -39,30 +39,29 @@ enum { PARASITE_CMD_MAX, }; -struct parasite_vma_entry -{ - unsigned long start; - unsigned long len; - int prot; +struct parasite_vma_entry { + unsigned long start; + unsigned long len; + int prot; }; struct parasite_vdso_vma_entry { - unsigned long start; - unsigned long len; - unsigned long orig_vdso_addr; - unsigned long orig_vvar_addr; - unsigned long rt_vvar_addr; - int is_marked; - bool try_fill_symtable; - bool is_vdso; + unsigned long start; + unsigned long len; + unsigned long orig_vdso_addr; + unsigned long orig_vvar_addr; + unsigned long rt_vvar_addr; + int is_marked; + bool try_fill_symtable; + bool is_vdso; }; struct parasite_dump_pages_args { - unsigned int nr_vmas; - unsigned int add_prot; - unsigned int off; - unsigned int nr_segs; - unsigned int nr_pages; + unsigned int nr_vmas; + unsigned int add_prot; + unsigned int off; + unsigned int nr_segs; + unsigned int nr_pages; }; static inline struct parasite_vma_entry *pargs_vmas(struct parasite_dump_pages_args *a) @@ -117,7 +116,7 @@ static inline int posix_timers_dump_size(int timer_n) */ struct parasite_dump_misc { - unsigned long brk; + unsigned long brk; u32 pid; u32 sid; @@ -133,22 +132,22 @@ struct parasite_dump_misc { * Calculate how long we can make the groups array in parasite_dump_creds * and still fit the struct in one page */ -#define PARASITE_MAX_GROUPS \ - ((PAGE_SIZE - sizeof(struct parasite_dump_thread) - \ - offsetof(struct parasite_dump_creds, groups)) / sizeof(unsigned int)) /* groups */ +#define PARASITE_MAX_GROUPS \ + ((PAGE_SIZE - sizeof(struct parasite_dump_thread) - offsetof(struct parasite_dump_creds, groups)) / \ + sizeof(unsigned int)) /* groups */ struct parasite_dump_creds { - unsigned int cap_last_cap; + unsigned int cap_last_cap; - u32 cap_inh[CR_CAP_SIZE]; - u32 cap_prm[CR_CAP_SIZE]; - u32 cap_eff[CR_CAP_SIZE]; - u32 cap_bnd[CR_CAP_SIZE]; + u32 cap_inh[CR_CAP_SIZE]; + u32 cap_prm[CR_CAP_SIZE]; + u32 cap_eff[CR_CAP_SIZE]; + u32 cap_bnd[CR_CAP_SIZE]; - int uids[4]; - int gids[4]; - unsigned int secbits; - unsigned int ngroups; + int uids[4]; + int gids[4]; + unsigned int secbits; + unsigned int ngroups; /* * FIXME -- this structure is passed to parasite code * through parasite args area so in parasite_dump_creds() @@ -162,17 +161,17 @@ struct parasite_dump_creds { * of memory in use doesn't exceed the PAGE_SIZE and the * args area is at least one page (PARASITE_ARG_SIZE_MIN). */ - unsigned int groups[0]; + unsigned int groups[0]; }; struct parasite_dump_thread { - unsigned int *tid_addr; - pid_t tid; - tls_t tls; - stack_t sas; - int pdeath_sig; - char comm[TASK_COMM_LEN]; - struct parasite_dump_creds creds[0]; + unsigned int *tid_addr; + pid_t tid; + tls_t tls; + stack_t sas; + int pdeath_sig; + char comm[TASK_COMM_LEN]; + struct parasite_dump_creds creds[0]; }; static inline void copy_sas(ThreadSasEntry *dst, const stack_t *src) @@ -190,11 +189,11 @@ static inline void copy_sas(ThreadSasEntry *dst, const stack_t *src) * are transferred with help of send_fds and recv_fds. * 3) criu should work with a default value of the file limit (1024) */ -#define PARASITE_MAX_FDS CR_SCM_MAX_FD * 3 +#define PARASITE_MAX_FDS CR_SCM_MAX_FD * 3 struct parasite_drain_fd { - int nr_fds; - int fds[0]; + int nr_fds; + int fds[0]; }; struct fd_opts { @@ -215,16 +214,16 @@ static inline int drain_fds_size(struct parasite_drain_fd *dfds) } struct parasite_tty_args { - int fd; - int type; + int fd; + int type; - int sid; - int pgrp; - bool hangup; + int sid; + int pgrp; + bool hangup; - int st_pckt; - int st_lock; - int st_excl; + int st_pckt; + int st_lock; + int st_excl; }; struct parasite_dump_cgroup_args { diff --git a/criu/include/path.h b/criu/include/path.h index c475986eb..70e09587d 100644 --- a/criu/include/path.h +++ b/criu/include/path.h @@ -35,7 +35,6 @@ char *cut_root_for_bind(char *target_root, char *source_root); * Get a mount point for a sibling of m if m->parent and p are in the same * shared group. */ -char *mnt_get_sibling_path(struct mount_info *m, - struct mount_info *p, char *buf, int len); +char *mnt_get_sibling_path(struct mount_info *m, struct mount_info *p, char *buf, int len); #endif diff --git a/criu/include/pid.h b/criu/include/pid.h index c749176fa..49cb2d322 100644 --- a/criu/include/pid.h +++ b/criu/include/pid.h @@ -8,18 +8,17 @@ /* * Task states, used in e.g. struct pid's state. */ -enum __criu_task_state -{ +enum __criu_task_state { /* Values shared with compel */ - TASK_ALIVE = COMPEL_TASK_ALIVE, - TASK_DEAD = COMPEL_TASK_DEAD, - TASK_STOPPED = COMPEL_TASK_STOPPED, - TASK_ZOMBIE = COMPEL_TASK_ZOMBIE, + TASK_ALIVE = COMPEL_TASK_ALIVE, + TASK_DEAD = COMPEL_TASK_DEAD, + TASK_STOPPED = COMPEL_TASK_STOPPED, + TASK_ZOMBIE = COMPEL_TASK_ZOMBIE, /* Own internal states */ - TASK_HELPER = COMPEL_TASK_MAX + 1, + TASK_HELPER = COMPEL_TASK_MAX + 1, TASK_THREAD, /* new values are to be added before this line */ - TASK_UNDEF = 0xff + TASK_UNDEF = 0xff }; struct pid { @@ -31,7 +30,7 @@ struct pid { */ pid_t real; - int state; /* TASK_XXX constants */ + int state; /* TASK_XXX constants */ /* * The @virt pid is one which used in the image itself and keeps diff --git a/criu/include/pipes.h b/criu/include/pipes.h index 83fb71cfc..6e6310e14 100644 --- a/criu/include/pipes.h +++ b/criu/include/pipes.h @@ -13,28 +13,28 @@ static inline u32 pipe_id(const struct fd_parms *p) return p->stat.st_ino; } -#define NR_PIPES_WITH_DATA 1024 +#define NR_PIPES_WITH_DATA 1024 struct pipe_data_dump { - int img_type; - unsigned int nr; - u32 ids[NR_PIPES_WITH_DATA]; + int img_type; + unsigned int nr; + u32 ids[NR_PIPES_WITH_DATA]; }; extern int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p); struct pipe_data_rst { - PipeDataEntry *pde; + PipeDataEntry *pde; void *data; - struct pipe_data_rst *next; + struct pipe_data_rst *next; }; -#define PIPE_DATA_HASH_BITS 5 -#define PIPE_DATA_HASH_SIZE (1 << PIPE_DATA_HASH_BITS) -#define PIPE_DATA_HASH_MASK (PIPE_DATA_HASH_SIZE - 1) +#define PIPE_DATA_HASH_BITS 5 +#define PIPE_DATA_HASH_SIZE (1 << PIPE_DATA_HASH_BITS) +#define PIPE_DATA_HASH_MASK (PIPE_DATA_HASH_SIZE - 1) -extern int do_collect_pipe_data(struct pipe_data_rst *, - ProtobufCMessage *, struct cr_img *, struct pipe_data_rst **hash); +extern int do_collect_pipe_data(struct pipe_data_rst *, ProtobufCMessage *, struct cr_img *, + struct pipe_data_rst **hash); extern int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash); /* @@ -47,17 +47,15 @@ extern int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst #include "images/pipe.pb-c.h" struct pipe_info { - PipeEntry *pe; - struct list_head pipe_list; /* All pipe_info with the same pipe_id + PipeEntry *pe; + struct list_head pipe_list; /* All pipe_info with the same pipe_id * This is pure circular list without head */ - struct list_head list; /* global list of pipes */ - struct file_desc d; - unsigned int create : 1, - reopen : 1; + struct list_head list; /* global list of pipes */ + struct file_desc d; + unsigned int create : 1, reopen : 1; }; -extern int collect_one_pipe_ops(void *o, ProtobufCMessage *base, - struct file_desc_ops *ops); +extern int collect_one_pipe_ops(void *o, ProtobufCMessage *base, struct file_desc_ops *ops); extern int open_pipe(struct file_desc *d, int *new_fd); #endif /* __CR_PIPES_H__ */ diff --git a/criu/include/plugin.h b/criu/include/plugin.h index 82a6723d0..bbb3eb858 100644 --- a/criu/include/plugin.h +++ b/criu/include/plugin.h @@ -11,36 +11,35 @@ void cr_plugin_fini(int stage, int err); int cr_plugin_init(int stage); typedef struct { - struct list_head head; - struct list_head hook_chain[CR_PLUGIN_HOOK__MAX]; + struct list_head head; + struct list_head hook_chain[CR_PLUGIN_HOOK__MAX]; } cr_plugin_ctl_t; extern cr_plugin_ctl_t cr_plugin_ctl; typedef struct { - cr_plugin_desc_t *d; - struct list_head list; - void *dlhandle; - struct list_head link[CR_PLUGIN_HOOK__MAX]; + cr_plugin_desc_t *d; + struct list_head list; + void *dlhandle; + struct list_head link[CR_PLUGIN_HOOK__MAX]; } plugin_desc_t; -#define run_plugins(__hook, ...) \ -({ \ - plugin_desc_t *this; \ - int __ret = -ENOTSUP; \ - \ - list_for_each_entry(this, &cr_plugin_ctl.hook_chain[CR_PLUGIN_HOOK__ ##__hook], \ - link[CR_PLUGIN_HOOK__ ##__hook]) { \ - pr_debug("plugin: `%s' hook %u -> %p\n", \ - this->d->name, CR_PLUGIN_HOOK__ ##__hook, \ - this->d->hooks[CR_PLUGIN_HOOK__ ##__hook]); \ - __ret = ((CR_PLUGIN_HOOK__ ##__hook ##_t *) \ - this->d->hooks[CR_PLUGIN_HOOK__ ##__hook])(__VA_ARGS__); \ - if (__ret == -ENOTSUP) \ - continue; \ - break; \ - } \ - __ret; \ -}) +#define run_plugins(__hook, ...) \ + ({ \ + plugin_desc_t *this; \ + int __ret = -ENOTSUP; \ + \ + list_for_each_entry(this, &cr_plugin_ctl.hook_chain[CR_PLUGIN_HOOK__##__hook], \ + link[CR_PLUGIN_HOOK__##__hook]) { \ + pr_debug("plugin: `%s' hook %u -> %p\n", this->d->name, CR_PLUGIN_HOOK__##__hook, \ + this->d->hooks[CR_PLUGIN_HOOK__##__hook]); \ + __ret = ((CR_PLUGIN_HOOK__##__hook##_t *)this->d \ + ->hooks[CR_PLUGIN_HOOK__##__hook])(__VA_ARGS__); \ + if (__ret == -ENOTSUP) \ + continue; \ + break; \ + } \ + __ret; \ + }) #endif diff --git a/criu/include/posix-timer.h b/criu/include/posix-timer.h index 139f5c9a5..b1f4b1ab6 100644 --- a/criu/include/posix-timer.h +++ b/criu/include/posix-timer.h @@ -9,7 +9,7 @@ struct str_posix_timer { int si_signo; int it_sigev_notify; int notify_thread_id; - void * sival_ptr; + void *sival_ptr; }; struct proc_posix_timer { @@ -22,7 +22,7 @@ struct proc_posix_timers_stat { struct list_head timers; }; -extern int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat * args); +extern int parse_posix_timers(pid_t pid, struct proc_posix_timers_stat *args); void free_posix_timers(struct proc_posix_timers_stat *st); #endif /* __CR_PROC_POSIX_TIMER_H__ */ diff --git a/criu/include/prctl.h b/criu/include/prctl.h index 8e7fef317..c843f40a7 100644 --- a/criu/include/prctl.h +++ b/criu/include/prctl.h @@ -4,82 +4,82 @@ #include "int.h" #ifndef PR_SET_NAME -# define PR_SET_NAME 15 +#define PR_SET_NAME 15 #endif #ifndef PR_GET_NAME -# define PR_GET_NAME 16 +#define PR_GET_NAME 16 #endif #ifndef PR_SET_SECCOMP -# define PR_SET_SECCOMP 22 +#define PR_SET_SECCOMP 22 #endif #ifndef PR_CAPBSET_READ -# define PR_CAPBSET_READ 23 +#define PR_CAPBSET_READ 23 #endif #ifndef PR_CAPBSET_DROP -# define PR_CAPBSET_DROP 24 +#define PR_CAPBSET_DROP 24 #endif #ifndef PR_GET_SECUREBITS -# define PR_GET_SECUREBITS 27 +#define PR_GET_SECUREBITS 27 #endif #ifndef PR_SET_SECUREBITS -# define PR_SET_SECUREBITS 28 +#define PR_SET_SECUREBITS 28 #endif #ifndef PR_GET_DUMPABLE -# define PR_GET_DUMPABLE 3 +#define PR_GET_DUMPABLE 3 #endif #ifndef PR_SET_DUMPABLE -# define PR_SET_DUMPABLE 4 +#define PR_SET_DUMPABLE 4 #endif #ifndef PR_SET_MM -#define PR_SET_MM 35 -# define PR_SET_MM_START_CODE 1 -# define PR_SET_MM_END_CODE 2 -# define PR_SET_MM_START_DATA 3 -# define PR_SET_MM_END_DATA 4 -# define PR_SET_MM_START_STACK 5 -# define PR_SET_MM_START_BRK 6 -# define PR_SET_MM_BRK 7 -# define PR_SET_MM_ARG_START 8 -# define PR_SET_MM_ARG_END 9 -# define PR_SET_MM_ENV_START 10 -# define PR_SET_MM_ENV_END 11 -# define PR_SET_MM_AUXV 12 -# define PR_SET_MM_EXE_FILE 13 +#define PR_SET_MM 35 +#define PR_SET_MM_START_CODE 1 +#define PR_SET_MM_END_CODE 2 +#define PR_SET_MM_START_DATA 3 +#define PR_SET_MM_END_DATA 4 +#define PR_SET_MM_START_STACK 5 +#define PR_SET_MM_START_BRK 6 +#define PR_SET_MM_BRK 7 +#define PR_SET_MM_ARG_START 8 +#define PR_SET_MM_ARG_END 9 +#define PR_SET_MM_ENV_START 10 +#define PR_SET_MM_ENV_END 11 +#define PR_SET_MM_AUXV 12 +#define PR_SET_MM_EXE_FILE 13 #endif #ifndef PR_SET_MM_MAP -# define PR_SET_MM_MAP 14 -# define PR_SET_MM_MAP_SIZE 15 +#define PR_SET_MM_MAP 14 +#define PR_SET_MM_MAP_SIZE 15 struct prctl_mm_map { - u64 start_code; - u64 end_code; - u64 start_data; - u64 end_data; - u64 start_brk; - u64 brk; - u64 start_stack; - u64 arg_start; - u64 arg_end; - u64 env_start; - u64 env_end; - u64 *auxv; - u32 auxv_size; - u32 exe_fd; + u64 start_code; + u64 end_code; + u64 start_data; + u64 end_data; + u64 start_brk; + u64 brk; + u64 start_stack; + u64 arg_start; + u64 arg_end; + u64 env_start; + u64 env_end; + u64 *auxv; + u32 auxv_size; + u32 exe_fd; }; #endif #ifndef PR_GET_TID_ADDRESS -# define PR_GET_TID_ADDRESS 40 +#define PR_GET_TID_ADDRESS 40 #endif #ifndef PR_SET_THP_DISABLE -# define PR_SET_THP_DISABLE 41 +#define PR_SET_THP_DISABLE 41 #endif #ifndef PR_GET_THP_DISABLE -# define PR_GET_THP_DISABLE 42 +#define PR_GET_THP_DISABLE 42 #endif #endif /* __CR_PRCTL_H__ */ diff --git a/criu/include/proc_parse.h b/criu/include/proc_parse.h index c043804b4..0c334a190 100644 --- a/criu/include/proc_parse.h +++ b/criu/include/proc_parse.h @@ -5,65 +5,65 @@ #include "compel/infect.h" -#define PROC_TASK_COMM_LEN 32 -#define PROC_TASK_COMM_LEN_FMT "(%31s" +#define PROC_TASK_COMM_LEN 32 +#define PROC_TASK_COMM_LEN_FMT "(%31s" struct proc_pid_stat { - int pid; - char comm[PROC_TASK_COMM_LEN]; - char state; - int ppid; - int pgid; - int sid; - int tty_nr; - int tty_pgrp; - unsigned int flags; - unsigned long min_flt; - unsigned long cmin_flt; - unsigned long maj_flt; - unsigned long cmaj_flt; - unsigned long utime; - unsigned long stime; - long cutime; - long cstime; - long priority; - long nice; - int num_threads; - int zero0; - unsigned long long start_time; - unsigned long vsize; - long mm_rss; - unsigned long rsslim; - unsigned long start_code; - unsigned long end_code; - unsigned long start_stack; - unsigned long esp; - unsigned long eip; - unsigned long sig_pending; - unsigned long sig_blocked; - unsigned long sig_ignored; - unsigned long sig_handled; - unsigned long wchan; - unsigned long zero1; - unsigned long zero2; - int exit_signal; - int task_cpu; - unsigned int rt_priority; - unsigned int policy; - unsigned long long delayacct_blkio_ticks; - unsigned long gtime; - long cgtime; - unsigned long start_data; - unsigned long end_data; - unsigned long start_brk; - unsigned long arg_start; - unsigned long arg_end; - unsigned long env_start; - unsigned long env_end; - int exit_code; + int pid; + char comm[PROC_TASK_COMM_LEN]; + char state; + int ppid; + int pgid; + int sid; + int tty_nr; + int tty_pgrp; + unsigned int flags; + unsigned long min_flt; + unsigned long cmin_flt; + unsigned long maj_flt; + unsigned long cmaj_flt; + unsigned long utime; + unsigned long stime; + long cutime; + long cstime; + long priority; + long nice; + int num_threads; + int zero0; + unsigned long long start_time; + unsigned long vsize; + long mm_rss; + unsigned long rsslim; + unsigned long start_code; + unsigned long end_code; + unsigned long start_stack; + unsigned long esp; + unsigned long eip; + unsigned long sig_pending; + unsigned long sig_blocked; + unsigned long sig_ignored; + unsigned long sig_handled; + unsigned long wchan; + unsigned long zero1; + unsigned long zero2; + int exit_signal; + int task_cpu; + unsigned int rt_priority; + unsigned int policy; + unsigned long long delayacct_blkio_ticks; + unsigned long gtime; + long cgtime; + unsigned long start_data; + unsigned long end_data; + unsigned long start_brk; + unsigned long arg_start; + unsigned long arg_end; + unsigned long env_start; + unsigned long env_end; + int exit_code; }; -#define PROC_CAP_SIZE 2 +#define PROC_CAP_SIZE 2 struct proc_status_creds { struct seize_task_status s; @@ -71,16 +71,16 @@ struct proc_status_creds { unsigned int uids[4]; unsigned int gids[4]; - u32 last_filter; + u32 last_filter; /* * Keep them at the end of structure * for fast comparison reason. */ - u32 cap_inh[PROC_CAP_SIZE]; - u32 cap_prm[PROC_CAP_SIZE]; - u32 cap_eff[PROC_CAP_SIZE]; - u32 cap_bnd[PROC_CAP_SIZE]; + u32 cap_inh[PROC_CAP_SIZE]; + u32 cap_prm[PROC_CAP_SIZE]; + u32 cap_eff[PROC_CAP_SIZE]; + u32 cap_bnd[PROC_CAP_SIZE]; }; #define INVALID_UID ((uid_t)-1) diff --git a/criu/include/protobuf-desc.h b/criu/include/protobuf-desc.h index 35fa1a90b..87f20d23a 100644 --- a/criu/include/protobuf-desc.h +++ b/criu/include/protobuf-desc.h @@ -6,7 +6,7 @@ enum { /* PB_AUTOGEN_START */ - PB_INVENTORY, /* 0 */ + PB_INVENTORY, /* 0 */ PB_STATS, PB_FDINFO, PB_CORE, @@ -16,7 +16,7 @@ enum { PB_POSIX_TIMER, PB_CREDS, PB_FS, - PB_UTSNS, /* 10 */ + PB_UTSNS, /* 10 */ PB_IPC_VAR, PB_IPC_SHM, PB_IPC_SEM, @@ -26,7 +26,7 @@ enum { PB_TCP_STREAM, PB_REG_FILE, PB_EXT_FILE, - PB_NS_FILE, /* 20 */ + PB_NS_FILE, /* 20 */ PB_INET_SK, PB_UNIX_SK, PB_PACKET_SOCK, @@ -36,7 +36,7 @@ enum { PB_PIPE_DATA, PB_EVENTFD_FILE, PB_EVENTPOLL_FILE, - PB_EVENTPOLL_TFD, /* 30 */ + PB_EVENTPOLL_TFD, /* 30 */ PB_SIGNALFD, PB_INOTIFY_FILE, PB_INOTIFY_WD, @@ -46,7 +46,7 @@ enum { PB_TTY_INFO, PB_FILE_LOCK, PB_RLIMIT, - PB_PAGEMAP, /* 40 */ + PB_PAGEMAP, /* 40 */ PB_SIGINFO, PB_TUNFILE, PB_IRMAP_CACHE, @@ -56,7 +56,7 @@ enum { PB_CPUINFO, PB_USERNS, PB_NETNS, - PB_BINFMT_MISC, /* 50 */ + PB_BINFMT_MISC, /* 50 */ PB_TTY_DATA, PB_AUTOFS, PB_GHOST_CHUNK, @@ -86,15 +86,15 @@ enum { typedef size_t (*pb_getpksize_t)(void *obj); typedef size_t (*pb_pack_t)(void *obj, void *where); -typedef void *(*pb_unpack_t)(void *allocator, size_t size, void *from); -typedef void (*pb_free_t)(void *obj, void *allocator); +typedef void *(*pb_unpack_t)(void *allocator, size_t size, void *from); +typedef void (*pb_free_t)(void *obj, void *allocator); struct cr_pb_message_desc { - pb_getpksize_t getpksize; - pb_pack_t pack; - pb_unpack_t unpack; - pb_free_t free; - const ProtobufCMessageDescriptor *pb_desc; + pb_getpksize_t getpksize; + pb_pack_t pack; + pb_unpack_t unpack; + pb_free_t free; + const ProtobufCMessageDescriptor *pb_desc; }; extern void cr_pb_init(void); diff --git a/criu/include/protobuf.h b/criu/include/protobuf.h index 0b6d8c150..11cca1564 100644 --- a/criu/include/protobuf.h +++ b/criu/include/protobuf.h @@ -11,19 +11,16 @@ struct cr_img; extern int do_pb_read_one(struct cr_img *, void **objp, int type, bool eof); -#define pb_read_one(fd, objp, type) do_pb_read_one(fd, (void **)objp, type, false) +#define pb_read_one(fd, objp, type) do_pb_read_one(fd, (void **)objp, type, false) #define pb_read_one_eof(fd, objp, type) do_pb_read_one(fd, (void **)objp, type, true) extern int pb_write_one(struct cr_img *, void *obj, int type); -#define pb_pksize(__obj, __proto_message_name) \ - (__proto_message_name ##__get_packed_size(__obj) + sizeof(u32)) +#define pb_pksize(__obj, __proto_message_name) (__proto_message_name##__get_packed_size(__obj) + sizeof(u32)) -#define pb_repeated_size(__obj, __member) \ - ((size_t)(sizeof(*(__obj)->__member) * (__obj)->n_ ##__member)) +#define pb_repeated_size(__obj, __member) ((size_t)(sizeof(*(__obj)->__member) * (__obj)->n_##__member)) -#define pb_msg(__base, __type) \ - container_of(__base, __type, base) +#define pb_msg(__base, __type) container_of(__base, __type, base) #include @@ -35,9 +32,9 @@ struct collect_image_info { unsigned flags; }; -#define COLLECT_SHARED 0x1 /* use shared memory for obj-s */ -#define COLLECT_NOFREE 0x2 /* don't free entry after callback */ -#define COLLECT_HAPPENED 0x4 /* image was opened and collected */ +#define COLLECT_SHARED 0x1 /* use shared memory for obj-s */ +#define COLLECT_NOFREE 0x2 /* don't free entry after callback */ +#define COLLECT_HAPPENED 0x4 /* image was opened and collected */ extern int collect_image(struct collect_image_info *); extern int collect_entry(ProtobufCMessage *base, struct collect_image_info *cinfo); @@ -57,6 +54,6 @@ static inline int collect_images(struct collect_image_info **array, unsigned siz * by providing space on stack, this should * be more than enough for most objects. */ -#define PB_PKOBJ_LOCAL_SIZE 1024 +#define PB_PKOBJ_LOCAL_SIZE 1024 #endif /* __CR_PROTOBUF_H__ */ diff --git a/criu/include/pstree.h b/criu/include/pstree.h index 17d22e791..faf359073 100644 --- a/criu/include/pstree.h +++ b/criu/include/pstree.h @@ -11,24 +11,24 @@ * That's the init process which usually inherit * all orphaned children in the system. */ -#define INIT_PID (1) +#define INIT_PID (1) struct pstree_item { - struct pstree_item *parent; - struct list_head children; /* list of my children */ - struct list_head sibling; /* linkage in my parent's children list */ + struct pstree_item *parent; + struct list_head children; /* list of my children */ + struct list_head sibling; /* linkage in my parent's children list */ - struct pid *pid; - pid_t pgid; - pid_t sid; - pid_t born_sid; + struct pid *pid; + pid_t pgid; + pid_t sid; + pid_t born_sid; - int nr_threads; /* number of threads */ - struct pid *threads; /* array of threads */ - CoreEntry **core; - TaskKobjIdsEntry *ids; + int nr_threads; /* number of threads */ + struct pid *threads; /* array of threads */ + CoreEntry **core; + TaskKobjIdsEntry *ids; union { - futex_t task_st; - unsigned long task_st_le_bits; + futex_t task_st; + unsigned long task_st_le_bits; }; }; @@ -38,7 +38,7 @@ static inline pid_t vpid(const struct pstree_item *i) } enum { - FDS_EVENT_BIT = 0, + FDS_EVENT_BIT = 0, }; #define FDS_EVENT (1 << FDS_EVENT_BIT) @@ -68,8 +68,7 @@ static inline struct dmp_info *dmpi(const struct pstree_item *i) /* ids is allocated and initialized for all alive tasks */ static inline int shared_fdtable(struct pstree_item *item) { - return (item->parent && - item->ids->files_id == item->parent->ids->files_id); + return (item->parent && item->ids->files_id == item->parent->ids->files_id); } static inline bool is_alive_state(int state) @@ -93,8 +92,7 @@ extern struct pid *pstree_pid_by_virt(pid_t pid); extern struct pstree_item *root_item; extern struct pstree_item *pstree_item_next(struct pstree_item *item); -#define for_each_pstree_item(pi) \ - for (pi = root_item; pi != NULL; pi = pstree_item_next(pi)) +#define for_each_pstree_item(pi) for (pi = root_item; pi != NULL; pi = pstree_item_next(pi)) extern bool restore_before_setsid(struct pstree_item *child); extern int prepare_pstree(void); diff --git a/criu/include/ptrace-compat.h b/criu/include/ptrace-compat.h index e16fef036..a2f211129 100644 --- a/criu/include/ptrace-compat.h +++ b/criu/include/ptrace-compat.h @@ -7,9 +7,9 @@ #ifndef CONFIG_HAS_PTRACE_PEEKSIGINFO struct ptrace_peeksiginfo_args { - __u64 off; /* from which siginfo to start */ + __u64 off; /* from which siginfo to start */ __u32 flags; - __u32 nr; /* how may siginfos to take */ + __u32 nr; /* how may siginfos to take */ }; #endif diff --git a/criu/include/rbtree.h b/criu/include/rbtree.h index 007950638..ba0a8100e 100644 --- a/criu/include/rbtree.h +++ b/criu/include/rbtree.h @@ -9,26 +9,32 @@ #include "common/compiler.h" -#define RB_RED 0 -#define RB_BLACK 1 -#define RB_MASK 3 +#define RB_RED 0 +#define RB_BLACK 1 +#define RB_MASK 3 struct rb_node { - unsigned long rb_parent_color; /* Keeps both parent anc color */ - struct rb_node *rb_right; - struct rb_node *rb_left; + unsigned long rb_parent_color; /* Keeps both parent anc color */ + struct rb_node *rb_right; + struct rb_node *rb_left; } __aligned(sizeof(long)); struct rb_root { - struct rb_node *rb_node; + struct rb_node *rb_node; }; -#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~RB_MASK)) -#define rb_color(r) ((r)->rb_parent_color & RB_BLACK) -#define rb_is_red(r) (!rb_color(r)) -#define rb_is_black(r) (rb_color(r)) -#define rb_set_red(r) do { (r)->rb_parent_color &= ~RB_BLACK; } while (0) -#define rb_set_black(r) do { (r)->rb_parent_color |= RB_BLACK; } while (0) +#define rb_parent(r) ((struct rb_node *)((r)->rb_parent_color & ~RB_MASK)) +#define rb_color(r) ((r)->rb_parent_color & RB_BLACK) +#define rb_is_red(r) (!rb_color(r)) +#define rb_is_black(r) (rb_color(r)) +#define rb_set_red(r) \ + do { \ + (r)->rb_parent_color &= ~RB_BLACK; \ + } while (0) +#define rb_set_black(r) \ + do { \ + (r)->rb_parent_color |= RB_BLACK; \ + } while (0) static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p) { @@ -40,16 +46,20 @@ static inline void rb_set_color(struct rb_node *rb, int color) rb->rb_parent_color = (rb->rb_parent_color & ~RB_BLACK) | color; } -#define RB_ROOT (struct rb_root){ NULL, } -#define rb_entry(ptr, type, member) container_of(ptr, type, member) +#define RB_ROOT \ + (struct rb_root) \ + { \ + NULL, \ + } +#define rb_entry(ptr, type, member) container_of(ptr, type, member) -#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) -#define RB_EMPTY_NODE(node) (rb_parent(node) == node) -#define RB_CLEAR_NODE(node) (rb_set_parent(node, node)) +#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) +#define RB_EMPTY_NODE(node) (rb_parent(node) == node) +#define RB_CLEAR_NODE(node) (rb_set_parent(node, node)) static inline void rb_init_node(struct rb_node *node) { - *node = (struct rb_node){ }; + *node = (struct rb_node){}; RB_CLEAR_NODE(node); } @@ -64,11 +74,9 @@ extern struct rb_node *rb_next(const struct rb_node *node); extern struct rb_node *rb_prev(const struct rb_node *node); /* Fast replacement of a single node without remove/rebalance/add/rebalance */ -extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, - struct rb_root *root); +extern void rb_replace_node(struct rb_node *victim, struct rb_node *new, struct rb_root *root); -static inline void rb_link_node(struct rb_node *node, struct rb_node *parent, - struct rb_node **rb_link) +static inline void rb_link_node(struct rb_node *node, struct rb_node *parent, struct rb_node **rb_link) { node->rb_parent_color = (unsigned long)parent; node->rb_left = node->rb_right = NULL; @@ -76,10 +84,8 @@ static inline void rb_link_node(struct rb_node *node, struct rb_node *parent, *rb_link = node; } -static inline void rb_link_and_balance(struct rb_root *root, - struct rb_node *node, - struct rb_node *parent, - struct rb_node **rb_link) +static inline void rb_link_and_balance(struct rb_root *root, struct rb_node *node, struct rb_node *parent, + struct rb_node **rb_link) { rb_link_node(node, parent, rb_link); rb_insert_color(node, root); diff --git a/criu/include/restorer.h b/criu/include/restorer.h index dfb4e6b71..934d60cf9 100644 --- a/criu/include/restorer.h +++ b/criu/include/restorer.h @@ -28,14 +28,14 @@ /* * These *must* be power of two values. */ -#define RESTORE_ARGS_SIZE (512) -#define RESTORE_STACK_REDZONE (128) -#define RESTORE_STACK_SIZE (KILO(32)) +#define RESTORE_ARGS_SIZE (512) +#define RESTORE_STACK_REDZONE (128) +#define RESTORE_STACK_SIZE (KILO(32)) struct restore_mem_zone { - u8 redzone[RESTORE_STACK_REDZONE]; - u8 stack[RESTORE_STACK_SIZE]; - u8 rt_sigframe[RESTORE_STACK_SIGFRAME]; + u8 redzone[RESTORE_STACK_REDZONE]; + u8 stack[RESTORE_STACK_SIZE]; + u8 rt_sigframe[RESTORE_STACK_SIGFRAME]; } __stack_aligned__; struct rst_sched_param { @@ -57,66 +57,66 @@ struct restore_posix_timer { */ struct thread_creds_args { - CredsEntry creds; + CredsEntry creds; - unsigned int cap_last_cap; + unsigned int cap_last_cap; - u32 cap_inh[CR_CAP_SIZE]; - u32 cap_prm[CR_CAP_SIZE]; - u32 cap_eff[CR_CAP_SIZE]; - u32 cap_bnd[CR_CAP_SIZE]; + u32 cap_inh[CR_CAP_SIZE]; + u32 cap_prm[CR_CAP_SIZE]; + u32 cap_eff[CR_CAP_SIZE]; + u32 cap_bnd[CR_CAP_SIZE]; - unsigned int secbits; - char *lsm_profile; - unsigned int *groups; - char *lsm_sockcreate; + unsigned int secbits; + char *lsm_profile; + unsigned int *groups; + char *lsm_sockcreate; - unsigned long mem_lsm_profile_pos; - unsigned long mem_lsm_sockcreate_pos; - unsigned long mem_groups_pos; + unsigned long mem_lsm_profile_pos; + unsigned long mem_lsm_sockcreate_pos; + unsigned long mem_groups_pos; - unsigned long mem_pos_next; + unsigned long mem_pos_next; }; struct thread_seccomp_filter { - struct sock_fprog sock_fprog; - unsigned int flags; + struct sock_fprog sock_fprog; + unsigned int flags; }; struct thread_restore_args { - struct restore_mem_zone *mz; + struct restore_mem_zone *mz; - int pid; - UserRegsEntry gpregs; - u64 clear_tid_addr; + int pid; + UserRegsEntry gpregs; + u64 clear_tid_addr; - u64 futex_rla; - u32 futex_rla_len; + u64 futex_rla; + u32 futex_rla_len; - struct rst_sched_param sp; + struct rst_sched_param sp; - struct task_restore_args *ta; + struct task_restore_args *ta; - tls_t tls; + tls_t tls; - siginfo_t *siginfo; - unsigned int siginfo_n; + siginfo_t *siginfo; + unsigned int siginfo_n; - int pdeath_sig; + int pdeath_sig; - struct thread_creds_args *creds_args; + struct thread_creds_args *creds_args; - int seccomp_mode; - unsigned long seccomp_filters_pos; - struct thread_seccomp_filter *seccomp_filters; - void *seccomp_filters_data; - unsigned int seccomp_filters_n; - bool seccomp_force_tsync; + int seccomp_mode; + unsigned long seccomp_filters_pos; + struct thread_seccomp_filter *seccomp_filters; + void *seccomp_filters_data; + unsigned int seccomp_filters_n; + bool seccomp_force_tsync; - char comm[TASK_COMM_LEN]; + char comm[TASK_COMM_LEN]; } __aligned(64); -typedef long (*thread_restore_fcall_t) (struct thread_restore_args *args); +typedef long (*thread_restore_fcall_t)(struct thread_restore_args *args); struct restore_vma_io { int nr_iovs; @@ -124,112 +124,111 @@ struct restore_vma_io { struct iovec iovs[0]; }; -#define RIO_SIZE(niovs) (sizeof(struct restore_vma_io) + (niovs) * sizeof(struct iovec)) +#define RIO_SIZE(niovs) (sizeof(struct restore_vma_io) + (niovs) * sizeof(struct iovec)) struct task_restore_args { - struct thread_restore_args *t; /* thread group leader */ + struct thread_restore_args *t; /* thread group leader */ - int fd_exe_link; /* opened self->exe file */ - int logfd; - unsigned int loglevel; - struct timeval logstart; + int fd_exe_link; /* opened self->exe file */ + int logfd; + unsigned int loglevel; + struct timeval logstart; - int uffd; - bool has_thp_enabled; + int uffd; + bool has_thp_enabled; /* threads restoration */ - int nr_threads; /* number of threads */ - thread_restore_fcall_t clone_restore_fn; /* helper address for clone() call */ - struct thread_restore_args *thread_args; /* array of thread arguments */ - struct task_entries *task_entries; - void *rst_mem; - unsigned long rst_mem_size; + int nr_threads; /* number of threads */ + thread_restore_fcall_t clone_restore_fn; /* helper address for clone() call */ + struct thread_restore_args *thread_args; /* array of thread arguments */ + struct task_entries *task_entries; + void *rst_mem; + unsigned long rst_mem_size; /* Below arrays get remapped from RM_PRIVATE in sigreturn_restore */ - VmaEntry *vmas; - unsigned int vmas_n; + VmaEntry *vmas; + unsigned int vmas_n; - int vma_ios_fd; - struct restore_vma_io *vma_ios; - unsigned int vma_ios_n; + int vma_ios_fd; + struct restore_vma_io *vma_ios; + unsigned int vma_ios_n; - struct restore_posix_timer *posix_timers; - unsigned int posix_timers_n; + struct restore_posix_timer *posix_timers; + unsigned int posix_timers_n; - struct restore_timerfd *timerfd; - unsigned int timerfd_n; + struct restore_timerfd *timerfd; + unsigned int timerfd_n; - siginfo_t *siginfo; - unsigned int siginfo_n; + siginfo_t *siginfo; + unsigned int siginfo_n; - struct rst_tcp_sock *tcp_socks; - unsigned int tcp_socks_n; + struct rst_tcp_sock *tcp_socks; + unsigned int tcp_socks_n; - struct rst_aio_ring *rings; - unsigned int rings_n; + struct rst_aio_ring *rings; + unsigned int rings_n; - struct rlimit64 *rlims; - unsigned int rlims_n; + struct rlimit64 *rlims; + unsigned int rlims_n; - pid_t *helpers /* the TASK_HELPERS to wait on at the end of restore */; - unsigned int helpers_n; + pid_t *helpers /* the TASK_HELPERS to wait on at the end of restore */; + unsigned int helpers_n; - pid_t *zombies; - unsigned int zombies_n; + pid_t *zombies; + unsigned int zombies_n; - int *inotify_fds; /* fds to cleanup inotify events at CR_STATE_RESTORE_SIGCHLD stage */ - unsigned int inotify_fds_n; + int *inotify_fds; /* fds to cleanup inotify events at CR_STATE_RESTORE_SIGCHLD stage */ + unsigned int inotify_fds_n; /* * * * * * * * * * * * * * * * * * * * */ - unsigned long task_size; - unsigned long premmapped_addr; - unsigned long premmapped_len; - rt_sigaction_t sigchld_act; + unsigned long task_size; + unsigned long premmapped_addr; + unsigned long premmapped_len; + rt_sigaction_t sigchld_act; - void *bootstrap_start; - unsigned long bootstrap_len; + void *bootstrap_start; + unsigned long bootstrap_len; - struct itimerval itimers[3]; + struct itimerval itimers[3]; - MmEntry mm; - auxv_t mm_saved_auxv[AT_VECTOR_SIZE]; - u32 mm_saved_auxv_size; - char comm[TASK_COMM_LEN]; + MmEntry mm; + auxv_t mm_saved_auxv[AT_VECTOR_SIZE]; + u32 mm_saved_auxv_size; + char comm[TASK_COMM_LEN]; /* * proc_fd is a handle to /proc that the restorer blob can use to open * files there, because some of them can't be opened before the * restorer blob is called. */ - int proc_fd; + int proc_fd; - int seccomp_mode; + int seccomp_mode; - bool compatible_mode; + bool compatible_mode; - bool can_map_vdso; - bool auto_dedup; - unsigned long vdso_rt_size; - struct vdso_maps vdso_maps_rt; /* runtime vdso symbols */ - unsigned long vdso_rt_parked_at; /* safe place to keep vdso */ - void **breakpoint; + bool can_map_vdso; + bool auto_dedup; + unsigned long vdso_rt_size; + struct vdso_maps vdso_maps_rt; /* runtime vdso symbols */ + unsigned long vdso_rt_parked_at; /* safe place to keep vdso */ + void **breakpoint; - enum faults fault_strategy; + enum faults fault_strategy; #ifdef ARCH_HAS_LONG_PAGES - unsigned page_size; + unsigned page_size; #endif - int lsm_type; - int child_subreaper; - bool has_clone3_set_tid; + int lsm_type; + int child_subreaper; + bool has_clone3_set_tid; } __aligned(64); /* * For arm64 stack needs to aligned to 16 bytes. * Hence align to 16 bytes for all */ -#define RESTORE_ALIGN_STACK(start, size) \ - (ALIGN((start) + (size) - 16, 16)) +#define RESTORE_ALIGN_STACK(start, size) (ALIGN((start) + (size)-16, 16)) static inline unsigned long restorer_stack(struct restore_mem_zone *mz) { @@ -245,12 +244,12 @@ enum { * The first stated stage is CR_STATE_ROOT_TASK which is started * right before calling fork_with_pid() for the root_item. */ - CR_STATE_FAIL = -1, + CR_STATE_FAIL = -1, /* * Root task is created and does some pre-checks. * After the stage ACT_SETUP_NS scripts are performed. */ - CR_STATE_ROOT_TASK = 0, + CR_STATE_ROOT_TASK = 0, /* * The prepare_namespace() is called. * After the stage criu opens root task's mntns and @@ -304,14 +303,14 @@ enum { CR_STATE_COMPLETE }; -#define restore_finish_stage(__v, __stage) ({ \ - futex_dec_and_wake(&(__v)->nr_in_progress); \ - futex_wait_while(&(__v)->start, __stage); \ - (s32) futex_get(&(__v)->start); \ +#define restore_finish_stage(__v, __stage) \ + ({ \ + futex_dec_and_wake(&(__v)->nr_in_progress); \ + futex_wait_while(&(__v)->start, __stage); \ + (s32) futex_get(&(__v)->start); \ }) - -#define __r_sym(name) restorer_sym ## name -#define restorer_sym(rblob, name) (void*)(rblob + __r_sym(name)) +#define __r_sym(name) restorer_sym##name +#define restorer_sym(rblob, name) (void *)(rblob + __r_sym(name)) #endif /* __CR_RESTORER_H__ */ diff --git a/criu/include/rst-malloc.h b/criu/include/rst-malloc.h index 67391ba77..918359a93 100644 --- a/criu/include/rst-malloc.h +++ b/criu/include/rst-malloc.h @@ -52,9 +52,10 @@ extern void rst_mem_switch_to_private(void); */ extern unsigned long rst_mem_align_cpos(int type); extern void *rst_mem_remap_ptr(unsigned long pos, int type); -#define RST_MEM_FIXUP_PPTR(ptr) do { \ - ptr = rst_mem_remap_ptr((unsigned long)ptr, RM_PRIVATE);\ -} while (0) +#define RST_MEM_FIXUP_PPTR(ptr) \ + do { \ + ptr = rst_mem_remap_ptr((unsigned long)ptr, RM_PRIVATE); \ + } while (0) /* * Allocate and free objects. We don't need to free arbitrary diff --git a/criu/include/rst_info.h b/criu/include/rst_info.h index 3dc119a93..2e2107b0e 100644 --- a/criu/include/rst_info.h +++ b/criu/include/rst_info.h @@ -17,59 +17,59 @@ struct task_entries { }; struct fdt { - int nr; /* How many tasks share this fd table */ - pid_t pid; /* Who should restore this fd table */ + int nr; /* How many tasks share this fd table */ + pid_t pid; /* Who should restore this fd table */ /* * The fd table is ready for restoing, if fdt_lock is equal to nr * The fdt table was restrored, if fdt_lock is equal to nr + 1 */ - futex_t fdt_lock; + futex_t fdt_lock; }; struct rst_info { - struct list_head fds; + struct list_head fds; - void *premmapped_addr; - unsigned long premmapped_len; - unsigned long clone_flags; + void *premmapped_addr; + unsigned long premmapped_len; + unsigned long clone_flags; - void *munmap_restorer; + void *munmap_restorer; int service_fd_id; - struct fdt *fdt; + struct fdt *fdt; - struct vm_area_list vmas; - MmEntry *mm; - struct list_head vma_io; - unsigned int pages_img_id; + struct vm_area_list vmas; + MmEntry *mm; + struct list_head vma_io; + unsigned int pages_img_id; - u32 cg_set; + u32 cg_set; union { - struct pstree_item *pgrp_leader; - futex_t pgrp_set; + struct pstree_item *pgrp_leader; + futex_t pgrp_set; }; - struct file_desc *cwd; - struct file_desc *root; - bool has_umask; - u32 umask; + struct file_desc *cwd; + struct file_desc *root; + bool has_umask; + u32 umask; /* * We set this flag when process has seccomp filters * so that we know to suspend them before we unmap the * restorer blob. */ - bool has_seccomp; + bool has_seccomp; /* * To be compatible with old images where filters * are bound to group leader and we need to use tsync flag. */ - bool has_old_seccomp_filter; + bool has_old_seccomp_filter; - bool has_thp_enabled; + bool has_thp_enabled; - void *breakpoint; + void *breakpoint; }; extern struct task_entries *task_entries; diff --git a/criu/include/sched.h b/criu/include/sched.h index 78f65e3b7..9f9f993ce 100644 --- a/criu/include/sched.h +++ b/criu/include/sched.h @@ -4,10 +4,10 @@ #include #ifndef ptr_to_u64 -#define ptr_to_u64(ptr) ((__u64)((uintptr_t)(ptr))) +#define ptr_to_u64(ptr) ((__u64)((uintptr_t)(ptr))) #endif #ifndef u64_to_ptr -#define u64_to_ptr(x) ((void *)(uintptr_t)x) +#define u64_to_ptr(x) ((void *)(uintptr_t)x) #endif /* diff --git a/criu/include/seccomp.h b/criu/include/seccomp.h index 8e200124e..e20b9d655 100644 --- a/criu/include/seccomp.h +++ b/criu/include/seccomp.h @@ -45,19 +45,19 @@ struct rb_node; * which has no filters yet. */ struct seccomp_filter_chain { - struct seccomp_filter_chain *prev; - SeccompFilter filter; + struct seccomp_filter_chain *prev; + SeccompFilter filter; }; struct seccomp_entry { - struct rb_node node; - struct seccomp_entry *next; - pid_t tid_real; - size_t img_filter_pos; - unsigned int mode; + struct rb_node node; + struct seccomp_entry *next; + pid_t tid_real; + size_t img_filter_pos; + unsigned int mode; - struct seccomp_filter_chain *chain; - size_t nr_chains; + struct seccomp_filter_chain *chain; + size_t nr_chains; }; extern struct seccomp_entry *seccomp_lookup(pid_t tid_real, bool create, bool mandatory); diff --git a/criu/include/servicefd.h b/criu/include/servicefd.h index b03bdaf59..e75e8444c 100644 --- a/criu/include/servicefd.h +++ b/criu/include/servicefd.h @@ -15,18 +15,18 @@ enum sfd_type { LOG_FD_OFF, IMG_FD_OFF, IMG_STREAMER_FD_OFF, - PROC_FD_OFF, /* fd with /proc for all proc_ calls */ + PROC_FD_OFF, /* fd with /proc for all proc_ calls */ PROC_PID_FD_OFF, PROC_SELF_FD_OFF, - CR_PROC_FD_OFF, /* some other's proc fd: + CR_PROC_FD_OFF, /* some other's proc fd: * - For dump -- target ns' proc * - For restore -- CRIU ns' proc */ - ROOT_FD_OFF, /* Root of the namespace we dump/restore */ + ROOT_FD_OFF, /* Root of the namespace we dump/restore */ CGROUP_YARD, - USERNSD_SK, /* Socket for usernsd */ - NS_FD_OFF, /* Node's net namespace fd */ - TRANSPORT_FD_OFF, /* to transfer file descriptors */ + USERNSD_SK, /* Socket for usernsd */ + NS_FD_OFF, /* Node's net namespace fd */ + TRANSPORT_FD_OFF, /* to transfer file descriptors */ RPC_SK_OFF, FDSTORE_SK_OFF, @@ -36,7 +36,6 @@ enum sfd_type { struct pstree_item; extern bool sfds_protected; - extern const char *sfd_type_name(enum sfd_type type); extern int init_service_fd(void); extern int get_service_fd(enum sfd_type type); diff --git a/criu/include/shmem.h b/criu/include/shmem.h index 798e28f34..813ef630e 100644 --- a/criu/include/shmem.h +++ b/criu/include/shmem.h @@ -17,7 +17,6 @@ extern int dump_one_sysv_shmem(void *addr, unsigned long size, unsigned long shm extern int restore_sysv_shmem_content(void *addr, unsigned long size, unsigned long shmid); extern int restore_memfd_shmem_content(int fd, unsigned long shmid, unsigned long size); - -#define SYSV_SHMEM_SKIP_FD (0x7fffffff) +#define SYSV_SHMEM_SKIP_FD (0x7fffffff) #endif /* __CR_SHMEM_H__ */ diff --git a/criu/include/sigframe.h b/criu/include/sigframe.h index b63d9f0e5..539d7b17c 100644 --- a/criu/include/sigframe.h +++ b/criu/include/sigframe.h @@ -8,9 +8,7 @@ #include #include "images/core.pb-c.h" -extern int construct_sigframe(struct rt_sigframe *sigframe, - struct rt_sigframe *rsigframe, - k_rtsigset_t *blkset, +extern int construct_sigframe(struct rt_sigframe *sigframe, struct rt_sigframe *rsigframe, k_rtsigset_t *blkset, CoreEntry *core); #endif /* __CR_SIGFRAME_H__ */ diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h index dec67ca6c..c832d6387 100644 --- a/criu/include/sk-inet.h +++ b/criu/include/sk-inet.h @@ -8,39 +8,39 @@ #include "common/list.h" #include "images/sk-inet.pb-c.h" -#define INET_ADDR_LEN 48 /* max of INET_ADDRSTRLEN and INET6_ADDRSTRLEN */ +#define INET_ADDR_LEN 48 /* max of INET_ADDRSTRLEN and INET6_ADDRSTRLEN */ #ifndef TCP_REPAIR -#define TCP_REPAIR 19 /* TCP sock is under repair right now */ -#define TCP_REPAIR_QUEUE 20 -#define TCP_QUEUE_SEQ 21 -#define TCP_REPAIR_OPTIONS 22 +#define TCP_REPAIR 19 /* TCP sock is under repair right now */ +#define TCP_REPAIR_QUEUE 20 +#define TCP_QUEUE_SEQ 21 +#define TCP_REPAIR_OPTIONS 22 #endif #ifndef IP_HDRINCL -# define IP_HDRINCL 3 +#define IP_HDRINCL 3 #endif #ifndef IP_NODEFRAG -# define IP_NODEFRAG 22 +#define IP_NODEFRAG 22 #endif #ifndef IPV6_HDRINCL -# define IPV6_HDRINCL 36 +#define IPV6_HDRINCL 36 #endif struct inet_sk_desc { - struct socket_desc sd; - unsigned int type; - unsigned int src_port; - unsigned int dst_port; - unsigned int state; - unsigned int rqlen; - unsigned int wqlen; /* sent + unsent data */ - unsigned int uwqlen; /* unsent data */ - unsigned int src_addr[4]; - unsigned int dst_addr[4]; - unsigned short shutdown; - bool cork; + struct socket_desc sd; + unsigned int type; + unsigned int src_port; + unsigned int dst_port; + unsigned int state; + unsigned int rqlen; + unsigned int wqlen; /* sent + unsent data */ + unsigned int uwqlen; /* unsent data */ + unsigned int src_addr[4]; + unsigned int dst_addr[4]; + unsigned short shutdown; + bool cork; int rfd; int cpt_reuseaddr; @@ -68,7 +68,7 @@ extern int inet_bind(int sk, struct inet_sk_info *); extern int inet_connect(int sk, struct inet_sk_info *); #ifdef CR_NOGLIBC -#define setsockopt sys_setsockopt +#define setsockopt sys_setsockopt #endif static inline void tcp_repair_off(int fd) { @@ -86,20 +86,19 @@ extern void cpt_unlock_tcp_connections(void); extern int dump_one_tcp(int sk, struct inet_sk_desc *sd, SkOptsEntry *soe); extern int restore_one_tcp(int sk, struct inet_sk_info *si); -#define SK_EST_PARAM "tcp-established" +#define SK_EST_PARAM "tcp-established" #define SK_INFLIGHT_PARAM "skip-in-flight" -#define SK_CLOSE_PARAM "tcp-close" +#define SK_CLOSE_PARAM "tcp-close" struct task_restore_args; int prepare_tcp_socks(struct task_restore_args *); struct rst_tcp_sock { - int sk; - bool reuseaddr; + int sk; + bool reuseaddr; }; union libsoccr_addr; -int restore_sockaddr(union libsoccr_addr *sa, - int family, u32 pb_port, u32 *pb_addr, u32 ifindex); +int restore_sockaddr(union libsoccr_addr *sa, int family, u32 pb_port, u32 *pb_addr, u32 ifindex); #endif /* __CR_SK_INET_H__ */ diff --git a/criu/include/sk-packet.h b/criu/include/sk-packet.h index a0738ae0c..5fe6d3d62 100644 --- a/criu/include/sk-packet.h +++ b/criu/include/sk-packet.h @@ -2,7 +2,7 @@ #define __CR_SK_PACKET_H__ #ifndef PACKET_TIMESTAMP -#define PACKET_TIMESTAMP 17 +#define PACKET_TIMESTAMP 17 #endif struct cr_imgset; @@ -22,7 +22,7 @@ extern int packet_receive_one(struct nlmsghdr *h, struct ns_id *ns, void *arg); #endif #ifndef PACKET_FANOUT -#define PACKET_FANOUT 18 +#define PACKET_FANOUT 18 #endif #ifndef TPACKET3_HDRLEN diff --git a/criu/include/sockets.h b/criu/include/sockets.h index e971f3efd..3e8f3d601 100644 --- a/criu/include/sockets.h +++ b/criu/include/sockets.h @@ -17,11 +17,11 @@ struct nlmsghdr; struct cr_img; struct socket_desc { - unsigned int family; - unsigned int ino; - struct socket_desc *next; - struct ns_id *sk_ns; - int already_dumped; + unsigned int family; + unsigned int ino; + struct socket_desc *next; + struct ns_id *sk_ns; + int already_dumped; }; extern int dump_socket(struct fd_parms *p, int lfd, FdinfoEntry *); @@ -65,23 +65,24 @@ extern int unix_prepare_root_shared(void); extern void init_sk_info_hash(void); extern int do_dump_opt(int sk, int level, int name, void *val, int len); -#define dump_opt(s, l, n, f) do_dump_opt(s, l, n, f, sizeof(*f)) +#define dump_opt(s, l, n, f) do_dump_opt(s, l, n, f, sizeof(*f)) extern int do_restore_opt(int sk, int level, int name, void *val, int len); -#define restore_opt(s, l, n, f) do_restore_opt(s, l, n, f, sizeof(*f)) +#define restore_opt(s, l, n, f) do_restore_opt(s, l, n, f, sizeof(*f)) -#define sk_encode_shutdown(img, mask) do { \ +#define sk_encode_shutdown(img, mask) \ + do { \ /* \ * protobuf SK_SHUTDOWN__ bits match those \ * reported by kernel \ - */ \ - (img)->shutdown = mask; \ - if ((img)->shutdown != SK_SHUTDOWN__NONE) \ - (img)->has_shutdown = true; \ + */ \ + (img)->shutdown = mask; \ + if ((img)->shutdown != SK_SHUTDOWN__NONE) \ + (img)->has_shutdown = true; \ } while (0) static inline int sk_decode_shutdown(int val) { - static const int hows[] = {-1, SHUT_RD, SHUT_WR, SHUT_RDWR}; + static const int hows[] = { -1, SHUT_RD, SHUT_WR, SHUT_RDWR }; return hows[val]; } @@ -94,7 +95,7 @@ static inline int sk_decode_shutdown(int val) extern int set_netns(uint32_t ns_id); #ifndef SIOCGSKNS -#define SIOCGSKNS 0x894C /* get socket network namespace */ +#define SIOCGSKNS 0x894C /* get socket network namespace */ #endif extern int kerndat_socket_netns(void); @@ -107,19 +108,19 @@ extern const char *socket_proto_name(unsigned int proto, char *nm, size_t size); #define __tcp_state_name(state, a) tcp_state_name(state, a, sizeof(a)) #define __socket_type_name(type, a) socket_type_name(type, a, sizeof(a)) -#define __socket_family_name(family, a) socket_family_name(family, a, sizeof(a)) +#define __socket_family_name(family, a) socket_family_name(family, a, sizeof(a)) #define __socket_proto_name(proto, a) socket_proto_name(proto, a, sizeof(a)) -#define __socket_info_helper(__h, __v) \ - ({ \ - char *__nm = alloca(32); \ - const char *__r = __h(__v, __nm, 32); \ - __r; \ +#define __socket_info_helper(__h, __v) \ + ({ \ + char *__nm = alloca(32); \ + const char *__r = __h(__v, __nm, 32); \ + __r; \ }) -#define ___tcp_state_name(state) __socket_info_helper(tcp_state_name, state) -#define ___socket_type_name(type) __socket_info_helper(socket_type_name, type) -#define ___socket_family_name(family) __socket_info_helper(socket_family_name, family) -#define ___socket_proto_name(proto) __socket_info_helper(socket_proto_name, proto) +#define ___tcp_state_name(state) __socket_info_helper(tcp_state_name, state) +#define ___socket_type_name(type) __socket_info_helper(socket_type_name, type) +#define ___socket_family_name(family) __socket_info_helper(socket_family_name, family) +#define ___socket_proto_name(proto) __socket_info_helper(socket_proto_name, proto) #endif /* __CR_SOCKETS_H__ */ diff --git a/criu/include/stats.h b/criu/include/stats.h index 5d408b7b1..d8dd15998 100644 --- a/criu/include/stats.h +++ b/criu/include/stats.h @@ -47,8 +47,8 @@ enum { extern void cnt_add(int c, unsigned long val); extern void cnt_sub(int c, unsigned long val); -#define DUMP_STATS 1 -#define RESTORE_STATS 2 +#define DUMP_STATS 1 +#define RESTORE_STATS 2 extern int init_stats(int what); extern void write_stats(int what); diff --git a/criu/include/string.h b/criu/include/string.h index bc5f9d219..e11a42058 100644 --- a/criu/include/string.h +++ b/criu/include/string.h @@ -4,7 +4,7 @@ #include #ifdef CONFIG_HAS_LIBBSD -# include +#include #endif #include "common/config.h" diff --git a/criu/include/sysctl.h b/criu/include/sysctl.h index e271f5ead..ac7924dcd 100644 --- a/criu/include/sysctl.h +++ b/criu/include/sysctl.h @@ -2,10 +2,10 @@ #define __CR_SYSCTL_H__ struct sysctl_req { - char *name; - void *arg; - int type; - int flags; + char *name; + void *arg; + int type; + int flags; }; extern int sysctl_op(struct sysctl_req *req, size_t nr_req, int op, unsigned int ns); @@ -15,27 +15,27 @@ enum { CTL_WRITE, }; -#define CTL_SHIFT 4 /* Up to 16 types */ +#define CTL_SHIFT 4 /* Up to 16 types */ -#define CTL_U32 1 /* Single u32 */ -#define CTL_U64 2 /* Single u64 */ -#define __CTL_U32A 3 /* Array of u32 */ -#define __CTL_U64A 4 /* Array of u64 */ -#define __CTL_STR 5 /* String */ -#define CTL_32 6 /* Single s32 */ +#define CTL_U32 1 /* Single u32 */ +#define CTL_U64 2 /* Single u64 */ +#define __CTL_U32A 3 /* Array of u32 */ +#define __CTL_U64A 4 /* Array of u64 */ +#define __CTL_STR 5 /* String */ +#define CTL_32 6 /* Single s32 */ -#define CTL_U32A(n) (__CTL_U32A | ((n) << CTL_SHIFT)) -#define CTL_U64A(n) (__CTL_U64A | ((n) << CTL_SHIFT)) -#define CTL_STR(len) (__CTL_STR | ((len) << CTL_SHIFT)) +#define CTL_U32A(n) (__CTL_U32A | ((n) << CTL_SHIFT)) +#define CTL_U64A(n) (__CTL_U64A | ((n) << CTL_SHIFT)) +#define CTL_STR(len) (__CTL_STR | ((len) << CTL_SHIFT)) -#define CTL_LEN(t) ((t) >> CTL_SHIFT) -#define CTL_TYPE(t) ((t) & ((1 << CTL_SHIFT) - 1)) +#define CTL_LEN(t) ((t) >> CTL_SHIFT) +#define CTL_TYPE(t) ((t) & ((1 << CTL_SHIFT) - 1)) /* * Some entries might be missing mark them as optional. */ #define CTL_FLAGS_OPTIONAL 1 #define CTL_FLAGS_HAS 2 -#define CTL_FLAGS_READ_EIO_SKIP 4 +#define CTL_FLAGS_READ_EIO_SKIP 4 #endif /* __CR_SYSCTL_H__ */ diff --git a/criu/include/sysfs_parse.h b/criu/include/sysfs_parse.h index 3ba06ed56..ff0e61148 100644 --- a/criu/include/sysfs_parse.h +++ b/criu/include/sysfs_parse.h @@ -2,9 +2,9 @@ #define __CR_SYSFS_PARSE_H__ #define SYSFS_AUFS "/sys/fs/aufs/" -#define SBINFO_LEN (3 + 16 + 1) /* si_%lx */ -#define SBINFO_PATH_LEN (sizeof SYSFS_AUFS + SBINFO_LEN) /* /sys/fs/aufs/ */ -#define AUFSBR_PATH_LEN (SBINFO_PATH_LEN + 6 + 1) /* /sys/fs/aufs//br%3d */ +#define SBINFO_LEN (3 + 16 + 1) /* si_%lx */ +#define SBINFO_PATH_LEN (sizeof SYSFS_AUFS + SBINFO_LEN) /* /sys/fs/aufs/ */ +#define AUFSBR_PATH_LEN (SBINFO_PATH_LEN + 6 + 1) /* /sys/fs/aufs//br%3d */ struct mount_info; struct vma_area; @@ -14,4 +14,3 @@ extern int fixup_aufs_vma_fd(struct vma_area *vma, int vm_file_fd); extern void free_aufs_branches(void); #endif /* __CR_SYSFS_PARSE_H__ */ - diff --git a/criu/include/timerfd.h b/criu/include/timerfd.h index 2e42a74fa..866cb13c7 100644 --- a/criu/include/timerfd.h +++ b/criu/include/timerfd.h @@ -11,12 +11,12 @@ struct pstree_item; struct restore_timerfd { - int id; - int fd; - int clockid; - int settime_flags; - unsigned long ticks; - struct itimerspec val; + int id; + int fd; + int clockid; + int settime_flags; + unsigned long ticks; + struct itimerspec val; }; extern const struct fdtype_ops timerfd_dump_ops; @@ -29,18 +29,16 @@ extern int check_timerfd(void); extern int is_timerfd_link(char *link); #ifndef TFD_TIMER_ABSTIME -# define TFD_TIMER_ABSTIME (1 << 0) +#define TFD_TIMER_ABSTIME (1 << 0) #endif #ifndef TFD_IOC_SET_TICKS -# define TFD_IOC_SET_TICKS _IOW('T', 0, u64) +#define TFD_IOC_SET_TICKS _IOW('T', 0, u64) #endif static inline int verify_timerfd(TimerfdEntry *tfe) { - if (tfe->clockid != CLOCK_REALTIME && - tfe->clockid != CLOCK_BOOTTIME && - tfe->clockid != CLOCK_MONOTONIC) { + if (tfe->clockid != CLOCK_REALTIME && tfe->clockid != CLOCK_BOOTTIME && tfe->clockid != CLOCK_MONOTONIC) { pr_err("Unknown clock type %d for %#x\n", tfe->clockid, tfe->id); return -1; } @@ -48,5 +46,4 @@ static inline int verify_timerfd(TimerfdEntry *tfe) return 0; } - #endif /* __CR_TIMERFD_H__ */ diff --git a/criu/include/tls.h b/criu/include/tls.h index b48e4b480..26f9976fd 100644 --- a/criu/include/tls.h +++ b/criu/include/tls.h @@ -1,7 +1,7 @@ #ifndef __CR_TLS_H__ #define __CR_TLS_H__ -# ifdef CONFIG_GNUTLS +#ifdef CONFIG_GNUTLS int tls_x509_init(int sockfd, bool is_server); void tls_terminate_session(void); @@ -12,13 +12,13 @@ ssize_t tls_recv(void *buf, size_t len, int flags); int tls_send_data_from_fd(int fd, unsigned long len); int tls_recv_data_to_fd(int fd, unsigned long len); -# else /* CONFIG_GNUTLS */ +#else /* CONFIG_GNUTLS */ #define tls_x509_init(sockfd, is_server) (0) -#define tls_send(buf, len, flags) (-1) -#define tls_recv(buf, len, flags) (-1) -#define tls_send_data_from_fd(fd, len) (-1) -#define tls_recv_data_to_fd(fd, len) (-1) +#define tls_send(buf, len, flags) (-1) +#define tls_recv(buf, len, flags) (-1) +#define tls_send_data_from_fd(fd, len) (-1) +#define tls_recv_data_to_fd(fd, len) (-1) #define tls_terminate_session() #endif /* CONFIG_HAS_GNUTLS */ diff --git a/criu/include/tty.h b/criu/include/tty.h index 8419593e5..3f9c53116 100644 --- a/criu/include/tty.h +++ b/criu/include/tty.h @@ -7,11 +7,11 @@ #include "files.h" /* Kernel's limit */ -#define TERMIOS_NCC 19 +#define TERMIOS_NCC 19 /* Popular serial console's majors, which not defined in */ -#define USB_SERIAL_MAJOR 188 -#define LOW_DENSE_SERIAL_MAJOR 204 +#define USB_SERIAL_MAJOR 188 +#define LOW_DENSE_SERIAL_MAJOR 204 extern const struct fdtype_ops tty_dump_ops; @@ -36,6 +36,6 @@ extern int tty_init_restore(void); extern int devpts_check_bindmount(struct mount_info *m); -#define OPT_SHELL_JOB "shell-job" +#define OPT_SHELL_JOB "shell-job" #endif /* __CR_TTY_H__ */ diff --git a/criu/include/tun.h b/criu/include/tun.h index b82c445a7..200ead22b 100644 --- a/criu/include/tun.h +++ b/criu/include/tun.h @@ -2,7 +2,7 @@ #define __CR_TUN_H__ #ifndef TUN_MINOR -#define TUN_MINOR 200 +#define TUN_MINOR 200 #endif extern struct ns_id *ns; diff --git a/criu/include/unix_diag.h b/criu/include/unix_diag.h index d88d52fd3..cf612b248 100644 --- a/criu/include/unix_diag.h +++ b/criu/include/unix_diag.h @@ -2,30 +2,30 @@ #define __CR_UNIX_DIAG_H__ struct unix_diag_req { - u8 sdiag_family; - u8 sdiag_protocol; - u16 pad; - u32 udiag_states; - u32 udiag_ino; - u32 udiag_show; - u32 udiag_cookie[2]; + u8 sdiag_family; + u8 sdiag_protocol; + u16 pad; + u32 udiag_states; + u32 udiag_ino; + u32 udiag_show; + u32 udiag_cookie[2]; }; -#define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ -#define UDIAG_SHOW_VFS 0x00000002 /* show VFS inode info */ -#define UDIAG_SHOW_PEER 0x00000004 /* show peer socket info */ -#define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ -#define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ -#define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ +#define UDIAG_SHOW_NAME 0x00000001 /* show name (not path) */ +#define UDIAG_SHOW_VFS 0x00000002 /* show VFS inode info */ +#define UDIAG_SHOW_PEER 0x00000004 /* show peer socket info */ +#define UDIAG_SHOW_ICONS 0x00000008 /* show pending connections */ +#define UDIAG_SHOW_RQLEN 0x00000010 /* show skb receive queue len */ +#define UDIAG_SHOW_MEMINFO 0x00000020 /* show memory info of a socket */ struct unix_diag_msg { - u8 udiag_family; - u8 udiag_type; - u8 udiag_state; - u8 pad; + u8 udiag_family; + u8 udiag_type; + u8 udiag_state; + u8 pad; - u32 udiag_ino; - u32 udiag_cookie[2]; + u32 udiag_ino; + u32 udiag_cookie[2]; }; enum { @@ -53,13 +53,13 @@ enum { }; struct unix_diag_vfs { - u32 udiag_vfs_ino; - u32 udiag_vfs_dev; + u32 udiag_vfs_ino; + u32 udiag_vfs_dev; }; struct unix_diag_rqlen { - u32 udiag_rqueue; - u32 udiag_wqueue; + u32 udiag_rqueue; + u32 udiag_wqueue; }; #endif /* __CR_UNIX_DIAG_H__ */ diff --git a/criu/include/util-pie.h b/criu/include/util-pie.h index a8137f441..4c622a440 100644 --- a/criu/include/util-pie.h +++ b/criu/include/util-pie.h @@ -5,12 +5,11 @@ #include #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 #ifndef SO_PEEK_OFF -#define SO_PEEK_OFF 42 +#define SO_PEEK_OFF 42 #endif #include "common/scm.h" diff --git a/criu/include/util-vdso.h b/criu/include/util-vdso.h index 046cd96d7..c4386cf8e 100644 --- a/criu/include/util-vdso.h +++ b/criu/include/util-vdso.h @@ -23,22 +23,22 @@ #include "asm/vdso.h" struct vdso_symbol { - char name[32]; - unsigned long offset; + char name[32]; + unsigned long offset; }; struct vdso_symtable { - unsigned long vdso_size; - unsigned long vvar_size; - struct vdso_symbol symbols[VDSO_SYMBOL_MAX]; - bool vdso_before_vvar; /* order of vdso/vvar pair */ + unsigned long vdso_size; + unsigned long vvar_size; + struct vdso_symbol symbols[VDSO_SYMBOL_MAX]; + bool vdso_before_vvar; /* order of vdso/vvar pair */ }; struct vdso_maps { - unsigned long vdso_start; - unsigned long vvar_start; - struct vdso_symtable sym; - bool compatible; + unsigned long vdso_start; + unsigned long vvar_start; + struct vdso_symtable sym; + bool compatible; }; static inline bool vdso_is_present(struct vdso_maps *m) @@ -46,56 +46,57 @@ static inline bool vdso_is_present(struct vdso_maps *m) return m->vdso_start != VDSO_BAD_ADDR; } -#define VDSO_SYMBOL_INIT { .offset = VDSO_BAD_ADDR, } +#define VDSO_SYMBOL_INIT \ + { \ + .offset = VDSO_BAD_ADDR, \ + } -#define VDSO_SYMTABLE_INIT \ - { \ +#define VDSO_SYMTABLE_INIT \ + { \ .vdso_size = VDSO_BAD_SIZE, \ .vvar_size = VVAR_BAD_SIZE, \ .symbols = { \ [0 ... VDSO_SYMBOL_MAX - 1] = \ (struct vdso_symbol)VDSO_SYMBOL_INIT, \ }, \ - .vdso_before_vvar = false, \ + .vdso_before_vvar = false, \ } -#define VDSO_MAPS_INIT \ - { \ - .vdso_start = VDSO_BAD_ADDR, \ - .vvar_start = VVAR_BAD_ADDR, \ - .sym = VDSO_SYMTABLE_INIT, \ +#define VDSO_MAPS_INIT \ + { \ + .vdso_start = VDSO_BAD_ADDR, .vvar_start = VVAR_BAD_ADDR, .sym = VDSO_SYMTABLE_INIT, \ } #ifdef CONFIG_VDSO_32 -#define Ehdr_t Elf32_Ehdr -#define Sym_t Elf32_Sym -#define Phdr_t Elf32_Phdr -#define Word_t Elf32_Word -#define Dyn_t Elf32_Dyn +#define Ehdr_t Elf32_Ehdr +#define Sym_t Elf32_Sym +#define Phdr_t Elf32_Phdr +#define Word_t Elf32_Word +#define Dyn_t Elf32_Dyn #ifndef ELF_ST_TYPE -#define ELF_ST_TYPE ELF32_ST_TYPE +#define ELF_ST_TYPE ELF32_ST_TYPE #endif #ifndef ELF_ST_BIND -#define ELF_ST_BIND ELF32_ST_BIND +#define ELF_ST_BIND ELF32_ST_BIND #endif -# define vdso_fill_symtable vdso_fill_symtable_compat +#define vdso_fill_symtable vdso_fill_symtable_compat #else /* CONFIG_VDSO_32 */ -#define Ehdr_t Elf64_Ehdr -#define Sym_t Elf64_Sym -#define Phdr_t Elf64_Phdr -#define Word_t Elf64_Word -#define Dyn_t Elf64_Dyn +#define Ehdr_t Elf64_Ehdr +#define Sym_t Elf64_Sym +#define Phdr_t Elf64_Phdr +#define Word_t Elf64_Word +#define Dyn_t Elf64_Dyn #ifndef ELF_ST_TYPE -#define ELF_ST_TYPE ELF64_ST_TYPE +#define ELF_ST_TYPE ELF64_ST_TYPE #endif #ifndef ELF_ST_BIND -#define ELF_ST_BIND ELF64_ST_BIND +#define ELF_ST_BIND ELF64_ST_BIND #endif #endif /* CONFIG_VDSO_32 */ diff --git a/criu/include/util.h b/criu/include/util.h index 3c6027c27..a8bae990e 100644 --- a/criu/include/util.h +++ b/criu/include/util.h @@ -21,18 +21,18 @@ #include "log.h" #include "common/err.h" -#define PREF_SHIFT_OP(pref, op, size) ((size) op (pref ##BYTES_SHIFT)) -#define KBYTES_SHIFT 10 -#define MBYTES_SHIFT 20 -#define GBYTES_SHIFT 30 +#define PREF_SHIFT_OP(pref, op, size) ((size)op(pref##BYTES_SHIFT)) +#define KBYTES_SHIFT 10 +#define MBYTES_SHIFT 20 +#define GBYTES_SHIFT 30 -#define KBYTES(size) PREF_SHIFT_OP(K, >>, size) -#define MBYTES(size) PREF_SHIFT_OP(M, >>, size) -#define GBYTES(size) PREF_SHIFT_OP(G, >>, size) +#define KBYTES(size) PREF_SHIFT_OP(K, >>, size) +#define MBYTES(size) PREF_SHIFT_OP(M, >>, size) +#define GBYTES(size) PREF_SHIFT_OP(G, >>, size) -#define KILO(size) PREF_SHIFT_OP(K, <<, size) -#define MEGA(size) PREF_SHIFT_OP(M, <<, size) -#define GIGA(size) PREF_SHIFT_OP(G, <<, size) +#define KILO(size) PREF_SHIFT_OP(K, <<, size) +#define MEGA(size) PREF_SHIFT_OP(M, <<, size) +#define GIGA(size) PREF_SHIFT_OP(G, <<, size) struct vma_area; struct list_head; @@ -41,30 +41,30 @@ extern int service_fd_rlim_cur; extern void pr_vma(const struct vma_area *vma_area); -#define pr_info_vma(vma_area) pr_vma(vma_area) +#define pr_info_vma(vma_area) pr_vma(vma_area) -#define pr_vma_list(head) \ - do { \ - struct vma_area *vma; \ - list_for_each_entry(vma, head, list) \ - pr_vma(vma); \ +#define pr_vma_list(head) \ + do { \ + struct vma_area *vma; \ + list_for_each_entry(vma, head, list) \ + pr_vma(vma); \ } while (0) -#define pr_info_vma_list(head) pr_vma_list(head) +#define pr_info_vma_list(head) pr_vma_list(head) extern int move_fd_from(int *img_fd, int want_fd); extern int close_safe(int *fd); extern int reopen_fd_as_safe(char *file, int line, int new_fd, int old_fd, bool allow_reuse_fd); -#define reopen_fd_as(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, false) -#define reopen_fd_as_nocheck(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, true) +#define reopen_fd_as(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, false) +#define reopen_fd_as_nocheck(new_fd, old_fd) reopen_fd_as_safe(__FILE__, __LINE__, new_fd, old_fd, true) extern void close_proc(void); extern int open_pid_proc(pid_t pid); extern int close_pid_proc(void); extern int set_proc_fd(int fd); -extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, - void *child_tid, unsigned long newtls); +extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, + unsigned long newtls); /* * Values for pid argument of the proc opening routines below. @@ -73,72 +73,66 @@ extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *par * NONE is internal, don't use it ;) */ -#define PROC_SELF 0 -#define PROC_GEN -1 -#define PROC_NONE -2 +#define PROC_SELF 0 +#define PROC_GEN -1 +#define PROC_NONE -2 -extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 3, 4))); +extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...) __attribute__((__format__(__printf__, 3, 4))); -#define __open_proc(pid, ier, flags, fmt, ...) \ - ({ \ - int __fd = do_open_proc(pid, flags, \ - fmt, ##__VA_ARGS__); \ - if (__fd < 0 && (errno != (ier))) \ - pr_perror("Can't open %d/" fmt " on procfs", \ - pid, ##__VA_ARGS__); \ - \ - __fd; \ +#define __open_proc(pid, ier, flags, fmt, ...) \ + ({ \ + int __fd = do_open_proc(pid, flags, fmt, ##__VA_ARGS__); \ + if (__fd < 0 && (errno != (ier))) \ + pr_perror("Can't open %d/" fmt " on procfs", pid, ##__VA_ARGS__); \ + \ + __fd; \ }) /* int open_proc(pid_t pid, const char *fmt, ...); */ -#define open_proc(pid, fmt, ...) \ - __open_proc(pid, 0, O_RDONLY, fmt, ##__VA_ARGS__) +#define open_proc(pid, fmt, ...) __open_proc(pid, 0, O_RDONLY, fmt, ##__VA_ARGS__) /* int open_proc_rw(pid_t pid, const char *fmt, ...); */ -#define open_proc_rw(pid, fmt, ...) \ - __open_proc(pid, 0, O_RDWR, fmt, ##__VA_ARGS__) +#define open_proc_rw(pid, fmt, ...) __open_proc(pid, 0, O_RDWR, fmt, ##__VA_ARGS__) -#define open_proc_path(pid, fmt, ...) \ - __open_proc(pid, 0, O_PATH, fmt, ##__VA_ARGS__) +#define open_proc_path(pid, fmt, ...) __open_proc(pid, 0, O_PATH, fmt, ##__VA_ARGS__) /* DIR *opendir_proc(pid_t pid, const char *fmt, ...); */ -#define opendir_proc(pid, fmt, ...) \ - ({ \ - int __fd = open_proc(pid, fmt, ##__VA_ARGS__); \ - DIR *__d = NULL; \ - \ - if (__fd >= 0) { \ - __d = fdopendir(__fd); \ - if (__d == NULL) \ - pr_perror("Can't fdopendir %d " \ - "(%d/" fmt " on procfs)", \ - __fd, pid, ##__VA_ARGS__); \ - } \ - __d; \ - }) +#define opendir_proc(pid, fmt, ...) \ + ({ \ + int __fd = open_proc(pid, fmt, ##__VA_ARGS__); \ + DIR *__d = NULL; \ + \ + if (__fd >= 0) { \ + __d = fdopendir(__fd); \ + if (__d == NULL) \ + pr_perror("Can't fdopendir %d " \ + "(%d/" fmt " on procfs)", \ + __fd, pid, ##__VA_ARGS__); \ + } \ + __d; \ + }) /* FILE *fopen_proc(pid_t pid, const char *fmt, ...); */ -#define fopen_proc(pid, fmt, ...) \ - ({ \ - int __fd = open_proc(pid, fmt, ##__VA_ARGS__); \ - FILE *__f = NULL; \ - \ - if (__fd >= 0) { \ - __f = fdopen(__fd, "r"); \ - if (__f == NULL) \ - pr_perror("Can't fdopen %d " \ - "(%d/" fmt " on procfs)", \ - __fd, pid, ##__VA_ARGS__); \ - } \ - __f; \ - }) +#define fopen_proc(pid, fmt, ...) \ + ({ \ + int __fd = open_proc(pid, fmt, ##__VA_ARGS__); \ + FILE *__f = NULL; \ + \ + if (__fd >= 0) { \ + __f = fdopen(__fd, "r"); \ + if (__f == NULL) \ + pr_perror("Can't fdopen %d " \ + "(%d/" fmt " on procfs)", \ + __fd, pid, ##__VA_ARGS__); \ + } \ + __f; \ + }) -#define DEVZERO (makedev(1, 5)) +#define DEVZERO (makedev(1, 5)) -#define KDEV_MINORBITS 20 -#define KDEV_MINORMASK ((1UL << KDEV_MINORBITS) - 1) -#define MKKDEV(ma, mi) (((ma) << KDEV_MINORBITS) | (mi)) +#define KDEV_MINORBITS 20 +#define KDEV_MINORMASK ((1UL << KDEV_MINORBITS) - 1) +#define MKKDEV(ma, mi) (((ma) << KDEV_MINORBITS) | (mi)) static inline u32 kdev_major(u32 kdev) { @@ -166,16 +160,12 @@ static inline dev_t kdev_to_odev(u32 kdev) extern int copy_file(int fd_in, int fd_out, size_t bytes); extern int is_anon_link_type(char *link, char *type); -#define is_hex_digit(c) \ - (((c) >= '0' && (c) <= '9') || \ - ((c) >= 'a' && (c) <= 'f') || \ - ((c) >= 'A' && (c) <= 'F')) +#define is_hex_digit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) -#define CRS_CAN_FAIL 0x1 /* cmd can validly exit with non zero code */ +#define CRS_CAN_FAIL 0x1 /* cmd can validly exit with non zero code */ extern int cr_system(int in, int out, int err, char *cmd, char *const argv[], unsigned flags); -extern int cr_system_userns(int in, int out, int err, char *cmd, - char *const argv[], unsigned flags, int userns_pid); +extern int cr_system_userns(int in, int out, int err, char *cmd, char *const argv[], unsigned flags, int userns_pid); extern int cr_daemon(int nochdir, int noclose, int close_fd); extern int status_ready(void); extern int is_root_user(void); @@ -193,12 +183,12 @@ extern int is_empty_dir(int dirfd); * Size of buffer to carry the worst case or /proc/self/fd/N * path. Since fd is an integer, we can easily estimate one :) */ -#define PSFDS (sizeof("/proc/self/fd/2147483647")) +#define PSFDS (sizeof("/proc/self/fd/2147483647")) extern int read_fd_link(int lfd, char *buf, size_t size); -#define USEC_PER_SEC 1000000L -#define NSEC_PER_SEC 1000000000L +#define USEC_PER_SEC 1000000L +#define NSEC_PER_SEC 1000000000L int vaddr_to_pfn(int fd, unsigned long vaddr, u64 *pfn); @@ -211,7 +201,7 @@ static inline bool strstartswith2(const char *str, const char *sub, char *end) while (1) { if (*sub == '\0') /* end of sub -- match */ { if (end) { - if (*(sub-1) == '/') /* "/", "./" or "path/" */ + if (*(sub - 1) == '/') /* "/", "./" or "path/" */ *end = '/'; else *end = *str; @@ -248,8 +238,7 @@ static inline bool strstartswith(const char *str, const char *sub) static inline bool issubpath(const char *path, const char *sub_path) { char end; - return strstartswith2(path, sub_path, &end) && - (end == '/' || end == '\0'); + return strstartswith2(path, sub_path, &end) && (end == '/' || end == '\0'); } int strip_deleted(char *path, int len); @@ -275,7 +264,7 @@ int make_yard(char *path); static inline int sk_wait_data(int sk) { - struct pollfd pfd = {sk, POLLIN, 0}; + struct pollfd pfd = { sk, POLLIN, 0 }; return poll(&pfd, 1, -1); } @@ -288,37 +277,37 @@ const char *ns_to_string(unsigned int ns); int xatol(const char *string, long *number); int xatoi(const char *string, int *number); -char *xstrcat(char *str, const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 2, 3))); -char *xsprintf(const char *fmt, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); +char *xstrcat(char *str, const char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); +char *xsprintf(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); int setup_tcp_server(char *type, char *addr, unsigned short *port); int run_tcp_server(bool daemon_mode, int *ask, int cfd, int sk); int setup_tcp_client(char *hostname); -#define LAST_PID_PATH "sys/kernel/ns_last_pid" -#define PID_MAX_PATH "sys/kernel/pid_max" +#define LAST_PID_PATH "sys/kernel/ns_last_pid" +#define PID_MAX_PATH "sys/kernel/pid_max" -#define block_sigmask(saved_mask, sig_mask) ({ \ - sigset_t ___blocked_mask; \ - int ___ret = 0; \ - sigemptyset(&___blocked_mask); \ - sigaddset(&___blocked_mask, sig_mask); \ - if (sigprocmask(SIG_BLOCK, &___blocked_mask, saved_mask) == -1) { \ - pr_perror("Can not set mask of blocked signals"); \ - ___ret = -1; \ - } \ - ___ret; \ +#define block_sigmask(saved_mask, sig_mask) \ + ({ \ + sigset_t ___blocked_mask; \ + int ___ret = 0; \ + sigemptyset(&___blocked_mask); \ + sigaddset(&___blocked_mask, sig_mask); \ + if (sigprocmask(SIG_BLOCK, &___blocked_mask, saved_mask) == -1) { \ + pr_perror("Can not set mask of blocked signals"); \ + ___ret = -1; \ + } \ + ___ret; \ }) -#define restore_sigmask(saved_mask) ({ \ - int ___ret = 0; \ - if (sigprocmask(SIG_SETMASK, saved_mask, NULL) == -1) { \ - pr_perror("Can not unset mask of blocked signals"); \ - ___ret = -1; \ - } \ - ___ret; \ +#define restore_sigmask(saved_mask) \ + ({ \ + int ___ret = 0; \ + if (sigprocmask(SIG_SETMASK, saved_mask, NULL) == -1) { \ + pr_perror("Can not unset mask of blocked signals"); \ + ___ret = -1; \ + } \ + ___ret; \ }) /* @@ -357,28 +346,32 @@ extern int call_in_child_process(int (*fn)(void *), void *arg); #ifdef __GLIBC__ extern void print_stack_trace(pid_t pid); #else -static inline void print_stack_trace(pid_t pid) {} +static inline void print_stack_trace(pid_t pid) +{ +} #endif -#define block_sigmask(saved_mask, sig_mask) ({ \ - sigset_t ___blocked_mask; \ - int ___ret = 0; \ - sigemptyset(&___blocked_mask); \ - sigaddset(&___blocked_mask, sig_mask); \ - if (sigprocmask(SIG_BLOCK, &___blocked_mask, saved_mask) == -1) { \ - pr_perror("Can not set mask of blocked signals"); \ - ___ret = -1; \ - } \ - ___ret; \ +#define block_sigmask(saved_mask, sig_mask) \ + ({ \ + sigset_t ___blocked_mask; \ + int ___ret = 0; \ + sigemptyset(&___blocked_mask); \ + sigaddset(&___blocked_mask, sig_mask); \ + if (sigprocmask(SIG_BLOCK, &___blocked_mask, saved_mask) == -1) { \ + pr_perror("Can not set mask of blocked signals"); \ + ___ret = -1; \ + } \ + ___ret; \ }) -#define restore_sigmask(saved_mask) ({ \ - int ___ret = 0; \ - if (sigprocmask(SIG_SETMASK, saved_mask, NULL) == -1) { \ - pr_perror("Can not unset mask of blocked signals"); \ - ___ret = -1; \ - } \ - ___ret; \ +#define restore_sigmask(saved_mask) \ + ({ \ + int ___ret = 0; \ + if (sigprocmask(SIG_SETMASK, saved_mask, NULL) == -1) { \ + pr_perror("Can not unset mask of blocked signals"); \ + ___ret = -1; \ + } \ + ___ret; \ }) extern int mount_detached_fs(const char *fsname); @@ -388,11 +381,11 @@ extern char *get_legacy_iptables_bin(bool ipv6); extern ssize_t read_all(int fd, void *buf, size_t size); extern ssize_t write_all(int fd, const void *buf, size_t size); -#define cleanup_free __attribute__ ((cleanup (cleanup_freep))) -static inline void cleanup_freep (void *p) +#define cleanup_free __attribute__((cleanup(cleanup_freep))) +static inline void cleanup_freep(void *p) { - void **pp = (void **) p; - free (*pp); + void **pp = (void **)p; + free(*pp); } #endif /* __CR_UTIL_H__ */ diff --git a/criu/include/vdso.h b/criu/include/vdso.h index fd30772b4..83a04a39e 100644 --- a/criu/include/vdso.h +++ b/criu/include/vdso.h @@ -15,12 +15,10 @@ extern int vdso_init_restore(void); extern int kerndat_vdso_fill_symtable(void); extern int kerndat_vdso_preserves_hint(void); -extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid, - struct vm_area_list *vma_area_list); +extern int parasite_fixup_vdso(struct parasite_ctl *ctl, pid_t pid, struct vm_area_list *vma_area_list); #ifdef CONFIG_COMPAT -extern void compat_vdso_helper(struct vdso_maps *native, int pipe_fd, - int err_fd, void *vdso_buf, size_t buf_size); +extern void compat_vdso_helper(struct vdso_maps *native, int pipe_fd, int err_fd, void *vdso_buf, size_t buf_size); #endif #endif /* __CR_VDSO_H__ */ diff --git a/criu/include/vma.h b/criu/include/vma.h index 5e3f3527b..ed9f31ef6 100644 --- a/criu/include/vma.h +++ b/criu/include/vma.h @@ -10,15 +10,15 @@ #include struct vm_area_list { - struct list_head h; /* list of VMAs */ - unsigned nr; /* nr of all VMAs in the list */ - unsigned int nr_aios; /* nr of AIOs VMAs in the list */ + struct list_head h; /* list of VMAs */ + unsigned nr; /* nr of all VMAs in the list */ + unsigned int nr_aios; /* nr of AIOs VMAs in the list */ union { - unsigned long nr_priv_pages; /* dmp: nr of pages in private VMAs */ - unsigned long rst_priv_size; /* rst: size of private VMAs */ + unsigned long nr_priv_pages; /* dmp: nr of pages in private VMAs */ + unsigned long rst_priv_size; /* rst: size of private VMAs */ }; - unsigned long nr_priv_pages_longest; /* nr of pages in longest private VMA */ - unsigned long nr_shared_pages_longest;/* nr of pages in longest shared VMA */ + unsigned long nr_priv_pages_longest; /* nr of pages in longest private VMA */ + unsigned long nr_shared_pages_longest; /* nr of pages in longest shared VMA */ }; static inline void vm_area_list_init(struct vm_area_list *vml) @@ -30,32 +30,32 @@ static inline void vm_area_list_init(struct vm_area_list *vml) struct file_desc; struct vma_area { - struct list_head list; - VmaEntry *e; + struct list_head list; + VmaEntry *e; union { struct /* for dump */ { - int vm_socket_id; + int vm_socket_id; - char *aufs_rpath; /* path from aufs root */ - char *aufs_fpath; /* full path from global root */ + char *aufs_rpath; /* path from aufs root */ + char *aufs_fpath; /* full path from global root */ /* * When several subsequent vmas have the same * dev:ino pair all 'tail' ones set this to true * and the vmst points to the head's stat buf. */ - bool file_borrowed; - struct stat *vmst; - int mnt_id; + bool file_borrowed; + struct stat *vmst; + int mnt_id; }; struct /* for restore */ { int (*vm_open)(int pid, struct vma_area *vma); struct file_desc *vmfd; - struct vma_area *pvma; /* parent for inherited VMAs */ - unsigned long *page_bitmap; /* existent pages */ - unsigned long premmaped_addr; /* restore only */ + struct vma_area *pvma; /* parent for inherited VMAs */ + unsigned long *page_bitmap; /* existent pages */ + unsigned long premmaped_addr; /* restore only */ /* * Some notes about pvma, page_bitmap and premmaped_addr bits @@ -72,22 +72,21 @@ struct vma_area { }; }; -#define VMA_COW_ROOT ((struct vma_area *)1) +#define VMA_COW_ROOT ((struct vma_area *)1) typedef int (*dump_filemap_t)(struct vma_area *vma_area, int fd); extern struct vma_area *alloc_vma_area(void); -extern int collect_mappings(pid_t pid, - struct vm_area_list *vma_area_list, dump_filemap_t cb); +extern int collect_mappings(pid_t pid, struct vm_area_list *vma_area_list, dump_filemap_t cb); extern void free_mappings(struct vm_area_list *vma_area_list); extern int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, dump_filemap_t cb); extern int parse_self_maps_lite(struct vm_area_list *vms); -#define vma_area_is(vma_area, s) vma_entry_is((vma_area)->e, s) -#define vma_area_len(vma_area) vma_entry_len((vma_area)->e) -#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s)) -#define vma_entry_len(vma) ((vma)->end - (vma)->start) +#define vma_area_is(vma_area, s) vma_entry_is((vma_area)->e, s) +#define vma_area_len(vma_area) vma_entry_len((vma_area)->e) +#define vma_entry_is(vma, s) (((vma)->status & (s)) == (s)) +#define vma_entry_len(vma) ((vma)->end - (vma)->start) /* * vma_premmaped_start() can be used only in restorer. @@ -95,26 +94,22 @@ extern int parse_self_maps_lite(struct vm_area_list *vms); * This hack is required, because vma_area isn't transferred in restorer and * shmid is used to determine which vma-s are cowed. */ -#define vma_premmaped_start(vma) ((vma)->shmid) +#define vma_premmaped_start(vma) ((vma)->shmid) static inline int in_vma_area(struct vma_area *vma, unsigned long addr) { - return addr >= (unsigned long)vma->e->start && - addr < (unsigned long)vma->e->end; + return addr >= (unsigned long)vma->e->start && addr < (unsigned long)vma->e->end; } -static inline bool vma_entry_is_private(VmaEntry *entry, - unsigned long task_size) +static inline bool vma_entry_is_private(VmaEntry *entry, unsigned long task_size) { - return (vma_entry_is(entry, VMA_AREA_REGULAR) && - (vma_entry_is(entry, VMA_ANON_PRIVATE) || - vma_entry_is(entry, VMA_FILE_PRIVATE)) && - (entry->end <= task_size)) || - vma_entry_is(entry, VMA_AREA_AIORING); + return (vma_entry_is(entry, VMA_AREA_REGULAR) && + (vma_entry_is(entry, VMA_ANON_PRIVATE) || vma_entry_is(entry, VMA_FILE_PRIVATE)) && + (entry->end <= task_size)) || + vma_entry_is(entry, VMA_AREA_AIORING); } -static inline bool vma_area_is_private(struct vma_area *vma, - unsigned long task_size) +static inline bool vma_area_is_private(struct vma_area *vma, unsigned long task_size) { return vma_entry_is_private(vma->e, task_size); } @@ -126,11 +121,8 @@ static inline struct vma_area *vma_next(struct vma_area *vma) static inline bool vma_entry_can_be_lazy(VmaEntry *e) { - return ((e->flags & MAP_ANONYMOUS) && - (e->flags & MAP_PRIVATE) && - !(e->flags & MAP_LOCKED) && - !(vma_entry_is(e, VMA_AREA_VDSO)) && - !(vma_entry_is(e, VMA_AREA_VSYSCALL))); + return ((e->flags & MAP_ANONYMOUS) && (e->flags & MAP_PRIVATE) && !(e->flags & MAP_LOCKED) && + !(vma_entry_is(e, VMA_AREA_VDSO)) && !(vma_entry_is(e, VMA_AREA_VSYSCALL))); } #endif /* __CR_VMA_H__ */ diff --git a/include/common/arch/aarch64/asm/atomic.h b/include/common/arch/aarch64/asm/atomic.h index 11785c3aa..8861d9aa4 100644 --- a/include/common/arch/aarch64/asm/atomic.h +++ b/include/common/arch/aarch64/asm/atomic.h @@ -5,11 +5,9 @@ typedef struct { int counter; } atomic_t; - /* Copied from the Linux header arch/arm/include/asm/barrier.h */ -#define smp_mb() asm volatile("dmb ish" : : : "memory") - +#define smp_mb() asm volatile("dmb ish" : : : "memory") /* Copied from the Linux kernel header arch/arm64/include/asm/atomic.h */ @@ -25,20 +23,18 @@ static inline void atomic_set(atomic_t *v, int i) #define atomic_get atomic_read - static inline int atomic_add_return(int i, atomic_t *v) { unsigned long tmp; int result; - asm volatile( -"1: ldxr %w0, %2\n" -" add %w0, %w0, %w3\n" -" stlxr %w1, %w0, %2\n" -" cbnz %w1, 1b" - : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) - : "Ir" (i) - : "cc", "memory"); + asm volatile("1: ldxr %w0, %2\n" + " add %w0, %w0, %w3\n" + " stlxr %w1, %w0, %2\n" + " cbnz %w1, 1b" + : "=&r"(result), "=&r"(tmp), "+Q"(v->counter) + : "Ir"(i) + : "cc", "memory"); smp_mb(); return result; @@ -49,30 +45,38 @@ static inline int atomic_sub_return(int i, atomic_t *v) unsigned long tmp; int result; - asm volatile( -"1: ldxr %w0, %2\n" -" sub %w0, %w0, %w3\n" -" stlxr %w1, %w0, %2\n" -" cbnz %w1, 1b" - : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) - : "Ir" (i) - : "cc", "memory"); + asm volatile("1: ldxr %w0, %2\n" + " sub %w0, %w0, %w3\n" + " stlxr %w1, %w0, %2\n" + " cbnz %w1, 1b" + : "=&r"(result), "=&r"(tmp), "+Q"(v->counter) + : "Ir"(i) + : "cc", "memory"); smp_mb(); return result; } -static inline int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } +static inline int atomic_inc(atomic_t *v) +{ + return atomic_add_return(1, v) - 1; +} -static inline int atomic_add(int val, atomic_t *v) { return atomic_add_return(val, v) - val; } +static inline int atomic_add(int val, atomic_t *v) +{ + return atomic_add_return(val, v) - val; +} -static inline int atomic_dec(atomic_t *v) { return atomic_sub_return(1, v) + 1; } +static inline int atomic_dec(atomic_t *v) +{ + return atomic_sub_return(1, v) + 1; +} /* true if the result is 0, or false for all other cases. */ #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) -#define atomic_dec_return(v) (atomic_sub_return(1, v)) +#define atomic_dec_return(v) (atomic_sub_return(1, v)) -#define atomic_inc_return(v) (atomic_add_return(1, v)) +#define atomic_inc_return(v) (atomic_add_return(1, v)) static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) { @@ -82,15 +86,15 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) smp_mb(); asm volatile("// atomic_cmpxchg\n" -"1: ldxr %w1, %2\n" -" cmp %w1, %w3\n" -" b.ne 2f\n" -" stxr %w0, %w4, %2\n" -" cbnz %w0, 1b\n" -"2:" - : "=&r" (tmp), "=&r" (oldval), "+Q" (ptr->counter) - : "Ir" (old), "r" (new) - : "cc"); + "1: ldxr %w1, %2\n" + " cmp %w1, %w3\n" + " b.ne 2f\n" + " stxr %w0, %w4, %2\n" + " cbnz %w0, 1b\n" + "2:" + : "=&r"(tmp), "=&r"(oldval), "+Q"(ptr->counter) + : "Ir"(old), "r"(new) + : "cc"); smp_mb(); return oldval; diff --git a/include/common/arch/aarch64/asm/linkage.h b/include/common/arch/aarch64/asm/linkage.h index 738064233..23862db17 100644 --- a/include/common/arch/aarch64/asm/linkage.h +++ b/include/common/arch/aarch64/asm/linkage.h @@ -3,22 +3,21 @@ #ifdef __ASSEMBLY__ -#define __ALIGN .align 4, 0x00 -#define __ALIGN_STR ".align 4, 0x00" +#define __ALIGN .align 4, 0x00 +#define __ALIGN_STR ".align 4, 0x00" -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - .type name, #function; \ - __ALIGN; \ +#define ENTRY(name) \ + .globl name; \ + .type name, #function; \ + __ALIGN; \ name: -#define END(sym) \ - .size sym, . - sym +#define END(sym) .size sym, .- sym -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLY__ */ #endif /* __CR_LINKAGE_H__ */ diff --git a/include/common/arch/aarch64/asm/page.h b/include/common/arch/aarch64/asm/page.h index bd8fe8f71..90670d126 100644 --- a/include/common/arch/aarch64/asm/page.h +++ b/include/common/arch/aarch64/asm/page.h @@ -29,11 +29,11 @@ static inline unsigned page_shift(void) * on aarch64, then we need refrain using PAGE_SIZE in criu and use * page_size() across sources (as it may differ on aarch64). */ -#define PAGE_SIZE page_size() -#define PAGE_MASK (~(PAGE_SIZE - 1)) -#define PAGE_SHIFT page_shift() +#define PAGE_SIZE page_size() +#define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_SHIFT page_shift() -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) #else /* CR_NOGLIBC */ diff --git a/include/common/arch/arm/asm/atomic.h b/include/common/arch/arm/asm/atomic.h index 7998a20f2..bcdd3be73 100644 --- a/include/common/arch/arm/asm/atomic.h +++ b/include/common/arch/arm/asm/atomic.h @@ -7,12 +7,11 @@ typedef struct { int counter; } atomic_t; - /* Copied from the Linux kernel header arch/arm/include/asm/atomic.h */ #if defined(CONFIG_ARMV7) -#define smp_mb() __asm__ __volatile__ ("dmb" : : : "memory") +#define smp_mb() __asm__ __volatile__("dmb" : : : "memory") static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) { @@ -24,14 +23,14 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) do { __asm__ __volatile__("@ atomic_cmpxchg\n" - "ldrex %1, [%3]\n" - "mov %0, #0\n" - "teq %1, %4\n" - "it eq\n" - "strexeq %0, %5, [%3]\n" - : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter) - : "r" (&ptr->counter), "Ir" (old), "r" (new) - : "cc"); + "ldrex %1, [%3]\n" + "mov %0, #0\n" + "teq %1, %4\n" + "it eq\n" + "strexeq %0, %5, [%3]\n" + : "=&r"(res), "=&r"(oldval), "+Qo"(ptr->counter) + : "r"(&ptr->counter), "Ir"(old), "r"(new) + : "cc"); } while (res); smp_mb(); @@ -43,7 +42,7 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new) /* SMP isn't supported for ARMv6 */ -#define smp_mb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory") +#define smp_mb() __asm__ __volatile__("mcr p15, 0, %0, c7, c10, 5" : : "r"(0) : "memory") static inline int atomic_cmpxchg(atomic_t *v, int old, int new) { @@ -82,14 +81,14 @@ static inline int atomic_add_return(int i, atomic_t *v) smp_mb(); __asm__ __volatile__("@ atomic_add_return\n" -"1: ldrex %0, [%3]\n" -" add %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b\n" - : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) - : "r" (&v->counter), "Ir" (i) - : "cc"); + "1: ldrex %0, [%3]\n" + " add %0, %0, %4\n" + " strex %1, %0, [%3]\n" + " teq %1, #0\n" + " bne 1b\n" + : "=&r"(result), "=&r"(tmp), "+Qo"(v->counter) + : "r"(&v->counter), "Ir"(i) + : "cc"); smp_mb(); @@ -104,30 +103,39 @@ static inline int atomic_sub_return(int i, atomic_t *v) smp_mb(); __asm__ __volatile__("@ atomic_sub_return\n" -"1: ldrex %0, [%3]\n" -" sub %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b\n" - : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter) - : "r" (&v->counter), "Ir" (i) - : "cc"); + "1: ldrex %0, [%3]\n" + " sub %0, %0, %4\n" + " strex %1, %0, [%3]\n" + " teq %1, #0\n" + " bne 1b\n" + : "=&r"(result), "=&r"(tmp), "+Qo"(v->counter) + : "r"(&v->counter), "Ir"(i) + : "cc"); smp_mb(); return result; } -static inline int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } +static inline int atomic_inc(atomic_t *v) +{ + return atomic_add_return(1, v) - 1; +} -static inline int atomic_add(int val, atomic_t *v) { return atomic_add_return(val, v) - val; } +static inline int atomic_add(int val, atomic_t *v) +{ + return atomic_add_return(val, v) - val; +} -static inline int atomic_dec(atomic_t *v) { return atomic_sub_return(1, v) + 1; } +static inline int atomic_dec(atomic_t *v) +{ + return atomic_sub_return(1, v) + 1; +} /* true if the result is 0, or false for all other cases. */ #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) -#define atomic_dec_return(v) (atomic_sub_return(1, v)) +#define atomic_dec_return(v) (atomic_sub_return(1, v)) -#define atomic_inc_return(v) (atomic_add_return(1, v)) +#define atomic_inc_return(v) (atomic_add_return(1, v)) #endif /* __CR_ATOMIC_H__ */ diff --git a/include/common/arch/arm/asm/linkage.h b/include/common/arch/arm/asm/linkage.h index a93898be5..de6b82a9b 100644 --- a/include/common/arch/arm/asm/linkage.h +++ b/include/common/arch/arm/asm/linkage.h @@ -3,26 +3,25 @@ #ifdef __ASSEMBLY__ -#define __ALIGN .align 4, 0x00 -#define __ALIGN_STR ".align 4, 0x00" +#define __ALIGN .align 4, 0x00 +#define __ALIGN_STR ".align 4, 0x00" -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - .type name, #function; \ - __ALIGN; \ +#define ENTRY(name) \ + .globl name; \ + .type name, #function; \ + __ALIGN; \ name: -#define END(sym) \ - .size sym, . - sym +#define END(sym) .size sym, .- sym -#define ALIAS(sym_new, sym_old) \ - .globl sym_new; \ +#define ALIAS(sym_new, sym_old) \ + .globl sym_new; \ .set sym_new, sym_old -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLY__ */ #endif /* __CR_LINKAGE_H__ */ diff --git a/include/common/arch/arm/asm/page.h b/include/common/arch/arm/asm/page.h index 134835556..d31e82c60 100644 --- a/include/common/arch/arm/asm/page.h +++ b/include/common/arch/arm/asm/page.h @@ -2,18 +2,18 @@ #define __CR_ASM_PAGE_H__ #ifndef PAGE_SHIFT -# define PAGE_SHIFT 12 +#define PAGE_SHIFT 12 #endif #ifndef PAGE_SIZE -# define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_SIZE (1UL << PAGE_SHIFT) #endif #ifndef PAGE_MASK -# define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_MASK (~(PAGE_SIZE - 1)) #endif -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) -#define page_size() PAGE_SIZE +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define page_size() PAGE_SIZE #endif /* __CR_ASM_PAGE_H__ */ diff --git a/include/common/arch/arm/asm/processor.h b/include/common/arch/arm/asm/processor.h index a390cfd32..9c5f102f4 100644 --- a/include/common/arch/arm/asm/processor.h +++ b/include/common/arch/arm/asm/processor.h @@ -3,26 +3,21 @@ /* Copied from linux kernel arch/arm/include/asm/unified.h */ -#define WASM(instr) #instr +#define WASM(instr) #instr /* Copied from linux kernel arch/arm/include/asm/processor.h */ -#define __ALT_SMP_ASM(smp, up) \ - "9998: " smp "\n" \ - " .pushsection \".alt.smp.init\", \"a\"\n" \ - " .long 9998b\n" \ - " " up "\n" \ +#define __ALT_SMP_ASM(smp, up) \ + "9998: " smp "\n" \ + " .pushsection \".alt.smp.init\", \"a\"\n" \ + " .long 9998b\n" \ + " " up "\n" \ " .popsection\n" static inline void prefetchw(const void *ptr) { __asm__ __volatile__( - ".arch_extension mp\n" - __ALT_SMP_ASM( - WASM(pldw) "\t%a0", - WASM(pld) "\t%a0" - ) - :: "p" (ptr)); + ".arch_extension mp\n" __ALT_SMP_ASM(WASM(pldw) "\t%a0", WASM(pld) "\t%a0")::"p"(ptr)); } #endif /* __CR_PROCESSOR_H__ */ diff --git a/include/common/arch/mips/asm/atomic.h b/include/common/arch/mips/asm/atomic.h old mode 100755 new mode 100644 index 600e3a70f..d51800055 --- a/include/common/arch/mips/asm/atomic.h +++ b/include/common/arch/mips/asm/atomic.h @@ -12,7 +12,7 @@ * * Atomically reads the value of @v. */ -#define atomic_read(v) (*(volatile int *)&(v)->counter) +#define atomic_read(v) (*(volatile int *)&(v)->counter) /* * atomic_set - set atomic variable @@ -21,7 +21,7 @@ * * Atomically sets the value of @v to @i. */ -#define atomic_set(v, i) ((v)->counter = (i)) +#define atomic_set(v, i) ((v)->counter = (i)) /* * atomic_add - add integer to atomic variable * @i: integer value to add @@ -30,20 +30,19 @@ * Atomically adds @i to @v. */ -static __inline__ void atomic_add(int i, atomic_t * v) +static __inline__ void atomic_add(int i, atomic_t *v) { - int temp; + int temp; - do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %0, %1 # atomic_add \n" - " addu %0, %2 \n" - " sc %0, %1 \n" - " .set mips0 \n" - : "=&r" (temp), "+m" (v->counter) - : "Ir" (i)); - } while (unlikely(!temp)); + do { + __asm__ __volatile__(" .set mips3 \n" + " ll %0, %1 # atomic_add \n" + " addu %0, %2 \n" + " sc %0, %1 \n" + " .set mips0 \n" + : "=&r"(temp), "+m"(v->counter) + : "Ir"(i)); + } while (unlikely(!temp)); } /* @@ -53,43 +52,40 @@ static __inline__ void atomic_add(int i, atomic_t * v) * * Atomically subtracts @i from @v. */ -static __inline__ void atomic_sub(int i, atomic_t * v) +static __inline__ void atomic_sub(int i, atomic_t *v) { - int temp; + int temp; - do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %0, %1 # atomic_sub \n" - " subu %0, %2 \n" - " sc %0, %1 \n" - " .set mips0 \n" - : "=&r" (temp), "+m" (v->counter) - : "Ir" (i)); - } while (unlikely(!temp)); + do { + __asm__ __volatile__(" .set mips3 \n" + " ll %0, %1 # atomic_sub \n" + " subu %0, %2 \n" + " sc %0, %1 \n" + " .set mips0 \n" + : "=&r"(temp), "+m"(v->counter) + : "Ir"(i)); + } while (unlikely(!temp)); } /* * Same as above, but return the result value */ -static __inline__ int atomic_add_return(int i, atomic_t * v) +static __inline__ int atomic_add_return(int i, atomic_t *v) { int result; smp_mb__before_llsc(); - int temp; do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %1, %2 # atomic_add_return \n" - " addu %0, %1, %3 \n" - " sc %0, %2 \n" - " .set mips0 \n" - : "=&r" (result), "=&r" (temp), "+m" (v->counter) - : "Ir" (i)); + __asm__ __volatile__(" .set mips3 \n" + " ll %1, %2 # atomic_add_return \n" + " addu %0, %1, %3 \n" + " sc %0, %2 \n" + " .set mips0 \n" + : "=&r"(result), "=&r"(temp), "+m"(v->counter) + : "Ir"(i)); } while (unlikely(!result)); result = temp + i; @@ -99,7 +95,7 @@ static __inline__ int atomic_add_return(int i, atomic_t * v) return result; } -static __inline__ int atomic_sub_return(int i, atomic_t * v) +static __inline__ int atomic_sub_return(int i, atomic_t *v) { int result; @@ -108,14 +104,13 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v) int temp; do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %1, %2 # atomic_sub_return \n" - " subu %0, %1, %3 \n" - " sc %0, %2 \n" - " .set mips0 \n" - : "=&r" (result), "=&r" (temp), "+m" (v->counter) - : "Ir" (i)); + __asm__ __volatile__(" .set mips3 \n" + " ll %1, %2 # atomic_sub_return \n" + " subu %0, %1, %3 \n" + " sc %0, %2 \n" + " .set mips0 \n" + : "=&r"(result), "=&r"(temp), "+m"(v->counter) + : "Ir"(i)); } while (unlikely(!result)); result = temp - i; @@ -126,8 +121,8 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v) } #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) -#define atomic_dec_return(v) atomic_sub_return(1, (v)) -#define atomic_inc_return(v) atomic_add_return(1, (v)) +#define atomic_dec_return(v) atomic_sub_return(1, (v)) +#define atomic_inc_return(v) atomic_add_return(1, (v)) /* * atomic_inc - increment atomic variable @@ -135,7 +130,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v) * * Atomically increments @v by 1. */ -#define atomic_inc( v) atomic_add(1, (v)) +#define atomic_inc(v) atomic_add(1, (v)) /* * atomic_dec - decrement and test diff --git a/include/common/arch/mips/asm/bitops.h b/include/common/arch/mips/asm/bitops.h index 874845e45..096ed4a23 100644 --- a/include/common/arch/mips/asm/bitops.h +++ b/include/common/arch/mips/asm/bitops.h @@ -13,24 +13,22 @@ * It also implies a memory barrier. */ -static inline int test_and_set_bit(unsigned long nr, - volatile unsigned long *addr) +static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *addr) { - unsigned long *m = ((unsigned long *) addr) + (nr >> 6); + unsigned long *m = ((unsigned long *)addr) + (nr >> 6); unsigned long temp = 0; unsigned long res; int bit = nr & 63UL; do { - __asm__ __volatile__( - " .set mips3 \n" - " lld %0, %1 # test_and_set_bit \n" - " or %2, %0, %3 \n" - " scd %2, %1 \n" - " .set mips0 \n" - : "=&r" (temp), "+m" (*m), "=&r" (res) - : "r" (1UL << bit) - : "memory"); + __asm__ __volatile__(" .set mips3 \n" + " lld %0, %1 # test_and_set_bit \n" + " or %2, %0, %3 \n" + " scd %2, %1 \n" + " .set mips0 \n" + : "=&r"(temp), "+m"(*m), "=&r"(res) + : "r"(1UL << bit) + : "memory"); } while (unlikely(!res)); res = temp & (1UL << bit); diff --git a/include/common/arch/mips/asm/bitsperlong.h b/include/common/arch/mips/asm/bitsperlong.h old mode 100755 new mode 100644 index 31aece3b6..d95727d19 --- a/include/common/arch/mips/asm/bitsperlong.h +++ b/include/common/arch/mips/asm/bitsperlong.h @@ -1,6 +1,6 @@ #ifndef __CR_BITSPERLONG_H__ #define __CR_BITSPERLONG_H__ -# define BITS_PER_LONG 64 +#define BITS_PER_LONG 64 #endif /* __CR_BITSPERLONG_H__ */ diff --git a/include/common/arch/mips/asm/cmpxchg.h b/include/common/arch/mips/asm/cmpxchg.h old mode 100755 new mode 100644 index bdc41390b..85cd482c3 --- a/include/common/arch/mips/asm/cmpxchg.h +++ b/include/common/arch/mips/asm/cmpxchg.h @@ -1,67 +1,65 @@ #ifndef __CR_CMPXCHG_H__ #define __CR_CMPXCHG_H__ -#define __cmpxchg_asm(ld, st, m, old, new) \ -({ \ - __typeof(*(m)) __ret; \ - \ - if (kernel_uses_llsc) { \ - __asm__ __volatile__( \ - " .set push \n" \ - " .set noat \n" \ - " .set mips3 \n" \ - "1: " ld " %0, %2 # __cmpxchg_asm \n" \ - " bne %0, %z3, 2f \n" \ - " .set mips0 \n" \ - " move $1, %z4 \n" \ - " .set mips3 \n" \ - " " st " $1, %1 \n" \ - " beqz $1, 1b \n" \ - " .set pop \n" \ - "2: \n" \ - : "=&r" (__ret), "=R" (*m) \ - : "R" (*m), "Jr" (old), "Jr" (new) \ - : "memory"); \ - } else { \ - } \ - \ - __ret; \ -}) +#define __cmpxchg_asm(ld, st, m, old, new) \ + ({ \ + __typeof(*(m)) __ret; \ + \ + if (kernel_uses_llsc) { \ + __asm__ __volatile__(" .set push \n" \ + " .set noat \n" \ + " .set mips3 \n" \ + "1: " ld " %0, %2 # __cmpxchg_asm \n" \ + " bne %0, %z3, 2f \n" \ + " .set mips0 \n" \ + " move $1, %z4 \n" \ + " .set mips3 \n" \ + " " st " $1, %1 \n" \ + " beqz $1, 1b \n" \ + " .set pop \n" \ + "2: \n" \ + : "=&r"(__ret), "=R"(*m) \ + : "R"(*m), "Jr"(old), "Jr"(new) \ + : "memory"); \ + } else { \ + } \ + \ + __ret; \ + }) /* * This function doesn't exist, so you'll get a linker error * if something tries to do an invalid cmpxchg(). */ extern void __cmpxchg_called_with_bad_pointer(void); -#define __cmpxchg(ptr, old, new, pre_barrier, post_barrier) \ -({ \ - __typeof__(ptr) __ptr = (ptr); \ - __typeof__(*(ptr)) __old = (old); \ - __typeof__(*(ptr)) __new = (new); \ - __typeof__(*(ptr)) __res = 0; \ - \ - pre_barrier; \ - \ - switch (sizeof(*(__ptr))) { \ - case 4: \ - __res = __cmpxchg_asm("ll", "sc", __ptr, __old, __new); \ - break; \ - case 8: \ - if (sizeof(long) == 8) { \ - __res = __cmpxchg_asm("lld", "scd", __ptr, \ - __old, __new); \ - break; \ - } \ - default: \ - __cmpxchg_called_with_bad_pointer(); \ - break; \ - } \ - \ - post_barrier; \ - \ - __res; \ -}) +#define __cmpxchg(ptr, old, new, pre_barrier, post_barrier) \ + ({ \ + __typeof__(ptr) __ptr = (ptr); \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ + __typeof__(*(ptr)) __res = 0; \ + \ + pre_barrier; \ + \ + switch (sizeof(*(__ptr))) { \ + case 4: \ + __res = __cmpxchg_asm("ll", "sc", __ptr, __old, __new); \ + break; \ + case 8: \ + if (sizeof(long) == 8) { \ + __res = __cmpxchg_asm("lld", "scd", __ptr, __old, __new); \ + break; \ + } \ + default: \ + __cmpxchg_called_with_bad_pointer(); \ + break; \ + } \ + \ + post_barrier; \ + \ + __res; \ + }) -#define cmpxchg(ptr, old, new) __cmpxchg(ptr, old, new, smp_mb__before_llsc(), smp_llsc_mb()) +#define cmpxchg(ptr, old, new) __cmpxchg(ptr, old, new, smp_mb__before_llsc(), smp_llsc_mb()) #endif /* __CR_CMPXCHG_H__ */ diff --git a/include/common/arch/mips/asm/linkage.h b/include/common/arch/mips/asm/linkage.h index 87bfcffa8..4d5b184cc 100644 --- a/include/common/arch/mips/asm/linkage.h +++ b/include/common/arch/mips/asm/linkage.h @@ -1,58 +1,56 @@ #ifndef __CR_LINKAGE_H__ #define __CR_LINKAGE_H__ -#define zero $0 /* wired zero */ -#define AT $1 /* assembler temp - uppercase because of ".set at" */ -#define v0 $2 -#define v1 $3 +#define zero $0 /* wired zero */ +#define AT $1 /* assembler temp - uppercase because of ".set at" */ +#define v0 $2 +#define v1 $3 -#define a0 $4 -#define a1 $5 -#define a2 $6 -#define a3 $7 -#define a4 $8 -#define a5 $9 -#define a6 $10 -#define a7 $11 -#define t0 $12 -#define t1 $13 -#define t2 $14 -#define t3 $15 +#define a0 $4 +#define a1 $5 +#define a2 $6 +#define a3 $7 +#define a4 $8 +#define a5 $9 +#define a6 $10 +#define a7 $11 +#define t0 $12 +#define t1 $13 +#define t2 $14 +#define t3 $15 -#define s0 $16 /* callee saved */ -#define s1 $17 -#define s2 $18 -#define s3 $19 -#define s4 $20 -#define s5 $21 -#define s6 $22 -#define s7 $23 -#define t8 $24 /* caller saved */ -#define t9 $25 -#define jp $25 /* PIC jump register */ -#define k0 $26 /* kernel scratch */ -#define k1 $27 -#define gp $28 /* global pointer */ -#define sp $29 /* stack pointer */ -#define fp $30 /* frame pointer */ -#define s8 $30 /* same like fp! */ -#define ra $31 /* return address */ +#define s0 $16 /* callee saved */ +#define s1 $17 +#define s2 $18 +#define s3 $19 +#define s4 $20 +#define s5 $21 +#define s6 $22 +#define s7 $23 +#define t8 $24 /* caller saved */ +#define t9 $25 +#define jp $25 /* PIC jump register */ +#define k0 $26 /* kernel scratch */ +#define k1 $27 +#define gp $28 /* global pointer */ +#define sp $29 /* stack pointer */ +#define fp $30 /* frame pointer */ +#define s8 $30 /* same like fp! */ +#define ra $31 /* return address */ -#define __ALIGN .align 8 -#define __ALIGN_STR ".align 8" +#define __ALIGN .align 8 +#define __ALIGN_STR ".align 8" -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - __ALIGN; \ - .type name, @function; \ +#define ENTRY(name) \ + .globl name; \ + __ALIGN; \ + .type name, @function; \ name: -#define END(sym) \ - .size sym, . - sym - +#define END(sym) .size sym, .- sym #endif /* __CR_LINKAGE_H__ */ diff --git a/include/common/arch/mips/asm/page.h b/include/common/arch/mips/asm/page.h old mode 100755 new mode 100644 index bf27420f7..25bdbc141 --- a/include/common/arch/mips/asm/page.h +++ b/include/common/arch/mips/asm/page.h @@ -13,7 +13,7 @@ static unsigned __page_shift; static inline unsigned page_size(void) { if (!__page_size) - __page_size = sysconf(_SC_PAGESIZE); + __page_size = sysconf(_SC_PAGESIZE); return __page_size; } @@ -24,11 +24,11 @@ static inline unsigned page_shift(void) return __page_shift; } -#define PAGE_SIZE page_size() -#define PAGE_SHIFT page_shift() -#define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_SIZE page_size() +#define PAGE_SHIFT page_shift() +#define PAGE_MASK (~(PAGE_SIZE - 1)) -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) #else /* CR_NOGLIBC */ extern unsigned page_size(void); diff --git a/include/common/arch/mips/asm/utils.h b/include/common/arch/mips/asm/utils.h index 6415bf485..76c5f8654 100644 --- a/include/common/arch/mips/asm/utils.h +++ b/include/common/arch/mips/asm/utils.h @@ -1,24 +1,22 @@ #ifndef __UTILS_H__ #define __UTILS_H__ - -# define kernel_uses_llsc 1 +#define kernel_uses_llsc 1 typedef struct { int counter; -}atomic_t; - +} atomic_t; /* * FIXME: detect with compel_cpu_has_feature() if LL/SC implicitly * provide a memory barrier. */ -#define __WEAK_LLSC_MB " sync \n" +#define __WEAK_LLSC_MB " sync \n" -#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") +#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : : "memory") -#define smp_mb__before_llsc() smp_llsc_mb() -#define smp_mb__before_atomic() smp_mb__before_llsc() +#define smp_mb__before_llsc() smp_llsc_mb() +#define smp_mb__before_atomic() smp_mb__before_llsc() #define smp_mb__after_atomic() smp_llsc_mb() #endif /* __UTILS_H__ */ diff --git a/include/common/arch/ppc64/asm/atomic.h b/include/common/arch/ppc64/asm/atomic.h index 4c6477412..223dca195 100644 --- a/include/common/arch/ppc64/asm/atomic.h +++ b/include/common/arch/ppc64/asm/atomic.h @@ -13,10 +13,13 @@ typedef struct { #include "common/arch/ppc64/asm/cmpxchg.h" -#define PPC_ATOMIC_ENTRY_BARRIER "lwsync \n" -#define PPC_ATOMIC_EXIT_BARRIER "sync \n" +#define PPC_ATOMIC_ENTRY_BARRIER "lwsync \n" +#define PPC_ATOMIC_EXIT_BARRIER "sync \n" -#define ATOMIC_INIT(i) { (i) } +#define ATOMIC_INIT(i) \ + { \ + (i) \ + } static __inline__ int atomic_read(const atomic_t *v) { @@ -32,6 +35,7 @@ static __inline__ void atomic_set(atomic_t *v, int i) __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(v->counter) : "r"(i)); } +/* clang-format off */ #define ATOMIC_OP(op, asm_op) \ static __inline__ void atomic_##op(int a, atomic_t *v) \ { \ @@ -124,10 +128,11 @@ static __inline__ int atomic_sub_return(int a, atomic_t *v) return t; } +/* clang-format on */ /* true if the result is 0, or false for all other cases. */ #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) -#define atomic_dec_return(v) (atomic_sub_return(1, v)) +#define atomic_dec_return(v) (atomic_sub_return(1, v)) #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) diff --git a/include/common/arch/ppc64/asm/bitops.h b/include/common/arch/ppc64/asm/bitops.h index f9a327ccd..704668263 100644 --- a/include/common/arch/ppc64/asm/bitops.h +++ b/include/common/arch/ppc64/asm/bitops.h @@ -42,37 +42,36 @@ #include "common/asm/bitsperlong.h" -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] +#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)] #define __stringify_in_c(...) #__VA_ARGS__ #define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " " -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) /* PPC bit number conversion */ -#define PPC_BITLSHIFT(be) (BITS_PER_LONG - 1 - (be)) -#define PPC_BIT(bit) (1UL << PPC_BITLSHIFT(bit)) -#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) +#define PPC_BITLSHIFT(be) (BITS_PER_LONG - 1 - (be)) +#define PPC_BIT(bit) (1UL << PPC_BITLSHIFT(bit)) +#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs)) -#define PPC_INST_LDARX 0x7c0000a8 -#define ___PPC_RA(a) (((a) & 0x1f) << 16) -#define ___PPC_RB(b) (((b) & 0x1f) << 11) -#define ___PPC_RS(s) (((s) & 0x1f) << 21) -#define __PPC_EH(eh) (((eh) & 0x1) << 0) -#define ___PPC_RT(t) ___PPC_RS(t) +#define PPC_INST_LDARX 0x7c0000a8 +#define ___PPC_RA(a) (((a)&0x1f) << 16) +#define ___PPC_RB(b) (((b)&0x1f) << 11) +#define ___PPC_RS(s) (((s)&0x1f) << 21) +#define __PPC_EH(eh) (((eh)&0x1) << 0) +#define ___PPC_RT(t) ___PPC_RS(t) -#define PPC_LDARX(t, a, b, eh) stringify_in_c(.long PPC_INST_LDARX | \ - ___PPC_RT(t) | ___PPC_RA(a) | \ - ___PPC_RB(b) | __PPC_EH(eh)) -#define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh) +#define PPC_LDARX(t, a, b, eh) \ + stringify_in_c(.long PPC_INST_LDARX | ___PPC_RT(t) | ___PPC_RA(a) | ___PPC_RB(b) | __PPC_EH(eh)) +#define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh) +/* clang-format off */ /* Macro for generating the ***_bits() functions */ -#define DEFINE_BITOP(fn, op) \ +#define DEFINE_BITOP(fn, op) \ static __inline__ void fn(unsigned long mask, \ volatile unsigned long *_p) \ { \ @@ -87,6 +86,7 @@ static __inline__ void fn(unsigned long mask, \ : "r" (mask), "r" (p) \ : "cc", "memory"); \ } +/* clang-format on */ DEFINE_BITOP(set_bits, or) DEFINE_BITOP(clear_bits, andc) @@ -94,26 +94,27 @@ DEFINE_BITOP(change_bits, xor) static __inline__ void set_bit(int nr, volatile unsigned long *addr) { - set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); + set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); } static __inline__ void clear_bit(int nr, volatile unsigned long *addr) { - clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); + clear_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); } static __inline__ void change_bit(int nr, volatile unsigned long *addr) { - change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); + change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)); } static inline int test_bit(int nr, const volatile unsigned long *addr) { - return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); + return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1))); } /* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output * operands. */ +/* clang-format off */ #define DEFINE_TESTOP(fn, op, prefix, postfix, eh) \ static __inline__ unsigned long fn( \ unsigned long mask, \ @@ -133,11 +134,11 @@ static __inline__ unsigned long fn( \ : "cc", "memory"); \ return (old & mask); \ } +/* clang-format on */ DEFINE_TESTOP(test_and_set_bits, or, "\nLWSYNC\n", "\nsync\n", 0) -static __inline__ int test_and_set_bit(unsigned long nr, - volatile unsigned long *addr) +static __inline__ int test_and_set_bit(unsigned long nr, volatile unsigned long *addr) { return test_and_set_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0; } @@ -146,70 +147,63 @@ static __inline__ int test_and_set_bit(unsigned long nr, * Return the zero-based bit position (LE, not IBM bit numbering) of * the most significant 1-bit in a double word. */ -static __inline__ __attribute__((const)) -int __ilog2(unsigned long x) +static __inline__ __attribute__((const)) int __ilog2(unsigned long x) { - int lz; + int lz; - asm ("cntlzd %0,%1" : "=r" (lz) : "r" (x)); - return BITS_PER_LONG - 1 - lz; + asm("cntlzd %0,%1" : "=r"(lz) : "r"(x)); + return BITS_PER_LONG - 1 - lz; } - static __inline__ unsigned long __ffs(unsigned long x) { - return __ilog2(x & -x); + return __ilog2(x & -x); } - -#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) /* * Find the next set bit in a memory region. */ -static inline -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +static inline unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { - const unsigned long *p = addr + BITOP_WORD(offset); - unsigned long result = offset & ~(BITS_PER_LONG-1); - unsigned long tmp; + const unsigned long *p = addr + BITOP_WORD(offset); + unsigned long result = offset & ~(BITS_PER_LONG - 1); + unsigned long tmp; - if (offset >= size) - return size; - size -= result; - offset %= BITS_PER_LONG; - if (offset) { - tmp = *(p++); - tmp &= (~0UL << offset); - if (size < BITS_PER_LONG) - goto found_first; - if (tmp) - goto found_middle; - size -= BITS_PER_LONG; - result += BITS_PER_LONG; - } - while (size & ~(BITS_PER_LONG-1)) { - if ((tmp = *(p++))) - goto found_middle; - result += BITS_PER_LONG; - size -= BITS_PER_LONG; - } - if (!size) - return result; - tmp = *p; + if (offset >= size) + return size; + size -= result; + offset %= BITS_PER_LONG; + if (offset) { + tmp = *(p++); + tmp &= (~0UL << offset); + if (size < BITS_PER_LONG) + goto found_first; + if (tmp) + goto found_middle; + size -= BITS_PER_LONG; + result += BITS_PER_LONG; + } + while (size & ~(BITS_PER_LONG - 1)) { + if ((tmp = *(p++))) + goto found_middle; + result += BITS_PER_LONG; + size -= BITS_PER_LONG; + } + if (!size) + return result; + tmp = *p; found_first: - tmp &= (~0UL >> (BITS_PER_LONG - size)); - if (tmp == 0UL) /* Are any bits set? */ - return result + size; /* Nope. */ + tmp &= (~0UL >> (BITS_PER_LONG - size)); + if (tmp == 0UL) /* Are any bits set? */ + return result + size; /* Nope. */ found_middle: - return result + __ffs(tmp); + return result + __ffs(tmp); } -#define for_each_bit(i, bitmask) \ - for (i = find_next_bit(bitmask, sizeof(bitmask), 0); \ - i < sizeof(bitmask); \ - i = find_next_bit(bitmask, sizeof(bitmask), i + 1)) - +#define for_each_bit(i, bitmask) \ + for (i = find_next_bit(bitmask, sizeof(bitmask), 0); i < sizeof(bitmask); \ + i = find_next_bit(bitmask, sizeof(bitmask), i + 1)) #endif /* __CR_BITOPS_H__ */ diff --git a/include/common/arch/ppc64/asm/cmpxchg.h b/include/common/arch/ppc64/asm/cmpxchg.h index b93fbdef0..ba204a3f2 100644 --- a/include/common/arch/ppc64/asm/cmpxchg.h +++ b/include/common/arch/ppc64/asm/cmpxchg.h @@ -5,54 +5,44 @@ * Copied from kernel header file arch/powerpc/include/asm/cmpxchg.h */ -#define PPC_ACQUIRE_BARRIER "isync \n" -#define PPC_RELEASE_BARRIER "lwsync \n" +#define PPC_ACQUIRE_BARRIER "isync \n" +#define PPC_RELEASE_BARRIER "lwsync \n" /* * Compare and exchange - if *p == old, set it to new, * and return the old value of *p. */ -static __always_inline unsigned long -__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) +static __always_inline unsigned long __cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new) { unsigned int prev; - __asm__ __volatile__ ( - PPC_RELEASE_BARRIER \ -"1: lwarx %0,0,%2 # __cmpxchg_u32\n\ + __asm__ __volatile__(PPC_RELEASE_BARRIER "1: lwarx %0,0,%2 # __cmpxchg_u32\n\ cmpw 0,%0,%3\n\ bne- 2f\n" -" stwcx. %4,0,%2\n\ - bne- 1b \n" \ - PPC_ACQUIRE_BARRIER - "\n\ + " stwcx. %4,0,%2\n\ + bne- 1b \n" PPC_ACQUIRE_BARRIER "\n\ 2:" - : "=&r" (prev), "+m" (*p) - : "r" (p), "r" (old), "r" (new) - : "cc", "memory"); + : "=&r"(prev), "+m"(*p) + : "r"(p), "r"(old), "r"(new) + : "cc", "memory"); return prev; } -static __always_inline unsigned long -__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) +static __always_inline unsigned long __cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) { unsigned long prev; - __asm__ __volatile__ ( - PPC_RELEASE_BARRIER \ -"1: ldarx %0,0,%2 # __cmpxchg_u64\n\ + __asm__ __volatile__(PPC_RELEASE_BARRIER "1: ldarx %0,0,%2 # __cmpxchg_u64\n\ cmpd 0,%0,%3\n\ bne- 2f\n\ stdcx. %4,0,%2\n\ - bne- 1b \n" \ - PPC_ACQUIRE_BARRIER - "\n\ + bne- 1b \n" PPC_ACQUIRE_BARRIER "\n\ 2:" - : "=&r" (prev), "+m" (*p) - : "r" (p), "r" (old), "r" (new) - : "cc", "memory"); + : "=&r"(prev), "+m"(*p) + : "r"(p), "r"(old), "r"(new) + : "cc", "memory"); return prev; } @@ -62,18 +52,18 @@ __cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new) #ifdef CR_DEBUG static inline void __cmpxchg_called_with_bad_pointer(void) { - __asm__ __volatile__ ( - "1: twi 31,0,0 # trap\n" - " b 1b" - : : : "memory"); + __asm__ __volatile__("1: twi 31,0,0 # trap\n" + " b 1b" + : + : + : "memory"); } #else extern void __cmpxchg_called_with_bad_pointer(void); #endif -static __always_inline unsigned long -__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, - unsigned int size) +static __always_inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, + unsigned int size) { switch (size) { case 4: @@ -85,12 +75,11 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, return old; } -#define cmpxchg(ptr, o, n) \ - ({ \ - __typeof__(*(ptr)) _o_ = (o); \ - __typeof__(*(ptr)) _n_ = (n); \ - (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \ - (unsigned long)_n_, sizeof(*(ptr))); \ - }) +#define cmpxchg(ptr, o, n) \ + ({ \ + __typeof__(*(ptr)) _o_ = (o); \ + __typeof__(*(ptr)) _n_ = (n); \ + (__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)_o_, (unsigned long)_n_, sizeof(*(ptr))); \ + }) #endif /* __CR_CMPXCHG_H__ */ diff --git a/include/common/arch/ppc64/asm/linkage.h b/include/common/arch/ppc64/asm/linkage.h index 01a47ab1a..8e388c105 100644 --- a/include/common/arch/ppc64/asm/linkage.h +++ b/include/common/arch/ppc64/asm/linkage.h @@ -10,36 +10,33 @@ #ifdef __ASSEMBLY__ -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - .type name, @function; \ +#define ENTRY(name) \ + .globl name; \ + .type name, @function; \ name: -#define END(sym) \ - .size sym, . - sym - +#define END(sym) .size sym, .- sym #define STACKFRAMESIZE 256 -#define __STK_REG(i) (112 + ((i)-14)*8) +#define __STK_REG(i) (112 + ((i)-14) * 8) #define STK_REG(i) __STK_REG(__REG_##i) /* The boring bits... */ /* Condition Register Bit Fields */ -#define cr0 0 -#define cr1 1 -#define cr2 2 -#define cr3 3 -#define cr4 4 -#define cr5 5 -#define cr6 6 -#define cr7 7 - +#define cr0 0 +#define cr1 1 +#define cr2 2 +#define cr3 3 +#define cr4 4 +#define cr5 5 +#define cr6 6 +#define cr7 7 /* * General Purpose Registers (GPRs) @@ -49,6 +46,7 @@ * Use R0-31 only when really nessesary. */ +/* clang-format off */ #define r0 %r0 #define r1 %r1 #define r2 %r2 @@ -81,221 +79,219 @@ #define r29 %r29 #define r30 %r30 #define r31 %r31 - +/* clang-format on */ /* Floating Point Registers (FPRs) */ -#define fr0 0 -#define fr1 1 -#define fr2 2 -#define fr3 3 -#define fr4 4 -#define fr5 5 -#define fr6 6 -#define fr7 7 -#define fr8 8 -#define fr9 9 -#define fr10 10 -#define fr11 11 -#define fr12 12 -#define fr13 13 -#define fr14 14 -#define fr15 15 -#define fr16 16 -#define fr17 17 -#define fr18 18 -#define fr19 19 -#define fr20 20 -#define fr21 21 -#define fr22 22 -#define fr23 23 -#define fr24 24 -#define fr25 25 -#define fr26 26 -#define fr27 27 -#define fr28 28 -#define fr29 29 -#define fr30 30 -#define fr31 31 +#define fr0 0 +#define fr1 1 +#define fr2 2 +#define fr3 3 +#define fr4 4 +#define fr5 5 +#define fr6 6 +#define fr7 7 +#define fr8 8 +#define fr9 9 +#define fr10 10 +#define fr11 11 +#define fr12 12 +#define fr13 13 +#define fr14 14 +#define fr15 15 +#define fr16 16 +#define fr17 17 +#define fr18 18 +#define fr19 19 +#define fr20 20 +#define fr21 21 +#define fr22 22 +#define fr23 23 +#define fr24 24 +#define fr25 25 +#define fr26 26 +#define fr27 27 +#define fr28 28 +#define fr29 29 +#define fr30 30 +#define fr31 31 /* AltiVec Registers (VPRs) */ -#define vr0 0 -#define vr1 1 -#define vr2 2 -#define vr3 3 -#define vr4 4 -#define vr5 5 -#define vr6 6 -#define vr7 7 -#define vr8 8 -#define vr9 9 -#define vr10 10 -#define vr11 11 -#define vr12 12 -#define vr13 13 -#define vr14 14 -#define vr15 15 -#define vr16 16 -#define vr17 17 -#define vr18 18 -#define vr19 19 -#define vr20 20 -#define vr21 21 -#define vr22 22 -#define vr23 23 -#define vr24 24 -#define vr25 25 -#define vr26 26 -#define vr27 27 -#define vr28 28 -#define vr29 29 -#define vr30 30 -#define vr31 31 +#define vr0 0 +#define vr1 1 +#define vr2 2 +#define vr3 3 +#define vr4 4 +#define vr5 5 +#define vr6 6 +#define vr7 7 +#define vr8 8 +#define vr9 9 +#define vr10 10 +#define vr11 11 +#define vr12 12 +#define vr13 13 +#define vr14 14 +#define vr15 15 +#define vr16 16 +#define vr17 17 +#define vr18 18 +#define vr19 19 +#define vr20 20 +#define vr21 21 +#define vr22 22 +#define vr23 23 +#define vr24 24 +#define vr25 25 +#define vr26 26 +#define vr27 27 +#define vr28 28 +#define vr29 29 +#define vr30 30 +#define vr31 31 /* VSX Registers (VSRs) */ -#define vsr0 0 -#define vsr1 1 -#define vsr2 2 -#define vsr3 3 -#define vsr4 4 -#define vsr5 5 -#define vsr6 6 -#define vsr7 7 -#define vsr8 8 -#define vsr9 9 -#define vsr10 10 -#define vsr11 11 -#define vsr12 12 -#define vsr13 13 -#define vsr14 14 -#define vsr15 15 -#define vsr16 16 -#define vsr17 17 -#define vsr18 18 -#define vsr19 19 -#define vsr20 20 -#define vsr21 21 -#define vsr22 22 -#define vsr23 23 -#define vsr24 24 -#define vsr25 25 -#define vsr26 26 -#define vsr27 27 -#define vsr28 28 -#define vsr29 29 -#define vsr30 30 -#define vsr31 31 -#define vsr32 32 -#define vsr33 33 -#define vsr34 34 -#define vsr35 35 -#define vsr36 36 -#define vsr37 37 -#define vsr38 38 -#define vsr39 39 -#define vsr40 40 -#define vsr41 41 -#define vsr42 42 -#define vsr43 43 -#define vsr44 44 -#define vsr45 45 -#define vsr46 46 -#define vsr47 47 -#define vsr48 48 -#define vsr49 49 -#define vsr50 50 -#define vsr51 51 -#define vsr52 52 -#define vsr53 53 -#define vsr54 54 -#define vsr55 55 -#define vsr56 56 -#define vsr57 57 -#define vsr58 58 -#define vsr59 59 -#define vsr60 60 -#define vsr61 61 -#define vsr62 62 -#define vsr63 63 +#define vsr0 0 +#define vsr1 1 +#define vsr2 2 +#define vsr3 3 +#define vsr4 4 +#define vsr5 5 +#define vsr6 6 +#define vsr7 7 +#define vsr8 8 +#define vsr9 9 +#define vsr10 10 +#define vsr11 11 +#define vsr12 12 +#define vsr13 13 +#define vsr14 14 +#define vsr15 15 +#define vsr16 16 +#define vsr17 17 +#define vsr18 18 +#define vsr19 19 +#define vsr20 20 +#define vsr21 21 +#define vsr22 22 +#define vsr23 23 +#define vsr24 24 +#define vsr25 25 +#define vsr26 26 +#define vsr27 27 +#define vsr28 28 +#define vsr29 29 +#define vsr30 30 +#define vsr31 31 +#define vsr32 32 +#define vsr33 33 +#define vsr34 34 +#define vsr35 35 +#define vsr36 36 +#define vsr37 37 +#define vsr38 38 +#define vsr39 39 +#define vsr40 40 +#define vsr41 41 +#define vsr42 42 +#define vsr43 43 +#define vsr44 44 +#define vsr45 45 +#define vsr46 46 +#define vsr47 47 +#define vsr48 48 +#define vsr49 49 +#define vsr50 50 +#define vsr51 51 +#define vsr52 52 +#define vsr53 53 +#define vsr54 54 +#define vsr55 55 +#define vsr56 56 +#define vsr57 57 +#define vsr58 58 +#define vsr59 59 +#define vsr60 60 +#define vsr61 61 +#define vsr62 62 +#define vsr63 63 /* SPE Registers (EVPRs) */ -#define evr0 0 -#define evr1 1 -#define evr2 2 -#define evr3 3 -#define evr4 4 -#define evr5 5 -#define evr6 6 -#define evr7 7 -#define evr8 8 -#define evr9 9 -#define evr10 10 -#define evr11 11 -#define evr12 12 -#define evr13 13 -#define evr14 14 -#define evr15 15 -#define evr16 16 -#define evr17 17 -#define evr18 18 -#define evr19 19 -#define evr20 20 -#define evr21 21 -#define evr22 22 -#define evr23 23 -#define evr24 24 -#define evr25 25 -#define evr26 26 -#define evr27 27 -#define evr28 28 -#define evr29 29 -#define evr30 30 -#define evr31 31 +#define evr0 0 +#define evr1 1 +#define evr2 2 +#define evr3 3 +#define evr4 4 +#define evr5 5 +#define evr6 6 +#define evr7 7 +#define evr8 8 +#define evr9 9 +#define evr10 10 +#define evr11 11 +#define evr12 12 +#define evr13 13 +#define evr14 14 +#define evr15 15 +#define evr16 16 +#define evr17 17 +#define evr18 18 +#define evr19 19 +#define evr20 20 +#define evr21 21 +#define evr22 22 +#define evr23 23 +#define evr24 24 +#define evr25 25 +#define evr26 26 +#define evr27 27 +#define evr28 28 +#define evr29 29 +#define evr30 30 +#define evr31 31 /* some stab codes */ #define N_FUN 36 #define N_RSYM 64 -#define N_SLINE 68 +#define N_SLINE 68 #define N_SO 100 -#define __REG_R0 0 -#define __REG_R1 1 -#define __REG_R2 2 -#define __REG_R3 3 -#define __REG_R4 4 -#define __REG_R5 5 -#define __REG_R6 6 -#define __REG_R7 7 -#define __REG_R8 8 -#define __REG_R9 9 -#define __REG_R10 10 -#define __REG_R11 11 -#define __REG_R12 12 -#define __REG_R13 13 -#define __REG_R14 14 -#define __REG_R15 15 -#define __REG_R16 16 -#define __REG_R17 17 -#define __REG_R18 18 -#define __REG_R19 19 -#define __REG_R20 20 -#define __REG_R21 21 -#define __REG_R22 22 -#define __REG_R23 23 -#define __REG_R24 24 -#define __REG_R25 25 -#define __REG_R26 26 -#define __REG_R27 27 -#define __REG_R28 28 -#define __REG_R29 29 -#define __REG_R30 30 -#define __REG_R31 31 +#define __REG_R0 0 +#define __REG_R1 1 +#define __REG_R2 2 +#define __REG_R3 3 +#define __REG_R4 4 +#define __REG_R5 5 +#define __REG_R6 6 +#define __REG_R7 7 +#define __REG_R8 8 +#define __REG_R9 9 +#define __REG_R10 10 +#define __REG_R11 11 +#define __REG_R12 12 +#define __REG_R13 13 +#define __REG_R14 14 +#define __REG_R15 15 +#define __REG_R16 16 +#define __REG_R17 17 +#define __REG_R18 18 +#define __REG_R19 19 +#define __REG_R20 20 +#define __REG_R21 21 +#define __REG_R22 22 +#define __REG_R23 23 +#define __REG_R24 24 +#define __REG_R25 25 +#define __REG_R26 26 +#define __REG_R27 27 +#define __REG_R28 28 +#define __REG_R29 29 +#define __REG_R30 30 +#define __REG_R31 31 - - -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLY__ */ #endif /* __CR_LINKAGE_H__ */ diff --git a/include/common/arch/ppc64/asm/page.h b/include/common/arch/ppc64/asm/page.h index 5107cb8e0..a1ff6718a 100644 --- a/include/common/arch/ppc64/asm/page.h +++ b/include/common/arch/ppc64/asm/page.h @@ -29,11 +29,11 @@ static inline unsigned page_shift(void) * on ppc64, then we need refrain using PAGE_SIZE in criu and use * page_size() across sources (as it may differ on ppc64). */ -#define PAGE_SIZE page_size() -#define PAGE_MASK (~(PAGE_SIZE - 1)) -#define PAGE_SHIFT page_shift() +#define PAGE_SIZE page_size() +#define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_SHIFT page_shift() -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) #else /* CR_NOGLIBC */ diff --git a/include/common/arch/s390/asm/atomic.h b/include/common/arch/s390/asm/atomic.h index dfdba1296..a132ebe05 100644 --- a/include/common/arch/s390/asm/atomic.h +++ b/include/common/arch/s390/asm/atomic.h @@ -4,7 +4,10 @@ #include "common/arch/s390/asm/atomic_ops.h" #include "common/compiler.h" -#define ATOMIC_INIT(i) { (i) } +#define ATOMIC_INIT(i) \ + { \ + (i) \ + } typedef struct { int counter; @@ -14,17 +17,13 @@ static inline int atomic_read(const atomic_t *v) { int c; - asm volatile( - " l %0,%1\n" - : "=d" (c) : "Q" (v->counter)); + asm volatile(" l %0,%1\n" : "=d"(c) : "Q"(v->counter)); return c; } static inline void atomic_set(atomic_t *v, int i) { - asm volatile( - " st %1,%0\n" - : "=Q" (v->counter) : "d" (i)); + asm volatile(" st %1,%0\n" : "=Q"(v->counter) : "d"(i)); } static inline int atomic_add_return(int i, atomic_t *v) @@ -32,25 +31,24 @@ static inline int atomic_add_return(int i, atomic_t *v) return __atomic_add_barrier(i, &v->counter) + i; } - static inline void atomic_add(int i, atomic_t *v) { __atomic_add(i, &v->counter); } -#define atomic_inc(_v) atomic_add(1, _v) -#define atomic_inc_return(_v) atomic_add_return(1, _v) -#define atomic_sub(_i, _v) atomic_add(-(int)(_i), _v) -#define atomic_sub_return(_i, _v) atomic_add_return(-(int)(_i), _v) -#define atomic_dec(_v) atomic_sub(1, _v) -#define atomic_dec_return(_v) atomic_sub_return(1, _v) -#define atomic_dec_and_test(_v) (atomic_sub_return(1, _v) == 0) +#define atomic_inc(_v) atomic_add(1, _v) +#define atomic_inc_return(_v) atomic_add_return(1, _v) +#define atomic_sub(_i, _v) atomic_add(-(int)(_i), _v) +#define atomic_sub_return(_i, _v) atomic_add_return(-(int)(_i), _v) +#define atomic_dec(_v) atomic_sub(1, _v) +#define atomic_dec_return(_v) atomic_sub_return(1, _v) +#define atomic_dec_and_test(_v) (atomic_sub_return(1, _v) == 0) -#define ATOMIC_OPS(op) \ -static inline void atomic_##op(int i, atomic_t *v) \ -{ \ - __atomic_##op(i, &v->counter); \ -} \ +#define ATOMIC_OPS(op) \ + static inline void atomic_##op(int i, atomic_t *v) \ + { \ + __atomic_##op(i, &v->counter); \ + } ATOMIC_OPS(and) ATOMIC_OPS(or) @@ -64,4 +62,3 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new) } #endif /* __ARCH_S390_ATOMIC__ */ - diff --git a/include/common/arch/s390/asm/atomic_ops.h b/include/common/arch/s390/asm/atomic_ops.h index ff0e1e3da..e04d66e3c 100644 --- a/include/common/arch/s390/asm/atomic_ops.h +++ b/include/common/arch/s390/asm/atomic_ops.h @@ -1,6 +1,7 @@ #ifndef __ARCH_S390_ATOMIC_OPS__ #define __ARCH_S390_ATOMIC_OPS__ +/* clang-format off */ #define __ATOMIC_OP(op_name, op_string) \ static inline int op_name(int val, int *ptr) \ { \ @@ -15,18 +16,20 @@ static inline int op_name(int val, int *ptr) \ : [val] "d" (val), "0" (*ptr) : "cc", "memory"); \ return old; \ } +/* clang-format on */ -#define __ATOMIC_OPS(op_name, op_string) \ - __ATOMIC_OP(op_name, op_string) \ +#define __ATOMIC_OPS(op_name, op_string) \ + __ATOMIC_OP(op_name, op_string) \ __ATOMIC_OP(op_name##_barrier, op_string) __ATOMIC_OPS(__atomic_add, "ar") __ATOMIC_OPS(__atomic_and, "nr") -__ATOMIC_OPS(__atomic_or, "or") +__ATOMIC_OPS(__atomic_or, "or") __ATOMIC_OPS(__atomic_xor, "xr") #undef __ATOMIC_OPS +/* clang-format off */ #define __ATOMIC64_OP(op_name, op_string) \ static inline long op_name(long val, long *ptr) \ { \ @@ -41,33 +44,34 @@ static inline long op_name(long val, long *ptr) \ : [val] "d" (val), "0" (*ptr) : "cc", "memory"); \ return old; \ } +/* clang-format on */ -#define __ATOMIC64_OPS(op_name, op_string) \ - __ATOMIC64_OP(op_name, op_string) \ +#define __ATOMIC64_OPS(op_name, op_string) \ + __ATOMIC64_OP(op_name, op_string) \ __ATOMIC64_OP(op_name##_barrier, op_string) __ATOMIC64_OPS(__atomic64_add, "agr") __ATOMIC64_OPS(__atomic64_and, "ngr") -__ATOMIC64_OPS(__atomic64_or, "ogr") +__ATOMIC64_OPS(__atomic64_or, "ogr") __ATOMIC64_OPS(__atomic64_xor, "xgr") #undef __ATOMIC64_OPS static inline int __atomic_cmpxchg(int *ptr, int old, int new) { - asm volatile( - " cs %[old],%[new],%[ptr]" - : [old] "+d" (old), [ptr] "+Q" (*ptr) - : [new] "d" (new) : "cc", "memory"); + asm volatile(" cs %[old],%[new],%[ptr]" + : [old] "+d"(old), [ptr] "+Q"(*ptr) + : [new] "d"(new) + : "cc", "memory"); return old; } static inline long __atomic64_cmpxchg(long *ptr, long old, long new) { - asm volatile( - " csg %[old],%[new],%[ptr]" - : [old] "+d" (old), [ptr] "+Q" (*ptr) - : [new] "d" (new) : "cc", "memory"); + asm volatile(" csg %[old],%[new],%[ptr]" + : [old] "+d"(old), [ptr] "+Q"(*ptr) + : [new] "d"(new) + : "cc", "memory"); return old; } diff --git a/include/common/arch/s390/asm/bitops.h b/include/common/arch/s390/asm/bitops.h index 648d898d1..f396721e9 100644 --- a/include/common/arch/s390/asm/bitops.h +++ b/include/common/arch/s390/asm/bitops.h @@ -5,15 +5,13 @@ #include "common/compiler.h" #include "common/arch/s390/asm/atomic_ops.h" -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) -#define __BITOPS_WORDS(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) +#define __BITOPS_WORDS(bits) (((bits) + BITS_PER_LONG - 1) / BITS_PER_LONG) -#define DECLARE_BITMAP(name,bits) \ - unsigned long name[BITS_TO_LONGS(bits)] +#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)] -static inline unsigned long * -__bitops_word(unsigned long nr, volatile unsigned long *ptr) +static inline unsigned long *__bitops_word(unsigned long nr, volatile unsigned long *ptr) { unsigned long addr; @@ -21,8 +19,7 @@ __bitops_word(unsigned long nr, volatile unsigned long *ptr) return (unsigned long *)addr; } -static inline unsigned char * -__bitops_byte(unsigned long nr, volatile unsigned long *ptr) +static inline unsigned char *__bitops_byte(unsigned long nr, volatile unsigned long *ptr) { return ((unsigned char *)ptr) + ((nr ^ (BITS_PER_LONG - 8)) >> 3); } @@ -33,7 +30,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *ptr) unsigned long mask; mask = 1UL << (nr & (BITS_PER_LONG - 1)); - __atomic64_or((long) mask, (long *) addr); + __atomic64_or((long)mask, (long *)addr); } static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr) @@ -42,7 +39,7 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *ptr) unsigned long mask; mask = ~(1UL << (nr & (BITS_PER_LONG - 1))); - __atomic64_and((long) mask, (long *) addr); + __atomic64_and((long)mask, (long *)addr); } static inline void change_bit(unsigned long nr, volatile unsigned long *ptr) @@ -51,17 +48,16 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *ptr) unsigned long mask; mask = 1UL << (nr & (BITS_PER_LONG - 1)); - __atomic64_xor((long) mask, (long *) addr); + __atomic64_xor((long)mask, (long *)addr); } -static inline int -test_and_set_bit(unsigned long nr, volatile unsigned long *ptr) +static inline int test_and_set_bit(unsigned long nr, volatile unsigned long *ptr) { unsigned long *addr = __bitops_word(nr, ptr); unsigned long old, mask; mask = 1UL << (nr & (BITS_PER_LONG - 1)); - old = __atomic64_or_barrier((long) mask, (long *) addr); + old = __atomic64_or_barrier((long)mask, (long *)addr); return (old & mask) != 0; } @@ -118,9 +114,8 @@ static inline unsigned long __ffs(unsigned long word) #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1))) -static inline unsigned long _find_next_bit(const unsigned long *addr, - unsigned long nbits, unsigned long start, - unsigned long invert) +static inline unsigned long _find_next_bit(const unsigned long *addr, unsigned long nbits, unsigned long start, + unsigned long invert) { unsigned long tmp; @@ -143,16 +138,13 @@ static inline unsigned long _find_next_bit(const unsigned long *addr, return min(start + __ffs(tmp), nbits); } -static inline unsigned long find_next_bit(const unsigned long *addr, - unsigned long size, - unsigned long offset) +static inline unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { return _find_next_bit(addr, size, offset, 0UL); } -#define for_each_bit(i, bitmask) \ - for (i = find_next_bit(bitmask, sizeof(bitmask), 0); \ - i < sizeof(bitmask); \ +#define for_each_bit(i, bitmask) \ + for (i = find_next_bit(bitmask, sizeof(bitmask), 0); i < sizeof(bitmask); \ i = find_next_bit(bitmask, sizeof(bitmask), i + 1)) #endif /* _S390_BITOPS_H */ diff --git a/include/common/arch/s390/asm/linkage.h b/include/common/arch/s390/asm/linkage.h index 99895ced5..4587b09ca 100644 --- a/include/common/arch/s390/asm/linkage.h +++ b/include/common/arch/s390/asm/linkage.h @@ -5,18 +5,17 @@ #define __ALIGN .align 4, 0x07 -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - .type name, @function; \ - __ALIGN; \ +#define ENTRY(name) \ + .globl name; \ + .type name, @function; \ + __ALIGN; \ name: -#define END(name) \ - .size name, . - name +#define END(name) .size name, .- name #endif /* __ASSEMBLY__ */ #endif diff --git a/include/common/arch/s390/asm/page.h b/include/common/arch/s390/asm/page.h index 8e8c6491b..d31e82c60 100644 --- a/include/common/arch/s390/asm/page.h +++ b/include/common/arch/s390/asm/page.h @@ -2,18 +2,18 @@ #define __CR_ASM_PAGE_H__ #ifndef PAGE_SHIFT -#define PAGE_SHIFT 12 +#define PAGE_SHIFT 12 #endif #ifndef PAGE_SIZE -#define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_SIZE (1UL << PAGE_SHIFT) #endif #ifndef PAGE_MASK -#define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_MASK (~(PAGE_SIZE - 1)) #endif -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) -#define page_size() PAGE_SIZE +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define page_size() PAGE_SIZE #endif /* __CR_ASM_PAGE_H__ */ diff --git a/include/common/arch/x86/asm/asm.h b/include/common/arch/x86/asm/asm.h index af324c6e2..49abe00bd 100644 --- a/include/common/arch/x86/asm/asm.h +++ b/include/common/arch/x86/asm/asm.h @@ -2,27 +2,27 @@ #define __CR_ASM_H__ #ifdef __GCC_ASM_FLAG_OUTPUTS__ -# define CC_SET(c) "\n\t/* output condition code " #c "*/\n" -# define CC_OUT(c) "=@cc" #c +#define CC_SET(c) "\n\t/* output condition code " #c "*/\n" +#define CC_OUT(c) "=@cc" #c #else -# define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n" -# define CC_OUT(c) [_cc_ ## c] "=qm" +#define CC_SET(c) "\n\tset" #c " %[_cc_" #c "]\n" +#define CC_OUT(c) [_cc_##c] "=qm" #endif #ifdef __ASSEMBLY__ -# define __ASM_FORM(x) x +#define __ASM_FORM(x) x #else -# define __ASM_FORM(x) " " #x " " +#define __ASM_FORM(x) " " #x " " #endif #ifndef __x86_64__ /* 32 bit */ -# define __ASM_SEL(a,b) __ASM_FORM(a) +#define __ASM_SEL(a, b) __ASM_FORM(a) #else /* 64 bit */ -# define __ASM_SEL(a,b) __ASM_FORM(b) +#define __ASM_SEL(a, b) __ASM_FORM(b) #endif -#define __ASM_SIZE(inst, ...) __ASM_SEL(inst##l##__VA_ARGS__, inst##q##__VA_ARGS__) +#define __ASM_SIZE(inst, ...) __ASM_SEL(inst##l##__VA_ARGS__, inst##q##__VA_ARGS__) #endif /* __CR_ASM_H__ */ diff --git a/include/common/arch/x86/asm/atomic.h b/include/common/arch/x86/asm/atomic.h index ec178e7cf..a0df6b125 100644 --- a/include/common/arch/x86/asm/atomic.h +++ b/include/common/arch/x86/asm/atomic.h @@ -7,7 +7,10 @@ typedef struct { int counter; } atomic_t; -#define ATOMIC_INIT(i) { (i) } +#define ATOMIC_INIT(i) \ + { \ + (i) \ + } static inline int atomic_read(const atomic_t *v) { @@ -21,37 +24,29 @@ static inline void atomic_set(atomic_t *v, int i) static inline void atomic_add(int i, atomic_t *v) { - asm volatile(LOCK_PREFIX "addl %1,%0" - : "+m" (v->counter) - : "ir" (i)); + asm volatile(LOCK_PREFIX "addl %1,%0" : "+m"(v->counter) : "ir"(i)); } static inline void atomic_sub(int i, atomic_t *v) { - asm volatile(LOCK_PREFIX "subl %1,%0" - : "+m" (v->counter) - : "ir" (i)); + asm volatile(LOCK_PREFIX "subl %1,%0" : "+m"(v->counter) : "ir"(i)); } static inline void atomic_inc(atomic_t *v) { - asm volatile(LOCK_PREFIX "incl %0" - : "+m" (v->counter)); + asm volatile(LOCK_PREFIX "incl %0" : "+m"(v->counter)); } static inline void atomic_dec(atomic_t *v) { - asm volatile(LOCK_PREFIX "decl %0" - : "+m" (v->counter)); + asm volatile(LOCK_PREFIX "decl %0" : "+m"(v->counter)); } static inline int atomic_dec_and_test(atomic_t *v) { unsigned char c; - asm volatile(LOCK_PREFIX "decl %0; sete %1" - : "+m" (v->counter), "=qm" (c) - : : "memory"); + asm volatile(LOCK_PREFIX "decl %0; sete %1" : "+m"(v->counter), "=qm"(c) : : "memory"); return c != 0; } @@ -65,8 +60,8 @@ static inline int atomic_sub_return(int i, atomic_t *v) return atomic_add_return(-i, v); } -#define atomic_inc_return(v) (atomic_add_return(1, v)) -#define atomic_dec_return(v) (atomic_sub_return(1, v)) +#define atomic_inc_return(v) (atomic_add_return(1, v)) +#define atomic_dec_return(v) (atomic_sub_return(1, v)) static inline int atomic_cmpxchg(atomic_t *v, int old, int new) { diff --git a/include/common/arch/x86/asm/bitops.h b/include/common/arch/x86/asm/bitops.h index 9c7aeb5d7..d7a60589b 100644 --- a/include/common/arch/x86/asm/bitops.h +++ b/include/common/arch/x86/asm/bitops.h @@ -6,47 +6,46 @@ #include "common/arch/x86/asm/asm.h" #include "common/asm/bitsperlong.h" -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) -#define DECLARE_BITMAP(name, bits) \ - unsigned long name[BITS_TO_LONGS(bits)] +#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)] #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) /* Technically wrong, but this avoids compilation errors on some gcc versions. */ -#define BITOP_ADDR(x) "=m" (*(volatile long *) (x)) +#define BITOP_ADDR(x) "=m"(*(volatile long *)(x)) #else -#define BITOP_ADDR(x) "+m" (*(volatile long *) (x)) +#define BITOP_ADDR(x) "+m"(*(volatile long *)(x)) #endif -#define ADDR BITOP_ADDR(addr) +#define ADDR BITOP_ADDR(addr) static inline void set_bit(long nr, volatile unsigned long *addr) { - asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir" (nr) : "memory"); + asm volatile(__ASM_SIZE(bts) " %1,%0" : ADDR : "Ir"(nr) : "memory"); } static inline void change_bit(long nr, volatile unsigned long *addr) { - asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir" (nr)); + asm volatile(__ASM_SIZE(btc) " %1,%0" : ADDR : "Ir"(nr)); } static inline bool test_bit(long nr, volatile const unsigned long *addr) { bool oldbit; - asm volatile(__ASM_SIZE(bt) " %2,%1" - CC_SET(c) - : CC_OUT(c) (oldbit) - : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory"); + asm volatile(__ASM_SIZE(bt) " %2,%1" CC_SET(c) + : CC_OUT(c)(oldbit) + : "m"(*(unsigned long *)addr), "Ir"(nr) + : "memory"); return oldbit; } static inline void clear_bit(long nr, volatile unsigned long *addr) { - asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir" (nr)); + asm volatile(__ASM_SIZE(btr) " %1,%0" : ADDR : "Ir"(nr)); } /** @@ -61,10 +60,7 @@ static inline bool test_and_set_bit(long nr, volatile unsigned long *addr) { bool oldbit; - asm(__ASM_SIZE(bts) " %2,%1" - CC_SET(c) - : CC_OUT(c) (oldbit) - : "m" (*(unsigned long *)addr), "Ir" (nr) : "memory"); + asm(__ASM_SIZE(bts) " %2,%1" CC_SET(c) : CC_OUT(c)(oldbit) : "m"(*(unsigned long *)addr), "Ir"(nr) : "memory"); return oldbit; } @@ -76,23 +72,19 @@ static inline bool test_and_set_bit(long nr, volatile unsigned long *addr) */ static inline unsigned long __ffs(unsigned long word) { - asm("bsf %1,%0" - : "=r" (word) - : "rm" (word)); + asm("bsf %1,%0" : "=r"(word) : "rm"(word)); return word; } -#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) /* * Find the next set bit in a memory region. */ -static inline -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +static inline unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); - unsigned long result = offset & ~(BITS_PER_LONG-1); + unsigned long result = offset & ~(BITS_PER_LONG - 1); unsigned long tmp; if (offset >= size) @@ -109,7 +101,7 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, size -= BITS_PER_LONG; result += BITS_PER_LONG; } - while (size & ~(BITS_PER_LONG-1)) { + while (size & ~(BITS_PER_LONG - 1)) { if ((tmp = *(p++))) goto found_middle; result += BITS_PER_LONG; @@ -121,15 +113,14 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, found_first: tmp &= (~0UL >> (BITS_PER_LONG - size)); - if (tmp == 0UL) /* Are any bits set? */ - return result + size; /* Nope. */ + if (tmp == 0UL) /* Are any bits set? */ + return result + size; /* Nope. */ found_middle: return result + __ffs(tmp); } -#define for_each_bit(i, bitmask) \ - for (i = find_next_bit(bitmask, sizeof(bitmask), 0); \ - i < sizeof(bitmask); \ +#define for_each_bit(i, bitmask) \ + for (i = find_next_bit(bitmask, sizeof(bitmask), 0); i < sizeof(bitmask); \ i = find_next_bit(bitmask, sizeof(bitmask), i + 1)) #endif /* __CR_BITOPS_H__ */ diff --git a/include/common/arch/x86/asm/bitsperlong.h b/include/common/arch/x86/asm/bitsperlong.h index 7e0a71e8d..2a88b0a37 100644 --- a/include/common/arch/x86/asm/bitsperlong.h +++ b/include/common/arch/x86/asm/bitsperlong.h @@ -2,9 +2,9 @@ #define __CR_BITSPERLONG_H__ #ifdef CONFIG_X86_64 -# define BITS_PER_LONG 64 +#define BITS_PER_LONG 64 #else -# define BITS_PER_LONG 32 +#define BITS_PER_LONG 32 #endif #endif /* __CR_BITSPERLONG_H__ */ diff --git a/include/common/arch/x86/asm/cmpxchg.h b/include/common/arch/x86/asm/cmpxchg.h index fa5eccf09..ca3c9622c 100644 --- a/include/common/arch/x86/asm/cmpxchg.h +++ b/include/common/arch/x86/asm/cmpxchg.h @@ -5,46 +5,38 @@ #define LOCK_PREFIX "\n\tlock; " -#define __X86_CASE_B 1 -#define __X86_CASE_W 2 -#define __X86_CASE_L 4 -#define __X86_CASE_Q 8 +#define __X86_CASE_B 1 +#define __X86_CASE_W 2 +#define __X86_CASE_L 4 +#define __X86_CASE_Q 8 /* * An exchange-type operation, which takes a value and a pointer, and * returns the old value. Make sure you never reach non-case statement * here, otherwise behaviour is undefined. */ -#define __xchg_op(ptr, arg, op, lock) \ - ({ \ - __typeof__ (*(ptr)) __ret = (arg); \ - switch (sizeof(*(ptr))) { \ - case __X86_CASE_B: \ - asm volatile (lock #op "b %b0, %1\n" \ - : "+q" (__ret), "+m" (*(ptr)) \ - : : "memory", "cc"); \ - break; \ - case __X86_CASE_W: \ - asm volatile (lock #op "w %w0, %1\n" \ - : "+r" (__ret), "+m" (*(ptr)) \ - : : "memory", "cc"); \ - break; \ - case __X86_CASE_L: \ - asm volatile (lock #op "l %0, %1\n" \ - : "+r" (__ret), "+m" (*(ptr)) \ - : : "memory", "cc"); \ - break; \ - case __X86_CASE_Q: \ - asm volatile (lock #op "q %q0, %1\n" \ - : "+r" (__ret), "+m" (*(ptr)) \ - : : "memory", "cc"); \ - break; \ - } \ - __ret; \ +#define __xchg_op(ptr, arg, op, lock) \ + ({ \ + __typeof__(*(ptr)) __ret = (arg); \ + switch (sizeof(*(ptr))) { \ + case __X86_CASE_B: \ + asm volatile(lock #op "b %b0, %1\n" : "+q"(__ret), "+m"(*(ptr)) : : "memory", "cc"); \ + break; \ + case __X86_CASE_W: \ + asm volatile(lock #op "w %w0, %1\n" : "+r"(__ret), "+m"(*(ptr)) : : "memory", "cc"); \ + break; \ + case __X86_CASE_L: \ + asm volatile(lock #op "l %0, %1\n" : "+r"(__ret), "+m"(*(ptr)) : : "memory", "cc"); \ + break; \ + case __X86_CASE_Q: \ + asm volatile(lock #op "q %q0, %1\n" : "+r"(__ret), "+m"(*(ptr)) : : "memory", "cc"); \ + break; \ + } \ + __ret; \ }) -#define __xadd(ptr, inc, lock) __xchg_op((ptr), (inc), xadd, lock) -#define xadd(ptr, inc) __xadd((ptr), (inc), "lock ;") +#define __xadd(ptr, inc, lock) __xchg_op((ptr), (inc), xadd, lock) +#define xadd(ptr, inc) __xadd((ptr), (inc), "lock ;") /* Borrowed from linux kernel arch/x86/include/asm/cmpxchg.h */ @@ -53,55 +45,49 @@ * store NEW in MEM. Return the initial value in MEM. Success is * indicated by comparing RETURN with OLD. */ -#define __raw_cmpxchg(ptr, old, new, size, lock) \ -({ \ - __typeof__(*(ptr)) __ret; \ - __typeof__(*(ptr)) __old = (old); \ - __typeof__(*(ptr)) __new = (new); \ - switch (size) { \ - case __X86_CASE_B: \ - { \ - volatile uint8_t *__ptr = (volatile uint8_t *)(ptr); \ - asm volatile(lock "cmpxchgb %2,%1" \ - : "=a" (__ret), "+m" (*__ptr) \ - : "q" (__new), "0" (__old) \ - : "memory"); \ - break; \ - } \ - case __X86_CASE_W: \ - { \ - volatile uint16_t *__ptr = (volatile uint16_t *)(ptr); \ - asm volatile(lock "cmpxchgw %2,%1" \ - : "=a" (__ret), "+m" (*__ptr) \ - : "r" (__new), "0" (__old) \ - : "memory"); \ - break; \ - } \ - case __X86_CASE_L: \ - { \ - volatile uint32_t *__ptr = (volatile uint32_t *)(ptr); \ - asm volatile(lock "cmpxchgl %2,%1" \ - : "=a" (__ret), "+m" (*__ptr) \ - : "r" (__new), "0" (__old) \ - : "memory"); \ - break; \ - } \ - case __X86_CASE_Q: \ - { \ - volatile uint64_t *__ptr = (volatile uint64_t *)(ptr); \ - asm volatile(lock "cmpxchgq %2,%1" \ - : "=a" (__ret), "+m" (*__ptr) \ - : "r" (__new), "0" (__old) \ - : "memory"); \ - break; \ - } \ - } \ - __ret; \ -}) +#define __raw_cmpxchg(ptr, old, new, size, lock) \ + ({ \ + __typeof__(*(ptr)) __ret; \ + __typeof__(*(ptr)) __old = (old); \ + __typeof__(*(ptr)) __new = (new); \ + switch (size) { \ + case __X86_CASE_B: { \ + volatile uint8_t *__ptr = (volatile uint8_t *)(ptr); \ + asm volatile(lock "cmpxchgb %2,%1" \ + : "=a"(__ret), "+m"(*__ptr) \ + : "q"(__new), "0"(__old) \ + : "memory"); \ + break; \ + } \ + case __X86_CASE_W: { \ + volatile uint16_t *__ptr = (volatile uint16_t *)(ptr); \ + asm volatile(lock "cmpxchgw %2,%1" \ + : "=a"(__ret), "+m"(*__ptr) \ + : "r"(__new), "0"(__old) \ + : "memory"); \ + break; \ + } \ + case __X86_CASE_L: { \ + volatile uint32_t *__ptr = (volatile uint32_t *)(ptr); \ + asm volatile(lock "cmpxchgl %2,%1" \ + : "=a"(__ret), "+m"(*__ptr) \ + : "r"(__new), "0"(__old) \ + : "memory"); \ + break; \ + } \ + case __X86_CASE_Q: { \ + volatile uint64_t *__ptr = (volatile uint64_t *)(ptr); \ + asm volatile(lock "cmpxchgq %2,%1" \ + : "=a"(__ret), "+m"(*__ptr) \ + : "r"(__new), "0"(__old) \ + : "memory"); \ + break; \ + } \ + } \ + __ret; \ + }) -#define __cmpxchg(ptr, old, new, size) \ - __raw_cmpxchg((ptr), (old), (new), (size), LOCK_PREFIX) -#define cmpxchg(ptr, old, new) \ - __cmpxchg(ptr, old, new, sizeof(*(ptr))) +#define __cmpxchg(ptr, old, new, size) __raw_cmpxchg((ptr), (old), (new), (size), LOCK_PREFIX) +#define cmpxchg(ptr, old, new) __cmpxchg(ptr, old, new, sizeof(*(ptr))) #endif /* __CR_CMPXCHG_H__ */ diff --git a/include/common/arch/x86/asm/linkage.h b/include/common/arch/x86/asm/linkage.h index 5eaf450db..2088b2e0a 100644 --- a/include/common/arch/x86/asm/linkage.h +++ b/include/common/arch/x86/asm/linkage.h @@ -3,25 +3,24 @@ #ifdef __ASSEMBLY__ -#define __ALIGN .align 4, 0x90 -#define __ALIGN_STR ".align 4, 0x90" +#define __ALIGN .align 4, 0x90 +#define __ALIGN_STR ".align 4, 0x90" -#define GLOBAL(name) \ - .globl name; \ +#define GLOBAL(name) \ + .globl name; \ name: -#define ENTRY(name) \ - .globl name; \ - .type name, @function; \ - __ALIGN; \ +#define ENTRY(name) \ + .globl name; \ + .type name, @function; \ + __ALIGN; \ name: -#define END(sym) \ - .size sym, . - sym +#define END(sym) .size sym, .- sym -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLY__ */ -#define __USER32_CS 0x23 -#define __USER_CS 0x33 +#define __USER32_CS 0x23 +#define __USER_CS 0x33 #endif /* __CR_LINKAGE_H__ */ diff --git a/include/common/arch/x86/asm/page.h b/include/common/arch/x86/asm/page.h index 134835556..d31e82c60 100644 --- a/include/common/arch/x86/asm/page.h +++ b/include/common/arch/x86/asm/page.h @@ -2,18 +2,18 @@ #define __CR_ASM_PAGE_H__ #ifndef PAGE_SHIFT -# define PAGE_SHIFT 12 +#define PAGE_SHIFT 12 #endif #ifndef PAGE_SIZE -# define PAGE_SIZE (1UL << PAGE_SHIFT) +#define PAGE_SIZE (1UL << PAGE_SHIFT) #endif #ifndef PAGE_MASK -# define PAGE_MASK (~(PAGE_SIZE - 1)) +#define PAGE_MASK (~(PAGE_SIZE - 1)) #endif -#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) -#define page_size() PAGE_SIZE +#define PAGE_PFN(addr) ((addr) / PAGE_SIZE) +#define page_size() PAGE_SIZE #endif /* __CR_ASM_PAGE_H__ */ diff --git a/include/common/asm-generic/bitops.h b/include/common/asm-generic/bitops.h index 0d861bdcc..064ba4cc4 100644 --- a/include/common/asm-generic/bitops.h +++ b/include/common/asm-generic/bitops.h @@ -10,23 +10,23 @@ #include "common/asm/bitsperlong.h" -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) -#define DECLARE_BITMAP(name, bits) \ - unsigned long name[BITS_TO_LONGS(bits)] +#define DECLARE_BITMAP(name, bits) unsigned long name[BITS_TO_LONGS(bits)] #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) /* Technically wrong, but this avoids compilation errors on some gcc versions. */ -#define BITOP_ADDR(x) "=m" (*(volatile long *) (x)) +#define BITOP_ADDR(x) "=m"(*(volatile long *)(x)) #else -#define BITOP_ADDR(x) "+m" (*(volatile long *) (x)) +#define BITOP_ADDR(x) "+m"(*(volatile long *)(x)) #endif -#define ADDR BITOP_ADDR(addr) +#define ADDR BITOP_ADDR(addr) -static inline void set_bit(int nr, volatile unsigned long *addr) { +static inline void set_bit(int nr, volatile unsigned long *addr) +{ addr += nr / BITS_PER_LONG; *addr |= (1UL << (nr % BITS_PER_LONG)); } @@ -60,17 +60,15 @@ static inline unsigned long __ffs(unsigned long word) return __builtin_ffsl(word) - 1; } -#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG) /* * Find the next set bit in a memory region. */ -static inline -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +static inline unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); - unsigned long result = offset & ~(BITS_PER_LONG-1); + unsigned long result = offset & ~(BITS_PER_LONG - 1); unsigned long tmp; if (offset >= size) @@ -87,7 +85,7 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, size -= BITS_PER_LONG; result += BITS_PER_LONG; } - while (size & ~(BITS_PER_LONG-1)) { + while (size & ~(BITS_PER_LONG - 1)) { if ((tmp = *(p++))) goto found_middle; result += BITS_PER_LONG; @@ -99,15 +97,14 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size, found_first: tmp &= (~0UL >> (BITS_PER_LONG - size)); - if (tmp == 0UL) /* Are any bits set? */ - return result + size; /* Nope. */ + if (tmp == 0UL) /* Are any bits set? */ + return result + size; /* Nope. */ found_middle: return result + __ffs(tmp); } -#define for_each_bit(i, bitmask) \ - for (i = find_next_bit(bitmask, sizeof(bitmask), 0); \ - i < sizeof(bitmask); \ +#define for_each_bit(i, bitmask) \ + for (i = find_next_bit(bitmask, sizeof(bitmask), 0); i < sizeof(bitmask); \ i = find_next_bit(bitmask, sizeof(bitmask), i + 1)) #endif /* __CR_GENERIC_BITOPS_H__ */ diff --git a/include/common/bitops.h b/include/common/bitops.h index 1e6411243..a1000cd13 100644 --- a/include/common/bitops.h +++ b/include/common/bitops.h @@ -6,9 +6,9 @@ #include #if __BYTE_ORDER == __BIG_ENDIAN -#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7) +#define BITOP_LE_SWIZZLE ((BITS_PER_LONG - 1) & ~0x7) #else -#define BITOP_LE_SWIZZLE 0 +#define BITOP_LE_SWIZZLE 0 #endif static inline int test_and_set_bit_le(int nr, void *addr) diff --git a/include/common/bug.h b/include/common/bug.h index bacbf566b..fca3cadc6 100644 --- a/include/common/bug.h +++ b/include/common/bug.h @@ -9,34 +9,34 @@ #ifndef BUG_ON_HANDLER #ifdef CR_NOGLIBC -# define __raise() +#define __raise() #else -# define __raise() raise(SIGABRT) +#define __raise() raise(SIGABRT) #endif #ifndef __clang_analyzer__ -# ifndef pr_err -# error pr_err macro must be defined -# endif -# define BUG_ON_HANDLER(condition) \ - do { \ - if ((condition)) { \ - pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ - __raise(); \ - *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ - __builtin_unreachable(); \ - } \ +#ifndef pr_err +#error pr_err macro must be defined +#endif +#define BUG_ON_HANDLER(condition) \ + do { \ + if ((condition)) { \ + pr_err("BUG at %s:%d\n", __FILE__, __LINE__); \ + __raise(); \ + *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ + __builtin_unreachable(); \ + } \ } while (0) #else -# define BUG_ON_HANDLER(condition) \ - do { \ - assert(!condition); \ +#define BUG_ON_HANDLER(condition) \ + do { \ + assert(!condition); \ } while (0) #endif #endif /* BUG_ON_HANDLER */ -#define BUG_ON(condition) BUG_ON_HANDLER((condition)) -#define BUG() BUG_ON(true) +#define BUG_ON(condition) BUG_ON_HANDLER((condition)) +#define BUG() BUG_ON(true) #endif /* __CR_BUG_H__ */ diff --git a/include/common/compiler.h b/include/common/compiler.h index f19292989..bd3de01df 100644 --- a/include/common/compiler.h +++ b/include/common/compiler.h @@ -8,97 +8,113 @@ */ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#define NELEMS_AS_ARRAY(x,y) (sizeof(x) / sizeof((y)[0])) -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#define NELEMS_AS_ARRAY(x, y) (sizeof(x) / sizeof((y)[0])) +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) -#define ASSIGN_TYPED(a, b) do { (a) = (typeof(a))(b); } while (0) -#define ASSIGN_MEMBER(a, b, m) do { ASSIGN_TYPED((a)->m, (b)->m); } while (0) +#define ASSIGN_TYPED(a, b) \ + do { \ + (a) = (typeof(a))(b); \ + } while (0) +#define ASSIGN_MEMBER(a, b, m) \ + do { \ + ASSIGN_TYPED((a)->m, (b)->m); \ + } while (0) -#define __stringify_1(x...) #x -#define __stringify(x...) __stringify_1(x) +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x) -#define NORETURN __attribute__((__noreturn__)) -#define __packed __attribute__((__packed__)) -#define __used __attribute__((__used__)) -#define __maybe_unused __attribute__((unused)) -#define __always_unused __attribute__((unused)) -#define __must_check __attribute__((__warn_unused_result__)) +#define NORETURN __attribute__((__noreturn__)) +#define __packed __attribute__((__packed__)) +#define __used __attribute__((__used__)) +#define __maybe_unused __attribute__((unused)) +#define __always_unused __attribute__((unused)) +#define __must_check __attribute__((__warn_unused_result__)) -#define __section(S) __attribute__ ((__section__(#S))) +#define __section(S) __attribute__((__section__(#S))) #ifndef __always_inline -# define __always_inline inline __attribute__((always_inline)) +#define __always_inline inline __attribute__((always_inline)) #endif -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) #ifndef always_inline -# define always_inline __always_inline +#define always_inline __always_inline #endif #ifndef noinline -# define noinline __attribute__((noinline)) +#define noinline __attribute__((noinline)) #endif -#define __aligned(x) __attribute__((aligned(x))) +#define __aligned(x) __attribute__((aligned(x))) /* * Macro to define stack alignment. * aarch64 requires stack to be aligned to 16 bytes. */ -#define __stack_aligned__ __attribute__((aligned(16))) +#define __stack_aligned__ __attribute__((aligned(16))) #ifndef offsetof -# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) #endif -#define barrier() asm volatile("" ::: "memory") +#define barrier() asm volatile("" ::: "memory") -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) +#define container_of(ptr, type, member) \ + ({ \ + const typeof(((type *)0)->member) *__mptr = (ptr); \ + (type *)((char *)__mptr - offsetof(type, member)); \ + }) #ifndef FIELD_SIZEOF -# define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) +#define FIELD_SIZEOF(t, f) (sizeof(((t *)0)->f)) #endif -#define __round_mask(x, y) ((__typeof__(x))((y) - 1)) -#define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) -#define round_down(x, y) ((x) & ~__round_mask(x, y)) -#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) -#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y)) + 1) +#define round_down(x, y) ((x) & ~__round_mask(x, y)) +#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d)) +#define ALIGN(x, a) (((x) + (a)-1) & ~((a)-1)) -#define min(x, y) ({ \ - typeof(x) _min1 = (x); \ - typeof(y) _min2 = (y); \ - (void) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) +#define min(x, y) \ + ({ \ + typeof(x) _min1 = (x); \ + typeof(y) _min2 = (y); \ + (void)(&_min1 == &_min2); \ + _min1 < _min2 ? _min1 : _min2; \ + }) -#define max(x, y) ({ \ - typeof(x) _max1 = (x); \ - typeof(y) _max2 = (y); \ - (void) (&_max1 == &_max2); \ - _max1 > _max2 ? _max1 : _max2; }) +#define max(x, y) \ + ({ \ + typeof(x) _max1 = (x); \ + typeof(y) _max2 = (y); \ + (void)(&_max1 == &_max2); \ + _max1 > _max2 ? _max1 : _max2; \ + }) -#define min_t(type, x, y) ({ \ - type __min1 = (x); \ - type __min2 = (y); \ - __min1 < __min2 ? __min1: __min2; }) +#define min_t(type, x, y) \ + ({ \ + type __min1 = (x); \ + type __min2 = (y); \ + __min1 < __min2 ? __min1 : __min2; \ + }) -#define max_t(type, x, y) ({ \ - type __max1 = (x); \ - type __max2 = (y); \ - __max1 > __max2 ? __max1: __max2; }) +#define max_t(type, x, y) \ + ({ \ + type __max1 = (x); \ + type __max2 = (y); \ + __max1 > __max2 ? __max1 : __max2; \ + }) -#define SWAP(x, y) \ - do { \ - typeof(x) ____val = x; \ - x = y; \ - y = ____val; \ +#define SWAP(x, y) \ + do { \ + typeof(x) ____val = x; \ + x = y; \ + y = ____val; \ } while (0) -#define is_log2(v) (((v) & ((v) - 1)) == 0) +#define is_log2(v) (((v) & ((v)-1)) == 0) /* * Use "__ignore_value" to avoid a warning when using a function declared with @@ -121,9 +137,13 @@ * (See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 for the details) */ #if 3 < __GNUC__ + (4 <= __GNUC_MINOR__) -# define __ignore_value(x) ({ __typeof__ (x) __x = (x); (void) __x; }) +#define __ignore_value(x) \ + ({ \ + __typeof__(x) __x = (x); \ + (void)__x; \ + }) #else -# define __ignore_value(x) ((void) (x)) +#define __ignore_value(x) ((void)(x)) #endif #endif /* __CR_COMPILER_H__ */ diff --git a/include/common/err.h b/include/common/err.h index a370daf6b..d2473d228 100644 --- a/include/common/err.h +++ b/include/common/err.h @@ -12,7 +12,7 @@ * * Thus we may encode error number in low bits. */ -#define MAX_ERRNO 4095 +#define MAX_ERRNO 4095 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) diff --git a/include/common/list.h b/include/common/list.h index b8b57c784..b1506d5d9 100644 --- a/include/common/list.h +++ b/include/common/list.h @@ -9,15 +9,18 @@ #include "common/compiler.h" #define POISON_POINTER_DELTA 0 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA) -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA) +#define LIST_POISON1 ((void *)0x00100100 + POISON_POINTER_DELTA) +#define LIST_POISON2 ((void *)0x00200200 + POISON_POINTER_DELTA) struct list_head { struct list_head *prev, *next; }; -#define LIST_HEAD_INIT(name) { &(name), &(name) } -#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) +#define LIST_HEAD_INIT(name) \ + { \ + &(name), &(name) \ + } +#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) static inline void INIT_LIST_HEAD(struct list_head *list) { @@ -25,14 +28,12 @@ static inline void INIT_LIST_HEAD(struct list_head *list) list->prev = list; } -static inline void __list_add(struct list_head *new, - struct list_head *prev, - struct list_head *next) +static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) { - next->prev = new; - new->next = next; - new->prev = prev; - prev->next = new; + next->prev = new; + new->next = next; + new->prev = prev; + prev->next = new; } static inline void list_add(struct list_head *new, struct list_head *head) @@ -45,7 +46,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head) __list_add(new, head->prev, head); } -static inline void __list_del(struct list_head * prev, struct list_head * next) +static inline void __list_del(struct list_head *prev, struct list_head *next) { next->prev = prev; prev->next = next; @@ -63,17 +64,15 @@ static inline void list_del(struct list_head *entry) entry->prev = LIST_POISON2; } -static inline void list_replace(struct list_head *old, - struct list_head *new) +static inline void list_replace(struct list_head *old, struct list_head *new) { - new->next = old->next; - new->next->prev = new; - new->prev = old->prev; - new->prev->next = new; + new->next = old->next; + new->next->prev = new; + new->prev = old->prev; + new->prev->next = new; } -static inline void list_replace_init(struct list_head *old, - struct list_head *new) +static inline void list_replace_init(struct list_head *old, struct list_head *new) { list_replace(old, new); INIT_LIST_HEAD(old); @@ -91,21 +90,18 @@ static inline void list_move(struct list_head *list, struct list_head *head) list_add(list, head); } -static inline void list_move_tail(struct list_head *list, - struct list_head *head) +static inline void list_move_tail(struct list_head *list, struct list_head *head) { __list_del_entry(list); list_add_tail(list, head); } -static inline int list_is_last(const struct list_head *list, - const struct list_head *head) +static inline int list_is_last(const struct list_head *list, const struct list_head *head) { return list->next == head; } -static inline int list_is_first(const struct list_head *list, - const struct list_head *head) +static inline int list_is_first(const struct list_head *list, const struct list_head *head) { return list->prev == head; } @@ -135,8 +131,7 @@ static inline int list_is_singular(const struct list_head *head) return !list_empty(head) && (head->next == head->prev); } -static inline void __list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) +static inline void __list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry) { struct list_head *new_first = entry->next; list->next = head->next; @@ -147,13 +142,11 @@ static inline void __list_cut_position(struct list_head *list, new_first->prev = head; } -static inline void list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) +static inline void list_cut_position(struct list_head *list, struct list_head *head, struct list_head *entry) { if (list_empty(head)) return; - if (list_is_singular(head) && - (head->next != entry && head != entry)) + if (list_is_singular(head) && (head->next != entry && head != entry)) return; if (entry == head) INIT_LIST_HEAD(list); @@ -161,36 +154,31 @@ static inline void list_cut_position(struct list_head *list, __list_cut_position(list, head, entry); } -static inline void __list_splice(const struct list_head *list, - struct list_head *prev, - struct list_head *next) +static inline void __list_splice(const struct list_head *list, struct list_head *prev, struct list_head *next) { struct list_head *first = list->next; struct list_head *last = list->prev; - first->prev = prev; - prev->next = first; + first->prev = prev; + prev->next = first; - last->next = next; - next->prev = last; + last->next = next; + next->prev = last; } -static inline void list_splice(const struct list_head *list, - struct list_head *head) +static inline void list_splice(const struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head, head->next); } -static inline void list_splice_tail(struct list_head *list, - struct list_head *head) +static inline void list_splice_tail(struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head->prev, head); } -static inline void list_splice_init(struct list_head *list, - struct list_head *head) +static inline void list_splice_init(struct list_head *list, struct list_head *head) { if (!list_empty(list)) { __list_splice(list, head, head->next); @@ -198,8 +186,7 @@ static inline void list_splice_init(struct list_head *list, } } -static inline void list_splice_tail_init(struct list_head *list, - struct list_head *head) +static inline void list_splice_tail_init(struct list_head *list, struct list_head *head) { if (!list_empty(list)) { __list_splice(list, head->prev, head); @@ -207,79 +194,60 @@ static inline void list_splice_tail_init(struct list_head *list, } } -#define list_entry(ptr, type, member) \ - container_of(ptr, type, member) +#define list_entry(ptr, type, member) container_of(ptr, type, member) -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->next, type, member) +#define list_first_entry(ptr, type, member) list_entry((ptr)->next, type, member) -#define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) +#define list_for_each(pos, head) for (pos = (head)->next; pos != (head); pos = pos->next) -#define list_for_each_prev(pos, head) \ - for (pos = (head)->prev; pos != (head); pos = pos->prev) +#define list_for_each_prev(pos, head) for (pos = (head)->prev; pos != (head); pos = pos->prev) -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) +#define list_for_each_safe(pos, n, head) for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next) -#define list_for_each_prev_safe(pos, n, head) \ - for (pos = (head)->prev, n = pos->prev; \ - pos != (head); \ - pos = n, n = pos->prev) +#define list_for_each_prev_safe(pos, n, head) \ + for (pos = (head)->prev, n = pos->prev; pos != (head); pos = n, n = pos->prev) -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry(pos, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member); &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) -#define list_for_each_entry_reverse(pos, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry_reverse(pos, head, member) \ + for (pos = list_entry((head)->prev, typeof(*pos), member); &pos->member != (head); \ pos = list_entry(pos->member.prev, typeof(*pos), member)) -#define list_prepare_entry(pos, head, member) \ - ((pos) ? : list_entry(head, typeof(*pos), member)) +#define list_prepare_entry(pos, head, member) ((pos) ?: list_entry(head, typeof(*pos), member)) -#define list_for_each_entry_continue(pos, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry_continue(pos, head, member) \ + for (pos = list_entry(pos->member.next, typeof(*pos), member); &pos->member != (head); \ pos = list_entry(pos->member.next, typeof(*pos), member)) -#define list_for_each_entry_continue_reverse(pos, head, member) \ - for (pos = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry_continue_reverse(pos, head, member) \ + for (pos = list_entry(pos->member.prev, typeof(*pos), member); &pos->member != (head); \ pos = list_entry(pos->member.prev, typeof(*pos), member)) -#define list_for_each_entry_from(pos, head, member) \ - for (; &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) +#define list_for_each_entry_from(pos, head, member) \ + for (; &pos->member != (head); pos = list_entry(pos->member.next, typeof(*pos), member)) -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ +#define list_for_each_entry_safe(pos, n, head, member) \ + for (pos = list_entry((head)->next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); pos = n, n = list_entry(n->member.next, typeof(*n), member)) + +#define list_for_each_entry_safe_continue(pos, n, head, member) \ + for (pos = list_entry(pos->member.next, typeof(*pos), member), \ + n = list_entry(pos->member.next, typeof(*pos), member); \ + &pos->member != (head); pos = n, n = list_entry(n->member.next, typeof(*n), member)) + +#define list_for_each_entry_safe_from(pos, n, head, member) \ + for (n = list_entry(pos->member.next, typeof(*pos), member); &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) -#define list_for_each_entry_safe_continue(pos, n, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) +#define list_for_each_entry_safe_reverse(pos, n, head, member) \ + for (pos = list_entry((head)->prev, typeof(*pos), member), \ + n = list_entry(pos->member.prev, typeof(*pos), member); \ + &pos->member != (head); pos = n, n = list_entry(n->member.prev, typeof(*n), member)) -#define list_for_each_entry_safe_from(pos, n, head, member) \ - for (n = list_entry(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) - -#define list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = list_entry((head)->prev, typeof(*pos), member), \ - n = list_entry(pos->member.prev, typeof(*pos), member); \ - &pos->member != (head); \ - pos = n, n = list_entry(n->member.prev, typeof(*n), member)) - -#define list_safe_reset_next(pos, n, member) \ - n = list_entry(pos->member.next, typeof(*pos), member) +#define list_safe_reset_next(pos, n, member) n = list_entry(pos->member.next, typeof(*pos), member) /* * Double linked lists with a single pointer list head. @@ -293,9 +261,12 @@ struct hlist_node { struct hlist_node *next, **pprev; }; -#define HLIST_HEAD_INIT { .first = NULL } -#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } -#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) +#define HLIST_HEAD_INIT \ + { \ + .first = NULL \ + } +#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } +#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) static inline void INIT_HLIST_NODE(struct hlist_node *h) { @@ -348,8 +319,7 @@ static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h) } /* next must be != NULL */ -static inline void hlist_add_before(struct hlist_node *n, - struct hlist_node *next) +static inline void hlist_add_before(struct hlist_node *n, struct hlist_node *next) { n->pprev = next->pprev; n->next = next; @@ -357,15 +327,14 @@ static inline void hlist_add_before(struct hlist_node *n, *(n->pprev) = n; } -static inline void hlist_add_after(struct hlist_node *n, - struct hlist_node *next) +static inline void hlist_add_after(struct hlist_node *n, struct hlist_node *next) { next->next = n->next; n->next = next; next->pprev = &n->next; if (next->next) - next->next->pprev = &next->next; + next->next->pprev = &next->next; } /* after that we'll appear to be on some hlist and hlist_del will work */ @@ -378,8 +347,7 @@ static inline void hlist_add_fake(struct hlist_node *n) * Move a list from one list head to another. Fixup the pprev * reference of the first entry if it exists. */ -static inline void hlist_move_list(struct hlist_head *old, - struct hlist_head *new) +static inline void hlist_move_list(struct hlist_head *old, struct hlist_head *new) { new->first = old->first; if (new->first) @@ -387,35 +355,35 @@ static inline void hlist_move_list(struct hlist_head *old, old->first = NULL; } -#define hlist_entry(ptr, type, member) container_of(ptr,type,member) +#define hlist_entry(ptr, type, member) container_of(ptr, type, member) -#define hlist_for_each(pos, head) \ - for (pos = (head)->first; pos ; pos = pos->next) +#define hlist_for_each(pos, head) for (pos = (head)->first; pos; pos = pos->next) -#define hlist_for_each_safe(pos, n, head) \ - for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ +#define hlist_for_each_safe(pos, n, head) \ + for (pos = (head)->first; pos && ({ \ + n = pos->next; \ + 1; \ + }); \ pos = n) -#define hlist_entry_safe(ptr, type, member) \ - (ptr) ? hlist_entry(ptr, type, member) : NULL +#define hlist_entry_safe(ptr, type, member) (ptr) ? hlist_entry(ptr, type, member) : NULL -#define hlist_for_each_entry(pos, head, member) \ - for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \ - pos; \ +#define hlist_for_each_entry(pos, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); pos; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) -#define hlist_for_each_entry_continue(pos, member) \ - for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member);\ - pos; \ +#define hlist_for_each_entry_continue(pos, member) \ + for (pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member); pos; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) -#define hlist_for_each_entry_from(pos, member) \ - for (; pos; \ - pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) +#define hlist_for_each_entry_from(pos, member) \ + for (; pos; pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) -#define hlist_for_each_entry_safe(pos, n, head, member) \ - for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \ - pos && ({ n = pos->member.next; 1; }); \ +#define hlist_for_each_entry_safe(pos, n, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); pos && ({ \ + n = pos->member.next; \ + 1; \ + }); \ pos = hlist_entry_safe(n, typeof(*pos), member)) #endif /* __CR_LIST_H__ */ diff --git a/include/common/lock.h b/include/common/lock.h index 6baece25f..4fbe42c63 100644 --- a/include/common/lock.h +++ b/include/common/lock.h @@ -11,23 +11,24 @@ /* scan-build complains about derefencing a NULL pointer here. */ #ifndef __clang_analyzer__ -#define LOCK_BUG_ON(condition) \ - if ((condition)) \ - *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__ -#define LOCK_BUG() LOCK_BUG_ON(1) +#define LOCK_BUG_ON(condition) \ + if ((condition)) \ + *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__ +#define LOCK_BUG() LOCK_BUG_ON(1) #endif /* __clang_analyzer__ */ #ifdef CR_NOGLIBC -# include +#include #else -# include -# include -static inline long sys_futex (uint32_t *addr1, int op, uint32_t val1, - struct timespec *timeout, uint32_t *addr2, uint32_t val3) +#include +#include +static inline long sys_futex(uint32_t *addr1, int op, uint32_t val1, struct timespec *timeout, uint32_t *addr2, + uint32_t val3) { - int rc = syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); - if (rc == -1) rc = -errno; - return rc; + int rc = syscall(SYS_futex, addr1, op, val1, timeout, addr2, val3); + if (rc == -1) + rc = -errno; + return rc; } #endif @@ -35,8 +36,8 @@ typedef struct { atomic_t raw; } __aligned(sizeof(int)) futex_t; -#define FUTEX_ABORT_FLAG (0x80000000) -#define FUTEX_ABORT_RAW (-1U) +#define FUTEX_ABORT_FLAG (0x80000000) +#define FUTEX_ABORT_RAW (-1U) /* Get current futex @f value */ static inline uint32_t futex_get(futex_t *f) @@ -50,29 +51,27 @@ static inline void futex_set(futex_t *f, uint32_t v) atomic_set(&f->raw, (int)v); } -#define futex_init(f) futex_set(f, 0) +#define futex_init(f) futex_set(f, 0) /* Wait on futex @__f value @__v become in condition @__c */ -#define futex_wait_if_cond(__f, __v, __cond) \ - do { \ - int ret; \ - uint32_t tmp; \ - \ - while (1) { \ - struct timespec to = {.tv_sec = 120}; \ - tmp = futex_get(__f); \ - if ((tmp & FUTEX_ABORT_FLAG) || \ - (tmp __cond (__v))) \ - break; \ - ret = sys_futex((uint32_t *)&(__f)->raw.counter, FUTEX_WAIT,\ - tmp, &to, NULL, 0); \ - if (ret == -ETIMEDOUT) \ - continue; \ - if (ret == -EINTR || ret == -EWOULDBLOCK) \ - continue; \ - if (ret < 0) \ - LOCK_BUG(); \ - } \ +#define futex_wait_if_cond(__f, __v, __cond) \ + do { \ + int ret; \ + uint32_t tmp; \ + \ + while (1) { \ + struct timespec to = { .tv_sec = 120 }; \ + tmp = futex_get(__f); \ + if ((tmp & FUTEX_ABORT_FLAG) || (tmp __cond(__v))) \ + break; \ + ret = sys_futex((uint32_t *)&(__f)->raw.counter, FUTEX_WAIT, tmp, &to, NULL, 0); \ + if (ret == -ETIMEDOUT) \ + continue; \ + if (ret == -EINTR || ret == -EWOULDBLOCK) \ + continue; \ + if (ret < 0) \ + LOCK_BUG(); \ + } \ } while (0) /* Set futex @f to @v and wake up all waiters */ @@ -110,10 +109,16 @@ static inline void futex_inc_and_wake(futex_t *f) } /* Plain increment futex @f value */ -static inline void futex_inc(futex_t *f) { atomic_inc(&f->raw); } +static inline void futex_inc(futex_t *f) +{ + atomic_inc(&f->raw); +} /* Plain decrement futex @f value */ -static inline void futex_dec(futex_t *f) { atomic_dec(&f->raw); } +static inline void futex_dec(futex_t *f) +{ + atomic_dec(&f->raw); +} /* Wait until futex @f value become @v */ #define futex_wait_until(f, v) futex_wait_if_cond(f, v, ==) @@ -137,7 +142,7 @@ static inline void futex_wait_while(futex_t *f, uint32_t v) } typedef struct { - atomic_t raw; + atomic_t raw; } mutex_t; static inline void mutex_init(mutex_t *m) diff --git a/include/common/scm.h b/include/common/scm.h index a8eb9ec4c..bcb198882 100644 --- a/include/common/scm.h +++ b/include/common/scm.h @@ -14,25 +14,22 @@ * the pressue on kernel memory manager and use predefined * known to work well size of the message buffer. */ -#define CR_SCM_MSG_SIZE (1024) -#define CR_SCM_MAX_FD (252) +#define CR_SCM_MSG_SIZE (1024) +#define CR_SCM_MAX_FD (252) struct scm_fdset { - struct msghdr hdr; - struct iovec iov; - char msg_buf[CR_SCM_MSG_SIZE]; + struct msghdr hdr; + struct iovec iov; + char msg_buf[CR_SCM_MSG_SIZE]; }; #ifndef F_GETOWNER_UIDS -#define F_GETOWNER_UIDS 17 +#define F_GETOWNER_UIDS 17 #endif -extern int send_fds(int sock, struct sockaddr_un *saddr, int len, - int *fds, int nr_fds, void *data, unsigned ch_size); -extern int __recv_fds(int sock, int *fds, int nr_fds, - void *data, unsigned ch_size, int flags); -static inline int recv_fds(int sock, int *fds, int nr_fds, - void *data, unsigned ch_size) +extern int send_fds(int sock, struct sockaddr_un *saddr, int len, int *fds, int nr_fds, void *data, unsigned ch_size); +extern int __recv_fds(int sock, int *fds, int nr_fds, void *data, unsigned ch_size, int flags); +static inline int recv_fds(int sock, int *fds, int nr_fds, void *data, unsigned ch_size) { return __recv_fds(sock, fds, nr_fds, data, ch_size, 0); } diff --git a/include/common/xmalloc.h b/include/common/xmalloc.h index d377c83a0..42893a8b5 100644 --- a/include/common/xmalloc.h +++ b/include/common/xmalloc.h @@ -8,43 +8,42 @@ #error "Macro pr_err is needed." #endif -#define __xalloc(op, size, ...) \ - ({ \ - void *___p = op( __VA_ARGS__ ); \ - if (!___p) \ - pr_err("%s: Can't allocate %li bytes\n", \ - __func__, (long)(size)); \ - ___p; \ +#define __xalloc(op, size, ...) \ + ({ \ + void *___p = op(__VA_ARGS__); \ + if (!___p) \ + pr_err("%s: Can't allocate %li bytes\n", __func__, (long)(size)); \ + ___p; \ }) -#define xstrdup(str) __xalloc(strdup, strlen(str) + 1, str) -#define xmalloc(size) __xalloc(malloc, size, size) -#define xzalloc(size) __xalloc(calloc, size, 1, size) -#define xrealloc(p, size) __xalloc(realloc, size, p, size) +#define xstrdup(str) __xalloc(strdup, strlen(str) + 1, str) +#define xmalloc(size) __xalloc(malloc, size, size) +#define xzalloc(size) __xalloc(calloc, size, 1, size) +#define xrealloc(p, size) __xalloc(realloc, size, p, size) -#define xfree(p) free(p) +#define xfree(p) free(p) -#define xrealloc_safe(pptr, size) \ - ({ \ - int __ret = -1; \ - void *new = xrealloc(*pptr, size); \ - if (new) { \ - *pptr = new; \ - __ret = 0; \ - } \ - __ret; \ - }) +#define xrealloc_safe(pptr, size) \ + ({ \ + int __ret = -1; \ + void *new = xrealloc(*pptr, size); \ + if (new) { \ + *pptr = new; \ + __ret = 0; \ + } \ + __ret; \ + }) -#define xmemdup(ptr, size) \ - ({ \ - void *new = xmalloc(size); \ - if (new) \ - memcpy(new, ptr, size); \ - new; \ - }) +#define xmemdup(ptr, size) \ + ({ \ + void *new = xmalloc(size); \ + if (new) \ + memcpy(new, ptr, size); \ + new; \ + }) -#define memzero_p(p) memset(p, 0, sizeof(*p)) -#define memzero(p, size) memset(p, 0, size) +#define memzero_p(p) memset(p, 0, sizeof(*p)) +#define memzero(p, size) memset(p, 0, size) /* * Helper for allocating trees with single xmalloc. @@ -64,6 +63,6 @@ static inline void *xptr_pull_s(void **m, size_t s) return ret; } -#define xptr_pull(m, type) xptr_pull_s(m, sizeof(type)) +#define xptr_pull(m, type) xptr_pull_s(m, sizeof(type)) #endif /* __CR_XMALLOC_H__ */ diff --git a/lib/c/criu.h b/lib/c/criu.h index d2bfbf958..044e5373d 100644 --- a/lib/c/criu.h +++ b/lib/c/criu.h @@ -25,14 +25,10 @@ #include "rpc.pb-c.h" #ifdef __GNUG__ - extern "C" { +extern "C" { #endif -enum criu_service_comm { - CRIU_COMM_SK, - CRIU_COMM_FD, - CRIU_COMM_BIN -}; +enum criu_service_comm { CRIU_COMM_SK, CRIU_COMM_FD, CRIU_COMM_BIN }; enum criu_cg_mode { CRIU_CG_MODE_IGNORE, @@ -44,10 +40,7 @@ enum criu_cg_mode { CRIU_CG_MODE_DEFAULT, }; -enum criu_pre_dump_mode { - CRIU_PRE_DUMP_SPLICE = 1, - CRIU_PRE_DUMP_READ = 2 -}; +enum criu_pre_dump_mode { CRIU_PRE_DUMP_SPLICE = 1, CRIU_PRE_DUMP_READ = 2 }; int criu_set_service_address(const char *path); void criu_set_service_fd(int fd); diff --git a/soccr/soccr.h b/soccr/soccr.h index e3cfb7955..934d43827 100644 --- a/soccr/soccr.h +++ b/soccr/soccr.h @@ -1,9 +1,9 @@ #ifndef __LIBSOCCR_H__ #define __LIBSOCCR_H__ -#include /* sockaddr_in, sockaddr_in6 */ -#include /* TCP_REPAIR_WINDOW, TCP_TIMESTAMP */ -#include /* uint32_t */ -#include /* sockaddr */ +#include /* sockaddr_in, sockaddr_in6 */ +#include /* TCP_REPAIR_WINDOW, TCP_TIMESTAMP */ +#include /* uint32_t */ +#include /* sockaddr */ #include "common/config.h" @@ -12,12 +12,12 @@ #ifndef CONFIG_HAS_TCP_REPAIR_WINDOW struct tcp_repair_window { - uint32_t snd_wl1; - uint32_t snd_wnd; - uint32_t max_window; + uint32_t snd_wl1; + uint32_t snd_wnd; + uint32_t max_window; - uint32_t rcv_wnd; - uint32_t rcv_wup; + uint32_t rcv_wnd; + uint32_t rcv_wup; }; #endif @@ -30,8 +30,8 @@ struct tcp_repair_window { * our own. */ struct tcp_repair_opt { - uint32_t opt_code; - uint32_t opt_val; + uint32_t opt_code; + uint32_t opt_val; }; enum { @@ -43,17 +43,17 @@ enum { #endif #ifndef TCP_TIMESTAMP -#define TCP_TIMESTAMP 24 +#define TCP_TIMESTAMP 24 #endif #ifndef TCP_REPAIR_WINDOW -#define TCP_REPAIR_WINDOW 29 +#define TCP_REPAIR_WINDOW 29 #endif void libsoccr_set_log(unsigned int level, void (*fn)(unsigned int level, const char *fmt, ...)); -#define SOCCR_LOG_ERR 1 -#define SOCCR_LOG_DBG 2 +#define SOCCR_LOG_ERR 1 +#define SOCCR_LOG_DBG 2 /* * An opaque handler for C/R-ing a TCP socket. @@ -71,24 +71,24 @@ union libsoccr_addr { * socket and given back into the library in two steps (see below). */ struct libsoccr_sk_data { - uint32_t state; - uint32_t inq_len; - uint32_t inq_seq; - uint32_t outq_len; - uint32_t outq_seq; - uint32_t unsq_len; - uint32_t opt_mask; - uint32_t mss_clamp; - uint32_t snd_wscale; - uint32_t rcv_wscale; - uint32_t timestamp; + uint32_t state; + uint32_t inq_len; + uint32_t inq_seq; + uint32_t outq_len; + uint32_t outq_seq; + uint32_t unsq_len; + uint32_t opt_mask; + uint32_t mss_clamp; + uint32_t snd_wscale; + uint32_t rcv_wscale; + uint32_t timestamp; - uint32_t flags; /* SOCCR_FLAGS_... below */ - uint32_t snd_wl1; - uint32_t snd_wnd; - uint32_t max_window; - uint32_t rcv_wnd; - uint32_t rcv_wup; + uint32_t flags; /* SOCCR_FLAGS_... below */ + uint32_t snd_wl1; + uint32_t snd_wnd; + uint32_t max_window; + uint32_t rcv_wnd; + uint32_t rcv_wup; }; /* @@ -105,7 +105,7 @@ struct libsoccr_sk_data { * Window parameters. Mark snd_wl1, snd_wnd, max_window, rcv_wnd * and rcv_wup fields. */ -#define SOCCR_FLAGS_WINDOW 0x1 +#define SOCCR_FLAGS_WINDOW 0x1 /* * These two calls pause and resume the socket for and after C/R @@ -136,7 +136,7 @@ void libsoccr_release(struct libsoccr_sk *sk); * the former will free() one, when given to the library, the latter * is to free() it. */ -#define SOCCR_MEM_EXCL 0x1 +#define SOCCR_MEM_EXCL 0x1 /* * CHECKPOINTING calls diff --git a/test/compel/arch/arm/include/arch_test_handle_binary.h b/test/compel/arch/arm/include/arch_test_handle_binary.h index 234bd384a..84a958511 100644 --- a/test/compel/arch/arm/include/arch_test_handle_binary.h +++ b/test/compel/arch/arm/include/arch_test_handle_binary.h @@ -17,5 +17,4 @@ static __maybe_unused void arch_test_set_elf_hdr_machine(Ehdr_t *hdr) hdr->e_machine = EM_ARM; } - #endif /* __ARCH_TEST_HANDLE_BINARY__ */ diff --git a/test/compel/arch/x86/include/arch_test_handle_binary.h b/test/compel/arch/x86/include/arch_test_handle_binary.h index ae16ac57e..596de931b 100644 --- a/test/compel/arch/x86/include/arch_test_handle_binary.h +++ b/test/compel/arch/x86/include/arch_test_handle_binary.h @@ -5,7 +5,7 @@ #ifdef CONFIG_X86_64 #include "uapi/elf64-types.h" -#define __run_tests run_tests_64 +#define __run_tests run_tests_64 static __maybe_unused void arch_test_set_elf_hdr_ident(void *mem) { @@ -20,7 +20,7 @@ static __maybe_unused void arch_test_set_elf_hdr_machine(Ehdr_t *hdr) #else /* !CONFIG_X86_64 */ #include "uapi/elf32-types.h" -#define __run_tests run_tests_32 +#define __run_tests run_tests_32 static __maybe_unused void arch_test_set_elf_hdr_ident(void *mem) { diff --git a/test/zdtm/lib/arch/aarch64/include/asm/atomic.h b/test/zdtm/lib/arch/aarch64/include/asm/atomic.h index ddf4ad9f6..d59e53f4a 100644 --- a/test/zdtm/lib/arch/aarch64/include/asm/atomic.h +++ b/test/zdtm/lib/arch/aarch64/include/asm/atomic.h @@ -3,11 +3,9 @@ typedef uint32_t atomic_t; - /* Copied from the Linux header arch/arm/include/asm/barrier.h */ -#define smp_mb() asm volatile("dmb ish" : : : "memory") - +#define smp_mb() asm volatile("dmb ish" : : : "memory") /* Copied from the Linux kernel header arch/arm64/include/asm/atomic.h */ @@ -28,14 +26,13 @@ static inline int atomic_add_return(int i, atomic_t *v) unsigned long tmp; int result; - asm volatile( -"1: ldxr %w0, %2\n" -" add %w0, %w0, %w3\n" -" stlxr %w1, %w0, %2\n" -" cbnz %w1, 1b" - : "=&r" (result), "=&r" (tmp), "+Q" (*v) - : "Ir" (i) - : "cc", "memory"); + asm volatile("1: ldxr %w0, %2\n" + " add %w0, %w0, %w3\n" + " stlxr %w1, %w0, %2\n" + " cbnz %w1, 1b" + : "=&r"(result), "=&r"(tmp), "+Q"(*v) + : "Ir"(i) + : "cc", "memory"); smp_mb(); return result; @@ -46,28 +43,36 @@ static inline int atomic_sub_return(int i, atomic_t *v) unsigned long tmp; int result; - asm volatile( -"1: ldxr %w0, %2\n" -" sub %w0, %w0, %w3\n" -" stlxr %w1, %w0, %2\n" -" cbnz %w1, 1b" - : "=&r" (result), "=&r" (tmp), "+Q" (*v) - : "Ir" (i) - : "cc", "memory"); + asm volatile("1: ldxr %w0, %2\n" + " sub %w0, %w0, %w3\n" + " stlxr %w1, %w0, %2\n" + " cbnz %w1, 1b" + : "=&r"(result), "=&r"(tmp), "+Q"(*v) + : "Ir"(i) + : "cc", "memory"); smp_mb(); return result; } -static inline int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } +static inline int atomic_inc(atomic_t *v) +{ + return atomic_add_return(1, v) - 1; +} -static inline int atomic_add(int val, atomic_t *v) { return atomic_add_return(val, v) - val; } +static inline int atomic_add(int val, atomic_t *v) +{ + return atomic_add_return(val, v) - val; +} -static inline int atomic_dec(atomic_t *v) { return atomic_sub_return(1, v) + 1; } +static inline int atomic_dec(atomic_t *v) +{ + return atomic_sub_return(1, v) + 1; +} /* true if the result is 0, or false for all other cases. */ #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) -#define atomic_inc_return(v) (atomic_add_return(1, v)) +#define atomic_inc_return(v) (atomic_add_return(1, v)) #endif /* __CR_ATOMIC_H__ */ diff --git a/test/zdtm/lib/arch/arm/include/asm/atomic.h b/test/zdtm/lib/arch/arm/include/asm/atomic.h index 0ff76408d..bed1816a2 100644 --- a/test/zdtm/lib/arch/arm/include/asm/atomic.h +++ b/test/zdtm/lib/arch/arm/include/asm/atomic.h @@ -1,16 +1,14 @@ #ifndef __CR_ATOMIC_H__ #define __CR_ATOMIC_H__ - typedef uint32_t atomic_t; - /* Copied from the Linux kernel header arch/arm/include/asm/atomic.h */ -#define smp_mb() __asm__ __volatile__ ("dmb" : : : "memory") +#define smp_mb() __asm__ __volatile__("dmb" : : : "memory") -#define atomic_set(mem,v) (*(mem) = (v)) -#define atomic_get(v) (*(volatile uint32_t *)v) +#define atomic_set(mem, v) (*(mem) = (v)) +#define atomic_get(v) (*(volatile uint32_t *)v) static inline unsigned int atomic_add_return(int i, atomic_t *v) { @@ -20,14 +18,14 @@ static inline unsigned int atomic_add_return(int i, atomic_t *v) smp_mb(); __asm__ __volatile__("@ atomic_add_return\n" -"1: ldrex %0, [%3]\n" -" add %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b\n" - : "=&r" (result), "=&r" (tmp), "+Qo" (*v) - : "r" (v), "Ir" (i) - : "cc"); + "1: ldrex %0, [%3]\n" + " add %0, %0, %4\n" + " strex %1, %0, [%3]\n" + " teq %1, #0\n" + " bne 1b\n" + : "=&r"(result), "=&r"(tmp), "+Qo"(*v) + : "r"(v), "Ir"(i) + : "cc"); smp_mb(); @@ -42,25 +40,34 @@ static inline unsigned int atomic_sub_return(int i, atomic_t *v) smp_mb(); __asm__ __volatile__("@ atomic_sub_return\n" -"1: ldrex %0, [%3]\n" -" sub %0, %0, %4\n" -" strex %1, %0, [%3]\n" -" teq %1, #0\n" -" bne 1b\n" - : "=&r" (result), "=&r" (tmp), "+Qo" (*v) - : "r" (v), "Ir" (i) - : "cc"); + "1: ldrex %0, [%3]\n" + " sub %0, %0, %4\n" + " strex %1, %0, [%3]\n" + " teq %1, #0\n" + " bne 1b\n" + : "=&r"(result), "=&r"(tmp), "+Qo"(*v) + : "r"(v), "Ir"(i) + : "cc"); smp_mb(); return result; } -static inline unsigned int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } +static inline unsigned int atomic_inc(atomic_t *v) +{ + return atomic_add_return(1, v) - 1; +} -static inline unsigned int atomic_add(int val, atomic_t *v) { return atomic_add_return(val, v) - val; } +static inline unsigned int atomic_add(int val, atomic_t *v) +{ + return atomic_add_return(val, v) - val; +} -static inline unsigned int atomic_dec(atomic_t *v) { return atomic_sub_return(1, v) + 1; } +static inline unsigned int atomic_dec(atomic_t *v) +{ + return atomic_sub_return(1, v) + 1; +} /* true if the result is 0, or false for all other cases. */ #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0) diff --git a/test/zdtm/lib/arch/mips/include/asm/atomic.h b/test/zdtm/lib/arch/mips/include/asm/atomic.h index acf4c03cd..1db8c98a5 100644 --- a/test/zdtm/lib/arch/mips/include/asm/atomic.h +++ b/test/zdtm/lib/arch/mips/include/asm/atomic.h @@ -11,19 +11,19 @@ typedef uint32_t atomic_t; /* int counter; */ /* }atomic_t; */ -#define __WEAK_LLSC_MB " sync \n" +#define __WEAK_LLSC_MB " sync \n" -#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") +#define smp_llsc_mb() __asm__ __volatile__(__WEAK_LLSC_MB : : : "memory") -#define smp_mb__before_llsc() smp_llsc_mb() -#define smp_mb__before_atomic() smp_mb__before_llsc() +#define smp_mb__before_llsc() smp_llsc_mb() +#define smp_mb__before_atomic() smp_mb__before_llsc() #define smp_mb__after_atomic() smp_llsc_mb() -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) -#define atomic_get(v) (*(volatile int *)v) -#define atomic_set(v, i) ((*v) = (i)) +#define atomic_get(v) (*(volatile int *)v) +#define atomic_set(v, i) ((*v) = (i)) //#define atomic_get atomic_read @@ -35,20 +35,19 @@ typedef uint32_t atomic_t; * Atomically adds @i to @v. */ -static __inline__ void atomic_add(int i, atomic_t * v) +static __inline__ void atomic_add(int i, atomic_t *v) { - int temp; + int temp; - do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %0, %1 # atomic_add \n" - " addu %0, %2 \n" - " sc %0, %1 \n" - " .set mips0 \n" - : "=&r" (temp), "+m" (*v) - : "Ir" (i)); - } while (unlikely(!temp)); + do { + __asm__ __volatile__(" .set mips3 \n" + " ll %0, %1 # atomic_add \n" + " addu %0, %2 \n" + " sc %0, %1 \n" + " .set mips0 \n" + : "=&r"(temp), "+m"(*v) + : "Ir"(i)); + } while (unlikely(!temp)); } /* @@ -58,26 +57,25 @@ static __inline__ void atomic_add(int i, atomic_t * v) * * Atomically subtracts @i from @v. */ -static __inline__ void atomic_sub(int i, atomic_t * v) +static __inline__ void atomic_sub(int i, atomic_t *v) { - int temp; + int temp; - do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %0, %1 # atomic_sub \n" - " subu %0, %2 \n" - " sc %0, %1 \n" - " .set mips0 \n" - : "=&r" (temp), "+m" (*v) - : "Ir" (i)); - } while (unlikely(!temp)); + do { + __asm__ __volatile__(" .set mips3 \n" + " ll %0, %1 # atomic_sub \n" + " subu %0, %2 \n" + " sc %0, %1 \n" + " .set mips0 \n" + : "=&r"(temp), "+m"(*v) + : "Ir"(i)); + } while (unlikely(!temp)); } /* * Same as above, but return the result value */ -static __inline__ int atomic_add_return(int i, atomic_t * v) +static __inline__ int atomic_add_return(int i, atomic_t *v) { int result; int temp; @@ -85,14 +83,13 @@ static __inline__ int atomic_add_return(int i, atomic_t * v) smp_mb__before_llsc(); do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %1, %2 # atomic_add_return \n" - " addu %0, %1, %3 \n" - " sc %0, %2 \n" - " .set mips0 \n" - : "=&r" (result), "=&r" (temp), "+m" (*v) - : "Ir" (i)); + __asm__ __volatile__(" .set mips3 \n" + " ll %1, %2 # atomic_add_return \n" + " addu %0, %1, %3 \n" + " sc %0, %2 \n" + " .set mips0 \n" + : "=&r"(result), "=&r"(temp), "+m"(*v) + : "Ir"(i)); } while (unlikely(!result)); result = temp + i; @@ -102,7 +99,7 @@ static __inline__ int atomic_add_return(int i, atomic_t * v) return result; } -static __inline__ int atomic_sub_return(int i, atomic_t * v) +static __inline__ int atomic_sub_return(int i, atomic_t *v) { int result; int temp; @@ -110,14 +107,13 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v) smp_mb__before_llsc(); do { - __asm__ __volatile__( - " .set mips3 \n" - " ll %1, %2 # atomic_sub_return \n" - " subu %0, %1, %3 \n" - " sc %0, %2 \n" - " .set mips0 \n" - : "=&r" (result), "=&r" (temp), "+m" (*v) - : "Ir" (i)); + __asm__ __volatile__(" .set mips3 \n" + " ll %1, %2 # atomic_sub_return \n" + " subu %0, %1, %3 \n" + " sc %0, %2 \n" + " .set mips0 \n" + : "=&r"(result), "=&r"(temp), "+m"(*v) + : "Ir"(i)); } while (unlikely(!result)); result = temp - i; @@ -128,9 +124,15 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v) } #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n))) -#define atomic_dec_return(v) atomic_sub_return(1, (v)) -#define atomic_inc_return(v) atomic_add_return(1, (v)) +#define atomic_dec_return(v) atomic_sub_return(1, (v)) +#define atomic_inc_return(v) atomic_add_return(1, (v)) -static inline unsigned int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } -static inline unsigned int atomic_dec(atomic_t *v) { return atomic_sub_return(1, v) + 1; } +static inline unsigned int atomic_inc(atomic_t *v) +{ + return atomic_add_return(1, v) - 1; +} +static inline unsigned int atomic_dec(atomic_t *v) +{ + return atomic_sub_return(1, v) + 1; +} #endif /* __CR_ATOMIC_H__ */ diff --git a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h index bd14cc059..fc52160e8 100644 --- a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h +++ b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h @@ -8,10 +8,13 @@ */ typedef uint32_t atomic_t; -#define PPC_ATOMIC_ENTRY_BARRIER "lwsync \n" -#define PPC_ATOMIC_EXIT_BARRIER "sync \n" +#define PPC_ATOMIC_ENTRY_BARRIER "lwsync \n" +#define PPC_ATOMIC_EXIT_BARRIER "sync \n" -#define ATOMIC_INIT(i) { (i) } +#define ATOMIC_INIT(i) \ + { \ + (i) \ + } static __inline__ int atomic_get(const atomic_t *v) { @@ -27,20 +30,18 @@ static __inline__ void atomic_set(atomic_t *v, int i) __asm__ __volatile__("stw%U0%X0 %1,%0" : "=m"(*v) : "r"(i)); } -#define ATOMIC_OP(op, asm_op) \ -static __inline__ void atomic_##op(int a, atomic_t *v) \ -{ \ - int t; \ - \ - __asm__ __volatile__( \ -"1: lwarx %0,0,%3 # atomic_" #op "\n" \ - #asm_op " %0,%2,%0\n" \ -" stwcx. %0,0,%3 \n" \ -" bne- 1b\n" \ - : "=&r" (t), "+m" (*v) \ - : "r" (a), "r" (v) \ - : "cc"); \ -} \ +#define ATOMIC_OP(op, asm_op) \ + static __inline__ void atomic_##op(int a, atomic_t *v) \ + { \ + int t; \ + \ + __asm__ __volatile__("1: lwarx %0,0,%3 # atomic_" #op "\n" #asm_op " %0,%2,%0\n" \ + " stwcx. %0,0,%3 \n" \ + " bne- 1b\n" \ + : "=&r"(t), "+m"(*v) \ + : "r"(a), "r"(v) \ + : "cc"); \ + } ATOMIC_OP(add, add) ATOMIC_OP(sub, subf) @@ -51,16 +52,13 @@ static __inline__ int atomic_inc_return(atomic_t *v) { int t; - __asm__ __volatile__( - PPC_ATOMIC_ENTRY_BARRIER \ -"1: lwarx %0,0,%1 # atomic_inc_return\n\ + __asm__ __volatile__(PPC_ATOMIC_ENTRY_BARRIER "1: lwarx %0,0,%1 # atomic_inc_return\n\ addic %0,%0,1\n" -" stwcx. %0,0,%1 \n\ - bne- 1b \n" \ - PPC_ATOMIC_EXIT_BARRIER - : "=&r" (t) - : "r" (v) - : "cc", "xer", "memory"); + " stwcx. %0,0,%1 \n\ + bne- 1b \n" PPC_ATOMIC_EXIT_BARRIER + : "=&r"(t) + : "r"(v) + : "cc", "xer", "memory"); return t; } @@ -74,14 +72,13 @@ static __inline__ void atomic_dec(atomic_t *v) { int t; - __asm__ __volatile__( -"1: lwarx %0,0,%2 # atomic_dec\n\ + __asm__ __volatile__("1: lwarx %0,0,%2 # atomic_dec\n\ addic %0,%0,-1\n" -" stwcx. %0,0,%2\n\ + " stwcx. %0,0,%2\n\ bne- 1b" - : "=&r" (t), "+m" (*v) - : "r" (v) - : "cc", "xer"); + : "=&r"(t), "+m"(*v) + : "r"(v) + : "cc", "xer"); } #endif /* __CR_ATOMIC_H__ */ diff --git a/test/zdtm/lib/arch/s390/include/asm/atomic.h b/test/zdtm/lib/arch/s390/include/asm/atomic.h index b7c4b2c53..4472501ff 100644 --- a/test/zdtm/lib/arch/s390/include/asm/atomic.h +++ b/test/zdtm/lib/arch/s390/include/asm/atomic.h @@ -5,23 +5,22 @@ typedef uint32_t atomic_t; -#define __ATOMIC_OP(op_name, op_type, op_string) \ -static inline op_type op_name(op_type val, op_type *ptr) \ -{ \ - op_type old, new; \ - \ - asm volatile( \ - "0: lr %[new],%[old]\n" \ - op_string " %[new],%[val]\n" \ - " cs %[old],%[new],%[ptr]\n" \ - " jl 0b" \ - : [old] "=d" (old), [new] "=&d" (new), [ptr] "+Q" (*ptr)\ - : [val] "d" (val), "0" (*ptr) : "cc", "memory"); \ - return old; \ -} +#define __ATOMIC_OP(op_name, op_type, op_string) \ + static inline op_type op_name(op_type val, op_type *ptr) \ + { \ + op_type old, new; \ + \ + asm volatile("0: lr %[new],%[old]\n" op_string " %[new],%[val]\n" \ + " cs %[old],%[new],%[ptr]\n" \ + " jl 0b" \ + : [old] "=d"(old), [new] "=&d"(new), [ptr] "+Q"(*ptr) \ + : [val] "d"(val), "0"(*ptr) \ + : "cc", "memory"); \ + return old; \ + } -#define __ATOMIC_OPS(op_name, op_type, op_string) \ - __ATOMIC_OP(op_name, op_type, op_string) \ +#define __ATOMIC_OPS(op_name, op_type, op_string) \ + __ATOMIC_OP(op_name, op_type, op_string) \ __ATOMIC_OP(op_name##_barrier, op_type, op_string) __ATOMIC_OPS(__atomic_add, uint32_t, "ar") @@ -33,17 +32,13 @@ static inline int atomic_get(const atomic_t *v) { int c; - asm volatile( - " l %0,%1\n" - : "=d" (c) : "Q" (*v)); + asm volatile(" l %0,%1\n" : "=d"(c) : "Q"(*v)); return c; } static inline void atomic_set(atomic_t *v, int i) { - asm volatile( - " st %1,%0\n" - : "=Q" (*v) : "d" (i)); + asm volatile(" st %1,%0\n" : "=Q"(*v) : "d"(i)); } static inline int atomic_add_return(int i, atomic_t *v) @@ -56,13 +51,13 @@ static inline void atomic_add(int i, atomic_t *v) __atomic_add(i, v); } -#define atomic_sub(_i, _v) atomic_add(-(int)(_i), _v) +#define atomic_sub(_i, _v) atomic_add(-(int)(_i), _v) static inline int atomic_inc(atomic_t *v) { return atomic_add_return(1, v) - 1; } -#define atomic_dec(_v) atomic_sub(1, _v) +#define atomic_dec(_v) atomic_sub(1, _v) #endif /* __ARCH_S390_ATOMIC__ */ diff --git a/test/zdtm/lib/arch/x86/include/asm/atomic.h b/test/zdtm/lib/arch/x86/include/asm/atomic.h index 7621df09c..40a9c1836 100644 --- a/test/zdtm/lib/arch/x86/include/asm/atomic.h +++ b/test/zdtm/lib/arch/x86/include/asm/atomic.h @@ -1,49 +1,29 @@ #ifndef ATOMIC_H__ #define ATOMIC_H__ -#define atomic_set(mem, v) \ - ({ \ - asm volatile ("lock xchg %0, %1\n" \ - : "+r" (v), "+m" (*mem) \ - : \ - : "cc", "memory"); \ +#define atomic_set(mem, v) ({ asm volatile("lock xchg %0, %1\n" : "+r"(v), "+m"(*mem) : : "cc", "memory"); }) + +#define atomic_get(mem) \ + ({ \ + uint32_t ret__ = 0; \ + asm volatile("lock xadd %0, %1\n" : "+r"(ret__), "+m"(*mem) : : "cc", "memory"); \ + ret__; \ }) -#define atomic_get(mem) \ - ({ \ - uint32_t ret__ = 0; \ - asm volatile ("lock xadd %0, %1\n" \ - : "+r" (ret__), "+m" (*mem) \ - : \ - : "cc", "memory"); \ - ret__; \ +#define atomic_inc(mem) \ + ({ \ + uint32_t ret__ = 1; \ + asm volatile("lock xadd %0, %1\n" : "+r"(ret__), "+m"(*mem) : : "cc", "memory"); \ + ret__; \ }) -#define atomic_inc(mem) \ - ({ \ - uint32_t ret__ = 1; \ - asm volatile ("lock xadd %0, %1\n" \ - : "+r" (ret__), "+m" (*mem) \ - : \ - : "cc", "memory"); \ - ret__; \ +#define atomic_dec(mem) \ + ({ \ + uint32_t ret__ = -1; \ + asm volatile("lock xadd %0, %1\n" : "+r"(ret__), "+m"(*mem) : : "cc", "memory"); \ + ret__; \ }) -#define atomic_dec(mem) \ - ({ \ - uint32_t ret__ = -1; \ - asm volatile ("lock xadd %0, %1\n" \ - : "+r" (ret__), "+m" (*mem) \ - : \ - : "cc", "memory"); \ - ret__; \ - }) - -#define atomic_add(i, mem) \ -({ \ - asm volatile("lock addl %1,%0" \ - : "+m" (*mem) \ - : "ir" (i)); \ -}) +#define atomic_add(i, mem) ({ asm volatile("lock addl %1,%0" : "+m"(*mem) : "ir"(i)); }) #endif /* ATOMIC_H__ */ diff --git a/test/zdtm/lib/bpfmap_zdtm.h b/test/zdtm/lib/bpfmap_zdtm.h index b8b1ecd0b..75b494c51 100644 --- a/test/zdtm/lib/bpfmap_zdtm.h +++ b/test/zdtm/lib/bpfmap_zdtm.h @@ -3,17 +3,17 @@ #include "zdtmtst.h" -#define fdinfo_field(str, field) !strncmp(str, field":", sizeof(field)) +#define fdinfo_field(str, field) !strncmp(str, field ":", sizeof(field)) struct bpfmap_fdinfo_obj { - uint32_t map_type; - uint32_t key_size; - uint32_t value_size; - uint32_t max_entries; - uint32_t map_flags; - uint64_t memlock; - uint32_t map_id; - uint32_t frozen; + uint32_t map_type; + uint32_t key_size; + uint32_t value_size; + uint32_t max_entries; + uint32_t map_flags; + uint64_t memlock; + uint32_t map_id; + uint32_t frozen; }; extern int parse_bpfmap_fdinfo(int, struct bpfmap_fdinfo_obj *, uint32_t); diff --git a/test/zdtm/lib/cpuid.h b/test/zdtm/lib/cpuid.h index f87d1acb7..0acae6fe9 100644 --- a/test/zdtm/lib/cpuid.h +++ b/test/zdtm/lib/cpuid.h @@ -5,30 +5,20 @@ * Adopted from linux kernel code. */ -static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { /* ecx is often an input as well as an output. */ - asm volatile("cpuid" - : "=a" (*eax), - "=b" (*ebx), - "=c" (*ecx), - "=d" (*edx) - : "0" (*eax), "2" (*ecx) - : "memory"); + asm volatile("cpuid" : "=a"(*eax), "=b"(*ebx), "=c"(*ecx), "=d"(*edx) : "0"(*eax), "2"(*ecx) : "memory"); } -static inline void cpuid(unsigned int op, - unsigned int *eax, unsigned int *ebx, - unsigned int *ecx, unsigned int *edx) +static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { *eax = op; *ecx = 0; native_cpuid(eax, ebx, ecx, edx); } -static inline void cpuid_count(unsigned int op, unsigned int count, - unsigned int *eax, unsigned int *ebx, +static inline void cpuid_count(unsigned int op, unsigned int count, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) { *eax = op; diff --git a/test/zdtm/lib/fs.h b/test/zdtm/lib/fs.h index af7a665fb..315fe71be 100644 --- a/test/zdtm/lib/fs.h +++ b/test/zdtm/lib/fs.h @@ -2,7 +2,7 @@ #define ZDTM_FS_H_ #ifndef _BSD_SOURCE -# define _BSD_SOURCE +#define _BSD_SOURCE #endif #include @@ -10,9 +10,9 @@ #include -#define KDEV_MINORBITS 20 -#define KDEV_MINORMASK ((1UL << KDEV_MINORBITS) - 1) -#define MKKDEV(ma, mi) (((ma) << KDEV_MINORBITS) | (mi)) +#define KDEV_MINORBITS 20 +#define KDEV_MINORMASK ((1UL << KDEV_MINORBITS) - 1) +#define MKKDEV(ma, mi) (((ma) << KDEV_MINORBITS) | (mi)) static inline unsigned int kdev_major(unsigned int kdev) { @@ -38,12 +38,12 @@ static inline dev_t kdev_to_odev(unsigned int kdev) } typedef struct { - int mnt_id; - int parent_mnt_id; - unsigned int s_dev; - char root[PATH_MAX]; - char mountpoint[PATH_MAX]; - char fsname[64]; + int mnt_id; + int parent_mnt_id; + unsigned int s_dev; + char root[PATH_MAX]; + char mountpoint[PATH_MAX]; + char fsname[64]; } mnt_info_t; extern mnt_info_t *mnt_info_alloc(void); diff --git a/test/zdtm/lib/lock.h b/test/zdtm/lib/lock.h index 9c0831d46..2b23550be 100644 --- a/test/zdtm/lib/lock.h +++ b/test/zdtm/lib/lock.h @@ -9,22 +9,22 @@ #include #include "asm/atomic.h" -#define BUG_ON(condition) \ - do { \ - if ((condition)) { \ - raise(SIGABRT); \ +#define BUG_ON(condition) \ + do { \ + if ((condition)) { \ + raise(SIGABRT); \ *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__; \ - } \ + } \ } while (0) typedef struct { - uint32_t raw; + uint32_t raw; } futex_t; -#define FUTEX_ABORT_FLAG (0x80000000) -#define FUTEX_ABORT_RAW (-1U) +#define FUTEX_ABORT_FLAG (0x80000000) +#define FUTEX_ABORT_RAW (-1U) -static inline int sys_futex(uint32_t *uaddr, int op, uint32_t val, const struct timespec *timeout, - uint32_t *uaddr2, uint32_t val3) +static inline int sys_futex(uint32_t *uaddr, int op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, + uint32_t val3) { return syscall(__NR_futex, uaddr, op, val, timeout, uaddr2, val3); } @@ -48,26 +48,23 @@ static inline void futex_add_and_wake(futex_t *f, uint32_t v) BUG_ON(sys_futex(&f->raw, FUTEX_WAKE, INT_MAX, NULL, NULL, 0) < 0); } - -#define futex_init(f) futex_set(f, 0) +#define futex_init(f) futex_set(f, 0) /* Wait on futex @__f value @__v become in condition @__c */ -#define futex_wait_if_cond(__f, __v, __cond) \ - do { \ - int ret; \ - uint32_t tmp; \ - \ - while (1) { \ - tmp = (__f)->raw; \ - if ((tmp & FUTEX_ABORT_FLAG) || \ - (tmp __cond (__v))) \ - break; \ - ret = sys_futex(&(__f)->raw, FUTEX_WAIT,\ - tmp, NULL, NULL, 0); \ - if (ret < 0 && (errno == EAGAIN || errno == EINTR)) \ - continue; \ - BUG_ON(ret < 0 && errno != EWOULDBLOCK); \ - } \ +#define futex_wait_if_cond(__f, __v, __cond) \ + do { \ + int ret; \ + uint32_t tmp; \ + \ + while (1) { \ + tmp = (__f)->raw; \ + if ((tmp & FUTEX_ABORT_FLAG) || (tmp __cond(__v))) \ + break; \ + ret = sys_futex(&(__f)->raw, FUTEX_WAIT, tmp, NULL, NULL, 0); \ + if (ret < 0 && (errno == EAGAIN || errno == EINTR)) \ + continue; \ + BUG_ON(ret < 0 && errno != EWOULDBLOCK); \ + } \ } while (0) /* Set futex @f to @v and wake up all waiters */ @@ -98,22 +95,34 @@ static inline void futex_inc_and_wake(futex_t *f) } /* Plain increment futex @f value */ -static inline void futex_inc(futex_t *f) { atomic_inc(&f->raw); } +static inline void futex_inc(futex_t *f) +{ + atomic_inc(&f->raw); +} /* Plain decrement futex @f value */ -static inline void futex_dec(futex_t *f) { atomic_dec(&f->raw); } +static inline void futex_dec(futex_t *f) +{ + atomic_dec(&f->raw); +} /* Wait until futex @f value become @v */ static inline void futex_wait_until(futex_t *f, uint32_t v) -{ futex_wait_if_cond(f, v, ==); } +{ + futex_wait_if_cond(f, v, ==); +} /* Wait while futex @f value is greater than @v */ static inline void futex_wait_while_gt(futex_t *f, uint32_t v) -{ futex_wait_if_cond(f, v, <=); } +{ + futex_wait_if_cond(f, v, <=); +} /* Wait while futex @f value is less than @v */ static inline void futex_wait_while_lt(futex_t *f, uint32_t v) -{ futex_wait_if_cond(f, v, >=); } +{ + futex_wait_if_cond(f, v, >=); +} /* Wait while futex @f value is @v */ static inline uint32_t futex_wait_while(futex_t *f, uint32_t v) { @@ -128,7 +137,7 @@ static inline uint32_t futex_wait_while(futex_t *f, uint32_t v) } typedef struct { - uint32_t raw; + uint32_t raw; } mutex_t; static void inline mutex_init(mutex_t *m) diff --git a/test/zdtm/lib/zdtmtst.h b/test/zdtm/lib/zdtmtst.h index ec6c110a2..c6d77011d 100644 --- a/test/zdtm/lib/zdtmtst.h +++ b/test/zdtm/lib/zdtmtst.h @@ -9,11 +9,11 @@ #define INPROGRESS ".inprogress" #ifndef PAGE_SIZE -# define PAGE_SIZE (unsigned int)(sysconf(_SC_PAGESIZE)) +#define PAGE_SIZE (unsigned int)(sysconf(_SC_PAGESIZE)) #endif #ifndef PR_SET_CHILD_SUBREAPER -# define PR_SET_CHILD_SUBREAPER 36 +#define PR_SET_CHILD_SUBREAPER 36 #endif /* set up test */ @@ -28,15 +28,14 @@ extern void test_init(int argc, char **argv); #define CLONE_NEWIPC 0x08000000 #endif -#define TEST_MSG_BUFFER_SIZE 2048 +#define TEST_MSG_BUFFER_SIZE 2048 /*wrapper for fork: init log offset*/ #define test_fork() test_fork_id(-1) extern int test_fork_id(int id); /* finish setting up the test, write out pid file, and go to background */ extern void test_daemon(void); /* store a message to a static buffer */ -extern void test_msg(const char *format, ...) - __attribute__ ((__format__ (__printf__, 1, 2))); +extern void test_msg(const char *format, ...) __attribute__((__format__(__printf__, 1, 2))); /* tell if SIGTERM hasn't been received yet */ extern int test_go(void); /* sleep until SIGTERM is delivered */ @@ -77,16 +76,21 @@ struct long_opt { extern void __push_opt(struct long_opt *opt); -#define TEST_OPTION(name, type, doc, is_required) \ - param_check_##type(name, &(name)); \ - static struct long_opt __long_opt_##name = { \ - #name, #type, doc, is_required, parse_opt_##type, &name }; \ - static void __init_opt_##name(void) __attribute__ ((constructor)); \ - static void __init_opt_##name(void) \ - { (void)__check_##name; __push_opt(&__long_opt_##name); } +#define TEST_OPTION(name, type, doc, is_required) \ + param_check_##type(name, &(name)); \ + static struct long_opt __long_opt_##name = { #name, #type, doc, is_required, parse_opt_##type, &name }; \ + static void __init_opt_##name(void) __attribute__((constructor)); \ + static void __init_opt_##name(void) \ + { \ + (void)__check_##name; \ + __push_opt(&__long_opt_##name); \ + } -#define __param_check(name, p, type) \ - static inline type *__check_##name(void) { return(p); } +#define __param_check(name, p, type) \ + static inline type *__check_##name(void) \ + { \ + return (p); \ + } #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -110,34 +114,29 @@ extern int write_pidfile(int pid); #include #include -#define __stringify_1(x) #x -#define __stringify(x) __stringify_1(x) +#define __stringify_1(x) #x +#define __stringify(x) __stringify_1(x) /* * Macro to define stack alignment. * aarch64 requires stack to be aligned to 16 bytes. */ -#define __stack_aligned__ __attribute__((aligned(16))) +#define __stack_aligned__ __attribute__((aligned(16))) /* message helpers */ extern int test_log_init(const char *outfile, const char *suffix); extern int zdtm_seccomp; -#define pr_err(format, arg...) \ - test_msg("ERR: %s:%d: " format, __FILE__, __LINE__, ## arg) -#define pr_perror(format, arg...) \ - test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", \ - __FILE__, __LINE__, ## arg, errno, strerror(errno)) -#define fail(format, arg...) \ - test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", \ - __FILE__, __LINE__, ## arg, errno, strerror(errno)) -#define skip(format, arg...) \ - test_msg("SKIP: %s:%d: " format "\n", \ - __FILE__, __LINE__, ## arg) -#define pass() test_msg("PASS\n") +#define pr_err(format, arg...) test_msg("ERR: %s:%d: " format, __FILE__, __LINE__, ##arg) +#define pr_perror(format, arg...) \ + test_msg("ERR: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, strerror(errno)) +#define fail(format, arg...) \ + test_msg("FAIL: %s:%d: " format " (errno = %d (%s))\n", __FILE__, __LINE__, ##arg, errno, strerror(errno)) +#define skip(format, arg...) test_msg("SKIP: %s:%d: " format "\n", __FILE__, __LINE__, ##arg) +#define pass() test_msg("PASS\n") typedef struct { - unsigned long seed; - int pipes[2]; + unsigned long seed; + int pipes[2]; } task_waiter_t; extern void task_waiter_init(task_waiter_t *t); @@ -163,16 +162,17 @@ extern const char *test_author; extern const char *test_doc; extern int tcp_init_server_with_opts(int family, int *port, struct zdtm_tcp_opts *opts); -extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, - void *child_tid, unsigned long newtls); +extern pid_t sys_clone_unified(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid, + unsigned long newtls); -#define ssprintf(s, fmt, ...) ({ \ - int ___ret; \ - \ - ___ret = snprintf(s, sizeof(s), fmt, ##__VA_ARGS__); \ - if (___ret >= sizeof(s)) \ - abort(); \ - ___ret; \ -}) +#define ssprintf(s, fmt, ...) \ + ({ \ + int ___ret; \ + \ + ___ret = snprintf(s, sizeof(s), fmt, ##__VA_ARGS__); \ + if (___ret >= sizeof(s)) \ + abort(); \ + ___ret; \ + }) #endif /* _VIMITESU_H_ */ diff --git a/test/zdtm/static/auto_dev-ioctl.h b/test/zdtm/static/auto_dev-ioctl.h index aeaeb3ea7..e65259b30 100644 --- a/test/zdtm/static/auto_dev-ioctl.h +++ b/test/zdtm/static/auto_dev-ioctl.h @@ -18,69 +18,69 @@ #include #endif /* __KERNEL__ */ -#define AUTOFS_DEVICE_NAME "autofs" +#define AUTOFS_DEVICE_NAME "autofs" -#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1 -#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0 +#define AUTOFS_DEV_IOCTL_VERSION_MAJOR 1 +#define AUTOFS_DEV_IOCTL_VERSION_MINOR 0 -#define AUTOFS_DEVID_LEN 16 +#define AUTOFS_DEVID_LEN 16 -#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_SIZE sizeof(struct autofs_dev_ioctl) /* * An ioctl interface for autofs mount point control. */ struct args_protover { - __u32 version; + __u32 version; }; struct args_protosubver { - __u32 sub_version; + __u32 sub_version; }; struct args_openmount { - __u32 devid; + __u32 devid; }; struct args_ready { - __u32 token; + __u32 token; }; struct args_fail { - __u32 token; - __s32 status; + __u32 token; + __s32 status; }; struct args_setpipefd { - __s32 pipefd; + __s32 pipefd; }; struct args_timeout { - __u64 timeout; + __u64 timeout; }; struct args_requester { - __u32 uid; - __u32 gid; + __u32 uid; + __u32 gid; }; struct args_expire { - __u32 how; + __u32 how; }; struct args_askumount { - __u32 may_umount; + __u32 may_umount; }; struct args_ismountpoint { union { struct args_in { - __u32 type; + __u32 type; } in; struct args_out { - __u32 devid; - __u32 magic; + __u32 devid; + __u32 magic; } out; }; }; @@ -95,30 +95,31 @@ struct args_ismountpoint { struct autofs_dev_ioctl { __u32 ver_major; __u32 ver_minor; - __u32 size; /* total size of data passed in + __u32 size; /* total size of data passed in * including this struct */ - __s32 ioctlfd; /* automount command fd */ + __s32 ioctlfd; /* automount command fd */ /* Command parameters */ union { - struct args_protover protover; - struct args_protosubver protosubver; - struct args_openmount openmount; - struct args_ready ready; - struct args_fail fail; - struct args_setpipefd setpipefd; - struct args_timeout timeout; - struct args_requester requester; - struct args_expire expire; - struct args_askumount askumount; - struct args_ismountpoint ismountpoint; + struct args_protover protover; + struct args_protosubver protosubver; + struct args_openmount openmount; + struct args_ready ready; + struct args_fail fail; + struct args_setpipefd setpipefd; + struct args_timeout timeout; + struct args_requester requester; + struct args_expire expire; + struct args_askumount askumount; + struct args_ismountpoint ismountpoint; }; char path[0]; }; -static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in) { +static inline void init_autofs_dev_ioctl(struct autofs_dev_ioctl *in) +{ memset(in, 0, sizeof(struct autofs_dev_ioctl)); in->ver_major = AUTOFS_DEV_IOCTL_VERSION_MAJOR; in->ver_minor = AUTOFS_DEV_IOCTL_VERSION_MINOR; @@ -169,60 +170,32 @@ enum { #define AUTOFS_IOCTL 0x93 -#define AUTOFS_DEV_IOCTL_VERSION \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_VERSION _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_VERSION_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_PROTOVER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_PROTOVER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_PROTOVER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_PROTOSUBVER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_PROTOSUBVER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_PROTOSUBVER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_OPENMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_OPENMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_OPENMOUNT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_CLOSEMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_CLOSEMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_CLOSEMOUNT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_READY \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_READY _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_READY_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_FAIL \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_FAIL _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_FAIL_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_SETPIPEFD \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_SETPIPEFD _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_SETPIPEFD_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_CATATONIC \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_CATATONIC _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_CATATONIC_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_TIMEOUT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_TIMEOUT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_TIMEOUT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_REQUESTER \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_REQUESTER _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_REQUESTER_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_EXPIRE \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_EXPIRE _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_EXPIRE_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_ASKUMOUNT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_ASKUMOUNT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_ASKUMOUNT_CMD, struct autofs_dev_ioctl) -#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT \ - _IOWR(AUTOFS_IOCTL, \ - AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl) +#define AUTOFS_DEV_IOCTL_ISMOUNTPOINT _IOWR(AUTOFS_IOCTL, AUTOFS_DEV_IOCTL_ISMOUNTPOINT_CMD, struct autofs_dev_ioctl) -#endif /* _LINUX_AUTO_DEV_IOCTL_H */ +#endif /* _LINUX_AUTO_DEV_IOCTL_H */ diff --git a/test/zdtm/static/ofd_file_locks.h b/test/zdtm/static/ofd_file_locks.h index 1b206a238..99095d648 100644 --- a/test/zdtm/static/ofd_file_locks.h +++ b/test/zdtm/static/ofd_file_locks.h @@ -4,9 +4,9 @@ #include #ifndef F_OFD_GETLK -#define F_OFD_GETLK 36 -#define F_OFD_SETLK 37 -#define F_OFD_SETLKW 38 +#define F_OFD_GETLK 36 +#define F_OFD_SETLK 37 +#define F_OFD_SETLKW 38 #endif /*