Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH 1/2] gpu: nova-core: check for overflow to DMATRFBASE1
@ 2026-01-07  1:24 Timur Tabi
  2026-01-07  1:24 ` [PATCH 2/2] gpu: nova-core: add missing newlines to several print strings Timur Tabi
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Timur Tabi @ 2026-01-07  1:24 UTC (permalink / raw)
  To: Danilo Krummrich, Alexandre Courbot, Joel Fernandes, John Hubbard,
	nouveau, rust-for-linux

The NV_PFALCON_FALCON_DMATRFBASE/1 register pair supports DMA address
up to 49 bits only, but the write to DMATRFBASE1 could exceed that.
To mitigate, check first that the DMA address will fit.

Fixes: 69f5cd67ce41 ("gpu: nova-core: add falcon register definitions and base code")
Signed-off-by: Timur Tabi <ttabi@nvidia.com>
---
 drivers/gpu/nova-core/falcon.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon.rs
index 82c661aef594..fe5abf64dd2b 100644
--- a/drivers/gpu/nova-core/falcon.rs
+++ b/drivers/gpu/nova-core/falcon.rs
@@ -493,7 +493,11 @@ fn dma_wr<F: FalconFirmware<Target = E>>(
             Some(_) => (),
         };
 
-        // Set up the base source DMA address.
+        // Set up the base source DMA address.  DMATRFBASE only supports a 49-bit address.
+        if dma_start > kernel::dma::DmaMask::new::<49>().value() {
+            dev_err!(self.dev, "DMA address {:#x} exceeds 49 bits\n", dma_start);
+            return Err(ERANGE);
+        }
 
         regs::NV_PFALCON_FALCON_DMATRFBASE::default()
             // CAST: `as u32` is used on purpose since we do want to strip the upper bits, which

base-commit: 4348796233e736147e2e79c58784d0a9fb48867d
-- 
2.52.0


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

end of thread, other threads:[~2026-01-08 14:13 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07  1:24 [PATCH 1/2] gpu: nova-core: check for overflow to DMATRFBASE1 Timur Tabi
2026-01-07  1:24 ` [PATCH 2/2] gpu: nova-core: add missing newlines to several print strings Timur Tabi
2026-01-07  2:10   ` John Hubbard
2026-01-07  2:21     ` Timur Tabi
2026-01-07  2:39       ` John Hubbard
2026-01-07 10:22         ` Miguel Ojeda
2026-01-07  9:54     ` Miguel Ojeda
2026-01-08 12:55       ` Gary Guo
2026-01-08 13:36         ` Danilo Krummrich
2026-01-08 13:42           ` Alice Ryhl
2026-01-08 14:13           ` Gary Guo
2026-01-07  1:56 ` [PATCH 1/2] gpu: nova-core: check for overflow to DMATRFBASE1 John Hubbard
2026-01-07  2:04   ` Timur Tabi
2026-01-07  3:55 ` Joel Fernandes

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