[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH] Have another go at __CacheMaskScan()


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Paul Durrant <paul.durrant@xxxxxxxxxx>
  • Date: Tue, 20 Aug 2019 14:22:35 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@xxxxxxxxxx; spf=Pass smtp.mailfrom=Paul.Durrant@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: Paul Durrant <paul.durrant@xxxxxxxxxx>
  • Delivery-date: Tue, 20 Aug 2019 13:22:55 +0000
  • Ironport-sdr: L0hl4OigtLPfUYtbb4QRN7BUOaR7B0F/DTlx3tFPM4qPS2YSCqLYf8TfeXlzjW/d1QePD1Hrhf 0+j5wc6Uqrfj5pIHK+DXvgJgL7I2JYI3+KZrLAr2S/ReXyanQXRblvqizMDuTxzvEqkOf1qB6W mOg2Peozu9aaJflsfQFh5FOuPEgztGuL/R5eY2rwrZ57ewGxuk6kMCVEtmkNG8RWIuF7MTX6Zi 4pV0JTKh+lK71GKRDaMrZizyoM+7Dzd8jT58xQ/qAAogzwCrGo+whbLddox9bN2AWIYew0nlo8 CVE=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Trying to BUG() at the end of the function if an available index is not
found is proving to be too challenging for the compilier. It seems that,
in general, a free build may object if there's (an effectively dead) return
statement after the BUG() and a checked build will fail if the return
statement is *not* there. Rock. Hard place.

This patch instead gets rid of the BUG(), makes __CacheMaskScan() return
and out-of-range index if there is no available index and then adds a
suitable BUG_ON() into CacheGetObjectFromSlab(), the only caller.

The patch also fixes a hole in the logic where an out-of-range index
could have been returned if it was less than the maximum occupancy
rounded up to the next 32-bit boundary.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenbus/cache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xenbus/cache.c b/src/xenbus/cache.c
index 7daf8da..479c411 100644
--- a/src/xenbus/cache.c
+++ b/src/xenbus/cache.c
@@ -369,10 +369,11 @@ __CacheMaskScan(
             continue;
 
         Bit += Index * BITS_PER_ULONG;
-        return Bit;
+        if (Bit < Maximum)
+            return Bit;
     }
 
-    BUG("CACHE SCAN FAILED");
+    return Maximum;
 }
 
 static FORCEINLINE VOID
@@ -425,6 +426,7 @@ CacheGetObjectFromSlab(
         return NULL;
 
     Index = __CacheMaskScan(Slab->Mask, Slab->MaximumOccupancy);
+    BUG_ON(Index >= Slab->MaximumOccupancy);
 
     __CacheMaskSet(Slab->Mask, Index);
     Slab->CurrentOccupancy++;
-- 
2.5.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.