From 33e6450b35b8dc1e537e3c5b9a26cdafba6f08bb Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 30 Dec 2020 17:46:26 +0100 Subject: executor: fix kcov_remote_arg declaration kcov_remote_arg was changed to a portable format so we don't need to handle differences between 64/32-bits anymore. --- executor/executor_linux.h | 59 +++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 41 deletions(-) (limited to 'executor') diff --git a/executor/executor_linux.h b/executor/executor_linux.h index 9de1b1c40..e66c92e3d 100644 --- a/executor/executor_linux.h +++ b/executor/executor_linux.h @@ -14,35 +14,21 @@ const unsigned long KCOV_TRACE_PC = 0; const unsigned long KCOV_TRACE_CMP = 1; -template +template struct kcov_remote_arg { - unsigned trace_mode; - unsigned area_size; - unsigned num_handles; - kernel_u64_t common_handle; - kernel_u64_t handles[N]; + uint32 trace_mode; + uint32 area_size; + uint32 num_handles; + uint32 pad; + uint64 common_handle; + uint64 handles[N]; }; -struct uint64_aligned64 { - uint64 v; -} __attribute__((aligned(8))); - -struct uint64_aligned32 { - uint64 v; -} __attribute__((packed, aligned(4))); - -typedef kcov_remote_arg kcov_remote_arg32; -typedef kcov_remote_arg kcov_remote_arg64; - -typedef char kcov_remote_arg32_size[sizeof(kcov_remote_arg32) == 20 ? 1 : -1]; -typedef char kcov_remote_arg64_size[sizeof(kcov_remote_arg64) == 24 ? 1 : -1]; - #define KCOV_INIT_TRACE32 _IOR('c', 1, uint32) #define KCOV_INIT_TRACE64 _IOR('c', 1, uint64) #define KCOV_ENABLE _IO('c', 100) #define KCOV_DISABLE _IO('c', 101) -#define KCOV_REMOTE_ENABLE32 _IOW('c', 102, kcov_remote_arg32) -#define KCOV_REMOTE_ENABLE64 _IOW('c', 102, kcov_remote_arg64) +#define KCOV_REMOTE_ENABLE _IOW('c', 102, kcov_remote_arg<0>) #define KCOV_SUBSYSTEM_COMMON (0x00ull << 56) #define KCOV_SUBSYSTEM_USB (0x01ull << 56) @@ -115,21 +101,6 @@ static void cover_unprotect(cover_t* cov) { } -template -static void enable_remote_cover(cover_t* cov, unsigned long ioctl_cmd, unsigned int kcov_mode) -{ - kcov_remote_arg arg = { - .trace_mode = kcov_mode, - }; - // Coverage buffer size of background threads. - arg.area_size = kExtraCoverSize; - arg.num_handles = 1; - arg.handles[0].v = kcov_remote_handle(KCOV_SUBSYSTEM_USB, procid + 1); - arg.common_handle.v = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, procid + 1); - if (ioctl(cov->fd, ioctl_cmd, &arg)) - exitf("remote cover enable write trace failed"); -} - static void cover_enable(cover_t* cov, bool collect_comps, bool extra) { unsigned int kcov_mode = collect_comps ? KCOV_TRACE_CMP : KCOV_TRACE_PC; @@ -141,10 +112,16 @@ static void cover_enable(cover_t* cov, bool collect_comps, bool extra) exitf("cover enable write trace failed, mode=%d", kcov_mode); return; } - if (is_kernel_64_bit) - enable_remote_cover(cov, KCOV_REMOTE_ENABLE64, kcov_mode); - else - enable_remote_cover(cov, KCOV_REMOTE_ENABLE32, kcov_mode); + kcov_remote_arg<1> arg = { + .trace_mode = kcov_mode, + // Coverage buffer size of background threads. + .area_size = kExtraCoverSize, + .num_handles = 1, + }; + arg.common_handle = kcov_remote_handle(KCOV_SUBSYSTEM_COMMON, procid + 1); + arg.handles[0] = kcov_remote_handle(KCOV_SUBSYSTEM_USB, procid + 1); + if (ioctl(cov->fd, KCOV_REMOTE_ENABLE, &arg)) + exitf("remote cover enable write trace failed"); } static void cover_reset(cover_t* cov) -- cgit mrf-deployment