summaryrefslogtreecommitdiffstats
path: root/sys/ia64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-04-06 05:56:33 +0000
committermarcel <marcel@FreeBSD.org>2002-04-06 05:56:33 +0000
commite51cd0ad8f9101be501b273db0b12a9b5b138609 (patch)
tree54d6219666ef1ad12e4b2878de7d62a69f64dee2 /sys/ia64
parent4f01203b03788c761d4efa8790faa4bc426c7d9a (diff)
downloadFreeBSD-src-e51cd0ad8f9101be501b273db0b12a9b5b138609.zip
FreeBSD-src-e51cd0ad8f9101be501b273db0b12a9b5b138609.tar.gz
Fix a braino in the alignment of the segment contents after dumping
the program headers. As a result of this, dumplo was advanced too much causing the end of the dump and most notably the trailing dump header to be written beyond the end of the the dump medium.
Diffstat (limited to 'sys/ia64')
-rw-r--r--sys/ia64/ia64/dump_machdep.c13
-rw-r--r--sys/ia64/ia64/ia64dump.c13
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/ia64/ia64/dump_machdep.c b/sys/ia64/ia64/dump_machdep.c
index a86754e..fc6532e 100644
--- a/sys/ia64/ia64/dump_machdep.c
+++ b/sys/ia64/ia64/dump_machdep.c
@@ -41,6 +41,7 @@
CTASSERT(sizeof(struct kerneldumpheader) == 512);
#define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK)
+#define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*);
@@ -203,6 +204,7 @@ dumpsys(struct dumperinfo *di)
{
Elf64_Ehdr ehdr;
uint64_t dumpsize;
+ off_t hdrgap;
size_t hdrsz;
int error;
@@ -233,6 +235,7 @@ dumpsys(struct dumperinfo *di)
hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
fileofs = MD_ALIGN(hdrsz);
dumpsize += fileofs;
+ hdrgap = fileofs - DEV_ALIGN(hdrsz);
/* Determine dump offset on device. */
dumplo = di->mediaoffset + di->mediasize - dumpsize;
@@ -258,7 +261,15 @@ dumpsys(struct dumperinfo *di)
if (error < 0)
goto fail;
buf_flush(di);
- dumplo += MD_ALIGN(hdrsz);
+
+ /*
+ * All headers are written using blocked I/O, so we know the
+ * current offset is (still) block aligned. Skip the alignement
+ * in the file to have the segment contents aligned at page
+ * boundary. We cannot use MD_ALIGN on dumplo, because we don't
+ * care and may very well be unaligned within the dump device.
+ */
+ dumplo += hdrgap;
/* Dump region data (updates dumplo) */
error = foreach_region(cb_dumpdata, di);
diff --git a/sys/ia64/ia64/ia64dump.c b/sys/ia64/ia64/ia64dump.c
index a86754e..fc6532e 100644
--- a/sys/ia64/ia64/ia64dump.c
+++ b/sys/ia64/ia64/ia64dump.c
@@ -41,6 +41,7 @@
CTASSERT(sizeof(struct kerneldumpheader) == 512);
#define MD_ALIGN(x) (((off_t)(x) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK)
+#define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
typedef int callback_t(EFI_MEMORY_DESCRIPTOR*, int, void*);
@@ -203,6 +204,7 @@ dumpsys(struct dumperinfo *di)
{
Elf64_Ehdr ehdr;
uint64_t dumpsize;
+ off_t hdrgap;
size_t hdrsz;
int error;
@@ -233,6 +235,7 @@ dumpsys(struct dumperinfo *di)
hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
fileofs = MD_ALIGN(hdrsz);
dumpsize += fileofs;
+ hdrgap = fileofs - DEV_ALIGN(hdrsz);
/* Determine dump offset on device. */
dumplo = di->mediaoffset + di->mediasize - dumpsize;
@@ -258,7 +261,15 @@ dumpsys(struct dumperinfo *di)
if (error < 0)
goto fail;
buf_flush(di);
- dumplo += MD_ALIGN(hdrsz);
+
+ /*
+ * All headers are written using blocked I/O, so we know the
+ * current offset is (still) block aligned. Skip the alignement
+ * in the file to have the segment contents aligned at page
+ * boundary. We cannot use MD_ALIGN on dumplo, because we don't
+ * care and may very well be unaligned within the dump device.
+ */
+ dumplo += hdrgap;
/* Dump region data (updates dumplo) */
error = foreach_region(cb_dumpdata, di);
OpenPOWER on IntegriCloud