summaryrefslogtreecommitdiffstats
path: root/sys/arm
diff options
context:
space:
mode:
authorandrew <andrew@FreeBSD.org>2014-10-29 16:36:08 +0000
committerandrew <andrew@FreeBSD.org>2014-10-29 16:36:08 +0000
commitce556e32576b3ac1f093f651cb863dad68e1729a (patch)
tree40f1de597ecacf5e4cfd110ddb38f797061912c0 /sys/arm
parentf0629d0f088e0764c7bc26a56baca5b4ef8acf1d (diff)
downloadFreeBSD-src-ce556e32576b3ac1f093f651cb863dad68e1729a.zip
FreeBSD-src-ce556e32576b3ac1f093f651cb863dad68e1729a.tar.gz
MFC r273284:
Allow libkvm to get the kernel va to pa delta without the need for physaddr. This should allow for a kernel where PHYSADDR and KERNPHYSADDR are both undefined. For now libkvm will use the old method of reading physaddr and kernaddr to allow it to work with old kernels. This could be removed in the future when enough time has passed.
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/arm/dump_machdep.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/arm/arm/dump_machdep.c b/sys/arm/arm/dump_machdep.c
index f37346c..b0e4b1b 100644
--- a/sys/arm/arm/dump_machdep.c
+++ b/sys/arm/arm/dump_machdep.c
@@ -246,6 +246,29 @@ cb_dumphdr(struct md_pa *mdp, int seqnr, void *arg)
return (error);
}
+/*
+ * Add a header to be used by libkvm to get the va to pa delta
+ */
+static int
+dump_os_header(struct dumperinfo *di)
+{
+ Elf_Phdr phdr;
+ int error;
+
+ bzero(&phdr, sizeof(phdr));
+ phdr.p_type = PT_DUMP_DELTA;
+ phdr.p_flags = PF_R; /* XXX */
+ phdr.p_offset = 0;
+ phdr.p_vaddr = KERNVIRTADDR;
+ phdr.p_paddr = pmap_kextract(KERNVIRTADDR);
+ phdr.p_filesz = 0;
+ phdr.p_memsz = 0;
+ phdr.p_align = PAGE_SIZE;
+
+ error = buf_write(di, (char*)&phdr, sizeof(phdr));
+ return (error);
+}
+
static int
cb_size(struct md_pa *mdp, int seqnr, void *arg)
{
@@ -311,7 +334,7 @@ dumpsys(struct dumperinfo *di)
/* Calculate dump size. */
dumpsize = 0L;
- ehdr.e_phnum = foreach_chunk(cb_size, &dumpsize);
+ ehdr.e_phnum = foreach_chunk(cb_size, &dumpsize) + 1;
hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
fileofs = MD_ALIGN(hdrsz);
dumpsize += fileofs;
@@ -328,7 +351,7 @@ dumpsys(struct dumperinfo *di)
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION, dumpsize, di->blocksize);
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
- ehdr.e_phnum);
+ ehdr.e_phnum - 1);
/* Dump leader */
error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh));
@@ -343,6 +366,8 @@ dumpsys(struct dumperinfo *di)
/* Dump program headers */
error = foreach_chunk(cb_dumphdr, di);
+ if (error >= 0)
+ error = dump_os_header(di);
if (error < 0)
goto fail;
buf_flush(di);
OpenPOWER on IntegriCloud