Skip to content

Commit f7018be

Browse files
committed
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
2 parents 1654e95 + 4716023 commit f7018be

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

arch/x86/events/intel/core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3048,8 +3048,10 @@ intel_vlbr_constraints(struct perf_event *event)
30483048
{
30493049
struct event_constraint *c = &vlbr_constraint;
30503050

3051-
if (unlikely(constraint_match(c, event->hw.config)))
3051+
if (unlikely(constraint_match(c, event->hw.config))) {
3052+
event->hw.flags |= c->flags;
30523053
return c;
3054+
}
30533055

30543056
return NULL;
30553057
}

arch/x86/events/intel/lbr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ void intel_pmu_lbr_reset(void)
265265

266266
cpuc->last_task_ctx = NULL;
267267
cpuc->last_log_id = 0;
268+
if (!static_cpu_has(X86_FEATURE_ARCH_LBR) && cpuc->lbr_select)
269+
wrmsrl(MSR_LBR_SELECT, 0);
268270
}
269271

270272
/*

kernel/events/core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7154,7 +7154,6 @@ void perf_output_sample(struct perf_output_handle *handle,
71547154
static u64 perf_virt_to_phys(u64 virt)
71557155
{
71567156
u64 phys_addr = 0;
7157-
struct page *p = NULL;
71587157

71597158
if (!virt)
71607159
return 0;
@@ -7173,14 +7172,15 @@ static u64 perf_virt_to_phys(u64 virt)
71737172
* If failed, leave phys_addr as 0.
71747173
*/
71757174
if (current->mm != NULL) {
7175+
struct page *p;
7176+
71767177
pagefault_disable();
7177-
if (get_user_page_fast_only(virt, 0, &p))
7178+
if (get_user_page_fast_only(virt, 0, &p)) {
71787179
phys_addr = page_to_phys(p) + virt % PAGE_SIZE;
7180+
put_page(p);
7181+
}
71797182
pagefault_enable();
71807183
}
7181-
7182-
if (p)
7183-
put_page(p);
71847184
}
71857185

71867186
return phys_addr;

0 commit comments

Comments
 (0)