From: Raag Jadav <raag.jadav@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: riana.tauro@intel.com, Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v2] drm/xe/ras: Validate sysctrl response
Date: Wed, 22 Jul 2026 20:01:42 +0530 [thread overview]
Message-ID: <20260722143142.675658-1-raag.jadav@intel.com> (raw)
Validate errors raised by sysctrl firmware instead of blindly trusting
them.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
v2: Continue invalid uncorrectable error case (Riana)
s/error/counter (Riana)
---
drivers/gpu/drm/xe/xe_ras.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
index 5e294e9f8f99..28123f08e513 100644
--- a/drivers/gpu/drm/xe/xe_ras.c
+++ b/drivers/gpu/drm/xe/xe_ras.c
@@ -156,6 +156,24 @@ static inline const char *comp_to_str(u8 component)
return xe_ras_components[component];
}
+static bool ras_counter_is_valid(struct xe_device *xe, struct xe_ras_error_class *counter)
+{
+ u8 severity = counter->common.severity;
+ u8 component = counter->common.component;
+
+ if (!in_range(severity, XE_RAS_SEV_NOT_SUPPORTED + 1, XE_RAS_SEV_MAX - 1)) {
+ xe_err(xe, "sysctrl: unexpected severity %u\n", severity);
+ return false;
+ }
+
+ if (!in_range(component, XE_RAS_COMP_NOT_SUPPORTED + 1, XE_RAS_COMP_MAX - 1)) {
+ xe_err(xe, "sysctrl: unexpected component %u\n", component);
+ return false;
+ }
+
+ return true;
+}
+
static struct pci_dev *find_usp_dev(struct pci_dev *pdev)
{
struct pci_dev *vsp;
@@ -327,6 +345,9 @@ void xe_ras_counter_threshold_crossed(struct xe_device *xe,
severity = errors[id].common.severity;
component = errors[id].common.component;
+ if (!ras_counter_is_valid(xe, &errors[id]))
+ continue;
+
xe_warn(xe, "[RAS]: %s %s detected\n",
comp_to_str(component), sev_to_str(severity));
}
@@ -358,6 +379,9 @@ static int get_counter(struct xe_device *xe, struct xe_ras_error_class *counter,
return -EIO;
}
+ if (!ras_counter_is_valid(xe, &response.counter))
+ return -EBADMSG;
+
common = &response.counter.common;
*value = response.value;
@@ -422,6 +446,9 @@ enum xe_ras_recovery_action xe_ras_process_errors(struct xe_device *xe)
component = arr->counter.common.component;
severity = arr->counter.common.severity;
+ if (!ras_counter_is_valid(xe, &arr->counter))
+ continue;
+
xe_info(xe, "[RAS]: %s %s detected\n", comp_to_str(component),
sev_to_str(severity));
@@ -532,6 +559,9 @@ int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component)
counter = &response.counter;
+ if (!ras_counter_is_valid(xe, counter))
+ return -EBADMSG;
+
xe_dbg(xe, "[RAS]: clear counter for %s %s\n", comp_to_str(counter->common.component),
sev_to_str(counter->common.severity));
--
2.43.0
next reply other threads:[~2026-07-22 14:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 14:31 Raag Jadav [this message]
2026-07-22 18:43 ` ✓ CI.KUnit: success for drm/xe/ras: Validate sysctrl response (rev2) Patchwork
2026-07-22 19:52 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-23 14:29 ` [PATCH v2] drm/xe/ras: Validate sysctrl response Tauro, Riana
2026-08-03 9:51 ` Tauro, Riana
2026-07-23 15:52 ` ✗ Xe.CI.FULL: failure for drm/xe/ras: Validate sysctrl response (rev2) Patchwork
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=20260722143142.675658-1-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=riana.tauro@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