]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: Support MADV_DONTDUMP, MADV_DODUMP
authorJon Wilson <jonwilson030981@gmail.com>
Wed, 24 Sep 2025 01:52:28 +0000 (18:52 -0700)
committerRichard Henderson <richard.henderson@linaro.org>
Tue, 14 Oct 2025 14:30:39 +0000 (07:30 -0700)
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>
include/exec/page-protection.h
linux-user/elfload.c
linux-user/mmap.c

index 5a18f98a3aed94240339ca74e7d31a347bf5b389..c50ce57d150f3c4c5f35182477a471358db11871 100644 (file)
 #define PAGE_PASSTHROUGH 0x40
 /* For linux-user, indicates that the page is MAP_ANON. */
 #define PAGE_ANON      0x0080
-
+/*
+ * For linux-user, indicates that the page should not be
+ * included in a core dump.
+ */
+#define PAGE_DONTDUMP  0x0100
 /* Target-specific bits that will be used via page_get_flags().  */
 #define PAGE_TARGET_1  0x0200
 #define PAGE_TARGET_2  0x0400
index 1370ec59be4dfc65564d685d9cf8f8353a8d8193..0002d5be2f5f992fb96d18615c47fc4ce9c8c270 100644 (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;
     }
 
index 527ca5f211d70bcfaf8a83c92f5c6c7b33dc8121..423c77856a3aa8caeccfa2c0bcf26364d6c04d1d 100644 (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;