From nobody Fri Dec 03 14:53:40 2021 X-Original-To: dev-commits-src-all@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 1050418C143A; Fri, 3 Dec 2021 14:53:41 +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 4J5G6X4JZmz51sK; Fri, 3 Dec 2021 14:53:40 +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 7334112B67; Fri, 3 Dec 2021 14:53:40 +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 1B3Ere2P081024; Fri, 3 Dec 2021 14:53:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B3Ereew081023; Fri, 3 Dec 2021 14:53:40 GMT (envelope-from git) Date: Fri, 3 Dec 2021 14:53:40 GMT Message-Id: <202112031453.1B3Ereew081023@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: eb2ea57ef1f2 - stable/13 - minidump: Parameterize minidumpsys() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: eb2ea57ef1f2f1a36953aa0aaa7c7522311a81f8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638543220; 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=JFp3UKgUiMZQ+9/MK4zUPIBZCdU2i40JcJ1MNPlfEO0=; b=T/fGBd2XxTeeaW5i9YkLdzk7vb6jHt8HwFcC/EzIo+vzebbCHhfUtlUB7lZi07MAXr0Kvn 0SrYQzi8p8IK83W1RRrjiRyidhwNY5ARctmsW55dG/pR16mjLLzirNG7XGtsg7ETBA+eNW tBVDsmmrcXXJKicbllrXhynfBefjFWYtKbHH37CDrPKjPJDP6Zjdhh/ggIFSRgwZOaL3Wu gO2lSFP7zBt9DWw1ndHk1CS5TFiCgJub/3QaVUUW6d2kSiazVJT+3/XWRVOHCy6/SGCF24 Gqg2ml6lA5fbLFuFYiKf3Egr0v9o+r4I3dXkwKmN5KyppKOGzjtJ/g5nl5f2eg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638543220; a=rsa-sha256; cv=none; b=vpqQgLQaqPfYqSY/wy4IhnhyUv308G7SETBs/WYuL0eYJWrqV+ZG2vWZ5iFQ/OD4P6WzPJ YtFvOInjmu+z6fM0etaBEJM4hlfvMqPfSe/4U1mJotgt/7sfEGJ91XDLXN+GybX3i0T1fd jRx12C9twp+3fcOp5mTy7mjQ4ufNb0j1j+JA0sSzYgJgC7pNdIdJqEaW3sGWUvoScVBpkr Uoz2MEXqT6K/JPDh5QdRLavjKHRC2/NrLroqyY4F+c6/lg+ToCWjKOw+Vej1O17VDnLtA8 DEyvE93fVmZpemQdzLQx4SmB+Fek7QkRTo5obx33y1ty6YVvb/UiuLEt2PnSiQ== 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=eb2ea57ef1f2f1a36953aa0aaa7c7522311a81f8 commit eb2ea57ef1f2f1a36953aa0aaa7c7522311a81f8 Author: Mitchell Horne AuthorDate: 2021-11-17 15:26:59 +0000 Commit: Mitchell Horne CommitDate: 2021-12-03 14:02:03 +0000 minidump: Parameterize minidumpsys() The minidump code is written assuming that certain global state will not change, and rightly so, since it executes from a kernel debugger context. In order to support taking minidumps of a live system, we should allow copies of relevant global state that is likely to change to be passed as parameters to the minidumpsys() function. This patch does the work of parameterizing this function, by adding a struct minidumpstate argument. For now, this struct allows for copies of the kernel message buffer, and the bitset that tracks which pages should be dumped (vm_page_dump). Follow-up changes will actually make use of these arguments. Notably, dump_avail[] does not need a snapshot, since it is not expected to change after system initialization. The existing minidumpsys() definitions are renamed, and a thin MI wrapper is added to kern_dump.c, which handles the construction of the state struct. Thus, calling minidumpsys() remains as simple as before. Reviewed by: kib, markj, jhb Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31989 (cherry picked from commit 1adebe3cd6b1eb0973969e2c4c5d41f174caa304) --- sys/amd64/amd64/minidump_machdep.c | 2 +- sys/arm/arm/minidump_machdep.c | 2 +- sys/arm/include/md_var.h | 3 ++- sys/arm64/arm64/minidump_machdep.c | 2 +- sys/arm64/include/md_var.h | 3 ++- sys/i386/i386/minidump_machdep.c | 5 +++-- sys/i386/i386/minidump_machdep_base.c | 10 +++++----- sys/i386/include/md_var.h | 4 ++-- sys/kern/kern_dump.c | 22 +++++++++++++++++++++- sys/mips/include/md_var.h | 3 ++- sys/mips/mips/minidump_machdep.c | 2 +- sys/powerpc/include/md_var.h | 3 ++- sys/powerpc/powerpc/minidump_machdep.c | 2 +- sys/riscv/include/md_var.h | 3 ++- sys/riscv/riscv/minidump_machdep.c | 2 +- sys/sys/kerneldump.h | 6 ++++++ sys/x86/include/x86_var.h | 3 ++- 17 files changed, 55 insertions(+), 22 deletions(-) diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index d6bdbfb7e633..68333088ed5a 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -160,7 +160,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) static pd_entry_t fakepd[NPDEPG]; int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { uint32_t pmapsize; vm_offset_t va; diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index 83c607c839ee..6d199d1894c3 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -153,7 +153,7 @@ static char dumpbuf[PAGE_SIZE] __aligned(sizeof(uint64_t)); CTASSERT(sizeof(dumpbuf) % sizeof(pt2_entry_t) == 0); int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { struct minidumphdr mdhdr; uint64_t dumpsize, *dump_avail_buf; diff --git a/sys/arm/include/md_var.h b/sys/arm/include/md_var.h index d60992f104e1..1864d30074c6 100644 --- a/sys/arm/include/md_var.h +++ b/sys/arm/include/md_var.h @@ -62,9 +62,10 @@ enum cpu_class { extern enum cpu_class cpu_class; struct dumperinfo; +struct minidumpstate; extern int busdma_swi_pending; void busdma_swi(void); -int minidumpsys(struct dumperinfo *); +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); extern uint32_t initial_fpscr; diff --git a/sys/arm64/arm64/minidump_machdep.c b/sys/arm64/arm64/minidump_machdep.c index 92b172260ae0..7558e612153c 100644 --- a/sys/arm64/arm64/minidump_machdep.c +++ b/sys/arm64/arm64/minidump_machdep.c @@ -147,7 +147,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) } int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { struct minidumphdr mdhdr; pd_entry_t *l0, *l1, *l2; diff --git a/sys/arm64/include/md_var.h b/sys/arm64/include/md_var.h index beaea0f8e719..0745a25cf2a6 100644 --- a/sys/arm64/include/md_var.h +++ b/sys/arm64/include/md_var.h @@ -44,10 +44,11 @@ extern u_long elf32_hwcap2; #endif struct dumperinfo; +struct minidumpstate; extern int busdma_swi_pending; void busdma_swi(void); -int minidumpsys(struct dumperinfo *); +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); void generic_bs_fault(void) __asm(__STRING(generic_bs_fault)); void generic_bs_peek_1(void) __asm(__STRING(generic_bs_peek_1)); void generic_bs_peek_2(void) __asm(__STRING(generic_bs_peek_2)); diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c index d2a7999cb2c3..6d3585795208 100644 --- a/sys/i386/i386/minidump_machdep.c +++ b/sys/i386/i386/minidump_machdep.c @@ -50,8 +50,9 @@ __FBSDID("$FreeBSD$"); CTASSERT(sizeof(struct kerneldumpheader) == 512); int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { - return (pae_mode ? minidumpsys_pae(di) : minidumpsys_nopae(di)); + return (pae_mode ? cpu_minidumpsys_pae(di, state) : + cpu_minidumpsys_nopae(di, state)); } diff --git a/sys/i386/i386/minidump_machdep_base.c b/sys/i386/i386/minidump_machdep_base.c index e3e211bf9a46..8984ab4dd083 100644 --- a/sys/i386/i386/minidump_machdep_base.c +++ b/sys/i386/i386/minidump_machdep_base.c @@ -145,15 +145,15 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) static pt_entry_t fakept[NPTEPG]; #ifdef PMAP_PAE_COMP -#define minidumpsys minidumpsys_pae -#define IdlePTD IdlePTD_pae +#define cpu_minidumpsys cpu_minidumpsys_pae +#define IdlePTD IdlePTD_pae #else -#define minidumpsys minidumpsys_nopae -#define IdlePTD IdlePTD_nopae +#define cpu_minidumpsys cpu_minidumpsys_nopae +#define IdlePTD IdlePTD_nopae #endif int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { uint64_t dumpsize; uint32_t ptesize; diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index 95f4907a61d0..88b036a9cc24 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -68,8 +68,8 @@ void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault)); void fill_based_sd(struct segment_descriptor *sdp, uint32_t base); void i686_pagezero(void *addr); void sse2_pagezero(void *addr); -int minidumpsys_nopae(struct dumperinfo *); -int minidumpsys_pae(struct dumperinfo *); +int cpu_minidumpsys_nopae(struct dumperinfo *, const struct minidumpstate *); +int cpu_minidumpsys_pae(struct dumperinfo *, const struct minidumpstate *); void init_AMD_Elan_sc520(void); vm_paddr_t kvtop(void *addr); void panicifcpuunsupported(void); diff --git a/sys/kern/kern_dump.c b/sys/kern/kern_dump.c index 4c592f446f45..278863e19a65 100644 --- a/sys/kern/kern_dump.c +++ b/sys/kern/kern_dump.c @@ -32,15 +32,18 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include +#include +#include #include + #include #include #include #include #include #include + #include #include #include @@ -386,6 +389,8 @@ dumpsys_generic(struct dumperinfo *di) return (error); } +#if MINIDUMP_PAGE_TRACKING == 1 + /* Minidump progress bar */ static struct { const int min_per; @@ -454,3 +459,18 @@ dumpsys_pb_progress(size_t delta) break; } } + +int +minidumpsys(struct dumperinfo *di) +{ + struct minidumpstate state; + int error; + + state.msgbufp = msgbufp; + state.dump_bitset = vm_page_dump; + + error = cpu_minidumpsys(di, &state); + + return (error); +} +#endif /* MINIDUMP_PAGE_TRACKING == 1 */ diff --git a/sys/mips/include/md_var.h b/sys/mips/include/md_var.h index 8462b1beb22e..3d8981456654 100644 --- a/sys/mips/include/md_var.h +++ b/sys/mips/include/md_var.h @@ -82,6 +82,7 @@ extern int busdma_swi_pending; void busdma_swi(void); struct dumperinfo; -int minidumpsys(struct dumperinfo *); +struct minidumpstate; +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/mips/mips/minidump_machdep.c b/sys/mips/mips/minidump_machdep.c index 691e1208e684..06a63834cab8 100644 --- a/sys/mips/mips/minidump_machdep.c +++ b/sys/mips/mips/minidump_machdep.c @@ -106,7 +106,7 @@ write_buffer(struct dumperinfo *di, char *ptr, size_t sz) } int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { struct minidumphdr mdhdr; uint64_t *dump_avail_buf; diff --git a/sys/powerpc/include/md_var.h b/sys/powerpc/include/md_var.h index ab5f9e33a5bb..6e74000340b9 100644 --- a/sys/powerpc/include/md_var.h +++ b/sys/powerpc/include/md_var.h @@ -43,7 +43,8 @@ extern char sigcode64[], sigcode64_elfv2[]; extern int szsigcode64, szsigcode64_elfv2; struct dumperinfo; -int minidumpsys(struct dumperinfo *); +struct minidumpstate; +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); #endif extern long Maxmem; diff --git a/sys/powerpc/powerpc/minidump_machdep.c b/sys/powerpc/powerpc/minidump_machdep.c index 908e6f7a3fc7..e6a0f3918883 100644 --- a/sys/powerpc/powerpc/minidump_machdep.c +++ b/sys/powerpc/powerpc/minidump_machdep.c @@ -189,7 +189,7 @@ dump_pmap(struct dumperinfo *di) } int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { vm_paddr_t pa; int error, retry_count; diff --git a/sys/riscv/include/md_var.h b/sys/riscv/include/md_var.h index b36a44d7d023..56007cd0c155 100644 --- a/sys/riscv/include/md_var.h +++ b/sys/riscv/include/md_var.h @@ -42,8 +42,9 @@ extern register_t marchid; extern register_t mimpid; struct dumperinfo; +struct minidumpstate; void busdma_swi(void); -int minidumpsys(struct dumperinfo *); +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); #endif /* !_MACHINE_MD_VAR_H_ */ diff --git a/sys/riscv/riscv/minidump_machdep.c b/sys/riscv/riscv/minidump_machdep.c index 992ab097e1b3..d71dde8f6da5 100644 --- a/sys/riscv/riscv/minidump_machdep.c +++ b/sys/riscv/riscv/minidump_machdep.c @@ -153,7 +153,7 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) } int -minidumpsys(struct dumperinfo *di) +cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state) { pd_entry_t *l1, *l2; pt_entry_t *l3; diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h index c4ce9d2f13ec..54662d9cff39 100644 --- a/sys/sys/kerneldump.h +++ b/sys/sys/kerneldump.h @@ -135,6 +135,12 @@ struct dump_pa { vm_paddr_t pa_size; }; +struct minidumpstate { + struct msgbuf *msgbufp; + struct bitset *dump_bitset; +}; + +int minidumpsys(struct dumperinfo *); int dumpsys_generic(struct dumperinfo *); void dumpsys_map_chunk(vm_paddr_t, size_t, void **); diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 55227cf9e65a..f6ebf1954a00 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -103,6 +103,7 @@ struct fpreg; struct dbreg; struct dumperinfo; struct trapframe; +struct minidumpstate; /* * The interface type of the interrupt handler entry point cannot be @@ -150,7 +151,7 @@ void pagecopy(void *from, void *to); void printcpuinfo(void); int pti_get_default(void); int user_dbreg_trap(register_t dr6); -int minidumpsys(struct dumperinfo *); +int cpu_minidumpsys(struct dumperinfo *, const struct minidumpstate *); struct pcb *get_pcb_td(struct thread *td); uint64_t rdtsc_ordered(void);