aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorSepherosa Ziehau <sephe@FreeBSD.org>2016-08-01 05:09:11 +0000
committerSepherosa Ziehau <sephe@FreeBSD.org>2016-08-01 05:09:11 +0000
commit05f7a8a69c9693daf513af4740def8d13f114074 (patch)
tree10c1e66e57e5344b9d48b7d02c29693fbb1d88ad /sys/dev
parent88cb8d781269fa07b817680f1c3f27b7e25fef84 (diff)
downloadsrc-05f7a8a69c9693daf513af4740def8d13f114074.tar.gz
src-05f7a8a69c9693daf513af4740def8d13f114074.zip
hyperv/storvsc: Stringent PRP list assertions
MFC after: 1 week Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D7361
Notes
Notes: svn path=/head/; revision=303605
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index e6a18e86b12a..b51348238987 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -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;
}