qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with QEMU usermode + jemalloc


From: Peter Maydell
Subject: Re: Problem with QEMU usermode + jemalloc
Date: Tue, 12 May 2020 19:38:14 +0100

On Tue, 12 May 2020 at 19:16, Michael Goffioul
<address@hidden> wrote:
> I'm running into a problem using QEMU in usermode and jemalloc (this is in 
> the context of an ARM-to-x86 translation layer for Android). The issue is 
> discussed here:
>
> https://github.com/jemalloc/jemalloc/issues/1844
>
> In a nutshell, the lack of madvise implementation is making jemalloc return 
> non-zeroed memory on calloc. This then creates various crashes in the 
> emulated code.
>
> What would be the QEMU devs point of view on this?

Yes, this is a QEMU bug. The comment in the QEMU code
suggests that making MADV_DONTNEED zero memory is not going
to be as straightforward as just passing through the call, though:

    case TARGET_NR_madvise:
        /* A straight passthrough may not be safe because qemu sometimes
           turns private file-backed mappings into anonymous mappings.
           This will break MADV_DONTNEED.
           This is a hint, so ignoring and returning success is ok.  */
        return 0;

That an "advice" function has been given guaranteed "actual
behaviour" requirements suggests somebody somewhere along the
line made a bad API design choice, but we're stuck with it now :-(

In general, QEMU's syscall emulation is not always perfect; you're
more likely to run into bugs if you do weird things, and using
madvise() to zero memory (rather than, say, just zeroing it) is
somewhat off the beaten path.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]