xref: /linux/arch/x86/include/asm/amd/ibs.h (revision ab93e0dd72c37d378dd936f031ffb83ff2bd87ce)
13846389cSIngo Molnar /* SPDX-License-Identifier: GPL-2.0 */
2*861c6b11SIngo Molnar #ifndef _ASM_X86_AMD_IBS_H
3*861c6b11SIngo Molnar #define _ASM_X86_AMD_IBS_H
4*861c6b11SIngo Molnar 
53846389cSIngo Molnar /*
63846389cSIngo Molnar  * From PPR Vol 1 for AMD Family 19h Model 01h B1
73846389cSIngo Molnar  * 55898 Rev 0.35 - Feb 5, 2021
83846389cSIngo Molnar  */
93846389cSIngo Molnar 
103846389cSIngo Molnar #include <asm/msr-index.h>
113846389cSIngo Molnar 
123846389cSIngo Molnar /* IBS_OP_DATA2 DataSrc */
133846389cSIngo Molnar #define IBS_DATA_SRC_LOC_CACHE			 2
143846389cSIngo Molnar #define IBS_DATA_SRC_DRAM			 3
153846389cSIngo Molnar #define IBS_DATA_SRC_REM_CACHE			 4
163846389cSIngo Molnar #define IBS_DATA_SRC_IO				 7
173846389cSIngo Molnar 
183846389cSIngo Molnar /* IBS_OP_DATA2 DataSrc Extension */
193846389cSIngo Molnar #define IBS_DATA_SRC_EXT_LOC_CACHE		 1
203846389cSIngo Molnar #define IBS_DATA_SRC_EXT_NEAR_CCX_CACHE		 2
213846389cSIngo Molnar #define IBS_DATA_SRC_EXT_DRAM			 3
223846389cSIngo Molnar #define IBS_DATA_SRC_EXT_FAR_CCX_CACHE		 5
233846389cSIngo Molnar #define IBS_DATA_SRC_EXT_PMEM			 6
243846389cSIngo Molnar #define IBS_DATA_SRC_EXT_IO			 7
253846389cSIngo Molnar #define IBS_DATA_SRC_EXT_EXT_MEM		 8
263846389cSIngo Molnar #define IBS_DATA_SRC_EXT_PEER_AGENT_MEM		12
273846389cSIngo Molnar 
283846389cSIngo Molnar /*
293846389cSIngo Molnar  * IBS Hardware MSRs
303846389cSIngo Molnar  */
313846389cSIngo Molnar 
323846389cSIngo Molnar /* MSR 0xc0011030: IBS Fetch Control */
333846389cSIngo Molnar union ibs_fetch_ctl {
343846389cSIngo Molnar 	__u64 val;
353846389cSIngo Molnar 	struct {
363846389cSIngo Molnar 		__u64	fetch_maxcnt:16,/* 0-15: instruction fetch max. count */
373846389cSIngo Molnar 			fetch_cnt:16,	/* 16-31: instruction fetch count */
383846389cSIngo Molnar 			fetch_lat:16,	/* 32-47: instruction fetch latency */
393846389cSIngo Molnar 			fetch_en:1,	/* 48: instruction fetch enable */
403846389cSIngo Molnar 			fetch_val:1,	/* 49: instruction fetch valid */
413846389cSIngo Molnar 			fetch_comp:1,	/* 50: instruction fetch complete */
423846389cSIngo Molnar 			ic_miss:1,	/* 51: i-cache miss */
433846389cSIngo Molnar 			phy_addr_valid:1,/* 52: physical address valid */
443846389cSIngo Molnar 			l1tlb_pgsz:2,	/* 53-54: i-cache L1TLB page size
453846389cSIngo Molnar 					 *	  (needs IbsPhyAddrValid) */
463846389cSIngo Molnar 			l1tlb_miss:1,	/* 55: i-cache fetch missed in L1TLB */
473846389cSIngo Molnar 			l2tlb_miss:1,	/* 56: i-cache fetch missed in L2TLB */
483846389cSIngo Molnar 			rand_en:1,	/* 57: random tagging enable */
493846389cSIngo Molnar 			fetch_l2_miss:1,/* 58: L2 miss for sampled fetch
503846389cSIngo Molnar 					 *      (needs IbsFetchComp) */
513846389cSIngo Molnar 			l3_miss_only:1,	/* 59: Collect L3 miss samples only */
523846389cSIngo Molnar 			fetch_oc_miss:1,/* 60: Op cache miss for the sampled fetch */
533846389cSIngo Molnar 			fetch_l3_miss:1,/* 61: L3 cache miss for the sampled fetch */
543846389cSIngo Molnar 			reserved:2;	/* 62-63: reserved */
553846389cSIngo Molnar 	};
563846389cSIngo Molnar };
573846389cSIngo Molnar 
583846389cSIngo Molnar /* MSR 0xc0011033: IBS Execution Control */
593846389cSIngo Molnar union ibs_op_ctl {
603846389cSIngo Molnar 	__u64 val;
613846389cSIngo Molnar 	struct {
623846389cSIngo Molnar 		__u64	opmaxcnt:16,	/* 0-15: periodic op max. count */
633846389cSIngo Molnar 			l3_miss_only:1,	/* 16: Collect L3 miss samples only */
643846389cSIngo Molnar 			op_en:1,	/* 17: op sampling enable */
653846389cSIngo Molnar 			op_val:1,	/* 18: op sample valid */
663846389cSIngo Molnar 			cnt_ctl:1,	/* 19: periodic op counter control */
673846389cSIngo Molnar 			opmaxcnt_ext:7,	/* 20-26: upper 7 bits of periodic op maximum count */
683846389cSIngo Molnar 			reserved0:5,	/* 27-31: reserved */
693846389cSIngo Molnar 			opcurcnt:27,	/* 32-58: periodic op counter current count */
703846389cSIngo Molnar 			ldlat_thrsh:4,	/* 59-62: Load Latency threshold */
713846389cSIngo Molnar 			ldlat_en:1;	/* 63: Load Latency enabled */
723846389cSIngo Molnar 	};
733846389cSIngo Molnar };
743846389cSIngo Molnar 
753846389cSIngo Molnar /* MSR 0xc0011035: IBS Op Data 1 */
763846389cSIngo Molnar union ibs_op_data {
773846389cSIngo Molnar 	__u64 val;
783846389cSIngo Molnar 	struct {
793846389cSIngo Molnar 		__u64	comp_to_ret_ctr:16,	/* 0-15: op completion to retire count */
803846389cSIngo Molnar 			tag_to_ret_ctr:16,	/* 15-31: op tag to retire count */
813846389cSIngo Molnar 			reserved1:2,		/* 32-33: reserved */
823846389cSIngo Molnar 			op_return:1,		/* 34: return op */
833846389cSIngo Molnar 			op_brn_taken:1,		/* 35: taken branch op */
843846389cSIngo Molnar 			op_brn_misp:1,		/* 36: mispredicted branch op */
853846389cSIngo Molnar 			op_brn_ret:1,		/* 37: branch op retired */
863846389cSIngo Molnar 			op_rip_invalid:1,	/* 38: RIP is invalid */
873846389cSIngo Molnar 			op_brn_fuse:1,		/* 39: fused branch op */
883846389cSIngo Molnar 			op_microcode:1,		/* 40: microcode op */
893846389cSIngo Molnar 			reserved2:23;		/* 41-63: reserved */
903846389cSIngo Molnar 	};
913846389cSIngo Molnar };
923846389cSIngo Molnar 
933846389cSIngo Molnar /* MSR 0xc0011036: IBS Op Data 2 */
943846389cSIngo Molnar union ibs_op_data2 {
953846389cSIngo Molnar 	__u64 val;
963846389cSIngo Molnar 	struct {
973846389cSIngo Molnar 		__u64	data_src_lo:3,	/* 0-2: data source low */
983846389cSIngo Molnar 			reserved0:1,	/* 3: reserved */
993846389cSIngo Molnar 			rmt_node:1,	/* 4: destination node */
1003846389cSIngo Molnar 			cache_hit_st:1,	/* 5: cache hit state */
1013846389cSIngo Molnar 			data_src_hi:2,	/* 6-7: data source high */
1023846389cSIngo Molnar 			reserved1:56;	/* 8-63: reserved */
1033846389cSIngo Molnar 	};
1043846389cSIngo Molnar };
1053846389cSIngo Molnar 
1063846389cSIngo Molnar /* MSR 0xc0011037: IBS Op Data 3 */
1073846389cSIngo Molnar union ibs_op_data3 {
1083846389cSIngo Molnar 	__u64 val;
1093846389cSIngo Molnar 	struct {
1103846389cSIngo Molnar 		__u64	ld_op:1,			/* 0: load op */
1113846389cSIngo Molnar 			st_op:1,			/* 1: store op */
1123846389cSIngo Molnar 			dc_l1tlb_miss:1,		/* 2: data cache L1TLB miss */
1133846389cSIngo Molnar 			dc_l2tlb_miss:1,		/* 3: data cache L2TLB hit in 2M page */
1143846389cSIngo Molnar 			dc_l1tlb_hit_2m:1,		/* 4: data cache L1TLB hit in 2M page */
1153846389cSIngo Molnar 			dc_l1tlb_hit_1g:1,		/* 5: data cache L1TLB hit in 1G page */
1163846389cSIngo Molnar 			dc_l2tlb_hit_2m:1,		/* 6: data cache L2TLB hit in 2M page */
1173846389cSIngo Molnar 			dc_miss:1,			/* 7: data cache miss */
1183846389cSIngo Molnar 			dc_mis_acc:1,			/* 8: misaligned access */
1193846389cSIngo Molnar 			reserved:4,			/* 9-12: reserved */
1203846389cSIngo Molnar 			dc_wc_mem_acc:1,		/* 13: write combining memory access */
1213846389cSIngo Molnar 			dc_uc_mem_acc:1,		/* 14: uncacheable memory access */
1223846389cSIngo Molnar 			dc_locked_op:1,			/* 15: locked operation */
1233846389cSIngo Molnar 			dc_miss_no_mab_alloc:1,		/* 16: DC miss with no MAB allocated */
1243846389cSIngo Molnar 			dc_lin_addr_valid:1,		/* 17: data cache linear address valid */
1253846389cSIngo Molnar 			dc_phy_addr_valid:1,		/* 18: data cache physical address valid */
1263846389cSIngo Molnar 			dc_l2_tlb_hit_1g:1,		/* 19: data cache L2 hit in 1GB page */
1273846389cSIngo Molnar 			l2_miss:1,			/* 20: L2 cache miss */
1283846389cSIngo Molnar 			sw_pf:1,			/* 21: software prefetch */
1293846389cSIngo Molnar 			op_mem_width:4,			/* 22-25: load/store size in bytes */
1303846389cSIngo Molnar 			op_dc_miss_open_mem_reqs:6,	/* 26-31: outstanding mem reqs on DC fill */
1313846389cSIngo Molnar 			dc_miss_lat:16,			/* 32-47: data cache miss latency */
1323846389cSIngo Molnar 			tlb_refill_lat:16;		/* 48-63: L1 TLB refill latency */
1333846389cSIngo Molnar 	};
1343846389cSIngo Molnar };
1353846389cSIngo Molnar 
1363846389cSIngo Molnar /* MSR 0xc001103c: IBS Fetch Control Extended */
1373846389cSIngo Molnar union ic_ibs_extd_ctl {
1383846389cSIngo Molnar 	__u64 val;
1393846389cSIngo Molnar 	struct {
1403846389cSIngo Molnar 		__u64	itlb_refill_lat:16,	/* 0-15: ITLB Refill latency for sampled fetch */
1413846389cSIngo Molnar 			reserved:48;		/* 16-63: reserved */
1423846389cSIngo Molnar 	};
1433846389cSIngo Molnar };
1443846389cSIngo Molnar 
1453846389cSIngo Molnar /*
1463846389cSIngo Molnar  * IBS driver related
1473846389cSIngo Molnar  */
1483846389cSIngo Molnar 
1493846389cSIngo Molnar struct perf_ibs_data {
1503846389cSIngo Molnar 	u32		size;
1513846389cSIngo Molnar 	union {
1523846389cSIngo Molnar 		u32	data[0];	/* data buffer starts here */
1533846389cSIngo Molnar 		u32	caps;
1543846389cSIngo Molnar 	};
1553846389cSIngo Molnar 	u64		regs[MSR_AMD64_IBS_REG_COUNT_MAX];
1563846389cSIngo Molnar };
157*861c6b11SIngo Molnar 
158*861c6b11SIngo Molnar #endif /* _ASM_X86_AMD_IBS_H */
159