Skip to content

Commit 355f83c

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar: "Misc fixes: an ABI fix for a reserved field, AMD IBS fixes, an Intel uncore PMU driver fix and a header typo fix" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/headers: Fix spelling s/EACCESS/EACCES/, s/privilidge/privilege/ perf/x86/uncore: Fix event group support perf/x86/amd/ibs: Handle erratum #420 only on the affected CPU family (10h) perf/x86/amd/ibs: Fix reading of the IBS OpData register and thus precise RIP validity perf/core: Start rejecting the syscall with attr.__reserved_2 set
2 parents b2a18c2 + 652521d commit 355f83c

File tree

5 files changed

+45
-23
lines changed

5 files changed

+45
-23
lines changed

arch/x86/events/amd/ibs.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ static inline void perf_ibs_disable_event(struct perf_ibs *perf_ibs,
377377
struct hw_perf_event *hwc, u64 config)
378378
{
379379
config &= ~perf_ibs->cnt_mask;
380-
wrmsrl(hwc->config_base, config);
380+
if (boot_cpu_data.x86 == 0x10)
381+
wrmsrl(hwc->config_base, config);
381382
config &= ~perf_ibs->enable_mask;
382383
wrmsrl(hwc->config_base, config);
383384
}
@@ -553,7 +554,8 @@ static struct perf_ibs perf_ibs_op = {
553554
},
554555
.msr = MSR_AMD64_IBSOPCTL,
555556
.config_mask = IBS_OP_CONFIG_MASK,
556-
.cnt_mask = IBS_OP_MAX_CNT,
557+
.cnt_mask = IBS_OP_MAX_CNT | IBS_OP_CUR_CNT |
558+
IBS_OP_CUR_CNT_RAND,
557559
.enable_mask = IBS_OP_ENABLE,
558560
.valid_mask = IBS_OP_VAL,
559561
.max_period = IBS_OP_MAX_CNT << 4,
@@ -614,7 +616,7 @@ static int perf_ibs_handle_irq(struct perf_ibs *perf_ibs, struct pt_regs *iregs)
614616
if (event->attr.sample_type & PERF_SAMPLE_RAW)
615617
offset_max = perf_ibs->offset_max;
616618
else if (check_rip)
617-
offset_max = 2;
619+
offset_max = 3;
618620
else
619621
offset_max = 1;
620622
do {

arch/x86/events/intel/uncore.c

+38-6
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,8 @@ void uncore_pmu_event_start(struct perf_event *event, int flags)
502502
local64_set(&event->hw.prev_count, uncore_read_counter(box, event));
503503
uncore_enable_event(box, event);
504504

505-
if (box->n_active == 1) {
506-
uncore_enable_box(box);
505+
if (box->n_active == 1)
507506
uncore_pmu_start_hrtimer(box);
508-
}
509507
}
510508

511509
void uncore_pmu_event_stop(struct perf_event *event, int flags)
@@ -529,10 +527,8 @@ void uncore_pmu_event_stop(struct perf_event *event, int flags)
529527
WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
530528
hwc->state |= PERF_HES_STOPPED;
531529

532-
if (box->n_active == 0) {
533-
uncore_disable_box(box);
530+
if (box->n_active == 0)
534531
uncore_pmu_cancel_hrtimer(box);
535-
}
536532
}
537533

538534
if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
@@ -778,6 +774,40 @@ static int uncore_pmu_event_init(struct perf_event *event)
778774
return ret;
779775
}
780776

777+
static void uncore_pmu_enable(struct pmu *pmu)
778+
{
779+
struct intel_uncore_pmu *uncore_pmu;
780+
struct intel_uncore_box *box;
781+
782+
uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu);
783+
if (!uncore_pmu)
784+
return;
785+
786+
box = uncore_pmu_to_box(uncore_pmu, smp_processor_id());
787+
if (!box)
788+
return;
789+
790+
if (uncore_pmu->type->ops->enable_box)
791+
uncore_pmu->type->ops->enable_box(box);
792+
}
793+
794+
static void uncore_pmu_disable(struct pmu *pmu)
795+
{
796+
struct intel_uncore_pmu *uncore_pmu;
797+
struct intel_uncore_box *box;
798+
799+
uncore_pmu = container_of(pmu, struct intel_uncore_pmu, pmu);
800+
if (!uncore_pmu)
801+
return;
802+
803+
box = uncore_pmu_to_box(uncore_pmu, smp_processor_id());
804+
if (!box)
805+
return;
806+
807+
if (uncore_pmu->type->ops->disable_box)
808+
uncore_pmu->type->ops->disable_box(box);
809+
}
810+
781811
static ssize_t uncore_get_attr_cpumask(struct device *dev,
782812
struct device_attribute *attr, char *buf)
783813
{
@@ -803,6 +833,8 @@ static int uncore_pmu_register(struct intel_uncore_pmu *pmu)
803833
pmu->pmu = (struct pmu) {
804834
.attr_groups = pmu->type->attr_groups,
805835
.task_ctx_nr = perf_invalid_context,
836+
.pmu_enable = uncore_pmu_enable,
837+
.pmu_disable = uncore_pmu_disable,
806838
.event_init = uncore_pmu_event_init,
807839
.add = uncore_pmu_event_add,
808840
.del = uncore_pmu_event_del,

arch/x86/events/intel/uncore.h

-12
Original file line numberDiff line numberDiff line change
@@ -441,18 +441,6 @@ static inline int uncore_freerunning_hw_config(struct intel_uncore_box *box,
441441
return -EINVAL;
442442
}
443443

444-
static inline void uncore_disable_box(struct intel_uncore_box *box)
445-
{
446-
if (box->pmu->type->ops->disable_box)
447-
box->pmu->type->ops->disable_box(box);
448-
}
449-
450-
static inline void uncore_enable_box(struct intel_uncore_box *box)
451-
{
452-
if (box->pmu->type->ops->enable_box)
453-
box->pmu->type->ops->enable_box(box);
454-
}
455-
456444
static inline void uncore_disable_event(struct intel_uncore_box *box,
457445
struct perf_event *event)
458446
{

include/linux/perf_event.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ struct pmu {
292292
* -EBUSY -- @event is for this PMU but PMU temporarily unavailable
293293
* -EINVAL -- @event is for this PMU but @event is not valid
294294
* -EOPNOTSUPP -- @event is for this PMU, @event is valid, but not supported
295-
* -EACCESS -- @event is for this PMU, @event is valid, but no privilidges
295+
* -EACCES -- @event is for this PMU, @event is valid, but no privileges
296296
*
297297
* 0 -- @event is for this PMU and valid
298298
*

kernel/events/core.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10635,7 +10635,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
1063510635

1063610636
attr->size = size;
1063710637

10638-
if (attr->__reserved_1)
10638+
if (attr->__reserved_1 || attr->__reserved_2)
1063910639
return -EINVAL;
1064010640

1064110641
if (attr->sample_type & ~(PERF_SAMPLE_MAX-1))

0 commit comments

Comments
 (0)