Sat Feb 18 16:15:51 2017 UTC ()
Add the AMD 10h family PMC values. Some values depend on the CPU revision,
they are commented out. Several other values are common with K7, we could
merge them later.

This family of CPUs has a 12bit event selector, contrary to K7 (8bit). The
thing is, i386's PMC interface takes as argument a uint8_t from userland,
so these counters are not accessible (yet).


(maxv)
diff -r1.93 -r1.94 src/sys/arch/x86/include/specialreg.h

cvs diff -r1.93 -r1.94 src/sys/arch/x86/include/specialreg.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/specialreg.h 2017/02/11 15:11:45 1.93
+++ src/sys/arch/x86/include/specialreg.h 2017/02/18 16:15:51 1.94
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: specialreg.h,v 1.93 2017/02/11 15:11:45 maxv Exp $ */ 1/* $NetBSD: specialreg.h,v 1.94 2017/02/18 16:15:51 maxv Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991 The Regents of the University of California. 4 * Copyright (c) 1991 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -987,27 +987,27 @@ @@ -987,27 +987,27 @@
987#define PMC6_MMX_SAT_INSTR_EXEC 0xb1 /* P-II and P-III only */ 987#define PMC6_MMX_SAT_INSTR_EXEC 0xb1 /* P-II and P-III only */
988#define PMC6_MMX_UOPS_EXEC 0xb2 /* P-II and P-III only */ 988#define PMC6_MMX_UOPS_EXEC 0xb2 /* P-II and P-III only */
989#define PMC6_MMX_INSTR_TYPE_EXEC 0xb3 /* P-II and P-III only */ 989#define PMC6_MMX_INSTR_TYPE_EXEC 0xb3 /* P-II and P-III only */
990#define PMC6_FP_MMX_TRANS 0xcc /* P-II and P-III only */ 990#define PMC6_FP_MMX_TRANS 0xcc /* P-II and P-III only */
991#define PMC6_MMX_ASSIST 0xcd /* P-II and P-III only */ 991#define PMC6_MMX_ASSIST 0xcd /* P-II and P-III only */
992#define PMC6_MMX_INSTR_RET 0xc3 /* P-II only */ 992#define PMC6_MMX_INSTR_RET 0xc3 /* P-II only */
993 993
994/* Segment Register Renaming */ 994/* Segment Register Renaming */
995#define PMC6_SEG_RENAME_STALLS 0xd4 /* P-II and P-III only */ 995#define PMC6_SEG_RENAME_STALLS 0xd4 /* P-II and P-III only */
996#define PMC6_SEG_REG_RENAMES 0xd5 /* P-II and P-III only */ 996#define PMC6_SEG_REG_RENAMES 0xd5 /* P-II and P-III only */
997#define PMC6_RET_SEG_RENAMES 0xd6 /* P-II and P-III only */ 997#define PMC6_RET_SEG_RENAMES 0xd6 /* P-II and P-III only */
998 998
999/* 999/*
1000 * AMD K7 Event Selector MSR format. 1000 * AMD K7 Event Selector MSR format. [Doc: 22007K.pdf, Feb 2002]
1001 */ 1001 */
1002 1002
1003#define K7_EVTSEL_EVENT 0x000000ff 1003#define K7_EVTSEL_EVENT 0x000000ff
1004#define K7_EVTSEL_UNIT 0x0000ff00 1004#define K7_EVTSEL_UNIT 0x0000ff00
1005#define K7_EVTSEL_UNIT_SHIFT 8 1005#define K7_EVTSEL_UNIT_SHIFT 8
1006#define K7_EVTSEL_USR (1 << 16) 1006#define K7_EVTSEL_USR (1 << 16)
1007#define K7_EVTSEL_OS (1 << 17) 1007#define K7_EVTSEL_OS (1 << 17)
1008#define K7_EVTSEL_E (1 << 18) 1008#define K7_EVTSEL_E (1 << 18)
1009#define K7_EVTSEL_PC (1 << 19) 1009#define K7_EVTSEL_PC (1 << 19)
1010#define K7_EVTSEL_INT (1 << 20) 1010#define K7_EVTSEL_INT (1 << 20)
1011#define K7_EVTSEL_EN (1 << 22) 1011#define K7_EVTSEL_EN (1 << 22)
1012#define K7_EVTSEL_INV (1 << 23) 1012#define K7_EVTSEL_INV (1 << 23)
1013#define K7_EVTSEL_COUNTER_MASK 0xff000000 1013#define K7_EVTSEL_COUNTER_MASK 0xff000000
@@ -1074,13 +1074,174 @@ @@ -1074,13 +1074,174 @@
1074#define K7_SERIALIZE 0xd3 1074#define K7_SERIALIZE 0xd3
1075#define K7_SEGMENT_LOAD_STALL 0xd4 1075#define K7_SEGMENT_LOAD_STALL 0xd4
1076#define K7_ICU_FULL 0xd5 1076#define K7_ICU_FULL 0xd5
1077#define K7_RESERVATION_STATIONS_FULL 0xd6 1077#define K7_RESERVATION_STATIONS_FULL 0xd6
1078#define K7_FPU_FULL 0xd7 1078#define K7_FPU_FULL 0xd7
1079#define K7_LS_FULL 0xd8 1079#define K7_LS_FULL 0xd8
1080#define K7_ALL_QUIET_STALL 0xd9 1080#define K7_ALL_QUIET_STALL 0xd9
1081#define K7_FAR_TRANSFER_OR_RESYNC_BRANCH_PENDING 0xda 1081#define K7_FAR_TRANSFER_OR_RESYNC_BRANCH_PENDING 0xda
1082 1082
1083#define K7_BP0_MATCH 0xdc 1083#define K7_BP0_MATCH 0xdc
1084#define K7_BP1_MATCH 0xdd 1084#define K7_BP1_MATCH 0xdd
1085#define K7_BP2_MATCH 0xde 1085#define K7_BP2_MATCH 0xde
1086#define K7_BP3_MATCH 0xdf 1086#define K7_BP3_MATCH 0xdf
 1087
 1088/*
 1089 * AMD 10h family PMCs. [Doc: 31116.pdf, Jan 2013]
 1090 */
 1091/* Register MSRs */
 1092#define MSR_F10H_EVNTSEL0 0xc0010000
 1093#define MSR_F10H_EVNTSEL1 0xc0010001
 1094#define MSR_F10H_EVNTSEL2 0xc0010002
 1095#define MSR_F10H_EVNTSEL3 0xc0010003
 1096#define MSR_F10H_PERFCTR0 0xc0010004
 1097#define MSR_F10H_PERFCTR1 0xc0010005
 1098#define MSR_F10H_PERFCTR2 0xc0010006
 1099#define MSR_F10H_PERFCTR3 0xc0010007
 1100/* Event Selector MSR format */
 1101#define F10H_EVTSEL_EVENT_MASK 0x000F000000FF
 1102#define F10H_EVTSEL_EVENT_SHIFT_LOW 0
 1103#define F10H_EVTSEL_EVENT_SHIFT_HIGH 32
 1104#define F10H_EVTSEL_UNIT_MASK 0x0000FF00
 1105#define F10H_EVTSEL_UNIT_SHIFT 8
 1106#define F10H_EVTSEL_USR __BIT(16)
 1107#define F10H_EVTSEL_OS __BIT(17)
 1108#define F10H_EVTSEL_EDGE __BIT(18)
 1109#define F10H_EVTSEL_RSVD1 __BIT(19)
 1110#define F10H_EVTSEL_INT __BIT(20)
 1111#define F10H_EVTSEL_RSVD2 __BIT(21)
 1112#define F10H_EVTSEL_EN __BIT(22)
 1113#define F10H_EVTSEL_INV __BIT(23)
 1114#define F10H_EVTSEL_COUNTER_MASK 0xFF000000
 1115#define F10H_EVTSEL_COUNTER_MASK_SHIFT 24
 1116/* Floating Point Events */
 1117#define F10H_FP_DISPATCHED_FPU_OPS 0x00
 1118#define F10H_FP_CYCLES_EMPTY_FPU_OPS 0x01
 1119#define F10H_FP_DISPATCHED_FASTFLAG_OPS 0x02
 1120#define F10H_FP_RETIRED_SSE_OPS 0x03
 1121#define F10H_FP_RETIRED_MOVE_OPS 0x04
 1122#define F10H_FP_RETIRED_SERIALIZING_OPS 0x05
 1123#define F10H_FP_CYCLES_SERIALIZING_OP_SCHEDULER 0x06
 1124/* Load/Store and TLB Events */
 1125#define F10H_SEGMENT_REG_LOADS 0x20
 1126#define F10H_PIPELINE_RESTART_SELFMOD_CODE 0x21
 1127#define F10H_PIPELINE_RESTART_PROBE_HIT 0x22
 1128#define F10H_LS_BUFFER_2_FILL 0x23
 1129#define F10H_LOCKED_OPERATIONS 0x24
 1130#define F10H_RETIRED_CLFLUSH_INSTRUCTIONS 0x26
 1131#define F10H_RETIRED_CPUID_INSTRUCTIONS 0x27
 1132#define F10H_CANCELLED_STORE_LOAD_FORWARD_OPS 0x2A
 1133#define F10H_SMI_RECEIVED 0x2B
 1134/* Data Cache Events */
 1135#define F10H_DATA_CACHE_ACCESSES 0x40
 1136#define F10H_DATA_CACHE_MISSES 0x41
 1137#define F10H_DATA_CACHE_REFILLS_FROM_L2 0x42
 1138#define F10H_DATA_CACHE_REFILLS_FROM_NORTHBRIDGE 0x43
 1139#define F10H_CACHE_LINES_EVICTED 0x44
 1140#define F10H_L1_DTLB_MISS 0x45
 1141#define F10H_L2_DTLB_MISS 0x46
 1142#define F10H_MISALIGNED_ACCESSES 0x47
 1143#define F10H_MICROARCH_LATE_CANCEL_OF_ACCESS 0x48
 1144#define F10H_MICROARCH_EARLY_CANCEL_OF_ACCESS 0x49
 1145#define F10H_SINGLE_BIT_ECC_ERRORS_RECORDED 0x4A
 1146#define F10H_PREFETCH_INSTRUCTIONS_DISPATCHED 0x4B
 1147#define F10H_DCACHE_MISSES_LOCKED_INSTRUCTIONS 0x4C
 1148#define F10H_L1_DTLB_HIT 0x4D
 1149#define F10H_INEFFECTIVE_SOFTWARE_PREFETCHS 0x52
 1150#define F10H_GLOBAL_TLB_FLUSHES 0x54
 1151#define F10H_MEMORY_REQUESTS_BY_TYPE 0x65
 1152#define F10H_DATA_PREFETCHER 0x67
 1153#define F10H_MAB_REQUESTS 0x68
 1154#define F10H_MAB_WAIT_CYCLES 0x69
 1155#define F10H_NORTHBRIDGE_READ_RESP_BY_COH_STATE 0x6C
 1156#define F10H_OCTWORDS_WRITTEN_TO_SYSTEM 0x6D
 1157#define F10H_CPU_CLOCKS_NOT_HALTED 0x76
 1158#define F10H_REQUESTS_TO_L2_CACHE 0x7D
 1159#define F10H_L2_CACHE_MISSES 0x7E
 1160#define F10H_L2_FILL 0x7F
 1161/* F10H_PAGE_SIZE_MISMATCHES (0x01C0): reserved on some revisions */
 1162/* Instruction Cache Events */
 1163#define F10H_INSTRUCTION_CACHE_FETCHES 0x80
 1164#define F10H_INSTRUCTION_CACHE_MISSES 0x81
 1165#define F10H_INSTRUCTION_CACHE_REFILLS_FROM_L2 0x82
 1166#define F10H_INSTRUCTION_CACHE_REFILLS_FROM_SYS 0x83
 1167#define F10H_L1_ITLB_MISS 0x84
 1168#define F10H_L2_ITLB_MISS 0x85
 1169#define F10H_PIPELINE_RESTART_INSTR_STREAM_PROBE 0x86
 1170#define F10H_INSTRUCTION_FETCH_STALL 0x87
 1171#define F10H_RETURN_STACK_HITS 0x88
 1172#define F10H_RETURN_STACK_OVERFLOWS 0x89
 1173#define F10H_INSTRUCTION_CACHE_VICTIMS 0x8B
 1174#define F10H_INSTRUCTION_CACHE_LINES_INVALIDATED 0x8C
 1175#define F10H_ITLD_RELOADS 0x99
 1176#define F10H_ITLD_RELOADS_ABORTED 0x9A
 1177/* Execution Unit Events */
 1178#define F10H_RETIRED_INSTRUCTIONS 0xC0
 1179#define F10H_RETIRED_UOPS 0xC1
 1180#define F10H_RETIRED_BRANCH_INSTRUCTIONS 0xC2
 1181#define F10H_RETIRED_MISPREDICTED_BRANCH_INSTR 0xC3
 1182#define F10H_RETIRED_TAKEN_BRANCH_INSTRUCTIONS 0xC4
 1183#define F10H_RETIRED_TAKEN_BRANCH_INSTR_MISPREDICTED 0xC5
 1184#define F10H_RETIRED_FAR_CONTROL_TRANSFERS 0xC6
 1185#define F10H_RETIRED_BRANCH_RESYNCS 0xC7
 1186#define F10H_RETIRED_NEAR_RETURNS 0xC8
 1187#define F10H_RETIRED_NEAR_RETURNS_MISPREDICTED 0xC9
 1188#define F10H_RETIRED_INDIRECT_BRANCHES_MISPREDICTED 0xCA
 1189#define F10H_RETIRED_MMX_FP_INSTRUCTIONS 0xCB
 1190#define F10H_RETIRED_FASTPATH_DOUBLE_OP_INSTR 0xCC
 1191#define F10H_INTERRUPTS_MASKED_CYCLES 0xCD
 1192#define F10H_INTERRUPTS_MASKED_CYCLES_INTERRUPT_PENDING 0xCE
 1193#define F10H_INTERRUPTS_TAKEN 0xCF
 1194#define F10H_DECODER_EMPTY 0xD0
 1195#define F10H_DISPATCH_STALLS 0xD1
 1196#define F10H_DISPATCH_STALLS_BRANCH_ABORT_RETIRE 0xD2
 1197#define F10H_DISPATCH_STALLS_SERIALIZATION 0xD3
 1198#define F10H_DISPATCH_STALLS_SEGMENT_LOAD 0xD4
 1199#define F10H_DISPATCH_STALLS_REORDER_BUF_FULL 0xD5
 1200#define F10H_DISPATCH_STALLS_RSV_STATION_FULL 0xD6
 1201#define F10H_DISPATCH_STALLS_FPU_FULL 0xD7
 1202#define F10H_DISPATCH_STALLS_LS_FULL 0xD8
 1203#define F10H_DISPATCH_STALLS_WAITING_ALL_QUITE 0xD9
 1204#define F10H_DISPATCH_STALLS_FAR_TRANSFER 0xDA
 1205#define F10H_FPU_EXCEPTIONS 0xDB
 1206#define F10H_DR0_BREAKPOINT_MATCHES 0xDC
 1207#define F10H_DR1_BREAKPOINT_MATCHES 0xDD
 1208#define F10H_DR2_BREAKPOINT_MATCHES 0xDE
 1209#define F10H_DR3_BREAKPOINT_MATCHES 0xDF
 1210/* F10H_RETIRED_X87_FP_OPERATIONS (0x01C0): reserved on some revisions */
 1211/* F10H_IBS_OPS_TAGGED (0x1CF): reserved on some revisions */
 1212/* F10H_LFENCE_INSTRUCTIONS_RETIRED (0x01D3): reserved on some revisions */
 1213/* F10H_SFENCE_INSTRUCTIONS_RETIRED (0x01D4): reserved on some revisions */
 1214/* F10H_MFENCE_INSTRUCTIONS_RETIRED (0x01D5): reserved on some revisions */
 1215/* Memory Controller Events */
 1216#define F10H_DRAM_ACCESSES 0xE0
 1217#define F10H_DRAM_CONTROLLER_PT_OVERFLOWS 0xE1
 1218#define F10H_MEM_CONTROLLER_DRAM_COMMAND_SLOTS_MISSED 0xE2
 1219#define F10H_MEM_CONTROLLER_TURNAROUNDS 0xE3
 1220#define F10H_MEM_CONTROLLER_BYPASS_COUNTER_SATURATION 0xE4
 1221#define F10H_THERMAL_STATUS 0xE8
 1222#define F10H_CPU_IO_REQUESTS_TO_MEMORY_IO 0xE9
 1223#define F10H_CACHE_BLOCK_COMMANDS 0xEA
 1224#define F10H_SIZED_COMMANDS 0xEB
 1225#define F10H_PROBE_RESPONSES_AND_UPSTREAM_REQUESTS 0xEC
 1226#define F10H_GART_EVENTS 0xEE
 1227#define F10H_MEMORY_CONTROLLER_REQUESTS 0x01F0
 1228#define F10H_CPU_TO_DRAM_REQUESTS_TO_TARGET_NODE 0x01E0
 1229#define F10H_IO_TO_DRAM_REQUESTS_TO_TARGET_NODE 0x01E1
 1230#define F10H_CPU_READ_CMD_LATENCY_TARGET_NODE_03 0x01E2
 1231#define F10H_CPU_READ_CMD_REQUESTS_TARGET_NODE_03 0x01E3
 1232#define F10H_CPU_READ_CMD_LATENCY_TARGET_NODE_47 0x01E4
 1233#define F10H_CPU_READ_CMD_REQUESTS_TARGET_NODE_47 0x01E5
 1234#define F10H_CPU_CMD_LATENCY_TO_TARGET_NODE_0347 0x01E6
 1235#define F10H_CPU_REQUESTS_TO_TARGET_NODE_0347 0x01E7
 1236/* Link Events */
 1237#define F10H_HYPERTRANSPORT_LINK0_TRANSMIT_BANDWIDTH 0xF6
 1238#define F10H_HYPERTRANSPORT_LINK1_TRANSMIT_BANDWIDTH 0xF7
 1239#define F10H_HYPERTRANSPORT_LINK2_TRANSMIT_BANDWIDTH 0xF8
 1240#define F10H_HYPERTRANSPORT_LINK3_TRANSMIT_BANDWIDTH 0x01F9
 1241/* L3 Cache Events */
 1242/* F10H_READ_READ_REQUEST_TO_L3_CACHE (0x04E0): depends on the revision */
 1243/* F10H_L3_CACHE_MISSES (0x04E1): depends on the revision */
 1244/* F10H_L3_FILLS_FROM_L2_EVICTIONS (0x04E2): depends on the revision */
 1245#define F10H_L3_EVICTIONS 0x04E3
 1246/* F10H_NONCANCELLED_L3_READ_REQUESTS (0x04ED): depends on the revision */
 1247