linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
@ 2021-09-16 21:07 Russ Weight
  2021-09-16 22:24 ` Moritz Fischer
  2021-09-17  5:42 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Russ Weight @ 2021-09-16 21:07 UTC (permalink / raw)
  To: mdf, linux-fpga
  Cc: trix, lgoncalv, yilun.xu, hao.wu, matthew.gerlach, rc,
	Russ Weight, stable

CSR address space for Accelerator Functional Units (AFU) is not available
during the early Device Feature List (DFL) enumeration. Early access
to this space results in invalid data and port errors. This change adds
a condition to prevent an early read from the AFU CSR space.

Signed-off-by: Russ Weight <russell.h.weight@intel.com>

Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
dfl_device")
Cc: stable@vger.kernel.org
---
 drivers/fpga/dfl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
index c99b78ee008a..f86666cf2c6a 100644
--- a/drivers/fpga/dfl.c
+++ b/drivers/fpga/dfl.c
@@ -1019,16 +1019,18 @@ create_feature_instance(struct build_feature_devs_info *binfo,
 {
 	unsigned int irq_base, nr_irqs;
 	struct dfl_feature_info *finfo;
+	u8 revision = 0;
 	int ret;
-	u8 revision;
 	u64 v;
 
-	v = readq(binfo->ioaddr + ofst);
-	revision = FIELD_GET(DFH_REVISION, v);
+	if (fid != FEATURE_ID_AFU) {
+		v = readq(binfo->ioaddr + ofst);
+		revision = FIELD_GET(DFH_REVISION, v);
 
-	/* read feature size and id if inputs are invalid */
-	size = size ? size : feature_size(v);
-	fid = fid ? fid : feature_id(v);
+		/* read feature size and id if inputs are invalid */
+		size = size ? size : feature_size(v);
+		fid = fid ? fid : feature_id(v);
+	}
 
 	if (binfo->len - ofst < size)
 		return -EINVAL;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-16 21:07 [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration Russ Weight
@ 2021-09-16 22:24 ` Moritz Fischer
  2021-09-16 22:34   ` Russ Weight
  2021-09-17  5:42 ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Moritz Fischer @ 2021-09-16 22:24 UTC (permalink / raw)
  To: Russ Weight
  Cc: mdf, linux-fpga, trix, lgoncalv, yilun.xu, hao.wu,
	matthew.gerlach, rc, stable

On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
> CSR address space for Accelerator Functional Units (AFU) is not available
> during the early Device Feature List (DFL) enumeration. Early access
> to this space results in invalid data and port errors. This change adds
> a condition to prevent an early read from the AFU CSR space.
> 
> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> 
> Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
> dfl_device")
Did you mean:

Fixes: 1604986c3e6b ("fpga: dfl: expose feature revision from struct dfl_device")

And for future please don't line break those, or we'll get yelled at :)

I can locally fix it up, no need to resubmit

- Moritz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-16 22:24 ` Moritz Fischer
@ 2021-09-16 22:34   ` Russ Weight
  2021-09-16 22:50     ` Moritz Fischer
  0 siblings, 1 reply; 7+ messages in thread
From: Russ Weight @ 2021-09-16 22:34 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: linux-fpga, trix, lgoncalv, yilun.xu, hao.wu, matthew.gerlach,
	rc, stable


On 9/16/21 3:24 PM, Moritz Fischer wrote:
> On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
>> CSR address space for Accelerator Functional Units (AFU) is not available
>> during the early Device Feature List (DFL) enumeration. Early access
>> to this space results in invalid data and port errors. This change adds
>> a condition to prevent an early read from the AFU CSR space.
>>
>> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
>>
>> Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
>> dfl_device")
> Did you mean:
>
> Fixes: 1604986c3e6b ("fpga: dfl: expose feature revision from struct dfl_device")
Oops - I must have been looking at the wrong branch. Yes - you have the
correct commit ID
>
> And for future please don't line break those, or we'll get yelled at :)
Got it.

Thanks!
- Russ
>
> I can locally fix it up, no need to resubmit
>
> - Moritz


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-16 22:34   ` Russ Weight
@ 2021-09-16 22:50     ` Moritz Fischer
  2021-09-17 18:24       ` Russ Weight
  0 siblings, 1 reply; 7+ messages in thread
From: Moritz Fischer @ 2021-09-16 22:50 UTC (permalink / raw)
  To: Russ Weight
  Cc: Moritz Fischer, linux-fpga, trix, lgoncalv, yilun.xu, hao.wu,
	matthew.gerlach, rc, stable

On Thu, Sep 16, 2021 at 03:34:39PM -0700, Russ Weight wrote:
> 
> On 9/16/21 3:24 PM, Moritz Fischer wrote:
> > On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
> >> CSR address space for Accelerator Functional Units (AFU) is not available
> >> during the early Device Feature List (DFL) enumeration. Early access
> >> to this space results in invalid data and port errors. This change adds
> >> a condition to prevent an early read from the AFU CSR space.
> >>
> >> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> >>
> >> Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
> >> dfl_device")
> > Did you mean:
> >
> > Fixes: 1604986c3e6b ("fpga: dfl: expose feature revision from struct dfl_device")
> Oops - I must have been looking at the wrong branch. Yes - you have the
> correct commit ID
> >
> > And for future please don't line break those, or we'll get yelled at :)
> Got it.
> 
> Thanks!
> - Russ
> >
> > I can locally fix it up, no need to resubmit
> >
> > - Moritz
> 
Applied w/changes to fixes,

- Moritz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-16 21:07 [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration Russ Weight
  2021-09-16 22:24 ` Moritz Fischer
@ 2021-09-17  5:42 ` Greg KH
  2021-09-17 16:26   ` Moritz Fischer
  1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2021-09-17  5:42 UTC (permalink / raw)
  To: Russ Weight
  Cc: mdf, linux-fpga, trix, lgoncalv, yilun.xu, hao.wu,
	matthew.gerlach, rc, stable

On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
> CSR address space for Accelerator Functional Units (AFU) is not available
> during the early Device Feature List (DFL) enumeration. Early access
> to this space results in invalid data and port errors. This change adds
> a condition to prevent an early read from the AFU CSR space.
> 
> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> 
> Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
> dfl_device")

Nit, please keep this all on one line or our tools will complain about
it when we commit it to our trees :(

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-17  5:42 ` Greg KH
@ 2021-09-17 16:26   ` Moritz Fischer
  0 siblings, 0 replies; 7+ messages in thread
From: Moritz Fischer @ 2021-09-17 16:26 UTC (permalink / raw)
  To: Greg KH
  Cc: Russ Weight, mdf, linux-fpga, trix, lgoncalv, yilun.xu, hao.wu,
	matthew.gerlach, rc, stable

On Fri, Sep 17, 2021 at 07:42:28AM +0200, Greg KH wrote:
> On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
> > CSR address space for Accelerator Functional Units (AFU) is not available
> > during the early Device Feature List (DFL) enumeration. Early access
> > to this space results in invalid data and port errors. This change adds
> > a condition to prevent an early read from the AFU CSR space.
> > 
> > Signed-off-by: Russ Weight <russell.h.weight@intel.com>
> > 
> > Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
> > dfl_device")
> 
> Nit, please keep this all on one line or our tools will complain about
> it when we commit it to our trees :(

I had caught that and fixed it when applying :)

Thanks,
Moritz

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration
  2021-09-16 22:50     ` Moritz Fischer
@ 2021-09-17 18:24       ` Russ Weight
  0 siblings, 0 replies; 7+ messages in thread
From: Russ Weight @ 2021-09-17 18:24 UTC (permalink / raw)
  To: Moritz Fischer
  Cc: linux-fpga, trix, lgoncalv, yilun.xu, hao.wu, matthew.gerlach,
	rc, stable



On 9/16/21 3:50 PM, Moritz Fischer wrote:
> On Thu, Sep 16, 2021 at 03:34:39PM -0700, Russ Weight wrote:
>> On 9/16/21 3:24 PM, Moritz Fischer wrote:
>>> On Thu, Sep 16, 2021 at 02:07:33PM -0700, Russ Weight wrote:
>>>> CSR address space for Accelerator Functional Units (AFU) is not available
>>>> during the early Device Feature List (DFL) enumeration. Early access
>>>> to this space results in invalid data and port errors. This change adds
>>>> a condition to prevent an early read from the AFU CSR space.
>>>>
>>>> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
>>>>
>>>> Fixes: 23bcda750558 ("fpga: dfl: expose feature revision from struct
>>>> dfl_device")
>>> Did you mean:
>>>
>>> Fixes: 1604986c3e6b ("fpga: dfl: expose feature revision from struct dfl_device")
>> Oops - I must have been looking at the wrong branch. Yes - you have the
>> correct commit ID
>>> And for future please don't line break those, or we'll get yelled at :)
>> Got it.
>>
>> Thanks!
>> - Russ
>>> I can locally fix it up, no need to resubmit
>>>
>>> - Moritz
> Applied w/changes to fixes,

Can a signed-off tag still be added?

Signed-off-by: Roger Christensen <rc@silicom.dk>

There was also a suggestion the the variable v could be declared within
the scope of the "if" statement instead of being declared at function
scope. I haven't seen that done much (at all?) in kernel code.

- Russ
>
> - Moritz


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-17 18:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 21:07 [PATCH 1/1] fpga: dfl: Avoid reads to AFU CSRs during enumeration Russ Weight
2021-09-16 22:24 ` Moritz Fischer
2021-09-16 22:34   ` Russ Weight
2021-09-16 22:50     ` Moritz Fischer
2021-09-17 18:24       ` Russ Weight
2021-09-17  5:42 ` Greg KH
2021-09-17 16:26   ` Moritz Fischer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).