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: <35123882-b909-43b7-879d-f3802dca2da1@linux.intel.com>
Date: Tue, 13 Jan 2026 10:29:38 +0800
From: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo
 <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
 Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Andi Kleen <ak@...ux.intel.com>, Eranian Stephane <eranian@...gle.com>,
 linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
 Dapeng Mi <dapeng1.mi@...el.com>, Zide Chen <zide.chen@...el.com>,
 Falcon Thomas <thomas.falcon@...el.com>, Xudong Hao <xudong.hao@...el.com>
Subject: Re: [Patch v2 7/7] perf/x86/intel: Add support for rdpmc user disable
 feature


On 1/12/2026 6:57 PM, Peter Zijlstra wrote:
> On Mon, Jan 12, 2026 at 01:16:49PM +0800, Dapeng Mi wrote:
>
>> +static void intel_pmu_update_rdpmc_user_disable(struct perf_event *event)
>> +{
>> +	/*
>> +	 * Counter scope's user-space rdpmc is disabled by default
>> +	 * except two cases.
>> +	 * a. rdpmc = 2 (user space rdpmc enabled unconditionally)
>> +	 * b. rdpmc = 1 and the event is not a system-wide event.
>> +	 *    The count of non-system-wide events would be cleared when
>> +	 *    context switches, so no count data is leaked.
>> +	 */
>> +	if (x86_pmu_has_rdpmc_user_disable(event->pmu)) {
>> +		if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_ENABLE ||
>> +		    (x86_pmu.attr_rdpmc == X86_USER_RDPMC_CONDITIONAL_ENABLE &&
>> +		     event->ctx->task))
>> +			event->hw.config &= ~ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
>> +		else
>> +			event->hw.config |= ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
>> +	}
>> +}
> Is it not simpler to invert that condition?
>
> 	if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_NEVER ||
> 	    !event->ctx->task)
> 		event->hw.config |= ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
> 	else
> 		event->hw.config &= ~ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;

Hmm, it seems the logic changes along with the code change. The system-wide
event should be allowed to read with rdpmc from user space when attr_rdpmc
== X86_USER_RDPMC_ALWAYS_ENABLE, but it doesn't with the new code.

If we don't change the logic and just invert the condition, the code
simplicity has no much change.

	if (x86_pmu.attr_rdpmc == X86_USER_RDPMC_ALWAYS_NEVER ||
            (x86_pmu.attr_rdpmc == X86_USER_RDPMC_CONDITIONAL_ENABLE &&
	    !event->ctx->task))
		event->hw.config |= ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;
	else
		event->hw.config &= ~ARCH_PERFMON_EVENTSEL_RDPMC_USER_DISABLE;



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ