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: <dfc629d3-08d8-4443-9a8d-61e4612dfbd6@amd.com>
Date: Wed, 3 Sep 2025 12:38:15 -0500
From: "Moger, Babu" <babu.moger@....com>
To: Reinette Chatre <reinette.chatre@...el.com>, corbet@....net,
 tony.luck@...el.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com
Cc: Dave.Martin@....com, james.morse@....com, x86@...nel.org, hpa@...or.com,
 akpm@...ux-foundation.org, rostedt@...dmis.org, paulmck@...nel.org,
 pawan.kumar.gupta@...ux.intel.com, kees@...nel.org, arnd@...db.de,
 fvdl@...gle.com, seanjc@...gle.com, thomas.lendacky@....com,
 yosry.ahmed@...ux.dev, xin@...or.com, sohil.mehta@...el.com,
 kai.huang@...el.com, xiaoyao.li@...el.com, peterz@...radead.org,
 mario.limonciello@....com, xin3.li@...el.com, perry.yuan@....com,
 chang.seok.bae@...el.com, linux-doc@...r.kernel.org,
 linux-kernel@...r.kernel.org, peternewman@...gle.com, eranian@...gle.com,
 gautham.shenoy@....com
Subject: Re: [PATCH v17 25/33] fs/resctrl: Provide interface to update the
 event configurations

Hi Reinette,

Thanks for the review of series.

On 9/2/25 21:41, Reinette Chatre wrote:
> Hi Babu,
> 
> On 8/14/25 7:25 PM, Babu Moger wrote:
> 
>> diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c
>> index 25fec9bf2d61..9201fedd2796 100644
>> --- a/fs/resctrl/monitor.c
>> +++ b/fs/resctrl/monitor.c
>> @@ -1029,6 +1029,125 @@ int event_filter_show(struct kernfs_open_file *of, struct seq_file *seq, void *v
>>  	return ret;
>>  }
>>  
>> +static int resctrl_parse_mem_transactions(char *tok, u32 *val)
>> +{
>> +	u32 temp_val = 0;
>> +	char *evt_str;
>> +	bool found;
>> +	int i;
>> +
>> +next_config:
>> +	if (!tok || tok[0] == '\0') {
>> +		*val = temp_val;
>> +		return 0;
>> +	}
> 
> Looks like resctrl_parse_mem_transactions() can return "success" with a parsed
> return value of "0" (*val = 0) ... (follow-up comment in event_filter_write()).

Yes. *val=0 is a valid value.

> 
>> +
>> +	/* Start processing the strings for each memory transaction type */
>> +	evt_str = strim(strsep(&tok, ","));
>> +	found = false;
>> +	for (i = 0; i < NUM_MBM_TRANSACTIONS; i++) {
>> +		if (!strcmp(mbm_transactions[i].name, evt_str)) {
>> +			temp_val |= mbm_transactions[i].val;
>> +			found = true;
>> +			break;
>> +		}
>> +	}
>> +
>> +	if (!found) {
>> +		rdt_last_cmd_printf("Invalid memory transaction type %s\n", evt_str);
>> +		return -EINVAL;
>> +	}
>> +
>> +	goto next_config;
>> +}
>> +
>> +/*
>> + * rdtgroup_update_cntr_event - Update the counter assignments for the event
>> + *				in a group.
>> + * @r:		Resource to which update needs to be done.
>> + * @rdtgrp:	Resctrl group.
>> + * @evtid:	MBM monitor event.
>> + */
>> +static void rdtgroup_update_cntr_event(struct rdt_resource *r, struct rdtgroup *rdtgrp,
>> +				       enum resctrl_event_id evtid)
>> +{
>> +	struct rdt_mon_domain *d;
>> +	struct mbm_state *m;
>> +	int cntr_id;
>> +
>> +	list_for_each_entry(d, &r->mon_domains, hdr.list) {
>> +		cntr_id = mbm_cntr_get(r, d, rdtgrp, evtid);
>> +		if (cntr_id >= 0) {
>> +			resctrl_arch_config_cntr(r, d, evtid, rdtgrp->mon.rmid,
>> +						 rdtgrp->closid, cntr_id, true);
>> +			m = get_mbm_state(d, rdtgrp->closid, rdtgrp->mon.rmid, evtid);
>> +			if (m)
>> +				memset(m, 0, sizeof(*m));
> 
> This looks like open code of rdtgroup_assign_cntr()?

Will call rdtgroup_assign_cntr() directly here.

> 
>> +		}
>> +	}
>> +}
>> +
> 
> ...
> 
>> +
>> +ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t nbytes,
>> +			   loff_t off)
>> +{
>> +	struct mon_evt *mevt = rdt_kn_parent_priv(of->kn);
>> +	struct rdt_resource *r;
>> +	u32 evt_cfg = 0;
>> +	int ret = 0;
>> +
>> +	/* Valid input requires a trailing newline */
>> +	if (nbytes == 0 || buf[nbytes - 1] != '\n')
>> +		return -EINVAL;
>> +
>> +	buf[nbytes - 1] = '\0';
>> +
>> +	cpus_read_lock();
>> +	mutex_lock(&rdtgroup_mutex);
>> +
>> +	rdt_last_cmd_clear();
>> +
>> +	r = resctrl_arch_get_resource(mevt->rid);
>> +	if (!resctrl_arch_mbm_cntr_assign_enabled(r)) {
>> +		rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n");
>> +		ret = -EINVAL;
>> +		goto out_unlock;
>> +	}
>> +
>> +	ret = resctrl_parse_mem_transactions(buf, &evt_cfg);
>> +	if (!ret && mevt->evt_cfg != evt_cfg) {
> 
> ... is evt_cfg of 0 (a) a valid value (that will not cause hardware to fault) and
> (b) a reasonable value to allow? 
> 

The value evt_cfg = 0 is valid and permitted for both ABMC and BMEC. I
have confirmed here through verification and testing. In that case, the
event counter will not be monitoring anything.
-- 
Thanks
Babu Moger


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ