[Qemu-devel] [PATCH v3] dump: add kernel_gs_base to QEMU CPU state

Viktor Prutyanov posted 1 patch 5 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20180714123000.11326-1-viktor.prutyanov@virtuozzo.com
Test checkpatch passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
target/i386/arch_dump.c | 10 ++++++++++
1 file changed, 10 insertions(+)
[Qemu-devel] [PATCH v3] dump: add kernel_gs_base to QEMU CPU state
Posted by Viktor Prutyanov 5 years, 9 months ago
This patch adds field with content of KERNEL_GS_BASE MSR to QEMU note in
ELF dump.

On Windows, if all vCPUs are running usermode tasks at the time the dump is
created, this can be helpful in the discovery of guest system structures
during conversion ELF dump to MEMORY.DMP dump.

Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>
---
 v2: keep version 1 in QEMUCPUState and document the extension procedure
 v3: enable kernel_gs_base filling only on x86_64

 target/i386/arch_dump.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/target/i386/arch_dump.c b/target/i386/arch_dump.c
index 35b55fc200..004141fc04 100644
--- a/target/i386/arch_dump.c
+++ b/target/i386/arch_dump.c
@@ -258,6 +258,12 @@ struct QEMUCPUState {
     QEMUCPUSegment cs, ds, es, fs, gs, ss;
     QEMUCPUSegment ldt, tr, gdt, idt;
     uint64_t cr[5];
+    /*
+     * Fields below are optional and are being added at the end without
+     * changing the version. External tools may identify their presence
+     * by checking 'size' field.
+     */
+    uint64_t kernel_gs_base;
 };
 
 typedef struct QEMUCPUState QEMUCPUState;
@@ -315,6 +321,10 @@ static void qemu_get_cpustate(QEMUCPUState *s, CPUX86State *env)
     s->cr[2] = env->cr[2];
     s->cr[3] = env->cr[3];
     s->cr[4] = env->cr[4];
+
+#ifdef TARGET_X86_64
+    s->kernel_gs_base = env->kernelgsbase;
+#endif
 }
 
 static inline int cpu_write_qemu_note(WriteCoreDumpFunction f,
-- 
2.14.3


Re: [Qemu-devel] [PATCH v3] dump: add kernel_gs_base to QEMU CPU state
Posted by Eduardo Habkost 5 years, 9 months ago
On Sat, Jul 14, 2018 at 03:30:00PM +0300, Viktor Prutyanov wrote:
> This patch adds field with content of KERNEL_GS_BASE MSR to QEMU note in
> ELF dump.
> 
> On Windows, if all vCPUs are running usermode tasks at the time the dump is
> created, this can be helpful in the discovery of guest system structures
> during conversion ELF dump to MEMORY.DMP dump.
> 
> Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>

Queued for 3.1, thanks.

-- 
Eduardo

Re: [Qemu-devel] [PATCH v3] dump: add kernel_gs_base to QEMU CPU state
Posted by Paolo Bonzini 5 years, 9 months ago
On 16/07/2018 23:16, Eduardo Habkost wrote:
> On Sat, Jul 14, 2018 at 03:30:00PM +0300, Viktor Prutyanov wrote:
>> This patch adds field with content of KERNEL_GS_BASE MSR to QEMU note in
>> ELF dump.
>>
>> On Windows, if all vCPUs are running usermode tasks at the time the dump is
>> created, this can be helpful in the discovery of guest system structures
>> during conversion ELF dump to MEMORY.DMP dump.
>>
>> Signed-off-by: Viktor Prutyanov <viktor.prutyanov@virtuozzo.com>
> 
> Queued for 3.1, thanks.

Oh, I sent it for 3.0 already.

Paolo