summaryrefslogtreecommitdiff
path: root/sys/arm
diff options
context:
space:
mode:
authorD Scott Phillips <scottph@FreeBSD.org>2020-09-21 22:20:37 +0000
committerD Scott Phillips <scottph@FreeBSD.org>2020-09-21 22:20:37 +0000
commitab041f713aeccdf23b4805ffb71815c8d4aa9c88 (patch)
tree5eac5e6ee8c19209a3b421f8f4377eb19f1489c0 /sys/arm
parenta9cf0eebb37c0ad5c3811e5e40d6730916a20767 (diff)
Notes
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/arm/minidump_machdep.c88
-rw-r--r--sys/arm/include/md_var.h4
-rw-r--r--sys/arm/include/vmparam.h5
3 files changed, 28 insertions, 69 deletions
diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c
index c8d55118ec74..4d4d565885b7 100644
--- a/sys/arm/arm/minidump_machdep.c
+++ b/sys/arm/arm/minidump_machdep.c
@@ -57,9 +57,6 @@ __FBSDID("$FreeBSD$");
CTASSERT(sizeof(struct kerneldumpheader) == 512);
-uint32_t *vm_page_dump;
-int vm_page_dump_size;
-
static struct kerneldumpheader kdh;
/* Handle chunked writes. */
@@ -67,8 +64,6 @@ static size_t fragsz;
static void *dump_va;
static uint64_t counter, progress;
-CTASSERT(sizeof(*vm_page_dump) == 4);
-
static int
is_dumpable(vm_paddr_t pa)
{
@@ -182,10 +177,9 @@ minidumpsys(struct dumperinfo *di)
struct minidumphdr mdhdr;
uint64_t dumpsize;
uint32_t ptesize;
- uint32_t bits;
uint32_t pa, prev_pa = 0, count = 0;
vm_offset_t va;
- int i, bit, error;
+ int error;
char *addr;
/*
@@ -212,20 +206,13 @@ minidumpsys(struct dumperinfo *di)
/* Calculate dump size. */
dumpsize = ptesize;
dumpsize += round_page(msgbufp->msg_size);
- dumpsize += round_page(vm_page_dump_size);
- for (i = 0; i < vm_page_dump_size / sizeof(*vm_page_dump); i++) {
- bits = vm_page_dump[i];
- while (bits) {
- bit = ffs(bits) - 1;
- pa = (((uint64_t)i * sizeof(*vm_page_dump) * NBBY) +
- bit) * PAGE_SIZE;
- /* Clear out undumpable pages now if needed */
- if (is_dumpable(pa))
- dumpsize += PAGE_SIZE;
- else
- dump_drop_page(pa);
- bits &= ~(1ul << bit);
- }
+ dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages));
+ VM_PAGE_DUMP_FOREACH(pa) {
+ /* Clear out undumpable pages now if needed */
+ if (is_dumpable(pa))
+ dumpsize += PAGE_SIZE;
+ else
+ dump_drop_page(pa);
}
dumpsize += PAGE_SIZE;
@@ -236,7 +223,7 @@ minidumpsys(struct dumperinfo *di)
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
mdhdr.version = MINIDUMP_VERSION;
mdhdr.msgbufsize = msgbufp->msg_size;
- mdhdr.bitmapsize = vm_page_dump_size;
+ mdhdr.bitmapsize = round_page(BITSET_SIZE(vm_page_dump_pages));
mdhdr.ptesize = ptesize;
mdhdr.kernbase = KERNBASE;
mdhdr.arch = __ARM_ARCH;
@@ -270,7 +257,7 @@ minidumpsys(struct dumperinfo *di)
/* Dump bitmap */
error = blk_write(di, (char *)vm_page_dump, 0,
- round_page(vm_page_dump_size));
+ round_page(BITSET_SIZE(vm_page_dump_pages)));
if (error)
goto fail;
@@ -293,28 +280,21 @@ minidumpsys(struct dumperinfo *di)
}
/* Dump memory chunks */
- for (i = 0; i < vm_page_dump_size / sizeof(*vm_page_dump); i++) {
- bits = vm_page_dump[i];
- while (bits) {
- bit = ffs(bits) - 1;
- pa = (((uint64_t)i * sizeof(*vm_page_dump) * NBBY) +
- bit) * PAGE_SIZE;
- if (!count) {
- prev_pa = pa;
+ VM_PAGE_DUMP_FOREACH(pa) {
+ if (!count) {
+ prev_pa = pa;
+ count++;
+ } else {
+ if (pa == (prev_pa + count * PAGE_SIZE))
count++;
- } else {
- if (pa == (prev_pa + count * PAGE_SIZE))
- count++;
- else {
- error = blk_write(di, NULL, prev_pa,
- count * PAGE_SIZE);
- if (error)
- goto fail;
- count = 1;
- prev_pa = pa;
- }
+ else {
+ error = blk_write(di, NULL, prev_pa,
+ count * PAGE_SIZE);
+ if (error)
+ goto fail;
+ count = 1;
+ prev_pa = pa;
}
- bits &= ~(1ul << bit);
}
}
if (count) {
@@ -349,25 +329,3 @@ fail:
printf("\n** DUMP FAILED (ERROR %d) **\n", error);
return (error);
}
-
-void
-dump_add_page(vm_paddr_t pa)
-{
- int idx, bit;
-
- pa >>= PAGE_SHIFT;
- idx = pa >> 5; /* 2^5 = 32 */
- bit = pa & 31;
- atomic_set_int(&vm_page_dump[idx], 1ul << bit);
-}
-
-void
-dump_drop_page(vm_paddr_t pa)
-{
- int idx, bit;
-
- pa >>= PAGE_SHIFT;
- idx = pa >> 5; /* 2^5 = 32 */
- bit = pa & 31;
- atomic_clear_int(&vm_page_dump[idx], 1ul << bit);
-}
diff --git a/sys/arm/include/md_var.h b/sys/arm/include/md_var.h
index 6b58c96c1b8d..eb6e59794622 100644
--- a/sys/arm/include/md_var.h
+++ b/sys/arm/include/md_var.h
@@ -38,8 +38,6 @@
extern long Maxmem;
extern char sigcode[];
extern int szsigcode;
-extern uint32_t *vm_page_dump;
-extern int vm_page_dump_size;
extern u_long elf_hwcap;
extern u_long elf_hwcap2;
extern vm_paddr_t arm_physmem_kernaddr;
@@ -72,8 +70,6 @@ extern enum cpu_class cpu_class;
struct dumperinfo;
extern int busdma_swi_pending;
void busdma_swi(void);
-void dump_add_page(vm_paddr_t);
-void dump_drop_page(vm_paddr_t);
int minidumpsys(struct dumperinfo *);
extern uint32_t initial_fpscr;
diff --git a/sys/arm/include/vmparam.h b/sys/arm/include/vmparam.h
index b9b9163d8af7..28269074d139 100644
--- a/sys/arm/include/vmparam.h
+++ b/sys/arm/include/vmparam.h
@@ -193,4 +193,9 @@ extern vm_offset_t vm_max_kernel_address;
#define DEVMAP_MAX_VADDR ARM_VECTORS_HIGH
+/*
+ * Need a page dump array for minidump.
+ */
+#define MINIDUMP_PAGE_TRACKING 1
+
#endif /* _MACHINE_VMPARAM_H_ */