linux-user: Support MADV_DONTDUMP, MADV_DODUMP

Set and clear PAGE_DONTDUMP, and honor that in vma_dump_size.

Signed-off-by: Jon Wilson <jonwilson030981@gmail.com>
[rth: Use new page_set_flags semantics; also handle DODUMP]
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Jon Wilson 2025-09-23 18:52:28 -07:00 committed by Richard Henderson
parent f55fc1c092
commit a79fbb6988
3 changed files with 13 additions and 3 deletions

View file

@ -2127,8 +2127,8 @@ static void bswap_note(struct elf_note *en)
*/
static size_t vma_dump_size(vaddr start, vaddr end, int flags)
{
/* The area must be readable. */
if (!(flags & PAGE_READ)) {
/* The area must be readable and dumpable. */
if (!(flags & PAGE_READ) || (flags & PAGE_DONTDUMP)) {
return 0;
}

View file

@ -1248,6 +1248,12 @@ abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice)
*/
mmap_lock();
switch (advice) {
case MADV_DONTDUMP:
page_set_flags(start, start + len - 1, PAGE_DONTDUMP, 0);
break;
case MADV_DODUMP:
page_set_flags(start, start + len - 1, 0, PAGE_DONTDUMP);
break;
case MADV_WIPEONFORK:
case MADV_KEEPONFORK:
ret = -EINVAL;