mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Reinette Chatre <reinette.chatre@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: <tony.luck@intel.com>, <james.morse@arm.com>,
	<Dave.Martin@arm.com>, <babu.moger@amd.com>, <tglx@linutronix.de>,
	<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
	<ben.horgan@arm.com>, <fustini@kernel.org>, <fenghuay@nvidia.com>,
	<peternewman@google.com>, <yu.c.chen@intel.com>,
	<linux-kernel@vger.kernel.org>, <patches@lists.linux.dev>
Subject: Re: [PATCH v5 02/10] x86/resctrl: Protect against bad shift
Date: Tue, 21 Jul 2026 16:50:32 -0700	[thread overview]
Message-ID: <86f26d3c-92a7-4365-b6b9-2b31da15ce1b@intel.com> (raw)
In-Reply-To: <20260721231502.GGal_9dvrdG9NdUkA4@fat_crate.local>

Hi Boris,

On 7/21/26 4:15 PM, Borislav Petkov wrote:
> On Tue, Jul 21, 2026 at 09:14:20AM -0700, Reinette Chatre wrote:
>> On 7/20/26 6:59 PM, Borislav Petkov wrote:
>>> On Tue, Jun 30, 2026 at 09:27:02PM -0700, Reinette Chatre wrote:
>>>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
>>>> index bca782050198..9b9495174041 100644
>>>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>>>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>>>> @@ -247,7 +247,11 @@ static __init bool __rdt_get_mem_config_amd(struct rdt_resource *r)
>>>>  
>>>>  	cpuid_count(0x80000020, subleaf, &eax, &ebx, &ecx, &edx);
>>>>  	hw_res->num_closid = edx + 1;
>>>> -	r->membw.max_bw = 1 << eax;
>>>> +	if (BITS_PER_TYPE(r->membw.max_bw) <= eax) {
>>>> +		pr_warn("Unable to support hardware's maximum bandwidth\n");
>>>> +		return false;
>>>> +	}
>>>> +	r->membw.max_bw = BIT(eax);
>>>
>>> Why?
>>>
>>> Why go all the effort if the field can be 64 bits?
>>>
>>> Why not make max_bw u64 and handle *all* possible values naturally?
>>>
>>
>> resctrl does not support values larger than u32.
>>
>> The value represented by max_bw provides the upper limit of control values that
>> user space can configure via the schemata file, which in turn represents the
>> control value programmed to hardware.
>>
>> u32 is expected in several places:
>> - Parsing of user input in bw_validate() is done via kstrtou32() placing result in
>>   "u32 bw". It is this value that is compared against max_bw and would thus need to
>>   change as a consequence.
>> - Parsing of user input to schemata file via parse_bw() places parsed bandwidth in
>>   "u32 bw_val".
>> - Upon successful parsing the control value is staged by resctrl fs in
>>   resctrl_staged_config::new_ctrl that is u32.
>> - On receipt of programming request from resctrl fs, the x86 architectural specific
>>   code programs the control value to rdt_hw_ctrl_domain::ctrl_val[] that are u32.
>>
>> resctrl, from fs to x86 architecture and now also MPAM, would thus require changes to
>> support these AMD systems. If I get the math right this will be systems that support 
>> 1073741823.875GB/s and up?
>>
>> If resctrl is required to support AMD hardware that can return up to 64bits here
>> then that requires more changes than what I am able to take on at this time. From
>> my side I prefer to stick to this resctrl safeguard for the scenario and leave support
>> for this hardware to AMD.
> 
> So that bandwidth limit thing is read from those L3QOS_BW_CONTROL_n MSRs which
> have
> 
> BW_LEN-1:0 as the range which is the bandwidth limit, at
> BW_LEN there's the unlimited bandwidth limit
> 
> and that BW_LEN is read from CPUID.
> 
> And that is, kinda 12, right now.
> 
> And your worry is that some day that limit BW_LEN might go over 31?

This is theoretical since the spec/hardware technically supports larger values
than what resctrl supports. This could take the form of actual hardware or some
model aimed at testing limits.

> 
> Which your math shows how absurd this is.
> 
> So what are we actually fixing here?
> 
> Something some AI hallucinated that it might be possible at some point in the
> very distant, dark future?
Not an AI hallucination but something encountered during my earlier attempts
at getting resctrl to pass with fewer issues reported by the various deterministic
tools, in this case a static checker, that I run as part of checking resctrl
health. 

I aim to highlight this caveat in the changelog with:
	Whether this could ever represent a reasonable bandwidth value is unknown
	but addressing the issue will appease static checkers.

I see how such change could be considered absurd. I am ok to drop it from the series
and just keep treating it's report locally as a false positive.

Reinette

  reply	other threads:[~2026-07-21 23:50 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  4:27 [PATCH v5 00/10] x86,fs/resctrl: Improve resctrl quality and consistency Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 01/10] fs/resctrl: Use correct format specifier for printing error pointers Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 02/10] x86/resctrl: Protect against bad shift Reinette Chatre
2026-07-21  1:59   ` Borislav Petkov
2026-07-21 16:14     ` Reinette Chatre
2026-07-21 23:15       ` Borislav Petkov
2026-07-21 23:50         ` Reinette Chatre [this message]
2026-07-22  0:50           ` Borislav Petkov
2026-07-22 15:59             ` Reinette Chatre
2026-07-22 20:03               ` Borislav Petkov
2026-07-22 21:07                 ` Reinette Chatre
2026-07-22 21:11                 ` [PATCH v5.1 " Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 03/10] fs/resctrl: Change pattern used to track number of entries in enum Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 04/10] fs/resctrl: Use accurate type for rdt_resource::rid Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 05/10] fs/resctrl: Pass error reading event through to user space Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 06/10] fs/resctrl: Use accurate and symmetric exit flows Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 07/10] fs/resctrl: Change last_cmd_status custom during input parsing Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 08/10] fs/resctrl: Add last_cmd_status support for writes to max_threshold_occupancy Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 09/10] fs/resctrl: Communicate resource group deleted error via last_cmd_status Reinette Chatre
2026-07-01  4:27 ` [PATCH v5 10/10] fs/resctrl: Inform user space when status buffer overflowed Reinette Chatre
2026-07-14 17:49 ` [PATCH v5 00/10] x86,fs/resctrl: Improve resctrl quality and consistency Reinette Chatre
2026-07-20 17:16   ` Borislav Petkov
2026-07-14 22:45 ` Moger, Babu
2026-07-15  0:00   ` Reinette Chatre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86f26d3c-92a7-4365-b6b9-2b31da15ce1b@intel.com \
    --to=reinette.chatre@intel.com \
    --cc=Dave.Martin@arm.com \
    --cc=babu.moger@amd.com \
    --cc=ben.horgan@arm.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghuay@nvidia.com \
    --cc=fustini@kernel.org \
    --cc=hpa@zytor.com \
    --cc=james.morse@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=peternewman@google.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=yu.c.chen@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®