All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Timur Tabi <ttabi@nvidia.com>, Danilo Krummrich <dakr@kernel.org>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Joel Fernandes <joelagnelf@nvidia.com>,
	nouveau@lists.freedesktop.org, rust-for-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] gpu: nova-core: check for overflow to DMATRFBASE1
Date: Tue, 6 Jan 2026 17:56:13 -0800	[thread overview]
Message-ID: <60c8a10b-c333-412e-8b13-446a3e04c41d@nvidia.com> (raw)
In-Reply-To: <20260107012414.2429246-1-ttabi@nvidia.com>

On 1/6/26 5:24 PM, Timur Tabi wrote:
> 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.

Your commit log said it accurately, so I think we should use similar wording
here. So maybe:

   // Set up the base source DMA address.  The DMATRFBASE/1 register pair
   // only supports a 49-bit address.

However, one could argue that only the DMATRFBASE base matters
when considering overflow. But even so, it's slightly confusing
at first glance, to refer to a 32-bit register as only supporting
49-bit addresses. Of course yes, they can look at the register
which is shifted up, but still.

Either way is fine, I'm just fussing over nearly nothing here,
so:

Reviewed-by: John Hubbard <jhubbard@nvidia.com>


thanks,
-- 
John Hubbard

> +        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



  parent reply	other threads:[~2026-01-07  1:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 10:22           ` Miguel Ojeda
2026-01-07  9:54     ` Miguel Ojeda
2026-01-07  9:54       ` Miguel Ojeda
2026-01-08 12:55       ` Gary Guo
2026-01-08 12:55         ` Gary Guo
2026-01-08 13:36         ` Danilo Krummrich
2026-01-08 13:36           ` Danilo Krummrich
2026-01-08 13:42           ` Alice Ryhl
2026-01-08 13:42             ` Alice Ryhl
2026-01-08 14:13           ` Gary Guo
2026-01-08 14:13             ` Gary Guo
2026-01-07  1:56 ` John Hubbard [this message]
2026-01-07  2:04   ` [PATCH 1/2] gpu: nova-core: check for overflow to DMATRFBASE1 Timur Tabi
2026-01-07  3:55 ` Joel Fernandes
2026-01-07  3:55   ` Joel Fernandes

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=60c8a10b-c333-412e-8b13-446a3e04c41d@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=acourbot@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=joelagnelf@nvidia.com \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=ttabi@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.