qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Hanna Reitz" <hreitz@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
	"Keith Busch" <kbusch@kernel.org>,
	"Klaus Jensen" <its@irrelevant.dk>,
	"Jesper Devantier" <foss@defmacro.it>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Akihiko Odaki" <akihiko.odaki@daynix.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH] Use "void *" as parameter for functions that are used for aio_set_event_notifier()
Date: Fri, 31 May 2024 07:10:23 +0200	[thread overview]
Message-ID: <48e4fe8f-7a3c-4b2f-a687-02613e3b5a26@redhat.com> (raw)
In-Reply-To: <20240529182222.GB1203999@fedora.redhat.com>

On 29/05/2024 20.22, Stefan Hajnoczi wrote:
> On Wed, May 29, 2024 at 07:49:48PM +0200, Thomas Huth wrote:
>> aio_set_event_notifier() and aio_set_event_notifier_poll() in
>> util/aio-posix.c and util/aio-win32.c are casting function pointers of
>> functions that take an "EventNotifier *" pointer as parameter to function
>> pointers that take a "void *" pointer as parameter (i.e. the IOHandler
>> type). When those function pointers are later used to call the referenced
>> function, this triggers undefined behavior errors with the latest version
>> of Clang in Fedora 40 when compiling with the option "-fsanitize=undefined".
>> And this also prevents enabling the strict mode of CFI which is currently
>> disabled with -fsanitize-cfi-icall-generalize-pointers. Thus let us avoid
>> the problem by using "void *" as parameter in all spots where it is needed.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   Yes, I know, the patch looks ugly ... but I don't see a better way to
>>   tackle this. If someone has a better idea, suggestions are welcome!
> 
> An alternative is adding EventNotifierHandler *io_read, *io_poll_ready,
> *io_poll_begin, and *io_poll_end fields to EventNotifier so that
> aio_set_event_notifier() and aio_set_event_notifier_poll() can pass
> helper functions to the underlying aio_set_fd_handler() and
> aio_set_fd_poll() APIs. These helper functions then invoke the
> EventNotifier callbacks:
> 
> /* Helpers */
> static void event_notifier_io_read(void *opaque)
> {
>      EventNotifier *notifier = opaque;
>      notifier->io_read(notifier);
> }

That's a nice idea, thanks, I'll give it a try!

  Thomas




  reply	other threads:[~2024-05-31  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-29 17:49 [PATCH] Use "void *" as parameter for functions that are used for aio_set_event_notifier() Thomas Huth
2024-05-29 18:22 ` Stefan Hajnoczi
2024-05-31  5:10   ` Thomas Huth [this message]
2024-06-02 22:01 ` Michael S. Tsirkin

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=48e4fe8f-7a3c-4b2f-a687-02613e3b5a26@redhat.com \
    --to=thuth@redhat.com \
    --cc=akihiko.odaki@daynix.com \
    --cc=eperezma@redhat.com \
    --cc=fam@euphon.net \
    --cc=foss@defmacro.it \
    --cc=hreitz@redhat.com \
    --cc=its@irrelevant.dk \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=maciej.szmigiero@oracle.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /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;
as well as URLs for NNTP newsgroup(s).