Date: Mon, 1 Aug 2016 05:09:11 +0000 (UTC) From: Sepherosa Ziehau <sephe@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303605 - head/sys/dev/hyperv/storvsc Message-ID: <201608010509.u7159BIl025535@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608010509.u7159BIl025535>