From cbb261aec7de20bad5d56ed7a2b2670c6f1ce902 Mon Sep 17 00:00:00 2001 From: Colin Percival Date: Mon, 11 Jan 2016 21:02:30 +0000 Subject: [PATCH] Add two more assertions to catch busdma problems. Each segment provided by busdma to the blkfront driver must be an integer number of sectors, and must be aligned in memory on a "sector" boundary. Having these assertions yesterday would have made finding the bug fixed in r293698 somewhat easier. --- sys/dev/xen/blkfront/blkfront.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/dev/xen/blkfront/blkfront.c b/sys/dev/xen/blkfront/blkfront.c index 0a75d79b1d2..c193d84b5a2 100644 --- a/sys/dev/xen/blkfront/blkfront.c +++ b/sys/dev/xen/blkfront/blkfront.c @@ -170,6 +170,11 @@ xbd_mksegarray(bus_dma_segment_t *segs, int nsegs, int ref; while (sg < last_block_sg) { + KASSERT(segs->ds_addr % (1 << XBD_SECTOR_SHFT) == 0, + ("XEN disk driver I/O must be sector aligned")); + KASSERT(segs->ds_len % (1 << XBD_SECTOR_SHFT) == 0, + ("XEN disk driver I/Os must be a multiple of " + "the sector length")); buffer_ma = segs->ds_addr; fsect = (buffer_ma & PAGE_MASK) >> XBD_SECTOR_SHFT; lsect = fsect + (segs->ds_len >> XBD_SECTOR_SHFT) - 1;