VirtualBox

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


Ignore:
Timestamp:
Nov 29, 2015 10:22:48 PM (9 years ago)
Author:
vboxsync
Message:

HM: Some top-level VBOXSTRICTRC use and related work.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r58912 r58913  
    9090    DECLR0CALLBACKMEMBER(void, pfnThreadCtxCallback, (RTTHREADCTXEVENT enmEvent, PVMCPU pVCpu, bool fGlobalInit));
    9191    DECLR0CALLBACKMEMBER(int,  pfnSaveHostState, (PVM pVM, PVMCPU pVCpu));
    92     DECLR0CALLBACKMEMBER(int,  pfnRunGuestCode, (PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx));
     92    DECLR0CALLBACKMEMBER(VBOXSTRICTRC,pfnRunGuestCode, (PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx));
    9393    DECLR0CALLBACKMEMBER(int,  pfnEnableCpu, (PHMGLOBALCPUINFO pCpu, PVM pVM, void *pvCpuPage, RTHCPHYS HCPhysCpuPage,
    9494                                              bool fEnabledByHost, void *pvArg));
     
    272272}
    273273
    274 static DECLCALLBACK(int) hmR0DummyRunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
     274static DECLCALLBACK(VBOXSTRICTRC) hmR0DummyRunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    275275{
    276276    NOREF(pVM); NOREF(pVCpu); NOREF(pCtx);
     
    14661466 * Runs guest code in a hardware accelerated VM.
    14671467 *
    1468  * @returns VBox status code.
     1468 * @returns Strict VBox status code. (VBOXSTRICTRC isn't used because it's
     1469 *          called from setjmp assembly.)
    14691470 * @param   pVM         The cross context VM structure.
    14701471 * @param   pVCpu       The cross context virtual CPU structure.
     
    14921493#endif
    14931494
    1494     int rc = g_HmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu));
     1495    VBOXSTRICTRC rcStrict = g_HmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu));
    14951496
    14961497#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    14971498    PGMRZDynMapReleaseAutoSet(pVCpu);
    14981499#endif
    1499     return rc;
     1500    return VBOXSTRICTRC_VAL(rcStrict);
    15001501}
    15011502
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r58658 r58913  
    34693469 * Runs the guest code using AMD-V.
    34703470 *
    3471  * @returns VBox status code.
     3471 * @returns Strict VBox status code.
    34723472 * @param   pVM         The cross context VM structure.
    34733473 * @param   pVCpu       The cross context virtual CPU structure.
    34743474 * @param   pCtx        Pointer to the guest-CPU context.
    34753475 */
    3476 VMMR0DECL(int) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
     3476VMMR0DECL(VBOXSTRICTRC) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    34773477{
    34783478    Assert(VMMRZCallRing3IsEnabled(pVCpu));
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.h

    r58123 r58913  
    4848VMMR0DECL(int)  SVMR0TermVM(PVM pVM);
    4949VMMR0DECL(int)  SVMR0SetupVM(PVM pVM);
    50 VMMR0DECL(int) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
     50VMMR0DECL(VBOXSTRICTRC) SVMR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    5151VMMR0DECL(int)  SVMR0SaveHostState(PVM pVM, PVMCPU pVCpu);
    5252
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r58912 r58913  
    47764776 * Wrapper for running the guest code in VT-x.
    47774777 *
    4778  * @returns VBox strict status code.
     4778 * @returns VBox status code, no informational status codes.
    47794779 * @param   pVM         The cross context VM structure.
    47804780 * @param   pVCpu       The cross context virtual CPU structure.
     
    47934793    /** @todo Add stats for resume vs launch. */
    47944794#ifdef VBOX_WITH_KERNEL_USING_XMM
    4795     return HMR0VMXStartVMWrapXMM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hm.s.vmx.pfnStartVM);
     4795    int rc = HMR0VMXStartVMWrapXMM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu, pVCpu->hm.s.vmx.pfnStartVM);
    47964796#else
    4797     return pVCpu->hm.s.vmx.pfnStartVM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu);
     4797    int rc = pVCpu->hm.s.vmx.pfnStartVM(fResumeVM, pCtx, &pVCpu->hm.s.vmx.VMCSCache, pVM, pVCpu);
    47984798#endif
     4799    AssertMsg(rc <= VINF_SUCCESS, ("%Rrc\n", rc));
     4800    return rc;
    47994801}
    48004802
     
    50555057 * Executes the specified handler in 64-bit mode.
    50565058 *
    5057  * @returns VBox status code.
     5059 * @returns VBox status code (no informational status codes).
    50585060 * @param   pVM         The cross context VM structure.
    50595061 * @param   pVCpu       The cross context virtual CPU structure.
     
    70937095 *                      VINF_VMM_UNKNOWN_RING3_CALL.
    70947096 */
    7095 static int hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, int rcExit)
     7097static int hmR0VmxExitToRing3(PVM pVM, PVMCPU pVCpu, PCPUMCTX pMixedCtx, VBOXSTRICTRC rcExit)
    70967098{
    70977099    Assert(pVM);
     
    71107112    /* Please, no longjumps here (any logging shouldn't flush jump back to ring-3). NO LOGGING BEFORE THIS POINT! */
    71117113    VMMRZCallRing3Disable(pVCpu);
    7112     Log4(("hmR0VmxExitToRing3: pVCpu=%p idCpu=%RU32 rcExit=%d\n", pVCpu, pVCpu->idCpu, rcExit));
     7114    Log4(("hmR0VmxExitToRing3: pVCpu=%p idCpu=%RU32 rcExit=%d\n", pVCpu, pVCpu->idCpu, VBOXSTRICTRC_VAL(rcExit)));
    71137115
    71147116    /* We need to do this only while truly exiting the "inner loop" back to ring-3 and -not- for any longjmp to ring3. */
     
    71247126    /* If we're emulating an instruction, we shouldn't have any TRPM traps pending
    71257127       and if we're injecting an event we should have a TRPM trap pending. */
    7126     AssertMsg(rcExit != VINF_EM_RAW_INJECT_TRPM_EVENT || TRPMHasTrap(pVCpu), ("%Rrc\n", rcExit));
     7128    AssertMsg(rcExit != VINF_EM_RAW_INJECT_TRPM_EVENT || TRPMHasTrap(pVCpu), ("%Rrc\n", VBOXSTRICTRC_VAL(rcExit)));
    71277129#ifndef DEBUG_bird /* Triggered after firing an NMI against NT4SP1, possibly a tripple fault in progress. */
    7128     AssertMsg(rcExit != VINF_EM_RAW_EMULATE_INSTR || !TRPMHasTrap(pVCpu), ("%Rrc\n", rcExit));
     7130    AssertMsg(rcExit != VINF_EM_RAW_EMULATE_INSTR || !TRPMHasTrap(pVCpu), ("%Rrc\n", VBOXSTRICTRC_VAL(rcExit)));
    71297131#endif
    71307132
     
    87218723 * @note    Mostly the same as hmR0VmxRunGuestCodeStep().
    87228724 */
    8723 static int hmR0VmxRunGuestCodeNormal(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
     8725static VBOXSTRICTRC hmR0VmxRunGuestCodeNormal(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    87248726{
    87258727    VMXTRANSIENT VmxTransient;
    87268728    VmxTransient.fUpdateTscOffsettingAndPreemptTimer = true;
    8727     int          rc    = VERR_INTERNAL_ERROR_5;
     8729    VBOXSTRICTRC rcStrict = VERR_INTERNAL_ERROR_5;
    87288730    uint32_t     cLoops = 0;
    87298731
     
    87368738           to ring-3.  This bugger disables interrupts on VINF_SUCCESS! */
    87378739        STAM_PROFILE_ADV_START(&pVCpu->hm.s.StatEntry, x);
    8738         rc = hmR0VmxPreRunGuest(pVM, pVCpu, pCtx, &VmxTransient, false /* fStepping */);
    8739         if (rc != VINF_SUCCESS)
     8740        rcStrict = hmR0VmxPreRunGuest(pVM, pVCpu, pCtx, &VmxTransient, false /* fStepping */);
     8741        if (rcStrict != VINF_SUCCESS)
    87408742            break;
    87418743
    87428744        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    8743         rc = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
     8745        int rcRun = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
    87448746        /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */
    87458747
    87468748        /* Restore any residual host-state and save any bits shared between host
    87478749           and guest into the guest-CPU state.  Re-enables interrupts! */
    8748         hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, rc);
     8750        hmR0VmxPostRunGuest(pVM, pVCpu, pCtx, &VmxTransient, VBOXSTRICTRC_TODO(rcStrict));
    87498751
    87508752        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
    8751         if (RT_UNLIKELY(rc != VINF_SUCCESS))
     8753        if (RT_SUCCESS(rcRun))
     8754        { /* very likely */ }
     8755        else
    87528756        {
    87538757            STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x);
    8754             hmR0VmxReportWorldSwitchError(pVM, pVCpu, rc, pCtx, &VmxTransient);
    8755             return rc;
     8758            hmR0VmxReportWorldSwitchError(pVM, pVCpu, rcRun, pCtx, &VmxTransient);
     8759            return rcRun;
    87568760        }
    87578761
     
    87648768
    87658769        VBOXVMM_R0_HMVMX_VMEXIT_NOCTX(pVCpu, pCtx, VmxTransient.uExitReason);
    8766         if (RT_UNLIKELY(VBOXVMM_R0_HMVMX_VMEXIT_ENABLED()))
     8770        if (RT_LIKELY(!VBOXVMM_R0_HMVMX_VMEXIT_ENABLED()))
     8771        { /* likely */ }
     8772        else
    87678773        {
    87688774            hmR0VmxReadExitQualificationVmcs(pVCpu, &VmxTransient);
     
    87738779        /* Handle the VM-exit. */
    87748780#ifdef HMVMX_USE_FUNCTION_TABLE
    8775         rc = g_apfnVMExitHandlers[VmxTransient.uExitReason](pVCpu, pCtx, &VmxTransient);
     8781        rcStrict = g_apfnVMExitHandlers[VmxTransient.uExitReason](pVCpu, pCtx, &VmxTransient);
    87768782#else
    8777         rc = hmR0VmxHandleExit(pVCpu, pCtx, &VmxTransient, VmxTransient.uExitReason);
     8783        rcStrict = hmR0VmxHandleExit(pVCpu, pCtx, &VmxTransient, VmxTransient.uExitReason);
    87788784#endif
    87798785        STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit2, x);
    8780         if (rc != VINF_SUCCESS)
    8781             break;
    8782         if (cLoops > pVM->hm.s.cMaxResumeLoops)
    8783         {
     8786        if (rcStrict == VINF_SUCCESS)
     8787        {
     8788            if (cLoops <= pVM->hm.s.cMaxResumeLoops)
     8789                continue; /* likely */
    87848790            STAM_COUNTER_INC(&pVCpu->hm.s.StatSwitchMaxResumeLoops);
    8785             rc = VINF_EM_RAW_INTERRUPT;
    8786             break;
    8787         }
     8791            rcStrict = VINF_EM_RAW_INTERRUPT;
     8792        }
     8793        break;
    87888794    }
    87898795
    87908796    STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x);
    8791     return rc;
     8797    return rcStrict;
    87928798}
    87938799
     
    87968802 * Single steps guest code using VT-x.
    87978803 *
    8798  * @returns VBox status code.
     8804 * @returns Strict VBox status code.
    87998805 * @param   pVM         The cross context VM structure.
    88008806 * @param   pVCpu       The cross context virtual CPU structure.
     
    88038809 * @note    Mostly the same as hmR0VmxRunGuestCodeNormal().
    88048810 */
    8805 static int hmR0VmxRunGuestCodeStep(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
     8811static VBOXSTRICTRC hmR0VmxRunGuestCodeStep(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    88068812{
    88078813    VMXTRANSIENT VmxTransient;
     
    88258831
    88268832        hmR0VmxPreRunGuestCommitted(pVM, pVCpu, pCtx, &VmxTransient);
    8827         rcStrict = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
     8833        int rcRun = hmR0VmxRunGuest(pVM, pVCpu, pCtx);
    88288834        /* The guest-CPU context is now outdated, 'pCtx' is to be treated as 'pMixedCtx' from this point on!!! */
    88298835
     
    88338839
    88348840        /* Check for errors with running the VM (VMLAUNCH/VMRESUME). */
    8835         if (RT_UNLIKELY(rcStrict != VINF_SUCCESS))
     8841        if (RT_SUCCESS(rcRun))
     8842        { /* very likely */ }
     8843        else
    88368844        {
    88378845            STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatExit1, x);
    8838             hmR0VmxReportWorldSwitchError(pVM, pVCpu, VBOXSTRICTRC_TODO(rcStrict), pCtx, &VmxTransient);
    8839             return VBOXSTRICTRC_TODO(rcStrict);
     8846            hmR0VmxReportWorldSwitchError(pVM, pVCpu, rcRun, pCtx, &VmxTransient);
     8847            return rcRun;
    88408848        }
    88418849
     
    88488856
    88498857        VBOXVMM_R0_HMVMX_VMEXIT_NOCTX(pVCpu, pCtx, VmxTransient.uExitReason);
    8850         if (RT_UNLIKELY(VBOXVMM_R0_HMVMX_VMEXIT_ENABLED()))
     8858        if (!VBOXVMM_R0_HMVMX_VMEXIT_ENABLED())
     8859        { /* more likely */ }
     8860        else
    88518861        {
    88528862            hmR0VmxReadExitQualificationVmcs(pVCpu, &VmxTransient);
     
    88988908
    88998909    STAM_PROFILE_ADV_STOP(&pVCpu->hm.s.StatEntry, x);
    8900     return VBOXSTRICTRC_TODO(rcStrict);
     8910    return rcStrict;
    89018911}
    89028912
     
    89058915 * Runs the guest code using VT-x.
    89068916 *
    8907  * @returns VBox status code.
     8917 * @returns Strict VBox status code.
    89088918 * @param   pVM         The cross context VM structure.
    89098919 * @param   pVCpu       The cross context virtual CPU structure.
    89108920 * @param   pCtx        Pointer to the guest-CPU context.
    89118921 */
    8912 VMMR0DECL(int) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
     8922VMMR0DECL(VBOXSTRICTRC) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx)
    89138923{
    89148924    Assert(VMMRZCallRing3IsEnabled(pVCpu));
     
    89188928    VMMRZCallRing3SetNotification(pVCpu, hmR0VmxCallRing3Callback, pCtx);
    89198929
    8920     int rc;
     8930    VBOXSTRICTRC rcStrict;
    89218931    if (!pVCpu->hm.s.fSingleInstruction)
    8922         rc = hmR0VmxRunGuestCodeNormal(pVM, pVCpu, pCtx);
     8932        rcStrict = hmR0VmxRunGuestCodeNormal(pVM, pVCpu, pCtx);
    89238933    else
    8924         rc = hmR0VmxRunGuestCodeStep(pVM, pVCpu, pCtx);
    8925 
    8926     if (rc == VERR_EM_INTERPRETER)
    8927         rc = VINF_EM_RAW_EMULATE_INSTR;
    8928     else if (rc == VINF_EM_RESET)
    8929         rc = VINF_EM_TRIPLE_FAULT;
    8930 
    8931     int rc2 = hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rc);
     8934        rcStrict = hmR0VmxRunGuestCodeStep(pVM, pVCpu, pCtx);
     8935
     8936    if (rcStrict == VERR_EM_INTERPRETER)
     8937        rcStrict = VINF_EM_RAW_EMULATE_INSTR;
     8938    else if (rcStrict == VINF_EM_RESET)
     8939        rcStrict = VINF_EM_TRIPLE_FAULT;
     8940
     8941    int rc2 = hmR0VmxExitToRing3(pVM, pVCpu, pCtx, rcStrict);
    89328942    if (RT_FAILURE(rc2))
    89338943    {
    8934         pVCpu->hm.s.u32HMError = rc;
    8935         rc = rc2;
     8944        pVCpu->hm.s.u32HMError = (uint32_t)VBOXSTRICTRC_VAL(rcStrict);
     8945        rcStrict = rc2;
    89368946    }
    89378947    Assert(!VMMRZCallRing3IsNotificationSet(pVCpu));
    8938     return rc;
     8948    return rcStrict;
    89398949}
    89408950
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.h

    r58122 r58913  
    4040VMMR0DECL(int)  VMXR0SetupVM(PVM pVM);
    4141VMMR0DECL(int)  VMXR0SaveHostState(PVM pVM, PVMCPU pVCpu);
    42 VMMR0DECL(int) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
     42VMMR0DECL(VBOXSTRICTRC) VMXR0RunGuestCode(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    4343DECLASM(int)    VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu);
    4444DECLASM(int)    VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu);
  • trunk/src/VBox/VMM/include/HMInternal.h

    r58912 r58913  
    596596AssertCompileSizeAlignment(VMCSCACHE, 8);
    597597
    598 /** VMX StartVM function. */
     598/**
     599 * VMX StartVM function.
     600 *
     601 * @returns VBox status code (no informational stuff).
     602 * @param   fResume     Whether to use VMRESUME (true) or VMLAUNCH (false).
     603 * @param   pCtx        The CPU register context.
     604 * @param   pCache      The VMCS cache.
     605 * @param   pVM         Pointer to the cross context VM structure.
     606 * @param   pVCpu       Pointer to the cross context per-CPU structure.
     607 */
    599608typedef DECLCALLBACK(int) FNHMVMXSTARTVM(RTHCUINT fResume, PCPUMCTX pCtx, PVMCSCACHE pCache, PVM pVM, PVMCPU pVCpu);
    600609/** Pointer to a VMX StartVM function. */
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