linux/arch/x86/events/utils.c

// SPDX-License-Identifier: GPL-2.0
#include <asm/insn.h>
#include <linux/mm.h>

#include "perf_event.h"

static int decode_branch_type(struct insn *insn)
{}

/*
 * return the type of control flow change at address "from"
 * instruction is not necessarily a branch (in case of interrupt).
 *
 * The branch type returned also includes the priv level of the
 * target of the control flow change (X86_BR_USER, X86_BR_KERNEL).
 *
 * If a branch type is unknown OR the instruction cannot be
 * decoded (e.g., text page not present), then X86_BR_NONE is
 * returned.
 *
 * While recording branches, some processors can report the "from"
 * address to be that of an instruction preceding the actual branch
 * when instruction fusion occurs. If fusion is expected, attempt to
 * find the type of the first branch instruction within the next
 * MAX_INSN_SIZE bytes and if found, provide the offset between the
 * reported "from" address and the actual branch instruction address.
 */
static int get_branch_type(unsigned long from, unsigned long to, int abort,
			   bool fused, int *offset)
{}

int branch_type(unsigned long from, unsigned long to, int abort)
{}

int branch_type_fused(unsigned long from, unsigned long to, int abort,
		      int *offset)
{}

#define X86_BR_TYPE_MAP_MAX

static int branch_map[X86_BR_TYPE_MAP_MAX] =;

int common_branch_type(int type)
{}