VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR3/VMMGuruMeditation.cpp

Last change on this file was 107227, checked in by vboxsync, 6 weeks ago

VMM: Cleaning up ARMv8 / x86 split. jiraref:VBP-1470

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 27.3 KB
Line 
1/* $Id: VMMGuruMeditation.cpp 107227 2024-12-04 15:20:14Z vboxsync $ */
2/** @file
3 * VMM - The Virtual Machine Monitor, Guru Meditation Code.
4 */
5
6/*
7 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#define LOG_GROUP LOG_GROUP_VMM
33#include <VBox/vmm/vmm.h>
34#include <VBox/vmm/pdmapi.h>
35#include <VBox/vmm/pdmcritsect.h>
36#include <VBox/vmm/trpm.h>
37#include <VBox/vmm/dbgf.h>
38#include "VMMInternal.h"
39#include <VBox/vmm/vm.h>
40#include <VBox/vmm/mm.h>
41#include <VBox/vmm/iom.h>
42#include <VBox/vmm/em.h>
43
44#include <VBox/err.h>
45#include <VBox/param.h>
46#include <VBox/version.h>
47#include <VBox/vmm/hm.h>
48#include <iprt/assert.h>
49#include <iprt/dbg.h>
50#include <iprt/time.h>
51#include <iprt/stream.h>
52#include <iprt/string.h>
53#include <iprt/stdarg.h>
54
55
56/*********************************************************************************************************************************
57* Structures and Typedefs *
58*********************************************************************************************************************************/
59/**
60 * Structure to pass to DBGFR3Info() and for doing all other
61 * output during fatal dump.
62 */
63typedef struct VMMR3FATALDUMPINFOHLP
64{
65 /** The helper core. */
66 DBGFINFOHLP Core;
67 /** The release logger instance. */
68 PRTLOGGER pRelLogger;
69 /** The saved release logger flags. */
70 uint32_t fRelLoggerFlags;
71 /** The logger instance. */
72 PRTLOGGER pLogger;
73 /** The saved logger flags. */
74 uint32_t fLoggerFlags;
75 /** The saved logger destination flags. */
76 uint32_t fLoggerDestFlags;
77 /** Whether to output to stderr or not. */
78 bool fStdErr;
79 /** Whether we're still recording the summary or not. */
80 bool fRecSummary;
81 /** Buffer for the summary. */
82 char szSummary[4096 - 2];
83 /** The current summary offset. */
84 size_t offSummary;
85 /** Standard error buffer. */
86 char achStdErrBuf[4096 - 8];
87 /** Standard error buffer offset. */
88 size_t offStdErrBuf;
89} VMMR3FATALDUMPINFOHLP, *PVMMR3FATALDUMPINFOHLP;
90/** Pointer to a VMMR3FATALDUMPINFOHLP structure. */
91typedef const VMMR3FATALDUMPINFOHLP *PCVMMR3FATALDUMPINFOHLP;
92
93
94/**
95 * Flushes the content of achStdErrBuf, setting offStdErrBuf to zero.
96 *
97 * @param pHlp The instance to flush.
98 */
99static void vmmR3FatalDumpInfoHlpFlushStdErr(PVMMR3FATALDUMPINFOHLP pHlp)
100{
101 size_t cch = pHlp->offStdErrBuf;
102 if (cch)
103 {
104 RTStrmWrite(g_pStdErr, pHlp->achStdErrBuf, cch);
105 pHlp->offStdErrBuf = 0;
106 }
107}
108
109/**
110 * @callback_method_impl{FNRTSTROUTPUT, For buffering stderr output.}
111 */
112static DECLCALLBACK(size_t) vmmR3FatalDumpInfoHlp_BufferedStdErrOutput(void *pvArg, const char *pachChars, size_t cbChars)
113{
114 PVMMR3FATALDUMPINFOHLP pHlp = (PVMMR3FATALDUMPINFOHLP)pvArg;
115 if (cbChars)
116 {
117 size_t offBuf = pHlp->offStdErrBuf;
118 if (cbChars < sizeof(pHlp->achStdErrBuf) - offBuf)
119 { /* likely */ }
120 else
121 {
122 vmmR3FatalDumpInfoHlpFlushStdErr(pHlp);
123 if (cbChars < sizeof(pHlp->achStdErrBuf))
124 offBuf = 0;
125 else
126 {
127 RTStrmWrite(g_pStdErr, pachChars, cbChars);
128 return cbChars;
129 }
130 }
131 memcpy(&pHlp->achStdErrBuf[offBuf], pachChars, cbChars);
132 pHlp->offStdErrBuf = offBuf + cbChars;
133 }
134 return cbChars;
135}
136
137
138/**
139 * Print formatted string.
140 *
141 * @param pHlp Pointer to this structure.
142 * @param pszFormat The format string.
143 * @param ... Arguments.
144 */
145static DECLCALLBACK(void) vmmR3FatalDumpInfoHlp_pfnPrintf(PCDBGFINFOHLP pHlp, const char *pszFormat, ...)
146{
147 va_list args;
148 va_start(args, pszFormat);
149 pHlp->pfnPrintfV(pHlp, pszFormat, args);
150 va_end(args);
151}
152
153/**
154 * Print formatted string.
155 *
156 * @param pHlp Pointer to this structure.
157 * @param pszFormat The format string.
158 * @param args Argument list.
159 */
160static DECLCALLBACK(void) vmmR3FatalDumpInfoHlp_pfnPrintfV(PCDBGFINFOHLP pHlp, const char *pszFormat, va_list args)
161{
162 PVMMR3FATALDUMPINFOHLP pMyHlp = (PVMMR3FATALDUMPINFOHLP)pHlp;
163
164 if (pMyHlp->pRelLogger)
165 {
166 va_list args2;
167 va_copy(args2, args);
168 RTLogLoggerV(pMyHlp->pRelLogger, pszFormat, args2);
169 va_end(args2);
170 }
171 if (pMyHlp->pLogger)
172 {
173 va_list args2;
174 va_copy(args2, args);
175 RTLogLoggerV(pMyHlp->pLogger, pszFormat, args);
176 va_end(args2);
177 }
178 if (pMyHlp->fStdErr)
179 {
180 va_list args2;
181 va_copy(args2, args);
182 RTStrFormatV(vmmR3FatalDumpInfoHlp_BufferedStdErrOutput, pMyHlp, NULL, NULL, pszFormat, args2);
183 //RTStrmPrintfV(g_pStdErr, pszFormat, args2);
184 va_end(args2);
185 }
186 if (pMyHlp->fRecSummary)
187 {
188 size_t cchLeft = sizeof(pMyHlp->szSummary) - pMyHlp->offSummary;
189 if (cchLeft > 1)
190 {
191 va_list args2;
192 va_copy(args2, args);
193 size_t cch = RTStrPrintfV(&pMyHlp->szSummary[pMyHlp->offSummary], cchLeft, pszFormat, args);
194 va_end(args2);
195 Assert(cch <= cchLeft);
196 pMyHlp->offSummary += cch;
197 }
198 }
199}
200
201
202/**
203 * Initializes the fatal dump output helper.
204 *
205 * @param pHlp The structure to initialize.
206 */
207static void vmmR3FatalDumpInfoHlpInit(PVMMR3FATALDUMPINFOHLP pHlp)
208{
209 RT_BZERO(pHlp, sizeof(*pHlp));
210
211 pHlp->Core.pfnPrintf = vmmR3FatalDumpInfoHlp_pfnPrintf;
212 pHlp->Core.pfnPrintfV = vmmR3FatalDumpInfoHlp_pfnPrintfV;
213 pHlp->Core.pfnGetOptError = DBGFR3InfoGenericGetOptError;
214
215 /*
216 * The loggers.
217 */
218 pHlp->pRelLogger = RTLogRelGetDefaultInstance();
219#ifdef LOG_ENABLED
220 pHlp->pLogger = RTLogDefaultInstance();
221#else
222 if (pHlp->pRelLogger)
223 pHlp->pLogger = RTLogGetDefaultInstance();
224 else
225 pHlp->pLogger = RTLogDefaultInstance();
226#endif
227
228 if (pHlp->pRelLogger)
229 {
230 pHlp->fRelLoggerFlags = RTLogGetFlags(pHlp->pRelLogger);
231 RTLogChangeFlags(pHlp->pRelLogger, RTLOGFLAGS_BUFFERED, RTLOGFLAGS_DISABLED);
232 }
233
234 if (pHlp->pLogger)
235 {
236 pHlp->fLoggerFlags = RTLogGetFlags(pHlp->pLogger);
237 pHlp->fLoggerDestFlags = RTLogGetDestinations(pHlp->pLogger);
238 RTLogChangeFlags(pHlp->pLogger, RTLOGFLAGS_BUFFERED, RTLOGFLAGS_DISABLED);
239#ifndef DEBUG_sandervl
240 RTLogChangeDestinations(pHlp->pLogger, RTLOGDEST_DEBUGGER, 0);
241#endif
242 }
243
244 /*
245 * Check if we need write to stderr.
246 */
247 pHlp->fStdErr = (!pHlp->pRelLogger || !(RTLogGetDestinations(pHlp->pRelLogger) & (RTLOGDEST_STDOUT | RTLOGDEST_STDERR)))
248 && (!pHlp->pLogger || !(RTLogGetDestinations(pHlp->pLogger) & (RTLOGDEST_STDOUT | RTLOGDEST_STDERR)));
249#ifdef DEBUG_sandervl
250 pHlp->fStdErr = false; /* takes too long to display here */
251#endif
252 pHlp->offStdErrBuf = 0;
253
254 /*
255 * Init the summary recording.
256 */
257 pHlp->fRecSummary = true;
258 pHlp->offSummary = 0;
259 pHlp->szSummary[0] = '\0';
260}
261
262
263/**
264 * Deletes the fatal dump output helper.
265 *
266 * @param pHlp The structure to delete.
267 */
268static void vmmR3FatalDumpInfoHlpDelete(PVMMR3FATALDUMPINFOHLP pHlp)
269{
270 if (pHlp->pRelLogger)
271 {
272 RTLogFlush(pHlp->pRelLogger);
273 RTLogChangeFlags(pHlp->pRelLogger,
274 pHlp->fRelLoggerFlags & RTLOGFLAGS_DISABLED,
275 pHlp->fRelLoggerFlags & RTLOGFLAGS_BUFFERED);
276 }
277
278 if (pHlp->pLogger)
279 {
280 RTLogFlush(pHlp->pLogger);
281 RTLogChangeFlags(pHlp->pLogger,
282 pHlp->fLoggerFlags & RTLOGFLAGS_DISABLED,
283 pHlp->fLoggerFlags & RTLOGFLAGS_BUFFERED);
284 RTLogChangeDestinations(pHlp->pLogger, 0, pHlp->fLoggerDestFlags & RTLOGDEST_DEBUGGER);
285 }
286
287 if (pHlp->fStdErr)
288 vmmR3FatalDumpInfoHlpFlushStdErr(pHlp);
289}
290
291
292/**
293 * @callback_method_impl{FNVMMEMTRENDEZVOUS}
294 */
295static DECLCALLBACK(VBOXSTRICTRC) vmmR3FatalDumpRendezvousDoneCallback(PVM pVM, PVMCPU pVCpu, void *pvUser)
296{
297 VM_FF_CLEAR(pVM, VM_FF_CHECK_VM_STATE);
298 RT_NOREF(pVCpu, pvUser);
299 return VINF_SUCCESS;
300}
301
302
303/**
304 * Dumps the VM state on a fatal error.
305 *
306 * @param pVM The cross context VM structure.
307 * @param pVCpu The cross context virtual CPU structure.
308 * @param rcErr VBox status code.
309 */
310VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr)
311{
312 /*
313 * Create our output helper and sync it with the log settings.
314 * This helper will be used for all the output.
315 */
316 VMMR3FATALDUMPINFOHLP Hlp;
317 PCDBGFINFOHLP pHlp = &Hlp.Core;
318 vmmR3FatalDumpInfoHlpInit(&Hlp);
319
320 /* Release owned locks to make sure other VCPUs can continue in case they were waiting for one. */
321 PDMR3CritSectLeaveAll(pVM);
322
323 /*
324 * Header.
325 */
326 pHlp->pfnPrintf(pHlp,
327 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
328 "!!\n"
329 "!! VCPU%u: Guru Meditation %d (%Rrc)\n"
330 "!!\n",
331 pVCpu->idCpu, rcErr, rcErr);
332
333 /*
334 * Continue according to context.
335 */
336 bool fDoneHyper = false;
337 bool fDoneImport = false;
338 switch (rcErr)
339 {
340 /*
341 * Hypervisor errors.
342 */
343 case VERR_VMM_RING0_ASSERTION:
344 case VINF_EM_DBG_HYPER_ASSERTION:
345 case VERR_VMM_RING3_CALL_DISABLED:
346 case VERR_VMM_WRONG_HM_VMCPU_STATE:
347 case VERR_VMM_CONTEXT_HOOK_STILL_ENABLED:
348 {
349 const char *pszMsg1 = VMMR3GetRZAssertMsg1(pVM);
350 while (pszMsg1 && *pszMsg1 == '\n')
351 pszMsg1++;
352 const char *pszMsg2 = VMMR3GetRZAssertMsg2(pVM);
353 while (pszMsg2 && *pszMsg2 == '\n')
354 pszMsg2++;
355 pHlp->pfnPrintf(pHlp,
356 "%s"
357 "%s",
358 pszMsg1,
359 pszMsg2);
360 if ( !pszMsg2
361 || !*pszMsg2
362 || strchr(pszMsg2, '\0')[-1] != '\n')
363 pHlp->pfnPrintf(pHlp, "\n");
364 }
365 RT_FALL_THRU();
366 case VERR_TRPM_DONT_PANIC:
367 case VERR_TRPM_PANIC:
368 case VINF_EM_RAW_STALE_SELECTOR:
369 case VINF_EM_RAW_IRET_TRAP:
370 case VINF_EM_DBG_HYPER_BREAKPOINT:
371 case VINF_EM_DBG_HYPER_STEPPED:
372 case VINF_EM_TRIPLE_FAULT:
373 case VERR_VMM_HYPER_CR3_MISMATCH:
374 case VERR_VMM_LONG_JMP_ERROR:
375 {
376 /*
377 * Active trap? This is only of partial interest when in hardware
378 * assisted virtualization mode, thus the different messages.
379 */
380 TRPMEVENT enmType;
381 uint8_t u8TrapNo = 0xce;
382 uint32_t uErrorCode = 0xdeadface;
383 RTGCUINTPTR uCR2 = 0xdeadface;
384 uint8_t cbInstr = UINT8_MAX;
385 bool fIcebp = false;
386 int rc2 = TRPMQueryTrapAll(pVCpu, &u8TrapNo, &enmType, &uErrorCode, &uCR2, &cbInstr, &fIcebp);
387 if (RT_SUCCESS(rc2))
388 pHlp->pfnPrintf(pHlp,
389 "!! ACTIVE TRAP=%02x ERRCD=%RX32 CR2=%RGv FlatPC=%RGr Type=%d cbInstr=%02x fIcebp=%RTbool (Guest!)\n",
390 u8TrapNo, uErrorCode, uCR2, CPUMGetGuestFlatPC(pVCpu), enmType, cbInstr, fIcebp);
391
392#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
393 /*
394 * Dump the relevant hypervisor registers and stack.
395 */
396 if (rcErr == VERR_VMM_RING0_ASSERTION)
397 {
398 /* Dump the jmpbuf. */
399 pHlp->pfnPrintf(pHlp,
400 "!!\n"
401 "!! AssertJmpBuf:\n"
402 "!!\n");
403 pHlp->pfnPrintf(pHlp,
404 "UnwindSp=%RHv UnwindRetSp=%RHv UnwindBp=%RHv UnwindPc=%RHv\n",
405 pVCpu->vmm.s.AssertJmpBuf.UnwindSp,
406 pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp,
407 pVCpu->vmm.s.AssertJmpBuf.UnwindBp,
408 pVCpu->vmm.s.AssertJmpBuf.UnwindPc);
409 pHlp->pfnPrintf(pHlp,
410 "UnwindRetPcValue=%RHv UnwindRetPcLocation=%RHv\n",
411 pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcValue,
412 pVCpu->vmm.s.AssertJmpBuf.UnwindRetPcLocation);
413 pHlp->pfnPrintf(pHlp,
414 "pfn=%RHv pvUser1=%RHv pvUser2=%RHv\n",
415 pVCpu->vmm.s.AssertJmpBuf.pfn,
416 pVCpu->vmm.s.AssertJmpBuf.pvUser1,
417 pVCpu->vmm.s.AssertJmpBuf.pvUser2);
418
419 /* Dump the resume register frame on the stack. */
420 PRTHCUINTPTR const pBP = (PRTHCUINTPTR)&pVCpu->vmm.s.abAssertStack[ pVCpu->vmm.s.AssertJmpBuf.UnwindBp
421 - pVCpu->vmm.s.AssertJmpBuf.UnwindSp];
422# if HC_ARCH_BITS == 32
423 pHlp->pfnPrintf(pHlp,
424 "eax=volatile ebx=%08x ecx=volatile edx=volatile esi=%08x edi=%08x\n"
425 "eip=%08x esp=%08x ebp=%08x efl=%08x\n"
426 ,
427 pBP[-3], pBP[-2], pBP[-1],
428 pBP[1], pVCpu->vmm.s.AssertJmpBuf.SavedEbp - 8, pBP[0], pBP[-4]);
429# else
430# ifdef RT_OS_WINDOWS
431 pHlp->pfnPrintf(pHlp,
432 "rax=volatile rbx=%016RX64 rcx=volatile rdx=volatile\n"
433 "rsi=%016RX64 rdi=%016RX64 r8=volatile r9=volatile \n"
434 "r10=volatile r11=volatile r12=%016RX64 r13=%016RX64\n"
435 "r14=%016RX64 r15=%016RX64\n"
436 "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 rfl=%08RX64\n"
437 ,
438 pBP[-7],
439 pBP[-6], pBP[-5],
440 pBP[-4], pBP[-3],
441 pBP[-2], pBP[-1],
442 pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-8]);
443# else
444 pHlp->pfnPrintf(pHlp,
445 "rax=volatile rbx=%016RX64 rcx=volatile rdx=volatile\n"
446 "rsi=volatile rdi=volatile r8=volatile r9=volatile \n"
447 "r10=volatile r11=volatile r12=%016RX64 r13=%016RX64\n"
448 "r14=%016RX64 r15=%016RX64\n"
449 "rip=%016RX64 rsp=%016RX64 rbp=%016RX64 rflags=%08RX64\n"
450 ,
451 pBP[-5],
452 pBP[-4], pBP[-3],
453 pBP[-2], pBP[-1],
454 pBP[1], pVCpu->vmm.s.AssertJmpBuf.UnwindRetSp, pBP[0], pBP[-6]);
455# endif
456# endif
457
458 /* Callstack. */
459 DBGFADDRESS AddrPc, AddrBp, AddrSp;
460 PCDBGFSTACKFRAME pFirstFrame;
461 rc2 = DBGFR3StackWalkBeginEx(pVM->pUVM, pVCpu->idCpu, DBGFCODETYPE_RING0,
462 DBGFR3AddrFromHostR0(&AddrBp, pVCpu->vmm.s.AssertJmpBuf.UnwindBp),
463 DBGFR3AddrFromHostR0(&AddrSp, pVCpu->vmm.s.AssertJmpBuf.UnwindSp),
464 DBGFR3AddrFromHostR0(&AddrPc, pVCpu->vmm.s.AssertJmpBuf.UnwindPc),
465 RTDBGRETURNTYPE_INVALID, &pFirstFrame);
466 if (RT_SUCCESS(rc2))
467 {
468 pHlp->pfnPrintf(pHlp,
469 "!!\n"
470 "!! Call Stack:\n"
471 "!!\n");
472# if HC_ARCH_BITS == 32
473 pHlp->pfnPrintf(pHlp, "EBP Ret EBP Ret CS:EIP Arg0 Arg1 Arg2 Arg3 CS:EIP Symbol [line]\n");
474# else
475 pHlp->pfnPrintf(pHlp, "RBP Ret RBP Ret RIP RIP Symbol [line]\n");
476# endif
477 for (PCDBGFSTACKFRAME pFrame = pFirstFrame;
478 pFrame;
479 pFrame = DBGFR3StackWalkNext(pFrame))
480 {
481# if HC_ARCH_BITS == 32
482 pHlp->pfnPrintf(pHlp,
483 "%RHv %RHv %04RX32:%RHv %RHv %RHv %RHv %RHv",
484 (RTHCUINTPTR)pFrame->AddrFrame.off,
485 (RTHCUINTPTR)pFrame->AddrReturnFrame.off,
486 (RTHCUINTPTR)pFrame->AddrReturnPC.Sel,
487 (RTHCUINTPTR)pFrame->AddrReturnPC.off,
488 pFrame->Args.au32[0],
489 pFrame->Args.au32[1],
490 pFrame->Args.au32[2],
491 pFrame->Args.au32[3]);
492 pHlp->pfnPrintf(pHlp, " %RTsel:%08RHv", pFrame->AddrPC.Sel, pFrame->AddrPC.off);
493# else
494 pHlp->pfnPrintf(pHlp,
495 "%RHv %RHv %RHv %RHv",
496 (RTHCUINTPTR)pFrame->AddrFrame.off,
497 (RTHCUINTPTR)pFrame->AddrReturnFrame.off,
498 (RTHCUINTPTR)pFrame->AddrReturnPC.off,
499 (RTHCUINTPTR)pFrame->AddrPC.off);
500# endif
501 if (pFrame->pSymPC)
502 {
503 RTGCINTPTR offDisp = pFrame->AddrPC.FlatPtr - pFrame->pSymPC->Value;
504 if (offDisp > 0)
505 pHlp->pfnPrintf(pHlp, " %s+%llx", pFrame->pSymPC->szName, (int64_t)offDisp);
506 else if (offDisp < 0)
507 pHlp->pfnPrintf(pHlp, " %s-%llx", pFrame->pSymPC->szName, -(int64_t)offDisp);
508 else
509 pHlp->pfnPrintf(pHlp, " %s", pFrame->pSymPC->szName);
510 }
511 if (pFrame->pLinePC)
512 pHlp->pfnPrintf(pHlp, " [%s @ 0i%d]", pFrame->pLinePC->szFilename, pFrame->pLinePC->uLineNo);
513 pHlp->pfnPrintf(pHlp, "\n");
514 for (uint32_t iReg = 0; iReg < pFrame->cSureRegs; iReg++)
515 {
516 const char *pszName = pFrame->paSureRegs[iReg].pszName;
517 if (!pszName)
518 pszName = DBGFR3RegCpuName(pVM->pUVM, pFrame->paSureRegs[iReg].enmReg,
519 pFrame->paSureRegs[iReg].enmType);
520 char szValue[1024];
521 szValue[0] = '\0';
522 DBGFR3RegFormatValue(szValue, sizeof(szValue), &pFrame->paSureRegs[iReg].Value,
523 pFrame->paSureRegs[iReg].enmType, false);
524 pHlp->pfnPrintf(pHlp, " %-3s=%s\n", pszName, szValue);
525 }
526 }
527 DBGFR3StackWalkEnd(pFirstFrame);
528 }
529
530 /* Symbols on the stack. */
531 uint32_t const cbRawStack = RT_MIN(pVCpu->vmm.s.AssertJmpBuf.cbStackValid, sizeof(pVCpu->vmm.s.abAssertStack));
532 uintptr_t const * const pauAddr = (uintptr_t const *)&pVCpu->vmm.s.abAssertStack[0];
533 uint32_t const iEnd = cbRawStack / sizeof(uintptr_t);
534 uint32_t iAddr = 0;
535 pHlp->pfnPrintf(pHlp,
536 "!!\n"
537 "!! Addresses on the stack (iAddr=%#x, iEnd=%#x)\n"
538 "!!\n",
539 iAddr, iEnd);
540 while (iAddr < iEnd)
541 {
542 uintptr_t const uAddr = pauAddr[iAddr];
543 if (uAddr > X86_PAGE_SIZE)
544 {
545 DBGFADDRESS Addr;
546 DBGFR3AddrFromFlat(pVM->pUVM, &Addr, uAddr);
547 RTGCINTPTR offDisp = 0;
548 RTGCINTPTR offLineDisp = 0;
549 PRTDBGSYMBOL pSym = DBGFR3AsSymbolByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr,
550 RTDBGSYMADDR_FLAGS_LESS_OR_EQUAL
551 | RTDBGSYMADDR_FLAGS_SKIP_ABS_IN_DEFERRED,
552 &offDisp, NULL);
553 PRTDBGLINE pLine = DBGFR3AsLineByAddrA(pVM->pUVM, DBGF_AS_R0, &Addr, &offLineDisp, NULL);
554 if (pLine || pSym)
555 {
556 pHlp->pfnPrintf(pHlp, "%#06x: %p =>", iAddr * sizeof(uintptr_t), uAddr);
557 if (pSym)
558 pHlp->pfnPrintf(pHlp, " %s + %#x", pSym->szName, (intptr_t)offDisp);
559 if (pLine)
560 pHlp->pfnPrintf(pHlp, " [%s:%u + %#x]\n", pLine->szFilename, pLine->uLineNo, offLineDisp);
561 else
562 pHlp->pfnPrintf(pHlp, "\n");
563 RTDbgSymbolFree(pSym);
564 RTDbgLineFree(pLine);
565 }
566 }
567 iAddr++;
568 }
569
570 /* raw stack */
571 Hlp.fRecSummary = false;
572 pHlp->pfnPrintf(pHlp,
573 "!!\n"
574 "!! Raw stack (mind the direction).\n"
575 "!! pbEMTStackR0=%RHv cbRawStack=%#x\n"
576 "!! pbEmtStackR3=%p\n"
577 "!!\n"
578 "%.*Rhxd\n",
579 pVCpu->vmm.s.AssertJmpBuf.UnwindSp, cbRawStack,
580 &pVCpu->vmm.s.abAssertStack[0],
581 cbRawStack, &pVCpu->vmm.s.abAssertStack[0]);
582 }
583 else
584 {
585 pHlp->pfnPrintf(pHlp,
586 "!! Skipping ring-0 registers and stack, rcErr=%Rrc\n", rcErr);
587 }
588#endif /* RT_ARCH_AMD64 || RT_ARCH_X86 */
589 break;
590 }
591
592 case VERR_IEM_INSTR_NOT_IMPLEMENTED:
593 case VERR_IEM_ASPECT_NOT_IMPLEMENTED:
594 case VERR_PATM_IPE_TRAP_IN_PATCH_CODE:
595 case VERR_EM_GUEST_CPU_HANG:
596 {
597 CPUMImportGuestStateOnDemand(pVCpu, CPUMCTX_EXTRN_ABSOLUTELY_ALL);
598 fDoneImport = true;
599
600 DBGFR3Info(pVM->pUVM, "cpumguest", NULL, pHlp);
601 DBGFR3Info(pVM->pUVM, "cpumguestinstr", NULL, pHlp);
602 DBGFR3Info(pVM->pUVM, "cpumguesthwvirt", NULL, pHlp);
603 break;
604 }
605
606 /*
607 * For some problems (e.g. VERR_INVALID_STATE in VMMR0.cpp), there could be
608 * additional details in the assertion messages.
609 */
610 default:
611 {
612 const char *pszMsg1 = VMMR3GetRZAssertMsg1(pVM);
613 while (pszMsg1 && *pszMsg1 == '\n')
614 pszMsg1++;
615 if (pszMsg1 && *pszMsg1 != '\0')
616 pHlp->pfnPrintf(pHlp, "AssertMsg1: %s\n", pszMsg1);
617
618 const char *pszMsg2 = VMMR3GetRZAssertMsg2(pVM);
619 while (pszMsg2 && *pszMsg2 == '\n')
620 pszMsg2++;
621 if (pszMsg2 && *pszMsg2 != '\0')
622 pHlp->pfnPrintf(pHlp, "AssertMsg2: %s\n", pszMsg2);
623 break;
624 }
625
626 } /* switch (rcErr) */
627 Hlp.fRecSummary = false;
628
629
630 /*
631 * Generic info dumper loop.
632 */
633 if (!fDoneImport)
634 CPUMImportGuestStateOnDemand(pVCpu, CPUMCTX_EXTRN_ABSOLUTELY_ALL);
635 static struct
636 {
637 const char *pszInfo;
638 const char *pszArgs;
639 } const aInfo[] =
640 {
641 { "mappings", NULL },
642 { "hma", NULL },
643 { "cpumguest", "verbose" },
644 { "cpumguesthwvirt", "verbose" },
645 { "cpumguestinstr", "verbose" },
646 { "cpumhyper", "verbose" },
647 { "cpumhost", "verbose" },
648 { "mode", "all" },
649 { "cpuid", "verbose" },
650 { "handlers", "phys virt hyper stats" },
651 { "timers", NULL },
652 { "activetimers", NULL },
653 };
654 for (unsigned i = 0; i < RT_ELEMENTS(aInfo); i++)
655 {
656 if (fDoneHyper && !strcmp(aInfo[i].pszInfo, "cpumhyper"))
657 continue;
658 pHlp->pfnPrintf(pHlp,
659 "!!\n"
660 "!! {%s, %s}\n"
661 "!!\n",
662 aInfo[i].pszInfo, aInfo[i].pszArgs);
663 DBGFR3Info(pVM->pUVM, aInfo[i].pszInfo, aInfo[i].pszArgs, pHlp);
664 }
665
666 /* All other info items */
667 DBGFR3InfoMulti(pVM,
668 "*",
669 "mappings|hma|cpum|cpumguest|cpumguesthwvirt|cpumguestinstr|cpumhyper|cpumhost|mode|cpuid"
670 "|pgmpd|pgmcr3|timers|activetimers|handlers|help|exithistory",
671 "!!\n"
672 "!! {%s}\n"
673 "!!\n",
674 pHlp);
675
676
677 /* done */
678 pHlp->pfnPrintf(pHlp,
679 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
680
681
682 /*
683 * Repeat the summary to stderr so we don't have to scroll half a mile up.
684 */
685 vmmR3FatalDumpInfoHlpFlushStdErr(&Hlp);
686 if (Hlp.szSummary[0])
687 RTStrmPrintf(g_pStdErr,
688 "%s\n"
689 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",
690 Hlp.szSummary);
691
692 /*
693 * Delete the output instance (flushing and restoring of flags).
694 */
695 vmmR3FatalDumpInfoHlpDelete(&Hlp);
696
697 /*
698 * Rendezvous with the other EMTs and clear the VM_FF_CHECK_VM_STATE so we can
699 * stop burning CPU cycles.
700 */
701 VMMR3EmtRendezvous(pVM, VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE, vmmR3FatalDumpRendezvousDoneCallback, NULL);
702}
703
Note: See TracBrowser for help on using the repository browser.

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