minidump: Use provided msgbuf pointer
Don't assume we are dumping the global message buffer, but use the one provided by the state argument. While here, drop superfluous cast to char *. Reviewed by: markj, jhb MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31991
This commit is contained in:
parent
681bd71047
commit
1d2d1418b4
@ -171,6 +171,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
int ii, j, k, n;
|
||||
int retry_count;
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
|
||||
retry_count = 0;
|
||||
retry:
|
||||
@ -252,8 +253,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size. */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = pmapsize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -273,7 +275,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.pmapsize = pmapsize;
|
||||
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS;
|
||||
@ -299,7 +301,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0, round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, mbp->msg_ptr, 0, round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
@ -156,6 +156,7 @@ int
|
||||
cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
{
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
uint64_t dumpsize, *dump_avail_buf;
|
||||
uint32_t ptesize;
|
||||
uint32_t pa, prev_pa = 0, count = 0;
|
||||
@ -190,8 +191,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size. */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = ptesize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -209,7 +211,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.ptesize = ptesize;
|
||||
mdhdr.kernbase = KERNBASE;
|
||||
@ -235,8 +237,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0,
|
||||
round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, mbp->msg_ptr, 0, round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
@ -151,6 +151,7 @@ int
|
||||
cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
{
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
pd_entry_t *l0, *l1, l1e, *l2, l2e;
|
||||
pt_entry_t *l3, l3e;
|
||||
vm_offset_t va, kva_end;
|
||||
@ -209,8 +210,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size. */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = pmapsize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -227,7 +229,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.pmapsize = pmapsize;
|
||||
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS;
|
||||
@ -254,8 +256,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0,
|
||||
round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, mbp->msg_ptr, 0, round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
@ -164,6 +164,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
pt_entry_t *pt, pte;
|
||||
int j, k;
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
|
||||
/* Snapshot the KVA upper bound in case it grows. */
|
||||
kva_end = kernel_vm_end;
|
||||
@ -212,8 +213,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size. */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = ptesize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -232,7 +234,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.ptesize = ptesize;
|
||||
mdhdr.kernbase = KERNBASE;
|
||||
@ -257,7 +259,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0, round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, (char *)mbp->msg_ptr, 0,
|
||||
round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
@ -109,6 +109,7 @@ int
|
||||
cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
{
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
uint64_t *dump_avail_buf;
|
||||
uint32_t ptesize;
|
||||
vm_paddr_t pa;
|
||||
@ -148,8 +149,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size. */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = ptesize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -167,7 +169,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.ptesize = ptesize;
|
||||
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS;
|
||||
@ -191,8 +193,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = write_buffer(di, (char *)msgbufp->msg_ptr,
|
||||
round_page(msgbufp->msg_size));
|
||||
error = write_buffer(di, mbp->msg_ptr, round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
@ -195,6 +195,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
int error, retry_count;
|
||||
uint32_t pmapsize;
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
|
||||
retry_count = 0;
|
||||
retry:
|
||||
@ -210,8 +211,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = PAGE_SIZE; /* header */
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
dumpsize += round_page(mbp->msg_size);
|
||||
dumpsize += round_page(sizeof(dump_avail));
|
||||
dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
dumpsize += pmapsize;
|
||||
@ -229,7 +231,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
strncpy(mdhdr.mmu_name, pmap_mmu_name(), sizeof(mdhdr.mmu_name) - 1);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.pmapsize = pmapsize;
|
||||
mdhdr.kernbase = VM_MIN_KERNEL_ADDRESS;
|
||||
@ -260,9 +262,8 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
dump_total("header", PAGE_SIZE);
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0,
|
||||
round_page(msgbufp->msg_size));
|
||||
dump_total("msgbuf", round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, mbp->msg_ptr, 0, round_page(mbp->msg_size));
|
||||
dump_total("msgbuf", round_page(mbp->msg_size));
|
||||
|
||||
/* Dump dump_avail */
|
||||
_Static_assert(sizeof(dump_avail) <= sizeof(pgbuf),
|
||||
|
@ -158,6 +158,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
pd_entry_t *l1, *l2, l2e;
|
||||
pt_entry_t *l3, l3e;
|
||||
struct minidumphdr mdhdr;
|
||||
struct msgbuf *mbp;
|
||||
uint32_t pmapsize;
|
||||
vm_offset_t va, kva_max;
|
||||
vm_paddr_t pa;
|
||||
@ -211,8 +212,9 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
}
|
||||
|
||||
/* Calculate dump size */
|
||||
mbp = state->msgbufp;
|
||||
dumpsize = pmapsize;
|
||||
dumpsize += round_page(msgbufp->msg_size);
|
||||
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) {
|
||||
@ -230,7 +232,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
bzero(&mdhdr, sizeof(mdhdr));
|
||||
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
|
||||
mdhdr.version = MINIDUMP_VERSION;
|
||||
mdhdr.msgbufsize = msgbufp->msg_size;
|
||||
mdhdr.msgbufsize = mbp->msg_size;
|
||||
mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
|
||||
mdhdr.pmapsize = pmapsize;
|
||||
mdhdr.kernbase = KERNBASE;
|
||||
@ -257,8 +259,7 @@ cpu_minidumpsys(struct dumperinfo *di, const struct minidumpstate *state)
|
||||
goto fail;
|
||||
|
||||
/* Dump msgbuf up front */
|
||||
error = blk_write(di, (char *)msgbufp->msg_ptr, 0,
|
||||
round_page(msgbufp->msg_size));
|
||||
error = blk_write(di, mbp->msg_ptr, 0, round_page(mbp->msg_size));
|
||||
if (error)
|
||||
goto fail;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user