public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Timur Tabi" <ttabi@nvidia.com>
Cc: "John Hubbard" <jhubbard@nvidia.com>,
	"gary@garyguo.net" <gary@garyguo.net>,
	"mmaurer@google.com" <mmaurer@google.com>,
	"rust-for-linux@vger.kernel.org" <rust-for-linux@vger.kernel.org>,
	"nouveau@lists.freedesktop.org" <nouveau@lists.freedesktop.org>,
	"dakr@kernel.org" <dakr@kernel.org>,
	"Joel Fernandes" <joelagnelf@nvidia.com>,
	"aliceryhl@google.com" <aliceryhl@google.com>
Subject: Re: [PATCH v8 3/7] rust: dma: implement BinaryWriter for CoherentAllocation<u8>
Date: Sun, 15 Mar 2026 14:11:10 +0900	[thread overview]
Message-ID: <DH33IXMUWQ3T.1QMJSFCCA8NTV@nvidia.com> (raw)
In-Reply-To: <ac909647923d01f1e00e40bb0af83a546fdb1f10.camel@nvidia.com>

On Sat Mar 14, 2026 at 11:05 AM JST, Timur Tabi wrote:
> On Fri, 2026-03-13 at 11:11 +0900, Alexandre Courbot wrote:
>> > +        if offset.is_negative() {
>> > +            return Err(EINVAL);
>> > +        }
>> 
>> Won't the `try_into` right below also reject negative values?
>> 
>> > +
>> > +        let offset_val: usize = (*offset).try_into().map_err(|_| EINVAL)?;
>
> Well, yes, but there's actually a bigger problem, now that you point this out.  If usize is 32
> bits, the try_into() could fail if *offset is too large.  In that case, it should return Ok(0)
> instead of EINVAL.
>
> So actually, we need to keep the is_negative() check, but should modify the try_into() to return
> Ok(0) instead of EINVAL.
>
> let Ok(offset_val) = usize::try_from(*offset) else {
>     return Ok(0);  // offset too large for usize = past EOF
> };
>
> Are we going to assume CONFIG_64BIT forever, and just ignore any possible errors if usize is 32
> bits?

This is not Nova, so we cannot assume CONFIG_64BIT. I guess we have to
do as you described above.

  reply	other threads:[~2026-03-15  5:11 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 21:59 [PATCH v8 0/7] gpu: nova-core: expose the logging buffers via debugfs Timur Tabi
2026-03-10 21:59 ` [PATCH v8 1/7] rust: device: add device name method Timur Tabi
2026-03-10 22:05   ` Alice Ryhl
2026-03-13  2:10   ` Alexandre Courbot
2026-03-10 21:59 ` [PATCH v8 2/7] rust: uaccess: add write_dma() for copying from DMA buffers to userspace Timur Tabi
2026-03-11  5:48   ` kernel test robot
2026-03-13  2:11   ` Alexandre Courbot
2026-03-10 21:59 ` [PATCH v8 3/7] rust: dma: implement BinaryWriter for CoherentAllocation<u8> Timur Tabi
2026-03-13  2:11   ` Alexandre Courbot
2026-03-14  2:05     ` Timur Tabi
2026-03-15  5:11       ` Alexandre Courbot [this message]
2026-03-15 18:57         ` Timur Tabi
2026-03-16  3:44           ` Alexandre Courbot
2026-03-10 21:59 ` [PATCH v8 4/7] gpu: nova-core: Replace module_pci_driver! with explicit module init Timur Tabi
2026-03-10 21:59 ` [PATCH v8 5/7] gpu: nova-core: use pin projection in method boot() Timur Tabi
2026-03-13  2:13   ` Alexandre Courbot
2026-03-14  2:20     ` Timur Tabi
2026-03-10 21:59 ` [PATCH v8 6/7] gpu: nova-core: create debugfs root in module init Timur Tabi
2026-03-10 22:00 ` [PATCH v8 7/7] gpu: nova-core: create GSP-RM logging buffers debugfs entries Timur Tabi
2026-03-10 22:20 ` [PATCH v8 0/7] gpu: nova-core: expose the logging buffers via debugfs John Hubbard
2026-03-12  3:50 ` John Hubbard

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=DH33IXMUWQ3T.1QMJSFCCA8NTV@nvidia.com \
    --to=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=joelagnelf@nvidia.com \
    --cc=mmaurer@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox