svn commit: r303605 - head/sys/dev/hyperv/storvsc
Sepherosa Ziehau
sephe at FreeBSD.org
Mon Aug 1 05:09:12 UTC 2016
Author: sephe
Date: Mon Aug 1 05:09:11 2016
New Revision: 303605
URL: https://svnweb.freebsd.org/changeset/base/303605
Log:
hyperv/storvsc: Stringent PRP list assertions
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7361
Modified:
head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
Modified: head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
==============================================================================
--- head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 1 04:51:31 2016 (r303604)
+++ head/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c Mon Aug 1 05:09:11 2016 (r303605)
@@ -1775,13 +1775,28 @@ storvsc_xferbuf_prepare(void *arg, bus_d
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;
}
More information about the svn-src-head
mailing list