Skip to content

Commit

Permalink
Merge tag 'perf_urgent_for_v5.16_rc1' of git://git.kernel.org/pub/scm…
Browse files Browse the repository at this point in the history
…/linux/kernel/git/tip/tip

Pull perf fixes from Borislav Petkov:

 - Prevent unintentional page sharing by checking whether a page
   reference to a PMU samples page has been acquired properly before
   that

 - Make sure the LBR_SELECT MSR is saved/restored too

 - Reset the LBR_SELECT MSR when resetting the LBR PMU to clear any
   residual data left

* tag 'perf_urgent_for_v5.16_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/core: Avoid put_page() when GUP fails
  perf/x86/vlbr: Add c->flags to vlbr event constraints
  perf/x86/lbr: Reset LBR_SELECT during vlbr reset
  • Loading branch information
torvalds committed Nov 14, 2021
2 parents 1654e95 + 4716023 commit f7018be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion arch/x86/events/intel/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3048,8 +3048,10 @@ intel_vlbr_constraints(struct perf_event *event)
{
struct event_constraint *c = &vlbr_constraint;

if (unlikely(constraint_match(c, event->hw.config)))
if (unlikely(constraint_match(c, event->hw.config))) {
event->hw.flags |= c->flags;
return c;
}

return NULL;
}
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/events/intel/lbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ void intel_pmu_lbr_reset(void)

cpuc->last_task_ctx = NULL;
cpuc->last_log_id = 0;
if (!static_cpu_has(X86_FEATURE_ARCH_LBR) && cpuc->lbr_select)
wrmsrl(MSR_LBR_SELECT, 0);
}

/*
Expand Down
10 changes: 5 additions & 5 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -7154,7 +7154,6 @@ void perf_output_sample(struct perf_output_handle *handle,
static u64 perf_virt_to_phys(u64 virt)
{
u64 phys_addr = 0;
struct page *p = NULL;

if (!virt)
return 0;
Expand All @@ -7173,14 +7172,15 @@ static u64 perf_virt_to_phys(u64 virt)
* If failed, leave phys_addr as 0.
*/
if (current->mm != NULL) {
struct page *p;

pagefault_disable();
if (get_user_page_fast_only(virt, 0, &p))
if (get_user_page_fast_only(virt, 0, &p)) {
phys_addr = page_to_phys(p) + virt % PAGE_SIZE;
put_page(p);
}
pagefault_enable();
}

if (p)
put_page(p);
}

return phys_addr;
Expand Down

0 comments on commit f7018be

Please sign in to comment.