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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251202095930.166761-1-sieberf@amazon.com>
Date: Tue, 2 Dec 2025 11:59:30 +0200
From: Fernand Sieber <sieberf@...zon.com>
To: <peterz@...radead.org>
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.es>,
	<pbonzini@...hat.com>, <seanjc@...gle.com>, <sieberf@...zon.com>,
	<stable@...r.kernel.org>, <tglx@...utronix.de>, <x86@...nel.org>
Subject: Re: [PATCH] KVM: x86/pmu: Do not accidentally create BTS events

On Mon, Dec 02, 2025 at 10:35:34AM +0100, Peter Zijlstra wrote:
> On Mon, Dec 01, 2025 at 02:45:01PM +0000, Woodhouse, David wrote:
> > On Mon, 2025-12-01 at 16:23 +0200, Fernand Sieber wrote
> > > Perf considers the combination of PERF_COUNT_HW_BRANCH_INSTRUCTIONS with
> > > a sample_period of 1 a special case and handles this as a BTS event (see
> > > intel_pmu_has_bts_period()) -- a deviation from the usual semantic,
> > > where the sample_period represents the amount of branch instructions to
> > > encounter before the overflow handler is invoked.
> >
> > That's kind of awful, and seems to be the real underlying cause of the KVM
> > issue. Can we kill it with fire? Peter?
>
> Well, IIRC it gives the same information and was actually less expensive
> to run, seeing how BTS can buffer the data rather than having to take an
> interrupt on every event.
>
> But its been ages since this was done.
>
> Now arguably it should not be done for this kvm stuff, because the
> data-store buffers don't virtualize (just like old PEBS).

This. The current logic bypasses what the guest should actually be allowed
to do. See `vmx_get_supported_debugctl`, specifically the guest should not
be allowed to enable BTS.

Also semi related to this thread, but the auto enablement of BTS for
sample_period = 1 seems to yield undesirable behavior on the guest OS. The
guest OS will try to enable BTS and guest a wrmsr failure because the host
KVM rejects it, which leads to incorrect behavior (no tracing at all
happening).



Amazon Development Centre (South Africa) (Proprietary) Limited
29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa
Registration Number: 2004 / 034463 / 07


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ