VirtualBox

Changeset 72689 in vbox


Ignore:
Timestamp:
Jun 26, 2018 2:37:40 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123206
Message:

NEM/win: Redid the IoCtlMessageSlotHandleAndGetNext stuff during nemHCWinStopCpu(). Ran into issue with DRx syncing, added todo. bugref:9044

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

Legend:

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

    r72676 r72689  
    15711571{
    15721572    pVCpu->cpum.s.Guest.dr[6] = uDr6;
     1573    pVCpu->cpum.s.Guest.fExtrn &= ~CPUMCTX_EXTRN_DR6;
    15731574    return VINF_SUCCESS; /* No need to recalc. */
    15741575}
     
    15781579{
    15791580    pVCpu->cpum.s.Guest.dr[7] = uDr7;
     1581    pVCpu->cpum.s.Guest.fExtrn &= ~CPUMCTX_EXTRN_DR7;
    15801582    return CPUMRecalcHyperDRx(pVCpu, 7, false);
    15811583}
  • trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h

    r72687 r72689  
    37233723
    37243724
     3725#ifdef IN_RING0
     3726/**
     3727 * Perform an I/O control operation on the partition handle (VID.SYS),
     3728 * restarting on alert-like behaviour.
     3729 *
     3730 * @returns NT status code.
     3731 * @param   pGVM            The ring-0 VM structure.
     3732 * @param   pGVCpu          The ring-0 CPU structure.
     3733 * @param   pVCpu           The calling cross context CPU structure.
     3734 * @param   fFlags          The wait flags.
     3735 * @param   cMillies        The timeout in milliseconds
     3736 */
     3737static NTSTATUS nemR0NtPerformIoCtlMessageSlotHandleAndGetNext(PGVM pGVM, PGVMCPU pGVCpu, PVMCPU pVCpu,
     3738                                                               uint32_t fFlags, uint32_t cMillies)
     3739{
     3740    pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
     3741    pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = fFlags;
     3742    pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = cMillies;
     3743    NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
     3744                                            &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
     3745                                            sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext),
     3746                                            NULL, 0);
     3747    if (rcNt == STATUS_SUCCESS)
     3748    { /* likely */ }
     3749    /*
     3750     * Generally, if we get down here, we have been interrupted between ACK'ing
     3751     * a message and waiting for the next due to a NtAlertThread call.  So, we
     3752     * should stop ACK'ing the previous message and get on waiting on the next.
     3753     * See similar stuff in nemHCWinRunGC().
     3754     */
     3755    else if (   rcNt == STATUS_TIMEOUT
     3756             || rcNt == STATUS_ALERTED    /* just in case */
     3757             || rcNt == STATUS_KERNEL_APC /* just in case */
     3758             || rcNt == STATUS_USER_APC   /* just in case */)
     3759    {
     3760        DBGFTRACE_CUSTOM(pVCpu->CTX_SUFF(pVM), "IoCtlMessageSlotHandleAndGetNextRestart/1 %#x (f=%#x)", rcNt, fFlags);
     3761        STAM_REL_COUNTER_INC(&pVCpu->nem.s.StatStopCpuPendingOdd);
     3762        Assert(fFlags & VID_MSHAGN_F_GET_NEXT_MESSAGE);
     3763
     3764        pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pVCpu->idCpu;
     3765        pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = fFlags & ~VID_MSHAGN_F_HANDLE_MESSAGE;
     3766        pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = cMillies;
     3767        rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
     3768                                       &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
     3769                                       sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext),
     3770                                       NULL, 0);
     3771        DBGFTRACE_CUSTOM(pVCpu->CTX_SUFF(pVM), "IoCtlMessageSlotHandleAndGetNextRestart/2 %#x", rcNt);
     3772    }
     3773    return rcNt;
     3774}
     3775
     3776#endif /* IN_RING0 */
     3777
     3778
    37253779#ifdef NEM_WIN_USE_OUR_OWN_RUN_API
    37263780/**
     
    37993853     */
    38003854# ifdef IN_RING0
    3801     pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
    3802     pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = VID_MSHAGN_F_GET_NEXT_MESSAGE;
    3803     pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = 30000; /*ms*/
    3804     rcNt = nemR0NtPerformIoControlRestart(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
    3805                                           &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
    3806                                           sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext));
     3855    rcNt = nemR0NtPerformIoCtlMessageSlotHandleAndGetNext(pGVM, pGVCpu, pVCpu, VID_MSHAGN_F_GET_NEXT_MESSAGE, 30000 /*ms*/);
    38073856    DBGFTRACE_CUSTOM(pVM, "nemStop#1: %#x / %#x %#x %#x", rcNt, pMappingHeader->enmVidMsgType, pMappingHeader->cbMessage,
    38083857                     pMsgForTrace->Header.MessageType);
     
    38323881         */
    38333882# ifdef IN_RING0
    3834         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
    3835         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE;
    3836         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = 30000; /*ms*/
    3837         rcNt = nemR0NtPerformIoControlRestart(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
    3838                                               &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
    3839                                               sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext));
     3883        rcNt = nemR0NtPerformIoCtlMessageSlotHandleAndGetNext(pGVM, pGVCpu, pVCpu,
     3884                                                              VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE,
     3885                                                              30000 /*ms*/);
    38403886        DBGFTRACE_CUSTOM(pVM, "nemStop#2: %#x / %#x %#x %#x", rcNt, pMappingHeader->enmVidMsgType, pMappingHeader->cbMessage,
    38413887                         pMsgForTrace->Header.MessageType);
     
    38633909         */
    38643910# ifdef IN_RING0
    3865         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu     = pGVCpu->idCpu;
    3866         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags   = VID_MSHAGN_F_HANDLE_MESSAGE;
    3867         pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.cMillies = 30000; /*ms*/
    3868         rcNt = nemR0NtPerformIoControlRestart(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction,
    3869                                               &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext,
    3870                                               sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext));
     3911        rcNt = nemR0NtPerformIoCtlMessageSlotHandleAndGetNext(pGVM, pGVCpu, pVCpu, VID_MSHAGN_F_HANDLE_MESSAGE, 30000 /*ms*/);
    38713912        DBGFTRACE_CUSTOM(pVM, "nemStop#3: %#x / %#x %#x %#x", rcNt, pMappingHeader->enmVidMsgType,
    38723913                         pMsgForTrace->Header.MessageType, pMappingHeader->cbMessage, pMsgForTrace->Header.MessageType);
     
    42144255                    LogFlow(("NEM/%u: VidMessageSlotHandleAndGetNext -> %#x\n", pVCpu->idCpu, rcNt));
    42154256                    AssertLogRelMsgReturn(   rcNt == STATUS_TIMEOUT
    4216                                           || rcNt == STATUS_ALERTED  /* just in case */
    4217                                           || rcNt == STATUS_USER_APC /* ditto */
     4257                                          || rcNt == STATUS_ALERTED    /* just in case */
     4258                                          || rcNt == STATUS_USER_APC   /* ditto */
     4259                                          || rcNt == STATUS_KERNEL_APC /* ditto */
    42184260                                          , ("VidMessageSlotHandleAndGetNext failed for CPU #%u: %#x (%u)\n",
    42194261                                             pVCpu->idCpu, rcNt, rcNt),
     
    42254267                                                 pVCpu->idCpu, hrc, GetLastError()),
    42264268                                                VERR_NEM_IPE_0);
    4227 
    42284269# endif
    42294270                }
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r72687 r72689  
    8888DECLINLINE(NTSTATUS) nemR0NtPerformIoControl(PGVM pGVM, uint32_t uFunction, void *pvInput, uint32_t cbInput,
    8989                                             void *pvOutput, uint32_t cbOutput);
    90 DECLINLINE(NTSTATUS) nemR0NtPerformIoControlRestart(PGVM pGVM, uint32_t uFunction, void *pvInput, uint32_t cbInput);
    9190
    9291
     
    271270
    272271/**
    273  * Perform an I/O control operation on the partition handle (VID.SYS),
    274  * restarting on alert-like behaviour.
    275  *
    276  * @returns NT status code.
    277  * @param   pGVM            The ring-0 VM structure.
    278  * @param   uFunction       The function to perform.
    279  * @param   pvInput         The input buffer.  This must point within the VM
    280  *                          structure so we can easily convert to a ring-3
    281  *                          pointer if necessary.
    282  * @param   cbInput         The size of the input.  @a pvInput must be NULL when
    283  *                          zero.
    284  */
    285 DECLINLINE(NTSTATUS) nemR0NtPerformIoControlRestart(PGVM pGVM, uint32_t uFunction, void *pvInput, uint32_t cbInput)
    286 {
    287 #ifdef RT_STRICT
    288     /*
    289      * Input and output parameters are part of the VM CPU structure.
    290      */
    291     PVM          pVM  = pGVM->pVM;
    292     size_t const cbVM = RT_UOFFSETOF(VM, aCpus[pGVM->cCpus]);
    293     if (pvInput)
    294         AssertReturn(((uintptr_t)pvInput + cbInput) - (uintptr_t)pVM <= cbVM, VERR_INVALID_PARAMETER);
    295 #endif
    296 
    297     int32_t rcNt = STATUS_UNSUCCESSFUL;
    298     int rc = SUPR0IoCtlPerform(pGVM->nem.s.pIoCtlCtx, uFunction,
    299                                pvInput,
    300                                pvInput ? (uintptr_t)pvInput  + pGVM->nem.s.offRing3ConversionDelta : NIL_RTR3PTR,
    301                                cbInput,
    302                                NULL,
    303                                NIL_RTR3PTR,
    304                                0,
    305                                &rcNt);
    306     if (RT_SUCCESS(rc) || !NT_SUCCESS((NTSTATUS)rcNt))
    307     {
    308         if (RT_LIKELY(rcNt == STATUS_SUCCESS))
    309             return rcNt;
    310 
    311         if (   rcNt == STATUS_TIMEOUT
    312             || rcNt == STATUS_ALERTED)
    313         {
    314             DBGFTRACE_CUSTOM(pVM, "nemR0NtPerformIoControlRestart/1 %#x", rcNt);
    315             rcNt = STATUS_UNSUCCESSFUL;
    316             rc = SUPR0IoCtlPerform(pGVM->nem.s.pIoCtlCtx, uFunction,
    317                                    pvInput,
    318                                    pvInput ? (uintptr_t)pvInput  + pGVM->nem.s.offRing3ConversionDelta : NIL_RTR3PTR,
    319                                    cbInput,
    320                                    NULL,
    321                                    NIL_RTR3PTR,
    322                                    0,
    323                                    &rcNt);
    324             if (!RT_SUCCESS(rc) && NT_SUCCESS((NTSTATUS)rcNt))
    325                 rcNt = STATUS_UNSUCCESSFUL;
    326             DBGFTRACE_CUSTOM(pVM, "nemR0NtPerformIoControlRestart/2 %#x", rcNt);
    327         }
    328         return (NTSTATUS)rcNt;
    329     }
    330     return STATUS_UNSUCCESSFUL;
    331 }
    332 
    333 
    334 /**
    335272 * 2nd part of the initialization, after we've got a partition handle.
    336273 *
     
    18101747    /* Debug registers. */
    18111748/** @todo fixme */
     1749/** @todo There are recalc issues here. Recalc will get register content and
     1750 * that may assert since we doesn't clear CPUMCTX_EXTRN_ until the end. */
    18121751    if (fWhat & CPUMCTX_EXTRN_DR0_DR3)
    18131752    {
Note: See TracChangeset for help on using the changeset viewer.

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