cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

intel-pt-log.h (1908B)


      1/* SPDX-License-Identifier: GPL-2.0-only */
      2/*
      3 * intel_pt_log.h: Intel Processor Trace support
      4 * Copyright (c) 2013-2014, Intel Corporation.
      5 */
      6
      7#ifndef INCLUDE__INTEL_PT_LOG_H__
      8#define INCLUDE__INTEL_PT_LOG_H__
      9
     10#include <linux/compiler.h>
     11#include <stdint.h>
     12#include <inttypes.h>
     13
     14struct intel_pt_pkt;
     15
     16void *intel_pt_log_fp(void);
     17void intel_pt_log_enable(void);
     18void intel_pt_log_disable(void);
     19void intel_pt_log_set_name(const char *name);
     20
     21void __intel_pt_log_packet(const struct intel_pt_pkt *packet, int pkt_len,
     22			   uint64_t pos, const unsigned char *buf);
     23
     24struct intel_pt_insn;
     25
     26void __intel_pt_log_insn(struct intel_pt_insn *intel_pt_insn, uint64_t ip);
     27void __intel_pt_log_insn_no_data(struct intel_pt_insn *intel_pt_insn,
     28				 uint64_t ip);
     29
     30void __intel_pt_log(const char *fmt, ...) __printf(1, 2);
     31
     32#define intel_pt_log(fmt, ...) \
     33	do { \
     34		if (intel_pt_enable_logging) \
     35			__intel_pt_log(fmt, ##__VA_ARGS__); \
     36	} while (0)
     37
     38#define intel_pt_log_packet(arg, ...) \
     39	do { \
     40		if (intel_pt_enable_logging) \
     41			__intel_pt_log_packet(arg, ##__VA_ARGS__); \
     42	} while (0)
     43
     44#define intel_pt_log_insn(arg, ...) \
     45	do { \
     46		if (intel_pt_enable_logging) \
     47			__intel_pt_log_insn(arg, ##__VA_ARGS__); \
     48	} while (0)
     49
     50#define intel_pt_log_insn_no_data(arg, ...) \
     51	do { \
     52		if (intel_pt_enable_logging) \
     53			__intel_pt_log_insn_no_data(arg, ##__VA_ARGS__); \
     54	} while (0)
     55
     56#define x64_fmt "0x%" PRIx64
     57
     58extern bool intel_pt_enable_logging;
     59
     60static inline void intel_pt_log_at(const char *msg, uint64_t u)
     61{
     62	intel_pt_log("%s at " x64_fmt "\n", msg, u);
     63}
     64
     65static inline void intel_pt_log_to(const char *msg, uint64_t u)
     66{
     67	intel_pt_log("%s to " x64_fmt "\n", msg, u);
     68}
     69
     70#define intel_pt_log_var(var, fmt) intel_pt_log("%s: " #var " " fmt "\n", __func__, var)
     71
     72#define intel_pt_log_x32(var) intel_pt_log_var(var, "%#x")
     73#define intel_pt_log_x64(var) intel_pt_log_var(var, "%#" PRIx64)
     74
     75#endif