win-pvdrivers

changeset 1098:470198964cf0

Use the real crash dump header if we can
author James Harper <james.harper@bendigoit.com.au>
date Thu Jan 16 19:52:24 2014 +1100 (2014-01-16)
parents 2c0d09515dd0
children 27bd2a5a4704
files xenpci/xenpci.c
line diff
     1.1 --- a/xenpci/xenpci.c	Thu Jan 16 19:51:57 2014 +1100
     1.2 +++ b/xenpci/xenpci.c	Thu Jan 16 19:52:24 2014 +1100
     1.3 @@ -22,10 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #include <aux_klib.h>
     1.5  #include <stdlib.h>
     1.6  
     1.7 -#define SYSRQ_PATH "control/sysrq"
     1.8 -#define SHUTDOWN_PATH "control/shutdown"
     1.9 -#define BALLOON_PATH "memory/target"
    1.10 -
    1.11  #pragma warning(disable : 4200) // zero-sized array
    1.12  
    1.13  PMDL balloon_mdl_head = NULL;
    1.14 @@ -557,8 +553,8 @@ XenPci_FixLoadOrder()
    1.15  /* this isn't freed on shutdown... perhaps it should be */
    1.16  static PUCHAR dump_header = NULL;
    1.17  static ULONG dump_header_size;
    1.18 -static ULONG dump_header_refreshed_flag = FALSE;
    1.19  static KBUGCHECK_REASON_CALLBACK_RECORD callback_record;
    1.20 +static ULONG64 dump_current_offset = 0;
    1.21  #define DUMP_HEADER_PREFIX_SIZE 8
    1.22  #define DUMP_HEADER_SUFFIX_SIZE 8
    1.23  
    1.24 @@ -569,15 +565,22 @@ XenPci_DebugHeaderDumpIoCallback(
    1.25    PKBUGCHECK_REASON_CALLBACK_RECORD record,
    1.26    PVOID reason_specific_data,
    1.27    ULONG reason_specific_data_length) {
    1.28 -  UNREFERENCED_PARAMETER(reason);
    1.29    UNREFERENCED_PARAMETER(record);
    1.30    UNREFERENCED_PARAMETER(reason_specific_data);
    1.31    UNREFERENCED_PARAMETER(reason_specific_data_length);
    1.32 -  if (!dump_header_refreshed_flag) {
    1.33 -    NTSTATUS status;
    1.34 -    status = KeInitializeCrashDumpHeader(DUMP_TYPE_FULL, 0, dump_header + DUMP_HEADER_PREFIX_SIZE, dump_header_size, &dump_header_size);
    1.35 -    /* copy bug check code in? */
    1.36 -    dump_header_refreshed_flag = TRUE;
    1.37 +  
    1.38 +  if (dump_header && reason == KbCallbackDumpIo) {
    1.39 +    PKBUGCHECK_DUMP_IO dump_io = reason_specific_data;
    1.40 +    if (dump_io->Type == KbDumpIoHeader ) {
    1.41 +      if (dump_io->Offset != -1) {
    1.42 +        dump_current_offset = dump_io->Offset;
    1.43 +      }
    1.44 +      XN_ASSERT(dump_current_offset + dump_io->BufferLength <= dump_header_size);
    1.45 +      RtlCopyMemory(dump_header + DUMP_HEADER_PREFIX_SIZE + dump_current_offset, dump_io->Buffer, dump_io->BufferLength);
    1.46 +      dump_current_offset += dump_io->BufferLength;
    1.47 +    } else if (dump_io->Type == KbDumpIoComplete) {
    1.48 +      dump_current_offset = 0;
    1.49 +    }
    1.50    }
    1.51  }
    1.52  #endif