]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Make sure we only use the first 32 (-8) grant entries for crash kernel
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 24 Feb 2015 11:50:38 +0000 (11:50 +0000)
committerPaul Durrant <paul.durrant@citrix.com>
Tue, 24 Feb 2015 11:50:38 +0000 (11:50 +0000)
XENBUS only uses grant entries 32 onwards so that the first 32 (minus the 8
reserved entries) are clean for the crash kernel. This patch makes sure that
the crash kernel does not go over that limit.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
src/xencrsh/gnttab.c

index bbaa51964524319ee872d4fa81a7eb8da340f6e8..9d56bb271fc03cbef0474313bc677f33fba47933 100644 (file)
@@ -66,7 +66,9 @@
 #define GNTTAB_IS_OUT_OF_RANGE_REFERENCE(_Reference) \
         ((_Reference) > GNTTAB_ENTRY_PER_FRAME)
 
-#define GNTTAB_MAX_DESCRIPTOR   (GNTTAB_MAXIMUM_FRAME_COUNT * GNTTAB_ENTRY_PER_FRAME)
+#define GNTTAB_CRASH_RESERVATION    32
+
+#define GNTTAB_ENTRY_COUNT   (GNTTAB_CRASH_RESERVATION)
 
 typedef struct _GNTTAB_REFERENCE_DESCRIPTOR {
     ULONG               Next;   // next free entry
@@ -75,19 +77,15 @@ typedef struct _GNTTAB_REFERENCE_DESCRIPTOR {
 
 typedef struct _XENBUS_GNTTAB_CONTEXT {
     grant_entry_v1_t*           Entry;  // mapped page
-    GNTTAB_REFERENCE_DESCRIPTOR Descriptor[GNTTAB_MAX_DESCRIPTOR]; // free list
+    GNTTAB_REFERENCE_DESCRIPTOR Descriptor[GNTTAB_ENTRY_COUNT]; // free list
     ULONG                       HeadFreeReference; // head free list
     ULONG                       Count;  // number in use
 } XENBUS_GNTTAB_CONTEXT, *PXENBUS_GNTTAB_CONTEXT;
 
 static XENBUS_GNTTAB_CONTEXT    GnttabContext;
 
-#define MAXIMUM_GRANT_ENTRY_PAGES   1
-// Entry(s), Status(s)
-#define MAXIMUM_GRANT_PAGES 1
-
 __declspec(allocate(".gnttab_section"))
-static UCHAR __GnttabSection[(MAXIMUM_GRANT_PAGES + 1) * PAGE_SIZE];
+static UCHAR __GnttabSection[(GNTTAB_MAXIMUM_FRAME_COUNT + 1) * PAGE_SIZE];
 
 extern PHYSICAL_ADDRESS MmGetPhysicalAddress(IN PVOID Buffer);
 static FORCEINLINE PFN_NUMBER
@@ -243,11 +241,11 @@ GnttabInitialize(
     LogVerbose("grant_entry_v1_t* : %p\n", GnttabContext.Entry);
 
     // initialize free list
-    LogVerbose("adding refrences [%08x - %08x]\n", GNTTAB_RESERVED_ENTRY_COUNT, GNTTAB_ENTRY_PER_FRAME - 1);
+    LogVerbose("adding refrences [%08x - %08x]\n", GNTTAB_RESERVED_ENTRY_COUNT, GNTTAB_ENTRY_COUNT - 1);
 
     GnttabContext.HeadFreeReference = GNTTAB_INVALID_REFERENCE;
     GnttabContext.Count = 0;
-    for (Reference = GNTTAB_ENTRY_PER_FRAME - 1; Reference >= GNTTAB_RESERVED_ENTRY_COUNT; --Reference) {
+    for (Reference = GNTTAB_ENTRY_COUNT - 1; Reference >= GNTTAB_RESERVED_ENTRY_COUNT; --Reference) {
         PGNTTAB_REFERENCE_DESCRIPTOR    Descriptor = &GnttabContext.Descriptor[Reference];
 
         ASSERT(GNTTAB_IS_INVALID_REFERENCE(Descriptor->Next));