aboutsummaryrefslogtreecommitdiff
path: root/linux-user/elfload.c
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-02-27 06:43:53 -1000
committerRichard Henderson <richard.henderson@linaro.org>2024-02-29 11:03:52 -1000
commitb4c7ab816b48e0d2dd15753c0329bd4aa59f713f (patch)
treed39c0cb09696298147c57488984ea464451c4f8e /linux-user/elfload.c
parent243c47066253c4236b8792ee158f9971d1c27bf9 (diff)
downloadqemu-b4c7ab816b48e0d2dd15753c0329bd4aa59f713f.zip
qemu-b4c7ab816b48e0d2dd15753c0329bd4aa59f713f.tar.gz
qemu-b4c7ab816b48e0d2dd15753c0329bd4aa59f713f.tar.bz2
linux-user/elfload: Write process memory to core file in larger chunks
We do not need to copy pages from guest memory before writing them out. Because vmas are contiguous in host memory, we can write them in one go. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'linux-user/elfload.c')
-rw-r--r--linux-user/elfload.c27
1 files changed, 4 insertions, 23 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index b8d07d8..491e754 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -4551,32 +4551,13 @@ static int elf_core_dump(int signr, const CPUArchState *env)
}
/*
- * Finally we can dump process memory into corefile as well.
+ * Finally write process memory into the corefile as well.
*/
for (vma = vma_first(&mm); vma != NULL; vma = vma_next(vma)) {
- abi_ulong addr;
- abi_ulong end;
+ size_t size = vma_dump_size(vma);
- end = vma->vma_start + vma_dump_size(vma);
-
- for (addr = vma->vma_start; addr < end;
- addr += TARGET_PAGE_SIZE) {
- char page[TARGET_PAGE_SIZE];
- int error;
-
- /*
- * Read in page from target process memory and
- * write it to coredump file.
- */
- error = copy_from_user(page, addr, sizeof (page));
- if (error != 0) {
- (void) fprintf(stderr, "unable to dump " TARGET_ABI_FMT_lx "\n",
- addr);
- errno = -error;
- goto out;
- }
- if (dump_write(fd, page, TARGET_PAGE_SIZE) < 0)
- goto out;
+ if (size && dump_write(fd, g2h_untagged(vma->vma_start), size) < 0) {
+ goto out;
}
}
errno = 0;