Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_shutdown.c
Show First 20 Lines • Show All 874 Lines • ▼ Show 20 Lines | printf("Attempt to write outside dump device boundaries.\n" | ||||
"offset(%jd), mediaoffset(%jd), length(%ju), mediasize(%jd).\n", | "offset(%jd), mediaoffset(%jd), length(%ju), mediasize(%jd).\n", | ||||
(intmax_t)offset, (intmax_t)di->mediaoffset, | (intmax_t)offset, (intmax_t)di->mediaoffset, | ||||
(uintmax_t)length, (intmax_t)di->mediasize); | (uintmax_t)length, (intmax_t)di->mediasize); | ||||
return (ENOSPC); | return (ENOSPC); | ||||
} | } | ||||
return (di->dumper(di->priv, virtual, physical, offset, length)); | return (di->dumper(di->priv, virtual, physical, offset, length)); | ||||
} | } | ||||
/* Call dumper with bounds checking. */ | |||||
int | |||||
dump_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, | |||||
off_t offset, size_t length, size_t *size) | |||||
{ | |||||
int ret; | |||||
char *temp; | |||||
char buf[4096]; | |||||
cem: I don't like having a large buf like this on the kernel stack, especially during panic/dump. | |||||
*size = ((length - 1) / di->blocksize + 1) * di->blocksize; | |||||
cemAuthorUnsubmitted Not Done Inline Actions*size = roundup(length, di->blocksize); cem: `*size = roundup(length, di->blocksize);` | |||||
if (*size == length) | |||||
temp = virtual; | |||||
else { | |||||
if (length > sizeof(buf)) | |||||
return (ENOMEM); | |||||
temp = buf; | |||||
bzero(temp, sizeof(buf)); | |||||
cemAuthorUnsubmitted Done Inline ActionsAs a minor optimization, we only need to zero (temp + length, sizeof(buf) - length). cem: As a minor optimization, we only need to zero `(temp + length, sizeof(buf) - length)`. | |||||
bcopy(virtual, temp, length); | |||||
} | |||||
ret = dump_write(di, temp, physical, offset, *size); | |||||
return (ret); | |||||
} | |||||
void | void | ||||
mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, | mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver, | ||||
uint64_t dumplen, uint32_t blksz) | uint64_t dumplen, uint32_t blksz) | ||||
{ | { | ||||
bzero(kdh, sizeof(*kdh)); | bzero(kdh, sizeof(*kdh)); | ||||
strlcpy(kdh->magic, magic, sizeof(kdh->magic)); | strlcpy(kdh->magic, magic, sizeof(kdh->magic)); | ||||
strlcpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture)); | strlcpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture)); | ||||
Show All 11 Lines |
I don't like having a large buf like this on the kernel stack, especially during panic/dump. For now, adding static would be fine. We can switch to using malloc memory, described above, in a later revision (if we care).