All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <tom.leiming@gmail.com>
To: Caleb Sander Mateos <csander@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [PATCH 1/7] ublk: widen ublk_shmem_buf_reg.len to __u64 for 4GB buffer support
Date: Wed, 15 Apr 2026 07:49:02 +0800	[thread overview]
Message-ID: <ad7SbiqAtlKlI5xh@fedora> (raw)
In-Reply-To: <CADUfDZr39RaLObyXg9sijCOpLF4K2+TZH3ygGiCVxO8aAqwTkw@mail.gmail.com>

On Tue, Apr 14, 2026 at 11:40:36AM -0700, Caleb Sander Mateos wrote:
> On Thu, Apr 9, 2026 at 6:30 AM Ming Lei <tom.leiming@gmail.com> wrote:
> >
> > The __u32 len field cannot represent a 4GB buffer (0x100000000
> > overflows to 0). Change it to __u64 so buffers up to 4GB can be
> > registered. Add a reserved field for alignment and validate it
> > is zero.
> >
> > The kernel enforces a default max of 4GB (UBLK_SHMEM_BUF_SIZE_MAX)
> > which may be increased in future.
> >
> > Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> > ---
> >  drivers/block/ublk_drv.c      | 9 ++++++++-
> >  include/uapi/linux/ublk_cmd.h | 3 ++-
> >  2 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index 2e475bdc54dd..ada9a2e32ea9 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -63,6 +63,9 @@
> >  #define UBLK_CMD_REG_BUF       _IOC_NR(UBLK_U_CMD_REG_BUF)
> >  #define UBLK_CMD_UNREG_BUF     _IOC_NR(UBLK_U_CMD_UNREG_BUF)
> >
> > +/* Default max shmem buffer size: 4GB (may be increased in future) */
> > +#define UBLK_SHMEM_BUF_SIZE_MAX        (1ULL << 32)
> > +
> >  #define UBLK_IO_REGISTER_IO_BUF                _IOC_NR(UBLK_U_IO_REGISTER_IO_BUF)
> >  #define UBLK_IO_UNREGISTER_IO_BUF      _IOC_NR(UBLK_U_IO_UNREGISTER_IO_BUF)
> >
> > @@ -5351,11 +5354,15 @@ static int ublk_ctrl_reg_buf(struct ublk_device *ub,
> >         if (buf_reg.flags & ~UBLK_SHMEM_BUF_READ_ONLY)
> >                 return -EINVAL;
> >
> > +       if (buf_reg.reserved)
> > +               return -EINVAL;
> > +
> >         addr = buf_reg.addr;
> >         size = buf_reg.len;
> >         nr_pages = size >> PAGE_SHIFT;
> >
> > -       if (!size || !PAGE_ALIGNED(size) || !PAGE_ALIGNED(addr))
> > +       if (!size || size > UBLK_SHMEM_BUF_SIZE_MAX ||
> 
> Should be >=? Otherwise, LGTM.

It should be ">" because we do want to support 4GB size buffer.


Thanks,
Ming

  reply	other threads:[~2026-04-14 23:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 13:30 [PATCH 0/7] ublk: followup fixes for SHMEM_ZC Ming Lei
2026-04-09 13:30 ` [PATCH 1/7] ublk: widen ublk_shmem_buf_reg.len to __u64 for 4GB buffer support Ming Lei
2026-04-14 18:40   ` Caleb Sander Mateos
2026-04-14 23:49     ` Ming Lei [this message]
2026-04-09 13:30 ` [PATCH 2/7] ublk: verify all pages in multi-page bvec fall within registered range Ming Lei
2026-04-09 13:30 ` [PATCH 3/7] ublk: simplify PFN range loop in __ublk_ctrl_reg_buf Ming Lei
2026-04-09 13:30 ` [PATCH 4/7] ublk: replace xarray with IDA for shmem buffer index allocation Ming Lei
2026-04-09 13:30 ` [PATCH 5/7] ublk: allow buffer registration before device is started Ming Lei
2026-04-09 13:30 ` [PATCH 6/7] Documentation: ublk: address review comments for SHMEM_ZC docs Ming Lei
2026-04-09 13:30 ` [PATCH 7/7] MAINTAINERS: update ublk driver maintainer email Ming Lei
2026-04-10  1:11 ` [PATCH 0/7] ublk: followup fixes for SHMEM_ZC Jens Axboe
2026-04-10  1:12 ` Jens Axboe

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=ad7SbiqAtlKlI5xh@fedora \
    --to=tom.leiming@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    /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.