qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/3] whpx: Fixed reporting of the CPU context to GDB for 64-bit


From: Ivan Shcherbakov
Subject: [PATCH 1/3] whpx: Fixed reporting of the CPU context to GDB for 64-bit
Date: Tue, 22 Feb 2022 21:15:41 -0800

Hi All,

We have been looking into kernel-debugging Linux VMs running on Windows with
Hyper-V enabled (that forces the virtualization software to use WHPX), and
it turned out, none of the major virtualization tools supports it properly.
I've added the missing parts to QEMU and it looks pretty solid: setting
breakpoints in the kernel, running, stepping in/over works reliably and
fast.
The changes involved 3 parts:
1. Fixing the x64 register reporting to gdb (this patch)
2. Fixing synchronization of CR8 <=> APIC.TPR, that was preventing
WHvSetVirtualProcessorRegisters() from working
3. Implementing software breakpoints 

It would be great if the changes could be integrated into the QEMU
repository, allowing other Windows users to debug their VMs.
Below is the description of the first patch.

This change makes sure that stopping in the 64-bit mode will set the
HF_CS64_MASK flag in env->hflags (see x86_update_hflags() in
target/i386/cpu.c).
Without it, the code in gdbstub.c would only use the 32-bit register values
when debugging 64-bit targets, making debugging effectively impossible.

Signed-off-by: Ivan Shcherbakov <ivan@sysprogs.com>
---
 target/i386/whpx/whpx-all.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index ef896da0a2..edd4fafbdf 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -604,6 +604,8 @@ static void whpx_get_registers(CPUState *cpu)
         whpx_apic_get(x86_cpu->apic_state);
     }
 
+    x86_update_hflags(env);
+
     return;
 }
 
-- 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]