Skip to content

Commit 904cb36

Browse files
Aravind GopalakrishnanIngo Molnar
authored andcommitted
perf/x86/amd/ibs: Update IBS MSRs and feature definitions
New Fam15h models carry extra feature bits and extend the MSR register space for IBS ops. Adding them here. While at it, add functionality to read IbsBrTarget and OpData4 depending on their availability if user wants a PERF_SAMPLE_RAW. Signed-off-by: Aravind Gopalakrishnan <[email protected]> Acked-by: Borislav Petkov <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Jan Kiszka <[email protected]> Cc: Len Brown <[email protected]> Cc: Fenghua Yu <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 322cd21 commit 904cb36

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

arch/x86/include/asm/perf_event.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ struct x86_pmu_capability {
177177
#define IBS_CAPS_BRNTRGT (1U<<5)
178178
#define IBS_CAPS_OPCNTEXT (1U<<6)
179179
#define IBS_CAPS_RIPINVALIDCHK (1U<<7)
180+
#define IBS_CAPS_OPBRNFUSE (1U<<8)
181+
#define IBS_CAPS_FETCHCTLEXTD (1U<<9)
182+
#define IBS_CAPS_OPDATA4 (1U<<10)
180183

181184
#define IBS_CAPS_DEFAULT (IBS_CAPS_AVAIL \
182185
| IBS_CAPS_FETCHSAM \

arch/x86/include/uapi/asm/msr-index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
#define MSR_AMD64_IBSOP_REG_MASK ((1UL<<MSR_AMD64_IBSOP_REG_COUNT)-1)
207207
#define MSR_AMD64_IBSCTL 0xc001103a
208208
#define MSR_AMD64_IBSBRTARGET 0xc001103b
209+
#define MSR_AMD64_IBSOPDATA4 0xc001103d
209210
#define MSR_AMD64_IBS_REG_COUNT_MAX 8 /* includes MSR_AMD64_IBSBRTARGET */
210211

211212
/* Fam 16h MSRs */

arch/x86/kernel/cpu/perf_event_amd_ibs.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,21 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
565565
perf_ibs->offset_max,
566566
offset + 1);
567567
} while (offset < offset_max);
568+
if (event->attr.sample_type & PERF_SAMPLE_RAW) {
569+
/*
570+
* Read IbsBrTarget and IbsOpData4 separately
571+
* depending on their availability.
572+
* Can't add to offset_max as they are staggered
573+
*/
574+
if (ibs_caps & IBS_CAPS_BRNTRGT) {
575+
rdmsrl(MSR_AMD64_IBSBRTARGET, *buf++);
576+
size++;
577+
}
578+
if (ibs_caps & IBS_CAPS_OPDATA4) {
579+
rdmsrl(MSR_AMD64_IBSOPDATA4, *buf++);
580+
size++;
581+
}
582+
}
568583
ibs_data.size = sizeof(u64) * size;
569584

570585
regs = *iregs;

0 commit comments

Comments
 (0)