1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

hyperv/storvsc: Stringent PRP list assertions

MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D7361
This commit is contained in:
Sepherosa Ziehau 2016-08-01 05:09:11 +00:00
parent 88cb8d7812
commit 05f7a8a69c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=303605

View File

@ -1775,13 +1775,28 @@ storvsc_xferbuf_prepare(void *arg, bus_dma_segment_t *segs, int nsegs, int error
prplist->gpa_range.gpa_ofs = segs[0].ds_addr & PAGE_MASK;
for (i = 0; i < nsegs; i++) {
prplist->gpa_page[i] = atop(segs[i].ds_addr);
#ifdef INVARIANTS
if (i != 0 && i != nsegs - 1) {
KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 &&
segs[i].ds_len == PAGE_SIZE, ("not a full page"));
if (nsegs > 1) {
if (i == 0) {
KASSERT((segs[i].ds_addr & PAGE_MASK) +
segs[i].ds_len == PAGE_SIZE,
("invalid 1st page, ofs 0x%jx, len %zu",
(uintmax_t)segs[i].ds_addr,
segs[i].ds_len));
} else if (i == nsegs - 1) {
KASSERT((segs[i].ds_addr & PAGE_MASK) == 0,
("invalid last page, ofs 0x%jx",
(uintmax_t)segs[i].ds_addr));
} else {
KASSERT((segs[i].ds_addr & PAGE_MASK) == 0 &&
segs[i].ds_len == PAGE_SIZE,
("not a full page, ofs 0x%jx, len %zu",
(uintmax_t)segs[i].ds_addr,
segs[i].ds_len));
}
}
#endif
prplist->gpa_page[i] = atop(segs[i].ds_addr);
}
reqp->prp_cnt = nsegs;
}