summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsephe <sephe@FreeBSD.org>2016-12-29 07:11:20 +0000
committersephe <sephe@FreeBSD.org>2016-12-29 07:11:20 +0000
commit981ab9afae448128b0926f3d6ac59e0e8ae54228 (patch)
tree77a423e0d091a6e7ea5b6d497fd57e525b39e736
parent818108f7293aed93f7e9e437c08b018163e23a55 (diff)
downloadFreeBSD-src-981ab9afae448128b0926f3d6ac59e0e8ae54228.zip
FreeBSD-src-981ab9afae448128b0926f3d6ac59e0e8ae54228.tar.gz
MFC 309236,309237
309236 hyperv/vmbus: Make sure that the allocated GPADL is not zero. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8631 309237 hyperv/vmbus: Stringent GPADL parameter assertion. Sponsored by: Microsoft Differential Revision: https://reviews.freebsd.org/D8632
-rw-r--r--sys/dev/hyperv/vmbus/vmbus.c8
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_chan.c8
2 files changed, 10 insertions, 6 deletions
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index 7cfa2f2..ad30db4 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -327,7 +327,13 @@ vmbus_msghc_wakeup(struct vmbus_softc *sc, const struct vmbus_message *msg)
uint32_t
vmbus_gpadl_alloc(struct vmbus_softc *sc)
{
- return atomic_fetchadd_int(&sc->vmbus_gpadl, 1);
+ uint32_t gpadl;
+
+again:
+ gpadl = atomic_fetchadd_int(&sc->vmbus_gpadl, 1);
+ if (gpadl == 0)
+ goto again;
+ return (gpadl);
}
static int
diff --git a/sys/dev/hyperv/vmbus/vmbus_chan.c b/sys/dev/hyperv/vmbus/vmbus_chan.c
index 70e12c5..47333ee 100644
--- a/sys/dev/hyperv/vmbus/vmbus_chan.c
+++ b/sys/dev/hyperv/vmbus/vmbus_chan.c
@@ -502,11 +502,7 @@ vmbus_chan_gpadl_connect(struct vmbus_channel *chan, bus_addr_t paddr,
int page_count, range_len, i, cnt, error;
uint64_t page_id;
- /*
- * Reset GPADL, so that the result would consistent, if error
- * happened later on.
- */
- *gpadl0 = 0;
+ KASSERT(*gpadl0 == 0, ("GPADL is not zero"));
/*
* Preliminary checks.
@@ -652,6 +648,8 @@ vmbus_chan_gpadl_disconnect(struct vmbus_channel *chan, uint32_t gpadl)
struct vmbus_chanmsg_gpadl_disconn *req;
int error;
+ KASSERT(gpadl != 0, ("GPADL is zero"));
+
mh = vmbus_msghc_get(sc, sizeof(*req));
if (mh == NULL) {
vmbus_chan_printf(chan,
OpenPOWER on IntegriCloud