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: <075501db8f45$ff6f9620$fe4ec260$@samsung.com>
Date: Fri, 7 Mar 2025 15:17:50 +0530
From: "Shradha Todi" <shradha.t@...sung.com>
To: "'Fan Ni'" <nifan.cxl@...il.com>
Cc: 'Krzysztof Wilczyński' <kw@...ux.com>,
	<linux-kernel@...r.kernel.org>, <linux-pci@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-perf-users@...r.kernel.org>,
	<manivannan.sadhasivam@...aro.org>, <lpieralisi@...nel.org>,
	<robh@...nel.org>, <bhelgaas@...gle.com>, <jingoohan1@...il.com>,
	<Jonathan.Cameron@...wei.com>, <a.manzanares@...sung.com>,
	<pankaj.dubey@...sung.com>, <cassel@...nel.org>, <18255117159@....com>,
	<xueshuai@...ux.alibaba.com>, <renyu.zj@...ux.alibaba.com>,
	<will@...nel.org>, <mark.rutland@....com>
Subject: RE: [PATCH v7 5/5] Add debugfs based statistical counter support in
 DWC



> -----Original Message-----
> From: Fan Ni <nifan.cxl@...il.com>
> Sent: 05 March 2025 09:56
> To: Shradha Todi <shradha.t@...sung.com>
> Cc: 'Fan Ni' <nifan.cxl@...il.com>; 'Krzysztof Wilczyński' <kw@...ux.com>; linux-kernel@...r.kernel.org; linux-pci@...r.kernel.org;
> linux-arm-kernel@...ts.infradead.org; linux-perf-users@...r.kernel.org; manivannan.sadhasivam@...aro.org; lpieralisi@...nel.org;
> robh@...nel.org; bhelgaas@...gle.com; jingoohan1@...il.com; Jonathan.Cameron@...wei.com; a.manzanares@...sung.com;
> pankaj.dubey@...sung.com; cassel@...nel.org; 18255117159@....com; xueshuai@...ux.alibaba.com; renyu.zj@...ux.alibaba.com;
> will@...nel.org; mark.rutland@....com
> Subject: Re: [PATCH v7 5/5] Add debugfs based statistical counter support in DWC
> 
> On Tue, Mar 04, 2025 at 10:40:43PM +0530, Shradha Todi wrote:
> >
> >
> > > -----Original Message-----
> > > From: Fan Ni <nifan.cxl@...il.com>
> > > Sent: 04 March 2025 02:33
> > > To: Krzysztof Wilczyński <kw@...ux.com>
> > > Cc: Fan Ni <nifan.cxl@...il.com>; Shradha Todi
> > > <shradha.t@...sung.com>; linux-kernel@...r.kernel.org; linux-
> > > pci@...r.kernel.org; linux-arm-kernel@...ts.infradead.org;
> > > linux-perf-users@...r.kernel.org; manivannan.sadhasivam@...aro.org;
> > > lpieralisi@...nel.org; robh@...nel.org; bhelgaas@...gle.com;
> > > jingoohan1@...il.com; Jonathan.Cameron@...wei.com;
> > > a.manzanares@...sung.com; pankaj.dubey@...sung.com;
> > > cassel@...nel.org; 18255117159@....com; xueshuai@...ux.alibaba.com;
> > > renyu.zj@...ux.alibaba.com; will@...nel.org; mark.rutland@....com
> > > Subject: Re: [PATCH v7 5/5] Add debugfs based statistical counter
> > > support in DWC
> > >
> > > On Tue, Mar 04, 2025 at 04:42:28AM +0900, Krzysztof Wilczyński wrote:
> > > > Hello,
> > > >
> > > > [...]
> > > > > > +static ssize_t counter_value_read(struct file *file, char
> > > > > > +__user *buf, size_t count, loff_t *ppos) {
> > > > > > +	struct dwc_pcie_rasdes_priv *pdata = file->private_data;
> > > > > > +	struct dw_pcie *pci = pdata->pci;
> > > > > > +	struct dwc_pcie_rasdes_info *rinfo = pci->debugfs->rasdes_info;
> > > > > > +	char debugfs_buf[DWC_DEBUGFS_BUF_MAX];
> > > > > > +	ssize_t pos;
> > > > > > +	u32 val;
> > > > > > +
> > > > > > +	mutex_lock(&rinfo->reg_event_lock);
> > > > > > +	set_event_number(pdata, pci, rinfo);
> > > > > > +	val = dw_pcie_readl_dbi(pci, rinfo->ras_cap_offset + RAS_DES_EVENT_COUNTER_DATA_REG);
> > > > > > +	mutex_unlock(&rinfo->reg_event_lock);
> > > > > > +	pos = scnprintf(debugfs_buf, DWC_DEBUGFS_BUF_MAX, "Counter
> > > > > > +value: %d\n", val);
> > > > > > +
> > > > > > +	return simple_read_from_buffer(buf, count, ppos,
> > > > > > +debugfs_buf, pos); }
> > > > >
> > > > > Do we need to check whether the counter is enabled or not for
> > > > > the event before retrieving the counter value?
> > > >
> > > > I believe, we have a patch that aims to address, have a look at:
> > > >
> > > >
> > > > https://lore.kernel.org/linux-pci/20250225171239.19574-1-manivanna
> > > > n.sa
> > > > dhasivam@...aro.org
> > >
> > > Maybe I missed something, that seems to fix counter_enable_read(), but here is to retrieve counter value.
> > > How dw_pcie_readl_dbi() can return something like "Counter Disabled"?
> > >
> > > Fan
> >
> > Hey Fan,
> > So the counter value will show 0 in case it is disabled so there will
> > not be any issues as per say. We could add the check here but I feel I
> > have already exposed the functionality to check if a counter is enabled or disabled, (by reading the counter_enable debugfs entry)
> so this could be handled in user space to only read the counter if it's enabled.
> Ok.
> Returning 0 when the counter is disabled makes sense to me.
> 
> Just some thought.
> 
> It seems natural to me if we make "counter_value" only visiable to users when the counter is enabled.
> 

Hey Fan,

This looks like a good suggestion to me. I have implemented this and in the process of testing. Since there is no support in the
debugfs framework for conditionally hiding certain files from user, the custom implementation is a little tricky and will need some
discussion before taking in. So let's take this up as a top up patch and live with returning 0 when the counter is disabled for now?

Thanks a lot for the suggestion.
Shradha 

> Fan
> >
> > > >
> > > > Thank you!
> > > >
> > > > 	Krzysztof
> >
> >



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ