[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 54/60] dump: use system context in Windows dump
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 54/60] dump: use system context in Windows dump |
Date: |
Thu, 28 Jun 2018 22:05:04 +0200 |
From: Viktor Prutyanov <address@hidden>
We use CPU #0 to access guest virtual memory, but it can execute user
thread at that moment. So, switch CR3 to PageDirectoryBase from header
and restore original value at the end.
Signed-off-by: Viktor Prutyanov <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
win_dump.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/win_dump.c b/win_dump.c
index 58255c1..7d956ca 100644
--- a/win_dump.c
+++ b/win_dump.c
@@ -111,12 +111,6 @@ static void patch_header(WinDumpHeader64 *h)
h->PhysicalMemoryBlock.unused = 0;
h->unused1 = 0;
- /*
- * We assume h->DirectoryBase and current CR3 are the same when we access
- * memory by virtual address. In other words, we suppose current context
- * is system context. It is definetely true in case of BSOD.
- */
-
patch_mm_pfn_database(h, &local_err);
if (local_err) {
warn_report_err(local_err);
@@ -171,6 +165,8 @@ void create_win_dump(DumpState *s, Error **errp)
{
WinDumpHeader64 *h = (WinDumpHeader64 *)(s->guest_note +
VMCOREINFO_ELF_NOTE_HDR_SIZE);
+ X86CPU *first_x86_cpu = X86_CPU(first_cpu);
+ uint64_t saved_cr3 = first_x86_cpu->env.cr[3];
Error *local_err = NULL;
if (s->guest_note_size != sizeof(WinDumpHeader64) +
@@ -185,10 +181,17 @@ void create_win_dump(DumpState *s, Error **errp)
return;
}
+ /*
+ * Further access to kernel structures by virtual addresses
+ * should be made from system context.
+ */
+
+ first_x86_cpu->env.cr[3] = h->DirectoryTableBase;
+
check_kdbg(h, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return;
+ goto out_cr3;
}
patch_header(h);
@@ -198,12 +201,17 @@ void create_win_dump(DumpState *s, Error **errp)
s->written_size = qemu_write_full(s->fd, h, sizeof(*h));
if (s->written_size != sizeof(*h)) {
error_setg(errp, QERR_IO_ERROR);
- return;
+ goto out_cr3;
}
write_runs(s, h, &local_err);
if (local_err) {
error_propagate(errp, local_err);
- return;
+ goto out_cr3;
}
+
+out_cr3:
+ first_x86_cpu->env.cr[3] = saved_cr3;
+
+ return;
}
--
1.8.3.1
- [Qemu-devel] [PULL 43/60] target-i386: Add NMI interception to SVM, (continued)
- [Qemu-devel] [PULL 43/60] target-i386: Add NMI interception to SVM, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 42/60] memory/hmp: Print owners/parents in "info mtree", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 48/60] ioapic: some proper indents when dump info, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 46/60] doc: another fix to "info pic", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 44/60] target-i386: Allow interrupt injection after STGI, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 45/60] target-i386: Mark cpu_vmexit noreturn, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 47/60] ioapic: support "info pic", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 49/60] ioapic: support "info irq", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 51/60] kvm: support -overcommit cpu-pm=on|off, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 52/60] i386/cpu: make -cpu host support monitor/mwait, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 54/60] dump: use system context in Windows dump,
Paolo Bonzini <=
- [Qemu-devel] [PULL 56/60] dump: add Windows live system dump, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 53/60] dump: add Windows dump format to dump-guest-memory, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 55/60] dump: add fallback KDBG using in Windows dump, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 50/60] hmp: obsolete "info ioapic", Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 58/60] hw/scsi: centralize SG_IO calls into single function, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 60/60] tests/boot-serial: Do not delete the output file in case of errors, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 59/60] hw/scsi: add VPD Block Limits emulation, Paolo Bonzini, 2018/06/28
- [Qemu-devel] [PULL 57/60] hw/scsi: cleanups before VPD BL emulation, Paolo Bonzini, 2018/06/28
- Re: [Qemu-devel] [PULL 00/60] Misc patches for soft freeze, Peter Maydell, 2018/06/29