Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Dec 2016 07:11:21 +0000 (UTC)
From:      Sepherosa Ziehau <sephe@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r310759 - stable/10/sys/dev/hyperv/vmbus
Message-ID:  <201612290711.uBT7BLY8055402@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sephe
Date: Thu Dec 29 07:11:20 2016
New Revision: 310759
URL: https://svnweb.freebsd.org/changeset/base/310759

Log:
  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

Modified:
  stable/10/sys/dev/hyperv/vmbus/vmbus.c
  stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/vmbus.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/vmbus.c	Thu Dec 29 07:10:25 2016	(r310758)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus.c	Thu Dec 29 07:11:20 2016	(r310759)
@@ -327,7 +327,13 @@ vmbus_msghc_wakeup(struct vmbus_softc *s
 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

Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c
==============================================================================
--- stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c	Thu Dec 29 07:10:25 2016	(r310758)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus_chan.c	Thu Dec 29 07:11:20 2016	(r310759)
@@ -502,11 +502,7 @@ vmbus_chan_gpadl_connect(struct vmbus_ch
 	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
 	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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612290711.uBT7BLY8055402>