Skip to content

Commit 8de3f7a

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: "Two kernel side fixes: - an Intel uncore PMU driver potential crash fix - a kprobes/perf-call-graph interaction fix" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel: Use rdmsrl_safe() when initializing RAPL PMU kprobes/x86: Fix page-fault handling logic
2 parents b931242 + 2422365 commit 8de3f7a

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

arch/x86/kernel/cpu/perf_event_intel_rapl.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,17 @@ static int rapl_cpu_prepare(int cpu)
535535
struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu);
536536
int phys_id = topology_physical_package_id(cpu);
537537
u64 ms;
538+
u64 msr_rapl_power_unit_bits;
538539

539540
if (pmu)
540541
return 0;
541542

542543
if (phys_id < 0)
543544
return -1;
544545

546+
if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits))
547+
return -1;
548+
545549
pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu));
546550
if (!pmu)
547551
return -1;
@@ -555,8 +559,7 @@ static int rapl_cpu_prepare(int cpu)
555559
*
556560
* we cache in local PMU instance
557561
*/
558-
rdmsrl(MSR_RAPL_POWER_UNIT, pmu->hw_unit);
559-
pmu->hw_unit = (pmu->hw_unit >> 8) & 0x1FULL;
562+
pmu->hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL;
560563
pmu->pmu = &rapl_pmu_class;
561564

562565
/*
@@ -677,7 +680,9 @@ static int __init rapl_pmu_init(void)
677680
cpu_notifier_register_begin();
678681

679682
for_each_online_cpu(cpu) {
680-
rapl_cpu_prepare(cpu);
683+
ret = rapl_cpu_prepare(cpu);
684+
if (ret)
685+
goto out;
681686
rapl_cpu_init(cpu);
682687
}
683688

@@ -700,6 +705,7 @@ static int __init rapl_pmu_init(void)
700705
hweight32(rapl_cntr_mask),
701706
ktime_to_ms(pmu->timer_interval));
702707

708+
out:
703709
cpu_notifier_register_done();
704710

705711
return 0;

arch/x86/kernel/kprobes/core.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,10 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
897897
struct kprobe *cur = kprobe_running();
898898
struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
899899

900-
switch (kcb->kprobe_status) {
901-
case KPROBE_HIT_SS:
902-
case KPROBE_REENTER:
900+
if (unlikely(regs->ip == (unsigned long)cur->ainsn.insn)) {
901+
/* This must happen on single-stepping */
902+
WARN_ON(kcb->kprobe_status != KPROBE_HIT_SS &&
903+
kcb->kprobe_status != KPROBE_REENTER);
903904
/*
904905
* We are here because the instruction being single
905906
* stepped caused a page fault. We reset the current
@@ -914,9 +915,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
914915
else
915916
reset_current_kprobe();
916917
preempt_enable_no_resched();
917-
break;
918-
case KPROBE_HIT_ACTIVE:
919-
case KPROBE_HIT_SSDONE:
918+
} else if (kcb->kprobe_status == KPROBE_HIT_ACTIVE ||
919+
kcb->kprobe_status == KPROBE_HIT_SSDONE) {
920920
/*
921921
* We increment the nmissed count for accounting,
922922
* we can also use npre/npostfault count for accounting
@@ -945,10 +945,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr)
945945
* fixup routine could not handle it,
946946
* Let do_page_fault() fix it.
947947
*/
948-
break;
949-
default:
950-
break;
951948
}
949+
952950
return 0;
953951
}
954952

0 commit comments

Comments
 (0)