Skip to content

elf2dmp: identify faulting CPU in Windows crash dumps

Zhengrong Li qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest posting 3/33 patches 3 repliesIn review
  2. v3 posting 2/33 patches 3 repliesSuperseded
  3. v3 posting 1/33 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v23 patches6 repliesSuperseded

Changes in v3 from the cover letter

- Remove unused fault_cpu variable in fill_context()
- Use per-CPU size check (s->size >= offsetof + sizeof) instead of global has_is_crash_occurred_cpu flag, fixing heterogeneous dumps where CPU notes have different sizes
- Remove has_is_crash_occurred_cpu from QEMU_Elf struct and init_states() since per-CPU check makes it unnecessary
- Move QEMUCPUState struct growth from patch 2 to patch 3 so sizeof() change and init_states() update stay together (bisectability)
- Fix patch 1 commit message: soften "is never called" to "is not always called when crash dumping is enabled"
- Fix patch 2 commit message: clarify compatibility description for both old-tools/new-dumps and new-tools/old-dumps directions
- Clamp state->size to MIN(state->size, n_descsz) in init_states() to prevent reading beyond note descriptor boundary
- Compare state_size against offsetof + sizeof(kernel_gs_base) instead of sizeof(*state) to avoid misclassifying valid old 440-byte notes as lacking kernel_gs_base

Patches in v3 posting 3/3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3runstate: set crash_occurred on guest crashloadedsystem/runstate.c+5 -00 replies
2/3dump: add crash_occurred flag to QEMUCPUStatetarget/i386/arch_dump.c+6 -00 replies
3/3elf2dmp: fill ContextBuffer with faulting CPU contextcontrib/elf2dmp/kdbg.h contrib/elf2dmp/main.c contrib/elf2dmp/qemu_elf.c +1 more+68 -30 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAkihiko Odaki
SeriesR-b R-b
1/3
2/3
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/3] elf2dmp: identify faulting CPU in Windows crash dumps

When a Windows guest crashes and QEMU generates a memory dump via pvpanic, elf2dmp currently always sets CPU 0's context in the dump header. This makes WinDbg default to CPU 0 when opening the dump, even if the actual crash happened on a different CPU.

This series adds crash_occurred tracking from the runstate layer through to the QEMUCPUState in the ELF dump, and teaches elf2dmp to identify and use the faulting CPU's context.

Changes since v2:
- Remove unused fault_cpu variable in fill_context()
- Use per-CPU size check (s->size >= offsetof + sizeof) instead of global has_is_crash_occurred_cpu flag, fixing heterogeneous dumps where CPU notes have different sizes
- Remove has_is_crash_occurred_cpu from QEMU_Elf struct and init_states() since per-CPU check makes it unnecessary
- Move QEMUCPUState struct growth from patch 2 to patch 3 so sizeof() change and init_states() update stay together (bisectability)
- Fix patch 1 commit message: soften "is never called" to "is not always called when crash dumping is enabled"
- Fix patch 2 commit message: clarify compatibility description for both old-tools/new-dumps and new-tools/old-dumps directions
- Clamp state->size to MIN(state->size, n_descsz) in init_states() to prevent reading beyond note descriptor boundary
- Compare state_size against offsetof + sizeof(kernel_gs_base) instead of sizeof(*state) to avoid misclassifying valid old 440-byte notes as lacking kernel_gs_base

Changes since v1:
- Set header context before best-effort guest memory operations to avoid losing faulting CPU context on partial dump failures
- Use LIVE_SYSTEM_DUMP when BugcheckCode is zero
- Use PRIx32 for BugcheckCode format specifier
- Use linux.alibaba.com identity

Zhengrong Li (3):
runstate: set crash_occurred on guest crashloaded
dump: add crash_occurred flag to QEMUCPUState
elf2dmp: fill ContextBuffer with faulting CPU context

 contrib/elf2dmp/kdbg.h     |  9 +++++++
 contrib/elf2dmp/main.c     | 50 ++++++++++++++++++++++++++++++++++++--
 contrib/elf2dmp/qemu_elf.c | 10 +++++++-
 contrib/elf2dmp/qemu_elf.h |  2 ++
 system/runstate.c          |  5 ++++
 target/i386/arch_dump.c    |  6 +++++
 6 files changed, 79 insertions(+), 3 deletions(-)
Signature · 1 line
2.43.0