VirtualBox

Changeset 18170 in vbox for trunk/src


Ignore:
Timestamp:
Mar 24, 2009 11:01:41 AM (16 years ago)
Author:
vboxsync
Message:

VBoxGuest/win: bugcheck cleanup: ULONG_PTR parameters cannot be printed using %u or %x, but requires %p or similar. Ignore bugcheck registration errors. Don't mess about with a context, just use the device extension (it's allocated from the nonpaged pool). TODO: Move the bugcheck code to a sepearte file and selectively enabled the vista ddk for that.

Location:
trunk/src/VBox/Additions/WINNT/VBoxGuest
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.cpp

    r18022 r18170  
    11/** @file
    2  *
    32 * VBoxGuest -- VirtualBox Win32 guest support driver
    4  *
     3 */
     4
     5/*
    56 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
    67 *
     
    2728
    2829#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    29  #ifndef TARGET_NT4
    30   #include <aux_klib.h>
    31  #endif
     30# ifndef TARGET_NT4
     31include <aux_klib.h>
     32# endif
    3233#endif
    3334
     
    254255
    255256#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    256 NTSTATUS hlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt)
    257 {
    258     int rc = STATUS_SUCCESS;
    259 
    260  #ifndef TARGET_NT4
     257/**
     258 * Called when a bug check occurs.
     259 *
     260 * @param   pvBuffer        Pointer to our device extension, just in case it
     261 *                          comes in handy some day.
     262 * @param   cbBuffer        The size of our device extension.
     263 */
     264static VOID hlpVBoxGuestBugCheckCallback(PVOID pvBuffer, ULONG cbBuffer)
     265{
     266    /*PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvBuffer;*/
     267
     268    LogRelBackdoor(("Windows bug check (bluescreen) detected!\n"));
     269
     270# ifndef TARGET_NT4
     271    /*
     272     * Try get details.
     273     */
     274    KBUGCHECK_DATA bugCheckData;
     275    bugCheckData.BugCheckDataSize = sizeof(KBUGCHECK_DATA);
     276    NTSTATUS rc = AuxKlibGetBugCheckData(&bugCheckData);
     277    if (NT_SUCCESS(rc))
     278    {
     279        LogRelBackdoor(("Bug check code: 0x%08x\n", bugCheckData.BugCheckCode));
     280        LogRelBackdoor(("Bug check parameters: 1=0x%p 2=0x%p 3=0x%p 4=0x%p\n",
     281                        bugCheckData.Parameter1,
     282                        bugCheckData.Parameter2,
     283                        bugCheckData.Parameter3,
     284                        bugCheckData.Parameter4));
     285        LogRelBackdoor(("For details run \"!analyze -show %x %p %p %p %p\" in WinDbg.\n",
     286                        bugCheckData.BugCheckCode,
     287                        bugCheckData.Parameter1,
     288                        bugCheckData.Parameter2,
     289                        bugCheckData.Parameter3,
     290                        bugCheckData.Parameter4));
     291    }
     292    else
     293        LogRelBackdoor(("Unable to retrieve bugcheck details! Error: %#x\n", rc));
     294# else  /* NT4 */
     295    LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));
     296# endif /* NT4 */
     297
     298    /*
     299     * Notify the host that we've panicked.
     300     */
     301    /** @todo Notify the host somehow over DevVMM. */
     302
     303    NOREF(pvBuffer); NOREF(cbBuffer);
     304}
     305
     306NTSTATUS hlpRegisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)
     307{
     308    NTSTATUS rc = STATUS_SUCCESS;
     309    pDevExt->bBugcheckCallbackRegistered = FALSE;
     310
     311# ifndef TARGET_NT4
     312    /*
     313     * This is required for calling AuxKlibGetBugCheckData() in hlpVBoxGuestBugCheckCallback().
     314     */
    261315    rc = AuxKlibInitialize();
    262316    if (NT_ERROR(rc))
    263317    {
    264         dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Unabled to initialize AuxKlib!\n"));
     318        dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Unabled to initialize AuxKlib! rc=%#x\n", rc));
    265319        return STATUS_DRIVER_UNABLE_TO_LOAD;
    266320    }
    267  #endif
     321# endif
    268322
    269323    /*
    270      * Setup bugcheck callback routine ASAP.
     324     * Setup bugcheck callback routine.
    271325     */
    272326    pDevExt->bBugcheckCallbackRegistered = FALSE;
    273     pDevExt->bugcheckContext = (VBOXBUGCHECKCONTEXT*)ExAllocatePool(NonPagedPool, sizeof(VBOXBUGCHECKCONTEXT));
    274     if(!pDevExt->bugcheckContext)
    275     {
    276         dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Not enough memory for bugcheck context!\n"));
    277         return STATUS_INSUFFICIENT_RESOURCES;
    278     }
    279 
    280     KeInitializeCallbackRecord(&pDevExt->bugcheckContext->bugcheckRecord);
    281     if (FALSE == KeRegisterBugCheckCallback(&pDevExt->bugcheckContext->bugcheckRecord,
    282                                             &hlpVBoxGuestBugCheckCallback,
    283                                             pDevExt->bugcheckContext,
    284                                             sizeof(VBOXBUGCHECKCONTEXT),
    285                                             (PUCHAR)"VBoxGuest"))
    286     {
    287         LogRelBackdoor(("Could not register bugcheck callback routine!\n"));
    288     }
    289     else
     327    KeInitializeCallbackRecord(&pDevExt->bugcheckRecord);
     328    if (KeRegisterBugCheckCallback(&pDevExt->bugcheckRecord,
     329                                   &hlpVBoxGuestBugCheckCallback,
     330                                   pDevExt,
     331                                   sizeof(*pDevExt),
     332                                   (PUCHAR)"VBoxGuest"))
    290333    {
    291334        pDevExt->bBugcheckCallbackRegistered = TRUE;
    292335        dprintf(("VBoxGuest::hlpRegisterBugCheckCallback: Bugcheck callback registered.\n"));
    293336    }
     337    else
     338        LogRelBackdoor(("Could not register bugcheck callback routine!\n"));
    294339
    295340    return rc;
    296341}
    297342
    298 VOID hlpVBoxGuestBugCheckCallback(PVOID pvBuffer, ULONG ulLength)
    299 {
    300     NTSTATUS rc = 0;
    301     PVBOXBUGCHECKCONTEXT pContext = (PVBOXBUGCHECKCONTEXT)pvBuffer;
    302 
    303     LogRelBackdoor(("Windows bugcheck (bluescreen) detected!\n"));
    304 
    305 #ifndef TARGET_NT4
    306     KBUGCHECK_DATA bugcheckData;
    307     bugcheckData.BugCheckDataSize = sizeof(KBUGCHECK_DATA);
    308     rc = AuxKlibGetBugCheckData(&bugcheckData);
    309     if (!RT_SUCCESS(rc))
    310     {
    311         LogRelBackdoor(("Unable to retrieve bugcheck details! Error: %d\n", rc));
    312         return;
    313     }
    314 
    315     LogRelBackdoor(("Bugcheck code: 0x%08x\n", bugcheckData.BugCheckCode));
    316     LogRelBackdoor(("Bugcheck parameters: 1=%ld 2=%ld 3=%ld 4=%ld\n",
    317                    bugcheckData.Parameter1,
    318                    bugcheckData.Parameter2,
    319                    bugcheckData.Parameter3,
    320                    bugcheckData.Parameter4));
    321 #else
    322     LogRelBackdoor(("No additional information for Windows NT 4.0 bugcheck available.\n"));
     343void hlpDeregisterBugCheckCallback(PVBOXGUESTDEVEXT pDevExt)
     344{
     345    if (pDevExt->bBugcheckCallbackRegistered)
     346    {
     347        if (!KeDeregisterBugCheckCallback(&pDevExt->bugcheckRecord))
     348            dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));
     349        pDevExt->bBugcheckCallbackRegistered = FALSE;
     350    }
     351}
    323352#endif
    324 
    325     if (pvBuffer)
    326     {
    327         /* @todo - Not used yet. */
    328     }
    329 
    330     /* @todo Notify the host somehow over DevVMM. */
    331 }
    332 #endif
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Helper.h

    r18019 r18170  
    6464NTSTATUS hlpRegisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt);
    6565
    66 VOID hlpVBoxGuestBugCheckCallback (PVOID pvBuffer, ULONG ulLength);
     66/**
     67 * Helper for deregistering the bugcheck callback rountine(s).
     68 *
     69 * @param pDevExt   VMMDev device extension
     70 */
     71void hlpDeregisterBugCheckCallback (PVBOXGUESTDEVEXT pDevExt);
    6772#endif
    6873}
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/Makefile.kmk

    r18037 r18170  
    3737#VBoxGuest_DEFS       += LOG_ENABLED
    3838VBoxGuest_INCS        = \
    39         ../include     
     39        ../include
    4040VBoxGuest_LDFLAGS.x86   = -Entry:DriverEntry@8
    4141VBoxGuest_LDFLAGS.amd64 = -Entry:DriverEntry
     
    5252
    5353ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    54  #VBoxGuest_SDKS = WINDDKWLH
     54 VBoxGuest_SDKS = WINDDKWLH
    5555 VBoxGuest_LIBS = \
    5656        $(PATH_SDK_WINDDKWLH_LIB)/ksecdd.lib \
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp

    r18022 r18170  
    3232#include "Helper.h"
    3333#include <excpt.h>
    34 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    35  #ifndef TARGET_NT4
    36   #include <aux_klib.h>
    37  #endif
    38 #endif
    3934#include <VBox/err.h>
    4035#include <VBox/log.h>
     
    4742
    4843#ifdef TARGET_NT4
    49 /* XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist on NT4, so...
    50  * The same for ExAllocatePool.
     44/*
     45 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
     46 * on NT4, so... The same for ExAllocatePool.
    5147 */
    5248#undef ExAllocatePool
     
    247243
    248244#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    249     rc = hlpRegisterBugCheckCallback(pDevExt);
     245    hlpRegisterBugCheckCallback(pDevExt); /* ignore failure! */
    250246#endif
    251247
     
    293289
    294290#ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION
    295     /* Unregister bugcheck callback. */
    296     if (pDevExt->bugcheckContext)
    297     {
    298         if (pDevExt->bBugcheckCallbackRegistered)
    299         {
    300             if (FALSE == KeDeregisterBugCheckCallback(&pDevExt->bugcheckContext->bugcheckRecord))
    301                 dprintf(("VBoxGuest::VBoxGuestUnload: Unregistering bugcheck callback routine failed!\n"));
    302         }
    303 
    304         ExFreePool(&pDevExt->bugcheckContext);
    305         pDevExt->bugcheckContext = NULL;
    306         pDevExt->bBugcheckCallbackRegistered = FALSE;
    307     }
     291    hlpDeregisterBugCheckCallback(pDevExt); /* ignore failure! */
    308292#endif
    309293
     
    17131697
    17141698            /* align at 4MB */
    1715             req->hypervisorStart = (RTGCPTR)RT_ALIGN_P(pDevExt->hypervisorMapping, 0x400000);
     1699            req->hypervisorStart = (uintptr_t)RT_ALIGN_P(pDevExt->hypervisorMapping, 0x400000);
    17161700
    17171701            req->header.requestType = VMMDevReq_SetHypervisorInfo;
  • trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest_Internal.h

    r18019 r18170  
    125125} BASE_ADDRESS, *PBASE_ADDRESS;
    126126
    127 typedef struct
    128 {
    129     KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
    130 } VBOXBUGCHECKCONTEXT, *PVBOXBUGCHECKCONTEXT;
    131127
    132128/**
     
    220216    VMMDevPowerStateRequest *powerStateRequest;
    221217
    222     /* Bugcheck context. */
     218    /** Is the bugcheck callback registered? */
    223219    BOOLEAN bBugcheckCallbackRegistered;
    224     PVBOXBUGCHECKCONTEXT bugcheckContext;
     220    /** The bugcheck registration record. */
     221    KBUGCHECK_CALLBACK_RECORD bugcheckRecord;
    225222
    226223} VBOXGUESTDEVEXT, *PVBOXGUESTDEVEXT;
     
    246243{
    247244    /** Array containing HGCM client IDs associated with this session.
    248      * This will be automatically disconnected when the session is closed. 
     245     * This will be automatically disconnected when the session is closed.
    249246     * Note that array size also affects/is maximum number of supported opengl threads per guest process.
    250247     */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette