/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ASM_X86_AMD_IBS_H2#define _ASM_X86_AMD_IBS_H34/*5* From PPR Vol 1 for AMD Family 19h Model 01h B16* 55898 Rev 0.35 - Feb 5, 20217*/89#include <asm/msr-index.h>1011/* IBS_OP_DATA2 DataSrc */12#define IBS_DATA_SRC_LOC_CACHE 213#define IBS_DATA_SRC_DRAM 314#define IBS_DATA_SRC_REM_CACHE 415#define IBS_DATA_SRC_IO 71617/* IBS_OP_DATA2 DataSrc Extension */18#define IBS_DATA_SRC_EXT_LOC_CACHE 119#define IBS_DATA_SRC_EXT_NEAR_CCX_CACHE 220#define IBS_DATA_SRC_EXT_DRAM 321#define IBS_DATA_SRC_EXT_FAR_CCX_CACHE 522#define IBS_DATA_SRC_EXT_PMEM 623#define IBS_DATA_SRC_EXT_IO 724#define IBS_DATA_SRC_EXT_EXT_MEM 825#define IBS_DATA_SRC_EXT_PEER_AGENT_MEM 122627/*28* IBS Hardware MSRs29*/3031/* MSR 0xc0011030: IBS Fetch Control */32union ibs_fetch_ctl {33__u64 val;34struct {35__u64 fetch_maxcnt:16,/* 0-15: instruction fetch max. count */36fetch_cnt:16, /* 16-31: instruction fetch count */37fetch_lat:16, /* 32-47: instruction fetch latency */38fetch_en:1, /* 48: instruction fetch enable */39fetch_val:1, /* 49: instruction fetch valid */40fetch_comp:1, /* 50: instruction fetch complete */41ic_miss:1, /* 51: i-cache miss */42phy_addr_valid:1,/* 52: physical address valid */43l1tlb_pgsz:2, /* 53-54: i-cache L1TLB page size44* (needs IbsPhyAddrValid) */45l1tlb_miss:1, /* 55: i-cache fetch missed in L1TLB */46l2tlb_miss:1, /* 56: i-cache fetch missed in L2TLB */47rand_en:1, /* 57: random tagging enable */48fetch_l2_miss:1,/* 58: L2 miss for sampled fetch49* (needs IbsFetchComp) */50l3_miss_only:1, /* 59: Collect L3 miss samples only */51fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */52fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */53reserved:2; /* 62-63: reserved */54};55};5657/* MSR 0xc0011033: IBS Execution Control */58union ibs_op_ctl {59__u64 val;60struct {61__u64 opmaxcnt:16, /* 0-15: periodic op max. count */62l3_miss_only:1, /* 16: Collect L3 miss samples only */63op_en:1, /* 17: op sampling enable */64op_val:1, /* 18: op sample valid */65cnt_ctl:1, /* 19: periodic op counter control */66opmaxcnt_ext:7, /* 20-26: upper 7 bits of periodic op maximum count */67reserved0:5, /* 27-31: reserved */68opcurcnt:27, /* 32-58: periodic op counter current count */69ldlat_thrsh:4, /* 59-62: Load Latency threshold */70ldlat_en:1; /* 63: Load Latency enabled */71};72};7374/* MSR 0xc0011035: IBS Op Data 1 */75union ibs_op_data {76__u64 val;77struct {78__u64 comp_to_ret_ctr:16, /* 0-15: op completion to retire count */79tag_to_ret_ctr:16, /* 15-31: op tag to retire count */80reserved1:2, /* 32-33: reserved */81op_return:1, /* 34: return op */82op_brn_taken:1, /* 35: taken branch op */83op_brn_misp:1, /* 36: mispredicted branch op */84op_brn_ret:1, /* 37: branch op retired */85op_rip_invalid:1, /* 38: RIP is invalid */86op_brn_fuse:1, /* 39: fused branch op */87op_microcode:1, /* 40: microcode op */88reserved2:23; /* 41-63: reserved */89};90};9192/* MSR 0xc0011036: IBS Op Data 2 */93union ibs_op_data2 {94__u64 val;95struct {96__u64 data_src_lo:3, /* 0-2: data source low */97reserved0:1, /* 3: reserved */98rmt_node:1, /* 4: destination node */99cache_hit_st:1, /* 5: cache hit state */100data_src_hi:2, /* 6-7: data source high */101reserved1:56; /* 8-63: reserved */102};103};104105/* MSR 0xc0011037: IBS Op Data 3 */106union ibs_op_data3 {107__u64 val;108struct {109__u64 ld_op:1, /* 0: load op */110st_op:1, /* 1: store op */111dc_l1tlb_miss:1, /* 2: data cache L1TLB miss */112dc_l2tlb_miss:1, /* 3: data cache L2TLB hit in 2M page */113dc_l1tlb_hit_2m:1, /* 4: data cache L1TLB hit in 2M page */114dc_l1tlb_hit_1g:1, /* 5: data cache L1TLB hit in 1G page */115dc_l2tlb_hit_2m:1, /* 6: data cache L2TLB hit in 2M page */116dc_miss:1, /* 7: data cache miss */117dc_mis_acc:1, /* 8: misaligned access */118reserved:4, /* 9-12: reserved */119dc_wc_mem_acc:1, /* 13: write combining memory access */120dc_uc_mem_acc:1, /* 14: uncacheable memory access */121dc_locked_op:1, /* 15: locked operation */122dc_miss_no_mab_alloc:1, /* 16: DC miss with no MAB allocated */123dc_lin_addr_valid:1, /* 17: data cache linear address valid */124dc_phy_addr_valid:1, /* 18: data cache physical address valid */125dc_l2_tlb_hit_1g:1, /* 19: data cache L2 hit in 1GB page */126l2_miss:1, /* 20: L2 cache miss */127sw_pf:1, /* 21: software prefetch */128op_mem_width:4, /* 22-25: load/store size in bytes */129op_dc_miss_open_mem_reqs:6, /* 26-31: outstanding mem reqs on DC fill */130dc_miss_lat:16, /* 32-47: data cache miss latency */131tlb_refill_lat:16; /* 48-63: L1 TLB refill latency */132};133};134135/* MSR 0xc001103c: IBS Fetch Control Extended */136union ic_ibs_extd_ctl {137__u64 val;138struct {139__u64 itlb_refill_lat:16, /* 0-15: ITLB Refill latency for sampled fetch */140reserved:48; /* 16-63: reserved */141};142};143144/*145* IBS driver related146*/147148struct perf_ibs_data {149u32 size;150union {151u32 data[0]; /* data buffer starts here */152u32 caps;153};154u64 regs[MSR_AMD64_IBS_REG_COUNT_MAX];155};156157#endif /* _ASM_X86_AMD_IBS_H */158159160