Commit f7018be2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'perf_urgent_for_v5.16_rc1' of git://git.kernel.org/pub/scm/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
parents 1654e95e 4716023a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -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);
}

/*
+5 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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;