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

[PATCH 1/3] util: Sync with xenbus


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Thu, 22 Oct 2026 14:17:35 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Delivery-date: Thu, 22 Oct 2026 12:17:47 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

Take util.h from xenbus. This brings TIME_* macros.
Remove TIME_* macros of xenvbd/ring.c now provided by util.h.

Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
 src/common/util.h | 23 ++++++++++++++++++-----
 src/xenvbd/ring.c |  7 +------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/common/util.h b/src/common/util.h
index b197b14..db40d4f 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -41,6 +41,11 @@
 #define        P2ROUNDUP(_t, _x, _a)   \
         (-(-((_t)(_x)) & -(((_t)(_a)))))
 
+#define TIME_US(_us)            ((_us) * 10ll)
+#define TIME_MS(_ms)            (TIME_US((_ms) * 1000ll))
+#define TIME_S(_s)              (TIME_MS((_s) * 1000ll))
+#define TIME_RELATIVE(_t)       (-(_t))
+
 static FORCEINLINE LONG
 __ffs(
     _In_ unsigned long long mask
@@ -89,7 +94,7 @@ __CpuId(
     _Out_opt_ PULONG    EDX
     )
 {
-    int                 Value[4] = {0};
+    int         Value[4] = {0};
 
     __cpuid(Value, Leaf);
 
@@ -181,13 +186,15 @@ __FreePoolWithTag(
 
 static FORCEINLINE PMDL
 __AllocatePages(
-    _In_ ULONG          Count
+    _In_ ULONG          Count,
+    _In_ BOOLEAN        Contiguous
     )
 {
     PHYSICAL_ADDRESS    LowAddress;
     PHYSICAL_ADDRESS    HighAddress;
     LARGE_INTEGER       SkipBytes;
     SIZE_T              TotalBytes;
+    ULONG               Flags;
     PMDL                Mdl;
     PUCHAR              MdlMappedSystemVa;
     NTSTATUS            status;
@@ -197,12 +204,18 @@ __AllocatePages(
     SkipBytes.QuadPart = 0ull;
     TotalBytes = (SIZE_T)PAGE_SIZE * Count;
 
+    if (Contiguous) {
+        Flags = MM_ALLOCATE_REQUIRE_CONTIGUOUS_CHUNKS;
+    } else {
+        Flags = MM_ALLOCATE_FULLY_REQUIRED;
+    }
+
     Mdl = MmAllocatePagesForMdlEx(LowAddress,
                                   HighAddress,
                                   SkipBytes,
                                   TotalBytes,
                                   MmCached,
-                                  MM_ALLOCATE_FULLY_REQUIRED);
+                                  Flags);
 
     status = STATUS_NO_MEMORY;
     if (Mdl == NULL)
@@ -246,14 +259,14 @@ fail1:
     return NULL;
 }
 
-#define __AllocatePage()    __AllocatePages(1)
+#define __AllocatePage()    __AllocatePages(1, FALSE)
 
 static FORCEINLINE VOID
 __FreePages(
     _In_ PMDL   Mdl
     )
 {
-    PUCHAR      MdlMappedSystemVa;
+    PUCHAR     MdlMappedSystemVa;
 
     ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
     MdlMappedSystemVa = Mdl->MappedSystemVa;
diff --git a/src/xenvbd/ring.c b/src/xenvbd/ring.c
index 339679b..dae2ca0 100644
--- a/src/xenvbd/ring.c
+++ b/src/xenvbd/ring.c
@@ -1679,11 +1679,6 @@ BlkifRingDpc(
     }
 }
 
-#define TIME_US(_us)        ((_us) * 10)
-#define TIME_MS(_ms)        (TIME_US((_ms) * 1000))
-#define TIME_S(_s)          (TIME_MS((_s) * 1000))
-#define TIME_RELATIVE(_t)   (-(_t))
-
 #define XENVBD_WATCHDOG_PERIOD 30
 
 static NTSTATUS
@@ -2050,7 +2045,7 @@ BlkifRingConnect(
     if (!NT_SUCCESS(status))
         goto fail1;
 
-    BlkifRing->Mdl = __AllocatePages(1 << Ring->Order);
+    BlkifRing->Mdl = __AllocatePages(1 << Ring->Order, FALSE);
 
     status = STATUS_NO_MEMORY;
     if (BlkifRing->Mdl == NULL)
-- 
2.55.0.windows.5



--
Césaire Mounah | Vates Windows Guest Tools Engineer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

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