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

arm-spe-decoder.h (1472B)


      1/* SPDX-License-Identifier: GPL-2.0 */
      2/*
      3 * arm_spe_decoder.h: Arm Statistical Profiling Extensions support
      4 * Copyright (c) 2019-2020, Arm Ltd.
      5 */
      6
      7#ifndef INCLUDE__ARM_SPE_DECODER_H__
      8#define INCLUDE__ARM_SPE_DECODER_H__
      9
     10#include <stdbool.h>
     11#include <stddef.h>
     12#include <stdint.h>
     13
     14#include "arm-spe-pkt-decoder.h"
     15
     16enum arm_spe_sample_type {
     17	ARM_SPE_L1D_ACCESS	= 1 << 0,
     18	ARM_SPE_L1D_MISS	= 1 << 1,
     19	ARM_SPE_LLC_ACCESS	= 1 << 2,
     20	ARM_SPE_LLC_MISS	= 1 << 3,
     21	ARM_SPE_TLB_ACCESS	= 1 << 4,
     22	ARM_SPE_TLB_MISS	= 1 << 5,
     23	ARM_SPE_BRANCH_MISS	= 1 << 6,
     24	ARM_SPE_REMOTE_ACCESS	= 1 << 7,
     25};
     26
     27enum arm_spe_op_type {
     28	ARM_SPE_LD		= 1 << 0,
     29	ARM_SPE_ST		= 1 << 1,
     30};
     31
     32struct arm_spe_record {
     33	enum arm_spe_sample_type type;
     34	int err;
     35	u32 op;
     36	u32 latency;
     37	u64 from_ip;
     38	u64 to_ip;
     39	u64 timestamp;
     40	u64 virt_addr;
     41	u64 phys_addr;
     42	u64 context_id;
     43};
     44
     45struct arm_spe_insn;
     46
     47struct arm_spe_buffer {
     48	const unsigned char *buf;
     49	size_t len;
     50	u64 offset;
     51	u64 trace_nr;
     52};
     53
     54struct arm_spe_params {
     55	int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
     56	void *data;
     57};
     58
     59struct arm_spe_decoder {
     60	int (*get_trace)(struct arm_spe_buffer *buffer, void *data);
     61	void *data;
     62	struct arm_spe_record record;
     63
     64	const unsigned char *buf;
     65	size_t len;
     66
     67	struct arm_spe_pkt packet;
     68};
     69
     70struct arm_spe_decoder *arm_spe_decoder_new(struct arm_spe_params *params);
     71void arm_spe_decoder_free(struct arm_spe_decoder *decoder);
     72
     73int arm_spe_decode(struct arm_spe_decoder *decoder);
     74
     75#endif