From nobody Fri Dec 03 14:53:43 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 09F7518C1455; Fri, 3 Dec 2021 14:53:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J5G6c0wM0z51WN; Fri, 3 Dec 2021 14:53:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B51B412F6A; Fri, 3 Dec 2021 14:53:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B3ErhE4081098; Fri, 3 Dec 2021 14:53:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B3Erh8u081097; Fri, 3 Dec 2021 14:53:43 GMT (envelope-from git) Date: Fri, 3 Dec 2021 14:53:43 GMT Message-Id: <202112031453.1B3Erh8u081097@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 233ec6b12b56 - stable/13 - minidump: Use the provided dump bitset List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 233ec6b12b56dcfb589479a82f1e973170f766d7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638543224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9AzBAHVF23FVPvP0YklqZkMpwbU4gHgSfUhsVDWNmMU=; b=vFgZagBfgVlj/r9S+hNeU/h7RWR54pw/uHZfM6qjMNeCTfUvo7bxZghnZC3p+wyfA3Niq+ kfelkehC0UxopcKZDVb/3ai7VMOY3D+CMLGXhBeWPXstKToaRjRPbxuCM5DEA8a5JAkd5/ 4cKwliXERstmpBy/xrpFOUD+E28mY9nE0Z0MMUiwWfZbCgr/+o3qmA+Yheh4En0Sk3fywo 3W9faOrNZ6AxMiShg4QKbrnbEYNi54wQ3DphAIp4qSJowD0wGx090tQRNSi4GwhgmvLPKd etkwC6fY+QqJnx8JTS9CNJdohgSx07btO2lAvf3xhSO0z0i1Mzj/zWdp15eJ5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638543224; a=rsa-sha256; cv=none; b=M151Vs2DuWX4O6HFcUTLTReeav2tK/3k8bhHgw6kBMxSvEhpQNXQ9Jgb/DiHJQHf/MT/Dc 7ySzMT5iazi8AznizJqZdGdUgDZqiASxiD5Q7CmDezLAjACdHWhVxkHr3GLT1CbbLZZCl+ 66EHWG7ECSSS2qGPw7iY1X1SEbhsEUVAMTmhMun2+G7Qf3gzq7vM54iAs4eO54jWS9342J P9ntMf0+VjcVYeg78h44n7PM7IN6J5i1MI+eQNJYQFlxuLHujKBDeY6EJeZKeZnoDmqXrB 3aGTai80vyj3j79PoSfnsTD8/3mTozIjae5iVTXkIuzts9WInNOqtvH6YkTPTA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=233ec6b12b56dcfb589479a82f1e973170f766d7 commit 233ec6b12b56dcfb589479a82f1e973170f766d7 Author: Mitchell Horne AuthorDate: 2021-11-17 15:35:18 +0000 Commit: Mitchell Horne CommitDate: 2021-12-03 14:02:03 +0000 minidump: Use the provided dump bitset When constructing the set of dumpable pages, use the bitset provided by the state argument, rather than assuming vm_page_dump invariably. For normal kernel minidumps this will be a pointer to vm_page_dump, but when dumping the live system it will not. To do this, the functions in vm_dumpset.h are extended to accept the desired bitset as an argument. Note that this provided bitset is assumed to be derived from vm_page_dump, and therefore has the same size. Reviewed by: kib, markj, jhb MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31992 (cherry picked from commit 10fe6f80a6c871ba317ddc2684cecb8f02096943) --- sys/amd64/amd64/minidump_machdep.c | 19 +++++++++++-------- sys/arm/arm/minidump_machdep.c | 10 +++++----- sys/arm64/arm64/minidump_machdep.c | 18 ++++++++++-------- sys/i386/i386/minidump_machdep_base.c | 12 +++++++----- sys/mips/mips/minidump_machdep.c | 13 +++++++------ sys/powerpc/aim/mmu_oea64.c | 10 +++++----- sys/powerpc/include/dump.h | 2 +- sys/powerpc/include/mmuvar.h | 2 +- sys/powerpc/powerpc/minidump_machdep.c | 8 ++++---- sys/powerpc/powerpc/pmap_dispatch.c | 2 +- sys/riscv/riscv/minidump_machdep.c | 12 +++++++----- sys/vm/vm_dumpset.h | 20 ++++++++++++-------- 12 files changed, 71 insertions(+), 57 deletions(-) diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index 8d2bc3bca84a..de8433ae5a05 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -211,7 +211,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) pa = pdpe & PG_PS_FRAME; for (n = 0; n < NPDEPG * NPTEPG; n++) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); pa += PAGE_SIZE; } continue; @@ -229,7 +230,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) pa = pde & PG_PS_FRAME; for (k = 0; k < NPTEPG; k++) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add( + state->dump_bitset, pa); pa += PAGE_SIZE; } continue; @@ -238,7 +240,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) pa = pde & PG_FRAME; /* set bit for this PTE page */ if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, pa); /* and for each valid page in this 2MB block */ pt = (uint64_t *)PHYS_TO_DMAP(pde & PG_FRAME); for (k = 0; k < NPTEPG; k++) { @@ -247,7 +249,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) continue; pa = pte & PG_FRAME; if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } } @@ -258,12 +261,12 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) dumpsize += round_page(mbp->msg_size); dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) { dumpsize += PAGE_SIZE; } else { - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } } dumpsize += PAGE_SIZE; @@ -315,7 +318,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) goto fail; /* Dump bitmap */ - error = blk_write(di, (char *)vm_page_dump, 0, + error = blk_write(di, (char *)state->dump_bitset, 0, round_page(BITSET_SIZE(vm_page_dump_pages))); if (error) goto fail; @@ -373,7 +376,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) } /* Dump memory chunks */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { error = blk_write(di, 0, pa, PAGE_SIZE); if (error) goto fail; diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index 76ce89f895e3..ab3034237d17 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -186,7 +186,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) for (va = KERNBASE; va < kva_end; va += PAGE_SIZE) { pa = pmap_dump_kextract(va, NULL); if (pa != 0 && vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, pa); ptesize += sizeof(pt2_entry_t); } @@ -196,12 +196,12 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) dumpsize += round_page(mbp->msg_size); dumpsize += round_page(nitems(dump_avail) * sizeof(uint64_t)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } dumpsize += PAGE_SIZE; @@ -255,7 +255,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) goto fail; /* Dump bitmap */ - error = blk_write(di, (char *)vm_page_dump, 0, + error = blk_write(di, (char *)state->dump_bitset, 0, round_page(BITSET_SIZE(vm_page_dump_pages))); if (error) goto fail; @@ -279,7 +279,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) } /* Dump memory chunks */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { if (!count) { prev_pa = pa; count++; diff --git a/sys/arm64/arm64/minidump_machdep.c b/sys/arm64/arm64/minidump_machdep.c index 5a935d3c379d..8383d69fc5f8 100644 --- a/sys/arm64/arm64/minidump_machdep.c +++ b/sys/arm64/arm64/minidump_machdep.c @@ -187,14 +187,16 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) for (i = 0; i < Ln_ENTRIES * Ln_ENTRIES; i++, pa += PAGE_SIZE) if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); pmapsize += (Ln_ENTRIES - 1) * PAGE_SIZE; va += L1_SIZE - L2_SIZE; } else if ((l2e & ATTR_DESCR_MASK) == L2_BLOCK) { pa = l2e & ~ATTR_MASK; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } else if ((l2e & ATTR_DESCR_MASK) == L2_TABLE) { for (i = 0; i < Ln_ENTRIES; i++) { @@ -202,9 +204,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) if ((l3e & ATTR_DESCR_MASK) != L3_PAGE) continue; pa = l3e & ~ATTR_MASK; - pa = l3e & ~ATTR_MASK; if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } } @@ -215,11 +217,11 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) dumpsize += round_page(mbp->msg_size); dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } dumpsize += PAGE_SIZE; @@ -270,7 +272,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) goto fail; /* Dump bitmap */ - error = blk_write(di, (char *)vm_page_dump, 0, + error = blk_write(di, (char *)state->dump_bitset, 0, round_page(BITSET_SIZE(vm_page_dump_pages))); if (error) goto fail; @@ -351,7 +353,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) } /* Dump memory chunks */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { error = blk_write(di, 0, pa, PAGE_SIZE); if (error) goto fail; diff --git a/sys/i386/i386/minidump_machdep_base.c b/sys/i386/i386/minidump_machdep_base.c index 196c375bec56..a3f09228fa2d 100644 --- a/sys/i386/i386/minidump_machdep_base.c +++ b/sys/i386/i386/minidump_machdep_base.c @@ -191,7 +191,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) pa = pde & PG_PS_FRAME; for (k = 0; k < NPTEPG; k++) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); pa += PAGE_SIZE; } continue; @@ -204,7 +205,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) if ((pte & PG_V) == PG_V) { pa = pte & PG_FRAME; if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add( + state->dump_bitset, pa); } } } else { @@ -218,12 +220,12 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) dumpsize += round_page(mbp->msg_size); dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (vm_phys_is_dumpable(pa)) { dumpsize += PAGE_SIZE; } else { - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } } dumpsize += PAGE_SIZE; @@ -317,7 +319,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) } /* Dump memory chunks */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { error = blk_write(di, 0, pa, PAGE_SIZE); if (error) goto fail; diff --git a/sys/mips/mips/minidump_machdep.c b/sys/mips/mips/minidump_machdep.c index 49a5ee3f15a7..abe45e999f13 100644 --- a/sys/mips/mips/minidump_machdep.c +++ b/sys/mips/mips/minidump_machdep.c @@ -134,7 +134,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) if (pte_test(&pte[i], PTE_V)) { pa = TLBLO_PTE_TO_PA(pte[i]); if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } } @@ -145,7 +146,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) */ for (pa = 0; pa < phys_avail[0]; pa += PAGE_SIZE) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, pa); } /* Calculate dump size. */ @@ -154,12 +155,12 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) dumpsize += round_page(mbp->msg_size); dumpsize += round_page(nitems(dump_avail) * sizeof(uint64_t)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } dumpsize += PAGE_SIZE; @@ -249,8 +250,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) prev_pte = 0; } - /* Dump memory chunks page by page*/ - VM_PAGE_DUMP_FOREACH(pa) { + /* Dump memory chunks page by page */ + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { dump_va = pmap_kenter_temporary(pa, 0); error = write_buffer(di, dump_va, PAGE_SIZE); if (error) diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index 2f7f6ce29422..41771c3650f3 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -438,7 +438,7 @@ static int moea64_map_user_ptr(pmap_t pm, volatile const void *uaddr, void **kaddr, size_t ulen, size_t *klen); static int moea64_decode_kernel_ptr(vm_offset_t addr, int *is_user, vm_offset_t *decoded_addr); -static size_t moea64_scan_pmap(void); +static size_t moea64_scan_pmap(struct bitset *dump_bitset); static void *moea64_dump_pmap_init(unsigned blkpgs); #ifdef __powerpc64__ static void moea64_page_array_startup(long); @@ -3324,7 +3324,7 @@ moea64_scan_init() #ifdef __powerpc64__ static size_t -moea64_scan_pmap() +moea64_scan_pmap(struct bitset *dump_bitset) { struct pvo_entry *pvo; vm_paddr_t pa, pa_end; @@ -3367,11 +3367,11 @@ moea64_scan_pmap() pa_end = pa + lpsize; for (; pa < pa_end; pa += PAGE_SIZE) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(dump_bitset, pa); } } else { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(dump_bitset, pa); } } PMAP_UNLOCK(kernel_pmap); @@ -3393,7 +3393,7 @@ moea64_dump_pmap_init(unsigned blkpgs) #else static size_t -moea64_scan_pmap() +moea64_scan_pmap(struct bitset *dump_bitset __unused) { return (0); } diff --git a/sys/powerpc/include/dump.h b/sys/powerpc/include/dump.h index 3debbfbe25f9..c45ccd2158de 100644 --- a/sys/powerpc/include/dump.h +++ b/sys/powerpc/include/dump.h @@ -40,7 +40,7 @@ void dumpsys_pa_init(void); void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *); -size_t dumpsys_scan_pmap(void); +size_t dumpsys_scan_pmap(struct bitset *); void *dumpsys_dump_pmap_init(unsigned blkpgs); void *dumpsys_dump_pmap(void *ctx, void *buf, u_long *nbytes); diff --git a/sys/powerpc/include/mmuvar.h b/sys/powerpc/include/mmuvar.h index f94ca56df441..b449064e009f 100644 --- a/sys/powerpc/include/mmuvar.h +++ b/sys/powerpc/include/mmuvar.h @@ -96,7 +96,7 @@ typedef void (*pmap_sync_icache_t)(pmap_t, vm_offset_t, vm_size_t); typedef void (*pmap_dumpsys_map_chunk_t)(vm_paddr_t, size_t, void **); typedef void (*pmap_dumpsys_unmap_chunk_t)(vm_paddr_t, size_t, void *); typedef void (*pmap_dumpsys_pa_init_t)(void); -typedef size_t (*pmap_dumpsys_scan_pmap_t)(void); +typedef size_t (*pmap_dumpsys_scan_pmap_t)(struct bitset *dump_bitset); typedef void *(*pmap_dumpsys_dump_pmap_init_t)(unsigned); typedef void *(*pmap_dumpsys_dump_pmap_t)(void *, void *, u_long *); typedef vm_offset_t (*pmap_quick_enter_page_t)(vm_page_t); diff --git a/sys/powerpc/powerpc/minidump_machdep.c b/sys/powerpc/powerpc/minidump_machdep.c index c7e8d1965b98..396c6487823e 100644 --- a/sys/powerpc/powerpc/minidump_machdep.c +++ b/sys/powerpc/powerpc/minidump_machdep.c @@ -204,7 +204,7 @@ retry: DBG(total = dumptotal = 0;) /* Build set of dumpable pages from kernel pmap */ - pmapsize = dumpsys_scan_pmap(); + pmapsize = dumpsys_scan_pmap(state->dump_bitset); if (pmapsize % PAGE_SIZE != 0) { printf("pmapsize not page aligned: 0x%x\n", pmapsize); return (EINVAL); @@ -217,12 +217,12 @@ retry: dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); dumpsize += pmapsize; - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } dumpsys_pb_init(dumpsize); @@ -289,7 +289,7 @@ retry: dump_total("pmap", pmapsize); /* Dump memory chunks */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { error = blk_write(di, 0, pa, PAGE_SIZE); if (error) goto fail; diff --git a/sys/powerpc/powerpc/pmap_dispatch.c b/sys/powerpc/powerpc/pmap_dispatch.c index 5a47b6d8bf31..a3c227bbde7d 100644 --- a/sys/powerpc/powerpc/pmap_dispatch.c +++ b/sys/powerpc/powerpc/pmap_dispatch.c @@ -188,7 +188,7 @@ DEFINE_PMAP_IFUNC(void, tlbie_all, (void)); DEFINE_DUMPSYS_IFUNC(void, map_chunk, (vm_paddr_t, size_t, void **)); DEFINE_DUMPSYS_IFUNC(void, unmap_chunk, (vm_paddr_t, size_t, void *)); DEFINE_DUMPSYS_IFUNC(void, pa_init, (void)); -DEFINE_DUMPSYS_IFUNC(size_t, scan_pmap, (void)); +DEFINE_DUMPSYS_IFUNC(size_t, scan_pmap, (struct bitset *)); DEFINE_DUMPSYS_IFUNC(void *, dump_pmap_init, (unsigned)); DEFINE_DUMPSYS_IFUNC(void *, dump_pmap, (void *, void *, u_long *)); diff --git a/sys/riscv/riscv/minidump_machdep.c b/sys/riscv/riscv/minidump_machdep.c index 814c2dd00697..ee6faaa6680f 100644 --- a/sys/riscv/riscv/minidump_machdep.c +++ b/sys/riscv/riscv/minidump_machdep.c @@ -197,7 +197,8 @@ retry: pa = (l2e >> PTE_PPN1_S) << L2_SHIFT; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { if (vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } else { for (i = 0; i < Ln_ENTRIES; i++) { @@ -206,7 +207,8 @@ retry: continue; pa = (l3e >> PTE_PPN0_S) * PAGE_SIZE; if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) - dump_add_page(pa); + vm_page_dump_add(state->dump_bitset, + pa); } } } @@ -217,12 +219,12 @@ retry: dumpsize += round_page(mbp->msg_size); dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { /* Clear out undumpable pages now if needed */ if (PHYS_IN_DMAP(pa) && vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else - dump_drop_page(pa); + vm_page_dump_drop(state->dump_bitset, pa); } dumpsize += PAGE_SIZE; @@ -327,7 +329,7 @@ retry: /* Dump memory chunks */ /* XXX cluster it up and use blk_dump() */ - VM_PAGE_DUMP_FOREACH(pa) { + VM_PAGE_DUMP_FOREACH(state->dump_bitset, pa) { error = blk_write(di, 0, pa, PAGE_SIZE); if (error) goto fail; diff --git a/sys/vm/vm_dumpset.h b/sys/vm/vm_dumpset.h index 6be417344263..f9ba6b2429c5 100644 --- a/sys/vm/vm_dumpset.h +++ b/sys/vm/vm_dumpset.h @@ -37,8 +37,12 @@ extern struct bitset *vm_page_dump; extern long vm_page_dump_pages; extern vm_paddr_t dump_avail[PHYS_AVAIL_COUNT]; +/* For the common case: add/remove a page from the minidump bitset. */ +#define dump_add_page(pa) vm_page_dump_add(vm_page_dump, pa) +#define dump_drop_page(pa) vm_page_dump_drop(vm_page_dump, pa) + static inline void -dump_add_page(vm_paddr_t pa) +vm_page_dump_add(struct bitset *bitset, vm_paddr_t pa) { vm_pindex_t adj; int i; @@ -48,7 +52,7 @@ dump_add_page(vm_paddr_t pa) if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) { BIT_SET_ATOMIC(vm_page_dump_pages, (pa >> PAGE_SHIFT) - (dump_avail[i] >> PAGE_SHIFT) + - adj, vm_page_dump); + adj, bitset); return; } adj += howmany(dump_avail[i + 1], PAGE_SIZE) - @@ -57,7 +61,7 @@ dump_add_page(vm_paddr_t pa) } static inline void -dump_drop_page(vm_paddr_t pa) +vm_page_dump_drop(struct bitset *bitset, vm_paddr_t pa) { vm_pindex_t adj; int i; @@ -67,7 +71,7 @@ dump_drop_page(vm_paddr_t pa) if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) { BIT_CLR_ATOMIC(vm_page_dump_pages, (pa >> PAGE_SHIFT) - (dump_avail[i] >> PAGE_SHIFT) + - adj, vm_page_dump); + adj, bitset); return; } adj += howmany(dump_avail[i + 1], PAGE_SIZE) - @@ -91,9 +95,9 @@ vm_page_dump_index_to_pa(int bit) return ((vm_paddr_t)NULL); } -#define VM_PAGE_DUMP_FOREACH(pa) \ - for (vm_pindex_t __b = BIT_FFS(vm_page_dump_pages, vm_page_dump); \ - (pa) = vm_page_dump_index_to_pa(__b - 1), __b != 0; \ - __b = BIT_FFS_AT(vm_page_dump_pages, vm_page_dump, __b)) +#define VM_PAGE_DUMP_FOREACH(bitset, pa) \ + for (vm_pindex_t __b = BIT_FFS(vm_page_dump_pages, bitset); \ + (pa) = vm_page_dump_index_to_pa(__b - 1), __b != 0; \ + __b = BIT_FFS_AT(vm_page_dump_pages, bitset, __b)) #endif /* _SYS_DUMPSET_H_ */