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

+10 -6
+3 -1
arch/x86/events/intel/core.c
··· 3048 3048 { 3049 3049 struct event_constraint *c = &vlbr_constraint; 3050 3050 3051 - if (unlikely(constraint_match(c, event->hw.config))) 3051 + if (unlikely(constraint_match(c, event->hw.config))) { 3052 + event->hw.flags |= c->flags; 3052 3053 return c; 3054 + } 3053 3055 3054 3056 return NULL; 3055 3057 }
+2
arch/x86/events/intel/lbr.c
··· 265 265 266 266 cpuc->last_task_ctx = NULL; 267 267 cpuc->last_log_id = 0; 268 + if (!static_cpu_has(X86_FEATURE_ARCH_LBR) && cpuc->lbr_select) 269 + wrmsrl(MSR_LBR_SELECT, 0); 268 270 } 269 271 270 272 /*
+5 -5
kernel/events/core.c
··· 7154 7154 static u64 perf_virt_to_phys(u64 virt) 7155 7155 { 7156 7156 u64 phys_addr = 0; 7157 - struct page *p = NULL; 7158 7157 7159 7158 if (!virt) 7160 7159 return 0; ··· 7172 7173 * If failed, leave phys_addr as 0. 7173 7174 */ 7174 7175 if (current->mm != NULL) { 7176 + struct page *p; 7177 + 7175 7178 pagefault_disable(); 7176 - if (get_user_page_fast_only(virt, 0, &p)) 7179 + if (get_user_page_fast_only(virt, 0, &p)) { 7177 7180 phys_addr = page_to_phys(p) + virt % PAGE_SIZE; 7181 + put_page(p); 7182 + } 7178 7183 pagefault_enable(); 7179 7184 } 7180 - 7181 - if (p) 7182 - put_page(p); 7183 7185 } 7184 7186 7185 7187 return phys_addr;