Commit c572ae4e authored by Robert Richter's avatar Robert Richter

x86/oprofile: use 64 bit values in IBS functions

The IBS code internally uses 32 bit values (a low and a high value) to
represent a 64 bit value. This patch changes this and now 64 bit
values are used instead. 64 bit MSR functions can be used now.

No functional changes.
Signed-off-by: default avatarRobert Richter <robert.richter@amd.com>
parent 1a245c45
...@@ -35,16 +35,18 @@ static unsigned long reset_value[NUM_COUNTERS]; ...@@ -35,16 +35,18 @@ static unsigned long reset_value[NUM_COUNTERS];
#ifdef CONFIG_OPROFILE_IBS #ifdef CONFIG_OPROFILE_IBS
/* IbsFetchCtl bits/masks */ /* IbsFetchCtl bits/masks */
#define IBS_FETCH_HIGH_VALID_BIT (1UL << 17) /* bit 49 */ #define IBS_FETCH_RAND_EN (1ULL<<57)
#define IBS_FETCH_HIGH_ENABLE (1UL << 16) /* bit 48 */ #define IBS_FETCH_VAL (1ULL<<49)
#define IBS_FETCH_LOW_MAX_CNT_MASK 0x0000FFFFUL /* MaxCnt mask */ #define IBS_FETCH_ENABLE (1ULL<<48)
#define IBS_FETCH_CNT_MASK 0xFFFF0000ULL
/*IbsOpCtl bits */ /*IbsOpCtl bits */
#define IBS_OP_LOW_VALID_BIT (1ULL<<18) /* bit 18 */ #define IBS_OP_CNT_CTL (1ULL<<19)
#define IBS_OP_LOW_ENABLE (1ULL<<17) /* bit 17 */ #define IBS_OP_VAL (1ULL<<18)
#define IBS_OP_ENABLE (1ULL<<17)
#define IBS_FETCH_SIZE 6 #define IBS_FETCH_SIZE 6
#define IBS_OP_SIZE 12 #define IBS_OP_SIZE 12
static int has_ibs; /* AMD Family10h and later */ static int has_ibs; /* AMD Family10h and later */
...@@ -126,66 +128,63 @@ static inline int ...@@ -126,66 +128,63 @@ static inline int
op_amd_handle_ibs(struct pt_regs * const regs, op_amd_handle_ibs(struct pt_regs * const regs,
struct op_msrs const * const msrs) struct op_msrs const * const msrs)
{ {
u32 low, high; u64 val, ctl;
u64 msr;
struct op_entry entry; struct op_entry entry;
if (!has_ibs) if (!has_ibs)
return 1; return 1;
if (ibs_config.fetch_enabled) { if (ibs_config.fetch_enabled) {
rdmsr(MSR_AMD64_IBSFETCHCTL, low, high); rdmsrl(MSR_AMD64_IBSFETCHCTL, ctl);
if (high & IBS_FETCH_HIGH_VALID_BIT) { if (ctl & IBS_FETCH_VAL) {
rdmsrl(MSR_AMD64_IBSFETCHLINAD, msr); rdmsrl(MSR_AMD64_IBSFETCHLINAD, val);
oprofile_write_reserve(&entry, regs, msr, oprofile_write_reserve(&entry, regs, val,
IBS_FETCH_CODE, IBS_FETCH_SIZE); IBS_FETCH_CODE, IBS_FETCH_SIZE);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_add_data(&entry, low); oprofile_add_data(&entry, (u32)ctl);
oprofile_add_data(&entry, high); oprofile_add_data(&entry, (u32)(ctl >> 32));
rdmsrl(MSR_AMD64_IBSFETCHPHYSAD, msr); rdmsrl(MSR_AMD64_IBSFETCHPHYSAD, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_write_commit(&entry); oprofile_write_commit(&entry);
/* reenable the IRQ */ /* reenable the IRQ */
high &= ~IBS_FETCH_HIGH_VALID_BIT; ctl &= ~(IBS_FETCH_VAL | IBS_FETCH_CNT_MASK);
high |= IBS_FETCH_HIGH_ENABLE; ctl |= IBS_FETCH_ENABLE;
low &= IBS_FETCH_LOW_MAX_CNT_MASK; wrmsrl(MSR_AMD64_IBSFETCHCTL, ctl);
wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
} }
} }
if (ibs_config.op_enabled) { if (ibs_config.op_enabled) {
rdmsr(MSR_AMD64_IBSOPCTL, low, high); rdmsrl(MSR_AMD64_IBSOPCTL, ctl);
if (low & IBS_OP_LOW_VALID_BIT) { if (ctl & IBS_OP_VAL) {
rdmsrl(MSR_AMD64_IBSOPRIP, msr); rdmsrl(MSR_AMD64_IBSOPRIP, val);
oprofile_write_reserve(&entry, regs, msr, oprofile_write_reserve(&entry, regs, val,
IBS_OP_CODE, IBS_OP_SIZE); IBS_OP_CODE, IBS_OP_SIZE);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA, msr); rdmsrl(MSR_AMD64_IBSOPDATA, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA2, msr); rdmsrl(MSR_AMD64_IBSOPDATA2, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
rdmsrl(MSR_AMD64_IBSOPDATA3, msr); rdmsrl(MSR_AMD64_IBSOPDATA3, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
rdmsrl(MSR_AMD64_IBSDCLINAD, msr); rdmsrl(MSR_AMD64_IBSDCLINAD, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
rdmsrl(MSR_AMD64_IBSDCPHYSAD, msr); rdmsrl(MSR_AMD64_IBSDCPHYSAD, val);
oprofile_add_data(&entry, (u32)msr); oprofile_add_data(&entry, (u32)val);
oprofile_add_data(&entry, (u32)(msr >> 32)); oprofile_add_data(&entry, (u32)(val >> 32));
oprofile_write_commit(&entry); oprofile_write_commit(&entry);
/* reenable the IRQ */ /* reenable the IRQ */
high = 0; ctl &= ~IBS_OP_VAL & 0xFFFFFFFF;
low &= ~IBS_OP_LOW_VALID_BIT; ctl |= IBS_OP_ENABLE;
low |= IBS_OP_LOW_ENABLE; wrmsrl(MSR_AMD64_IBSOPCTL, ctl);
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
} }
} }
...@@ -194,39 +193,31 @@ op_amd_handle_ibs(struct pt_regs * const regs, ...@@ -194,39 +193,31 @@ op_amd_handle_ibs(struct pt_regs * const regs,
static inline void op_amd_start_ibs(void) static inline void op_amd_start_ibs(void)
{ {
unsigned int low, high; u64 val;
if (has_ibs && ibs_config.fetch_enabled) { if (has_ibs && ibs_config.fetch_enabled) {
low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF; val = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
high = ((ibs_config.rand_en & 0x1) << 25) /* bit 57 */ val |= ibs_config.rand_en ? IBS_FETCH_RAND_EN : 0;
+ IBS_FETCH_HIGH_ENABLE; val |= IBS_FETCH_ENABLE;
wrmsr(MSR_AMD64_IBSFETCHCTL, low, high); wrmsrl(MSR_AMD64_IBSFETCHCTL, val);
} }
if (has_ibs && ibs_config.op_enabled) { if (has_ibs && ibs_config.op_enabled) {
low = ((ibs_config.max_cnt_op >> 4) & 0xFFFF) val = (ibs_config.max_cnt_op >> 4) & 0xFFFF;
+ ((ibs_config.dispatched_ops & 0x1) << 19) /* bit 19 */ val |= ibs_config.dispatched_ops ? IBS_OP_CNT_CTL : 0;
+ IBS_OP_LOW_ENABLE; val |= IBS_OP_ENABLE;
high = 0; wrmsrl(MSR_AMD64_IBSOPCTL, val);
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
} }
} }
static void op_amd_stop_ibs(void) static void op_amd_stop_ibs(void)
{ {
unsigned int low, high; if (has_ibs && ibs_config.fetch_enabled)
if (has_ibs && ibs_config.fetch_enabled) {
/* clear max count and enable */ /* clear max count and enable */
low = 0; wrmsrl(MSR_AMD64_IBSFETCHCTL, 0);
high = 0;
wrmsr(MSR_AMD64_IBSFETCHCTL, low, high);
}
if (has_ibs && ibs_config.op_enabled) { if (has_ibs && ibs_config.op_enabled)
/* clear max count and enable */ /* clear max count and enable */
low = 0; wrmsrl(MSR_AMD64_IBSOPCTL, 0);
high = 0;
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
}
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment