lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251210111655.GB3911114@noisy.programming.kicks-ass.net>
Date: Wed, 10 Dec 2025 12:16:55 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Fernand Sieber <sieberf@...zon.com>
Cc: abusse@...zon.de, bp@...en8.de, dave.hansen@...ux.intel.com,
	dwmw@...zon.co.uk, hborghor@...zon.de, hpa@...or.com,
	jschoenh@...zon.de, kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org, mingo@...hat.com,
	nh-open-source@...zon.com, nsaenz@...zon.com, pbonzini@...hat.com,
	seanjc@...gle.com, stable@...r.kernel.org, tglx@...utronix.de,
	x86@...nel.org
Subject: Re: [PATCH] KVM: x86/pmu: Do not accidentally create BTS events

On Wed, Dec 10, 2025 at 12:11:47PM +0200, Fernand Sieber wrote:

> > Does something like so work? It is still terrible, but perhaps slightly
> > less so.
> >
> > diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
> > index 2b969386dcdd..493e6ba51e06 100644
> > --- a/arch/x86/events/perf_event.h
> > +++ b/arch/x86/events/perf_event.h
> > @@ -1558,13 +1558,22 @@ static inline bool intel_pmu_has_bts_period(struct perf_event *event, u64 period
> >  	struct hw_perf_event *hwc = &event->hw;
> >  	unsigned int hw_event, bts_event;
> >
> > -	if (event->attr.freq)
> > +	/*
> > +	 * Only use BTS for fixed rate period==1 events.
> > +	 */
> > +	if (event->attr.freq || period != 1)
> > +		return false;
> > +
> > +	/*
> > +	 * BTS doesn't virtualize.
> > +	 */
> > +	if (event->attr.exclude_host)
> >  		return false;
> >
> >  	hw_event = hwc->config & INTEL_ARCH_EVENT_MASK;
> >  	bts_event = x86_pmu.event_map(PERF_COUNT_HW_BRANCH_INSTRUCTIONS);
> >
> > -	return hw_event == bts_event && period == 1;
> > +	return hw_event == bts_event;
> >  }
> >
> >  static inline bool intel_pmu_has_bts(struct perf_event *event)
> 
> Hi Peter,
> 
> I've pulled your changes and confirmed that they address the original
> bug report.
> 
> The repro I use is running on host, with a guest running:
> `perf record -e branches:u -c 2 -a &`
> `perf record -e branches:u -c 2 -a &`
> Then I monitor the enablement of BTS on the host and verify that without
> the change BTS is enabled, and with the change it's not.
> 
> This looks good to me, should we go ahead with your changes then?

Yeah, I suppose. Please stick a coherent changelog on and repost.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ