Re: [PATCH v3 07/14] gpu: nova-core: add an interrupt delivery self-test
From: sashiko-bot
Date: Wed Sep 02 2026 - 23:36:00 EST
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The `vectors_ref` field introduces a self-referential struct using a reference derived from a short-lived macro-local `&mut` binding. `try_pin_init!` provides access to previously initialized fields via local variable bindings, which expire at the end of the initialization closure. Taking a reference from this local variable and artificially extending its lifetime to `'gpu` via `unsafe { &*... }` violates strict aliasing rules (Stacked Borrows / Tree Borrows). When the closure returns, the local variable goes out of scope, its provenance tag is popped, and `vectors_ref` becomes a dangling pointer under the Rust memory model. Furthermore, the `pin-init` crate explicitly documents: "IMPORTANT: You are not allowed to create references to fields of the struct inside of the initializer."
--
commit 9bb2c0e6b8faa56d9fead3fb4f99c60340b45be0
Author: John Hubbard <jhubbard@xxxxxxxxxx>
gpu: nova-core: add an interrupt delivery self-test
Add an optional probe-time self-test that injects the CPU doorbell
through the GIN software trigger. It confirms the interrupt reaches
the driver's handler to validate the PCI interrupt path without GSP firmware.
> diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
> index e1ac8ee9ba4db..8a9bc4baf9ac0 100644
> --- a/drivers/gpu/nova-core/gpu.rs
> +++ b/drivers/gpu/nova-core/gpu.rs
[ ... ]
> @@ -330,6 +337,12 @@ pub(crate) fn new<'a>(
> let dev = pdev.as_ref();
>
> try_pin_init!(Self {
> + vectors: crate::irq::alloc_vectors(pdev, crate::irq::SERVICED_SUBTREE.into())?,
> +
> + // SAFETY: `vectors` is initialized above, lives at a pinned stable address, and is
> + // dropped after every field that uses `vectors_ref` (struct field drop order).
> + vectors_ref: unsafe { &*core::ptr::from_ref(vectors.as_ref().get_ref()) },
[Severity: High]
Does this create a dangling pointer under the Rust memory model?
`try_pin_init!` provides access to previously initialized fields via local
variable bindings, which expire at the end of the initialization closure.
Taking a reference from this local variable and artificially extending its
lifetime to `'gpu` via `unsafe { &*... }` violates strict aliasing rules
(Stacked Borrows / Tree Borrows).
When the closure returns, the local variable goes out of scope, its
provenance tag is popped, and `vectors_ref` becomes a dangling pointer.
The `pin-init` crate also explicitly documents that creating references to
fields of the struct inside the initializer is not allowed.
> +
> spec: Spec::new(dev, bar).inspect(|spec| {
> dev_info!(dev,"NVIDIA ({})\n", spec);
> })?,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903031514.1515905-1-jhubbard@xxxxxxxxxx?part=7