"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "linux/perf.c" between
honggfuzz-2.1.tar.gz and honggfuzz-2.2.tar.gz

About: honggfuzz is a security oriented, feedback-driven, evolutionary, easy-to-use fuzzer with powerful analysis options.

perf.c  (honggfuzz-2.1):perf.c  (honggfuzz-2.2)
skipping to change at line 57 skipping to change at line 57
#include "pt.h" #include "pt.h"
#define _HF_PERF_MAP_SZ (1024 * 512) #define _HF_PERF_MAP_SZ (1024 * 512)
#define _HF_PERF_AUX_SZ (1024 * 1024) #define _HF_PERF_AUX_SZ (1024 * 1024)
/* PERF_TYPE for Intel_PT/BTS -1 if none */ /* PERF_TYPE for Intel_PT/BTS -1 if none */
static int32_t perfIntelPtPerfType = -1; static int32_t perfIntelPtPerfType = -1;
static int32_t perfIntelBtsPerfType = -1; static int32_t perfIntelBtsPerfType = -1;
#if defined(PERF_ATTR_SIZE_VER5) #if defined(PERF_ATTR_SIZE_VER5)
__attribute__((hot)) static inline void arch_perfBtsCount(run_t* run) { __attribute__((hot)) static inline void arch_perfBtsCount(run_t* run) {
struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->linux. perfMmapBuf; struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->arch_l inux.perfMmapBuf;
struct bts_branch { struct bts_branch {
uint64_t from; uint64_t from;
uint64_t to; uint64_t to;
uint64_t misc; uint64_t misc;
}; };
uint64_t aux_head = ATOMIC_GET(pem->aux_head); uint64_t aux_head = ATOMIC_GET(pem->aux_head);
struct bts_branch* br = (struct bts_branch*)run->linux.perfMmapAux; struct bts_branch* br = (struct bts_branch*)run->arch_linux.perfMmapAux;
for (; br < ((struct bts_branch*)(run->linux.perfMmapAux + aux_head)); br++) for (; br < ((struct bts_branch*)(run->arch_linux.perfMmapAux + aux_head));
{ br++) {
/* /*
* Kernel sometimes reports branches from the kernel (iret), we are not interested in that * Kernel sometimes reports branches from the kernel (iret), we are not interested in that
* as it makes the whole concept of unique branch counting less predicta ble * as it makes the whole concept of unique branch counting less predicta ble
*/ */
if (run->global->linux.kernelOnly == false && if (run->global->arch_linux.kernelOnly == false &&
(__builtin_expect(br->from > 0xFFFFFFFF00000000, false) || (__builtin_expect(br->from > 0xFFFFFFFF00000000, false) ||
__builtin_expect(br->to > 0xFFFFFFFF00000000, false))) { __builtin_expect(br->to > 0xFFFFFFFF00000000, false))) {
LOG_D("Adding branch %#018" PRIx64 " - %#018" PRIx64, br->from, br-> to); LOG_D("Adding branch %#018" PRIx64 " - %#018" PRIx64, br->from, br-> to);
continue; continue;
} }
if (br->from >= run->global->linux.dynamicCutOffAddr || if (br->from >= run->global->arch_linux.dynamicCutOffAddr ||
br->to >= run->global->linux.dynamicCutOffAddr) { br->to >= run->global->arch_linux.dynamicCutOffAddr) {
continue; continue;
} }
register size_t pos = ((br->from << 12) ^ (br->to & 0xFFF)); register size_t pos = ((br->from << 12) ^ (br->to & 0xFFF));
pos &= _HF_PERF_BITMAP_BITSZ_MASK; pos &= _HF_PERF_BITMAP_BITSZ_MASK;
register bool prev = ATOMIC_BITMAP_SET(run->global->feedback.covFeedback Map->bbMapPc, pos); register bool prev = ATOMIC_BITMAP_SET(run->global->feedback.covFeedback Map->bbMapPc, pos);
if (!prev) { if (!prev) {
run->linux.hwCnts.newBBCnt++; run->hwCnts.newBBCnt++;
} }
} }
} }
#endif /* defined(PERF_ATTR_SIZE_VER5) */ #endif /* defined(PERF_ATTR_SIZE_VER5) */
static inline void arch_perfMmapParse(run_t* run HF_ATTR_UNUSED) { static inline void arch_perfMmapParse(run_t* run HF_ATTR_UNUSED) {
#if defined(PERF_ATTR_SIZE_VER5) #if defined(PERF_ATTR_SIZE_VER5)
struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->linux. perfMmapBuf; struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->arch_l inux.perfMmapBuf;
if (pem->aux_head == pem->aux_tail) { if (pem->aux_head == pem->aux_tail) {
return; return;
} }
if (pem->aux_head < pem->aux_tail) { if (pem->aux_head < pem->aux_tail) {
LOG_F("The PERF AUX data has been overwritten. The AUX buffer is too sma ll"); LOG_F("The PERF AUX data has been overwritten. The AUX buffer is too sma ll");
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
arch_perfBtsCount(run); arch_perfBtsCount(run);
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
skipping to change at line 134 skipping to change at line 134
if ((method & _HF_DYNFILE_BTS_EDGE) && perfIntelBtsPerfType == -1) { if ((method & _HF_DYNFILE_BTS_EDGE) && perfIntelBtsPerfType == -1) {
LOG_F("Intel BTS events (new type) are not supported on this platform"); LOG_F("Intel BTS events (new type) are not supported on this platform");
} }
if ((method & _HF_DYNFILE_IPT_BLOCK) && perfIntelPtPerfType == -1) { if ((method & _HF_DYNFILE_IPT_BLOCK) && perfIntelPtPerfType == -1) {
LOG_F("Intel PT events are not supported on this platform"); LOG_F("Intel PT events are not supported on this platform");
} }
struct perf_event_attr pe; struct perf_event_attr pe;
memset(&pe, 0, sizeof(struct perf_event_attr)); memset(&pe, 0, sizeof(struct perf_event_attr));
pe.size = sizeof(struct perf_event_attr); pe.size = sizeof(struct perf_event_attr);
if (run->global->linux.kernelOnly) { if (run->global->arch_linux.kernelOnly) {
pe.exclude_user = 1; pe.exclude_user = 1;
} else { } else {
pe.exclude_kernel = 1; pe.exclude_kernel = 1;
} }
pe.disabled = 1; pe.disabled = 1;
if (!run->global->exe.persistent) { if (!run->global->exe.persistent) {
pe.enable_on_exec = 1; pe.enable_on_exec = 1;
} }
pe.exclude_hv = 1; pe.exclude_hv = 1;
pe.type = PERF_TYPE_HARDWARE; pe.type = PERF_TYPE_HARDWARE;
skipping to change at line 185 skipping to change at line 185
*perfFd = perf_event_open(&pe, pid, -1, -1, PERF_FLAG_FD_CLOEXEC); *perfFd = perf_event_open(&pe, pid, -1, -1, PERF_FLAG_FD_CLOEXEC);
if (*perfFd == -1) { if (*perfFd == -1) {
PLOG_E("perf_event_open() failed"); PLOG_E("perf_event_open() failed");
return false; return false;
} }
if (method != _HF_DYNFILE_BTS_EDGE && method != _HF_DYNFILE_IPT_BLOCK) { if (method != _HF_DYNFILE_BTS_EDGE && method != _HF_DYNFILE_IPT_BLOCK) {
return true; return true;
} }
#if defined(PERF_ATTR_SIZE_VER5) #if defined(PERF_ATTR_SIZE_VER5)
if ((run->linux.perfMmapBuf = mmap(NULL, _HF_PERF_MAP_SZ + getpagesize(), if ((run->arch_linux.perfMmapBuf = mmap(NULL, _HF_PERF_MAP_SZ + getpagesize( ),
PROT_READ | PROT_WRITE, MAP_SHARED, *perfFd, 0)) == MAP_FAILED) { PROT_READ | PROT_WRITE, MAP_SHARED, *perfFd, 0)) == MAP_FAILED) {
run->linux.perfMmapBuf = NULL; run->arch_linux.perfMmapBuf = NULL;
PLOG_W("mmap(mmapBuf) failed, sz=%zu, try increasing the kernel.perf_eve nt_mlock_kb sysctl " PLOG_W("mmap(mmapBuf) failed, sz=%zu, try increasing the kernel.perf_eve nt_mlock_kb sysctl "
"(up to even 300000000)", "(up to even 300000000)",
(size_t)_HF_PERF_MAP_SZ + getpagesize()); (size_t)_HF_PERF_MAP_SZ + getpagesize());
close(*perfFd); close(*perfFd);
*perfFd = -1; *perfFd = -1;
return false; return false;
} }
struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->linux. perfMmapBuf; struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->arch_l inux.perfMmapBuf;
pem->aux_offset = pem->data_offset + pem->data_size; pem->aux_offset = pem->data_offset + pem->data_size;
pem->aux_size = _HF_PERF_AUX_SZ; pem->aux_size = _HF_PERF_AUX_SZ;
if ((run->linux.perfMmapAux = mmap( if ((run->arch_linux.perfMmapAux = mmap(
NULL, pem->aux_size, PROT_READ, MAP_SHARED, *perfFd, pem->aux_offse t)) == MAP_FAILED) { NULL, pem->aux_size, PROT_READ, MAP_SHARED, *perfFd, pem->aux_offse t)) == MAP_FAILED) {
munmap(run->linux.perfMmapBuf, _HF_PERF_MAP_SZ + getpagesize()); munmap(run->arch_linux.perfMmapBuf, _HF_PERF_MAP_SZ + getpagesize());
run->linux.perfMmapBuf = NULL; run->arch_linux.perfMmapBuf = NULL;
run->linux.perfMmapAux = NULL; run->arch_linux.perfMmapAux = NULL;
PLOG_W( PLOG_W(
"mmap(mmapAuxBuf) failed, try increasing the kernel.perf_event_mlock _kb sysctl (up to " "mmap(mmapAuxBuf) failed, try increasing the kernel.perf_event_mlock _kb sysctl (up to "
"even 300000000)"); "even 300000000)");
close(*perfFd); close(*perfFd);
*perfFd = -1; *perfFd = -1;
return false; return false;
} }
#else /* defined(PERF_ATTR_SIZE_VER5) */ #else /* defined(PERF_ATTR_SIZE_VER5) */
LOG_F("Your <linux/perf_event.h> includes are too old to support Intel PT/BT S"); LOG_F("Your <linux/perf_event.h> includes are too old to support Intel PT/BT S");
#endif /* defined(PERF_ATTR_SIZE_VER5) */ #endif /* defined(PERF_ATTR_SIZE_VER5) */
return true; return true;
} }
bool arch_perfOpen(run_t* run) { bool arch_perfOpen(run_t* run) {
if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) { if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) {
return true; return true;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_INSTR_COUNT, &run->linux .cpuInstrFd)) { if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_INSTR_COUNT, &run->arch_ linux.cpuInstrFd)) {
LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_INSTR_COUNT)", (in t)run->pid); LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_INSTR_COUNT)", (in t)run->pid);
goto out; goto out;
} }
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_BRANCH_COUNT, &run->linu if (!arch_perfCreate(
x.cpuBranchFd)) { run, run->pid, _HF_DYNFILE_BRANCH_COUNT, &run->arch_linux.cpuBra
nchFd)) {
LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_BRANCH_COUNT)", (i nt)run->pid); LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_BRANCH_COUNT)", (i nt)run->pid);
goto out; goto out;
} }
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_BTS_EDGE, &run->linux.cp uIptBtsFd)) { if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_BTS_EDGE, &run->arch_lin ux.cpuIptBtsFd)) {
LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_BTS_EDGE)", (int)r un->pid); LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_BTS_EDGE)", (int)r un->pid);
goto out; goto out;
} }
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_IPT_BLOCK, &run->linux.c puIptBtsFd)) { if (!arch_perfCreate(run, run->pid, _HF_DYNFILE_IPT_BLOCK, &run->arch_li nux.cpuIptBtsFd)) {
LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_IPT_BLOCK)", (int) run->pid); LOG_E("Cannot set up perf for pid=%d (_HF_DYNFILE_IPT_BLOCK)", (int) run->pid);
goto out; goto out;
} }
} }
return true; return true;
out: out:
close(run->linux.cpuInstrFd); close(run->arch_linux.cpuInstrFd);
run->linux.cpuInstrFd = -1; run->arch_linux.cpuInstrFd = -1;
close(run->linux.cpuBranchFd); close(run->arch_linux.cpuBranchFd);
run->linux.cpuBranchFd = -1; run->arch_linux.cpuBranchFd = -1;
close(run->linux.cpuIptBtsFd); close(run->arch_linux.cpuIptBtsFd);
run->linux.cpuIptBtsFd = -1; run->arch_linux.cpuIptBtsFd = -1;
return false; return false;
} }
void arch_perfClose(run_t* run) { void arch_perfClose(run_t* run) {
if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) { if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) {
return; return;
} }
if (run->linux.perfMmapAux != NULL) { if (run->arch_linux.perfMmapAux != NULL) {
munmap(run->linux.perfMmapAux, _HF_PERF_AUX_SZ); munmap(run->arch_linux.perfMmapAux, _HF_PERF_AUX_SZ);
run->linux.perfMmapAux = NULL; run->arch_linux.perfMmapAux = NULL;
} }
if (run->linux.perfMmapBuf != NULL) { if (run->arch_linux.perfMmapBuf != NULL) {
munmap(run->linux.perfMmapBuf, _HF_PERF_MAP_SZ + getpagesize()); munmap(run->arch_linux.perfMmapBuf, _HF_PERF_MAP_SZ + getpagesize());
run->linux.perfMmapBuf = NULL; run->arch_linux.perfMmapBuf = NULL;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
close(run->linux.cpuInstrFd); close(run->arch_linux.cpuInstrFd);
run->linux.cpuInstrFd = -1; run->arch_linux.cpuInstrFd = -1;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
close(run->linux.cpuBranchFd); close(run->arch_linux.cpuBranchFd);
run->linux.cpuBranchFd = -1; run->arch_linux.cpuBranchFd = -1;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
close(run->linux.cpuIptBtsFd); close(run->arch_linux.cpuIptBtsFd);
run->linux.cpuIptBtsFd = -1; run->arch_linux.cpuIptBtsFd = -1;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
close(run->linux.cpuIptBtsFd); close(run->arch_linux.cpuIptBtsFd);
run->linux.cpuIptBtsFd = -1; run->arch_linux.cpuIptBtsFd = -1;
} }
} }
bool arch_perfEnable(run_t* run) { bool arch_perfEnable(run_t* run) {
if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) { if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) {
return true; return true;
} }
/* It's enabled on exec in such scenario */ /* It's enabled on exec in such scenario */
if (!run->global->exe.persistent) { if (!run->global->exe.persistent) {
return true; return true;
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) {
ioctl(run->linux.cpuInstrFd, PERF_EVENT_IOC_ENABLE, 0); ioctl(run->arch_linux.cpuInstrFd, PERF_EVENT_IOC_ENABLE, 0);
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) {
ioctl(run->linux.cpuBranchFd, PERF_EVENT_IOC_ENABLE, 0); ioctl(run->arch_linux.cpuBranchFd, PERF_EVENT_IOC_ENABLE, 0);
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_ENABLE, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_ENABLE, 0);
} }
if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) { if (run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_ENABLE, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_ENABLE, 0);
} }
return true; return true;
} }
static void arch_perfMmapReset(run_t* run) { static void arch_perfMmapReset(run_t* run) {
/* smp_mb() required as per /usr/include/linux/perf_event.h */ /* smp_mb() required as per /usr/include/linux/perf_event.h */
wmb(); wmb();
struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->linux. perfMmapBuf; struct perf_event_mmap_page* pem = (struct perf_event_mmap_page*)run->arch_l inux.perfMmapBuf;
ATOMIC_SET(pem->data_head, 0); ATOMIC_SET(pem->data_head, 0);
ATOMIC_SET(pem->data_tail, 0); ATOMIC_SET(pem->data_tail, 0);
#if defined(PERF_ATTR_SIZE_VER5) #if defined(PERF_ATTR_SIZE_VER5)
ATOMIC_SET(pem->aux_head, 0); ATOMIC_SET(pem->aux_head, 0);
ATOMIC_SET(pem->aux_tail, 0); ATOMIC_SET(pem->aux_tail, 0);
#endif /* defined(PERF_ATTR_SIZE_VER5) */ #endif /* defined(PERF_ATTR_SIZE_VER5) */
} }
void arch_perfAnalyze(run_t* run) { void arch_perfAnalyze(run_t* run) {
if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) { if (run->global->feedback.dynFileMethod == _HF_DYNFILE_NONE) {
return; return;
} }
uint64_t instrCount = 0; uint64_t instrCount = 0;
if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) && if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_INSTR_COUNT) &&
run->linux.cpuInstrFd != -1) { run->arch_linux.cpuInstrFd != -1) {
ioctl(run->linux.cpuInstrFd, PERF_EVENT_IOC_DISABLE, 0); ioctl(run->arch_linux.cpuInstrFd, PERF_EVENT_IOC_DISABLE, 0);
if (files_readFromFd(run->linux.cpuInstrFd, (uint8_t*)&instrCount, sizeo if (files_readFromFd(run->arch_linux.cpuInstrFd, (uint8_t*)&instrCount,
f(instrCount)) != sizeof(instrCount)) != sizeof(instrCount)) {
sizeof(instrCount)) { PLOG_E("read(perfFd='%d') failed", run->arch_linux.cpuInstrFd);
PLOG_E("read(perfFd='%d') failed", run->linux.cpuInstrFd);
} }
ioctl(run->linux.cpuInstrFd, PERF_EVENT_IOC_RESET, 0); ioctl(run->arch_linux.cpuInstrFd, PERF_EVENT_IOC_RESET, 0);
} }
uint64_t branchCount = 0; uint64_t branchCount = 0;
if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) && if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BRANCH_COUNT) &&
run->linux.cpuBranchFd != -1) { run->arch_linux.cpuBranchFd != -1) {
ioctl(run->linux.cpuBranchFd, PERF_EVENT_IOC_DISABLE, 0); ioctl(run->arch_linux.cpuBranchFd, PERF_EVENT_IOC_DISABLE, 0);
if (files_readFromFd(run->linux.cpuBranchFd, (uint8_t*)&branchCount, siz if (files_readFromFd(run->arch_linux.cpuBranchFd, (uint8_t*)&branchCount
eof(branchCount)) != ,
sizeof(branchCount)) { sizeof(branchCount)) != sizeof(branchCount)) {
PLOG_E("read(perfFd='%d') failed", run->linux.cpuBranchFd); PLOG_E("read(perfFd='%d') failed", run->arch_linux.cpuBranchFd);
} }
ioctl(run->linux.cpuBranchFd, PERF_EVENT_IOC_RESET, 0); ioctl(run->arch_linux.cpuBranchFd, PERF_EVENT_IOC_RESET, 0);
} }
if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) && if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_BTS_EDGE) &&
run->linux.cpuIptBtsFd != -1) { run->arch_linux.cpuIptBtsFd != -1) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0);
arch_perfMmapParse(run); arch_perfMmapParse(run);
arch_perfMmapReset(run); arch_perfMmapReset(run);
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_RESET, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_RESET, 0);
} }
if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) && if ((run->global->feedback.dynFileMethod & _HF_DYNFILE_IPT_BLOCK) &&
run->linux.cpuIptBtsFd != -1) { run->arch_linux.cpuIptBtsFd != -1) {
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_DISABLE, 0);
arch_perfMmapParse(run); arch_perfMmapParse(run);
arch_perfMmapReset(run); arch_perfMmapReset(run);
ioctl(run->linux.cpuIptBtsFd, PERF_EVENT_IOC_RESET, 0); ioctl(run->arch_linux.cpuIptBtsFd, PERF_EVENT_IOC_RESET, 0);
} }
run->linux.hwCnts.cpuInstrCnt = instrCount; run->hwCnts.cpuInstrCnt = instrCount;
run->linux.hwCnts.cpuBranchCnt = branchCount; run->hwCnts.cpuBranchCnt = branchCount;
} }
bool arch_perfInit(honggfuzz_t* hfuzz HF_ATTR_UNUSED) { bool arch_perfInit(honggfuzz_t* hfuzz HF_ATTR_UNUSED) {
static char const intel_pt_path[] = "/sys/bus/event_source/devices/intel_pt/ type"; static char const intel_pt_path[] = "/sys/bus/event_source/devices/intel_pt/ type";
static char const intel_bts_path[] = "/sys/bus/event_source/devices/intel_bt s/type"; static char const intel_bts_path[] = "/sys/bus/event_source/devices/intel_bt s/type";
if (files_exists(intel_pt_path)) { if (files_exists(intel_pt_path)) {
uint8_t buf[256]; uint8_t buf[256];
ssize_t sz = files_readFileToBufMax(intel_pt_path, buf, sizeof(buf) - 1) ; ssize_t sz = files_readFileToBufMax(intel_pt_path, buf, sizeof(buf) - 1) ;
if (sz > 0) { if (sz > 0) {
 End of changes. 36 change blocks. 
70 lines changed or deleted 70 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)