VirtualBox

Changeset 92408 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Nov 12, 2021 9:49:06 PM (3 years ago)
Author:
vboxsync
Message:

VMM: Reworked most of the call-ring-3 stuff into setjmp-longjmp-on-assert and removed the stack switching/copying/resume code. bugref:10093 bugref:10124

Location:
trunk/src/VBox/VMM/VMMR3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r92392 r92408  
    165165*   Internal Functions                                                                                                           *
    166166*********************************************************************************************************************************/
    167 static int                  vmmR3InitStacks(PVM pVM);
    168167static void                 vmmR3InitRegisterStats(PVM pVM);
    169168static DECLCALLBACK(int)    vmmR3Save(PVM pVM, PSSMHANDLE pSSM);
     
    280279        return rc;
    281280
    282     /*
    283      * Init various sub-components.
    284      */
    285     rc = vmmR3InitStacks(pVM);
     281#ifdef VBOX_WITH_NMI
     282    /*
     283     * Allocate mapping for the host APIC.
     284     */
     285    rc = MMR3HyperReserve(pVM, PAGE_SIZE, "Host APIC", &pVM->vmm.s.GCPtrApicBase);
     286    AssertRC(rc);
     287#endif
    286288    if (RT_SUCCESS(rc))
    287289    {
    288 #ifdef VBOX_WITH_NMI
    289290        /*
    290          * Allocate mapping for the host APIC.
     291         * Start the log flusher thread.
    291292         */
    292         rc = MMR3HyperReserve(pVM, PAGE_SIZE, "Host APIC", &pVM->vmm.s.GCPtrApicBase);
    293         AssertRC(rc);
    294 #endif
     293        rc = RTThreadCreate(&pVM->vmm.s.hLogFlusherThread, vmmR3LogFlusher, pVM, 0 /*cbStack*/,
     294                            RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "R0LogWrk");
    295295        if (RT_SUCCESS(rc))
    296296        {
     297
    297298            /*
    298              * Start the log flusher thread.
     299             * Debug info and statistics.
    299300             */
    300             rc = RTThreadCreate(&pVM->vmm.s.hLogFlusherThread, vmmR3LogFlusher, pVM, 0 /*cbStack*/,
    301                                 RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "R0LogWrk");
    302             if (RT_SUCCESS(rc))
    303             {
    304 
    305                 /*
    306                  * Debug info and statistics.
    307                  */
    308                 DBGFR3InfoRegisterInternal(pVM, "fflags", "Displays the current Forced actions Flags.", vmmR3InfoFF);
    309                 vmmR3InitRegisterStats(pVM);
    310                 vmmInitFormatTypes();
    311 
    312                 return VINF_SUCCESS;
    313             }
     301            DBGFR3InfoRegisterInternal(pVM, "fflags", "Displays the current Forced actions Flags.", vmmR3InfoFF);
     302            vmmR3InitRegisterStats(pVM);
     303            vmmInitFormatTypes();
     304
     305            return VINF_SUCCESS;
    314306        }
    315307    }
    316308    /** @todo Need failure cleanup? */
    317 
    318     return rc;
    319 }
    320 
    321 
    322 /**
    323  * Allocate & setup the VMM RC stack(s) (for EMTs).
    324  *
    325  * The stacks are also used for long jumps in Ring-0.
    326  *
    327  * @returns VBox status code.
    328  * @param   pVM     The cross context VM structure.
    329  *
    330  * @remarks The optional guard page gets it protection setup up during R3 init
    331  *          completion because of init order issues.
    332  */
    333 static int vmmR3InitStacks(PVM pVM)
    334 {
    335     int rc = VINF_SUCCESS;
    336 #ifdef VMM_R0_SWITCH_STACK
    337     uint32_t fFlags = MMHYPER_AONR_FLAGS_KERNEL_MAPPING;
    338 #else
    339     uint32_t fFlags = 0;
    340 #endif
    341 
    342     for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++)
    343     {
    344         PVMCPU pVCpu = pVM->apCpusR3[idCpu];
    345 
    346 #ifdef VBOX_STRICT_VMM_STACK
    347         rc = MMR3HyperAllocOnceNoRelEx(pVM, PAGE_SIZE + VMM_STACK_SIZE + PAGE_SIZE,
    348 #else
    349         rc = MMR3HyperAllocOnceNoRelEx(pVM, VMM_STACK_SIZE,
    350 #endif
    351                                        PAGE_SIZE, MM_TAG_VMM, fFlags, (void **)&pVCpu->vmm.s.pbEMTStackR3);
    352         if (RT_SUCCESS(rc))
    353         {
    354 #ifdef VBOX_STRICT_VMM_STACK
    355             pVCpu->vmm.s.pbEMTStackR3 += PAGE_SIZE;
    356 #endif
    357             pVCpu->vmm.s.CallRing3JmpBufR0.pvSavedStack = MMHyperR3ToR0(pVM, pVCpu->vmm.s.pbEMTStackR3);
    358 
    359         }
    360     }
    361309
    362310    return rc;
     
    433381    STAMR3Register(pVM, &pVM->vmm.s.StatLogFlusherNoWakeUp, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, "/VMM/LogFlush/00-NoWakups", STAMUNIT_OCCURENCES, "Times the flusher thread didn't need waking up.");
    434382
    435 #ifdef VBOX_WITH_STATISTICS
    436     for (VMCPUID i = 0; i < pVM->cCpus; i++)
    437     {
    438         PVMCPU pVCpu = pVM->apCpusR3[i];
    439         STAMR3RegisterF(pVM, &pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedMax,  STAMTYPE_U32_RESET, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      "Max amount of stack used.", "/VMM/Stack/CPU%u/Max", i);
    440         STAMR3RegisterF(pVM, &pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedAvg,  STAMTYPE_U32,       STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES,      "Average stack usage.",      "/VMM/Stack/CPU%u/Avg", i);
    441         STAMR3RegisterF(pVM, &pVCpu->vmm.s.CallRing3JmpBufR0.cUsedTotal, STAMTYPE_U64,       STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of stack usages.",   "/VMM/Stack/CPU%u/Uses", i);
    442     }
    443 #endif
    444383    for (VMCPUID i = 0; i < pVM->cCpus; i++)
    445384    {
     
    22652204    AssertReturn(cbRead < ~(size_t)0 / 2, VERR_INVALID_PARAMETER);
    22662205
    2267     int rc;
    2268 #ifdef VMM_R0_SWITCH_STACK
    2269     RTHCUINTPTR off = R0Addr - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3);
    2270 #else
    2271     RTHCUINTPTR off = pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack - (pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck - R0Addr);
    2272 #endif
    2273     if (   off < VMM_STACK_SIZE
    2274         && off + cbRead <= VMM_STACK_SIZE)
    2275     {
    2276         memcpy(pvBuf, &pVCpu->vmm.s.pbEMTStackR3[off], cbRead);
    2277         rc = VINF_SUCCESS;
     2206    /*
     2207     * Hopefully we've got all the requested bits.  If not supply what we
     2208     * can and zero the remaining stuff.
     2209     */
     2210    RTHCUINTPTR off = R0Addr - pVCpu->vmm.s.AssertJmpBuf.UnwindSp;
     2211    if (off < pVCpu->vmm.s.AssertJmpBuf.cbStackValid)
     2212    {
     2213        size_t const cbValid = pVCpu->vmm.s.AssertJmpBuf.cbStackValid - off;
     2214        if (cbRead <= cbValid)
     2215        {
     2216            memcpy(pvBuf, &pVCpu->vmm.s.abAssertStack[off], cbRead);
     2217            return VINF_SUCCESS;
     2218        }
     2219
     2220        memcpy(pvBuf, &pVCpu->vmm.s.abAssertStack[off], cbValid);
     2221        RT_BZERO((uint8_t *)pvBuf + cbValid, cbRead - cbValid);
    22782222    }
    22792223    else
    2280         rc = VERR_INVALID_POINTER;
    2281 
    2282     /* Supply the setjmp return RIP/EIP.  */
    2283     if (   pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation + sizeof(RTR0UINTPTR) > R0Addr
    2284         && pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation < R0Addr + cbRead)
    2285     {
    2286         uint8_t const  *pbSrc  = (uint8_t const *)&pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcValue;
    2287         size_t          cbSrc  = sizeof(pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcValue);
     2224        RT_BZERO(pvBuf, cbRead);
     2225
     2226    /*
     2227     * Supply the setjmp return RIP/EIP if requested.
     2228     */
     2229    if (   pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation + sizeof(RTR0UINTPTR) > R0Addr
     2230        && pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation < R0Addr + cbRead)
     2231    {
     2232        uint8_t const  *pbSrc  = (uint8_t const *)&pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcValue;
     2233        size_t          cbSrc  = sizeof(pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcValue);
    22882234        size_t          offDst = 0;
    2289         if (R0Addr < pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation)
    2290             offDst = pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation - R0Addr;
    2291         else if (R0Addr > pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation)
    2292         {
    2293             size_t offSrc = R0Addr - pVCpu->vmm.s.CallRing3JmpBufR0.UnwindRetPcLocation;
     2235        if (R0Addr < pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation)
     2236            offDst = pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation - R0Addr;
     2237        else if (R0Addr > pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation)
     2238        {
     2239            size_t offSrc = R0Addr - pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation;
    22942240            Assert(offSrc < cbSrc);
    22952241            pbSrc -= offSrc;
     
    23002246        memcpy((uint8_t *)pvBuf + offDst, pbSrc, cbSrc);
    23012247
    2302         if (cbSrc == cbRead)
    2303             rc = VINF_SUCCESS;
    2304     }
    2305 
    2306     return rc;
     2248        //if (cbSrc == cbRead)
     2249        //    rc = VINF_SUCCESS;
     2250    }
     2251
     2252    return VINF_SUCCESS;
    23072253}
    23082254
     
    23212267
    23222268    /*
     2269     * This is all we really need here if we had proper unwind info (win64 only)...
     2270     */
     2271    pState->u.x86.auRegs[X86_GREG_xBP] = pVCpu->vmm.s.AssertJmpBuf.UnwindBp;
     2272    pState->u.x86.auRegs[X86_GREG_xSP] = pVCpu->vmm.s.AssertJmpBuf.UnwindSp;
     2273    pState->uPc                        = pVCpu->vmm.s.AssertJmpBuf.UnwindPc;
     2274
     2275    /*
    23232276     * Locate the resume point on the stack.
    23242277     */
    2325 #ifdef VMM_R0_SWITCH_STACK
    2326     uintptr_t off = pVCpu->vmm.s.CallRing3JmpBufR0.SpResume - MMHyperCCToR0(pVCpu->pVMR3, pVCpu->vmm.s.pbEMTStackR3);
    2327     AssertReturnVoid(off < VMM_STACK_SIZE);
    2328 #else
    23292278    uintptr_t off = 0;
    2330 #endif
    23312279
    23322280#ifdef RT_ARCH_AMD64
    23332281    /*
    2334      * This code must match the .resume stuff in VMMR0JmpA-amd64.asm exactly.
    2335      */
    2336 # ifdef VBOX_STRICT
    2337     Assert(*(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off] == UINT32_C(0x7eadf00d));
    2338     off += 8; /* RESUME_MAGIC */
    2339 # endif
     2282     * This code must match the vmmR0CallRing3LongJmp stack frame setup in VMMR0JmpA-amd64.asm exactly.
     2283     */
    23402284# ifdef RT_OS_WINDOWS
    23412285    off += 0xa0; /* XMM6 thru XMM15 */
    23422286# endif
    2343     pState->u.x86.uRFlags              = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2287    pState->u.x86.uRFlags              = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23442288    off += 8;
    2345     pState->u.x86.auRegs[X86_GREG_xBX] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2289    pState->u.x86.auRegs[X86_GREG_xBX] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23462290    off += 8;
    23472291# ifdef RT_OS_WINDOWS
    2348     pState->u.x86.auRegs[X86_GREG_xSI] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2292    pState->u.x86.auRegs[X86_GREG_xSI] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23492293    off += 8;
    2350     pState->u.x86.auRegs[X86_GREG_xDI] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2294    pState->u.x86.auRegs[X86_GREG_xDI] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23512295    off += 8;
    23522296# endif
    2353     pState->u.x86.auRegs[X86_GREG_x12] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2297    pState->u.x86.auRegs[X86_GREG_x12] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23542298    off += 8;
    2355     pState->u.x86.auRegs[X86_GREG_x13] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2299    pState->u.x86.auRegs[X86_GREG_x13] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23562300    off += 8;
    2357     pState->u.x86.auRegs[X86_GREG_x14] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2301    pState->u.x86.auRegs[X86_GREG_x14] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23582302    off += 8;
    2359     pState->u.x86.auRegs[X86_GREG_x15] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2303    pState->u.x86.auRegs[X86_GREG_x15] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23602304    off += 8;
    2361     pState->u.x86.auRegs[X86_GREG_xBP] = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2305    pState->u.x86.auRegs[X86_GREG_xBP] = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23622306    off += 8;
    2363     pState->uPc                        = *(uint64_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
    2364     off += 8;
     2307    pState->uPc                        = *(uint64_t const *)&pVCpu->vmm.s.abAssertStack[off];
     2308    pState->u.x86.auRegs[X86_GREG_xSP] = pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp;
    23652309
    23662310#elif defined(RT_ARCH_X86)
    23672311    /*
    2368      * This code must match the .resume stuff in VMMR0JmpA-x86.asm exactly.
    2369      */
    2370 # ifdef VBOX_STRICT
    2371     Assert(*(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off] == UINT32_C(0x7eadf00d));
    2372     off += 4; /* RESUME_MAGIC */
    2373 # endif
    2374     pState->u.x86.uRFlags              = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2312     * This code must match the vmmR0CallRing3LongJmp stack frame setup in VMMR0JmpA-x86.asm exactly.
     2313     */
     2314    pState->u.x86.uRFlags              = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23752315    off += 4;
    2376     pState->u.x86.auRegs[X86_GREG_xBX] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2316    pState->u.x86.auRegs[X86_GREG_xBX] = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23772317    off += 4;
    2378     pState->u.x86.auRegs[X86_GREG_xSI] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2318    pState->u.x86.auRegs[X86_GREG_xSI] = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23792319    off += 4;
    2380     pState->u.x86.auRegs[X86_GREG_xDI] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2320    pState->u.x86.auRegs[X86_GREG_xDI] = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23812321    off += 4;
    2382     pState->u.x86.auRegs[X86_GREG_xBP] = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
     2322    pState->u.x86.auRegs[X86_GREG_xBP] = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
    23832323    off += 4;
    2384     pState->uPc                        = *(uint32_t const *)&pVCpu->vmm.s.pbEMTStackR3[off];
    2385     off += 4;
     2324    pState->uPc                        = *(uint32_t const *)&pVCpu->vmm.s.abAssertStack[off];
     2325    pState->u.x86.auRegs[X86_GREG_xSP] = pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp;
    23862326#else
    23872327# error "Port me"
    23882328#endif
    2389 
    2390     /*
    2391      * This is all we really need here, though the above helps if the assembly
    2392      * doesn't contain unwind info (currently only on win/64, so that is useful).
    2393      */
    2394     pState->u.x86.auRegs[X86_GREG_xBP] = pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp;
    2395     pState->u.x86.auRegs[X86_GREG_xSP] = pVCpu->vmm.s.CallRing3JmpBufR0.SpResume;
    23962329}
    23972330
     
    24642397static int vmmR3HandleRing0Assert(PVM pVM, PVMCPU pVCpu)
    24652398{
    2466     /*
    2467      * Signal a ring 0 hypervisor assertion.
    2468      * Cancel the longjmp operation that's in progress.
    2469      */
    2470     pVCpu->vmm.s.CallRing3JmpBufR0.fInRing3Call = false;
    2471 #ifdef RT_ARCH_X86
    2472     pVCpu->vmm.s.CallRing3JmpBufR0.eip = 0;
    2473 #else
    2474     pVCpu->vmm.s.CallRing3JmpBufR0.rip = 0;
    2475 #endif
    2476 #ifdef VMM_R0_SWITCH_STACK
    2477     *(uint64_t *)pVCpu->vmm.s.pbEMTStackR3 = 0; /* clear marker  */
    2478 #endif
     2399    RT_NOREF(pVCpu);
    24792400    LogRel(("%s", pVM->vmm.s.szRing0AssertMsg1));
    24802401    LogRel(("%s", pVM->vmm.s.szRing0AssertMsg2));
  • trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp

    r90829 r92408  
    362362        case VINF_EM_TRIPLE_FAULT:
    363363        case VERR_VMM_HYPER_CR3_MISMATCH:
    364         case VERR_VMM_SET_JMP_ERROR:
    365         case VERR_VMM_SET_JMP_ABORTED_RESUME:
    366         case VERR_VMM_SET_JMP_STACK_OVERFLOW:
    367364        case VERR_VMM_LONG_JMP_ERROR:
    368365        {
     
    398395             * Dump the relevant hypervisor registers and stack.
    399396             */
    400             if (   rcErr == VERR_VMM_RING0_ASSERTION /* fInRing3Call has already been cleared here. */
    401                 || pVCpu->vmm.s.CallRing3JmpBufR0.fInRing3Call)
     397            if (rcErr == VERR_VMM_RING0_ASSERTION)
    402398            {
    403399                /* Dump the jmpbuf.  */
    404400                pHlp->pfnPrintf(pHlp,
    405401                                "!!\n"
    406                                 "!! CallRing3JmpBuf:\n"
     402                                "!! AssertJmpBuf:\n"
    407403                                "!!\n");
    408404                pHlp->pfnPrintf(pHlp,
    409                                 "SavedEsp=%RHv SavedEbp=%RHv SpResume=%RHv SpCheck=%RHv\n",
    410                                 pVCpu->vmm.s.CallRing3JmpBufR0.SavedEsp,
    411                                 pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp,
    412                                 pVCpu->vmm.s.CallRing3JmpBufR0.SpResume,
    413                                 pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck);
    414                 pHlp->pfnPrintf(pHlp,
    415                                 "pvSavedStack=%RHv cbSavedStack=%#x  fInRing3Call=%RTbool\n",
    416                                 pVCpu->vmm.s.CallRing3JmpBufR0.pvSavedStack,
    417                                 pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack,
    418                                 pVCpu->vmm.s.CallRing3JmpBufR0.fInRing3Call);
    419                 pHlp->pfnPrintf(pHlp,
    420                                 "cbUsedMax=%#x cbUsedAvg=%#x cbUsedTotal=%#llx cUsedTotal=%#llx\n",
    421                                 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedMax,
    422                                 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedAvg,
    423                                 pVCpu->vmm.s.CallRing3JmpBufR0.cbUsedTotal,
    424                                 pVCpu->vmm.s.CallRing3JmpBufR0.cUsedTotal);
     405                                "UnwindSp=%RHv UnwindRetSp=%RHv UnwindBp=%RHv UnwindPc=%RHv\n",
     406                                pVCpu->vmm.s.AssertJmpBuf.UnwindSp,
     407                                pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp,
     408                                pVCpu->vmm.s.AssertJmpBuf.UnwindBp,
     409                                pVCpu->vmm.s.AssertJmpBuf.UnwindPc);
     410                pHlp->pfnPrintf(pHlp,
     411                                "UnwindRetPcValue=%RHv UnwindRetPcLocation=%RHv\n",
     412                                pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcValue,
     413                                pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation);
    425414                pHlp->pfnPrintf(pHlp,
    426415                                "pfn=%RHv pvUser1=%RHv pvUser2=%RHv\n",
    427                                 pVCpu->vmm.s.CallRing3JmpBufR0.pfn,
    428                                 pVCpu->vmm.s.CallRing3JmpBufR0.pvUser1,
    429                                 pVCpu->vmm.s.CallRing3JmpBufR0.pvUser2);
     416                                pVCpu->vmm.s.AssertJmpBuf.pfn,
     417                                pVCpu->vmm.s.AssertJmpBuf.pvUser1,
     418                                pVCpu->vmm.s.AssertJmpBuf.pvUser2);
    430419
    431420                /* Dump the resume register frame on the stack. */
    432                 PRTHCUINTPTR pBP;
    433 #ifdef VMM_R0_SWITCH_STACK
    434                 pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.pbEMTStackR3[  pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp
    435                                                                - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3)];
    436 #else
    437                 pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.pbEMTStackR3[  pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack
    438                                                                - pVCpu->vmm.s.CallRing3JmpBufR0.SpCheck
    439                                                                + pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp];
    440 #endif
     421                PRTHCUINTPTR const pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.abAssertStack[  pVCpu->vmm.s.AssertJmpBuf.UnwindBp
     422                                                                                   - pVCpu->vmm.s.AssertJmpBuf.UnwindSp];
    441423#if HC_ARCH_BITS == 32
    442424                pHlp->pfnPrintf(pHlp,
     
    445427                                ,
    446428                                pBP[-3], pBP[-2], pBP[-1],
    447                                 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 8, pBP[0], pBP[-4]);
     429                                pBP[1], pVCpu->vmm.s.AssertJmpBuf.SavedEbp - 8, pBP[0], pBP[-4]);
    448430#else
    449431# ifdef RT_OS_WINDOWS
     
    459441                                pBP[-4], pBP[-3],
    460442                                pBP[-2], pBP[-1],
    461                                 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 16, pBP[0], pBP[-8]);
     443                                pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-8]);
    462444# else
    463445                pHlp->pfnPrintf(pHlp,
     
    471453                                pBP[-4], pBP[-3],
    472454                                pBP[-2], pBP[-1],
    473                                 pBP[1], pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp - 16, pBP[0], pBP[-6]);
     455                                pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-6]);
    474456# endif
    475457#endif
     
    479461                PCDBGFSTACKFRAME pFirstFrame;
    480462                rc2 = DBGFR3StackWalkBeginEx(pVM->pUVM, pVCpu->idCpu, DBGFCODETYPE_RING0,
    481                                              DBGFR3AddrFromHostR0(&AddrBp, pVCpu->vmm.s.CallRing3JmpBufR0.SavedEbp),
    482                                              DBGFR3AddrFromHostR0(&AddrSp, pVCpu->vmm.s.CallRing3JmpBufR0.SpResume),
    483                                              DBGFR3AddrFromHostR0(&AddrPc, pVCpu->vmm.s.CallRing3JmpBufR0.SavedEipForUnwind),
     463                                             DBGFR3AddrFromHostR0(&AddrBp, pVCpu->vmm.s.AssertJmpBuf.UnwindBp),
     464                                             DBGFR3AddrFromHostR0(&AddrSp, pVCpu->vmm.s.AssertJmpBuf.UnwindSp),
     465                                             DBGFR3AddrFromHostR0(&AddrPc, pVCpu->vmm.s.AssertJmpBuf.UnwindPc),
    484466                                             RTDBGRETURNTYPE_INVALID, &pFirstFrame);
    485467                if (RT_SUCCESS(rc2))
     
    548530
    549531                /* Symbols on the stack. */
    550 #ifdef VMM_R0_SWITCH_STACK
    551                 uint32_t const   iLast   = VMM_STACK_SIZE / sizeof(uintptr_t);
    552                 uint32_t         iAddr   = (uint32_t)(  pVCpu->vmm.s.CallRing3JmpBufR0.SavedEsp
    553                                                       - MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3)) / sizeof(uintptr_t);
    554                 if (iAddr > iLast)
    555                     iAddr = 0;
    556 #else
    557                 uint32_t const   iLast   = RT_MIN(pVCpu->vmm.s.CallRing3JmpBufR0.cbSavedStack, VMM_STACK_SIZE)
    558                                          / sizeof(uintptr_t);
    559                 uint32_t         iAddr   = 0;
    560 #endif
     532                uint32_t const          cbRawStack = RT_MIN(pVCpu->vmm.s.AssertJmpBuf.cbStackValid, sizeof(pVCpu->vmm.s.abAssertStack));
     533                uintptr_t const * const pauAddr    = (uintptr_t const *)&pVCpu->vmm.s.abAssertStack[0];
     534                uint32_t const          iEnd       = cbRawStack / sizeof(uintptr_t);
     535                uint32_t                iAddr      = 0;
    561536                pHlp->pfnPrintf(pHlp,
    562537                                "!!\n"
    563                                 "!! Addresses on the stack (iAddr=%#x, iLast=%#x)\n"
     538                                "!! Addresses on the stack (iAddr=%#x, iEnd=%#x)\n"
    564539                                "!!\n",
    565                                 iAddr, iLast);
    566                 uintptr_t const *paAddr  = (uintptr_t const *)pVCpu->vmm.s.pbEMTStackR3;
    567                 while (iAddr < iLast)
     540                                iAddr, iEnd);
     541                while (iAddr < iEnd)
    568542                {
    569                     uintptr_t const uAddr = paAddr[iAddr];
     543                    uintptr_t const uAddr = pauAddr[iAddr];
    570544                    if (uAddr > X86_PAGE_SIZE)
    571545                    {
    572546                        DBGFADDRESS  Addr;
    573547                        DBGFR3AddrFromFlat(pVM->pUVM, &Addr, uAddr);
    574                         RTGCINTPTR   offDisp = 0;
    575                         PRTDBGSYMBOL pSym  = DBGFR3AsSymbolByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr,
    576                                                                    RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
    577                                                                    &offDisp, NULL);
    578                         RTGCINTPTR   offLineDisp;
    579                         PRTDBGLINE   pLine = DBGFR3AsLineByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr, &offLineDisp, NULL);
     548                        RTGCINTPTR   offDisp     = 0;
     549                        RTGCINTPTR   offLineDisp = 0;
     550                        PRTDBGSYMBOL pSym        = DBGFR3AsSymbolByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr,
     551                                                                           RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL
     552                                                                         | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
     553                                                                         &offDisp, NULL);
     554                        PRTDBGLINE   pLine       = DBGFR3AsLineByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr, &offLineDisp, NULL);
    580555                        if (pLine || pSym)
    581556                        {
     
    599574                                "!!\n"
    600575                                "!! Raw stack (mind the direction).\n"
    601                                 "!! pbEMTStackR0=%RHv pbEMTStackBottomR0=%RHv VMM_STACK_SIZE=%#x\n"
     576                                "!! pbEMTStackR0=%RHv cbRawStack=%#x\n"
    602577                                "!! pbEmtStackR3=%p\n"
    603578                                "!!\n"
    604579                                "%.*Rhxd\n",
    605                                 MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3),
    606                                 MMHyperCCToR0(pVM, pVCpu->vmm.s.pbEMTStackR3) + VMM_STACK_SIZE,
    607                                 VMM_STACK_SIZE,
    608                                 pVCpu->vmm.s.pbEMTStackR3,
    609                                 VMM_STACK_SIZE, pVCpu->vmm.s.pbEMTStackR3);
     580                                pVCpu->vmm.s.AssertJmpBuf.UnwindSp, cbRawStack,
     581                                &pVCpu->vmm.s.abAssertStack[0],
     582                                cbRawStack, &pVCpu->vmm.s.abAssertStack[0]);
    610583            }
    611584            else
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