/*
* auxtrace.c: AUX area trace support
* Copyright (c) 2013-2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#include <sys/types.h>
#include <sys/mman.h>
#include <stdbool.h>
#include <linux/kernel.h>
#include <linux/perf_event.h>
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/log2.h>
#include <linux/string.h>
#include <sys/param.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <linux/list.h>
#include "../perf.h"
#include "util.h"
#include "evlist.h"
#include "cpumap.h"
#include "thread_map.h"
#include "asm/bug.h"
#include "auxtrace.h"
#include <linux/hash.h>
#include "event.h"
#include "session.h"
#include "debug.h"
#include "parse-options.h"
#include "intel-pt.h"
#include "intel-bts.h"
int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
struct auxtrace_mmap_params *mp,
void *userpg, int fd)
{
struct perf_event_mmap_page *pc = userpg;
WARN_ONCE(mm->base, "Uninitialized auxtrace_mmap\n");
mm->userpg = userpg;
mm->mask = mp->mask;
mm->len = mp->len;
mm->prev = 0;
mm->idx = mp->idx;
mm->tid = mp->tid;
mm->cpu = mp->cpu;
if (!mp->len) {
mm->base = NULL;
return 0;
}
#if BITS_PER_LONG != 64 && !defined(HAVE_SYNC_COMPARE_AND_SWAP_SUPPORT)
pr_err("Cannot use AUX area tracing mmaps\n");
return -1;
#endif
pc->aux_offset = mp->offset;
pc->aux_size = mp->len;
mm->base = mmap(NULL, mp->len, mp->prot, MAP_SHARED, fd, mp->offset);
if (mm->base == MAP_FAILED) {
pr_debug2("failed to mmap AUX area