From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <linux-pci@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>, <bhelgaas@google.com>,
Lukas Wunner <lukas@wunner.de>,
"Kuppuswamy Sathyanarayanan"
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Jon Pan-Doh <pandoh@google.com>,
Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH v3 1/2] PCI/AER: Reject negative ratelimit interval and burst values
Date: Tue, 24 Nov 2026 21:28:45 -0600 [thread overview]
Message-ID: <20261125032846.4019744-1-yazen.ghannam@amd.com> (raw)
In-Reply-To: <20261123233859.GA1120797@bhelgaas>
The AER "*_ratelimit_interval_ms" and "*_ratelimit_burst" sysfs
attributes accept negative values. A negative interval is treated as
0, which disables ratelimiting. A negative burst is stored as is, and
___ratelimit() then warns about an uninitialized ratelimit_state.
However, a negative value has no meaningful interpretation for either
attribute.
Return -EINVAL for negative input.
Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-pci/20260714191826.BA81E1F000E9@smtp.kernel.org/
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
Replaces "PCI/AER: Clamp negative ratelimit burst to zero" in place on
pci/aer. Patch 2/2 (docs) goes on top of the pci/aer tip.
v2->v3:
- Split the documentation into its own patch. (Bjorn)
v1->v2:
- Return -EINVAL for negative interval and burst values instead of
clamping. (Bjorn)
This no longer touches the ABI file, so "PCI/AER: Enable baseline
capability error reporting" applies on top as Lukas posted it, without
the "or any negative value" merge fixup in its two interval
descriptions. The rest of pci/aer applies unchanged.
Tested in a QEMU guest with injected correctable and non-fatal errors,
for every combination of interval {-1, 0, positive} and burst {-1, 0,
positive}. Negative writes fail with -EINVAL. Every error is counted
and traced. Interval 0 logs every error, whatever the burst. A positive
interval with burst 0 logs none.
An LLM coding assistant helped check the ___ratelimit() semantics,
split and rebase the patches, resolve the conflict and write the QEMU
test.
v2: https://lore.kernel.org/r/20261123165050.GA1741477@yaz-khff2.amd.com
v1: https://lore.kernel.org/r/20261110215614.3931232-3-yazen.ghannam@amd.com
drivers/pci/pcie/aer.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 6f2460231422..2c42d6e8bd9a 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -690,7 +690,8 @@ const struct attribute_group aer_stats_attr_group = {
/*
* Ratelimit interval
- * <=0: disabled with ratelimit.interval = 0
+ * <0: rejected
+ * 0: disabled with ratelimit.interval = 0
* >0: enabled with ratelimit.interval in ms
*/
#define aer_ratelimit_interval_attr(name, ratelimit) \
@@ -717,10 +718,10 @@ const struct attribute_group aer_stats_attr_group = {
if (kstrtoint(buf, 0, &interval) < 0) \
return -EINVAL; \
\
- if (interval <= 0) \
- interval = 0; \
- else \
- interval = msecs_to_jiffies(interval); \
+ if (interval < 0) \
+ return -EINVAL; \
+ \
+ interval = msecs_to_jiffies(interval); \
\
pdev->aer_info->ratelimit.interval = interval; \
\
@@ -752,6 +753,9 @@ const struct attribute_group aer_stats_attr_group = {
if (kstrtoint(buf, 0, &burst) < 0) \
return -EINVAL; \
\
+ if (burst < 0) \
+ return -EINVAL; \
+ \
pdev->aer_info->ratelimit.burst = burst; \
\
return count; \
--
2.55.0
next prev parent reply other threads:[~2026-11-25 3:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 21:56 [PATCH 0/4] AER sysfs fixes Yazen Ghannam
2026-11-10 21:56 ` [PATCH 1/4] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM Yazen Ghannam
2026-11-10 21:56 ` [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero Yazen Ghannam
2026-11-20 18:10 ` Bjorn Helgaas
2026-11-20 21:13 ` Yazen Ghannam
2026-11-21 0:12 ` Bjorn Helgaas
2026-11-23 16:50 ` Yazen Ghannam
2026-11-23 23:38 ` Bjorn Helgaas
2026-11-24 18:05 ` Yazen Ghannam
2026-11-25 3:28 ` Yazen Ghannam [this message]
2026-11-25 3:28 ` [PATCH v3 2/2] PCI/AER: Document ratelimit interval and burst values of 0 Yazen Ghannam
2026-11-10 21:56 ` [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds Yazen Ghannam
2026-11-18 16:39 ` Sang-Heon Jeon
2026-11-10 21:56 ` [PATCH 4/4] PCI/AER: Hide the "aer" sysfs directory on devices without AER Yazen Ghannam
2026-11-21 1:31 ` Bjorn Helgaas
2026-11-22 17:56 ` Lukas Wunner
2026-11-23 23:46 ` Bjorn Helgaas
2026-11-24 8:01 ` Lukas Wunner
2026-11-19 0:02 ` [PATCH 0/4] AER sysfs fixes Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125032846.4019744-1-yazen.ghannam@amd.com \
--to=yazen.ghannam@amd.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=pandoh@google.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®