All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Elisha Hollander <just4now666666@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] util/memfd: allow allocating 0 bytes
Date: Tue, 6 May 2025 17:48:39 +0100	[thread overview]
Message-ID: <aBo9Z4NjOReXwbni@redhat.com> (raw)
In-Reply-To: <CACkyd_YNXivoXE3PFNmK_5QCRQV83JZRf9NUEU+0yM4FOgM4fg@mail.gmail.com>

On Tue, May 06, 2025 at 07:41:32PM +0300, Elisha Hollander wrote:
> Gave an example for a case where QEMU would try to allocate 0 bytes thus
> fail here in the original version of the patch.
> 
> > As I mentioned earlier, let's say you don't initialize the vertical
> display end registers, and set the minimum scanline register, the emulation
> will then have to allocate some display buffer, but because the vertical
> display end is initilized as 0 the buffer will be empty and the program
> break.

Isn't this an invalid hardware configuration that should be detected
in the emulation code, and either force the display end to a minimum
value, or trigger an assert ?

Patching a bug in a specific HW impl, by changing the qemu_memfd_alloc
code feels like it is probably the wrong place to address this.

> 
> I have no idea as for why my emails are getting messed up... :/
> 
> Have to go now, will try and send it again tomorrow probably...
> 
> On Tue, May 6, 2025, 19:37 Daniel P. Berrangé <berrange@redhat.com> wrote:
> 
> > On Tue, May 06, 2025 at 07:17:25PM +0300, Elisha Hollander wrote:
> > > Sorry for former patch something is messed up with my email.
> >
> > The commit message needs to explain what problem is being solved by
> > making this change as allowing 0 bytes looks dubious on the surface.
> >
> > >
> > > Signed-off-by: donno2048 <just4now666666@gmail.com>
> > > ---
> > >  util/memfd.c | 10 ++++++----
> > >  1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/util/memfd.c b/util/memfd.c
> > > index 8a2e906..e96e5af 100644
> > > --- a/util/memfd.c
> > > +++ b/util/memfd.c
> > > @@ -108,7 +108,7 @@ err:
> > >  void *qemu_memfd_alloc(const char *name, size_t size, unsigned int
> > seals,
> > >                         int *fd, Error **errp)
> > >  {
> > > - void *ptr;
> > > + void *ptr = NULL;
> > >      int mfd = qemu_memfd_create(name, size, false, 0, seals, NULL);
> > >
> > >      /* some systems have memfd without sealing */
> > > @@ -131,9 +131,11 @@ void *qemu_memfd_alloc(const char *name, size_t
> > size,
> > > unsigned int seals,
> > >          }
> > >      }
> > >
> > > - ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
> > > - if (ptr == MAP_FAILED) {
> > > - goto err;
> > > + if (size != 0) {
> > > + ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
> > > + if (ptr == MAP_FAILED) {
> > > + goto err;
> > > + }
> > >      }
> >
> > This patch is mangled.
> >
> >
> > With regards,
> > Daniel
> > --
> > |: https://berrange.com      -o-
> > https://www.flickr.com/photos/dberrange :|
> > |: https://libvirt.org         -o-
> > https://fstop138.berrange.com :|
> > |: https://entangle-photo.org    -o-
> > https://www.instagram.com/dberrange :|
> >
> >

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-05-06 16:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 16:17 [PATCH v2] util/memfd: allow allocating 0 bytes Elisha Hollander
2025-05-06 16:37 ` Daniel P. Berrangé
2025-05-06 16:41   ` Elisha Hollander
2025-05-06 16:48     ` Daniel P. Berrangé [this message]
2025-05-06 22:25       ` Elisha Hollander
2025-05-07 11:36         ` Daniel P. Berrangé
  -- strict thread matches above, loose matches on Subject: below --
2025-05-06 16:44 Elisha Hollander
2025-05-07 11:58 ` Philippe Mathieu-Daudé
2025-05-07 15:51   ` Elisha Hollander
2025-05-06 16:10 Elisha Hollander

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=aBo9Z4NjOReXwbni@redhat.com \
    --to=berrange@redhat.com \
    --cc=just4now666666@gmail.com \
    --cc=marcandre.lureau@gmail.com \
    --cc=qemu-devel@nongnu.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.