qemu-arm
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 2/4] Memory: Enable writeback for given memory r


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH 2/4] Memory: Enable writeback for given memory region
Date: Tue, 24 Sep 2019 09:28:36 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 9/10/19 2:56 AM, Beata Michalska wrote:
> +int main(void) {
> +#if defined(_POSIX_MAPPED_FILES) && _POSIX_MAPPED_FILES > 0 \
> +&& defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
> +return msync(NULL,0, MS_SYNC);
> +#else
> +#error Not supported
> +#endif
> +}

Is there any particular reason to check _POSIX_MAPPED_FILES &
_POSIX_SYNCHRONIZED_IO?  IIRC, you can use those to "safely" use MS_SYNC.  But
this is a configure test, and an error is in fact our defined failure case, so
"safely" doesn't seem particularly relevant.

Alternately, do we even support any systems (besides perhaps windows) that do
not provide POSIX-2001 support, and so include msync + MS_SYNC?  My first guess
is that we don't.

> +        msync((void *)((uintptr_t)addr & qemu_host_page_mask),
> +               HOST_PAGE_ALIGN(length), MS_SYNC);

This isn't quite right.  If you move addr down to a lower address via this page
mask, you must also increase length by the same amount, and only afterward
increase length to the host page size.

Consider addr == 0xffffff, length = 2.  This covers two pages, so you'd expect
the final parameters to be, for 4k page size, 0xfff000, 0x2000.


r~



reply via email to

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