diff options
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_rapl.c | 12 | ||||
-rw-r--r-- | arch/x86/kernel/kprobes/core.c | 16 |
2 files changed, 16 insertions, 12 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c index 4b9a9e9466bd..7c87424d4140 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c +++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c | |||
@@ -535,6 +535,7 @@ static int rapl_cpu_prepare(int cpu) | |||
535 | struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu); | 535 | struct rapl_pmu *pmu = per_cpu(rapl_pmu, cpu); |
536 | int phys_id = topology_physical_package_id(cpu); | 536 | int phys_id = topology_physical_package_id(cpu); |
537 | u64 ms; | 537 | u64 ms; |
538 | u64 msr_rapl_power_unit_bits; | ||
538 | 539 | ||
539 | if (pmu) | 540 | if (pmu) |
540 | return 0; | 541 | return 0; |
@@ -542,6 +543,9 @@ static int rapl_cpu_prepare(int cpu) | |||
542 | if (phys_id < 0) | 543 | if (phys_id < 0) |
543 | return -1; | 544 | return -1; |
544 | 545 | ||
546 | if (!rdmsrl_safe(MSR_RAPL_POWER_UNIT, &msr_rapl_power_unit_bits)) | ||
547 | return -1; | ||
548 | |||
545 | pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); | 549 | pmu = kzalloc_node(sizeof(*pmu), GFP_KERNEL, cpu_to_node(cpu)); |
546 | if (!pmu) | 550 | if (!pmu) |
547 | return -1; | 551 | return -1; |
@@ -555,8 +559,7 @@ static int rapl_cpu_prepare(int cpu) | |||
555 | * | 559 | * |
556 | * we cache in local PMU instance | 560 | * we cache in local PMU instance |
557 | */ | 561 | */ |
558 | rdmsrl(MSR_RAPL_POWER_UNIT, pmu->hw_unit); | 562 | pmu->hw_unit = (msr_rapl_power_unit_bits >> 8) & 0x1FULL; |
559 | pmu->hw_unit = (pmu->hw_unit >> 8) & 0x1FULL; | ||
560 | pmu->pmu = &rapl_pmu_class; | 563 | pmu->pmu = &rapl_pmu_class; |
561 | 564 | ||
562 | /* | 565 | /* |
@@ -677,7 +680,9 @@ static int __init rapl_pmu_init(void) | |||
677 | cpu_notifier_register_begin(); | 680 | cpu_notifier_register_begin(); |
678 | 681 | ||
679 | for_each_online_cpu(cpu) { | 682 | for_each_online_cpu(cpu) { |
680 | rapl_cpu_prepare(cpu); | 683 | ret = rapl_cpu_prepare(cpu); |
684 | if (ret) | ||
685 | goto out; | ||
681 | rapl_cpu_init(cpu); | 686 | rapl_cpu_init(cpu); |
682 | } | 687 | } |
683 | 688 | ||
@@ -700,6 +705,7 @@ static int __init rapl_pmu_init(void) | |||
700 | hweight32(rapl_cntr_mask), | 705 | hweight32(rapl_cntr_mask), |
701 | ktime_to_ms(pmu->timer_interval)); | 706 | ktime_to_ms(pmu->timer_interval)); |
702 | 707 | ||
708 | out: | ||
703 | cpu_notifier_register_done(); | 709 | cpu_notifier_register_done(); |
704 | 710 | ||
705 | return 0; | 711 | return 0; |
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 79a3f9682871..61b17dc2c277 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
@@ -897,9 +897,10 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) | |||
897 | struct kprobe *cur = kprobe_running(); | 897 | struct kprobe *cur = kprobe_running(); |
898 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | 898 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
899 | 899 | ||
900 | switch (kcb->kprobe_status) { | 900 | if (unlikely(regs->ip == (unsigned long)cur->ainsn.insn)) { |
901 | case KPROBE_HIT_SS: | 901 | /* This must happen on single-stepping */ |
902 | case KPROBE_REENTER: | 902 | WARN_ON(kcb->kprobe_status != KPROBE_HIT_SS && |
903 | kcb->kprobe_status != KPROBE_REENTER); | ||
903 | /* | 904 | /* |
904 | * We are here because the instruction being single | 905 | * We are here because the instruction being single |
905 | * stepped caused a page fault. We reset the current | 906 | * stepped caused a page fault. We reset the current |
@@ -914,9 +915,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) | |||
914 | else | 915 | else |
915 | reset_current_kprobe(); | 916 | reset_current_kprobe(); |
916 | preempt_enable_no_resched(); | 917 | preempt_enable_no_resched(); |
917 | break; | 918 | } else if (kcb->kprobe_status == KPROBE_HIT_ACTIVE || |
918 | case KPROBE_HIT_ACTIVE: | 919 | kcb->kprobe_status == KPROBE_HIT_SSDONE) { |
919 | case KPROBE_HIT_SSDONE: | ||
920 | /* | 920 | /* |
921 | * We increment the nmissed count for accounting, | 921 | * We increment the nmissed count for accounting, |
922 | * we can also use npre/npostfault count for accounting | 922 | * we can also use npre/npostfault count for accounting |
@@ -945,10 +945,8 @@ int __kprobes kprobe_fault_handler(struct pt_regs *regs, int trapnr) | |||
945 | * fixup routine could not handle it, | 945 | * fixup routine could not handle it, |
946 | * Let do_page_fault() fix it. | 946 | * Let do_page_fault() fix it. |
947 | */ | 947 | */ |
948 | break; | ||
949 | default: | ||
950 | break; | ||
951 | } | 948 | } |
949 | |||
952 | return 0; | 950 | return 0; |
953 | } | 951 | } |
954 | 952 | ||