Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
@ 2026-11-26 18:35 Lukas Wunner
  2026-11-26 18:42 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Lukas Wunner @ 2026-11-26 18:35 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci
  Cc: Sourabh Jain, Oliver OHalloran, linuxppc-dev,
	Sathyanarayanan Kuppuswamy, Keith Busch, Maciej Grochowski,
	Yazen Ghannam

Since commit 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID
register"), the AER driver checks whether the Error Source ID register
contains either the ID of the Root Port (or RCEC) itself, or of a device
subordinate to the Root Port (or associated with the RCEC).

If this check succeeds, the Error Source ID register is assumed to contain
a valid value and is not double-checked by reading error status registers.

However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
zero Completer ID "prior to the initial device Configuration Write
Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
which can fail ACS Source Validation and trigger an ACS Violation Error.

On ARM platforms, there is often a Root Port at address 0000:00:00.0,
which makes it impossible to discern whether a zero Error Source ID refers
to the Root Port or to an uninitialized device downstream.

For this reason, always double-check error status registers if the Error
Source ID is zero.

Fixes: 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID register")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
base-commit: 6d69eeae8966bc3bea0facbd550f45ef9de41cc4
 
This fixes a commit queued on pci/aer.  It can either be folded into
that commit or applied on top of pci/aer, whichever is preferred.
 
 drivers/pci/pcie/aer.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 1973b6e..24b014b 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -1158,6 +1158,10 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
 
 static bool source_id_valid(struct pci_dev *root, u16 id)
 {
+	/* ID is zero prior to initial device config (PCIe r7.1 sec 2.2.9.1) */
+	if (id == 0)
+		return true;
+
 	/* The Root Port or RCEC can itself be a valid Error Source */
 	if (pci_dev_id(root) == id)
 		return true;
@@ -1186,7 +1190,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
 	u16 reg16;
 
 	/* Some Root Ports report an invalid Error Source ID */
-	if (e_info->id_valid &&
+	if (e_info->id && e_info->id_valid &&
 	    !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
 		/* Device ID match? */
 		if (e_info->id == pci_dev_id(dev))
-- 
2.53.0


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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-26 18:35 [PATCH] PCI/AER: Check error status registers if Error Source ID is zero Lukas Wunner
@ 2026-11-26 18:42 ` sashiko-bot
  2026-11-30 15:04 ` Kuppuswamy Sathyanarayanan
  2026-11-30 16:18 ` Yazen Ghannam
  2 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-11-26 18:42 UTC (permalink / raw)
  To: Lukas Wunner, linux-pci

> Since commit 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID
> register"), the AER driver checks whether the Error Source ID register
> contains either the ID of the Root Port (or RCEC) itself, or of a device
> subordinate to the Root Port (or associated with the RCEC).
> 
> If this check succeeds, the Error Source ID register is assumed to contain
> a valid value and is not double-checked by reading error status registers.
> 
> However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
> zero Completer ID "prior to the initial device Configuration Write
> Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
> generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
> which can fail ACS Source Validation and trigger an ACS Violation Error.
> 
> On ARM platforms, there is often a Root Port at address 0000:00:00.0,
> which makes it impossible to discern whether a zero Error Source ID refers
> to the Root Port or to an uninitialized device downstream.
> 
> For this reason, always double-check error status registers if the Error
> Source ID is zero.
> 
> Fixes: 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID register")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/1ddc35c51b5317988bbf235c467a9534218c6ea4.1795717157.git.lukas@wunner.de?part=1

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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-26 18:35 [PATCH] PCI/AER: Check error status registers if Error Source ID is zero Lukas Wunner
  2026-11-26 18:42 ` sashiko-bot
@ 2026-11-30 15:04 ` Kuppuswamy Sathyanarayanan
  2026-11-30 16:18 ` Yazen Ghannam
  2 siblings, 0 replies; 7+ messages in thread
From: Kuppuswamy Sathyanarayanan @ 2026-11-30 15:04 UTC (permalink / raw)
  To: Lukas Wunner, Bjorn Helgaas, linux-pci
  Cc: Sourabh Jain, Oliver OHalloran, linuxppc-dev, Keith Busch,
	Maciej Grochowski, Yazen Ghannam

Hi,

On 11/26/26 10:35, Lukas Wunner wrote:
> Since commit 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID
> register"), the AER driver checks whether the Error Source ID register
> contains either the ID of the Root Port (or RCEC) itself, or of a device
> subordinate to the Root Port (or associated with the RCEC).
> 
> If this check succeeds, the Error Source ID register is assumed to contain
> a valid value and is not double-checked by reading error status registers.
> 
> However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
> zero Completer ID "prior to the initial device Configuration Write
> Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
> generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
> which can fail ACS Source Validation and trigger an ACS Violation Error.
> 
> On ARM platforms, there is often a Root Port at address 0000:00:00.0,
> which makes it impossible to discern whether a zero Error Source ID refers
> to the Root Port or to an uninitialized device downstream.
> 
> For this reason, always double-check error status registers if the Error
> Source ID is zero.
> 
> Fixes: 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID register")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

> base-commit: 6d69eeae8966bc3bea0facbd550f45ef9de41cc4
>  
> This fixes a commit queued on pci/aer.  It can either be folded into
> that commit or applied on top of pci/aer, whichever is preferred.
>  
>  drivers/pci/pcie/aer.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 1973b6e..24b014b 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -1158,6 +1158,10 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
>  
>  static bool source_id_valid(struct pci_dev *root, u16 id)
>  {
> +	/* ID is zero prior to initial device config (PCIe r7.1 sec 2.2.9.1) */
> +	if (id == 0)
> +		return true;
> +
>  	/* The Root Port or RCEC can itself be a valid Error Source */
>  	if (pci_dev_id(root) == id)
>  		return true;
> @@ -1186,7 +1190,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
>  	u16 reg16;
>  
>  	/* Some Root Ports report an invalid Error Source ID */
> -	if (e_info->id_valid &&
> +	if (e_info->id && e_info->id_valid &&
>  	    !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
>  		/* Device ID match? */
>  		if (e_info->id == pci_dev_id(dev))

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer


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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-26 18:35 [PATCH] PCI/AER: Check error status registers if Error Source ID is zero Lukas Wunner
  2026-11-26 18:42 ` sashiko-bot
  2026-11-30 15:04 ` Kuppuswamy Sathyanarayanan
@ 2026-11-30 16:18 ` Yazen Ghannam
  2026-11-30 17:09   ` Lukas Wunner
  2 siblings, 1 reply; 7+ messages in thread
From: Yazen Ghannam @ 2026-11-30 16:18 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Bjorn Helgaas, linux-pci, Sourabh Jain, Oliver OHalloran,
	linuxppc-dev, Sathyanarayanan Kuppuswamy, Keith Busch,
	Maciej Grochowski

On Thu, Nov 26, 2026 at 07:35:00PM +0100, Lukas Wunner wrote:
> Since commit 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID
> register"), the AER driver checks whether the Error Source ID register
> contains either the ID of the Root Port (or RCEC) itself, or of a device
> subordinate to the Root Port (or associated with the RCEC).
> 
> If this check succeeds, the Error Source ID register is assumed to contain
> a valid value and is not double-checked by reading error status registers.
> 
> However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
> zero Completer ID "prior to the initial device Configuration Write
> Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
> generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
> which can fail ACS Source Validation and trigger an ACS Violation Error.
>

The Error Source ID records the "Requester ID" of a device. So how does
the "Completer ID" behavior relate here?

Can a device send ERR_* messages before it is initialized?

> 
> On ARM platforms, there is often a Root Port at address 0000:00:00.0,
> which makes it impossible to discern whether a zero Error Source ID refers
> to the Root Port or to an uninitialized device downstream.
> 
> For this reason, always double-check error status registers if the Error
> Source ID is zero.
> 
> Fixes: 6d69eeae8966 ("PCI/AER: Check validity of Error Source ID register")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---
> base-commit: 6d69eeae8966bc3bea0facbd550f45ef9de41cc4
>  
> This fixes a commit queued on pci/aer.  It can either be folded into
> that commit or applied on top of pci/aer, whichever is preferred.
>  
>  drivers/pci/pcie/aer.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 1973b6e..24b014b 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -1158,6 +1158,10 @@ static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
>  
>  static bool source_id_valid(struct pci_dev *root, u16 id)
>  {
> +	/* ID is zero prior to initial device config (PCIe r7.1 sec 2.2.9.1) */
> +	if (id == 0)
> +		return true;
> +
>

What is this hunk supposed to catch?

Maybe the answer is based on the Requester/Completer ID question from
above.

>
>  	/* The Root Port or RCEC can itself be a valid Error Source */
>  	if (pci_dev_id(root) == id)
>  		return true;

The ARM "RP 0:0.0" case would already be covered by this. ^^^


> @@ -1186,7 +1190,7 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
>  	u16 reg16;
>  
>  	/* Some Root Ports report an invalid Error Source ID */
> -	if (e_info->id_valid &&
> +	if (e_info->id && e_info->id_valid &&
>  	    !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
>  		/* Device ID match? */
>  		if (e_info->id == pci_dev_id(dev))
> -- 

So adding the "e_info->id" check is to let the ARM "RP 0:0.0" case fall
through and be double-checked, right?

Thanks,
Yazen

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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-30 16:18 ` Yazen Ghannam
@ 2026-11-30 17:09   ` Lukas Wunner
  2026-11-30 18:02     ` Yazen Ghannam
  0 siblings, 1 reply; 7+ messages in thread
From: Lukas Wunner @ 2026-11-30 17:09 UTC (permalink / raw)
  To: Yazen Ghannam
  Cc: Bjorn Helgaas, linux-pci, Sourabh Jain, Oliver OHalloran,
	linuxppc-dev, Sathyanarayanan Kuppuswamy, Keith Busch,
	Maciej Grochowski

On Mon, Nov 30, 2026 at 11:18:57AM -0500, Yazen Ghannam wrote:
> On Thu, Nov 26, 2026 at 07:35:00PM +0100, Lukas Wunner wrote:
> > However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
> > zero Completer ID "prior to the initial device Configuration Write
> > Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
> > generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
> > which can fail ACS Source Validation and trigger an ACS Violation Error.
> 
> The Error Source ID records the "Requester ID" of a device. So how does
> the "Completer ID" behavior relate here?
> 
> Can a device send ERR_* messages before it is initialized?

As an example, at any point in time can an Endpoint raise a Receiver
Error due to signaling issues at the physical layer.  That could occur
prior to the Endpoint receiving its initial device Configuration Write
Request from which it learns its bus, device and function number.

So yes I do believe that an error message could be generated with
a zero Requester ID.  The reason for referencing sec 2.2.9.1 is to
make it clear that the device learns its BDF from the first Config
Write Request and prior to that, the device uses zero as its ID.

I'm wondering if we should perform a single Config Write (e.g. to
the Vendor ID register) immediately after issuing a SBR, FLR or coming
out of D3hot/D3cold, to ensure the device gets its ID as early as
possible.  However that would only shrink, not eliminate the time window
within which the device uses a zero ID.  So we have to cope with a
zero ID regardless.

> >  static bool source_id_valid(struct pci_dev *root, u16 id)
> >  {
> > +	/* ID is zero prior to initial device config (PCIe r7.1 sec 2.2.9.1) */
> > +	if (id == 0)
> > +		return true;
> > +
> >
> 
> What is this hunk supposed to catch?

Without this, if the Root Port is not located at 00:00.0, users would
see a gratuitous " (invalid source)" message in dmesg for a zero
Error Source ID.  That message would not be correct because zero *is*
a valid Error Source ID if the device is uninitialized.

(The message was introduced by 6d69eeae8966, which is queued on pci/aer
and which is fixed by this patch.)

> >
> >  	/* The Root Port or RCEC can itself be a valid Error Source */
> >  	if (pci_dev_id(root) == id)
> >  		return true;
> 
> The ARM "RP 0:0.0" case would already be covered by this. ^^^

Right.

> >  	/* Some Root Ports report an invalid Error Source ID */
> > -	if (e_info->id_valid &&
> > +	if (e_info->id && e_info->id_valid &&
> >  	    !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
> >  		/* Device ID match? */
> >  		if (e_info->id == pci_dev_id(dev))
> > -- 
> 
> So adding the "e_info->id" check is to let the ARM "RP 0:0.0" case fall
> through and be double-checked, right?

Yes.

Thanks for taking a look!

Lukas

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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-30 17:09   ` Lukas Wunner
@ 2026-11-30 18:02     ` Yazen Ghannam
  2026-11-30 18:10       ` Lukas Wunner
  0 siblings, 1 reply; 7+ messages in thread
From: Yazen Ghannam @ 2026-11-30 18:02 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Bjorn Helgaas, linux-pci, Sourabh Jain, Oliver OHalloran,
	linuxppc-dev, Sathyanarayanan Kuppuswamy, Keith Busch,
	Maciej Grochowski

On Mon, Nov 30, 2026 at 06:09:00PM +0100, Lukas Wunner wrote:
> On Mon, Nov 30, 2026 at 11:18:57AM -0500, Yazen Ghannam wrote:
> > On Thu, Nov 26, 2026 at 07:35:00PM +0100, Lukas Wunner wrote:
> > > However per PCIe r7.1 sec 2.2.9.1, devices may send Completions with a
> > > zero Completer ID "prior to the initial device Configuration Write
> > > Request".  Similarly, CXL r4.0 sec 8.1.5.1 states that a Component may
> > > generate a CREDIT_RTN IP2PM message with a zero bus number after reset,
> > > which can fail ACS Source Validation and trigger an ACS Violation Error.
> > 
> > The Error Source ID records the "Requester ID" of a device. So how does
> > the "Completer ID" behavior relate here?
> > 
> > Can a device send ERR_* messages before it is initialized?
> 
> As an example, at any point in time can an Endpoint raise a Receiver
> Error due to signaling issues at the physical layer.  That could occur
> prior to the Endpoint receiving its initial device Configuration Write
> Request from which it learns its bus, device and function number.
> 
> So yes I do believe that an error message could be generated with
> a zero Requester ID.  The reason for referencing sec 2.2.9.1 is to
> make it clear that the device learns its BDF from the first Config
> Write Request and prior to that, the device uses zero as its ID.
> 
> I'm wondering if we should perform a single Config Write (e.g. to
> the Vendor ID register) immediately after issuing a SBR, FLR or coming
> out of D3hot/D3cold, to ensure the device gets its ID as early as
> possible.  However that would only shrink, not eliminate the time window
> within which the device uses a zero ID.  So we have to cope with a
> zero ID regardless.
> 
> > >  static bool source_id_valid(struct pci_dev *root, u16 id)
> > >  {
> > > +	/* ID is zero prior to initial device config (PCIe r7.1 sec 2.2.9.1) */
> > > +	if (id == 0)
> > > +		return true;
> > > +
> > >
> > 
> > What is this hunk supposed to catch?
> 
> Without this, if the Root Port is not located at 00:00.0, users would
> see a gratuitous " (invalid source)" message in dmesg for a zero
> Error Source ID.  That message would not be correct because zero *is*
> a valid Error Source ID if the device is uninitialized.
> 
> (The message was introduced by 6d69eeae8966, which is queued on pci/aer
> and which is fixed by this patch.)
> 

Yes, that's fair if the premise above is correct.

But I think you are still applying the explicit spec details for
Completer ID to Requester ID. And it seems like a logical jump.

The device *should not* send ERR_* messages before the enable bits are
set. And those require a config write, which means the device should be
initialized. So basically, the premise is not possible according to the
spec.

**BUT, I think your point is that a device *could* send spurious ERR_*
messages before it is actually initialized. IMO, this seems more like a
busted device rather than race condition gap in the spec.

All that to say, I agree this could happen, but it's not clear to me
that it is "valid" vs broken device behavior.

Thanks,
Yazen

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

* Re: [PATCH] PCI/AER: Check error status registers if Error Source ID is zero
  2026-11-30 18:02     ` Yazen Ghannam
@ 2026-11-30 18:10       ` Lukas Wunner
  0 siblings, 0 replies; 7+ messages in thread
From: Lukas Wunner @ 2026-11-30 18:10 UTC (permalink / raw)
  To: Yazen Ghannam
  Cc: Bjorn Helgaas, linux-pci, Sourabh Jain, Oliver OHalloran,
	linuxppc-dev, Sathyanarayanan Kuppuswamy, Keith Busch,
	Maciej Grochowski

On Mon, Nov 30, 2026 at 01:02:48PM -0500, Yazen Ghannam wrote:
> On Mon, Nov 30, 2026 at 06:09:00PM +0100, Lukas Wunner wrote:
> > On Mon, Nov 30, 2026 at 11:18:57AM -0500, Yazen Ghannam wrote:
> > > Can a device send ERR_* messages before it is initialized?
> > 
> > As an example, at any point in time can an Endpoint raise a Receiver
> > Error due to signaling issues at the physical layer.  That could occur
> > prior to the Endpoint receiving its initial device Configuration Write
> > Request from which it learns its bus, device and function number.
> > 
> > So yes I do believe that an error message could be generated with
> > a zero Requester ID.  The reason for referencing sec 2.2.9.1 is to
> > make it clear that the device learns its BDF from the first Config
> > Write Request and prior to that, the device uses zero as its ID.
[...]
> The device *should not* send ERR_* messages before the enable bits are
> set. And those require a config write, which means the device should be
> initialized. So basically, the premise is not possible according to the
> spec.
> 
> **BUT, I think your point is that a device *could* send spurious ERR_*
> messages before it is actually initialized. IMO, this seems more like a
> busted device rather than race condition gap in the spec.
> 
> All that to say, I agree this could happen, but it's not clear to me
> that it is "valid" vs broken device behavior.

Ah you're right.  I'm not sure we need to expect such broken devices
and handle them correctly.  I'll leave the decision to Bjorn, but
from my side, this fixup is optional based on your argument.

Thanks,

Lukas

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

end of thread, other threads:[~2026-11-30 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 18:35 [PATCH] PCI/AER: Check error status registers if Error Source ID is zero Lukas Wunner
2026-11-26 18:42 ` sashiko-bot
2026-11-30 15:04 ` Kuppuswamy Sathyanarayanan
2026-11-30 16:18 ` Yazen Ghannam
2026-11-30 17:09   ` Lukas Wunner
2026-11-30 18:02     ` Yazen Ghannam
2026-11-30 18:10       ` Lukas Wunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox