VirtualBox

Changeset 61628 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jun 9, 2016 5:52:51 PM (9 years ago)
Author:
vboxsync
Message:

DBGF: Added bsod_msr event, stubbed bsod_efi event. Since we cannot return VINF_EM_DBG_EVENT from an MSR handler, VMCPU_FF_DBGF was introduced as an alternative.

Location:
trunk/src/VBox/VMM
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/DBGFAll.cpp

    r59073 r61628  
    299299 * @returns Strict VBox status code.
    300300 * @retval  VINF_EM_DBG_EVENT if the event was raised and the caller should
    301  *          return ASAP to the debugger (via EM).
     301 *          return ASAP to the debugger (via EM).  We set VMCPU_FF_DBGF so, it
     302 *          is okay not to pass this along in some situations  .
    302303 * @retval  VINF_SUCCESS if the event was disabled or ignored.
    303304 *
     
    370371        pVCpu->dbgf.s.cEvents = i + 1;
    371372
     373        VMCPU_FF_SET(pVCpu, VMCPU_FF_DBGF);
    372374        return VINF_EM_DBG_EVENT;
    373375    }
  • trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp

    r61559 r61628  
    2121*********************************************************************************************************************************/
    2222#define LOG_GROUP LOG_GROUP_GIM
     23#include <VBox/vmm/em.h>
     24#include <VBox/vmm/hm.h>
     25#include <VBox/vmm/tm.h>
     26#include <VBox/vmm/dbgf.h>
     27#include <VBox/vmm/pgm.h>
    2328#include "GIMHvInternal.h"
    2429#include "GIMInternal.h"
     30#include <VBox/vmm/vm.h>
     31
     32#include <VBox/vmm/pdmdev.h>
     33#include <VBox/vmm/pdmapi.h>
     34#include <VBox/err.h>
    2535
    2636#include <iprt/asm-amd64-x86.h>
     
    2838# include <iprt/mem.h>
    2939#endif
    30 
    31 #include <VBox/err.h>
    32 #include <VBox/vmm/em.h>
    33 #include <VBox/vmm/hm.h>
    34 #include <VBox/vmm/tm.h>
    35 #include <VBox/vmm/vm.h>
    36 #include <VBox/vmm/pgm.h>
    37 #include <VBox/vmm/pdmdev.h>
    38 #include <VBox/vmm/pdmapi.h>
    3940
    4041
     
    726727                LogRel(("GIM: HyperV: Guest indicates a fatal condition! P0=%#RX64 P1=%#RX64 P2=%#RX64 P3=%#RX64 P4=%#RX64\n",
    727728                        pHv->uCrashP0Msr, pHv->uCrashP1Msr, pHv->uCrashP2Msr, pHv->uCrashP3Msr, pHv->uCrashP4Msr));
     729
     730                PVM pVM = pVCpu->CTX_SUFF(pVM);
     731                if (DBGF_IS_EVENT_ENABLED(pVM, DBGFEVENT_BSOD_MSR))
     732                    DBGFEventGenericWithArg(pVM, pVCpu, DBGFEVENT_BSOD_MSR, pHv->uCrashP0Msr, DBGFEVENTCTX_OTHER);
     733                /* (Do not try pass VINF_EM_DBG_EVENT, doesn't work from here!) */
    728734            }
    729735            return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r60993 r61628  
    11261126            /* Get guest page flags. */
    11271127            uint64_t fPageGst;
    1128             rc = PGMGstGetPage(pVCpu, pvFault, &fPageGst, NULL);
    1129             if (RT_SUCCESS(rc))
     1128            int rc2 = PGMGstGetPage(pVCpu, pvFault, &fPageGst, NULL);
     1129            if (RT_SUCCESS(rc2))
    11301130            {
    1131                 uint64_t fPageShw;
    1132                 rc = PGMShwGetPage(pVCpu, pvFault, &fPageShw, NULL);
     1131                uint64_t fPageShw = 0;
     1132                rc2 = PGMShwGetPage(pVCpu, pvFault, &fPageShw, NULL);
    11331133
    11341134                /*
     
    11431143                              && (fPageShw & (X86_PTE_RW | X86_PTE_US)) == X86_PTE_RW
    11441144                              && (fPageGst & (X86_PTE_RW | X86_PTE_US)) == X86_PTE_US),
    1145                           ("Page flags mismatch! pvFault=%RGv uErr=%x GCPhys=%RGp fPageShw=%RX64 fPageGst=%RX64\n",
    1146                            pvFault, (uint32_t)uErr, GCPhys, fPageShw, fPageGst));
     1145                          ("Page flags mismatch! pvFault=%RGv uErr=%x GCPhys=%RGp fPageShw=%RX64 fPageGst=%RX64 rc=%d\n",
     1146                           pvFault, (uint32_t)uErr, GCPhys, fPageShw, fPageGst, rc));
    11471147            }
    11481148            else
  • trunk/src/VBox/VMM/VMMAll/PGMAllPool.cpp

    r61212 r61628  
    859859     * Must do this in raw mode (!); XP boot will fail otherwise.
    860860     */
     861RTLogPrintf("pgmPoolAccessPfHandlerFlush\n");
    861862    VBOXSTRICTRC rc2 = EMInterpretInstructionDisasState(pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL);
    862863    if (rc2 == VINF_SUCCESS)
     
    10251026     * Interpret the instruction.
    10261027     */
     1028RTLogPrintf("pgmPoolAccessPfHandlerSimple\n");
    10271029    VBOXSTRICTRC rc = EMInterpretInstructionDisasState(pVCpu, pDis, pRegFrame, pvFault, EMCODETYPE_ALL);
    10281030    if (RT_SUCCESS(rc))
  • trunk/src/VBox/VMM/VMMR3/DBGF.cpp

    r60872 r61628  
    394394/**
    395395 * Forced action callback.
    396  * The VMM will call this from it's main loop when VM_FF_DBGF is set.
    397  *
    398  * The function checks and executes pending commands from the debugger.
     396 *
     397 * The VMM will call this from it's main loop when either VM_FF_DBGF or
     398 * VMCPU_FF_DBGF are set.
     399 *
     400 * The function checks for and executes pending commands from the debugger.
     401 * Then it checks for pending debug events and serves these.
    399402 *
    400403 * @returns VINF_SUCCESS normally.
     
    402405 * @param   pVM         The cross context VM structure.
    403406 */
    404 VMMR3_INT_DECL(int) DBGFR3VMMForcedAction(PVM pVM)
    405 {
    406     int rc = VINF_SUCCESS;
     407VMMR3_INT_DECL(int) DBGFR3VMMForcedAction(PVM pVM, PVMCPU pVCpu)
     408{
     409    VBOXSTRICTRC rcStrict = VINF_SUCCESS;
    407410
    408411    if (VM_FF_TEST_AND_CLEAR(pVM, VM_FF_DBGF))
    409412    {
    410         PVMCPU pVCpu = VMMGetCpu(pVM);
    411 
    412413        /*
    413414         * Command pending? Process it.
     
    418419            DBGFCMDDATA     CmdData = pVM->dbgf.s.VMMCmdData;
    419420            DBGFCMD         enmCmd = dbgfR3SetCmd(pVM, DBGFCMD_NO_COMMAND);
    420             rc = dbgfR3VMMCmd(pVM, enmCmd, &CmdData, &fResumeExecution);
     421            rcStrict = dbgfR3VMMCmd(pVM, enmCmd, &CmdData, &fResumeExecution);
    421422            if (!fResumeExecution)
    422                 rc = dbgfR3VMMWait(pVM);
    423         }
    424     }
    425     return rc;
     423                rcStrict = dbgfR3VMMWait(pVM);
     424        }
     425    }
     426
     427    /*
     428     * Dispatch pending events.
     429     */
     430    if (VMCPU_FF_TEST_AND_CLEAR(pVCpu, VMCPU_FF_DBGF))
     431    {
     432        if (   pVCpu->dbgf.s.cEvents > 0
     433            && pVCpu->dbgf.s.aEvents[pVCpu->dbgf.s.cEvents - 1].enmState == DBGFEVENTSTATE_CURRENT)
     434        {
     435            VBOXSTRICTRC rcStrict2 = DBGFR3EventHandlePending(pVM, pVCpu);
     436            if (   rcStrict2 != VINF_SUCCESS
     437                && (   rcStrict == VINF_SUCCESS
     438                    || RT_FAILURE(rcStrict2)
     439                    || rcStrict2 < rcStrict) ) /** @todo oversimplified? */
     440                rcStrict = rcStrict2;
     441        }
     442    }
     443
     444    return VBOXSTRICTRC_TODO(rcStrict);
    426445}
    427446
     
    554573{
    555574    VMCPU_ASSERT_EMT(pVCpu);
     575    VMCPU_FF_CLEAR(pVCpu, VMCPU_FF_DBGF);
    556576
    557577    /*
     
    567587    int rc = dbgfR3EventPrologue(pVM, pEvent->enmType);
    568588    if (RT_FAILURE(rc))
     589    {
     590        /** @todo drop them events?   */
    569591        return rc;
     592    }
    570593
    571594/** @todo SMP + debugger speaker logic  */
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r61027 r61628  
    895895         * Process the result.
    896896         */
    897         do
    898         {
    899             switch (VBOXSTRICTRC_VAL(rc))
    900             {
    901                 /*
    902                  * Continue the debugging loop.
    903                  */
    904                 case VINF_EM_DBG_STEP:
    905                 case VINF_EM_DBG_STOP:
    906                 case VINF_EM_DBG_EVENT:
    907                 case VINF_EM_DBG_STEPPED:
    908                 case VINF_EM_DBG_BREAKPOINT:
    909                 case VINF_EM_DBG_HYPER_STEPPED:
    910                 case VINF_EM_DBG_HYPER_BREAKPOINT:
    911                 case VINF_EM_DBG_HYPER_ASSERTION:
    912                     break;
    913 
    914                 /*
    915                  * Resuming execution (in some form) has to be done here if we got
    916                  * a hypervisor debug event.
    917                  */
    918                 case VINF_SUCCESS:
    919                 case VINF_EM_RESUME:
    920                 case VINF_EM_SUSPEND:
    921                 case VINF_EM_RESCHEDULE:
    922                 case VINF_EM_RESCHEDULE_RAW:
    923                 case VINF_EM_RESCHEDULE_REM:
    924                 case VINF_EM_HALT:
    925                     if (pVCpu->em.s.enmState == EMSTATE_DEBUG_HYPER)
    926                     {
     897        switch (VBOXSTRICTRC_VAL(rc))
     898        {
     899            /*
     900             * Continue the debugging loop.
     901             */
     902            case VINF_EM_DBG_STEP:
     903            case VINF_EM_DBG_STOP:
     904            case VINF_EM_DBG_EVENT:
     905            case VINF_EM_DBG_STEPPED:
     906            case VINF_EM_DBG_BREAKPOINT:
     907            case VINF_EM_DBG_HYPER_STEPPED:
     908            case VINF_EM_DBG_HYPER_BREAKPOINT:
     909            case VINF_EM_DBG_HYPER_ASSERTION:
     910                break;
     911
     912            /*
     913             * Resuming execution (in some form) has to be done here if we got
     914             * a hypervisor debug event.
     915             */
     916            case VINF_SUCCESS:
     917            case VINF_EM_RESUME:
     918            case VINF_EM_SUSPEND:
     919            case VINF_EM_RESCHEDULE:
     920            case VINF_EM_RESCHEDULE_RAW:
     921            case VINF_EM_RESCHEDULE_REM:
     922            case VINF_EM_HALT:
     923                if (pVCpu->em.s.enmState == EMSTATE_DEBUG_HYPER)
     924                {
    927925#ifdef VBOX_WITH_RAW_MODE
    928                         rc = emR3RawResumeHyper(pVM, pVCpu);
    929                         if (rc != VINF_SUCCESS && RT_SUCCESS(rc))
    930                             continue;
     926                    rc = emR3RawResumeHyper(pVM, pVCpu);
     927                    if (rc != VINF_SUCCESS && RT_SUCCESS(rc))
     928                        continue;
    931929#else
    932                         AssertLogRelMsgFailedReturn(("Not implemented\n"), VERR_EM_INTERNAL_ERROR);
    933 #endif
    934                     }
    935                     if (rc == VINF_SUCCESS)
    936                         rc = VINF_EM_RESCHEDULE;
    937                     return rc;
    938 
    939                 /*
    940                  * The debugger isn't attached.
    941                  * We'll simply turn the thing off since that's the easiest thing to do.
    942                  */
    943                 case VERR_DBGF_NOT_ATTACHED:
    944                     switch (VBOXSTRICTRC_VAL(rcLast))
    945                     {
    946                         case VINF_EM_DBG_HYPER_STEPPED:
    947                         case VINF_EM_DBG_HYPER_BREAKPOINT:
    948                         case VINF_EM_DBG_HYPER_ASSERTION:
    949                         case VERR_TRPM_PANIC:
    950                         case VERR_TRPM_DONT_PANIC:
    951                         case VERR_VMM_RING0_ASSERTION:
    952                         case VERR_VMM_HYPER_CR3_MISMATCH:
    953                         case VERR_VMM_RING3_CALL_DISABLED:
    954                             return rcLast;
    955                     }
    956                     return VINF_EM_OFF;
    957 
    958                 /*
    959                  * Status codes terminating the VM in one or another sense.
    960                  */
    961                 case VINF_EM_TERMINATE:
    962                 case VINF_EM_OFF:
    963                 case VINF_EM_RESET:
    964                 case VINF_EM_NO_MEMORY:
    965                 case VINF_EM_RAW_STALE_SELECTOR:
    966                 case VINF_EM_RAW_IRET_TRAP:
    967                 case VERR_TRPM_PANIC:
    968                 case VERR_TRPM_DONT_PANIC:
    969                 case VERR_IEM_INSTR_NOT_IMPLEMENTED:
    970                 case VERR_IEM_ASPECT_NOT_IMPLEMENTED:
    971                 case VERR_VMM_RING0_ASSERTION:
    972                 case VERR_VMM_HYPER_CR3_MISMATCH:
    973                 case VERR_VMM_RING3_CALL_DISABLED:
    974                 case VERR_INTERNAL_ERROR:
    975                 case VERR_INTERNAL_ERROR_2:
    976                 case VERR_INTERNAL_ERROR_3:
    977                 case VERR_INTERNAL_ERROR_4:
    978                 case VERR_INTERNAL_ERROR_5:
    979                 case VERR_IPE_UNEXPECTED_STATUS:
    980                 case VERR_IPE_UNEXPECTED_INFO_STATUS:
    981                 case VERR_IPE_UNEXPECTED_ERROR_STATUS:
    982                     return rc;
    983 
    984                 /*
    985                  * The rest is unexpected, and will keep us here.
    986                  */
    987                 default:
    988                     AssertMsgFailed(("Unexpected rc %Rrc!\n", VBOXSTRICTRC_VAL(rc)));
    989                     break;
    990             }
    991         } while (false);
     930                    AssertLogRelMsgFailedReturn(("Not implemented\n"), VERR_EM_INTERNAL_ERROR);
     931#endif
     932                }
     933                if (rc == VINF_SUCCESS)
     934                    rc = VINF_EM_RESCHEDULE;
     935                return rc;
     936
     937            /*
     938             * The debugger isn't attached.
     939             * We'll simply turn the thing off since that's the easiest thing to do.
     940             */
     941            case VERR_DBGF_NOT_ATTACHED:
     942                switch (VBOXSTRICTRC_VAL(rcLast))
     943                {
     944                    case VINF_EM_DBG_HYPER_STEPPED:
     945                    case VINF_EM_DBG_HYPER_BREAKPOINT:
     946                    case VINF_EM_DBG_HYPER_ASSERTION:
     947                    case VERR_TRPM_PANIC:
     948                    case VERR_TRPM_DONT_PANIC:
     949                    case VERR_VMM_RING0_ASSERTION:
     950                    case VERR_VMM_HYPER_CR3_MISMATCH:
     951                    case VERR_VMM_RING3_CALL_DISABLED:
     952                        return rcLast;
     953                }
     954                return VINF_EM_OFF;
     955
     956            /*
     957             * Status codes terminating the VM in one or another sense.
     958             */
     959            case VINF_EM_TERMINATE:
     960            case VINF_EM_OFF:
     961            case VINF_EM_RESET:
     962            case VINF_EM_NO_MEMORY:
     963            case VINF_EM_RAW_STALE_SELECTOR:
     964            case VINF_EM_RAW_IRET_TRAP:
     965            case VERR_TRPM_PANIC:
     966            case VERR_TRPM_DONT_PANIC:
     967            case VERR_IEM_INSTR_NOT_IMPLEMENTED:
     968            case VERR_IEM_ASPECT_NOT_IMPLEMENTED:
     969            case VERR_VMM_RING0_ASSERTION:
     970            case VERR_VMM_HYPER_CR3_MISMATCH:
     971            case VERR_VMM_RING3_CALL_DISABLED:
     972            case VERR_INTERNAL_ERROR:
     973            case VERR_INTERNAL_ERROR_2:
     974            case VERR_INTERNAL_ERROR_3:
     975            case VERR_INTERNAL_ERROR_4:
     976            case VERR_INTERNAL_ERROR_5:
     977            case VERR_IPE_UNEXPECTED_STATUS:
     978            case VERR_IPE_UNEXPECTED_INFO_STATUS:
     979            case VERR_IPE_UNEXPECTED_ERROR_STATUS:
     980                return rc;
     981
     982            /*
     983             * The rest is unexpected, and will keep us here.
     984             */
     985            default:
     986                AssertMsgFailed(("Unexpected rc %Rrc!\n", VBOXSTRICTRC_VAL(rc)));
     987                break;
     988        }
    992989    } /* debug for ever */
    993990}
     
    17151712         * Debugger Facility polling.
    17161713         */
    1717         if (VM_FF_IS_PENDING(pVM, VM_FF_DBGF))
    1718         {
    1719             rc2 = DBGFR3VMMForcedAction(pVM);
     1714        if (   VM_FF_IS_PENDING(pVM, VM_FF_DBGF)
     1715            || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_DBGF) )
     1716        {
     1717            rc2 = DBGFR3VMMForcedAction(pVM, pVCpu);
    17201718            UPDATE_RC();
    17211719        }
     
    17601758        /* check that we got them all  */
    17611759        AssertCompile(VM_FF_NORMAL_PRIORITY_POST_MASK == (VM_FF_CHECK_VM_STATE | VM_FF_DBGF | VM_FF_RESET | VM_FF_PGM_NO_MEMORY | VM_FF_EMT_RENDEZVOUS));
    1762         AssertCompile(VMCPU_FF_NORMAL_PRIORITY_POST_MASK == VM_WHEN_RAW_MODE(VMCPU_FF_CSAM_SCAN_PAGE, 0));
     1760        AssertCompile(VMCPU_FF_NORMAL_PRIORITY_POST_MASK == (VM_WHEN_RAW_MODE(VMCPU_FF_CSAM_SCAN_PAGE, 0) | VMCPU_FF_DBGF));
    17631761    }
    17641762
     
    19991997         * Debugger Facility request.
    20001998         */
    2001         if (VM_FF_IS_PENDING_EXCEPT(pVM, VM_FF_DBGF, VM_FF_PGM_NO_MEMORY))
    2002         {
    2003             rc2 = DBGFR3VMMForcedAction(pVM);
     1999        if (   (   VM_FF_IS_PENDING(pVM, VM_FF_DBGF)
     2000                || VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_DBGF) )
     2001            && !VM_FF_IS_PENDING(pVM, VM_FF_PGM_NO_MEMORY) )
     2002        {
     2003            rc2 = DBGFR3VMMForcedAction(pVM, pVCpu);
    20042004            UPDATE_RC();
    20052005        }
     
    20842084        /* check that we got them all  */
    20852085        AssertCompile(VM_FF_HIGH_PRIORITY_PRE_MASK == (VM_FF_TM_VIRTUAL_SYNC | VM_FF_DBGF | VM_FF_CHECK_VM_STATE | VM_FF_DEBUG_SUSPEND | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY | VM_FF_EMT_RENDEZVOUS));
    2086         AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_INHIBIT_INTERRUPTS | VM_WHEN_RAW_MODE(VMCPU_FF_SELM_SYNC_TSS | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT, 0)));
     2086        AssertCompile(VMCPU_FF_HIGH_PRIORITY_PRE_MASK == (VMCPU_FF_TIMER | VMCPU_FF_INTERRUPT_APIC | VMCPU_FF_UPDATE_APIC | VMCPU_FF_INTERRUPT_PIC | VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL | VMCPU_FF_INHIBIT_INTERRUPTS | VM_WHEN_RAW_MODE(VMCPU_FF_SELM_SYNC_TSS | VMCPU_FF_TRPM_SYNC_IDT | VMCPU_FF_SELM_SYNC_GDT | VMCPU_FF_SELM_SYNC_LDT | VMCPU_FF_DBGF, 0)));
    20872087    }
    20882088
  • trunk/src/VBox/VMM/VMMR3/VMEmt.cpp

    r60804 r61628  
    153153             * servicing requests. (Look after the ifs.)
    154154             */
    155             PVM pVM = pUVM->pVM;
     155            PVM    pVM   = pUVM->pVM;
     156            PVMCPU pVCpu = pUVCpu->pVCpu;
    156157            enmBefore = pVM->enmVMState;
    157158            if (pUVM->vm.s.fTerminateEMT)
     
    182183                Log(("vmR3EmulationThread: Req (cpu=%u) rc=%Rrc, VM state %s -> %s\n", pUVCpu->idCpu, rc, VMR3GetStateName(enmBefore), VMR3GetStateName(pVM->enmVMState)));
    183184            }
    184             else if (VM_FF_IS_SET(pVM, VM_FF_DBGF))
     185            else if (   VM_FF_IS_SET(pVM, VM_FF_DBGF)
     186                     || VMCPU_FF_IS_SET(pVCpu, VMCPU_FF_DBGF))
    185187            {
    186188                /*
    187189                 * Service the debugger request.
    188190                 */
    189                 rc = DBGFR3VMMForcedAction(pVM);
     191                rc = DBGFR3VMMForcedAction(pVM, pVCpu);
    190192                Log(("vmR3EmulationThread: Dbg rc=%Rrc, VM state %s -> %s\n", rc, VMR3GetStateName(enmBefore), VMR3GetStateName(pVM->enmVMState)));
    191193            }
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r61625 r61628  
    28582858        PRINT_FLAG(VMCPU_FF_,IEM);
    28592859        PRINT_FLAG(VMCPU_FF_,UPDATE_APIC);
     2860        PRINT_FLAG(VMCPU_FF_,DBGF);
    28602861        PRINT_FLAG(VMCPU_FF_,REQUEST);
    28612862        PRINT_FLAG(VMCPU_FF_,HM_UPDATE_CR3);
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