|
@@ -47,6 +47,10 @@
|
|
#define CTRL_SET_HOST_ONLY(val, h) (val |= ((h & 1) << 9))
|
|
#define CTRL_SET_HOST_ONLY(val, h) (val |= ((h & 1) << 9))
|
|
#define CTRL_SET_GUEST_ONLY(val, h) (val |= ((h & 1) << 8))
|
|
#define CTRL_SET_GUEST_ONLY(val, h) (val |= ((h & 1) << 8))
|
|
|
|
|
|
|
|
+static unsigned long reset_value[NUM_COUNTERS];
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_OPROFILE_IBS
|
|
|
|
+
|
|
/* IbsFetchCtl bits/masks */
|
|
/* IbsFetchCtl bits/masks */
|
|
#define IBS_FETCH_HIGH_VALID_BIT (1UL << 17) /* bit 49 */
|
|
#define IBS_FETCH_HIGH_VALID_BIT (1UL << 17) /* bit 49 */
|
|
#define IBS_FETCH_HIGH_ENABLE (1UL << 16) /* bit 48 */
|
|
#define IBS_FETCH_HIGH_ENABLE (1UL << 16) /* bit 48 */
|
|
@@ -104,7 +108,6 @@ struct ibs_op_sample {
|
|
*/
|
|
*/
|
|
static void clear_ibs_nmi(void);
|
|
static void clear_ibs_nmi(void);
|
|
|
|
|
|
-static unsigned long reset_value[NUM_COUNTERS];
|
|
|
|
static int ibs_allowed; /* AMD Family10h and later */
|
|
static int ibs_allowed; /* AMD Family10h and later */
|
|
|
|
|
|
struct op_ibs_config {
|
|
struct op_ibs_config {
|
|
@@ -118,6 +121,8 @@ struct op_ibs_config {
|
|
|
|
|
|
static struct op_ibs_config ibs_config;
|
|
static struct op_ibs_config ibs_config;
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
/* functions for op_amd_spec */
|
|
/* functions for op_amd_spec */
|
|
|
|
|
|
static void op_amd_fill_in_addresses(struct op_msrs * const msrs)
|
|
static void op_amd_fill_in_addresses(struct op_msrs * const msrs)
|
|
@@ -188,6 +193,8 @@ static void op_amd_setup_ctrs(struct op_msrs const * const msrs)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_OPROFILE_IBS
|
|
|
|
+
|
|
static inline int
|
|
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)
|
|
@@ -261,6 +268,8 @@ op_amd_handle_ibs(struct pt_regs * const regs,
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
static int op_amd_check_ctrs(struct pt_regs * const regs,
|
|
static int op_amd_check_ctrs(struct pt_regs * const regs,
|
|
struct op_msrs const * const msrs)
|
|
struct op_msrs const * const msrs)
|
|
{
|
|
{
|
|
@@ -277,7 +286,9 @@ static int op_amd_check_ctrs(struct pt_regs * const regs,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_OPROFILE_IBS
|
|
op_amd_handle_ibs(regs, msrs);
|
|
op_amd_handle_ibs(regs, msrs);
|
|
|
|
+#endif
|
|
|
|
|
|
/* See op_model_ppro.c */
|
|
/* See op_model_ppro.c */
|
|
return 1;
|
|
return 1;
|
|
@@ -294,6 +305,8 @@ static void op_amd_start(struct op_msrs const * const msrs)
|
|
CTRL_WRITE(low, high, msrs, i);
|
|
CTRL_WRITE(low, high, msrs, i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_OPROFILE_IBS
|
|
if (ibs_allowed && ibs_config.fetch_enabled) {
|
|
if (ibs_allowed && ibs_config.fetch_enabled) {
|
|
low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
|
|
low = (ibs_config.max_cnt_fetch >> 4) & 0xFFFF;
|
|
high = IBS_FETCH_HIGH_ENABLE;
|
|
high = IBS_FETCH_HIGH_ENABLE;
|
|
@@ -305,6 +318,7 @@ static void op_amd_start(struct op_msrs const * const msrs)
|
|
high = 0;
|
|
high = 0;
|
|
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
|
|
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -323,6 +337,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
|
|
CTRL_WRITE(low, high, msrs, i);
|
|
CTRL_WRITE(low, high, msrs, i);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_OPROFILE_IBS
|
|
if (ibs_allowed && ibs_config.fetch_enabled) {
|
|
if (ibs_allowed && ibs_config.fetch_enabled) {
|
|
low = 0; /* clear max count and enable */
|
|
low = 0; /* clear max count and enable */
|
|
high = 0;
|
|
high = 0;
|
|
@@ -334,6 +349,7 @@ static void op_amd_stop(struct op_msrs const * const msrs)
|
|
high = 0;
|
|
high = 0;
|
|
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
|
|
wrmsr(MSR_AMD64_IBSOPCTL, low, high);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
static void op_amd_shutdown(struct op_msrs const * const msrs)
|
|
static void op_amd_shutdown(struct op_msrs const * const msrs)
|
|
@@ -350,17 +366,10 @@ static void op_amd_shutdown(struct op_msrs const * const msrs)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-#ifndef CONFIG_SMP
|
|
|
|
|
|
+#ifndef CONFIG_OPROFILE_IBS
|
|
|
|
|
|
/* no IBS support */
|
|
/* no IBS support */
|
|
|
|
|
|
-static void setup_ibs(void)
|
|
|
|
-{
|
|
|
|
- ibs_allowed = 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static void clear_ibs_nmi(void) {}
|
|
|
|
-
|
|
|
|
static int op_amd_init(struct oprofile_operations *ops)
|
|
static int op_amd_init(struct oprofile_operations *ops)
|
|
{
|
|
{
|
|
return 0;
|
|
return 0;
|
|
@@ -441,8 +450,12 @@ static void setup_ibs(void)
|
|
if (!ibs_allowed)
|
|
if (!ibs_allowed)
|
|
return;
|
|
return;
|
|
|
|
|
|
- if (pfm_amd64_setup_eilvt())
|
|
|
|
|
|
+ if (pfm_amd64_setup_eilvt()) {
|
|
ibs_allowed = 0;
|
|
ibs_allowed = 0;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ printk(KERN_INFO "oprofile: AMD IBS detected\n");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|