Re: [PATCH v1 05/19] PCI/AER: Embed aer_capability_regs copy in struct aer_recover_entry
From: Lukas Wunner
Date: Tue Nov 17 2026 - 06:45:29 EST
On Tue, Nov 17, 2026 at 12:10:15PM +0100, Pierre Gondois wrote:
> commit e2abc47a5a1a ("ACPI: APEI: Fix AER info corruption when error
> status data has multiple sections") passed to aer_recover_queue() a
> newly allocated copy of pcie_err->aer_info instead of providing a
> pointer to the ghes struct. This prevented corruptions of the ghes
> record (in case the ghes record was re-used for a new error before
> the previous error was logged).
Since commit eddba19b8b5f ("PCI/AER: Support Advisory Non-Fatal Errors"),
aer_regs is modified for a recursive invocation of __pci_print_aer().
The copy is necessary because we don't want to modify a buffer owned by
platform firmware.
> +++ b/drivers/pci/pcie/aer.c
> @@ -1352,7 +1352,7 @@ struct aer_recover_entry {
> u8 devfn;
> u16 domain;
> int severity;
> - struct aer_capability_regs *regs;
> + struct aer_capability_regs regs;
> };
This increases stack usage significantly in aer_recover_queue(),
which is not good. A kzalloc() allocation may be better suited
for such a large struct, instead of relying on the stack.
> @@ -1374,24 +1374,14 @@ static void aer_recover_work_func(struct work_struct *work)
> PCI_SLOT(entry.devfn),
> PCI_FUNC(entry.devfn));
> else
> - pci_print_aer(pdev, entry.severity, entry.regs);
> + pci_print_aer(pdev, entry.severity, &entry.regs);
>
> - regs = entry.regs;
> + regs = &entry.regs;
> if (entry.severity == AER_CORRECTABLE)
> err = regs->cor_status & ~regs->cor_mask;
> else
> err = regs->uncor_status & ~regs->uncor_mask;
>
> - /*
> - * Memory for aer_capability_regs(entry.regs) is being
> - * allocated from the ghes_estatus_pool to protect it from
> - * overwriting when multiple sections are present in the
> - * error status. Thus free the same after processing the
> - * data.
> - */
> - ghes_estatus_pool_region_free((unsigned long)entry.regs,
> - sizeof(struct aer_capability_regs));
> -
So you're removing the call to ghes_estatus_pool_region_free() from the
worker...
> @@ -1441,17 +1431,18 @@ void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
> .devfn = devfn,
> .domain = domain,
> .severity = severity,
> - .regs = aer_regs,
> + .regs = *aer_regs,
> };
>
> + ghes_estatus_pool_region_free((unsigned long)aer_regs,
> + sizeof(struct aer_capability_regs));
> +
... and instead call it earlier, before even launching the worker.
So where's the benefit? You've traded less memory usage in the
pool for higher stack usage. How is that useful?
Thanks,
Lukas