ktr: correctly handle possible wrap-around in the boot buffer

Older entries should be 'before' newer entries in the new buffer too
and there should be no zero-filled gap between them.

Pointed out by:	jhb
MFC after:	3 days
X-MFC with:	r246282
This commit is contained in:
Andriy Gapon 2013-02-08 07:29:07 +00:00
parent 1767d529f2
commit c43b08dc6c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246530

View File

@ -213,7 +213,11 @@ ktr_entries_initializer(void *dummy __unused)
ktr_mask = 0;
ktr_buf = malloc(sizeof(*ktr_buf) * KTR_ENTRIES, M_KTR,
M_WAITOK | M_ZERO);
memcpy(ktr_buf, ktr_buf_init, sizeof(ktr_buf_init));
memcpy(ktr_buf, ktr_buf_init + ktr_idx,
(KTR_BOOT_ENTRIES - ktr_idx) * sizeof(*ktr_buf));
if (ktr_idx != 0)
memcpy(ktr_buf + KTR_BOOT_ENTRIES - ktr_idx, ktr_buf_init,
ktr_idx * sizeof(*ktr_buf));
ktr_entries = KTR_ENTRIES;
ktr_mask = mask;
}