Skip to contentSkip to conversation

Windbg supporting

PATCH In review Mikhail Abakumov 3 participants 43 messages Nov 29, 2018 – Dec 1, 2018 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Windbg supporting

We made the debugger module WinDbg (like GDB) for QEMU. This is the replacement of the remote server in Windows kernel. Used for remote Windows kernel debugging without debugging mode.

WinDbg is a multipurpose debugger for the Microsoft Windows computer operating system, distributed by Microsoft. Recent versions of WinDbg have been and are being distributed as part of the free Debugging Tools for Windows suite.

How to start debugging QEMU using WinDbg:
Run QEMU with next option:
-windbg pipe:<name>
QEMU will start and pause for waiting WinDbg connection. Run WinDbg with next options:

    -b -k com:pipe,baud=115200,port=\\.\pipe\<name>,resets=0

Wait for debugger connect to kernel.

Note: You can add Symbol Search Path in WinDbg
such as srv*c:\tmp*http://msdl.microsoft.com/download/symbols.

How it works:
The WinDbg debugger has the possibility of connecting to a remote debug server (Kdsrv.exe) in the Windows kernel. Therefore, it is possible to connect to the guest system running in the QEMU emulator. Kernel debugging is possible only with the enabled debugging mode, may change at the same time. Our module of WinDbg debugger for QEMU is an alternative of the remote debugging service in the kernel. Thus, the debugger connects to the debugging module, not to the kernel of the operating system. The module obtains all the necessary information answering debugger requests from the QEMU emulator. At the same time for debugging there is no need to enable debugging mode in the kernel. This leads to hidden debugging. Our module supports all features of WinDbg regarding remote debugging, besides interception of events and exceptions. Supports i386 and x86_64 architectures.

---

Mikhail Abakumov (39):
windbg: add empty windbgstub files
windbg: add windbg's KD header file
windbg: add -windbg option
windbg: add helper features
windbg: add WindbgState
windbg: add chardev
windbg: hook to wrmsr operation
windbg: implement windbg_on_load
windbg: implement find_KPCR
windbg: implement find_kdVersion
windbg: add windbg_search_vmaddr
windbg: implement find_kdDebuggerDataBlock
windbg: parsing data stream
windbg: send data and control packets
windbg: handler of parsing context
windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
windbg: generate ExceptionStateChange and LoadSymbolsStateChange
windbg: implement windbg_process_control_packet
windbg: implement windbg_process_data_packet
windbg: implement windbg_process_manipulate_packet
windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory
windbg: some kernel structures
windbg: add helper functions
windbg: [de]serialization cpu context
windbg: [de]serialization cpu spec registers
windbg: implement kd_api_get_context and kd_api_set_context
windbg: implement kd_api_get_context_ex and kd_api_set_context_ex
windbg: implement kd_api_read_control_space and kd_api_write_control_space
windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint
windbg: debug exception subscribing
windbg: implement kd_api_continue
windbg: implement kd_api_read_io_space and kd_api_write_io_space
windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory
windbg: implement kd_api_get_version
windbg: implement kd_api_read_msr and kd_api_write_msr
windbg: implement kd_api_search_memory
windbg: implement kd_api_fill_memory
windbg: implement kd_api_query_memory
windbg: maintainers

 MAINTAINERS                      |   12 
 Makefile.target                  |    3 
 cpus.c                           |   19 +
 default-configs/i386-softmmu.mak |    1 
 gdbstub.c                        |    4 
 include/exec/windbgkd.h          |  928 ++++++++++++++++++++++++++
 include/exec/windbgstub-utils.h  |  104 +++
 include/exec/windbgstub.h        |   25 +
 include/sysemu/sysemu.h          |    2 
 qemu-options.hx                  |    8 
 stubs/Makefile.objs              |    1 
 stubs/windbgstub.c               |   22 +
 target/i386/Makefile.objs        |    1 
 target/i386/cpu.h                |    5 
 target/i386/misc_helper.c        |   38 +
 target/i386/windbgstub.c         | 1368 ++++++++++++++++++++++++++++++++++++++
 vl.c                             |    8 
 windbgstub-utils.c               |  508 ++++++++++++++
 windbgstub.c                     |  545 +++++++++++++++
 19 files changed, 3592 insertions(+), 10 deletions(-)
 create mode 100644 include/exec/windbgkd.h
 create mode 100644 include/exec/windbgstub-utils.h
 create mode 100644 include/exec/windbgstub.h
 create mode 100644 stubs/windbgstub.c
 create mode 100644 target/i386/windbgstub.c
 create mode 100644 windbgstub-utils.c
 create mode 100644 windbgstub.c

--
Mikhail Abakumov

#1 lore raw

PATCH 1/39 windbg: add empty windbgstub files

---
 Makefile.target                  |    3 +++
 default-configs/i386-softmmu.mak |    1 +
 include/exec/windbgstub-utils.h  |   18 ++++++++++++++++++
 include/exec/windbgstub.h        |   17 +++++++++++++++++
 stubs/Makefile.objs              |    1 +
 stubs/windbgstub.c               |   18 ++++++++++++++++++
 target/i386/Makefile.objs        |    1 +
 target/i386/windbgstub.c         |   13 +++++++++++++
 windbgstub-utils.c               |   12 ++++++++++++
 windbgstub.c                     |   19 +++++++++++++++++++
 10 files changed, 103 insertions(+)
 create mode 100644 include/exec/windbgstub-utils.h
 create mode 100644 include/exec/windbgstub.h
 create mode 100644 stubs/windbgstub.c
 create mode 100644 target/i386/windbgstub.c
 create mode 100644 windbgstub-utils.c
 create mode 100644 windbgstub.c
Makefile.target +3 -0
index 4d56298bbf..3bf11d3366 100644
@@ -147,6 +147,9 @@ obj-$(TARGET_X86_64) += win_dump.o
 obj-y += migration/ram.o
 LIBS := $(libs_softmmu) $(LIBS)
 
+# WinDbg support
+obj-$(CONFIG_WINDBGSTUB) += windbgstub.o windbgstub-utils.o
+
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
 obj-y += hw/sparc64/
default-configs/i386-softmmu.mak +1 -0
index 64c998c4c8..5cb41a53ab 100644
@@ -67,3 +67,4 @@ CONFIG_I2C=y
 CONFIG_SEV=$(CONFIG_KVM)
 CONFIG_VTD=y
 CONFIG_AMD_IOMMU=y
+CONFIG_WINDBGSTUB=y
include/exec/windbgstub-utils.h new file +18 -0
new file mode 100644
index 0000000000..11487be465
@@ -0,0 +1,18 @@
+/*
+ * windbgstub-utils.h
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef WINDBGSTUB_UTILS_H
+#define WINDBGSTUB_UTILS_H
+
+#include "qemu/osdep.h"
+#include "exec/windbgstub.h"
+
+#endif /* WINDBGSTUB_UTILS_H */
include/exec/windbgstub.h new file +17 -0
new file mode 100644
index 0000000000..9656c152ef
@@ -0,0 +1,17 @@
+/*
+ * windbgstub.h
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef WINDBGSTUB_H
+#define WINDBGSTUB_H
+
+int windbg_server_start(const char *device);
+
+#endif /* WINDBGSTUB_H */
stubs/Makefile.objs +1 -0
index 5dd0aeeec6..2158e99516 100644
@@ -33,6 +33,7 @@ stub-obj-y += trace-control.o
 stub-obj-y += uuid.o
 stub-obj-y += vm-stop.o
 stub-obj-y += vmstate.o
+stub-obj-y += windbgstub.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += qmp_memory_device.o
 stub-obj-y += target-monitor-defs.o
stubs/windbgstub.c new file +18 -0
new file mode 100644
index 0000000000..36ad918dad
@@ -0,0 +1,18 @@
+/*
+ * windbgstub.c
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "exec/windbgstub.h"
+
+int windbg_server_start(const char *device)
+{
+    return 0;
+}
target/i386/Makefile.objs +1 -0
index 32bf966300..249b878036 100644
@@ -20,3 +20,4 @@ obj-$(CONFIG_WHPX) += whpx-all.o
 endif
 obj-$(CONFIG_SEV) += sev.o
 obj-$(call lnot,$(CONFIG_SEV)) += sev-stub.o
+obj-$(CONFIG_WINDBGSTUB) += windbgstub.o
target/i386/windbgstub.c new file +13 -0
new file mode 100644
index 0000000000..8caaa7cd38
@@ -0,0 +1,13 @@
+/*
+ * windbgstub.c
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "exec/windbgstub-utils.h"
windbgstub-utils.c new file +12 -0
new file mode 100644
index 0000000000..7f603b7f3f
@@ -0,0 +1,12 @@
+/*
+ * windbgstub-utils.c
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "exec/windbgstub-utils.h"
windbgstub.c new file +19 -0
new file mode 100644
index 0000000000..4673703b66
@@ -0,0 +1,19 @@
+/*
+ * windbgstub.c
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "exec/windbgstub.h"
+#include "exec/windbgstub-utils.h"
+
+int windbg_server_start(const char *device)
+{
+    return 0;
+}
#2 lore raw

PATCH 2/39 windbg: add windbg's KD header file

In reply to Mikhail Abakumov

Header file from windbg's source code describing the main structures.

---
 include/exec/windbgkd.h         |  928 +++++++++++++++++++++++++++++++++++++++
 include/exec/windbgstub-utils.h |    1 
 2 files changed, 929 insertions(+)
 create mode 100644 include/exec/windbgkd.h
include/exec/windbgkd.h new file +928 -0
new file mode 100644
index 0000000000..63ebc4c50f
@@ -0,0 +1,928 @@
+/*
+ * windbgkd.h
+ *
+ * Copyright (c) 2010-2018 Institute for System Programming
+ *                         of the Russian Academy of Sciences.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef WINDBGKD_H
+#define WINDBGKD_H
+
+/*
+ * Packet Size and Control Stream Size
+ */
+#define PACKET_MAX_SIZE                     4096
+#define DBGKD_MAXSTREAM                     16
+
+/*
+ * Magic Packet IDs
+ */
+#define INITIAL_PACKET_ID                   0x80800000
+#define SYNC_PACKET_ID                      0x00000800
+#define RESET_PACKET_ID                     0x0018359b
+
+/*
+ * Magic Packet bytes
+ */
+#define BREAKIN_PACKET                      0x62626262
+#define BREAKIN_PACKET_BYTE                 0x62
+#define PACKET_LEADER                       0x30303030
+#define PACKET_LEADER_BYTE                  0x30
+#define CONTROL_PACKET_LEADER               0x69696969
+#define CONTROL_PACKET_LEADER_BYTE          0x69
+#define PACKET_TRAILING_BYTE                0xaa
+
+/*
+ * Packet Types
+ */
+#define PACKET_TYPE_UNUSED                  0
+#define PACKET_TYPE_KD_STATE_CHANGE32       1
+#define PACKET_TYPE_KD_STATE_MANIPULATE     2
+#define PACKET_TYPE_KD_DEBUG_IO             3
+#define PACKET_TYPE_KD_ACKNOWLEDGE          4
+#define PACKET_TYPE_KD_RESEND               5
+#define PACKET_TYPE_KD_RESET                6
+#define PACKET_TYPE_KD_STATE_CHANGE64       7
+#define PACKET_TYPE_KD_POLL_BREAKIN         8
+#define PACKET_TYPE_KD_TRACE_IO             9
+#define PACKET_TYPE_KD_CONTROL_REQUEST      10
+#define PACKET_TYPE_KD_FILE_IO              11
+#define PACKET_TYPE_MAX                     12
+
+/*
+ * Wait State Change Types
+ */
+#define DbgKdMinimumStateChange             0x00003030
+#define DbgKdExceptionStateChange           0x00003030
+#define DbgKdLoadSymbolsStateChange         0x00003031
+#define DbgKdCommandStringStateChange       0x00003032
+#define DbgKdMaximumStateChange             0x00003033
+
+/*
+ * This is combined with the basic state change code
+ * if the state is from an alternate source
+ */
+#define DbgKdAlternateStateChange           0x00010000
+
+/*
+ * Manipulate Types
+ */
+#define DbgKdMinimumManipulate              0x00003130
+#define DbgKdReadVirtualMemoryApi           0x00003130
+#define DbgKdWriteVirtualMemoryApi          0x00003131
+#define DbgKdGetContextApi                  0x00003132
+#define DbgKdSetContextApi                  0x00003133
+#define DbgKdWriteBreakPointApi             0x00003134
+#define DbgKdRestoreBreakPointApi           0x00003135
+#define DbgKdContinueApi                    0x00003136
+#define DbgKdReadControlSpaceApi            0x00003137
+#define DbgKdWriteControlSpaceApi           0x00003138
+#define DbgKdReadIoSpaceApi                 0x00003139
+#define DbgKdWriteIoSpaceApi                0x0000313a
+#define DbgKdRebootApi                      0x0000313b
+#define DbgKdContinueApi2                   0x0000313c
+#define DbgKdReadPhysicalMemoryApi          0x0000313d
+#define DbgKdWritePhysicalMemoryApi         0x0000313e
+#define DbgKdQuerySpecialCallsApi           0x0000313f
+#define DbgKdSetSpecialCallApi              0x00003140
+#define DbgKdClearSpecialCallsApi           0x00003141
+#define DbgKdSetInternalBreakPointApi       0x00003142
+#define DbgKdGetInternalBreakPointApi       0x00003143
+#define DbgKdReadIoSpaceExtendedApi         0x00003144
+#define DbgKdWriteIoSpaceExtendedApi        0x00003145
+#define DbgKdGetVersionApi                  0x00003146
+#define DbgKdWriteBreakPointExApi           0x00003147
+#define DbgKdRestoreBreakPointExApi         0x00003148
+#define DbgKdCauseBugCheckApi               0x00003149
+#define DbgKdSwitchProcessor                0x00003150
+#define DbgKdPageInApi                      0x00003151
+#define DbgKdReadMachineSpecificRegister    0x00003152
+#define DbgKdWriteMachineSpecificRegister   0x00003153
+#define OldVlm1                             0x00003154
+#define OldVlm2                             0x00003155
+#define DbgKdSearchMemoryApi                0x00003156
+#define DbgKdGetBusDataApi                  0x00003157
+#define DbgKdSetBusDataApi                  0x00003158
+#define DbgKdCheckLowMemoryApi              0x00003159
+#define DbgKdClearAllInternalBreakpointsApi 0x0000315a
+#define DbgKdFillMemoryApi                  0x0000315b
+#define DbgKdQueryMemoryApi                 0x0000315c
+#define DbgKdSwitchPartition                0x0000315d
+#define DbgKdWriteCustomBreakpointApi       0x0000315e
+#define DbgKdGetContextExApi                0x0000315f
+#define DbgKdSetContextExApi                0x00003160
+#define DbgKdMaximumManipulate              0x00003161
+
+/*
+ * Debug I/O Types
+ */
+#define DbgKdPrintStringApi                 0x00003230
+#define DbgKdGetStringApi                   0x00003231
+
+/*
+ * Trace I/O Types
+ */
+#define DbgKdPrintTraceApi                  0x00003330
+
+/*
+ * Control Request Types
+ */
+#define DbgKdRequestHardwareBp              0x00004300
+#define DbgKdReleaseHardwareBp              0x00004301
+
+/*
+ * File I/O Types
+ */
+#define DbgKdCreateFileApi                 0x00003430
+#define DbgKdReadFileApi                   0x00003431
+#define DbgKdWriteFileApi                  0x00003432
+#define DbgKdCloseFileApi                  0x00003433
+
+/*
+ * Control Report Flags
+ */
+#define REPORT_INCLUDES_SEGS                0x0001
+#define REPORT_STANDARD_CS                  0x0002
+
+/*
+ * Protocol Versions
+ */
+#define DBGKD_64BIT_PROTOCOL_VERSION1       5
+#define DBGKD_64BIT_PROTOCOL_VERSION2       6
+
+/*
+ * Query Memory Address Spaces
+ */
+#define DBGKD_QUERY_MEMORY_VIRTUAL          0
+#define DBGKD_QUERY_MEMORY_PROCESS          0
+#define DBGKD_QUERY_MEMORY_SESSION          1
+#define DBGKD_QUERY_MEMORY_KERNEL           2
+
+/*
+ * Query Memory Flags
+ */
+#define DBGKD_QUERY_MEMORY_READ             0x01
+#define DBGKD_QUERY_MEMORY_WRITE            0x02
+#define DBGKD_QUERY_MEMORY_EXECUTE          0x04
+#define DBGKD_QUERY_MEMORY_FIXED            0x08
+
+/*
+ * Internal Breakpoint Flags
+ */
+#define DBGKD_INTERNAL_BP_FLAG_COUNTONLY    0x01
+#define DBGKD_INTERNAL_BP_FLAG_INVALID      0x02
+#define DBGKD_INTERNAL_BP_FLAG_SUSPENDED    0x04
+#define DBGKD_INTERNAL_BP_FLAG_DYING        0x08
+
+/*
+ * Fill Memory Flags
+ */
+#define DBGKD_FILL_MEMORY_VIRTUAL           0x01
+#define DBGKD_FILL_MEMORY_PHYSICAL          0x02
+
+/*
+ * Physical Memory Caching Flags
+ */
+#define DBGKD_CACHING_DEFAULT               0
+#define DBGKD_CACHING_CACHED                1
+#define DBGKD_CACHING_UNCACHED              2
+#define DBGKD_CACHING_WRITE_COMBINED        3
+
+/*
+ * Partition Switch Flags
+ */
+#define DBGKD_PARTITION_DEFAULT             0x00
+#define DBGKD_PARTITION_ALTERNATE           0x01
+
+/*
+ * AMD64 Control Space types
+ */
+#define AMD64_DEBUG_CONTROL_SPACE_KPCR      0
+#define AMD64_DEBUG_CONTROL_SPACE_KPRCB     1
+#define AMD64_DEBUG_CONTROL_SPACE_KSPECIAL  2
+#define AMD64_DEBUG_CONTROL_SPACE_KTHREAD   3
+
+/*
+ * Version flags
+ */
+#define DBGKD_VERS_FLAG_MP                  0x0001
+#define DBGKD_VERS_FLAG_DATA                0x0002
+#define DBGKD_VERS_FLAG_PTR64               0x0004
+#define DBGKD_VERS_FLAG_NOMM                0x0008
+#define DBGKD_VERS_FLAG_HSS                 0x0010
+#define DBGKD_VERS_FLAG_PARTITIONS          0x0020
+
+/*
+ * Image architectures
+ */
+#ifndef IMAGE_FILE_MACHINE_AMD64
+#define IMAGE_FILE_MACHINE_AMD64            0x8664
+#endif
+#ifndef IMAGE_FILE_MACHINE_ARM
+#define IMAGE_FILE_MACHINE_ARM              0x1c0
+#endif
+#ifndef IMAGE_FILE_MACHINE_EBC
+#define IMAGE_FILE_MACHINE_EBC              0xebc
+#endif
+#ifndef IMAGE_FILE_MACHINE_I386
+#define IMAGE_FILE_MACHINE_I386             0x14c
+#endif
+#ifndef IMAGE_FILE_MACHINE_IA64
+#define IMAGE_FILE_MACHINE_IA64             0x200
+#endif
+
+/*
+ * DBGKD_GET_VERSION64.Simulation
+ */
+enum {
+    DBGKD_SIMULATION_NONE,
+    DBGKD_SIMULATION_EXDI
+};
+
+/*
+ * Maximum supported number of breakpoints
+ */
+#define KD_BREAKPOINT_MAX 32
+
+typedef uint8_t boolean_t;
+typedef int32_t ntstatus_t;
+
+/*
+ * NTSTATUS
+ */
+#define NT_SUCCESS(status)       ((ntstatus_t) (status) >= 0)
+#ifndef STATUS_SUCCESS
+#define STATUS_SUCCESS           ((ntstatus_t) 0x00000000)
+#endif
+#ifndef DBG_CONTINUE
+#define DBG_CONTINUE             ((ntstatus_t) 0x00010002)
+#endif
+#ifndef STATUS_NO_MORE_ENTRIES
+#define STATUS_NO_MORE_ENTRIES   ((ntstatus_t) 0x8000001A)
+#endif
+#ifndef STATUS_UNSUCCESSFUL
+#define STATUS_UNSUCCESSFUL      ((ntstatus_t) 0xC0000001)
+#endif
+#ifndef STATUS_INVALID_PARAMETER
+#define STATUS_INVALID_PARAMETER ((ntstatus_t) 0xC000000D)
+#endif
+
+/*
+ * KD Packet Structure
+ */
+typedef struct _KD_PACKET {
+    uint32_t PacketLeader;
+    uint16_t PacketType;
+    uint16_t ByteCount;
+    uint32_t PacketId;
+    uint32_t Checksum;
+} QEMU_PACKED KD_PACKET, *PKD_PACKET;
+
+/*
+ * KD Context
+ */
+typedef struct _KD_CONTEXT {
+    uint32_t KdpDefaultRetries;
+    boolean_t KdpControlCPending;
+} KD_CONTEXT, *PKD_CONTEXT;
+
+/*
+ * Control Sets for Supported Architectures
+ */
+typedef struct _X86_DBGKD_CONTROL_SET {
+    uint32_t TraceFlag;
+    uint32_t Dr7;
+    uint32_t CurrentSymbolStart;
+    uint32_t CurrentSymbolEnd;
+} X86_DBGKD_CONTROL_SET, *PX86_DBGKD_CONTROL_SET;
+
+typedef struct _ALPHA_DBGKD_CONTROL_SET {
+    uint32_t __padding;
+} ALPHA_DBGKD_CONTROL_SET, *PALPHA_DBGKD_CONTROL_SET;
+
+typedef struct _IA64_DBGKD_CONTROL_SET {
+    uint32_t Continue;
+    uint64_t CurrentSymbolStart;
+    uint64_t CurrentSymbolEnd;
+} IA64_DBGKD_CONTROL_SET, *PIA64_DBGKD_CONTROL_SET;
+
+typedef struct _AMD64_DBGKD_CONTROL_SET {
+    uint32_t TraceFlag;
+    uint64_t Dr7;
+    uint64_t CurrentSymbolStart;
+    uint64_t CurrentSymbolEnd;
+} AMD64_DBGKD_CONTROL_SET, *PAMD64_DBGKD_CONTROL_SET;
+
+typedef struct _ARM_DBGKD_CONTROL_SET {
+    uint32_t Continue;
+    uint32_t CurrentSymbolStart;
+    uint32_t CurrentSymbolEnd;
+} ARM_DBGKD_CONTROL_SET, *PARM_DBGKD_CONTROL_SET;
+
+typedef struct _DBGKD_ANY_CONTROL_SET {
+    union {
+        X86_DBGKD_CONTROL_SET X86ControlSet;
+        ALPHA_DBGKD_CONTROL_SET AlphaControlSet;
+        IA64_DBGKD_CONTROL_SET IA64ControlSet;
+        AMD64_DBGKD_CONTROL_SET Amd64ControlSet;
+        ARM_DBGKD_CONTROL_SET ARMControlSet;
+    };
+} DBGKD_ANY_CONTROL_SET, *PDBGKD_ANY_CONTROL_SET;
+
+#if defined(TARGET_I386)
+typedef X86_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
+#elif defined(TARGET_X86_64)
+typedef AMD64_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
+#elif defined(TARGET_ARM)
+typedef ARM_DBGKD_CONTROL_SET DBGKD_CONTROL_SET, *PDBGKD_CONTROL_SET;
+#else
+#error Unsupported Architecture
+#endif
+
+/*
+ * EXCEPTION_RECORD Structures
+ */
+typedef struct _DBGKM_EXCEPTION_RECORD32 {
+    int32_t ExceptionCode;
+    uint32_t ExceptionFlags;
+    uint32_t ExceptionRecord;
+    uint32_t ExceptionAddress;
+    uint32_t NumberParameters;
+    uint32_t ExceptionInformation[15];
+} DBGKM_EXCEPTION_RECORD32, *PDBGKM_EXCEPTION_RECORD32;
+
+typedef struct _DBGKM_EXCEPTION_RECORD64 {
+    int32_t ExceptionCode;
+    uint32_t ExceptionFlags;
+    uint64_t ExceptionRecord;
+    uint64_t ExceptionAddress;
+    uint32_t NumberParameters;
+    uint32_t __unusedAligment;
+    uint64_t ExceptionInformation[15];
+} DBGKM_EXCEPTION_RECORD64, *PDBGKM_EXCEPTION_RECORD64;
+
+/*
+ * DBGKM Structure for Exceptions
+ */
+typedef struct _DBGKM_EXCEPTION32 {
+    DBGKM_EXCEPTION_RECORD32 ExceptionRecord;
+    uint32_t FirstChance;
+} DBGKM_EXCEPTION32, *PDBGKM_EXCEPTION32;
+
+typedef struct _DBGKM_EXCEPTION64 {
+    DBGKM_EXCEPTION_RECORD64 ExceptionRecord;
+    uint32_t FirstChance;
+} DBGKM_EXCEPTION64, *PDBGKM_EXCEPTION64;
+
+/*
+ * DBGKD Structure for State Change
+ */
+typedef struct _X86_DBGKD_CONTROL_REPORT {
+    uint32_t   Dr6;
+    uint32_t   Dr7;
+    uint16_t  InstructionCount;
+    uint16_t  ReportFlags;
+    uint8_t   InstructionStream[DBGKD_MAXSTREAM];
+    uint16_t  SegCs;
+    uint16_t  SegDs;
+    uint16_t  SegEs;
+    uint16_t  SegFs;
+    uint32_t   EFlags;
+} X86_DBGKD_CONTROL_REPORT, *PX86_DBGKD_CONTROL_REPORT;
+
+typedef struct _ALPHA_DBGKD_CONTROL_REPORT {
+    uint32_t InstructionCount;
+    uint8_t InstructionStream[DBGKD_MAXSTREAM];
+} ALPHA_DBGKD_CONTROL_REPORT, *PALPHA_DBGKD_CONTROL_REPORT;
+
+typedef struct _IA64_DBGKD_CONTROL_REPORT {
+    uint32_t InstructionCount;
+    uint8_t InstructionStream[DBGKD_MAXSTREAM];
+} IA64_DBGKD_CONTROL_REPORT, *PIA64_DBGKD_CONTROL_REPORT;
+
+typedef struct _AMD64_DBGKD_CONTROL_REPORT {
+    uint64_t Dr6;
+    uint64_t Dr7;
+    uint32_t EFlags;
+    uint16_t InstructionCount;
+    uint16_t ReportFlags;
+    uint8_t InstructionStream[DBGKD_MAXSTREAM];
+    uint16_t SegCs;
+    uint16_t SegDs;
+    uint16_t SegEs;
+    uint16_t SegFs;
+} AMD64_DBGKD_CONTROL_REPORT, *PAMD64_DBGKD_CONTROL_REPORT;
+
+typedef struct _ARM_DBGKD_CONTROL_REPORT {
+    uint32_t Cpsr;
+    uint32_t InstructionCount;
+    uint8_t InstructionStream[DBGKD_MAXSTREAM];
+} ARM_DBGKD_CONTROL_REPORT, *PARM_DBGKD_CONTROL_REPORT;
+
+typedef struct _DBGKD_ANY_CONTROL_REPORT {
+    union {
+        X86_DBGKD_CONTROL_REPORT X86ControlReport;
+        ALPHA_DBGKD_CONTROL_REPORT AlphaControlReport;
+        IA64_DBGKD_CONTROL_REPORT IA64ControlReport;
+        AMD64_DBGKD_CONTROL_REPORT Amd64ControlReport;
+        ARM_DBGKD_CONTROL_REPORT ARMControlReport;
+    };
+} DBGKD_ANY_CONTROL_REPORT, *PDBGKD_ANY_CONTROL_REPORT;
+
+#if defined(TARGET_I386)
+typedef X86_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
+#elif defined(TARGET_X86_64)
+typedef AMD64_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
+#elif defined(TARGET_ARM)
+typedef ARM_DBGKD_CONTROL_REPORT DBGKD_CONTROL_REPORT, *PDBGKD_CONTROL_REPORT;
+#else
+#error Unsupported Architecture
+#endif
+
+/*
+ * DBGKD Structure for Debug I/O Type Print String
+ */
+typedef struct _DBGKD_PRINT_STRING {
+    uint32_t LengthOfString;
+} DBGKD_PRINT_STRING, *PDBGKD_PRINT_STRING;
+
+/*
+ * DBGKD Structure for Debug I/O Type Get String
+ */
+typedef struct _DBGKD_GET_STRING {
+    uint32_t LengthOfPromptString;
+    uint32_t LengthOfStringRead;
+} DBGKD_GET_STRING, *PDBGKD_GET_STRING;
+
+/*
+ * DBGKD Structure for Debug I/O
+ */
+typedef struct _DBGKD_DEBUG_IO {
+    uint32_t ApiNumber;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    union {
+        DBGKD_PRINT_STRING PrintString;
+        DBGKD_GET_STRING GetString;
+    } u;
+} DBGKD_DEBUG_IO, *PDBGKD_DEBUG_IO;
+
+/*
+ * DBGkD Structure for Command String
+ */
+typedef struct _DBGKD_COMMAND_STRING {
+    uint32_t Flags;
+    uint32_t Reserved1;
+    uint64_t Reserved2[7];
+} DBGKD_COMMAND_STRING, *PDBGKD_COMMAND_STRING;
+
+/*
+ * DBGKD Structure for Load Symbols
+ */
+typedef struct _DBGKD_LOAD_SYMBOLS32 {
+    uint32_t PathNameLength;
+    uint32_t BaseOfDll;
+    uint32_t ProcessId;
+    uint32_t CheckSum;
+    uint32_t SizeOfImage;
+    boolean_t UnloadSymbols;
+} DBGKD_LOAD_SYMBOLS32, *PDBGKD_LOAD_SYMBOLS32;
+
+typedef struct _DBGKD_LOAD_SYMBOLS64 {
+    uint32_t PathNameLength;
+    uint64_t BaseOfDll;
+    uint64_t ProcessId;
+    uint32_t CheckSum;
+    uint32_t SizeOfImage;
+    boolean_t UnloadSymbols;
+} DBGKD_LOAD_SYMBOLS64, *PDBGKD_LOAD_SYMBOLS64;
+
+/*
+ * DBGKD Structure for Wait State Change
+ */
+typedef struct _DBGKD_WAIT_STATE_CHANGE32 {
+    uint32_t NewState;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    uint32_t NumberProcessors;
+    uint32_t Thread;
+    uint32_t ProgramCounter;
+    union {
+        DBGKM_EXCEPTION32 Exception;
+        DBGKD_LOAD_SYMBOLS32 LoadSymbols;
+    } u;
+} DBGKD_WAIT_STATE_CHANGE32, *PDBGKD_WAIT_STATE_CHANGE32;
+
+typedef struct _DBGKD_WAIT_STATE_CHANGE64 {
+    uint32_t NewState;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    uint32_t NumberProcessors;
+    uint64_t Thread;
+    uint64_t ProgramCounter;
+    union {
+        DBGKM_EXCEPTION64 Exception;
+        DBGKD_LOAD_SYMBOLS64 LoadSymbols;
+    } u;
+} DBGKD_WAIT_STATE_CHANGE64, *PDBGKD_WAIT_STATE_CHANGE64;
+
+typedef struct _DBGKD_ANY_WAIT_STATE_CHANGE {
+    uint32_t NewState;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    uint32_t NumberProcessors;
+    uint64_t Thread;
+    uint64_t ProgramCounter;
+    union {
+        DBGKM_EXCEPTION64 Exception;
+        DBGKD_LOAD_SYMBOLS64 LoadSymbols;
+        DBGKD_COMMAND_STRING CommandString;
+    } u;
+    union {
+        DBGKD_CONTROL_REPORT ControlReport;
+        DBGKD_ANY_CONTROL_REPORT AnyControlReport;
+    };
+} DBGKD_ANY_WAIT_STATE_CHANGE, *PDBGKD_ANY_WAIT_STATE_CHANGE;
+
+/*
+ * DBGKD Manipulate Structures
+ */
+typedef struct _DBGKD_READ_MEMORY32 {
+    uint32_t TargetBaseAddress;
+    uint32_t TransferCount;
+    uint32_t ActualBytesRead;
+} DBGKD_READ_MEMORY32, *PDBGKD_READ_MEMORY32;
+
+typedef struct _DBGKD_READ_MEMORY64 {
+    uint64_t TargetBaseAddress;
+    uint32_t TransferCount;
+    uint32_t ActualBytesRead;
+} DBGKD_READ_MEMORY64, *PDBGKD_READ_MEMORY64;
+
+typedef struct _DBGKD_WRITE_MEMORY32 {
+    uint32_t TargetBaseAddress;
+    uint32_t TransferCount;
+    uint32_t ActualBytesWritten;
+} DBGKD_WRITE_MEMORY32, *PDBGKD_WRITE_MEMORY32;
+
+typedef struct _DBGKD_WRITE_MEMORY64 {
+    uint64_t TargetBaseAddress;
+    uint32_t TransferCount;
+    uint32_t ActualBytesWritten;
+} DBGKD_WRITE_MEMORY64, *PDBGKD_WRITE_MEMORY64;
+
+typedef struct _DBGKD_GET_CONTEXT {
+    uint32_t Unused;
+} DBGKD_GET_CONTEXT, *PDBGKD_GET_CONTEXT;
+
+typedef struct _DBGKD_SET_CONTEXT {
+    uint32_t ContextFlags;
+} DBGKD_SET_CONTEXT, *PDBGKD_SET_CONTEXT;
+
+typedef struct _DBGKD_WRITE_BREAKPOINT32 {
+    uint32_t BreakPointAddress;
+    uint32_t BreakPointHandle;
+} DBGKD_WRITE_BREAKPOINT32, *PDBGKD_WRITE_BREAKPOINT32;
+
+typedef struct _DBGKD_WRITE_BREAKPOINT64 {
+    uint64_t BreakPointAddress;
+    uint32_t BreakPointHandle;
+} DBGKD_WRITE_BREAKPOINT64, *PDBGKD_WRITE_BREAKPOINT64;
+
+typedef struct _DBGKD_RESTORE_BREAKPOINT {
+    uint32_t BreakPointHandle;
+} DBGKD_RESTORE_BREAKPOINT, *PDBGKD_RESTORE_BREAKPOINT;
+
+typedef struct _DBGKD_CONTINUE {
+    ntstatus_t ContinueStatus;
+} DBGKD_CONTINUE, *PDBGKD_CONTINUE;
+
+#pragma pack(push, 4)
+typedef struct _DBGKD_CONTINUE2 {
+    ntstatus_t ContinueStatus;
+    union {
+        DBGKD_CONTROL_SET ControlSet;
+        DBGKD_ANY_CONTROL_SET AnyControlSet;
+    };
+} DBGKD_CONTINUE2, *PDBGKD_CONTINUE2;
+#pragma pack(pop)
+
+typedef struct _DBGKD_READ_WRITE_IO32 {
+    uint32_t IoAddress;
+    uint32_t DataSize;
+    uint32_t DataValue;
+} DBGKD_READ_WRITE_IO32, *PDBGKD_READ_WRITE_IO32;
+
+typedef struct _DBGKD_READ_WRITE_IO64 {
+    uint64_t IoAddress;
+    uint32_t DataSize;
+    uint32_t DataValue;
+} DBGKD_READ_WRITE_IO64, *PDBGKD_READ_WRITE_IO64;
+
+typedef struct _DBGKD_READ_WRITE_IO_EXTENDED32 {
+    uint32_t DataSize;
+    uint32_t InterfaceType;
+    uint32_t BusNumber;
+    uint32_t AddressSpace;
+    uint32_t IoAddress;
+    uint32_t DataValue;
+} DBGKD_READ_WRITE_IO_EXTENDED32, *PDBGKD_READ_WRITE_IO_EXTENDED32;
+
+typedef struct _DBGKD_READ_WRITE_IO_EXTENDED64 {
+    uint32_t DataSize;
+    uint32_t InterfaceType;
+    uint32_t BusNumber;
+    uint32_t AddressSpace;
+    uint64_t IoAddress;
+    uint32_t DataValue;
+} DBGKD_READ_WRITE_IO_EXTENDED64, *PDBGKD_READ_WRITE_IO_EXTENDED64;
+
+typedef struct _DBGKD_READ_WRITE_MSR {
+    uint32_t Msr;
+    uint32_t DataValueLow;
+    uint32_t DataValueHigh;
+} DBGKD_READ_WRITE_MSR, *PDBGKD_READ_WRITE_MSR;
+
+typedef struct _DBGKD_QUERY_SPECIAL_CALLS {
+    uint32_t NumberOfSpecialCalls;
+} DBGKD_QUERY_SPECIAL_CALLS, *PDBGKD_QUERY_SPECIAL_CALLS;
+
+typedef struct _DBGKD_SET_SPECIAL_CALL32 {
+    uint32_t SpecialCall;
+} DBGKD_SET_SPECIAL_CALL32, *PDBGKD_SET_SPECIAL_CALL32;
+
+typedef struct _DBGKD_SET_SPECIAL_CALL64 {
+    uint64_t SpecialCall;
+} DBGKD_SET_SPECIAL_CALL64, *PDBGKD_SET_SPECIAL_CALL64;
+
+typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT32 {
+    uint32_t BreakpointAddress;
+    uint32_t Flags;
+} DBGKD_SET_INTERNAL_BREAKPOINT32, *PDBGKD_SET_INTERNAL_BREAKPOINT32;
+
+typedef struct _DBGKD_SET_INTERNAL_BREAKPOINT64 {
+    uint64_t BreakpointAddress;
+    uint32_t Flags;
+} DBGKD_SET_INTERNAL_BREAKPOINT64, *PDBGKD_SET_INTERNAL_BREAKPOINT64;
+
+typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT32 {
+    uint32_t BreakpointAddress;
+    uint32_t Flags;
+    uint32_t Calls;
+    uint32_t MaxCallsPerPeriod;
+    uint32_t MinInstructions;
+    uint32_t MaxInstructions;
+    uint32_t TotalInstructions;
+} DBGKD_GET_INTERNAL_BREAKPOINT32, *PDBGKD_GET_INTERNAL_BREAKPOINT32;
+
+typedef struct _DBGKD_GET_INTERNAL_BREAKPOINT64 {
+    uint64_t BreakpointAddress;
+    uint32_t Flags;
+    uint32_t Calls;
+    uint32_t MaxCallsPerPeriod;
+    uint32_t MinInstructions;
+    uint32_t MaxInstructions;
+    uint32_t TotalInstructions;
+} DBGKD_GET_INTERNAL_BREAKPOINT64, *PDBGKD_GET_INTERNAL_BREAKPOINT64;
+
+typedef struct _DBGKD_GET_VERSION32 {
+    uint16_t MajorVersion;
+    uint16_t MinorVersion;
+    uint16_t ProtocolVersion;
+    uint16_t Flags;
+    uint32_t KernBase;
+    uint32_t PsLoadedModuleList;
+    uint16_t MachineType;
+    uint16_t ThCallbackStack;
+    uint16_t NextCallback;
+    uint16_t FramePointer;
+    uint32_t KiCallUserMode;
+    uint32_t KeUserCallbackDispatcher;
+    uint32_t BreakpointWithStatus;
+    uint32_t DebuggerDataList;
+} DBGKD_GET_VERSION32, *PDBGKD_GET_VERSION32;
+
+typedef struct _DBGKD_GET_VERSION64 {
+    uint16_t MajorVersion;
+    uint16_t MinorVersion;
+    uint8_t ProtocolVersion;
+    uint8_t KdSecondaryVersion;
+    uint16_t Flags;
+    uint16_t MachineType;
+    uint8_t MaxPacketType;
+    uint8_t MaxStateChange;
+    uint8_t MaxManipulate;
+    uint8_t Simulation;
+    uint16_t Unused[1];
+    uint64_t KernBase;
+    uint64_t PsLoadedModuleList;
+    uint64_t DebuggerDataList;
+} DBGKD_GET_VERSION64, *PDBGKD_GET_VERSION64;
+
+typedef struct _DBGKD_BREAKPOINTEX {
+    uint32_t BreakPointCount;
+    ntstatus_t ContinueStatus;
+} DBGKD_BREAKPOINTEX, *PDBGKD_BREAKPOINTEX;
+
+typedef struct _DBGKD_SEARCH_MEMORY {
+    union {
+        uint64_t SearchAddress;
+        uint64_t FoundAddress;
+    };
+    uint64_t SearchLength;
+    uint32_t PatternLength;
+} DBGKD_SEARCH_MEMORY, *PDBGKD_SEARCH_MEMORY;
+
+typedef struct _DBGKD_GET_SET_BUS_DATA {
+    uint32_t BusDataType;
+    uint32_t BusNumber;
+    uint32_t SlotNumber;
+    uint32_t Offset;
+    uint32_t Length;
+} DBGKD_GET_SET_BUS_DATA, *PDBGKD_GET_SET_BUS_DATA;
+
+typedef struct _DBGKD_FILL_MEMORY {
+    uint64_t Address;
+    uint32_t Length;
+    uint16_t Flags;
+    uint16_t PatternLength;
+} DBGKD_FILL_MEMORY, *PDBGKD_FILL_MEMORY;
+
+typedef struct _DBGKD_QUERY_MEMORY {
+    uint64_t Address;
+    uint64_t Reserved;
+    uint32_t AddressSpace;
+    uint32_t Flags;
+} DBGKD_QUERY_MEMORY, *PDBGKD_QUERY_MEMORY;
+
+typedef struct _DBGKD_SWITCH_PARTITION {
+    uint32_t Partition;
+} DBGKD_SWITCH_PARTITION;
+
+typedef struct _DBGKD_CONTEXT_EX {
+   uint32_t Offset;
+   uint32_t ByteCount;
+   uint32_t BytesCopied;
+} DBGKD_CONTEXT_EX, *PDBGKD_CONTEXT_EX;
+
+typedef struct _DBGKD_WRITE_CUSTOM_BREAKPOINT {
+   uint64_t BreakPointAddress;
+   uint64_t BreakPointInstruction;
+   uint32_t BreakPointHandle;
+   uint16_t BreakPointInstructionSize;
+   uint16_t BreakPointInstructionAlignment;
+} DBGKD_WRITE_CUSTOM_BREAKPOINT, *PDBGKD_WRITE_CUSTOM_BREAKPOINT;
+
+/*
+ * DBGKD Structure for Manipulate
+ */
+typedef struct _DBGKD_MANIPULATE_STATE32 {
+    uint32_t ApiNumber;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    ntstatus_t ReturnStatus;
+    union {
+        DBGKD_READ_MEMORY32 ReadMemory;
+        DBGKD_WRITE_MEMORY32 WriteMemory;
+        DBGKD_READ_MEMORY64 ReadMemory64;
+        DBGKD_WRITE_MEMORY64 WriteMemory64;
+        DBGKD_GET_CONTEXT GetContext;
+        DBGKD_SET_CONTEXT SetContext;
+        DBGKD_WRITE_BREAKPOINT32 WriteBreakPoint;
+        DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
+        DBGKD_CONTINUE Continue;
+        DBGKD_CONTINUE2 Continue2;
+        DBGKD_READ_WRITE_IO32 ReadWriteIo;
+        DBGKD_READ_WRITE_IO_EXTENDED32 ReadWriteIoExtended;
+        DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
+        DBGKD_SET_SPECIAL_CALL32 SetSpecialCall;
+        DBGKD_SET_INTERNAL_BREAKPOINT32 SetInternalBreakpoint;
+        DBGKD_GET_INTERNAL_BREAKPOINT32 GetInternalBreakpoint;
+        DBGKD_GET_VERSION32 GetVersion32;
+        DBGKD_BREAKPOINTEX BreakPointEx;
+        DBGKD_READ_WRITE_MSR ReadWriteMsr;
+        DBGKD_SEARCH_MEMORY SearchMemory;
+        DBGKD_GET_SET_BUS_DATA GetSetBusData;
+        DBGKD_FILL_MEMORY FillMemory;
+        DBGKD_QUERY_MEMORY QueryMemory;
+        DBGKD_SWITCH_PARTITION SwitchPartition;
+    } u;
+} DBGKD_MANIPULATE_STATE32, *PDBGKD_MANIPULATE_STATE32;
+
+typedef struct _DBGKD_MANIPULATE_STATE64 {
+    uint32_t ApiNumber;
+    uint16_t ProcessorLevel;
+    uint16_t Processor;
+    ntstatus_t ReturnStatus;
+    union {
+        DBGKD_READ_MEMORY64 ReadMemory;
+        DBGKD_WRITE_MEMORY64 WriteMemory;
+        DBGKD_GET_CONTEXT GetContext;
+        DBGKD_SET_CONTEXT SetContext;
+        DBGKD_WRITE_BREAKPOINT64 WriteBreakPoint;
+        DBGKD_RESTORE_BREAKPOINT RestoreBreakPoint;
+        DBGKD_CONTINUE Continue;
+        DBGKD_CONTINUE2 Continue2;
+        DBGKD_READ_WRITE_IO64 ReadWriteIo;
+        DBGKD_READ_WRITE_IO_EXTENDED64 ReadWriteIoExtended;
+        DBGKD_QUERY_SPECIAL_CALLS QuerySpecialCalls;
+        DBGKD_SET_SPECIAL_CALL64 SetSpecialCall;
+        DBGKD_SET_INTERNAL_BREAKPOINT64 SetInternalBreakpoint;
+        DBGKD_GET_INTERNAL_BREAKPOINT64 GetInternalBreakpoint;
+        DBGKD_GET_VERSION64 GetVersion64;
+        DBGKD_BREAKPOINTEX BreakPointEx;
+        DBGKD_READ_WRITE_MSR ReadWriteMsr;
+        DBGKD_SEARCH_MEMORY SearchMemory;
+        DBGKD_GET_SET_BUS_DATA GetSetBusData;
+        DBGKD_FILL_MEMORY FillMemory;
+        DBGKD_QUERY_MEMORY QueryMemory;
+        DBGKD_SWITCH_PARTITION SwitchPartition;
+        DBGKD_WRITE_CUSTOM_BREAKPOINT WriteCustomBreakpoint;
+        DBGKD_CONTEXT_EX ContextEx;
+    } u;
+} DBGKD_MANIPULATE_STATE64, *PDBGKD_MANIPULATE_STATE64;
+
+/*
+ * File I/O Structure
+ */
+typedef struct _DBGKD_CREATE_FILE {
+    uint32_t DesiredAccess;
+    uint32_t FileAttributes;
+    uint32_t ShareAccess;
+    uint32_t CreateDisposition;
+    uint32_t CreateOptions;
+    uint64_t Handle;
+    uint64_t Length;
+} DBGKD_CREATE_FILE, *PDBGKD_CREATE_FILE;
+
+typedef struct _DBGKD_READ_FILE {
+    uint64_t Handle;
+    uint64_t Offset;
+    uint32_t Length;
+} DBGKD_READ_FILE, *PDBGKD_READ_FILE;
+
+typedef struct _DBGKD_WRITE_FILE {
+    uint64_t Handle;
+    uint64_t Offset;
+    uint32_t Length;
+} DBGKD_WRITE_FILE, *PDBGKD_WRITE_FILE;
+
+typedef struct _DBGKD_CLOSE_FILE {
+    uint64_t Handle;
+} DBGKD_CLOSE_FILE, *PDBGKD_CLOSE_FILE;
+
+typedef struct _DBGKD_FILE_IO {
+    uint32_t ApiNumber;
+    uint32_t Status;
+    union {
+        uint64_t ReserveSpace[7];
+        DBGKD_CREATE_FILE CreateFile;
+        DBGKD_READ_FILE ReadFile;
+        DBGKD_WRITE_FILE WriteFile;
+        DBGKD_CLOSE_FILE CloseFile;
+    } u;
+} DBGKD_FILE_IO, *PDBGKD_FILE_IO;
+
+/*
+ * Control Request Structure
+ */
+typedef struct _DBGKD_REQUEST_BREAKPOINT {
+    uint32_t HardwareBreakPointNumber;
+    uint32_t Available;
+} DBGKD_REQUEST_BREAKPOINT, *PDBGKD_REQUEST_BREAKPOINT;
+
+typedef struct _DBGKD_RELEASE_BREAKPOINT {
+    uint32_t HardwareBreakPointNumber;
+    uint32_t Released;
+} DBGKD_RELEASE_BREAKPOINT, *PDBGKD_RELEASE_BREAKPOINT;
+
+typedef struct _DBGKD_CONTROL_REQUEST {
+    uint32_t ApiNumber;
+    union {
+        DBGKD_REQUEST_BREAKPOINT RequestBreakpoint;
+        DBGKD_RELEASE_BREAKPOINT ReleaseBreakpoint;
+    } u;
+} DBGKD_CONTROL_REQUEST, *PDBGKD_CONTROL_REQUEST;
+
+/*
+ * Trace I/O Structure
+ */
+typedef struct _DBGKD_PRINT_TRACE {
+    uint32_t LengthOfData;
+} DBGKD_PRINT_TRACE, *PDBGKD_PRINT_TRACE;
+
+typedef struct _DBGKD_TRACE_IO {
+   uint32_t ApiNumber;
+   uint16_t ProcessorLevel;
+   uint16_t Processor;
+   union {
+       uint64_t ReserveSpace[7];
+       DBGKD_PRINT_TRACE PrintTrace;
+   } u;
+} DBGKD_TRACE_IO, *PDBGKD_TRACE_IO;
+
+#endif /* WINDBGKD_H */
include/exec/windbgstub-utils.h +1 -0
index 11487be465..e80b9cba8f 100644
@@ -14,5 +14,6 @@
 
 #include "qemu/osdep.h"
 #include "exec/windbgstub.h"
+#include "exec/windbgkd.h"
 
 #endif /* WINDBGSTUB_UTILS_H */
#3 lore raw

PATCH 3/39 windbg: add -windbg option

In reply to Mikhail Abakumov

This option starts windbg server.

---
 qemu-options.hx |    8 ++++++++
 vl.c            |    8 ++++++++
 2 files changed, 16 insertions(+)
qemu-options.hx +8 -0
index f7df472f43..13b1157114 100644
@@ -3317,6 +3317,14 @@ Shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port 1234
 (@pxref{gdb_usage}).
 ETEXI
 
+DEF("windbg", HAS_ARG, QEMU_OPTION_windbg, \
+    "-windbg         wait for windbg connection\n", QEMU_ARCH_I386)
+STEXI
+@item -windbg
+@findex -windbg
+Wait for windbg connection.
+ETEXI
+
 DEF("d", HAS_ARG, QEMU_OPTION_d, \
     "-d item1,...    enable logging of specified items (use '-d help' for a list of log items)\n",
     QEMU_ARCH_ALL)
vl.c +8 -0
index fa25d1ae2d..bfcecf9a5c 100644
@@ -76,6 +76,7 @@ int main(int argc, char **argv)
 #include "sysemu/sysemu.h"
 #include "sysemu/numa.h"
 #include "exec/gdbstub.h"
+#include "exec/windbgstub.h"
 #include "qemu/timer.h"
 #include "chardev/char.h"
 #include "qemu/bitmap.h"
@@ -2372,6 +2373,7 @@ struct device_config {
         DEV_VIRTCON,   /* -virtioconsole */
         DEV_DEBUGCON,  /* -debugcon */
         DEV_GDB,       /* -gdb, -s */
+        DEV_WINDBG,    /* -windbg */
         DEV_SCLP,      /* s390 sclp */
     } type;
     const char *cmdline;
@@ -3324,6 +3326,9 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_gdb:
                 add_device_config(DEV_GDB, optarg);
                 break;
+            case QEMU_OPTION_windbg:
+                 add_device_config(DEV_WINDBG, optarg);
+                 break;
             case QEMU_OPTION_L:
                 if (is_help_option(optarg)) {
                     list_data_dirs = true;
@@ -4464,6 +4469,9 @@ int main(int argc, char **argv, char **envp)
     qemu_opts_foreach(qemu_find_opts("mon"),
                       mon_init_func, NULL, &error_fatal);
 
+    if (foreach_device_config(DEV_WINDBG, windbg_server_start) < 0) {
+        exit(1);
+    }
     if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
         exit(1);
     if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
#4 lore raw

PATCH 4/39 windbg: add helper features

In reply to Mikhail Abakumov

Add some helper features for windbgstub.

---
 include/exec/windbgstub-utils.h |   40 +++++++++++++++++++
 include/exec/windbgstub.h       |    6 +++
 windbgstub-utils.c              |   83 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 129 insertions(+)
include/exec/windbgstub-utils.h +40 -0
index e80b9cba8f..e7db062289 100644
@@ -13,7 +13,47 @@
 #define WINDBGSTUB_UTILS_H
 
 #include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "log.h"
+#include "cpu.h"
 #include "exec/windbgstub.h"
 #include "exec/windbgkd.h"
 
+#define DPRINTF(fmt, ...)                                                      \
+    do {                                                                       \
+        if (WINDBG_DPRINT) {                                                   \
+            qemu_log("windbg: " fmt, ##__VA_ARGS__);                           \
+        }                                                                      \
+    } while (0)
+
+#define WINDBG_ERROR(...) error_report("windbg: " __VA_ARGS__)
+
+#define FMT_ADDR "addr:0x" TARGET_FMT_lx
+#define FMT_ERR "Error:%d"
+
+#define PTR(var) ((uint8_t *) (&var))
+
+#define VMEM_ADDR(cpu, addr)                                                   \
+    ({                                                                         \
+        target_ulong _addr;                                                    \
+        cpu_memory_rw_debug(cpu, addr, PTR(_addr), sizeof(target_ulong), 0);   \
+        ldtul_p(&_addr);                                                       \
+    })
+
+#if TARGET_LONG_BITS == 64
+#define sttul_p(p, v) stq_p(p, v)
+#define ldtul_p(p) ldq_p(p)
+#else
+#define sttul_p(p, v) stl_p(p, v)
+#define ldtul_p(p) ldl_p(p)
+#endif
+
+typedef struct InitedAddr {
+    target_ulong addr;
+    bool is_init;
+} InitedAddr;
+
+const char *kd_api_name(int id);
+const char *kd_pkt_type_name(int id);
+
 #endif /* WINDBGSTUB_UTILS_H */
include/exec/windbgstub.h +6 -0
index 9656c152ef..576acb1ee8 100644
@@ -12,6 +12,12 @@
 #ifndef WINDBGSTUB_H
 #define WINDBGSTUB_H
 
+#ifdef DEBUG_WINDBG
+#define WINDBG_DPRINT true
+#else
+#define WINDBG_DPRINT false
+#endif
+
 int windbg_server_start(const char *device);
 
 #endif /* WINDBGSTUB_H */
windbgstub-utils.c +83 -0

86 lines not on this page · raw message

#5 lore raw

PATCH 5/39 windbg: add WindbgState

In reply to Mikhail Abakumov

Add definition of the WindbgState struct and its initialization.

---
 windbgstub.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
windbgstub.c +31 -0
index 4673703b66..b073cc6a3f 100644
@@ -13,7 +13,38 @@
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
 
+typedef struct WindbgState {
+    bool is_loaded;
+    bool catched_breakin_byte;
+    uint32_t wait_packet_type;
+    uint32_t curr_packet_id;
+} WindbgState;
+
+static WindbgState *windbg_state;
+
+static void windbg_state_clean(WindbgState *state)
+{
+    state->is_loaded = false;
+    state->catched_breakin_byte = false;
+    state->wait_packet_type = 0;
+    state->curr_packet_id = INITIAL_PACKET_ID | SYNC_PACKET_ID;
+}
+
+static void windbg_exit(void)
+{
+    g_free(windbg_state);
+}
+
 int windbg_server_start(const char *device)
 {
+    if (windbg_state) {
+        WINDBG_ERROR("Multiple instances of windbg are not supported.");
+        exit(1);
+    }
+
+    windbg_state = g_new0(WindbgState, 1);
+    windbg_state_clean(windbg_state);
+
+    atexit(windbg_exit);
     return 0;
 }
#6 lore raw

PATCH 6/39 windbg: add chardev

In reply to Mikhail Abakumov

Add chardev for listening to windbg client. Target device is a parameter in the '-windbg' option.

---
 windbgstub.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
windbgstub.c +31 -0
index b073cc6a3f..85e2215f73 100644
@@ -10,6 +10,10 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "chardev/char.h"
+#include "chardev/char-fe.h"
+#include "qemu/cutils.h"
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
 
@@ -18,6 +22,8 @@ typedef struct WindbgState {
     bool catched_breakin_byte;
     uint32_t wait_packet_type;
     uint32_t curr_packet_id;
+
+    CharBackend chr;
 } WindbgState;
 
 static WindbgState *windbg_state;
@@ -30,6 +36,15 @@ static void windbg_state_clean(WindbgState *state)
     state->curr_packet_id = INITIAL_PACKET_ID | SYNC_PACKET_ID;
 }
 
+static int windbg_chr_can_receive(void *opaque)
+{
+    return PACKET_MAX_SIZE;
+}
+
+static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size)
+{
+}
+
 static void windbg_exit(void)
 {
     g_free(windbg_state);
@@ -37,14 +52,30 @@ static void windbg_exit(void)
 
 int windbg_server_start(const char *device)
 {
+    Chardev *chr = NULL;
+
     if (windbg_state) {
         WINDBG_ERROR("Multiple instances of windbg are not supported.");
         exit(1);
     }
 
+    if (!strstart(device, "pipe:", NULL)) {
+        WINDBG_ERROR("Unsupported device. Supported only pipe.");
+        exit(1);
+    }
+
     windbg_state = g_new0(WindbgState, 1);
     windbg_state_clean(windbg_state);
 
+    chr = qemu_chr_new_noreplay("windbg", device, true);
+    if (!chr) {
+        return -1;
+    }
+
+    qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort);
+    qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive,
+                             windbg_chr_receive, NULL, NULL, NULL, NULL, true);
+
     atexit(windbg_exit);
     return 0;
 }
#7 lore raw

PATCH 7/39 windbg: hook to wrmsr operation

In reply to Mikhail Abakumov

Insert hook to wrmsr operation. Windows kernel put address on KPCR struct to fs/gs (x32/x64) register. Needs catch this moment and allow windbgstub handle packets from client.

---
 include/exec/windbgstub-utils.h |    3 +++
 include/exec/windbgstub.h       |    2 ++
 stubs/windbgstub.c              |    4 ++++
 target/i386/misc_helper.c       |    3 +++
 target/i386/windbgstub.c        |    9 +++++++++
 windbgstub.c                    |   24 ++++++++++++++++++++++++
 6 files changed, 45 insertions(+)
include/exec/windbgstub-utils.h +3 -0
index e7db062289..e076227b39 100644
@@ -56,4 +56,7 @@ typedef struct InitedAddr {
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
+bool windbg_on_load(void);
+void windbg_on_reset(void);
+
 #endif /* WINDBGSTUB_UTILS_H */
include/exec/windbgstub.h +2 -0
index 576acb1ee8..daa413da41 100644
@@ -18,6 +18,8 @@
 #define WINDBG_DPRINT false
 #endif
 
+void windbg_try_load(void);
+
 int windbg_server_start(const char *device);
 
 #endif /* WINDBGSTUB_H */
stubs/windbgstub.c +4 -0
index 36ad918dad..67205ae1f7 100644
@@ -12,6 +12,10 @@
 #include "qemu/osdep.h"
 #include "exec/windbgstub.h"
 
+void windbg_try_load(void)
+{
+}
+
 int windbg_server_start(const char *device)
 {
     return 0;
target/i386/misc_helper.c +3 -0
index 78f2020ef2..6ae67cf885 100644
@@ -24,6 +24,7 @@
 #include "exec/exec-all.h"
 #include "exec/cpu_ldst.h"
 #include "exec/address-spaces.h"
+#include "exec/windbgstub.h"
 
 void helper_outb(CPUX86State *env, uint32_t port, uint32_t data)
 {
@@ -385,6 +386,8 @@ void helper_wrmsr(CPUX86State *env)
         /* XXX: exception? */
         break;
     }
+
+    windbg_try_load();
 }
 
 void helper_rdmsr(CPUX86State *env)
target/i386/windbgstub.c +9 -0
index 8caaa7cd38..e55054c63d 100644
@@ -11,3 +11,12 @@
 
 #include "qemu/osdep.h"
 #include "exec/windbgstub-utils.h"
+
+bool windbg_on_load(void)
+{
+    return false;
+}
+
+void windbg_on_reset(void)
+{
+}
windbgstub.c +24 -0
index 85e2215f73..d7fadda096 100644
@@ -14,6 +14,8 @@
 #include "chardev/char.h"
 #include "chardev/char-fe.h"
 #include "qemu/cutils.h"
+#include "sysemu/reset.h"
+#include "sysemu/kvm.h"
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
 
@@ -50,6 +52,21 @@ static void windbg_exit(void)
     g_free(windbg_state);
 }
 
+static void windbg_handle_reset(void *opaque)
+{
+    windbg_state_clean(windbg_state);
+    windbg_on_reset();
+}
+
+void windbg_try_load(void)
+{
+    if (windbg_state && !windbg_state->is_loaded) {
+        if (windbg_on_load()) {
+            windbg_state->is_loaded = true;
+        }
+    }
+}
+
 int windbg_server_start(const char *device)
 {
     Chardev *chr = NULL;
@@ -59,6 +76,11 @@ int windbg_server_start(const char *device)
         exit(1);
     }
 
+    if (kvm_enabled()) {
+        WINDBG_ERROR("KVM is not supported.");
+        exit(1);
+    }
+
     if (!strstart(device, "pipe:", NULL)) {
         WINDBG_ERROR("Unsupported device. Supported only pipe.");
         exit(1);
@@ -76,6 +98,8 @@ int windbg_server_start(const char *device)
     qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive,
                              windbg_chr_receive, NULL, NULL, NULL, NULL, true);
 
+    qemu_register_reset(windbg_handle_reset, NULL);
+
     atexit(windbg_exit);
     return 0;
 }
#8 lore raw

PATCH 8/39 windbg: implement windbg_on_load

In reply to Mikhail Abakumov

Define addresses that must be found on loading stage.

---
 target/i386/windbgstub.c |   48 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)
target/i386/windbgstub.c +47 -1
index e55054c63d..1c1631d7c1 100644
@@ -12,11 +12,57 @@
 #include "qemu/osdep.h"
 #include "exec/windbgstub-utils.h"
 
+static InitedAddr KPCR;
+#ifdef TARGET_X86_64
+static InitedAddr kdDebuggerDataBlock;
+#else  /* TARGET_I386 */
+static InitedAddr kdVersion;
+#endif /* TARGET_I386 */
+
+static bool find_KPCR(CPUState *cs)
+{
+    return KPCR.is_init;
+}
+
+#ifdef TARGET_X86_64
+static bool find_kdDebuggerDataBlock(CPUState *cs)
+{
+    return kdDebuggerDataBlock.is_init;
+}
+#else  /* TARGET_I386 */
+static bool find_kdVersion(CPUState *cs)
+{
+    return kdVersion.is_init;
+}
+#endif /* TARGET_I386 */
+
 bool windbg_on_load(void)
 {
-    return false;
+    CPUState *cs = qemu_get_cpu(0);
+
+    if (!find_KPCR(cs)) {
+        return false;
+    }
+
+#ifdef TARGET_X86_64
+    if (!find_kdDebuggerDataBlock(cs)) {
+        return false;
+    }
+#else
+    if (!find_kdVersion(cs)) {
+        return false;
+    }
+#endif
+
+    return true;
 }
 
 void windbg_on_reset(void)
 {
+    KPCR.is_init = false;
+#ifdef TARGET_X86_64
+    kdDebuggerDataBlock.is_init = false;
+#else
+    kdVersion.is_init = false;
+#endif
 }
#9 lore raw

PATCH 9/39 windbg: implement find_KPCR

In reply to Mikhail Abakumov
---
 target/i386/windbgstub.c |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
target/i386/windbgstub.c +32 -0
index 1c1631d7c1..15a90e521c 100644
@@ -12,6 +12,18 @@
 #include "qemu/osdep.h"
 #include "exec/windbgstub-utils.h"
 
+#ifdef TARGET_X86_64
+#define OFFSET_KPCR_SELF 0x18
+#else  /* TARGET_I386 */
+#define OFFSET_KPCR_SELF 0x1C
+#endif /* TARGET_I386 */
+
+#ifdef TARGET_X86_64
+#define TARGET_SAFE(i386_obj, x86_64_obj) x86_64_obj
+#else  /* TARGET_I386 */
+#define TARGET_SAFE(i386_obj, x86_64_obj) i386_obj
+#endif /* TARGET_I386 */
+
 static InitedAddr KPCR;
 #ifdef TARGET_X86_64
 static InitedAddr kdDebuggerDataBlock;
@@ -21,6 +33,26 @@ static InitedAddr kdVersion;
 
 static bool find_KPCR(CPUState *cs)
 {
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    if (!KPCR.is_init) {
+        KPCR.addr = env->segs[TARGET_SAFE(R_FS, R_GS)].base;
+
+        static target_ulong prev_KPCR;
+        if (!KPCR.addr || prev_KPCR == KPCR.addr) {
+            return false;
+        }
+        prev_KPCR = KPCR.addr;
+
+        if (KPCR.addr != VMEM_ADDR(cs, KPCR.addr + OFFSET_KPCR_SELF)) {
+            return false;
+        }
+        KPCR.is_init = true;
+
+        DPRINTF("find KPCR " FMT_ADDR "\n", KPCR.addr);
+    }
+
     return KPCR.is_init;
 }
 
#10 lore raw

PATCH 10/39 windbg: implement find_kdVersion

In reply to Mikhail Abakumov
---
 target/i386/windbgstub.c |   11 +++++++++++
 1 file changed, 11 insertions(+)
target/i386/windbgstub.c +11 -0
index 15a90e521c..dc58f5a8cc 100644
@@ -16,6 +16,7 @@
 #define OFFSET_KPCR_SELF 0x18
 #else  /* TARGET_I386 */
 #define OFFSET_KPCR_SELF 0x1C
+#define OFFSET_KPCR_VERSION 0x34
 #endif /* TARGET_I386 */
 
 #ifdef TARGET_X86_64
@@ -64,6 +65,16 @@ static bool find_kdDebuggerDataBlock(CPUState *cs)
 #else  /* TARGET_I386 */
 static bool find_kdVersion(CPUState *cs)
 {
+    if (!kdVersion.is_init && KPCR.is_init) {
+        kdVersion.addr = VMEM_ADDR(cs, KPCR.addr + OFFSET_KPCR_VERSION);
+        if (!kdVersion.addr) {
+            return false;
+        }
+        kdVersion.is_init = true;
+
+        DPRINTF("find kdVersion " FMT_ADDR, kdVersion.addr);
+    }
+
     return kdVersion.is_init;
 }
 #endif /* TARGET_I386 */
#11 lore raw

PATCH 11/39 windbg: add windbg_search_vmaddr

In reply to Mikhail Abakumov

Add function to search in virtual memory.
Implemented Boyer-Moore search algorithm.

---
 include/exec/windbgstub-utils.h |    4 +
 windbgstub-utils.c              |  117 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)
include/exec/windbgstub-utils.h +4 -0
index e076227b39..2760684cfb 100644
@@ -59,4 +59,8 @@ const char *kd_pkt_type_name(int id);
 bool windbg_on_load(void);
 void windbg_on_reset(void);
 
+InitedAddr windbg_search_vmaddr(CPUState *cs, target_ulong start,
+                                target_ulong finish, const uint8_t *pattern,
+                                int pLen);
+
 #endif /* WINDBGSTUB_UTILS_H */
windbgstub-utils.c +117 -0

123 lines not on this page · raw message

#12 lore raw

PATCH 12/39 windbg: implement find_kdDebuggerDataBlock

In reply to Mikhail Abakumov

It is necessary to find address on the structure kdDebuggerDataBlock, which is located somewhere at kernel .data section.

We can find it in structure defined in kernel:
typedef struct _DBGKD_DEBUG_DATA_HEADER

{
    LIST_ENTRY64 List;
    ULONG OwnerTag;
    ULONG Size;
} DBGKD_DEBUG_DATA_HEADER, *PDBGKD_DEBUG_DATA_HEEADER;

where OwnerTag == 'KDBG',
then List == kdDebuggerDataBlock.

---
 target/i386/windbgstub.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
target/i386/windbgstub.c +47 -0
index dc58f5a8cc..f1bab10b10 100644
@@ -14,6 +14,7 @@
 
 #ifdef TARGET_X86_64
 #define OFFSET_KPCR_SELF 0x18
+#define OFFSET_KPCR_LOCK_ARRAY 0x28
 #else  /* TARGET_I386 */
 #define OFFSET_KPCR_SELF 0x1C
 #define OFFSET_KPCR_VERSION 0x34
@@ -60,6 +61,52 @@ static bool find_KPCR(CPUState *cs)
 #ifdef TARGET_X86_64
 static bool find_kdDebuggerDataBlock(CPUState *cs)
 {
+    target_ulong lockArray;
+    target_ulong dDataList;
+    const uint8_t tag[] = { 'K', 'D', 'B', 'G' };
+    target_ulong start = 0xfffff80000000000LL;
+    target_ulong finish = 0xfffff81000000000LL;
+    InitedAddr find;
+
+    /* kdDebuggerDataBlock is located in
+         - range of [0xfffff80000000000 ... 0xfffff81000000000]
+         - at offset of ('KDBG') - 0x10 */
+
+    if (!kdDebuggerDataBlock.is_init && KPCR.is_init) {
+        /* At first, find lockArray. If it is NULL,
+           then kdDebuggerDataBlock is also NULL (empirically). */
+        lockArray = VMEM_ADDR(cs, KPCR.addr + OFFSET_KPCR_LOCK_ARRAY);
+        if (!lockArray) {
+            return false;
+        }
+        DPRINTF("find LockArray " FMT_ADDR "\n", lockArray);
+
+        while (true) {
+            find = windbg_search_vmaddr(cs, start, finish, tag,
+                                        ARRAY_SIZE(tag));
+            if (!find.is_init) {
+                return false;
+            }
+
+            /* Valid address to 'KDBG ' is always aligned */
+            if (!(find.addr & 0xf)) {
+                dDataList = VMEM_ADDR(cs, find.addr - 0x10);
+
+                /* Valid address to 'dDataList ' is always
+                   in range [0xfffff80000000000 ... 0xfffff8ffffffffff] */
+                if ((dDataList >> 40) == 0xfffff8) {
+                    kdDebuggerDataBlock.addr = find.addr - 0x10;
+                    kdDebuggerDataBlock.is_init = true;
+                    DPRINTF("find kdDebuggerDataBlock " FMT_ADDR "\n",
+                            kdDebuggerDataBlock.addr);
+                    break;
+                }
+            }
+
+            start = find.addr + 0x8; /* next addr */
+        }
+    }
+
     return kdDebuggerDataBlock.is_init;
 }
 #else  /* TARGET_I386 */
#13 lore raw

PATCH 13/39 windbg: parsing data stream

In reply to Mikhail Abakumov

Add parsing data stream to packets from windbg client.

---
 include/exec/windbgstub-utils.h |   11 +++
 windbgstub.c                    |  139 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+)
include/exec/windbgstub-utils.h +11 -0
index 2760684cfb..a28068eecd 100644
@@ -53,6 +53,17 @@ typedef struct InitedAddr {
     bool is_init;
 } InitedAddr;
 
+typedef struct PacketData {
+    union {
+        struct {
+            DBGKD_MANIPULATE_STATE64 m64;
+            uint8_t extra[0];
+        };
+        uint8_t buf[PACKET_MAX_SIZE];
+    };
+    uint16_t extra_size;
+} PacketData;
+
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
windbgstub.c +139 -0

169 lines not on this page · raw message

#14 lore raw

PATCH 14/39 windbg: send data and control packets

In reply to Mikhail Abakumov
---
 windbgstub.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
windbgstub.c +59 -0
index 2869d94389..c45faec43f 100644
@@ -71,6 +71,65 @@ static void windbg_state_clean(WindbgState *state)
     state->ctx.result = RESULT_NONE;
 }
 
+static uint32_t compute_checksum(uint8_t *data, uint16_t len)
+{
+    uint32_t checksum = 0;
+    while (len) {
+        --len;
+        checksum += *data++;
+    }
+    return checksum;
+}
+
+static void windbg_store_packet(KD_PACKET *packet)
+{
+    stw_p(&packet->PacketLeader, packet->PacketLeader);
+    stw_p(&packet->PacketType, packet->PacketType);
+    stw_p(&packet->ByteCount, packet->ByteCount);
+    stl_p(&packet->PacketId, packet->PacketId);
+    stl_p(&packet->Checksum, packet->Checksum);
+}
+
+__attribute__ ((unused)) /* unused yet */
+static void windbg_send_data_packet(WindbgState *state, uint8_t *data,
+                                    uint16_t byte_count, uint16_t type)
+{
+    const uint8_t trailing_byte = PACKET_TRAILING_BYTE;
+
+    KD_PACKET packet = {
+        .PacketLeader = PACKET_LEADER,
+        .PacketType = type,
+        .ByteCount = byte_count,
+        .PacketId = state->curr_packet_id,
+        .Checksum = compute_checksum(data, byte_count),
+    };
+
+    windbg_store_packet(&packet);
+
+    qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
+    qemu_chr_fe_write(&state->chr, data, byte_count);
+    qemu_chr_fe_write(&state->chr, &trailing_byte, sizeof(trailing_byte));
+
+    state->wait_packet_type = PACKET_TYPE_KD_ACKNOWLEDGE;
+}
+
+__attribute__ ((unused)) /* unused yet */
+static void windbg_send_control_packet(WindbgState *state, uint16_t type,
+                                       uint32_t id)
+{
+    KD_PACKET packet = {
+        .PacketLeader = CONTROL_PACKET_LEADER,
+        .PacketType = type,
+        .ByteCount = 0,
+        .PacketId = id,
+        .Checksum = 0,
+    };
+
+    windbg_store_packet(&packet);
+
+    qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
+}
+
 static void windbg_ctx_handler(WindbgState *state)
 {
 }
#15 lore raw

PATCH 15/39 windbg: handler of parsing context

In reply to Mikhail Abakumov
---
 windbgstub.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)
windbgstub.c +53 -1
index c45faec43f..fe0b007a06 100644
@@ -15,6 +15,7 @@
 #include "chardev/char-fe.h"
 #include "qemu/cutils.h"
 #include "sysemu/reset.h"
+#include "sysemu/sysemu.h"
 #include "sysemu/kvm.h"
 #include "exec/windbgstub.h"
 #include "exec/windbgstub-utils.h"
@@ -113,7 +114,6 @@ static void windbg_send_data_packet(WindbgState *state, uint8_t *data,
     state->wait_packet_type = PACKET_TYPE_KD_ACKNOWLEDGE;
 }
 
-__attribute__ ((unused)) /* unused yet */
 static void windbg_send_control_packet(WindbgState *state, uint16_t type,
                                        uint32_t id)
 {
@@ -130,8 +130,52 @@ static void windbg_send_control_packet(WindbgState *state, uint16_t type,
     qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
 }
 
+static void windbg_vm_stop(void)
+{
+    vm_stop(RUN_STATE_PAUSED);
+}
+
+static void windbg_process_data_packet(WindbgState *state)
+{
+}
+
+static void windbg_process_control_packet(WindbgState *state)
+{
+}
+
 static void windbg_ctx_handler(WindbgState *state)
 {
+    if (!state->is_loaded) {
+        if (state->ctx.result == RESULT_BREAKIN_BYTE) {
+            state->catched_breakin_byte = true;
+        }
+        return;
+    }
+
+    switch (state->ctx.result) {
+    case RESULT_NONE:
+        break;
+
+    case RESULT_BREAKIN_BYTE:
+        windbg_vm_stop();
+        break;
+
+    case RESULT_CONTROL_PACKET:
+        windbg_process_control_packet(state);
+        break;
+
+    case RESULT_DATA_PACKET:
+        windbg_process_data_packet(state);
+        break;
+
+    case RESULT_UNKNOWN_PACKET:
+    case RESULT_ERROR:
+        windbg_send_control_packet(state, PACKET_TYPE_KD_RESEND, 0);
+        break;
+
+    default:
+        break;
+    }
 }
 
 static void windbg_read_byte(ParsingContext *ctx, uint8_t byte)
@@ -260,6 +304,14 @@ void windbg_try_load(void)
     if (windbg_state && !windbg_state->is_loaded) {
         if (windbg_on_load()) {
             windbg_state->is_loaded = true;
+
+            /* Handle last packet. Or we can require resend last packet. */
+            windbg_ctx_handler(windbg_state);
+
+            if (windbg_state->catched_breakin_byte == true) {
+                windbg_vm_stop();
+                windbg_state->catched_breakin_byte = false;
+            }
         }
     }
 }
#16 lore raw

PATCH 16/39 windbg: init DBGKD_ANY_WAIT_STATE_CHANGE

In reply to Mikhail Abakumov

Add function for init DBGKD_ANY_WAIT_STATE_CHANGE. It is a header of 'state change' packets.

---
 target/i386/windbgstub.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
target/i386/windbgstub.c +45 -0
index f1bab10b10..b2ac7a6d5f 100644
@@ -15,9 +15,13 @@
 #ifdef TARGET_X86_64
 #define OFFSET_KPCR_SELF 0x18
 #define OFFSET_KPCR_LOCK_ARRAY 0x28
+#define OFFSET_KPRCB 0x20
+#define OFFSET_KPRCB_CURRTHREAD 0x8
 #else  /* TARGET_I386 */
 #define OFFSET_KPCR_SELF 0x1C
 #define OFFSET_KPCR_VERSION 0x34
+#define OFFSET_KPRCB 0x20
+#define OFFSET_KPRCB_CURRTHREAD 0x4
 #endif /* TARGET_I386 */
 
 #ifdef TARGET_X86_64
@@ -156,3 +160,44 @@ void windbg_on_reset(void)
     kdVersion.is_init = false;
 #endif
 }
+
+__attribute__ ((unused)) /* unused yet */
+static void kd_init_state_change(CPUState *cs, DBGKD_ANY_WAIT_STATE_CHANGE *sc)
+{
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+    DBGKD_CONTROL_REPORT *cr = &sc->ControlReport;
+    target_ulong KPRCB = VMEM_ADDR(cs, KPCR.addr + OFFSET_KPRCB);
+    target_ulong thread = VMEM_ADDR(cs, KPRCB + OFFSET_KPRCB_CURRTHREAD);
+    int number_processors = 0;
+
+    CPUState *cpu_tmp;
+    CPU_FOREACH(cpu_tmp) {
+        ++number_processors;
+    }
+
+    /* HEADER */
+
+    /* TODO: Fix this hardcoded value. */
+    stw_p(&sc->ProcessorLevel, 0);
+    /* TODO: Fix this hardcoded value. */
+    stw_p(&sc->Processor, 0);
+    stl_p(&sc->NumberProcessors, number_processors);
+    sttul_p(&sc->Thread, thread);
+    sttul_p(&sc->ProgramCounter, env->eip);
+
+    /* CONTROL REPORT */
+
+    sttul_p(&cr->Dr6, env->dr[6]);
+    sttul_p(&cr->Dr7, env->dr[7]);
+    stw_p(&cr->ReportFlags, REPORT_INCLUDES_SEGS | REPORT_STANDARD_CS);
+    stw_p(&cr->SegCs, env->segs[R_CS].selector);
+    stw_p(&cr->SegDs, env->segs[R_DS].selector);
+    stw_p(&cr->SegEs, env->segs[R_ES].selector);
+    stw_p(&cr->SegFs, env->segs[R_FS].selector);
+    stl_p(&cr->EFlags, env->eflags);
+
+    /* This is a feature */
+    memset(cr->InstructionStream, 0, DBGKD_MAXSTREAM);
+    stw_p(&cr->InstructionCount, 0);
+}
#17 lore raw

PATCH 17/39 windbg: generate ExceptionStateChange and LoadSymbolsStateChange

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    3 +++
 target/i386/windbgstub.c        |   33 ++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 1 deletion(-)
include/exec/windbgstub-utils.h +3 -0
index a28068eecd..794cb387b0 100644
@@ -67,6 +67,9 @@ typedef struct PacketData {
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_ls(CPUState *cs);
+
 bool windbg_on_load(void);
 void windbg_on_reset(void);
 
target/i386/windbgstub.c +32 -1
index b2ac7a6d5f..37c5805818 100644
@@ -161,7 +161,6 @@ void windbg_on_reset(void)
 #endif
 }
 
-__attribute__ ((unused)) /* unused yet */
 static void kd_init_state_change(CPUState *cs, DBGKD_ANY_WAIT_STATE_CHANGE *sc)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -201,3 +200,35 @@ static void kd_init_state_change(CPUState *cs, DBGKD_ANY_WAIT_STATE_CHANGE *sc)
     memset(cr->InstructionStream, 0, DBGKD_MAXSTREAM);
     stw_p(&cr->InstructionCount, 0);
 }
+
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs)
+{
+    DBGKD_ANY_WAIT_STATE_CHANGE *sc = g_new0(DBGKD_ANY_WAIT_STATE_CHANGE, 1);
+    DBGKM_EXCEPTION_RECORD64 *exc = &sc->u.Exception.ExceptionRecord;
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    kd_init_state_change(cs, sc);
+
+    stl_p(&sc->NewState, DbgKdExceptionStateChange);
+    sttul_p(&exc->ExceptionAddress, env->eip);
+
+    /* TODO: Fix this hardcoded value. */
+    stl_p(&exc->ExceptionCode, 0x80000003);
+
+    return sc;
+}
+
+DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_ls(CPUState *cs)
+{
+    DBGKD_ANY_WAIT_STATE_CHANGE *sc = g_new0(DBGKD_ANY_WAIT_STATE_CHANGE, 1);
+
+    kd_init_state_change(cs, sc);
+
+    stl_p(&sc->NewState, DbgKdLoadSymbolsStateChange);
+
+    /* TODO: Path to load symbold (with extra array). */
+    stl_p(&sc->u.LoadSymbols.PathNameLength, 0);
+
+    return sc;
+}
#18 lore raw

PATCH 18/39 windbg: implement windbg_process_control_packet

In reply to Mikhail Abakumov
---
 windbgstub.c |   35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
windbgstub.c +34 -1
index fe0b007a06..f13c9a6c1e 100644
@@ -91,7 +91,6 @@ static void windbg_store_packet(KD_PACKET *packet)
     stl_p(&packet->Checksum, packet->Checksum);
 }
 
-__attribute__ ((unused)) /* unused yet */
 static void windbg_send_data_packet(WindbgState *state, uint8_t *data,
                                     uint16_t byte_count, uint16_t type)
 {
@@ -141,6 +140,40 @@ static void windbg_process_data_packet(WindbgState *state)
 
 static void windbg_process_control_packet(WindbgState *state)
 {
+    ParsingContext *ctx = &state->ctx;
+
+    switch (ctx->packet.PacketType) {
+    case PACKET_TYPE_KD_ACKNOWLEDGE:
+        if (state->wait_packet_type == PACKET_TYPE_KD_ACKNOWLEDGE &&
+            (ctx->packet.PacketId == (state->curr_packet_id &
+                                      ~SYNC_PACKET_ID))) {
+            state->curr_packet_id ^= 1;
+            state->wait_packet_type = 0;
+        }
+        break;
+
+    case PACKET_TYPE_KD_RESET: {
+        state->curr_packet_id = INITIAL_PACKET_ID;
+        windbg_send_control_packet(state, PACKET_TYPE_KD_RESET, 0);
+
+        DBGKD_ANY_WAIT_STATE_CHANGE *sc = kd_state_change_ls(qemu_get_cpu(0));
+        windbg_send_data_packet(state, (uint8_t *) sc,
+                                sizeof(DBGKD_ANY_WAIT_STATE_CHANGE),
+                                PACKET_TYPE_KD_STATE_CHANGE64);
+        g_free(sc);
+        break;
+    }
+
+    case PACKET_TYPE_KD_RESEND:
+        break;
+
+    default:
+        WINDBG_ERROR("Caught unsupported control packet 0x%x",
+                     ctx->packet.PacketType);
+
+        windbg_send_control_packet(state, PACKET_TYPE_KD_RESEND, 0);
+        break;
+    }
 }
 
 static void windbg_ctx_handler(WindbgState *state)
#19 lore raw

PATCH 19/39 windbg: implement windbg_process_data_packet

In reply to Mikhail Abakumov
---
 windbgstub.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
windbgstub.c +27 -0
index f13c9a6c1e..8cbece40da 100644
@@ -134,8 +134,35 @@ static void windbg_vm_stop(void)
     vm_stop(RUN_STATE_PAUSED);
 }
 
+static void windbg_process_manipulate_packet(WindbgState *state)
+{
+}
+
 static void windbg_process_data_packet(WindbgState *state)
 {
+    ParsingContext *ctx = &state->ctx;
+
+    if (state->wait_packet_type == PACKET_TYPE_KD_ACKNOWLEDGE) {
+        /* We received something different */
+        windbg_send_control_packet(state, PACKET_TYPE_KD_RESEND, 0);
+        return;
+    }
+
+    switch (ctx->packet.PacketType) {
+    case PACKET_TYPE_KD_STATE_MANIPULATE:
+        windbg_send_control_packet(state, PACKET_TYPE_KD_ACKNOWLEDGE,
+                                   ctx->packet.PacketId);
+        windbg_process_manipulate_packet(state);
+        state->curr_packet_id &= ~SYNC_PACKET_ID;
+        break;
+
+    default:
+        WINDBG_ERROR("Caught unsupported data packet 0x%x",
+                     ctx->packet.PacketType);
+
+        windbg_send_control_packet(state, PACKET_TYPE_KD_RESEND, 0);
+        break;
+    }
 }
 
 static void windbg_process_control_packet(WindbgState *state)
#20 lore raw

PATCH 20/39 windbg: implement windbg_process_manipulate_packet

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 ++
 windbgstub-utils.c              |    7 +++++++
 windbgstub.c                    |   27 +++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index 794cb387b0..1c577ddd49 100644
@@ -67,6 +67,8 @@ typedef struct PacketData {
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
+void kd_api_unsupported(CPUState *cs, PacketData *pd);
+
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_ls(CPUState *cs);
 
windbgstub-utils.c +7 -0
index dce82987bb..bbd95498f4 100644
@@ -197,6 +197,13 @@ InitedAddr windbg_search_vmaddr(CPUState *cs, target_ulong start,
     return ret;
 }
 
+void kd_api_unsupported(CPUState *cs, PacketData *pd)
+{
+    WINDBG_ERROR("Caught unimplemented api %s", kd_api_name(pd->m64.ApiNumber));
+    pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL;
+    pd->extra_size = 0;
+}
+
 const char *kd_api_name(int id)
 {
     return (id >= DbgKdMinimumManipulate && id < DbgKdMaximumManipulate)
windbgstub.c +27 -0
index 8cbece40da..6ed93b8ce9 100644
@@ -136,6 +136,33 @@ static void windbg_vm_stop(void)
 
 static void windbg_process_manipulate_packet(WindbgState *state)
 {
+    CPUState *cs;
+    ParsingContext *ctx = &state->ctx;
+    PacketData *data = &ctx->data;
+
+    data->extra_size = ctx->packet.ByteCount - sizeof(DBGKD_MANIPULATE_STATE64);
+    data->m64.ReturnStatus = STATUS_SUCCESS;
+
+    cs = qemu_get_cpu(data->m64.Processor);
+    if (cs == NULL) {
+        cs = qemu_get_cpu(0);
+    }
+
+    switch (data->m64.ApiNumber) {
+    default:
+        kd_api_unsupported(cs, data);
+        break;
+    }
+
+    if (data->m64.ReturnStatus == STATUS_UNSUCCESSFUL) {
+        WINDBG_ERROR("Caught error at %s", kd_api_name(data->m64.ApiNumber));
+    }
+
+    stl_p(&data->m64.ReturnStatus, data->m64.ReturnStatus);
+
+    windbg_send_data_packet(state, data->buf,
+                            data->extra_size + sizeof(DBGKD_MANIPULATE_STATE64),
+                            ctx->packet.PacketType);
 }
 
 static void windbg_process_data_packet(WindbgState *state)
#21 lore raw

PATCH 21/39 windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 ++
 windbgstub-utils.c              |   47 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |    8 +++++++
 3 files changed, 57 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index 1c577ddd49..638b2b9a6f 100644
@@ -67,6 +67,8 @@ typedef struct PacketData {
 const char *kd_api_name(int id);
 const char *kd_pkt_type_name(int id);
 
+void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
+void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
 
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
windbgstub-utils.c +47 -0

53 lines not on this page · raw message

windbgstub.c +8 -0
index 6ed93b8ce9..46400d9bad 100644
@@ -149,6 +149,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
     }
 
     switch (data->m64.ApiNumber) {
+    case DbgKdReadVirtualMemoryApi:
+        kd_api_read_virtual_memory(cs, data);
+        break;
+
+    case DbgKdWriteVirtualMemoryApi:
+        kd_api_write_virtual_memory(cs, data);
+        break;
+
     default:
         kd_api_unsupported(cs, data);
         break;
#22 lore raw

PATCH 22/39 windbg: some kernel structures

In reply to Mikhail Abakumov
---
 target/i386/windbgstub.c |  243 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 243 insertions(+)
target/i386/windbgstub.c +243 -0
index 37c5805818..5d47d5c9e9 100644
@@ -30,6 +30,249 @@
 #define TARGET_SAFE(i386_obj, x86_64_obj) i386_obj
 #endif /* TARGET_I386 */
 
+/*
+ * Next code copied from winnt.h
+ */
+#ifdef TARGET_X86_64
+
+#define CPU_CONTEXT_AMD64 0x100000
+
+#define CPU_CONTEXT_CONTROL (CPU_CONTEXT_AMD64 | 0x1)
+#define CPU_CONTEXT_INTEGER (CPU_CONTEXT_AMD64 | 0x2)
+#define CPU_CONTEXT_SEGMENTS (CPU_CONTEXT_AMD64 | 0x4)
+#define CPU_CONTEXT_FLOATING_POINT (CPU_CONTEXT_AMD64 | 0x8)
+#define CPU_CONTEXT_DEBUG_REGISTERS (CPU_CONTEXT_AMD64 | 0x10)
+
+#define CPU_CONTEXT_FULL \
+    (CPU_CONTEXT_CONTROL | CPU_CONTEXT_INTEGER | CPU_CONTEXT_FLOATING_POINT)
+#define CPU_CONTEXT_ALL \
+    (CPU_CONTEXT_FULL | CPU_CONTEXT_SEGMENTS | CPU_CONTEXT_DEBUG_REGISTERS)
+
+typedef struct _CPU_DESCRIPTOR {
+    uint16_t Pad[3];
+    uint16_t Limit;
+    uint64_t Base;
+} CPU_DESCRIPTOR, *PCPU_DESCRIPTOR;
+
+typedef struct _CPU_KSPECIAL_REGISTERS {
+    uint64_t Cr0;
+    uint64_t Cr2;
+    uint64_t Cr3;
+    uint64_t Cr4;
+    uint64_t KernelDr0;
+    uint64_t KernelDr1;
+    uint64_t KernelDr2;
+    uint64_t KernelDr3;
+    uint64_t KernelDr6;
+    uint64_t KernelDr7;
+    CPU_DESCRIPTOR Gdtr;
+    CPU_DESCRIPTOR Idtr;
+    uint16_t Tr;
+    uint16_t Ldtr;
+    uint32_t MxCsr;
+    uint64_t DebugControl;
+    uint64_t LastBranchToRip;
+    uint64_t LastBranchFromRip;
+    uint64_t LastExceptionToRip;
+    uint64_t LastExceptionFromRip;
+    uint64_t Cr8;
+    uint64_t MsrGsBase;
+    uint64_t MsrGsSwap;
+    uint64_t MsrStar;
+    uint64_t MsrLStar;
+    uint64_t MsrCStar;
+    uint64_t MsrSyscallMask;
+    uint64_t Xcr0;
+} CPU_KSPECIAL_REGISTERS, *PCPU_KSPECIAL_REGISTERS;
+
+typedef struct _CPU_M128A {
+    uint64_t Low;
+    int64_t High;
+} QEMU_ALIGNED(16) CPU_M128A, *PCPU_M128A;
+
+typedef struct _CPU_XMM_SAVE_AREA32 {
+    uint16_t ControlWord;
+    uint16_t StatusWord;
+    uint8_t TagWord;
+    uint8_t Reserved1;
+    uint16_t ErrorOpcode;
+    uint32_t ErrorOffset;
+    uint16_t ErrorSelector;
+    uint16_t Reserved2;
+    uint32_t DataOffset;
+    uint16_t DataSelector;
+    uint16_t Reserved3;
+    uint32_t MxCsr;
+    uint32_t MxCsr_Mask;
+    CPU_M128A FloatRegisters[8];
+    CPU_M128A XmmRegisters[16];
+    uint8_t Reserved4[96];
+} CPU_XMM_SAVE_AREA32, *PCPU_XMM_SAVE_AREA32;
+
+typedef struct _CPU_CONTEXT { /* sizeof = 1232 */
+    uint64_t P1Home;
+    uint64_t P2Home;
+    uint64_t P3Home;
+    uint64_t P4Home;
+    uint64_t P5Home;
+    uint64_t P6Home;
+    uint32_t ContextFlags;
+    uint32_t MxCsr;
+    uint16_t SegCs;
+    uint16_t SegDs;
+    uint16_t SegEs;
+    uint16_t SegFs;
+    uint16_t SegGs;
+    uint16_t SegSs;
+    uint32_t EFlags;
+    uint64_t Dr0;
+    uint64_t Dr1;
+    uint64_t Dr2;
+    uint64_t Dr3;
+    uint64_t Dr6;
+    uint64_t Dr7;
+    uint64_t Rax;
+    uint64_t Rcx;
+    uint64_t Rdx;
+    uint64_t Rbx;
+    uint64_t Rsp;
+    uint64_t Rbp;
+    uint64_t Rsi;
+    uint64_t Rdi;
+    uint64_t R8;
+    uint64_t R9;
+    uint64_t R10;
+    uint64_t R11;
+    uint64_t R12;
+    uint64_t R13;
+    uint64_t R14;
+    uint64_t R15;
+    uint64_t Rip;
+    union {
+        CPU_XMM_SAVE_AREA32 FltSave;
+        CPU_XMM_SAVE_AREA32 FloatSave;
+        struct {
+            CPU_M128A Header[2];
+            CPU_M128A Legacy[8];
+            CPU_M128A Xmm0;
+            CPU_M128A Xmm1;
+            CPU_M128A Xmm2;
+            CPU_M128A Xmm3;
+            CPU_M128A Xmm4;
+            CPU_M128A Xmm5;
+            CPU_M128A Xmm6;
+            CPU_M128A Xmm7;
+            CPU_M128A Xmm8;
+            CPU_M128A Xmm9;
+            CPU_M128A Xmm10;
+            CPU_M128A Xmm11;
+            CPU_M128A Xmm12;
+            CPU_M128A Xmm13;
+            CPU_M128A Xmm14;
+            CPU_M128A Xmm15;
+        };
+    };
+    CPU_M128A VectorRegister[26];
+    uint64_t VectorControl;
+    uint64_t DebugControl;
+    uint64_t LastBranchToRip;
+    uint64_t LastBranchFromRip;
+    uint64_t LastExceptionToRip;
+    uint64_t LastExceptionFromRip;
+} QEMU_ALIGNED(16) CPU_CONTEXT, *PCPU_CONTEXT;
+
+#else /* TARGET_I386 */
+
+#define SIZE_OF_X86_REG 80
+#define MAX_SUP_EXT 512
+
+#define CPU_CONTEXT_i386 0x10000
+
+#define CPU_CONTEXT_CONTROL (CPU_CONTEXT_i386 | 0x1)
+#define CPU_CONTEXT_INTEGER (CPU_CONTEXT_i386 | 0x2)
+#define CPU_CONTEXT_SEGMENTS (CPU_CONTEXT_i386 | 0x4)
+#define CPU_CONTEXT_FLOATING_POINT (CPU_CONTEXT_i386 | 0x8)
+#define CPU_CONTEXT_DEBUG_REGISTERS (CPU_CONTEXT_i386 | 0x10)
+#define CPU_CONTEXT_EXTENDED_REGISTERS (CPU_CONTEXT_i386 | 0x20)
+
+#define CPU_CONTEXT_FULL                                                       \
+    (CPU_CONTEXT_CONTROL | CPU_CONTEXT_INTEGER | CPU_CONTEXT_SEGMENTS)
+#define CPU_CONTEXT_ALL                                                        \
+    (CPU_CONTEXT_FULL | CPU_CONTEXT_FLOATING_POINT                             \
+     | CPU_CONTEXT_DEBUG_REGISTERS | CPU_CONTEXT_EXTENDED_REGISTERS)
+
+typedef struct _CPU_DESCRIPTOR {
+    uint16_t Pad;
+    uint16_t Limit;
+    uint32_t Base;
+} CPU_DESCRIPTOR, *PCPU_DESCRIPTOR;
+
+typedef struct _CPU_KSPECIAL_REGISTERS {
+    uint32_t Cr0;
+    uint32_t Cr2;
+    uint32_t Cr3;
+    uint32_t Cr4;
+    uint32_t KernelDr0;
+    uint32_t KernelDr1;
+    uint32_t KernelDr2;
+    uint32_t KernelDr3;
+    uint32_t KernelDr6;
+    uint32_t KernelDr7;
+    CPU_DESCRIPTOR Gdtr;
+    CPU_DESCRIPTOR Idtr;
+    uint16_t Tr;
+    uint16_t Ldtr;
+    uint32_t Reserved[6];
+} CPU_KSPECIAL_REGISTERS, *PCPU_KSPECIAL_REGISTERS;
+
+typedef struct _CPU_FLOATING_SAVE_AREA {
+    uint32_t ControlWord;
+    uint32_t StatusWord;
+    uint32_t TagWord;
+    uint32_t ErrorOffset;
+    uint32_t ErrorSelector;
+    uint32_t DataOffset;
+    uint32_t DataSelector;
+    uint8_t RegisterArea[SIZE_OF_X86_REG];
+    uint32_t Cr0NpxState;
+} CPU_FLOATING_SAVE_AREA, *PCPU_FLOATING_SAVE_AREA;
+
+typedef struct _CPU_CONTEXT { /* sizeof = 716 */
+    uint32_t ContextFlags;
+    uint32_t Dr0;
+    uint32_t Dr1;
+    uint32_t Dr2;
+    uint32_t Dr3;
+    uint32_t Dr6;
+    uint32_t Dr7;
+    CPU_FLOATING_SAVE_AREA FloatSave;
+    uint32_t SegGs;
+    uint32_t SegFs;
+    uint32_t SegEs;
+    uint32_t SegDs;
+
+    uint32_t Edi;
+    uint32_t Esi;
+    uint32_t Ebx;
+    uint32_t Edx;
+    uint32_t Ecx;
+    uint32_t Eax;
+    uint32_t Ebp;
+    uint32_t Eip;
+    uint32_t SegCs;
+    uint32_t EFlags;
+    uint32_t Esp;
+    uint32_t SegSs;
+    uint8_t ExtendedRegisters[MAX_SUP_EXT];
+} CPU_CONTEXT, *PCPU_CONTEXT;
+
+#endif /* TARGET_I386 */
+
+typedef struct _CPU_KPROCESSOR_STATE {
+    CPU_CONTEXT ContextFrame;
+    CPU_KSPECIAL_REGISTERS SpecialRegisters;
+} CPU_KPROCESSOR_STATE, *PCPU_KPROCESSOR_STATE;
+
 static InitedAddr KPCR;
 #ifdef TARGET_X86_64
 static InitedAddr kdDebuggerDataBlock;
#23 lore raw

PATCH 23/39 windbg: add helper functions

In reply to Mikhail Abakumov

Add helper functions for serialization and deserialization kernel structures to byte buffer.

---
 target/i386/windbgstub.c |  123 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
target/i386/windbgstub.c +123 -0
index 5d47d5c9e9..03807ce63e 100644
@@ -280,6 +280,129 @@ static InitedAddr kdDebuggerDataBlock;
 static InitedAddr kdVersion;
 #endif /* TARGET_I386 */
 
+__attribute__ ((unused)) /* unused yet */
+static void windbg_set_dr(CPUState *cs, int index, target_ulong value)
+{
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    switch (index) {
+    case 0 ... 3:
+        env->dr[index] = value;
+        return;
+    case 6:
+        env->dr[6] = value | DR6_FIXED_1;
+        return;
+    case 7:
+        cpu_x86_update_dr7(env, value);
+        return;
+    }
+}
+
+/* copy from gdbstub.c */
+__attribute__ ((unused)) /* unused yet */
+static void windbg_set_sr(CPUState *cs, int sreg, uint16_t selector)
+{
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+
+    if (selector != env->segs[sreg].selector) {
+#if defined(CONFIG_USER_ONLY)
+        cpu_x86_load_seg(env, sreg, selector);
+#else
+        unsigned int limit, flags;
+        target_ulong base;
+
+        if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) {
+            int dpl = (env->eflags & VM_MASK) ? 3 : 0;
+            base = selector << 4;
+            limit = 0xffff;
+            flags = DESC_P_MASK | DESC_S_MASK | DESC_W_MASK |
+                    DESC_A_MASK | (dpl << DESC_DPL_SHIFT);
+        } else {
+            if (!cpu_x86_get_descr_debug(env, selector, &base, &limit,
+                                         &flags)) {
+                return;
+            }
+        }
+        cpu_x86_load_seg_cache(env, sreg, selector, base, limit, flags);
+#endif
+    }
+}
+
+#define rwuw_p(ptr, var, is_read)                                              \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            var = lduw_p(ptr);                                                 \
+        } else {                                                               \
+            stw_p(ptr, var);                                                   \
+        }                                                                      \
+    } while (0)
+
+#define rwl_p(ptr, var, is_read)                                               \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            var = ldl_p(ptr);                                                  \
+        } else {                                                               \
+            stl_p(ptr, var);                                                   \
+        }                                                                      \
+    } while (0)
+
+#define rwtul_p(ptr, var, is_read)                                             \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            var = ldtul_p(ptr);                                                \
+        } else {                                                               \
+            sttul_p(ptr, var);                                                 \
+        }                                                                      \
+    } while (0)
+
+#define RW_DR(ptr, cs, dr_index, is_read)                                      \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            windbg_set_dr(cs, dr_index, ldtul_p(ptr));                         \
+        } else {                                                               \
+            sttul_p(ptr, X86_CPU(cs)->env.dr[dr_index]);                       \
+        }                                                                      \
+    } while (0)
+
+#define RW_SR(ptr, cs, sr_index, is_read)                                      \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            windbg_set_sr(cs, sr_index, lduw_p(ptr));                          \
+        } else {                                                               \
+            stw_p(ptr, X86_CPU(cs)->env.segs[R_CS].selector);                  \
+        }                                                                      \
+    } while (0)
+
+#define RW_CR(ptr, cs, cr_index, is_read)                                      \
+    do {                                                                       \
+        if (is_read) {                                                         \
+            cpu_x86_update_cr##cr_index(env, (int32_t) ldtul_p(ptr));          \
+        } else {                                                               \
+            sttul_p(ptr, (target_ulong) X86_CPU(cs)->env.cr[cr_index]);        \
+        }                                                                      \
+    } while (0)
+
+#define CASE_FIELD(srct, field, field_size, block)                             \
+    case offsetof(srct, field):                                                \
+        field_size = sizeof_field(srct, field);                                \
+        block;                                                                 \
+        break;
+
+#define CASE_FIELD_X32_64(srct, field_x32, field_x64, field_size, block) \
+    CASE_FIELD(srct, TARGET_SAFE(field_x32, field_x64), field_size, block)
+
+#ifdef TARGET_X86_64
+#define CASE_FIELD_X32(srct, field, field_size, block)
+#define CASE_FIELD_X64(srct, field, field_size, block) \
+    CASE_FIELD(srct, field, field_size, block)
+#else  /* TARGET_I386 */
+#define CASE_FIELD_X64(srct, field, field_size, block)
+#define CASE_FIELD_X32(srct, field, field_size, block) \
+    CASE_FIELD(srct, field, field_size, block)
+#endif /* TARGET_I386 */
+
 static bool find_KPCR(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
#24 lore raw

PATCH 24/39 windbg: [de]serialization cpu context

In reply to Mikhail Abakumov
---
 target/i386/windbgstub.c |  374 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 372 insertions(+), 2 deletions(-)
target/i386/windbgstub.c +372 -2
index 03807ce63e..60323a9369 100644
@@ -280,7 +280,6 @@ static InitedAddr kdDebuggerDataBlock;
 static InitedAddr kdVersion;
 #endif /* TARGET_I386 */
 
-__attribute__ ((unused)) /* unused yet */
 static void windbg_set_dr(CPUState *cs, int index, target_ulong value)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -300,7 +299,6 @@ static void windbg_set_dr(CPUState *cs, int index, target_ulong value)
 }
 
 /* copy from gdbstub.c */
-__attribute__ ((unused)) /* unused yet */
 static void windbg_set_sr(CPUState *cs, int sreg, uint16_t selector)
 {
     X86CPU *cpu = X86_CPU(cs);
@@ -403,6 +401,378 @@ static void windbg_set_sr(CPUState *cs, int sreg, uint16_t selector)
     CASE_FIELD(srct, field, field_size, block)
 #endif /* TARGET_I386 */
 
+#define GEN_WINDBG_CONTEXT_RW(fun_name, is_read)                               \
+static int fun_name(CPUState *cs, uint8_t *buf, int buf_size,                  \
+                    int offset, int len)                                       \
+{                                                                              \
+    X86CPU *cpu = X86_CPU(cs);                                                 \
+    CPUX86State *env = &cpu->env;                                              \
+    uint32_t ctx_flags = CPU_CONTEXT_ALL;                                      \
+    uint32_t tmp32, i;                                                         \
+    uint32_t f_size = 0;                                                       \
+                                                                               \
+    if (len < 0 || len > buf_size) {                                           \
+        WINDBG_ERROR("" #fun_name ": incorrect length %d", len);               \
+        return 1;                                                              \
+    }                                                                          \
+                                                                               \
+    if (offset < 0 || offset + len > sizeof(CPU_CONTEXT)) {                    \
+        WINDBG_ERROR("" #fun_name ": incorrect offset %d", offset);            \
+        return 2;                                                              \
+    }                                                                          \
+                                                                               \
+    len = MIN(len, sizeof(CPU_CONTEXT) - offset);                              \
+                                                                               \
+    while (offset < len) {                                                     \
+        switch (offset) {                                                      \
+        CASE_FIELD(CPU_CONTEXT, ContextFlags, f_size, {                        \
+            rwl_p(buf, ctx_flags, is_read);                                    \
+        });                                                                    \
+        /* DEBUG REGISTERS */                                                  \
+        CASE_FIELD(CPU_CONTEXT, Dr0, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 0, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, Dr1, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 1, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, Dr2, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 2, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, Dr3, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 3, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, Dr6, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 6, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, Dr7, f_size, {                                 \
+            if (ctx_flags & CPU_CONTEXT_DEBUG_REGISTERS) {                     \
+                RW_DR(buf, cs, 7, is_read);                                    \
+            }                                                                  \
+        });                                                                    \
+        /* SEGMENT REGISTERS */                                                \
+        CASE_FIELD(CPU_CONTEXT, SegCs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_CS, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, SegDs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_DS, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, SegEs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_ES, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, SegFs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_FS, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, SegGs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_GS, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, SegSs, f_size, {                               \
+            if (ctx_flags & CPU_CONTEXT_SEGMENTS) {                            \
+                RW_SR(buf, cs, R_SS, is_read);                                 \
+            }                                                                  \
+        });                                                                    \
+        /* INTEGER REGISTERS */                                                \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Eax, Rax, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_EAX], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Ecx, Rcx, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_ECX], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Edx, Rdx, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_EDX], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Ebx, Rbx, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_EBX], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Esi, Rsi, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_ESI], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Edi, Rdi, f_size, {                     \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[R_EDI], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R8, f_size, {                              \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[8], is_read);                           \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R9, f_size, {                              \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[9], is_read);                           \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R10, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[10], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R11, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[11], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R12, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[12], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R13, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[13], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R14, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[14], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, R15, f_size, {                             \
+            if (ctx_flags & CPU_CONTEXT_INTEGER) {                             \
+                rwtul_p(buf, env->regs[15], is_read);                          \
+            }                                                                  \
+        });                                                                    \
+        /* CONTROL REGISTERS */                                                \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
+            if (ctx_flags & CONTEXT_CONTROL) {                                 \
+                rwtul_p(buf, env->regs[R_ESP], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Ebp, Rbp, f_size, {                     \
+            if (ctx_flags & CONTEXT_CONTROL) {                                 \
+                rwtul_p(buf, env->regs[R_EBP], is_read);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, Eip, Rip, f_size, {                     \
+            if (ctx_flags & CONTEXT_CONTROL) {                                 \
+                rwtul_p(buf, env->eip, is_read);                               \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, EFlags, f_size, {                              \
+            if (ctx_flags & CONTEXT_CONTROL) {                                 \
+                rwl_p(buf, env->eflags, is_read);                              \
+            }                                                                  \
+        });                                                                    \
+        /* FLOAT REGISTERS */                                                  \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.ControlWord, f_size, {               \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    cpu_set_fpuc(env, TARGET_SAFE(ldl_p, lduw_p)(buf));        \
+                } else {                                                       \
+                    TARGET_SAFE(stl_p, stw_p)(buf, env->fpuc);                 \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.StatusWord, f_size, {                \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    tmp32 = TARGET_SAFE(ldl_p, lduw_p)(buf);                   \
+                    env->fpstt = (tmp32 >> 11) & 7;                            \
+                    env->fpus = tmp32 & ~0x3800;                               \
+                } else {                                                       \
+                    tmp32 = env->fpus & ~(7 << 11);                            \
+                    tmp32 |= (env->fpstt & 7) << 11;                           \
+                    TARGET_SAFE(stl_p, stw_p)(buf, tmp32);                     \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.TagWord, f_size, {                   \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    tmp32 = TARGET_SAFE(ldl_p(buf), buf[0]);                   \
+                    for (i = 0; i < 8; ++i) {                                  \
+                        env->fptags[i] = !((tmp32 >> i) & 1);                  \
+                    }                                                          \
+                } else {                                                       \
+                    tmp32 = 0;                                                 \
+                    for (i = 0; i < 8; ++i) {                                  \
+                        tmp32 |= (!env->fptags[i]) << i;                       \
+                    }                                                          \
+                    TARGET_SAFE(stl_p, stb_p)(buf, tmp32);                     \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.Reserved1, f_size, {});          \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.ErrorOpcode, f_size, {           \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                rwuw_p(buf, env->fpop, is_read);                               \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.ErrorOffset, f_size, {               \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    env->fpip &= ~0xffffffffL;                                 \
+                    env->fpip |= ldl_p(buf);                                   \
+                } else {                                                       \
+                    stl_p(buf, env->fpip & 0xffffffff);                        \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.ErrorSelector, f_size, {             \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    env->fpip &= 0xffffffffL;                                  \
+                    env->fpip |= ((uint64_t) ldl_p(buf)) << 32;                \
+                } else {                                                       \
+                    stl_p(buf, (env->fpip >> 32) & 0xffffffff);                \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.Reserved2, f_size, {});          \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.DataOffset, f_size, {                \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    env->fpdp &= ~0xffffffffL;                                 \
+                    env->fpdp |= ldl_p(buf);                                   \
+                } else {                                                       \
+                    stl_p(buf, env->fpdp & 0xffffffff);                        \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_CONTEXT, FloatSave.DataSelector, f_size, {              \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                if (is_read) {                                                 \
+                    env->fpdp &= 0xffffffffL;                                  \
+                    env->fpdp |= ((uint64_t) ldl_p(buf)) << 32;                \
+                } else {                                                       \
+                    stl_p(buf, (env->fpdp >> 32) & 0xffffffff);                \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.Reserved3, f_size, {});          \
+        CASE_FIELD_X32(CPU_CONTEXT, FloatSave.Cr0NpxState, f_size, {           \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                rwl_p(buf, env->xcr0, is_read);                                \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.MxCsr, f_size, {                 \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                rwl_p(buf, env->mxcsr, is_read);                               \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.MxCsr_Mask, f_size, {            \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                /* FIXME: this is unimplemented in qemu? */                    \
+                /* rwl_p(buf, env->mxcsr_mask, is_read); */                    \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X32_64(CPU_CONTEXT, FloatSave.RegisterArea,                 \
+                                       FloatSave.FloatRegisters, f_size, {     \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                uint8_t *mem = buf;                                            \
+                for (i = 0; i < 8; ++i, mem += TARGET_SAFE(10, 16)) {          \
+                    floatx80 fl = env->fpregs[i].d;                            \
+                    if (is_read) {                                             \
+                        fl.low = ldq_p(mem);                                   \
+                        fl.high = TARGET_SAFE(lduw_p, ldq_p)(mem + 8);         \
+                    } else {                                                   \
+                        stq_p(mem, fl.low);                                    \
+                        TARGET_SAFE(stw_p, stq_p)(mem + 8, fl.high);           \
+                    }                                                          \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.XmmRegisters, f_size, {          \
+            if (ctx_flags & CPU_CONTEXT_FLOATING_POINT) {                      \
+                uint8_t *mem = buf;                                            \
+                if (is_read) {                                                 \
+                    for (i = 0; i < CPU_NB_REGS; ++i, mem += 16) {             \
+                        env->xmm_regs[i].ZMM_Q(0) = ldl_p(mem);                \
+                        env->xmm_regs[i].ZMM_Q(1) = ldl_p(mem + 8);            \
+                    }                                                          \
+                } else {                                                       \
+                    for (i = 0; i < CPU_NB_REGS; ++i, mem += 16) {             \
+                        stq_p(mem, env->xmm_regs[i].ZMM_Q(0));                 \
+                        stq_p(mem + 8, env->xmm_regs[i].ZMM_Q(1));             \
+                    }                                                          \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, FloatSave.Reserved4, f_size, {});          \
+        /* EXTENDED REGISTERS I386 */                                          \
+        CASE_FIELD_X32(CPU_CONTEXT, ExtendedRegisters, f_size, {               \
+            if (ctx_flags & CPU_CONTEXT_EXTENDED_REGISTERS) {                  \
+                uint8_t *mem = buf + 160;                                      \
+                if (is_read) {                                                 \
+                    for (i = 0; i < CPU_NB_REGS; ++i, mem += 16) {             \
+                        env->xmm_regs[i].ZMM_Q(0) = ldl_p(mem);                \
+                        env->xmm_regs[i].ZMM_Q(1) = ldl_p(mem + 8);            \
+                    }                                                          \
+                    cpu_set_mxcsr(env, ldl_p(mem + 24));                       \
+                } else {                                                       \
+                    for (i = 0; i < CPU_NB_REGS; ++i, mem += 16) {             \
+                        stq_p(mem, env->xmm_regs[i].ZMM_Q(0));                 \
+                        stq_p(mem + 8, env->xmm_regs[i].ZMM_Q(1));             \
+                    }                                                          \
+                    stl_p(mem + 24, env->mxcsr);                               \
+                }                                                              \
+            }                                                                  \
+        });                                                                    \
+        /* UNKNOWN REGISTERS */                                                \
+        CASE_FIELD_X64(CPU_CONTEXT, P1Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, P2Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, P3Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, P4Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, P5Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, P6Home, f_size, {});                       \
+        CASE_FIELD_X64(CPU_CONTEXT, MxCsr, f_size, {                           \
+            if (is_read) {                                                     \
+                cpu_set_mxcsr(env, ldl_p(buf));                                \
+            } else {                                                           \
+                stl_p(buf, env->mxcsr);                                        \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_CONTEXT, VectorRegister, f_size, {});               \
+        CASE_FIELD_X64(CPU_CONTEXT, VectorControl, f_size, {});                \
+        CASE_FIELD_X64(CPU_CONTEXT, DebugControl, f_size, {});                 \
+        CASE_FIELD_X64(CPU_CONTEXT, LastBranchToRip, f_size, {});              \
+        CASE_FIELD_X64(CPU_CONTEXT, LastBranchFromRip, f_size, {});            \
+        CASE_FIELD_X64(CPU_CONTEXT, LastExceptionToRip, f_size, {});           \
+        CASE_FIELD_X64(CPU_CONTEXT, LastExceptionFromRip, f_size, {});         \
+        default:                                                               \
+            f_size = 1;                                                        \
+        }                                                                      \
+        offset += f_size;                                                      \
+        buf += f_size;                                                         \
+    }                                                                          \
+    return 0;                                                                  \
+}
+
+__attribute__ ((unused)) /* unused yet */
+GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
+
+__attribute__ ((unused)) /* unused yet */
+GEN_WINDBG_CONTEXT_RW(windbg_write_context, true)
+
 static bool find_KPCR(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
#25 lore raw

PATCH 25/39 windbg: [de]serialization cpu spec registers

In reply to Mikhail Abakumov
---
 target/i386/windbgstub.c |  123 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)
target/i386/windbgstub.c +123 -0
index 60323a9369..1c2bb496b0 100644
@@ -767,12 +767,135 @@ static int fun_name(CPUState *cs, uint8_t *buf, int buf_size,                  \
     return 0;                                                                  \
 }
 
+#define GEN_WINDBG_KSPEC_REGS_RW(fun_name, is_read)                            \
+static int fun_name(CPUState *cs, uint8_t *buf, int buf_size,                  \
+                    int offset, int len)                                       \
+{                                                                              \
+    X86CPU *cpu = X86_CPU(cs);                                                 \
+    CPUX86State *env = &cpu->env;                                              \
+    uint32_t f_size = 0;                                                       \
+                                                                               \
+    if (len < 0 || len > buf_size) {                                           \
+        WINDBG_ERROR("" #fun_name ": incorrect length %d", len);               \
+        return 1;                                                              \
+    }                                                                          \
+                                                                               \
+    if (offset < 0 || offset + len > sizeof(CPU_KSPECIAL_REGISTERS)) {         \
+        WINDBG_ERROR("" #fun_name ": incorrect offset %d", f_size);            \
+        return 2;                                                              \
+    }                                                                          \
+                                                                               \
+    len = MIN(len, sizeof(CPU_KSPECIAL_REGISTERS) - offset);                   \
+                                                                               \
+    while (offset < len) {                                                     \
+        switch (offset) {                                                      \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Cr0, f_size, {                      \
+            RW_CR(buf, cs, 0, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Cr2, f_size, {                      \
+            if (is_read) {                                                     \
+                env->cr[2] = (int32_t) ldtul_p(buf);                           \
+            } else {                                                           \
+                sttul_p(buf, (target_ulong) env->cr[2]);                       \
+            }                                                                  \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Cr3, f_size, {                      \
+            RW_CR(buf, cs, 3, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Cr4, f_size, {                      \
+            RW_CR(buf, cs, 4, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr0, f_size, {                \
+            RW_DR(buf, cs, 0, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr1, f_size, {                \
+            RW_DR(buf, cs, 1, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr2, f_size, {                \
+            RW_DR(buf, cs, 2, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr3, f_size, {                \
+            RW_DR(buf, cs, 3, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr6, f_size, {                \
+            RW_DR(buf, cs, 6, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, KernelDr7, f_size, {                \
+            RW_DR(buf, cs, 7, is_read);                                        \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Gdtr.Pad, f_size, {});              \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Gdtr.Limit, f_size, {               \
+            rwuw_p(buf, env->gdt.limit, is_read);                              \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Gdtr.Base, f_size, {                \
+            rwtul_p(buf, env->gdt.base, is_read);                              \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Idtr.Pad, f_size, {});              \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Idtr.Limit, f_size, {               \
+            rwuw_p(buf, env->idt.limit, is_read);                              \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Idtr.Base, f_size, {                \
+            rwtul_p(buf, env->idt.base, is_read);                              \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Tr, f_size, {                       \
+            rwuw_p(buf, env->tr.selector, is_read);                            \
+        });                                                                    \
+        CASE_FIELD(CPU_KSPECIAL_REGISTERS, Ldtr, f_size, {                     \
+            rwuw_p(buf, env->tr.selector, is_read);                            \
+        });                                                                    \
+        CASE_FIELD_X32(CPU_KSPECIAL_REGISTERS, Reserved, f_size, {});          \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MxCsr, f_size, {                \
+            rwl_p(buf, env->mxcsr, is_read);                                   \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, DebugControl, f_size, {});      \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, LastBranchToRip, f_size, {});   \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, LastBranchFromRip, f_size, {}); \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, LastExceptionToRip, f_size, {});\
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, LastExceptionFromRip, f_size, { \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, Cr8, f_size, {});               \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrGsBase, f_size, {            \
+            rwtul_p(buf, env->segs[R_GS].base, is_read);                       \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrGsSwap, f_size, {            \
+            rwtul_p(buf, env->kernelgsbase, is_read);                          \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrStar, f_size, {              \
+            rwtul_p(buf, env->star, is_read);                                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrLStar, f_size, {             \
+            rwtul_p(buf, env->lstar, is_read);                                 \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrCStar, f_size, {             \
+            rwtul_p(buf, env->cstar, is_read);                                 \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, MsrSyscallMask, f_size, {       \
+            /* NOTE: Unimplemented in qemu: msr MSR_SFMASK */                  \
+        });                                                                    \
+        CASE_FIELD_X64(CPU_KSPECIAL_REGISTERS, Xcr0, f_size, {                 \
+            rwtul_p(buf, env->xcr0, is_read);                                  \
+        });                                                                    \
+        default:                                                               \
+            f_size = 1;                                                        \
+        }                                                                      \
+        offset += f_size;                                                      \
+        buf += f_size;                                                         \
+    }                                                                          \
+    return 0;                                                                  \
+}
+
 __attribute__ ((unused)) /* unused yet */
 GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
 
 __attribute__ ((unused)) /* unused yet */
 GEN_WINDBG_CONTEXT_RW(windbg_write_context, true)
 
+__attribute__ ((unused)) /* unused yet */
+GEN_WINDBG_KSPEC_REGS_RW(windbg_read_ks_regs, false)
+
+__attribute__ ((unused)) /* unused yet */
+GEN_WINDBG_KSPEC_REGS_RW(windbg_write_ks_regs, true)
+
 static bool find_KPCR(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
#26 lore raw

PATCH 26/39 windbg: implement kd_api_get_context and kd_api_set_context

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 ++
 target/i386/windbgstub.c        |   27 +++++++++++++++++++++++++++
 windbgstub.c                    |    8 ++++++++
 3 files changed, 37 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index 638b2b9a6f..a88e013de9 100644
@@ -69,6 +69,8 @@ const char *kd_pkt_type_name(int id);
 
 void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
+void kd_api_get_context(CPUState *cs, PacketData *pd);
+void kd_api_set_context(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
 
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
target/i386/windbgstub.c +27 -0
index 1c2bb496b0..d08660c6fd 100644
@@ -896,6 +896,33 @@ GEN_WINDBG_KSPEC_REGS_RW(windbg_read_ks_regs, false)
 __attribute__ ((unused)) /* unused yet */
 GEN_WINDBG_KSPEC_REGS_RW(windbg_write_ks_regs, true)
 
+void kd_api_get_context(CPUState *cs, PacketData *pd)
+{
+    int err;
+
+    pd->extra_size = sizeof(CPU_CONTEXT);
+    err = windbg_read_context(cs, pd->extra, pd->extra_size,
+                              0, sizeof(CPU_CONTEXT));
+
+    if (err) {
+        pd->extra_size = 0;
+        pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL;
+    }
+}
+
+void kd_api_set_context(CPUState *cs, PacketData *pd)
+{
+    int err;
+
+    err = windbg_write_context(cs, pd->extra, pd->extra_size,
+                               0, sizeof(CPU_CONTEXT));
+    pd->extra_size = 0;
+
+    if (err) {
+        pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL;
+    }
+}
+
 static bool find_KPCR(CPUState *cs)
 {
     X86CPU *cpu = X86_CPU(cs);
windbgstub.c +8 -0
index 46400d9bad..70ebf3c0ad 100644
@@ -157,6 +157,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_virtual_memory(cs, data);
         break;
 
+    case DbgKdGetContextApi:
+        kd_api_get_context(cs, data);
+        break;
+
+    case DbgKdSetContextApi:
+        kd_api_set_context(cs, data);
+        break;
+
     default:
         kd_api_unsupported(cs, data);
         break;
#27 lore raw

PATCH 27/39 windbg: implement kd_api_get_context_ex and kd_api_set_context_ex

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 +
 target/i386/windbgstub.c        |   90 ++++++++++++++++++++++++++++++++++++---
 windbgstub.c                    |    8 +++
 3 files changed, 93 insertions(+), 7 deletions(-)
include/exec/windbgstub-utils.h +2 -0
index a88e013de9..6936fd0ffb 100644
@@ -71,6 +71,8 @@ void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_context(CPUState *cs, PacketData *pd);
 void kd_api_set_context(CPUState *cs, PacketData *pd);
+void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
+void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
 
 DBGKD_ANY_WAIT_STATE_CHANGE *kd_state_change_exc(CPUState *cs);
target/i386/windbgstub.c +83 -7

107 lines not on this page · raw message

windbgstub.c +8 -0
index 70ebf3c0ad..e9d759cddf 100644
@@ -165,6 +165,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_set_context(cs, data);
         break;
 
+    case DbgKdGetContextExApi:
+        kd_api_get_context_ex(cs, data);
+        break;
+
+    case DbgKdSetContextExApi:
+        kd_api_set_context_ex(cs, data);
+        break;
+
     default:
         kd_api_unsupported(cs, data);
         break;
#28 lore raw

PATCH 28/39 windbg: implement kd_api_read_control_space and kd_api_write_control_space

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 +
 target/i386/windbgstub.c        |   81 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |    8 ++++
 3 files changed, 91 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index 6936fd0ffb..2781a54044 100644
@@ -71,6 +71,8 @@ void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_context(CPUState *cs, PacketData *pd);
 void kd_api_set_context(CPUState *cs, PacketData *pd);
+void kd_api_read_control_space(CPUState *cs, PacketData *pd);
+void kd_api_write_control_space(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
target/i386/windbgstub.c +81 -0

87 lines not on this page · raw message

windbgstub.c +8 -0
index e9d759cddf..328a04735f 100644
@@ -165,6 +165,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_set_context(cs, data);
         break;
 
+    case DbgKdReadControlSpaceApi:
+        kd_api_read_control_space(cs, data);
+        break;
+
+    case DbgKdWriteControlSpaceApi:
+        kd_api_write_control_space(cs, data);
+        break;
+
     case DbgKdGetContextExApi:
         kd_api_get_context_ex(cs, data);
         break;
#29 lore raw

PATCH 29/39 windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    3 ++
 windbgstub-utils.c              |   68 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |   12 +++++++
 3 files changed, 83 insertions(+)
include/exec/windbgstub-utils.h +3 -0
index 2781a54044..85b7322b82 100644
@@ -71,8 +71,11 @@ void kd_api_read_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_virtual_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_context(CPUState *cs, PacketData *pd);
 void kd_api_set_context(CPUState *cs, PacketData *pd);
+void kd_api_write_breakpoint(CPUState *cs, PacketData *pd);
+void kd_api_restore_breakpoint(CPUState *cs, PacketData *pd);
 void kd_api_read_control_space(CPUState *cs, PacketData *pd);
 void kd_api_write_control_space(CPUState *cs, PacketData *pd);
+void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
windbgstub-utils.c +68 -0

80 lines not on this page · raw message

windbgstub.c +12 -0
index 328a04735f..a1c013cd8c 100644
@@ -165,6 +165,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_set_context(cs, data);
         break;
 
+    case DbgKdWriteBreakPointApi:
+        kd_api_write_breakpoint(cs, data);
+        break;
+
+    case DbgKdRestoreBreakPointApi:
+        kd_api_restore_breakpoint(cs, data);
+        break;
+
     case DbgKdReadControlSpaceApi:
         kd_api_read_control_space(cs, data);
         break;
@@ -173,6 +181,10 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_control_space(cs, data);
         break;
 
+    case DbgKdClearAllInternalBreakpointsApi:
+        kd_api_clear_all_internal_breakpoints(cs, data);
+        return;
+
     case DbgKdGetContextExApi:
         kd_api_get_context_ex(cs, data);
         break;
#30 lore raw

PATCH 30/39 windbg: debug exception subscribing

In reply to Mikhail Abakumov

Add handler registration of gdb debug exception. Its exception also can be used for windbg.

---
 cpus.c                  |   19 ++++++++++++++++++-
 gdbstub.c               |    4 ++++
 include/sysemu/sysemu.h |    2 ++
 windbgstub.c            |   14 ++++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
cpus.c +18 -1
index a2b33ccb29..c8b05260b4 100644
@@ -79,6 +79,8 @@ int64_t max_advance;
 static QEMUTimer *throttle_timer;
 static unsigned int throttle_percentage;
 
+static void (*excp_debug_handler)(CPUState *cpu);
+
 #define CPU_THROTTLE_PCT_MIN 1
 #define CPU_THROTTLE_PCT_MAX 99
 #define CPU_THROTTLE_TIMESLICE_NS 10000000
@@ -1103,9 +1105,24 @@ static bool cpu_can_run(CPUState *cpu)
     return true;
 }
 
+bool register_excp_debug_handler(void (*handler)(CPUState *cpu))
+{
+    if (excp_debug_handler == NULL) {
+        excp_debug_handler = handler;
+        return true;
+    } else {
+        error_report("Something debugger is already in use. '-gdb' and "
+                     "'-windbg' cannot be used at the same time");
+        return false;
+    }
+}
+
 static void cpu_handle_guest_debug(CPUState *cpu)
 {
-    gdb_set_stop_cpu(cpu);
+    if (excp_debug_handler != NULL) {
+        excp_debug_handler(cpu);
+    }
+
     qemu_system_debug_request();
     cpu->stopped = true;
 }
gdbstub.c +4 -0
index c4e4f9f082..9ed4fe2e8e 100644
@@ -2074,6 +2074,10 @@ int gdbserver_start(const char *device)
     s->mon_chr = mon_chr;
     s->current_syscall_cb = NULL;
 
+    if (!register_excp_debug_handler(gdb_set_stop_cpu)) {
+        exit(1);
+    }
+
     return 0;
 }
 
include/sysemu/sysemu.h +2 -0
index 8d6095d98b..826b701bfa 100644
@@ -203,6 +203,8 @@ QemuOpts *qemu_get_machine_opts(void);
 
 bool defaults_enabled(void);
 
+bool register_excp_debug_handler(void (*handler)(CPUState *cpu));
+
 extern QemuOptsList qemu_legacy_drive_opts;
 extern QemuOptsList qemu_common_drive_opts;
 extern QemuOptsList qemu_drive_opts;
windbgstub.c +14 -0
index a1c013cd8c..0e4ad6d009 100644
@@ -129,9 +129,19 @@ static void windbg_send_control_packet(WindbgState *state, uint16_t type,
     qemu_chr_fe_write(&state->chr, PTR(packet), sizeof(packet));
 }
 
+static void windbg_bp_handler(CPUState *cs)
+{
+    DBGKD_ANY_WAIT_STATE_CHANGE *sc = kd_state_change_exc(cs);
+    windbg_send_data_packet(windbg_state, (uint8_t *) sc,
+                            sizeof(DBGKD_ANY_WAIT_STATE_CHANGE),
+                            PACKET_TYPE_KD_STATE_CHANGE64);
+}
+
 static void windbg_vm_stop(void)
 {
+    CPUState *cs = qemu_get_cpu(0);
     vm_stop(RUN_STATE_PAUSED);
+    windbg_bp_handler(cs);
 }
 
 static void windbg_process_manipulate_packet(WindbgState *state)
@@ -481,6 +491,10 @@ int windbg_server_start(const char *device)
 
     qemu_register_reset(windbg_handle_reset, NULL);
 
+    if (!register_excp_debug_handler(windbg_bp_handler)) {
+        exit(1);
+    }
+
     atexit(windbg_exit);
     return 0;
 }
#31 lore raw

PATCH 31/39 windbg: implement kd_api_continue

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    1 +
 windbgstub-utils.c              |   15 +++++++++++++++
 windbgstub.c                    |    5 +++++
 3 files changed, 21 insertions(+)
include/exec/windbgstub-utils.h +1 -0
index 85b7322b82..2843ad055e 100644
@@ -73,6 +73,7 @@ void kd_api_get_context(CPUState *cs, PacketData *pd);
 void kd_api_set_context(CPUState *cs, PacketData *pd);
 void kd_api_write_breakpoint(CPUState *cs, PacketData *pd);
 void kd_api_restore_breakpoint(CPUState *cs, PacketData *pd);
+void kd_api_continue(CPUState *cs, PacketData *pd);
 void kd_api_read_control_space(CPUState *cs, PacketData *pd);
 void kd_api_write_control_space(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
windbgstub-utils.c +15 -0
index 67934442d9..ab88e36e2e 100644
@@ -10,6 +10,7 @@
  */
 
 #include "exec/windbgstub-utils.h"
+#include "sysemu/sysemu.h"
 
 static const char *kd_api_names[] = {
     "DbgKdReadVirtualMemoryApi",
@@ -308,6 +309,20 @@ void kd_api_restore_breakpoint(CPUState *cs, PacketData *pd)
     }
 }
 
+void kd_api_continue(CPUState *cs, PacketData *pd)
+{
+    uint32_t status = ldl_p(&pd->m64.u.Continue2.ContinueStatus);
+    uint32_t trace = ldl_p(&pd->m64.u.Continue2.ControlSet.TraceFlag);
+    int ssFlag = trace ? SSTEP_ENABLE | SSTEP_NOIRQ | SSTEP_NOTIMER : 0;
+
+    if (NT_SUCCESS(status)) {
+        cpu_single_step(cs, ssFlag);
+        if (!runstate_needs_reset()) {
+            vm_start();
+        }
+    }
+}
+
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd)
 {
 }
windbgstub.c +5 -0
index 0e4ad6d009..d64bbc3f34 100644
@@ -183,6 +183,11 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_restore_breakpoint(cs, data);
         break;
 
+    case DbgKdContinueApi:
+    case DbgKdContinueApi2:
+        kd_api_continue(cs, data);
+        return;
+
     case DbgKdReadControlSpaceApi:
         kd_api_read_control_space(cs, data);
         break;
#32 lore raw

PATCH 32/39 windbg: implement kd_api_read_io_space and kd_api_write_io_space

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 +
 windbgstub-utils.c              |   62 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |    8 +++++
 3 files changed, 72 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index 2843ad055e..f0a786cdef 100644
@@ -76,6 +76,8 @@ void kd_api_restore_breakpoint(CPUState *cs, PacketData *pd);
 void kd_api_continue(CPUState *cs, PacketData *pd);
 void kd_api_read_control_space(CPUState *cs, PacketData *pd);
 void kd_api_write_control_space(CPUState *cs, PacketData *pd);
+void kd_api_read_io_space(CPUState *cs, PacketData *pd);
+void kd_api_write_io_space(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
windbgstub-utils.c +62 -0

74 lines not on this page · raw message

windbgstub.c +8 -0
index d64bbc3f34..78f96a6621 100644
@@ -196,6 +196,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_control_space(cs, data);
         break;
 
+    case DbgKdReadIoSpaceApi:
+        kd_api_read_io_space(cs, data);
+        break;
+
+    case DbgKdWriteIoSpaceApi:
+        kd_api_write_io_space(cs, data);
+        break;
+
     case DbgKdClearAllInternalBreakpointsApi:
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
#33 lore raw

PATCH 33/39 windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    2 ++
 windbgstub-utils.c              |   29 +++++++++++++++++++++++++++++
 windbgstub.c                    |    8 ++++++++
 3 files changed, 39 insertions(+)
include/exec/windbgstub-utils.h +2 -0
index f0a786cdef..fa67a7048d 100644
@@ -78,6 +78,8 @@ void kd_api_read_control_space(CPUState *cs, PacketData *pd);
 void kd_api_write_control_space(CPUState *cs, PacketData *pd);
 void kd_api_read_io_space(CPUState *cs, PacketData *pd);
 void kd_api_write_io_space(CPUState *cs, PacketData *pd);
+void kd_api_read_physical_memory(CPUState *cs, PacketData *pd);
+void kd_api_write_physical_memory(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
windbgstub-utils.c +29 -0
index df6d89fada..fdb106ff12 100644
@@ -385,6 +385,35 @@ void kd_api_write_io_space(CPUState *cs, PacketData *pd)
     pd->m64.ReturnStatus = STATUS_SUCCESS;
 }
 
+void kd_api_read_physical_memory(CPUState *cs, PacketData *pd)
+{
+    DBGKD_READ_MEMORY64 *mem = &pd->m64.u.ReadMemory;
+    uint32_t len;
+    target_ulong addr;
+
+    len = MIN(ldl_p(&mem->TransferCount),
+              PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64));
+    addr = ldtul_p(&mem->TargetBaseAddress);
+
+    cpu_physical_memory_rw(addr, pd->extra, len, 0);
+    pd->extra_size = len;
+    stl_p(&mem->ActualBytesRead, len);
+}
+
+void kd_api_write_physical_memory(CPUState *cs, PacketData *pd)
+{
+    DBGKD_WRITE_MEMORY64 *mem = &pd->m64.u.WriteMemory;
+    uint32_t len;
+    target_ulong addr;
+
+    len = MIN(ldl_p(&mem->TransferCount), pd->extra_size);
+    addr = ldtul_p(&mem->TargetBaseAddress);
+
+    cpu_physical_memory_rw(addr, pd->extra, len, 1);
+    pd->extra_size = 0;
+    stl_p(&mem->ActualBytesWritten, len);
+}
+
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd)
 {
 }
windbgstub.c +8 -0
index 78f96a6621..25331f218f 100644
@@ -204,6 +204,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_io_space(cs, data);
         break;
 
+    case DbgKdReadPhysicalMemoryApi:
+        kd_api_read_physical_memory(cs, data);
+        break;
+
+    case DbgKdWritePhysicalMemoryApi:
+        kd_api_write_physical_memory(cs, data);
+        break;
+
     case DbgKdClearAllInternalBreakpointsApi:
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
#34 lore raw

PATCH 34/39 windbg: implement kd_api_get_version

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    1 +
 target/i386/windbgstub.c        |   61 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |    4 +++
 3 files changed, 66 insertions(+)
include/exec/windbgstub-utils.h +1 -0
index fa67a7048d..adfc9936f3 100644
@@ -80,6 +80,7 @@ void kd_api_read_io_space(CPUState *cs, PacketData *pd);
 void kd_api_write_io_space(CPUState *cs, PacketData *pd);
 void kd_api_read_physical_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_physical_memory(CPUState *cs, PacketData *pd);
+void kd_api_get_version(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
target/i386/windbgstub.c +61 -0

73 lines not on this page · raw message

windbgstub.c +4 -0
index 25331f218f..366856bc81 100644
@@ -212,6 +212,10 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_physical_memory(cs, data);
         break;
 
+    case DbgKdGetVersionApi:
+        kd_api_get_version(cs, data);
+        break;
+
     case DbgKdClearAllInternalBreakpointsApi:
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
#35 lore raw

PATCH 35/39 windbg: implement kd_api_read_msr and kd_api_write_msr

In reply to Mikhail Abakumov

Add sub functions for helper_wrmsr and helper_rdmsr: cpu_x86_write_msr and cpu_x86_read_msr.

---
 include/exec/windbgstub-utils.h |    2 ++
 target/i386/cpu.h               |    5 +++++
 target/i386/misc_helper.c       |   39 ++++++++++++++++++++++++++++-----------
 target/i386/windbgstub.c        |   30 ++++++++++++++++++++++++++++++
 windbgstub.c                    |    8 ++++++++
 5 files changed, 73 insertions(+), 11 deletions(-)
include/exec/windbgstub-utils.h +2 -0
index adfc9936f3..74e3b9a0da 100644
@@ -81,6 +81,8 @@ void kd_api_write_io_space(CPUState *cs, PacketData *pd);
 void kd_api_read_physical_memory(CPUState *cs, PacketData *pd);
 void kd_api_write_physical_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_version(CPUState *cs, PacketData *pd);
+void kd_api_read_msr(CPUState *cs, PacketData *pd);
+void kd_api_write_msr(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
target/i386/cpu.h +5 -0
index 9c52d0cbeb..0f451d81bf 100644
@@ -1680,6 +1680,11 @@ void cpu_x86_update_cr3(CPUX86State *env, target_ulong new_cr3);
 void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_cr4);
 void cpu_x86_update_dr7(CPUX86State *env, uint32_t new_dr7);
 
+#ifndef CONFIG_USER_ONLY
+void cpu_x86_write_msr(CPUX86State *env, uint64_t val);
+uint64_t cpu_x86_read_msr(CPUX86State *env);
+#endif
+
 /* hw/pc.c */
 uint64_t cpu_get_tsc(CPUX86State *env);
 
target/i386/misc_helper.c +28 -11
index 6ae67cf885..1f9adb246d 100644
@@ -228,15 +228,8 @@ void helper_rdmsr(CPUX86State *env)
 {
 }
 #else
-void helper_wrmsr(CPUX86State *env)
+void cpu_x86_write_msr(CPUX86State *env, uint64_t val)
 {
-    uint64_t val;
-
-    cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1, GETPC());
-
-    val = ((uint32_t)env->regs[R_EAX]) |
-        ((uint64_t)((uint32_t)env->regs[R_EDX]) << 32);
-
     switch ((uint32_t)env->regs[R_ECX]) {
     case MSR_IA32_SYSENTER_CS:
         env->sysenter_cs = val & 0xffff;
@@ -386,11 +379,9 @@ void helper_wrmsr(CPUX86State *env)
         /* XXX: exception? */
         break;
     }
-
-    windbg_try_load();
 }
 
-void helper_rdmsr(CPUX86State *env)
+uint64_t cpu_x86_read_msr(CPUX86State *env)
 {
     uint64_t val;
 
@@ -537,6 +528,32 @@ void helper_rdmsr(CPUX86State *env)
         val = 0;
         break;
     }
+
+    return val;
+}
+
+void helper_wrmsr(CPUX86State *env)
+{
+    uint64_t val;
+
+    cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 1, GETPC());
+
+    val = ((uint32_t)env->regs[R_EAX]) |
+        ((uint64_t)((uint32_t)env->regs[R_EDX]) << 32);
+
+    cpu_x86_write_msr(env, val);
+
+    windbg_try_load();
+}
+
+void helper_rdmsr(CPUX86State *env)
+{
+    uint64_t val;
+
+    cpu_svm_check_intercept_param(env, SVM_EXIT_MSR, 0, GETPC());
+
+    val = cpu_x86_read_msr(env);
+
     env->regs[R_EAX] = (uint32_t)(val);
     env->regs[R_EDX] = (uint32_t)(val >> 32);
 }
target/i386/windbgstub.c +30 -0
index a5be1bc158..071a5d7f77 100644
@@ -1083,6 +1083,36 @@ void kd_api_set_context_ex(CPUState *cs, PacketData *pd)
     stl_p(&ctx->BytesCopied, len);
 }
 
+void kd_api_read_msr(CPUState *cs, PacketData *pd)
+{
+#ifndef CONFIG_USER_ONLY
+    DBGKD_READ_WRITE_MSR *m64c = &pd->m64.u.ReadWriteMsr;
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+    uint64_t val = cpu_x86_read_msr(env);
+
+    stq_p(&val, val);
+
+    m64c->DataValueLow = val;
+    m64c->DataValueHigh = val >> 32;
+    pd->m64.ReturnStatus = STATUS_SUCCESS;
+#endif /* !CONFIG_USER_ONLY */
+}
+
+void kd_api_write_msr(CPUState *cs, PacketData *pd)
+{
+#ifndef CONFIG_USER_ONLY
+    DBGKD_READ_WRITE_MSR *m64c = &pd->m64.u.ReadWriteMsr;
+    X86CPU *cpu = X86_CPU(cs);
+    CPUX86State *env = &cpu->env;
+    uint64_t val = m64c->DataValueLow | ((uint64_t) m64c->DataValueHigh) << 32;
+
+    cpu_x86_write_msr(env, ldq_p(&val));
+
+    pd->m64.ReturnStatus = STATUS_SUCCESS;
+#endif /* !CONFIG_USER_ONLY */
+}
+
 void kd_api_get_version(CPUState *cs, PacketData *pd)
 {
     DBGKD_GET_VERSION64 *kdver = (DBGKD_GET_VERSION64 *) (PTR(pd->m64) + 0x10);
windbgstub.c +8 -0
index 366856bc81..109a52b663 100644
@@ -216,6 +216,14 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_get_version(cs, data);
         break;
 
+    case DbgKdReadMachineSpecificRegister:
+        kd_api_read_msr(cs, data);
+        break;
+
+    case DbgKdWriteMachineSpecificRegister:
+        kd_api_write_msr(cs, data);
+        break;
+
     case DbgKdClearAllInternalBreakpointsApi:
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
#36 lore raw

PATCH 36/39 windbg: implement kd_api_search_memory

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    1 +
 windbgstub-utils.c              |   17 +++++++++++++++++
 windbgstub.c                    |    4 ++++
 3 files changed, 22 insertions(+)
include/exec/windbgstub-utils.h +1 -0
index 74e3b9a0da..4eb976260b 100644
@@ -83,6 +83,7 @@ void kd_api_write_physical_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_version(CPUState *cs, PacketData *pd);
 void kd_api_read_msr(CPUState *cs, PacketData *pd);
 void kd_api_write_msr(CPUState *cs, PacketData *pd);
+void kd_api_search_memory(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
windbgstub-utils.c +17 -0
index fdb106ff12..d77908fb45 100644
@@ -414,6 +414,23 @@ void kd_api_write_physical_memory(CPUState *cs, PacketData *pd)
     stl_p(&mem->ActualBytesWritten, len);
 }
 
+void kd_api_search_memory(CPUState *cs, PacketData *pd)
+{
+    DBGKD_SEARCH_MEMORY *m64c = &pd->m64.u.SearchMemory;
+    int s_len = MAX(ldq_p(&m64c->SearchLength), 1);
+    int p_len = MIN(ldl_p(&m64c->PatternLength), pd->extra_size);
+    target_ulong addr = ldq_p(&m64c->SearchAddress);
+    InitedAddr find =
+        windbg_search_vmaddr(cs, addr, addr + s_len, pd->extra, p_len);
+    pd->extra_size = 0;
+    if (find.is_init) {
+        stl_p(&m64c->FoundAddress, find.addr);
+        pd->m64.ReturnStatus = STATUS_SUCCESS;
+    } else {
+        pd->m64.ReturnStatus = STATUS_NO_MORE_ENTRIES;
+    }
+}
+
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd)
 {
 }
windbgstub.c +4 -0
index 109a52b663..a50de68db5 100644
@@ -224,6 +224,10 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_write_msr(cs, data);
         break;
 
+    case DbgKdSearchMemoryApi:
+        kd_api_search_memory(cs, data);
+        break;
+
     case DbgKdClearAllInternalBreakpointsApi:
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
#37 lore raw

PATCH 37/39 windbg: implement kd_api_fill_memory

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    1 +
 windbgstub-utils.c              |   41 +++++++++++++++++++++++++++++++++++++++
 windbgstub.c                    |    4 ++++
 3 files changed, 46 insertions(+)
include/exec/windbgstub-utils.h +1 -0
index 4eb976260b..8192a7b849 100644
@@ -85,6 +85,7 @@ void kd_api_read_msr(CPUState *cs, PacketData *pd);
 void kd_api_write_msr(CPUState *cs, PacketData *pd);
 void kd_api_search_memory(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
+void kd_api_fill_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
windbgstub-utils.c +41 -0

47 lines not on this page · raw message

windbgstub.c +4 -0
index a50de68db5..daf6d37aa1 100644
@@ -232,6 +232,10 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_clear_all_internal_breakpoints(cs, data);
         return;
 
+    case DbgKdFillMemoryApi:
+        kd_api_fill_memory(cs, data);
+        break;
+
     case DbgKdGetContextExApi:
         kd_api_get_context_ex(cs, data);
         break;
#38 lore raw

PATCH 38/39 windbg: implement kd_api_query_memory

In reply to Mikhail Abakumov
---
 include/exec/windbgstub-utils.h |    1 +
 windbgstub-utils.c              |   10 ++++++++++
 windbgstub.c                    |    4 ++++
 3 files changed, 15 insertions(+)
include/exec/windbgstub-utils.h +1 -0
index 8192a7b849..bddb52d3db 100644
@@ -86,6 +86,7 @@ void kd_api_write_msr(CPUState *cs, PacketData *pd);
 void kd_api_search_memory(CPUState *cs, PacketData *pd);
 void kd_api_clear_all_internal_breakpoints(CPUState *cs, PacketData *pd);
 void kd_api_fill_memory(CPUState *cs, PacketData *pd);
+void kd_api_query_memory(CPUState *cs, PacketData *pd);
 void kd_api_get_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_set_context_ex(CPUState *cs, PacketData *pd);
 void kd_api_unsupported(CPUState *cs, PacketData *pd);
windbgstub-utils.c +10 -0
index 007fea7223..f109925f25 100644
@@ -476,6 +476,16 @@ void kd_api_fill_memory(CPUState *cs, PacketData *pd)
     g_free(mem);
 }
 
+void kd_api_query_memory(CPUState *cs, PacketData *pd)
+{
+    DBGKD_QUERY_MEMORY *mem = &pd->m64.u.QueryMemory;
+
+    /* TODO: Needs test memory. */
+    stl_p(&mem->AddressSpace, DBGKD_QUERY_MEMORY_PROCESS);
+    stl_p(&mem->Flags, DBGKD_QUERY_MEMORY_READ | DBGKD_QUERY_MEMORY_WRITE |
+                       DBGKD_QUERY_MEMORY_EXECUTE);
+}
+
 void kd_api_unsupported(CPUState *cs, PacketData *pd)
 {
     WINDBG_ERROR("Caught unimplemented api %s", kd_api_name(pd->m64.ApiNumber));
windbgstub.c +4 -0
index daf6d37aa1..23ad05f12b 100644
@@ -236,6 +236,10 @@ static void windbg_process_manipulate_packet(WindbgState *state)
         kd_api_fill_memory(cs, data);
         break;
 
+    case DbgKdQueryMemoryApi:
+        kd_api_query_memory(cs, data);
+        break;
+
     case DbgKdGetContextExApi:
         kd_api_get_context_ex(cs, data);
         break;
#39 lore raw

PATCH 39/39 windbg: maintainers

In reply to Mikhail Abakumov

Add WinDbg stub to the MAINTAINERS.

---
 MAINTAINERS |   12 ++++++++++++
 1 file changed, 12 insertions(+)
MAINTAINERS +12 -0
index 1032406c56..dffbd267be 100644
@@ -1689,6 +1689,18 @@ S: Odd Fixes
 F: gdbstub*
 F: gdb-xml/
 
+WinDbg stub
+M: Mikhail Abakumov <[email protected]>
+R: Pavel Dovgalyuk <[email protected]>
+S: Supported
+F: include/exec/windbgstub.h
+F: include/exec/windbgstub-utils.h
+F: include/exec/windbgkd.h
+F: windbgstub.c
+F: windbgstub-utils.c
+F: stubs/windbgstub.c
+F: target/i386/windbgstub.c
+
 Memory API
 M: Paolo Bonzini <[email protected]>
 S: Supported
#40 lore raw
In reply to Mikhail Abakumov
This series failed docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Hi,

This series failed docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Type: series
Subject: [Qemu-devel] [PATCH 00/39] Windbg supporting
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-quick@centos7 SHOW_ENV=1 J=8 === TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
17f6c7f windbg: maintainers
97b20af windbg: implement kd_api_query_memory
5635727 windbg: implement kd_api_fill_memory
6677180 windbg: implement kd_api_search_memory
9973f61 windbg: implement kd_api_read_msr and kd_api_write_msr
3c083dc windbg: implement kd_api_get_version
fca59ca windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory c3e495d windbg: implement kd_api_read_io_space and kd_api_write_io_space 4e29a33 windbg: implement kd_api_continue
5ca2f2f windbg: debug exception subscribing
dc31c84 windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint 0e915cc windbg: implement kd_api_read_control_space and kd_api_write_control_space 915f355 windbg: implement kd_api_get_context_ex and kd_api_set_context_ex 97cd6e2 windbg: implement kd_api_get_context and kd_api_set_context 6bf0cf1 windbg: [de]serialization cpu spec registers
fac3d74 windbg: [de]serialization cpu context
b0be5e5 windbg: add helper functions
0c2dacc windbg: some kernel structures
753465e windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory 8eb2ea2 windbg: implement windbg_process_manipulate_packet
05a53e5 windbg: implement windbg_process_data_packet
b41ab55 windbg: implement windbg_process_control_packet
008a6da windbg: generate ExceptionStateChange and LoadSymbolsStateChange e1bff4f windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
4022b99 windbg: handler of parsing context
bfc2e66 windbg: send data and control packets
b84f44e windbg: parsing data stream
86cf35e windbg: implement find_kdDebuggerDataBlock
e9afd1f windbg: add windbg_search_vmaddr
70d6fbe windbg: implement find_kdVersion
30eb118 windbg: implement find_KPCR
c909786 windbg: implement windbg_on_load
16531ab windbg: hook to wrmsr operation
bfc9fb5 windbg: add chardev
a8d8787 windbg: add WindbgState
3a5b5bf windbg: add helper features
e53a519 windbg: add -windbg option
7995ade windbg: add windbg's KD header file
5ed26b5 windbg: add empty windbgstub files

=== OUTPUT BEGIN ===
BUILD centos7
make[1]: Entering directory `/var/tmp/patchew-tester-tmp-elcqpjgq/src'
GEN /var/tmp/patchew-tester-tmp-elcqpjgq/src/docker-src.2018-11-30-06.51.33.7508/qemu.tar
Cloning into '/var/tmp/patchew-tester-tmp-elcqpjgq/src/docker-src.2018-11-30-06.51.33.7508/qemu.tar.vroot'... done.

Checking out files:  47% (3044/6472)   
Checking out files:  48% (3107/6472)   
Checking out files:  49% (3172/6472)   
Checking out files:  50% (3236/6472)   
Checking out files:  51% (3301/6472)   
Checking out files:  52% (3366/6472)   
Checking out files:  53% (3431/6472)   
Checking out files:  54% (3495/6472)   
Checking out files:  55% (3560/6472)   
Checking out files:  56% (3625/6472)   
Checking out files:  57% (3690/6472)   
Checking out files:  58% (3754/6472)   
Checking out files:  59% (3819/6472)   
Checking out files:  60% (3884/6472)   
Checking out files:  61% (3948/6472)   
Checking out files:  62% (4013/6472)   
Checking out files:  63% (4078/6472)   
Checking out files:  64% (4143/6472)   
Checking out files:  65% (4207/6472)   
Checking out files:  66% (4272/6472)   
Checking out files:  67% (4337/6472)   
Checking out files:  68% (4401/6472)   
Checking out files:  69% (4466/6472)   
Checking out files:  70% (4531/6472)   
Checking out files:  71% (4596/6472)   
Checking out files:  72% (4660/6472)   
Checking out files:  73% (4725/6472)   
Checking out files:  74% (4790/6472)   
Checking out files:  75% (4854/6472)   
Checking out files:  76% (4919/6472)   
Checking out files:  77% (4984/6472)   
Checking out files:  78% (5049/6472)   
Checking out files:  79% (5113/6472)   
Checking out files:  80% (5178/6472)   
Checking out files:  81% (5243/6472)   
Checking out files:  82% (5308/6472)   
Checking out files:  83% (5372/6472)   
Checking out files:  84% (5437/6472)   
Checking out files:  85% (5502/6472)   
Checking out files:  86% (5566/6472)   
Checking out files:  87% (5631/6472)   
Checking out files:  88% (5696/6472)   
Checking out files:  89% (5761/6472)   
Checking out files:  90% (5825/6472)   
Checking out files:  91% (5890/6472)   
Checking out files:  92% (5955/6472)   
Checking out files:  93% (6019/6472)   
Checking out files:  94% (6084/6472)   
Checking out files:  95% (6149/6472)   
Checking out files:  96% (6214/6472)   
Checking out files:  97% (6278/6472)   
Checking out files:  98% (6343/6472)   
Checking out files:  99% (6408/6472)   
Checking out files: 100% (6472/6472)   
Checking out files: 100% (6472/6472), done.

Submodule 'dtc' (https://git.qemu.org/git/dtc.git) registered for path 'dtc'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '88f18909db731a627456f26d779445f84e449536'
Submodule 'ui/keycodemapdb' (https://git.qemu.org/git/keycodemapdb.git) registered for path 'ui/keycodemapdb' Cloning into 'ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out '6b3d716e2b6472eb7189d3220552280ef3d832ce'
COPY RUNNER
RUN test-quick in qemu:centos7
Packages installed:
SDL-devel-1.2.15-14.el7.x86_64
bison-3.0.4-1.el7.x86_64
bzip2-1.0.6-13.el7.x86_64
bzip2-devel-1.0.6-13.el7.x86_64
ccache-3.3.4-1.el7.x86_64
csnappy-devel-0-6.20150729gitd7bc683.el7.x86_64
flex-2.5.37-3.el7.x86_64
gcc-4.8.5-28.el7_5.1.x86_64
gettext-0.19.8.1-2.el7.x86_64
git-1.8.3.1-14.el7_5.x86_64
glib2-devel-2.54.2-2.el7.x86_64
libaio-devel-0.3.109-13.el7.x86_64
libepoxy-devel-1.3.1-2.el7_5.x86_64
libfdt-devel-1.4.6-1.el7.x86_64
lzo-devel-2.06-8.el7.x86_64
make-3.82-23.el7.x86_64
mesa-libEGL-devel-17.2.3-8.20171019.el7.x86_64 mesa-libgbm-devel-17.2.3-8.20171019.el7.x86_64
nettle-devel-2.7.1-8.el7.x86_64
package g++ is not installed
package librdmacm-devel is not installed
pixman-devel-0.34.0-1.el7.x86_64
spice-glib-devel-0.34-3.el7_5.2.x86_64
spice-server-devel-0.14.0-2.el7_5.5.x86_64
tar-1.26-34.el7.x86_64
vte-devel-0.28.2-10.el7.x86_64
xen-devel-4.8.4.43.ge52ec4b787-1.el7.x86_64
zlib-devel-1.2.7-17.el7.x86_64

Environment variables:
PACKAGES=bison bzip2 bzip2-devel ccache csnappy-devel flex g++ gcc gettext git glib2-devel libaio-devel libepoxy-devel libfdt-devel librdmacm-devel lzo-devel make mesa-libEGL-devel mesa-libgbm-devel nettle-devel pixman-devel SDL-devel spice-glib-devel spice-server-devel tar vte-devel xen-devel zlib-devel
HOSTNAME=fa78a9554fb8
MAKEFLAGS= -j8
J=8
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1 PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/
TARGET_LIST=
SHLVL=1
HOME=/home/patchew
TEST_DIR=/tmp/qemu-test
FEATURES= dtc
DEBUG=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu --prefix=/tmp/qemu-test/install No C++ compiler available; disabling C++ specific optional code

Install prefix    /tmp/qemu-test/install
BIOS directory    /tmp/qemu-test/install/share/qemu
firmware path     /tmp/qemu-test/install/share/qemu-firmware
binary directory  /tmp/qemu-test/install/bin

library directory /tmp/qemu-test/install/lib module directory /tmp/qemu-test/install/lib/qemu libexec directory /tmp/qemu-test/install/libexec include directory /tmp/qemu-test/install/include config directory /tmp/qemu-test/install/etc
local state directory /tmp/qemu-test/install/var
Manual directory /tmp/qemu-test/install/share/man ELF interp prefix /usr/gnemul/qemu-%M
Source path /tmp/qemu-test/src
GIT binary git
GIT submodules
C compiler cc
Host C compiler cc
C++ compiler
Objective-C compiler cc

ARFLAGS           rv
CFLAGS            -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS       -I/usr/include/pixman-1    -Werror   -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong -Wno-missing-braces   -I/usr/include/libpng15     -pthread -I/usr/include/spice-server -I/usr/include/cacard -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/nss3 -I/usr/include/nspr4 -I/usr/include/spice-1  
LDFLAGS           -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
QEMU_LDFLAGS       
make              make
install           install
python            python -B
smbd              /usr/sbin/smbd
module support    no
host CPU          x86_64
host big endian   no
target list       x86_64-softmmu aarch64-softmmu
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
SDL support       yes (1.2.15)
GTK support       no 
GTK GL support    no
VTE support       no 
TLS priority      NORMAL
GNUTLS support    no
libgcrypt         no
nettle            yes (2.7.1)
libtasn1          no
curses support    yes
virgl support     no 
curl support      no
mingw32 support   no
Audio drivers     oss

Block whitelist (rw)
Block whitelist (ro)
VirtFS support no
Multipath support no

VNC support       yes
VNC SASL support  no
VNC JPEG support  no
VNC PNG support   yes
xen support       yes
xen ctrl version  40800
pv dom build      no
brlapi support    no
bluez  support    no
Documentation     no
PIE               yes
vde support       no
netmap support    no
Linux AIO support yes
ATTR/XATTR support yes
Install blobs     yes
KVM support       yes
HAX support       no
HVF support       no
WHPX support      no
TCG support       yes
TCG debug enabled no
TCG interpreter   no
malloc trim support yes
RDMA support      yes
PVRDMA support    yes
fdt support       system
membarrier        no
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
posix_memalign    yes

libcap-ng support no
vhost-net support yes
vhost-crypto support yes
vhost-scsi support yes
vhost-vsock support yes
vhost-user support yes

Trace backends    log
spice support     yes (0.12.13/0.14.0)
rbd support       no
xfsctl support    no
smartcard support yes
libusb            no
usb net redir     no
OpenGL support    yes
OpenGL dmabufs    yes
libiscsi support  no
libnfs support    no

build guest agent yes
QGA VSS support no
QGA w32 disk info no
QGA MSI support no
seccomp support no
coroutine backend ucontext
coroutine pool yes
debug stack usage no
mutex debugging no
crypto afalg no
GlusterFS support no

gcov              gcov
gcov enabled      no
TPM support       yes
libssh2 support   no
TPM passthrough   yes
TPM emulator      yes
QOM debugging     yes
Live block migration yes
lzo support       yes
snappy support    no
bzip2 support     yes
NUMA host support no
libxml2           no
tcmalloc support  no
jemalloc support  no
avx2 optimization yes
replication support yes
VxHS block device no
bochs support     yes
cloop support     yes
dmg support       yes
qcow v1 support   yes
vdi support       yes
vvfat support     yes
qed support       yes
parallels support yes
sheepdog support  yes
capstone          no
docker            no
libpmem support   no
libudev           no

WARNING: Use of SDL 1.2 is deprecated and will be removed in
WARNING: future releases. Please switch to using SDL 2.0

NOTE: cross-compilers enabled: 'cc'

  GEN     x86_64-softmmu/config-devices.mak.tmp
  GEN     aarch64-softmmu/config-devices.mak.tmp
  GEN     config-host.h
  GEN     qemu-options.def
  GEN     qapi-gen
  GEN     trace/generated-tcg-tracers.h
  GEN     trace/generated-helpers-wrappers.h
  GEN     trace/generated-helpers.h
  GEN     aarch64-softmmu/config-devices.mak
  GEN     x86_64-softmmu/config-devices.mak
  GEN     trace/generated-helpers.c
  GEN     module_block.h
  GEN     ui/input-keymap-atset1-to-qcode.c
  GEN     ui/input-keymap-linux-to-qcode.c
  GEN     ui/input-keymap-qcode-to-atset1.c
  GEN     ui/input-keymap-qcode-to-atset2.c
  GEN     ui/input-keymap-qcode-to-atset3.c
  GEN     ui/input-keymap-qcode-to-linux.c
  GEN     ui/input-keymap-qcode-to-qnum.c
  GEN     ui/input-keymap-qcode-to-sun.c
  GEN     ui/input-keymap-qnum-to-qcode.c
  GEN     ui/input-keymap-usb-to-qcode.c
  GEN     ui/input-keymap-win32-to-qcode.c
  GEN     ui/input-keymap-x11-to-qcode.c
  GEN     ui/input-keymap-xorgevdev-to-qcode.c
  GEN     ui/input-keymap-xorgkbd-to-qcode.c
  GEN     ui/input-keymap-xorgxquartz-to-qcode.c
  GEN     ui/input-keymap-xorgxwin-to-qcode.c
  GEN     ui/input-keymap-osx-to-qcode.c
  GEN     tests/test-qapi-gen
  GEN     trace-root.h
  GEN     accel/kvm/trace.h
  GEN     accel/tcg/trace.h
  GEN     audio/trace.h
  GEN     block/trace.h
  GEN     chardev/trace.h
  GEN     crypto/trace.h
  GEN     hw/9pfs/trace.h
  GEN     hw/acpi/trace.h
  GEN     hw/alpha/trace.h
  GEN     hw/arm/trace.h
  GEN     hw/audio/trace.h
  GEN     hw/block/trace.h
  GEN     hw/block/dataplane/trace.h
  GEN     hw/char/trace.h
  GEN     hw/display/trace.h
  GEN     hw/dma/trace.h
  GEN     hw/hppa/trace.h
  GEN     hw/i2c/trace.h
  GEN     hw/i386/trace.h
  GEN     hw/i386/xen/trace.h
  GEN     hw/ide/trace.h
  GEN     hw/input/trace.h
  GEN     hw/intc/trace.h
  GEN     hw/isa/trace.h
  GEN     hw/mem/trace.h
  GEN     hw/misc/trace.h
  GEN     hw/misc/macio/trace.h
  GEN     hw/net/trace.h
  GEN     hw/nvram/trace.h
  GEN     hw/pci/trace.h
  GEN     hw/pci-host/trace.h
  GEN     hw/ppc/trace.h
  GEN     hw/rdma/trace.h
  GEN     hw/rdma/vmw/trace.h
  GEN     hw/s390x/trace.h
  GEN     hw/scsi/trace.h
  GEN     hw/sd/trace.h
  GEN     hw/sparc/trace.h
  GEN     hw/sparc64/trace.h
  GEN     hw/timer/trace.h
  GEN     hw/tpm/trace.h
  GEN     hw/usb/trace.h
  GEN     hw/vfio/trace.h
  GEN     hw/virtio/trace.h
  GEN     hw/watchdog/trace.h
  GEN     hw/xen/trace.h
  GEN     io/trace.h
  GEN     linux-user/trace.h
  GEN     migration/trace.h
  GEN     nbd/trace.h
  GEN     net/trace.h
  GEN     qapi/trace.h
  GEN     qom/trace.h
  GEN     scsi/trace.h
  GEN     target/arm/trace.h
  GEN     target/i386/trace.h
  GEN     target/mips/trace.h
  GEN     target/ppc/trace.h
  GEN     target/s390x/trace.h
  GEN     target/sparc/trace.h
  GEN     ui/trace.h
  GEN     util/trace.h
  GEN     trace-root.c
  GEN     accel/kvm/trace.c
  GEN     accel/tcg/trace.c
  GEN     audio/trace.c
  GEN     block/trace.c
  GEN     chardev/trace.c
  GEN     crypto/trace.c
  GEN     hw/9pfs/trace.c
  GEN     hw/acpi/trace.c
  GEN     hw/alpha/trace.c
  GEN     hw/arm/trace.c
  GEN     hw/audio/trace.c
  GEN     hw/block/trace.c
  GEN     hw/block/dataplane/trace.c
  GEN     hw/char/trace.c
  GEN     hw/display/trace.c
  GEN     hw/dma/trace.c
  GEN     hw/hppa/trace.c
  GEN     hw/i2c/trace.c
  GEN     hw/i386/trace.c
  GEN     hw/i386/xen/trace.c
  GEN     hw/ide/trace.c
  GEN     hw/input/trace.c
  GEN     hw/intc/trace.c
  GEN     hw/isa/trace.c
  GEN     hw/mem/trace.c
  GEN     hw/misc/trace.c
  GEN     hw/misc/macio/trace.c
  GEN     hw/net/trace.c
  GEN     hw/nvram/trace.c
  GEN     hw/pci/trace.c
  GEN     hw/pci-host/trace.c
  GEN     hw/ppc/trace.c
  GEN     hw/rdma/trace.c
  GEN     hw/rdma/vmw/trace.c
  GEN     hw/s390x/trace.c
  GEN     hw/scsi/trace.c
  GEN     hw/sd/trace.c
  GEN     hw/sparc/trace.c
  GEN     hw/sparc64/trace.c
  GEN     hw/timer/trace.c
  GEN     hw/tpm/trace.c
  GEN     hw/usb/trace.c
  GEN     hw/vfio/trace.c
  GEN     hw/virtio/trace.c
  GEN     hw/watchdog/trace.c
  GEN     hw/xen/trace.c
  GEN     io/trace.c
  GEN     linux-user/trace.c
  GEN     migration/trace.c
  GEN     nbd/trace.c
  GEN     net/trace.c
  GEN     qapi/trace.c
  GEN     qom/trace.c
  GEN     scsi/trace.c
  GEN     target/arm/trace.c
  GEN     target/i386/trace.c
  GEN     target/mips/trace.c
  GEN     target/ppc/trace.c
  GEN     target/s390x/trace.c
  GEN     target/sparc/trace.c
  GEN     ui/trace.c
  GEN     util/trace.c
  GEN     config-all-devices.mak
  CC      tests/qemu-iotests/socket_scm_helper.o
  GEN     qga/qapi-generated/qapi-gen
  CC      qapi/qapi-builtin-types.o
  CC      qapi/qapi-types.o
  CC      qapi/qapi-types-block-core.o
  CC      qapi/qapi-types-block.o
  CC      qapi/qapi-types-char.o
  CC      qapi/qapi-types-common.o
  CC      qapi/qapi-types-crypto.o
  CC      qapi/qapi-types-introspect.o
  CC      qapi/qapi-types-job.o
  CC      qapi/qapi-types-migration.o
  CC      qapi/qapi-types-misc.o
  CC      qapi/qapi-types-net.o
  CC      qapi/qapi-types-rocker.o
  CC      qapi/qapi-types-run-state.o
  CC      qapi/qapi-types-sockets.o
  CC      qapi/qapi-types-tpm.o
  CC      qapi/qapi-types-trace.o
  CC      qapi/qapi-types-transaction.o
  CC      qapi/qapi-types-ui.o
  CC      qapi/qapi-builtin-visit.o
  CC      qapi/qapi-visit.o
  CC      qapi/qapi-visit-block-core.o
  CC      qapi/qapi-visit-block.o
  CC      qapi/qapi-visit-char.o
  CC      qapi/qapi-visit-common.o
  CC      qapi/qapi-visit-crypto.o
  CC      qapi/qapi-visit-introspect.o
  CC      qapi/qapi-visit-job.o
  CC      qapi/qapi-visit-migration.o
  CC      qapi/qapi-visit-misc.o
  CC      qapi/qapi-visit-net.o
  CC      qapi/qapi-visit-rocker.o
  CC      qapi/qapi-visit-run-state.o
  CC      qapi/qapi-visit-sockets.o
  CC      qapi/qapi-visit-tpm.o
  CC      qapi/qapi-visit-trace.o
  CC      qapi/qapi-visit-transaction.o
  CC      qapi/qapi-visit-ui.o
  CC      qapi/qapi-events.o
  CC      qapi/qapi-events-block-core.o
  CC      qapi/qapi-events-block.o
  CC      qapi/qapi-events-char.o
  CC      qapi/qapi-events-common.o
  CC      qapi/qapi-events-crypto.o
  CC      qapi/qapi-events-introspect.o
  CC      qapi/qapi-events-job.o
  CC      qapi/qapi-events-migration.o
  CC      qapi/qapi-events-misc.o
  CC      qapi/qapi-events-net.o
  CC      qapi/qapi-events-rocker.o
  CC      qapi/qapi-events-run-state.o
  CC      qapi/qapi-events-sockets.o
  CC      qapi/qapi-events-tpm.o
  CC      qapi/qapi-events-trace.o
  CC      qapi/qapi-events-transaction.o
  CC      qapi/qapi-events-ui.o
  CC      qapi/qapi-introspect.o
  CC      qapi/qapi-visit-core.o
  CC      qapi/qapi-dealloc-visitor.o
  CC      qapi/qobject-input-visitor.o
  CC      qapi/qobject-output-visitor.o
  CC      qapi/qmp-registry.o
  CC      qapi/qmp-dispatch.o
  CC      qapi/string-input-visitor.o
  CC      qapi/string-output-visitor.o
  CC      qapi/opts-visitor.o
  CC      qapi/qapi-clone-visitor.o
  CC      qapi/qmp-event.o
  CC      qapi/qapi-util.o
  CC      qobject/qnull.o
  CC      qobject/qnum.o
  CC      qobject/qstring.o
  CC      qobject/qdict.o
  CC      qobject/qlist.o
  CC      qobject/qlit.o
  CC      qobject/qbool.o
  CC      qobject/qjson.o
  CC      qobject/qobject.o
  CC      qobject/json-lexer.o
  CC      qobject/json-streamer.o
  CC      qobject/json-parser.o
  CC      qobject/block-qdict.o
  CC      trace/control.o
  CC      trace/qmp.o
  CC      util/cutils.o
  CC      util/osdep.o
  CC      util/unicode.o
  CC      util/qemu-timer-common.o
  CC      util/bufferiszero.o
  CC      util/lockcnt.o
  CC      util/aiocb.o
  CC      util/async.o
  CC      util/aio-wait.o
  CC      util/thread-pool.o
  CC      util/qemu-timer.o
  CC      util/main-loop.o
  CC      util/iohandler.o
  CC      util/aio-posix.o
  CC      util/compatfd.o
  CC      util/event_notifier-posix.o
  CC      util/mmap-alloc.o
  CC      util/oslib-posix.o
  CC      util/qemu-openpty.o
  CC      util/qemu-thread-posix.o
  CC      util/memfd.o
  CC      util/envlist.o
  CC      util/path.o
  CC      util/module.o
  CC      util/host-utils.o
  CC      util/bitmap.o
  CC      util/bitops.o
  CC      util/hbitmap.o
  CC      util/fifo8.o
  CC      util/acl.o
  CC      util/cacheinfo.o
  CC      util/error.o
  CC      util/qemu-error.o
  CC      util/id.o
  CC      util/iov.o
  CC      util/qemu-config.o
  CC      util/qemu-sockets.o
  CC      util/uri.o
  CC      util/notify.o
  CC      util/qemu-option.o
  CC      util/qemu-progress.o
  CC      util/keyval.o
  CC      util/hexdump.o
  CC      util/crc32c.o
  CC      util/uuid.o
  CC      util/throttle.o
  CC      util/getauxval.o
  CC      util/readline.o
  CC      util/rcu.o
  CC      util/qemu-coroutine.o
  CC      util/qemu-coroutine-lock.o
  CC      util/qemu-coroutine-io.o
  CC      util/qemu-coroutine-sleep.o
  CC      util/coroutine-ucontext.o
  CC      util/buffer.o
  CC      util/timed-average.o
  CC      util/base64.o
  CC      util/log.o
  CC      util/pagesize.o
  CC      util/qdist.o
  CC      util/qht.o
  CC      util/qsp.o
  CC      util/range.o
  CC      util/stats64.o
  CC      util/systemd.o
  CC      util/iova-tree.o
  CC      util/vfio-helpers.o
  CC      util/drm.o
  CC      trace-root.o
  CC      accel/kvm/trace.o
  CC      accel/tcg/trace.o
  CC      audio/trace.o
  CC      block/trace.o
  CC      chardev/trace.o
  CC      crypto/trace.o
  CC      hw/9pfs/trace.o
  CC      hw/acpi/trace.o
  CC      hw/alpha/trace.o
  CC      hw/arm/trace.o
  CC      hw/audio/trace.o
  CC      hw/block/trace.o
  CC      hw/block/dataplane/trace.o
  CC      hw/char/trace.o
  CC      hw/dma/trace.o
  CC      hw/display/trace.o
  CC      hw/hppa/trace.o
  CC      hw/i386/trace.o
  CC      hw/i2c/trace.o
  CC      hw/i386/xen/trace.o
  CC      hw/ide/trace.o
  CC      hw/input/trace.o
  CC      hw/intc/trace.o
  CC      hw/isa/trace.o
  CC      hw/mem/trace.o
  CC      hw/misc/trace.o
  CC      hw/misc/macio/trace.o
  CC      hw/net/trace.o
  CC      hw/nvram/trace.o
  CC      hw/pci/trace.o
  CC      hw/pci-host/trace.o
  CC      hw/ppc/trace.o
  CC      hw/rdma/trace.o
  CC      hw/rdma/vmw/trace.o
  CC      hw/s390x/trace.o
  CC      hw/scsi/trace.o
  CC      hw/sd/trace.o
  CC      hw/sparc/trace.o
  CC      hw/sparc64/trace.o
  CC      hw/timer/trace.o
  CC      hw/tpm/trace.o
  CC      hw/usb/trace.o
  CC      hw/vfio/trace.o
  CC      hw/virtio/trace.o
  CC      hw/watchdog/trace.o
  CC      hw/xen/trace.o
  CC      io/trace.o
  CC      linux-user/trace.o
  CC      migration/trace.o
  CC      nbd/trace.o
  CC      net/trace.o
  CC      qapi/trace.o
  CC      qom/trace.o
  CC      scsi/trace.o
  CC      target/arm/trace.o
  CC      target/i386/trace.o
  CC      target/mips/trace.o
  CC      target/ppc/trace.o
  CC      target/s390x/trace.o
  CC      target/sparc/trace.o
  CC      ui/trace.o
  CC      util/trace.o
  CC      crypto/pbkdf-stub.o
  CC      stubs/arch-query-cpu-def.o
  CC      stubs/arch-query-cpu-model-expansion.o
  CC      stubs/arch-query-cpu-model-comparison.o
  CC      stubs/arch-query-cpu-model-baseline.o
  CC      stubs/bdrv-next-monitor-owned.o
  CC      stubs/blk-commit-all.o
  CC      stubs/blockdev-close-all-bdrv-states.o
  CC      stubs/clock-warp.o
  CC      stubs/cpu-get-clock.o
  CC      stubs/cpu-get-icount.o
  CC      stubs/dump.o
  CC      stubs/error-printf.o
  CC      stubs/fdset.o
  CC      stubs/gdbstub.o
  CC      stubs/get-vm-name.o
  CC      stubs/iothread.o
  CC      stubs/iothread-lock.o
  CC      stubs/is-daemonized.o
  CC      stubs/linux-aio.o
  CC      stubs/machine-init-done.o
  CC      stubs/migr-blocker.o
  CC      stubs/change-state-handler.o
  CC      stubs/monitor.o
  CC      stubs/notify-event.o
  CC      stubs/qtest.o
  CC      stubs/replay.o
  CC      stubs/runstate-check.o
  CC      stubs/set-fd-handler.o
  CC      stubs/slirp.o
  CC      stubs/sysbus.o
  CC      stubs/tpm.o
  CC      stubs/trace-control.o
  CC      stubs/uuid.o
  CC      stubs/vm-stop.o
  CC      stubs/vmstate.o
  CC      stubs/windbgstub.o
  CC      stubs/qmp_memory_device.o
  CC      stubs/target-monitor-defs.o
  CC      stubs/target-get-monitor-def.o
  CC      stubs/pc_madt_cpu_entry.o
  CC      stubs/vmgenid.o
  CC      stubs/xen-common.o
  CC      stubs/xen-hvm.o
  CC      stubs/pci-host-piix.o
  CC      stubs/ram-block.o
  CC      stubs/ramfb.o
  CC      contrib/ivshmem-client/ivshmem-client.o
  CC      contrib/ivshmem-client/main.o
  CC      contrib/ivshmem-server/ivshmem-server.o
  CC      contrib/ivshmem-server/main.o
  CC      qemu-nbd.o
  CC      block.o
  CC      blockjob.o
  CC      job.o
  CC      qemu-io-cmds.o
  CC      replication.o
  CC      block/raw-format.o
  CC      block/vmdk.o
  CC      block/vpc.o
  CC      block/qcow.o
  CC      block/vdi.o
  CC      block/cloop.o
  CC      block/bochs.o
  CC      block/vvfat.o
  CC      block/dmg.o
  CC      block/qcow2.o
  CC      block/qcow2-refcount.o
  CC      block/qcow2-cluster.o
  CC      block/qcow2-snapshot.o
  CC      block/qcow2-cache.o
  CC      block/qcow2-bitmap.o
  CC      block/qed-l2-cache.o
  CC      block/qed.o
  CC      block/qed-table.o
  CC      block/qed-cluster.o
  CC      block/qed-check.o
  CC      block/vhdx.o
  CC      block/vhdx-endian.o
  CC      block/vhdx-log.o
  CC      block/quorum.o
  CC      block/blkdebug.o
  CC      block/blkverify.o
  CC      block/blkreplay.o
  CC      block/parallels.o
  CC      block/blklogwrites.o
  CC      block/block-backend.o
  CC      block/snapshot.o
  CC      block/qapi.o
  CC      block/file-posix.o
  CC      block/linux-aio.o
  CC      block/null.o
  CC      block/commit.o
  CC      block/mirror.o
  CC      block/io.o
  CC      block/create.o
  CC      block/throttle-groups.o
  CC      block/nvme.o
  CC      block/nbd.o
  CC      block/nbd-client.o
  CC      block/sheepdog.o
  CC      block/accounting.o
  CC      block/dirty-bitmap.o
  CC      block/write-threshold.o
  CC      block/backup.o
  CC      block/replication.o
  CC      block/throttle.o
  CC      block/copy-on-read.o
  CC      block/crypto.o
  CC      nbd/server.o
  CC      nbd/client.o
  CC      nbd/common.o
  CC      scsi/utils.o
  CC      scsi/pr-manager.o
  CC      scsi/pr-manager-helper.o
  CC      block/dmg-bz2.o
  CC      crypto/init.o
  CC      crypto/hash.o
  CC      crypto/hash-nettle.o
  CC      crypto/hmac.o
  CC      crypto/hmac-nettle.o
  CC      crypto/aes.o
  CC      crypto/desrfb.o
  CC      crypto/cipher.o
  CC      crypto/tlscreds.o
  CC      crypto/tlscredsanon.o
  CC      crypto/tlscredspsk.o
  CC      crypto/tlscredsx509.o
  CC      crypto/tlssession.o
  CC      crypto/secret.o
  CC      crypto/random-platform.o
  CC      crypto/pbkdf.o
  CC      crypto/pbkdf-nettle.o
  CC      crypto/ivgen.o
  CC      crypto/ivgen-essiv.o
  CC      crypto/ivgen-plain.o
  CC      crypto/ivgen-plain64.o
  CC      crypto/afsplit.o
  CC      crypto/xts.o
  CC      crypto/block.o
  CC      crypto/block-qcow.o
  CC      crypto/block-luks.o
  CC      io/channel.o
  CC      io/channel-buffer.o
  CC      io/channel-command.o
  CC      io/channel-file.o
  CC      io/channel-socket.o
  CC      io/channel-tls.o
  CC      io/channel-watch.o
  CC      io/channel-websock.o
  CC      io/channel-util.o
  CC      io/dns-resolver.o
  CC      io/net-listener.o
  CC      io/task.o
  CC      qom/object.o
  CC      qom/container.o
  CC      qom/qom-qobject.o
  CC      qom/object_interfaces.o
  GEN     qemu-img-cmds.h
  CC      qemu-io.o
  CC      qemu-edid.o
  CC      hw/display/edid-generate.o
  CC      scsi/qemu-pr-helper.o
  CC      qemu-bridge-helper.o
  CC      blockdev.o
  CC      blockdev-nbd.o
  CC      bootdevice.o
  CC      iothread.o
  CC      job-qmp.o
  CC      qdev-monitor.o
  CC      device-hotplug.o
  CC      os-posix.o
  CC      bt-host.o
  CC      bt-vhci.o
  CC      dma-helpers.o
  CC      vl.o
  CC      tpm.o
  CC      device_tree.o
  CC      qapi/qapi-commands.o
  CC      qapi/qapi-commands-block-core.o
  CC      qapi/qapi-commands-block.o
  CC      qapi/qapi-commands-char.o
  CC      qapi/qapi-commands-common.o
  CC      qapi/qapi-commands-crypto.o
  CC      qapi/qapi-commands-introspect.o
  CC      qapi/qapi-commands-job.o
  CC      qapi/qapi-commands-migration.o
  CC      qapi/qapi-commands-misc.o
  CC      qapi/qapi-commands-net.o
  CC      qapi/qapi-commands-rocker.o
  CC      qapi/qapi-commands-run-state.o
  CC      qapi/qapi-commands-tpm.o
  CC      qapi/qapi-commands-sockets.o
  CC      qapi/qapi-commands-trace.o
  CC      qapi/qapi-commands-transaction.o
  CC      qapi/qapi-commands-ui.o
  CC      qmp.o
  CC      hmp.o
  CC      cpus-common.o
  CC      audio/audio.o
  CC      audio/noaudio.o
  CC      audio/wavaudio.o
  CC      audio/mixeng.o
  CC      audio/spiceaudio.o
  CC      audio/wavcapture.o
  CC      backends/rng.o
  CC      backends/rng-egd.o
  CC      backends/rng-random.o
  CC      backends/tpm.o
  CC      backends/hostmem.o
  CC      backends/hostmem-ram.o
  CC      backends/hostmem-file.o
  CC      backends/cryptodev.o
  CC      backends/cryptodev-builtin.o
  CC      backends/cryptodev-vhost.o
  CC      backends/cryptodev-vhost-user.o
  CC      backends/hostmem-memfd.o
  CC      block/stream.o
  CC      chardev/msmouse.o
  CC      chardev/wctablet.o
  CC      chardev/testdev.o
  CC      chardev/spice.o
  CC      disas/arm.o
  CC      disas/i386.o
  CC      fsdev/qemu-fsdev-dummy.o
  CC      fsdev/qemu-fsdev-opts.o
  CC      fsdev/qemu-fsdev-throttle.o
  CC      hw/acpi/core.o
  CC      hw/acpi/piix4.o
  CC      hw/acpi/pcihp.o
  CC      hw/acpi/ich9.o
  CC      hw/acpi/tco.o
  CC      hw/acpi/cpu_hotplug.o
  CC      hw/acpi/memory_hotplug.o
  CC      hw/acpi/cpu.o
  CC      hw/acpi/nvdimm.o
  CC      hw/acpi/vmgenid.o
  CC      hw/acpi/acpi_interface.o
  CC      hw/acpi/bios-linker-loader.o
  CC      hw/acpi/aml-build.o
  CC      hw/acpi/ipmi.o
  CC      hw/acpi/acpi-stub.o
  CC      hw/acpi/ipmi-stub.o
  CC      hw/audio/sb16.o
  CC      hw/audio/es1370.o
  CC      hw/audio/ac97.o
  CC      hw/audio/fmopl.o
  CC      hw/audio/adlib.o
  CC      hw/audio/gus.o
  CC      hw/audio/gusemu_hal.o
  CC      hw/audio/gusemu_mixer.o
  CC      hw/audio/cs4231a.o
  CC      hw/audio/intel-hda.o
  CC      hw/audio/hda-codec.o
  CC      hw/audio/pcspk.o
  CC      hw/audio/wm8750.o
  CC      hw/audio/pl041.o
  CC      hw/audio/lm4549.o
  CC      hw/audio/marvell_88w8618.o
  CC      hw/audio/soundhw.o
  CC      hw/block/cdrom.o
  CC      hw/block/block.o
  CC      hw/block/hd-geometry.o
  CC      hw/block/fdc.o
  CC      hw/block/m25p80.o
  CC      hw/block/nand.o
  CC      hw/block/pflash_cfi01.o
  CC      hw/block/pflash_cfi02.o
  CC      hw/block/xen_disk.o
  CC      hw/block/ecc.o
  CC      hw/block/onenand.o
  CC      hw/block/nvme.o
  CC      hw/bt/core.o
  CC      hw/bt/l2cap.o
  CC      hw/bt/sdp.o
  CC      hw/bt/hci.o
  CC      hw/bt/hid.o
  CC      hw/bt/hci-csr.o
  CC      hw/char/ipoctal232.o
  CC      hw/char/nrf51_uart.o
  CC      hw/char/parallel.o
  CC      hw/char/parallel-isa.o
  CC      hw/char/pl011.o
  CC      hw/char/serial.o
  CC      hw/char/serial-isa.o
  CC      hw/char/serial-pci.o
  CC      hw/char/virtio-console.o
  CC      hw/char/xen_console.o
  CC      hw/char/cadence_uart.o
  CC      hw/char/cmsdk-apb-uart.o
  CC      hw/char/debugcon.o
  CC      hw/char/imx_serial.o
  CC      hw/core/qdev.o
  CC      hw/core/qdev-properties.o
  CC      hw/core/bus.o
  CC      hw/core/reset.o
  CC      hw/core/qdev-fw.o
  CC      hw/core/fw-path-provider.o
  CC      hw/core/irq.o
  CC      hw/core/hotplug.o
  CC      hw/core/nmi.o
  CC      hw/core/stream.o
  CC      hw/core/ptimer.o
  CC      hw/core/sysbus.o
  CC      hw/core/machine.o
  CC      hw/core/loader.o
  CC      hw/core/qdev-properties-system.o
  CC      hw/core/register.o
  CC      hw/core/or-irq.o
  CC      hw/core/split-irq.o
  CC      hw/core/platform-bus.o
  CC      hw/core/generic-loader.o
  CC      hw/core/null-machine.o
  CC      hw/cpu/core.o
  CC      hw/display/ramfb.o
  CC      hw/display/ramfb-standalone.o
  CC      hw/display/ads7846.o
  CC      hw/display/cirrus_vga.o
  CC      hw/display/cirrus_vga_isa.o
  CC      hw/display/pl110.o
  CC      hw/display/sii9022.o
  CC      hw/display/ssd0303.o
  CC      hw/display/ssd0323.o
  CC      hw/display/xenfb.o
  CC      hw/display/vga-pci.o
  CC      hw/display/edid-region.o
  CC      hw/display/vga-isa.o
  CC      hw/display/vmware_vga.o
  CC      hw/display/bochs-display.o
  CC      hw/display/blizzard.o
  CC      hw/display/exynos4210_fimd.o
  CC      hw/display/framebuffer.o
  CC      hw/display/tc6393xb.o
  CC      hw/display/qxl.o
  CC      hw/display/qxl-logger.o
  CC      hw/dma/pl080.o
  CC      hw/display/qxl-render.o
  CC      hw/dma/pl330.o
  CC      hw/dma/i8257.o
  CC      hw/dma/xilinx_axidma.o
  CC      hw/dma/xlnx-zynq-devcfg.o
  CC      hw/dma/xlnx-zdma.o
  CC      hw/gpio/max7310.o
  CC      hw/gpio/pl061.o
  CC      hw/gpio/zaurus.o
  CC      hw/gpio/gpio_key.o
  CC      hw/i2c/core.o
  CC      hw/i2c/smbus.o
  CC      hw/i2c/smbus_eeprom.o
  CC      hw/i2c/i2c-ddc.o
  CC      hw/i2c/versatile_i2c.o
  CC      hw/i2c/smbus_ich9.o
  CC      hw/i2c/pm_smbus.o
  CC      hw/i2c/bitbang_i2c.o
  CC      hw/i2c/exynos4210_i2c.o
  CC      hw/i2c/imx_i2c.o
  CC      hw/i2c/aspeed_i2c.o
  CC      hw/ide/core.o
  CC      hw/ide/atapi.o
  CC      hw/ide/qdev.o
  CC      hw/ide/pci.o
  CC      hw/ide/isa.o
  CC      hw/ide/piix.o
  CC      hw/ide/microdrive.o
  CC      hw/ide/ahci.o
  CC      hw/ide/ich.o
  CC      hw/ide/ahci-allwinner.o
  CC      hw/input/hid.o
  CC      hw/input/lm832x.o
  CC      hw/input/pckbd.o
  CC      hw/input/pl050.o
  CC      hw/input/ps2.o
  CC      hw/input/stellaris_input.o
  CC      hw/input/tsc2005.o
  CC      hw/input/virtio-input.o
  CC      hw/input/virtio-input-hid.o
  CC      hw/input/virtio-input-host.o
  CC      hw/intc/i8259_common.o
  CC      hw/intc/i8259.o
  CC      hw/intc/pl190.o
  CC      hw/intc/xlnx-pmu-iomod-intc.o
  CC      hw/intc/xlnx-zynqmp-ipi.o
  CC      hw/intc/imx_avic.o
  CC      hw/intc/imx_gpcv2.o
  CC      hw/intc/realview_gic.o
  CC      hw/intc/ioapic_common.o
  CC      hw/intc/arm_gic_common.o
  CC      hw/intc/arm_gic.o
  CC      hw/intc/arm_gicv2m.o
  CC      hw/intc/arm_gicv3_common.o
  CC      hw/intc/arm_gicv3.o
  CC      hw/intc/arm_gicv3_dist.o
  CC      hw/intc/arm_gicv3_redist.o
  CC      hw/intc/arm_gicv3_its_common.o
  CC      hw/intc/intc.o
  CC      hw/ipack/ipack.o
  CC      hw/ipack/tpci200.o
  CC      hw/ipmi/ipmi.o
  CC      hw/ipmi/ipmi_bmc_sim.o
  CC      hw/ipmi/ipmi_bmc_extern.o
  CC      hw/ipmi/isa_ipmi_kcs.o
  CC      hw/ipmi/isa_ipmi_bt.o
  CC      hw/isa/isa-bus.o
  CC      hw/isa/isa-superio.o
  CC      hw/isa/apm.o
  CC      hw/mem/pc-dimm.o
  CC      hw/mem/memory-device.o
  CC      hw/mem/nvdimm.o
  CC      hw/misc/applesmc.o
  CC      hw/misc/max111x.o
  CC      hw/misc/tmp105.o
  CC      hw/misc/tmp421.o
  CC      hw/misc/debugexit.o
  CC      hw/misc/sga.o
  CC      hw/misc/pc-testdev.o
  CC      hw/misc/pci-testdev.o
  CC      hw/misc/edu.o
  CC      hw/misc/pca9552.o
  CC      hw/misc/unimp.o
  CC      hw/misc/vmcoreinfo.o
  CC      hw/misc/arm_l2x0.o
  CC      hw/misc/arm_integrator_debug.o
  CC      hw/misc/a9scu.o
  CC      hw/misc/arm11scu.o
  CC      hw/net/xen_nic.o
  CC      hw/net/ne2000.o
  CC      hw/net/eepro100.o
  CC      hw/net/pcnet-pci.o
  CC      hw/net/pcnet.o
  CC      hw/net/e1000.o
  CC      hw/net/e1000x_common.o
  CC      hw/net/net_tx_pkt.o
  CC      hw/net/net_rx_pkt.o
  CC      hw/net/e1000e.o
  CC      hw/net/e1000e_core.o
  CC      hw/net/rtl8139.o
  CC      hw/net/vmxnet3.o
  CC      hw/net/smc91c111.o
  CC      hw/net/lan9118.o
  CC      hw/net/ne2000-isa.o
  CC      hw/net/xgmac.o
  CC      hw/net/xilinx_axienet.o
  CC      hw/net/allwinner_emac.o
  CC      hw/net/imx_fec.o
  CC      hw/net/cadence_gem.o
  CC      hw/net/stellaris_enet.o
  CC      hw/net/ftgmac100.o
  CC      hw/net/rocker/rocker.o
  CC      hw/net/rocker/rocker_fp.o
  CC      hw/net/rocker/rocker_desc.o
  CC      hw/net/rocker/rocker_world.o
  CC      hw/net/rocker/rocker_of_dpa.o
  CC      hw/net/can/can_sja1000.o
  CC      hw/net/can/can_kvaser_pci.o
  CC      hw/net/can/can_pcm3680_pci.o
  CC      hw/net/can/can_mioe3680_pci.o
  CC      hw/nvram/eeprom93xx.o
  CC      hw/nvram/fw_cfg.o
  CC      hw/nvram/chrp_nvram.o
  CC      hw/pci-bridge/pci_bridge_dev.o
  CC      hw/pci-bridge/pcie_root_port.o
  CC      hw/pci-bridge/gen_pcie_root_port.o
  CC      hw/pci-bridge/pcie_pci_bridge.o
  CC      hw/pci-bridge/pci_expander_bridge.o
  CC      hw/pci-bridge/xio3130_upstream.o
  CC      hw/pci-bridge/xio3130_downstream.o
  CC      hw/pci-bridge/ioh3420.o
  CC      hw/pci-bridge/i82801b11.o
  CC      hw/pci-host/pam.o
  CC      hw/pci-host/versatile.o
  CC      hw/pci-host/piix.o
  CC      hw/pci-host/q35.o
  CC      hw/pci-host/gpex.o
  CC      hw/pci-host/designware.o
  CC      hw/pci/pci.o
  CC      hw/pci/pci_bridge.o
  CC      hw/pci/msix.o
  CC      hw/pci/msi.o
  CC      hw/pci/shpc.o
  CC      hw/pci/slotid_cap.o
  CC      hw/pci/pci_host.o
  CC      hw/pci/pcie_host.o
  CC      hw/pci/pcie.o
  CC      hw/pci/pcie_aer.o
  CC      hw/pci/pcie_port.o
  CC      hw/pci/pci-stub.o
  CC      hw/pcmcia/pcmcia.o
  CC      hw/scsi/scsi-disk.o
  CC      hw/scsi/emulation.o
  CC      hw/scsi/scsi-generic.o
  CC      hw/scsi/scsi-bus.o
  CC      hw/scsi/lsi53c895a.o
  CC      hw/scsi/mptsas.o
  CC      hw/scsi/mptconfig.o
  CC      hw/scsi/mptendian.o
  CC      hw/scsi/megasas.o
  CC      hw/scsi/vmw_pvscsi.o
  CC      hw/scsi/esp.o
  CC      hw/scsi/esp-pci.o
  CC      hw/sd/pl181.o
  CC      hw/sd/ssi-sd.o
  CC      hw/sd/sd.o
  CC      hw/sd/core.o
  CC      hw/sd/sdmmc-internal.o
  CC      hw/sd/sdhci.o
  CC      hw/smbios/smbios.o
  CC      hw/smbios/smbios_type_38.o
  CC      hw/smbios/smbios-stub.o
  CC      hw/smbios/smbios_type_38-stub.o
  CC      hw/ssi/pl022.o
  CC      hw/ssi/ssi.o
  CC      hw/ssi/xilinx_spips.o
  CC      hw/ssi/aspeed_smc.o
  CC      hw/ssi/stm32f2xx_spi.o
  CC      hw/ssi/mss-spi.o
  CC      hw/timer/arm_timer.o
  CC      hw/timer/arm_mptimer.o
  CC      hw/timer/armv7m_systick.o
  CC      hw/timer/a9gtimer.o
  CC      hw/timer/cadence_ttc.o
  CC      hw/timer/ds1338.o
  CC      hw/timer/hpet.o
  CC      hw/timer/i8254_common.o
  CC      hw/timer/i8254.o
  CC      hw/timer/pl031.o
  CC      hw/timer/twl92230.o
  CC      hw/timer/imx_epit.o
  CC      hw/timer/imx_gpt.o
  CC      hw/timer/xlnx-zynqmp-rtc.o
  CC      hw/timer/stm32f2xx_timer.o
  CC      hw/timer/aspeed_timer.o
  CC      hw/timer/cmsdk-apb-timer.o
  CC      hw/timer/cmsdk-apb-dualtimer.o
  CC      hw/timer/mss-timer.o
  CC      hw/tpm/tpm_util.o
  CC      hw/tpm/tpm_tis.o
  CC      hw/tpm/tpm_crb.o
  CC      hw/tpm/tpm_passthrough.o
  CC      hw/tpm/tpm_emulator.o
  CC      hw/usb/core.o
  CC      hw/usb/combined-packet.o
  CC      hw/usb/bus.o
  CC      hw/usb/libhw.o
  CC      hw/usb/desc.o
  CC      hw/usb/desc-msos.o
  CC      hw/usb/hcd-uhci.o
  CC      hw/usb/hcd-ohci.o
  CC      hw/usb/hcd-ehci.o
  CC      hw/usb/hcd-ehci-pci.o
  CC      hw/usb/hcd-ehci-sysbus.o
  CC      hw/usb/hcd-xhci.o
  CC      hw/usb/hcd-xhci-nec.o
  CC      hw/usb/hcd-musb.o
  CC      hw/usb/dev-hub.o
  CC      hw/usb/dev-hid.o
  CC      hw/usb/dev-wacom.o
  CC      hw/usb/dev-storage.o
  CC      hw/usb/dev-uas.o
  CC      hw/usb/dev-audio.o
  CC      hw/usb/dev-serial.o
  CC      hw/usb/dev-network.o
  CC      hw/usb/dev-bluetooth.o
  CC      hw/usb/dev-smartcard-reader.o
  CC      hw/usb/ccid-card-passthru.o
  CC      hw/usb/ccid-card-emulated.o
  CC      hw/usb/dev-mtp.o
  CC      hw/usb/host-stub.o
  CC      hw/virtio/virtio-bus.o
  CC      hw/virtio/virtio-rng.o
  CC      hw/virtio/virtio-pci.o
  CC      hw/virtio/virtio-mmio.o
  CC      hw/virtio/vhost-stub.o
  CC      hw/watchdog/watchdog.o
  CC      hw/watchdog/cmsdk-apb-watchdog.o
  CC      hw/watchdog/wdt_i6300esb.o
  CC      hw/watchdog/wdt_ib700.o
  CC      hw/watchdog/wdt_aspeed.o
  CC      hw/xen/xen_backend.o
  CC      hw/xen/xen_devconfig.o
  CC      hw/xen/xen_pvdev.o
  CC      hw/xen/xen-common.o
  CC      migration/migration.o
  CC      migration/socket.o
  CC      migration/fd.o
  CC      migration/exec.o
  CC      migration/tls.o
  CC      migration/channel.o
  CC      migration/savevm.o
  CC      migration/colo.o
  CC      migration/colo-failover.o
  CC      migration/vmstate.o
  CC      migration/vmstate-types.o
  CC      migration/page_cache.o
  CC      migration/qemu-file.o
  CC      migration/global_state.o
  CC      migration/qemu-file-channel.o
  CC      migration/xbzrle.o
  CC      migration/postcopy-ram.o
  CC      migration/qjson.o
  CC      migration/block-dirty-bitmap.o
  CC      migration/rdma.o
  CC      migration/block.o
  CC      net/net.o
  CC      net/queue.o
  CC      net/checksum.o
  CC      net/util.o
  CC      net/hub.o
  CC      net/socket.o
  CC      net/dump.o
  CC      net/eth.o
  CC      net/l2tpv3.o
  CC      net/vhost-user.o
  CC      net/slirp.o
  CC      net/filter.o
  CC      net/filter-buffer.o
  CC      net/filter-mirror.o
  CC      net/colo-compare.o
  CC      net/colo.o
  CC      net/filter-rewriter.o
  CC      net/filter-replay.o
  CC      net/tap.o
  CC      net/tap-linux.o
  CC      net/can/can_core.o
  CC      net/can/can_host.o
  CC      net/can/can_socketcan.o
  CC      qom/cpu.o
  CC      replay/replay.o
  CC      replay/replay-internal.o
  CC      replay/replay-events.o
  CC      replay/replay-time.o
  CC      replay/replay-input.o
  CC      replay/replay-char.o
  CC      replay/replay-snapshot.o
  CC      replay/replay-net.o
  CC      replay/replay-audio.o
  CC      slirp/cksum.o
  CC      slirp/if.o
  CC      slirp/ip_icmp.o
  CC      slirp/ip6_icmp.o
  CC      slirp/ip6_input.o
  CC      slirp/ip6_output.o
  CC      slirp/ip_input.o
  CC      slirp/ip_output.o
  CC      slirp/dnssearch.o
  CC      slirp/dhcpv6.o
  CC      slirp/slirp.o
  CC      slirp/mbuf.o
  CC      slirp/misc.o
  CC      slirp/sbuf.o
  CC      slirp/socket.o
  CC      slirp/tcp_input.o
  CC      slirp/tcp_output.o
  CC      slirp/tcp_subr.o
  CC      slirp/tcp_timer.o
  CC      slirp/udp.o
  CC      slirp/udp6.o
  CC      slirp/bootp.o
  CC      slirp/tftp.o
  CC      slirp/arp_table.o
  CC      slirp/ndp_table.o
  CC      slirp/ncsi.o
  CC      ui/keymaps.o
  CC      ui/console.o
  CC      ui/cursor.o
  CC      ui/qemu-pixman.o
  CC      ui/input.o
  CC      ui/input-keymap.o
  CC      ui/input-legacy.o
  CC      ui/input-linux.o
  CC      ui/spice-core.o
  CC      ui/spice-input.o
  CC      ui/spice-display.o
  CC      ui/vnc.o
  CC      ui/vnc-enc-zlib.o
  CC      ui/vnc-enc-hextile.o
  CC      ui/vnc-enc-tight.o
  CC      ui/vnc-palette.o
  CC      ui/vnc-enc-zrle.o
  CC      ui/vnc-auth-vencrypt.o
  CC      ui/vnc-ws.o
  CC      ui/vnc-jobs.o
  VERT    ui/shader/texture-blit-vert.h
  VERT    ui/shader/texture-blit-flip-vert.h
  FRAG    ui/shader/texture-blit-frag.h
  CC      ui/console-gl.o
  CC      ui/egl-helpers.o
  CC      ui/egl-context.o
  CC      ui/egl-headless.o
  CC      audio/ossaudio.o
  CC      ui/sdl.o
  CC      ui/sdl_zoom.o
  CC      ui/x_keymap.o
  CC      ui/curses.o
  CC      chardev/char.o
  CC      chardev/char-fd.o
  CC      chardev/char-fe.o
  CC      chardev/char-file.o
  CC      chardev/char-io.o
  CC      chardev/char-mux.o
  CC      chardev/char-null.o
  CC      chardev/char-parallel.o
  CC      chardev/char-pipe.o
  CC      chardev/char-pty.o
  CC      chardev/char-ringbuf.o
  CC      chardev/char-serial.o
  CC      chardev/char-socket.o
  CC      chardev/char-stdio.o
  CC      chardev/char-udp.o
  LINK    tests/qemu-iotests/socket_scm_helper
  CC      qga/commands.o
  CC      qga/guest-agent-command-state.o
  CC      qga/main.o
  CC      qga/commands-posix.o
  CC      qga/channel-posix.o
  CC      qga/qapi-generated/qga-qapi-types.o
  CC      qga/qapi-generated/qga-qapi-visit.o
  CC      qga/qapi-generated/qga-qapi-commands.o
  CC      qemu-img.o
  AR      libqemuutil.a
  AS      optionrom/multiboot.o
  CC      ui/shader.o
  AS      optionrom/linuxboot.o
  AS      optionrom/kvmvapic.o
  CC      optionrom/linuxboot_dma.o
  BUILD   optionrom/multiboot.img
  BUILD   optionrom/linuxboot_dma.img
  BUILD   optionrom/multiboot.raw
  BUILD   optionrom/linuxboot.img
  BUILD   optionrom/linuxboot_dma.raw
  SIGN    optionrom/multiboot.bin
  BUILD   optionrom/kvmvapic.img
  BUILD   optionrom/linuxboot.raw
  SIGN    optionrom/linuxboot_dma.bin
  BUILD   optionrom/kvmvapic.raw
  SIGN    optionrom/linuxboot.bin
  SIGN    optionrom/kvmvapic.bin
  LINK    qemu-ga
  LINK    ivshmem-client
  LINK    ivshmem-server
  LINK    qemu-nbd
  LINK    qemu-io
  LINK    qemu-edid
  LINK    scsi/qemu-pr-helper
  LINK    qemu-bridge-helper
  GEN     x86_64-softmmu/hmp-commands.h
  GEN     x86_64-softmmu/hmp-commands-info.h
  GEN     x86_64-softmmu/config-target.h
  CC      x86_64-softmmu/tcg/tcg-op.o
  CC      x86_64-softmmu/exec.o
  CC      x86_64-softmmu/tcg/tcg.o
  CC      x86_64-softmmu/tcg/tcg-op-vec.o
  CC      x86_64-softmmu/tcg/tcg-op-gvec.o
  CC      x86_64-softmmu/tcg/tcg-common.o
  GEN     aarch64-softmmu/hmp-commands.h
  GEN     aarch64-softmmu/hmp-commands-info.h
  GEN     aarch64-softmmu/config-target.h
  CC      aarch64-softmmu/exec.o
  CC      x86_64-softmmu/tcg/optimize.o
  CC      aarch64-softmmu/tcg/tcg.o
  CC      x86_64-softmmu/fpu/softfloat.o
  CC      x86_64-softmmu/disas.o
  GEN     x86_64-softmmu/gdbstub-xml.c
  CC      x86_64-softmmu/arch_init.o
  CC      x86_64-softmmu/cpus.o
  CC      x86_64-softmmu/monitor.o
  CC      x86_64-softmmu/gdbstub.o
  LINK    qemu-img
  CC      aarch64-softmmu/tcg/tcg-op.o
  CC      aarch64-softmmu/tcg/tcg-op-vec.o
  CC      aarch64-softmmu/tcg/tcg-op-gvec.o
  CC      aarch64-softmmu/tcg/tcg-common.o
  CC      x86_64-softmmu/balloon.o
  CC      x86_64-softmmu/ioport.o
  CC      aarch64-softmmu/tcg/optimize.o
  CC      aarch64-softmmu/fpu/softfloat.o
  CC      x86_64-softmmu/numa.o
  CC      x86_64-softmmu/qtest.o
  CC      aarch64-softmmu/disas.o
  GEN     aarch64-softmmu/gdbstub-xml.c
  CC      x86_64-softmmu/memory.o
  CC      aarch64-softmmu/arch_init.o
  CC      x86_64-softmmu/memory_mapping.o
  CC      x86_64-softmmu/dump.o
  CC      x86_64-softmmu/win_dump.o
  CC      aarch64-softmmu/cpus.o
  CC      x86_64-softmmu/migration/ram.o
  CC      aarch64-softmmu/monitor.o
  CC      aarch64-softmmu/gdbstub.o
  CC      x86_64-softmmu/windbgstub.o
  CC      aarch64-softmmu/balloon.o
  CC      x86_64-softmmu/windbgstub-utils.o
  CC      x86_64-softmmu/accel/accel.o
  CC      x86_64-softmmu/accel/kvm/kvm-all.o
  CC      aarch64-softmmu/ioport.o
  CC      aarch64-softmmu/numa.o
  CC      x86_64-softmmu/accel/stubs/hax-stub.o
  CC      aarch64-softmmu/qtest.o
  CC      x86_64-softmmu/accel/stubs/hvf-stub.o
  CC      x86_64-softmmu/accel/stubs/whpx-stub.o
  CC      x86_64-softmmu/accel/tcg/tcg-all.o
  CC      x86_64-softmmu/accel/tcg/cputlb.o
  CC      x86_64-softmmu/accel/tcg/tcg-runtime.o
  CC      aarch64-softmmu/memory.o
  CC      aarch64-softmmu/memory_mapping.o
  CC      aarch64-softmmu/dump.o
  CC      aarch64-softmmu/migration/ram.o
  CC      x86_64-softmmu/accel/tcg/tcg-runtime-gvec.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec.o
  CC      x86_64-softmmu/accel/tcg/cpu-exec-common.o
  CC      x86_64-softmmu/accel/tcg/translate-all.o
  CC      x86_64-softmmu/accel/tcg/translator.o
  CC      x86_64-softmmu/hw/block/virtio-blk.o
  CC      aarch64-softmmu/accel/accel.o
  CC      x86_64-softmmu/hw/block/vhost-user-blk.o
  CC      x86_64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      aarch64-softmmu/accel/stubs/hax-stub.o
  CC      aarch64-softmmu/accel/stubs/hvf-stub.o
  CC      aarch64-softmmu/accel/stubs/whpx-stub.o
  CC      aarch64-softmmu/accel/stubs/kvm-stub.o
  CC      aarch64-softmmu/accel/tcg/tcg-all.o
  CC      aarch64-softmmu/accel/tcg/cputlb.o
  CC      aarch64-softmmu/accel/tcg/tcg-runtime.o
  CC      aarch64-softmmu/accel/tcg/tcg-runtime-gvec.o
  CC      x86_64-softmmu/hw/char/virtio-serial-bus.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec.o
  CC      x86_64-softmmu/hw/display/vga.o
  CC      x86_64-softmmu/hw/display/virtio-gpu.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-3d.o
  CC      x86_64-softmmu/hw/display/virtio-gpu-pci.o
  CC      x86_64-softmmu/hw/display/virtio-vga.o
  CC      x86_64-softmmu/hw/hyperv/hyperv.o
  CC      aarch64-softmmu/accel/tcg/cpu-exec-common.o
  CC      x86_64-softmmu/hw/hyperv/hyperv_testdev.o
  CC      aarch64-softmmu/accel/tcg/translate-all.o
  CC      aarch64-softmmu/accel/tcg/translator.o
  CC      aarch64-softmmu/hw/adc/stm32f2xx_adc.o
  CC      x86_64-softmmu/hw/intc/apic.o
  CC      aarch64-softmmu/hw/block/virtio-blk.o
  CC      x86_64-softmmu/hw/intc/apic_common.o
  CC      x86_64-softmmu/hw/intc/ioapic.o
  CC      x86_64-softmmu/hw/isa/lpc_ich9.o
  CC      aarch64-softmmu/hw/block/vhost-user-blk.o
  CC      x86_64-softmmu/hw/misc/ivshmem.o
  CC      aarch64-softmmu/hw/block/dataplane/virtio-blk.o
  CC      x86_64-softmmu/hw/misc/pvpanic.o
  CC      aarch64-softmmu/hw/char/exynos4210_uart.o
  CC      x86_64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/hw/net/vhost_net.o
  CC      x86_64-softmmu/hw/rdma/rdma_utils.o
  CC      x86_64-softmmu/hw/rdma/rdma_backend.o
  CC      x86_64-softmmu/hw/rdma/rdma_rm.o
  CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_dev_ring.o
  CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_cmd.o
  CC      aarch64-softmmu/hw/char/omap_uart.o
  CC      aarch64-softmmu/hw/char/digic-uart.o
  CC      aarch64-softmmu/hw/char/stm32f2xx_usart.o
  CC      aarch64-softmmu/hw/char/bcm2835_aux.o
  CC      aarch64-softmmu/hw/char/virtio-serial-bus.o
  CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_qp_ops.o
  CC      x86_64-softmmu/hw/rdma/vmw/pvrdma_main.o
  CC      aarch64-softmmu/hw/cpu/arm11mpcore.o
  CC      aarch64-softmmu/hw/cpu/realview_mpcore.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi.o
  CC      x86_64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      aarch64-softmmu/hw/cpu/a9mpcore.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      x86_64-softmmu/hw/scsi/vhost-scsi.o
  CC      aarch64-softmmu/hw/cpu/a15mpcore.o
  CC      aarch64-softmmu/hw/display/omap_dss.o
  CC      x86_64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      x86_64-softmmu/hw/timer/mc146818rtc.o
  CC      x86_64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/display/omap_lcdc.o
  CC      aarch64-softmmu/hw/display/pxa2xx_lcd.o
  CC      aarch64-softmmu/hw/display/bcm2835_fb.o
  CC      aarch64-softmmu/hw/display/vga.o
  CC      aarch64-softmmu/hw/display/virtio-gpu.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-3d.o
  CC      aarch64-softmmu/hw/display/virtio-gpu-pci.o
  CC      x86_64-softmmu/hw/vfio/pci.o
  CC      aarch64-softmmu/hw/display/dpcd.o
  CC      aarch64-softmmu/hw/display/xlnx_dp.o
  CC      aarch64-softmmu/hw/dma/xlnx_dpdma.o
  CC      aarch64-softmmu/hw/dma/omap_dma.o
  CC      aarch64-softmmu/hw/dma/soc_dma.o
  CC      aarch64-softmmu/hw/dma/pxa2xx_dma.o
  CC      aarch64-softmmu/hw/dma/bcm2835_dma.o
  CC      x86_64-softmmu/hw/vfio/pci-quirks.o
  CC      x86_64-softmmu/hw/vfio/display.o
  CC      x86_64-softmmu/hw/vfio/platform.o
  CC      aarch64-softmmu/hw/gpio/omap_gpio.o
  CC      aarch64-softmmu/hw/gpio/imx_gpio.o
  CC      aarch64-softmmu/hw/gpio/bcm2835_gpio.o
  CC      aarch64-softmmu/hw/i2c/omap_i2c.o
  CC      aarch64-softmmu/hw/input/pxa2xx_keypad.o
  CC      aarch64-softmmu/hw/input/tsc210x.o
  CC      aarch64-softmmu/hw/intc/armv7m_nvic.o
  CC      aarch64-softmmu/hw/intc/exynos4210_gic.o
  CC      aarch64-softmmu/hw/intc/exynos4210_combiner.o
  CC      aarch64-softmmu/hw/intc/omap_intc.o
  CC      aarch64-softmmu/hw/intc/bcm2835_ic.o
  CC      aarch64-softmmu/hw/intc/bcm2836_control.o
  CC      aarch64-softmmu/hw/intc/allwinner-a10-pic.o
  CC      aarch64-softmmu/hw/intc/aspeed_vic.o
  CC      aarch64-softmmu/hw/intc/arm_gicv3_cpuif.o
  CC      x86_64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/misc/ivshmem.o
  CC      aarch64-softmmu/hw/misc/arm_sysctl.o
  CC      x86_64-softmmu/hw/virtio/virtio.o
  CC      aarch64-softmmu/hw/misc/cbus.o
  CC      x86_64-softmmu/hw/virtio/virtio-balloon.o
  CC      aarch64-softmmu/hw/misc/exynos4210_pmu.o
  CC      aarch64-softmmu/hw/misc/exynos4210_clk.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto.o
  CC      x86_64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      x86_64-softmmu/hw/virtio/vhost.o
  CC      aarch64-softmmu/hw/misc/exynos4210_rng.o
  CC      x86_64-softmmu/hw/virtio/vhost-backend.o
  CC      x86_64-softmmu/hw/virtio/vhost-user.o
  CC      aarch64-softmmu/hw/misc/imx_ccm.o
  CC      aarch64-softmmu/hw/misc/imx31_ccm.o
  CC      aarch64-softmmu/hw/misc/imx25_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6ul_ccm.o
  CC      aarch64-softmmu/hw/misc/imx6_src.o
  CC      aarch64-softmmu/hw/misc/imx7_ccm.o
  CC      aarch64-softmmu/hw/misc/imx2_wdt.o
  CC      x86_64-softmmu/hw/virtio/vhost-vsock.o
  CC      x86_64-softmmu/hw/xen/xen-host-pci-device.o
  CC      x86_64-softmmu/hw/xen/xen_pt.o
  CC      aarch64-softmmu/hw/misc/imx7_snvs.o
  CC      x86_64-softmmu/hw/xen/xen_pt_config_init.o
  CC      x86_64-softmmu/hw/xen/xen_pt_graphics.o
  CC      aarch64-softmmu/hw/misc/imx7_gpr.o
  CC      aarch64-softmmu/hw/misc/mst_fpga.o
  CC      aarch64-softmmu/hw/misc/omap_clk.o
  CC      aarch64-softmmu/hw/misc/omap_gpmc.o
  CC      aarch64-softmmu/hw/misc/omap_l4.o
  CC      aarch64-softmmu/hw/misc/omap_sdrc.o
  CC      aarch64-softmmu/hw/misc/omap_tap.o
  CC      aarch64-softmmu/hw/misc/bcm2835_mbox.o
  CC      aarch64-softmmu/hw/misc/bcm2835_property.o
  CC      aarch64-softmmu/hw/misc/bcm2835_rng.o
  CC      x86_64-softmmu/hw/xen/xen_pt_msi.o
  CC      aarch64-softmmu/hw/misc/zynq_slcr.o
  CC      aarch64-softmmu/hw/misc/zynq-xadc.o
  CC      x86_64-softmmu/hw/xen/xen_pt_load_rom.o
  CC      aarch64-softmmu/hw/misc/stm32f2xx_syscfg.o
  CC      aarch64-softmmu/hw/misc/mps2-fpgaio.o
  CC      aarch64-softmmu/hw/misc/mps2-scc.o
  CC      aarch64-softmmu/hw/misc/tz-mpc.o
  CC      aarch64-softmmu/hw/misc/tz-msc.o
  CC      x86_64-softmmu/hw/i386/multiboot.o
  CC      x86_64-softmmu/hw/i386/pc.o
  CC      x86_64-softmmu/hw/i386/pc_piix.o
  CC      x86_64-softmmu/hw/i386/pc_q35.o
  CC      aarch64-softmmu/hw/misc/tz-ppc.o
  CC      x86_64-softmmu/hw/i386/pc_sysfw.o
  CC      aarch64-softmmu/hw/misc/iotkit-secctl.o
  CC      x86_64-softmmu/hw/i386/x86-iommu.o
  CC      aarch64-softmmu/hw/misc/iotkit-sysctl.o
  CC      aarch64-softmmu/hw/misc/iotkit-sysinfo.o
  CC      x86_64-softmmu/hw/i386/intel_iommu.o
  CC      aarch64-softmmu/hw/misc/auxbus.o
  CC      aarch64-softmmu/hw/misc/aspeed_scu.o
  CC      x86_64-softmmu/hw/i386/amd_iommu.o
  CC      aarch64-softmmu/hw/misc/aspeed_sdmc.o
  CC      aarch64-softmmu/hw/misc/msf2-sysreg.o
  CC      aarch64-softmmu/hw/net/virtio-net.o
  CC      x86_64-softmmu/hw/i386/vmport.o
  CC      aarch64-softmmu/hw/net/vhost_net.o
  CC      aarch64-softmmu/hw/pcmcia/pxa2xx.o
  CC      aarch64-softmmu/hw/rdma/rdma_utils.o
  CC      aarch64-softmmu/hw/rdma/rdma_backend.o
  CC      aarch64-softmmu/hw/rdma/rdma_rm.o
  CC      aarch64-softmmu/hw/rdma/vmw/pvrdma_dev_ring.o
  CC      aarch64-softmmu/hw/rdma/vmw/pvrdma_cmd.o
  CC      aarch64-softmmu/hw/rdma/vmw/pvrdma_qp_ops.o
  CC      aarch64-softmmu/hw/rdma/vmw/pvrdma_main.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi.o
  CC      aarch64-softmmu/hw/scsi/virtio-scsi-dataplane.o
  CC      x86_64-softmmu/hw/i386/vmmouse.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi-common.o
  CC      aarch64-softmmu/hw/scsi/vhost-scsi.o
  CC      aarch64-softmmu/hw/scsi/vhost-user-scsi.o
  CC      x86_64-softmmu/hw/i386/kvmvapic.o
  CC      x86_64-softmmu/hw/i386/acpi-build.o
  CC      x86_64-softmmu/hw/i386/../xenpv/xen_machine_pv.o
  CC      x86_64-softmmu/hw/i386/kvm/clock.o
  CC      aarch64-softmmu/hw/sd/omap_mmc.o
  CC      aarch64-softmmu/hw/sd/pxa2xx_mmci.o
  CC      aarch64-softmmu/hw/sd/bcm2835_sdhost.o
  CC      aarch64-softmmu/hw/ssi/omap_spi.o
  CC      aarch64-softmmu/hw/ssi/imx_spi.o
  CC      aarch64-softmmu/hw/timer/exynos4210_mct.o
  CC      aarch64-softmmu/hw/timer/exynos4210_pwm.o
  CC      x86_64-softmmu/hw/i386/kvm/apic.o
  CC      aarch64-softmmu/hw/timer/exynos4210_rtc.o
  CC      x86_64-softmmu/hw/i386/kvm/i8259.o
  CC      aarch64-softmmu/hw/timer/omap_gptimer.o
  CC      x86_64-softmmu/hw/i386/kvm/ioapic.o
  CC      x86_64-softmmu/hw/i386/kvm/i8254.o
  CC      aarch64-softmmu/hw/timer/omap_synctimer.o
  CC      aarch64-softmmu/hw/timer/pxa2xx_timer.o
  CC      x86_64-softmmu/hw/i386/xen/xen_platform.o
  CC      aarch64-softmmu/hw/timer/digic-timer.o
  CC      x86_64-softmmu/hw/i386/xen/xen_apic.o
  CC      x86_64-softmmu/hw/i386/xen/xen_pvdevice.o
  CC      x86_64-softmmu/hw/i386/xen/xen-hvm.o
  CC      x86_64-softmmu/hw/i386/xen/xen-mapcache.o
  CC      x86_64-softmmu/target/i386/helper.o
  CC      x86_64-softmmu/target/i386/cpu.o
  CC      aarch64-softmmu/hw/timer/allwinner-a10-pit.o
  CC      x86_64-softmmu/target/i386/gdbstub.o
  CC      aarch64-softmmu/hw/usb/tusb6010.o
  CC      aarch64-softmmu/hw/usb/chipidea.o
  CC      aarch64-softmmu/hw/vfio/common.o
  CC      aarch64-softmmu/hw/vfio/pci.o
  CC      x86_64-softmmu/target/i386/xsave_helper.o
  CC      aarch64-softmmu/hw/vfio/pci-quirks.o
  CC      x86_64-softmmu/target/i386/translate.o
  CC      x86_64-softmmu/target/i386/bpt_helper.o
  CC      x86_64-softmmu/target/i386/cc_helper.o
  CC      x86_64-softmmu/target/i386/excp_helper.o
  CC      x86_64-softmmu/target/i386/fpu_helper.o
  CC      aarch64-softmmu/hw/vfio/display.o
  CC      aarch64-softmmu/hw/vfio/platform.o
  CC      x86_64-softmmu/target/i386/int_helper.o
  CC      aarch64-softmmu/hw/vfio/calxeda-xgmac.o
  CC      aarch64-softmmu/hw/vfio/amd-xgbe.o
  CC      aarch64-softmmu/hw/vfio/spapr.o
  CC      aarch64-softmmu/hw/virtio/virtio.o
  CC      x86_64-softmmu/target/i386/mem_helper.o
  CC      aarch64-softmmu/hw/virtio/virtio-balloon.o
  CC      x86_64-softmmu/target/i386/misc_helper.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto.o
  CC      x86_64-softmmu/target/i386/mpx_helper.o
  CC      aarch64-softmmu/hw/virtio/virtio-crypto-pci.o
  CC      aarch64-softmmu/hw/virtio/vhost.o
  CC      x86_64-softmmu/target/i386/seg_helper.o
  CC      aarch64-softmmu/hw/virtio/vhost-backend.o
  CC      x86_64-softmmu/target/i386/smm_helper.o
  CC      aarch64-softmmu/hw/virtio/vhost-user.o
  CC      x86_64-softmmu/target/i386/svm_helper.o
  CC      aarch64-softmmu/hw/virtio/vhost-vsock.o
  CC      aarch64-softmmu/hw/arm/boot.o
  CC      aarch64-softmmu/hw/arm/virt.o
  CC      aarch64-softmmu/hw/arm/sysbus-fdt.o
  CC      aarch64-softmmu/hw/arm/virt-acpi-build.o
  CC      x86_64-softmmu/target/i386/machine.o
  CC      x86_64-softmmu/target/i386/arch_memory_mapping.o
  CC      x86_64-softmmu/target/i386/arch_dump.o
  CC      x86_64-softmmu/target/i386/monitor.o
  CC      aarch64-softmmu/hw/arm/digic_boards.o
  CC      aarch64-softmmu/hw/arm/exynos4_boards.o
  CC      aarch64-softmmu/hw/arm/highbank.o
  CC      aarch64-softmmu/hw/arm/integratorcp.o
  CC      x86_64-softmmu/target/i386/kvm.o
  CC      x86_64-softmmu/target/i386/hyperv.o
  CC      x86_64-softmmu/target/i386/sev.o
  CC      aarch64-softmmu/hw/arm/mainstone.o
  CC      aarch64-softmmu/hw/arm/musicpal.o
  CC      aarch64-softmmu/hw/arm/netduino2.o
  CC      aarch64-softmmu/hw/arm/nseries.o
  CC      aarch64-softmmu/hw/arm/omap_sx1.o
  CC      x86_64-softmmu/target/i386/windbgstub.o
  CC      aarch64-softmmu/hw/arm/palm.o
  GEN     trace/generated-helpers.c
  CC      x86_64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/hw/arm/gumstix.o
  CC      aarch64-softmmu/hw/arm/spitz.o
/tmp/qemu-test/src/target/i386/windbgstub.c: In function 'windbg_read_context':
/tmp/qemu-test/src/target/i386/windbgstub.c:569:29: error: 'CONTEXT_CONTROL' undeclared (first use in this function)
             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/tmp/qemu-test/src/target/i386/windbgstub.c:391:9: note: in definition of macro 'CASE_FIELD'
         block;                                                                 \
         ^
/tmp/qemu-test/src/target/i386/windbgstub.c:568:9: note: in expansion of macro 'CASE_FIELD_X32_64'
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^

/tmp/qemu-test/src/target/i386/windbgstub.c:890:1: note: in expansion of macro 'GEN_WINDBG_CONTEXT_RW'
GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
^
/tmp/qemu-test/src/target/i386/windbgstub.c:569:29: note: each undeclared identifier is reported only once for each function it appears in

             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/tmp/qemu-test/src/target/i386/windbgstub.c:391:9: note: in definition of macro 'CASE_FIELD'
         block;                                                                 \
         ^
/tmp/qemu-test/src/target/i386/windbgstub.c:568:9: note: in expansion of macro 'CASE_FIELD_X32_64'
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^

/tmp/qemu-test/src/target/i386/windbgstub.c:890:1: note: in expansion of macro 'GEN_WINDBG_CONTEXT_RW'
GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
^
/tmp/qemu-test/src/target/i386/windbgstub.c: In function 'windbg_write_context':
/tmp/qemu-test/src/target/i386/windbgstub.c:569:29: error: 'CONTEXT_CONTROL' undeclared (first use in this function)

             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/tmp/qemu-test/src/target/i386/windbgstub.c:391:9: note: in definition of macro 'CASE_FIELD'
         block;                                                                 \
         ^
/tmp/qemu-test/src/target/i386/windbgstub.c:568:9: note: in expansion of macro 'CASE_FIELD_X32_64'
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^

/tmp/qemu-test/src/target/i386/windbgstub.c:891:1: note: in expansion of macro 'GEN_WINDBG_CONTEXT_RW'
GEN_WINDBG_CONTEXT_RW(windbg_write_context, true)
^
make[1]: *** [target/i386/windbgstub.o] Error 1
make[1]: *** Waiting for unfinished jobs....

  CC      aarch64-softmmu/hw/arm/tosa.o
  CC      aarch64-softmmu/hw/arm/z2.o
  CC      aarch64-softmmu/hw/arm/realview.o
  CC      aarch64-softmmu/hw/arm/stellaris.o
  CC      aarch64-softmmu/hw/arm/collie.o
  CC      aarch64-softmmu/hw/arm/vexpress.o
  CC      aarch64-softmmu/hw/arm/versatilepb.o
  CC      aarch64-softmmu/hw/arm/xilinx_zynq.o
  CC      aarch64-softmmu/hw/arm/armv7m.o
  CC      aarch64-softmmu/hw/arm/exynos4210.o
  CC      aarch64-softmmu/hw/arm/pxa2xx.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_gpio.o
  CC      aarch64-softmmu/hw/arm/pxa2xx_pic.o
  CC      aarch64-softmmu/hw/arm/digic.o
  CC      aarch64-softmmu/hw/arm/omap1.o
  CC      aarch64-softmmu/hw/arm/omap2.o
  CC      aarch64-softmmu/hw/arm/strongarm.o
  CC      aarch64-softmmu/hw/arm/allwinner-a10.o
  CC      aarch64-softmmu/hw/arm/cubieboard.o
  CC      aarch64-softmmu/hw/arm/bcm2835_peripherals.o
  CC      aarch64-softmmu/hw/arm/bcm2836.o
  CC      aarch64-softmmu/hw/arm/raspi.o
  CC      aarch64-softmmu/hw/arm/stm32f205_soc.o
  CC      aarch64-softmmu/hw/arm/xlnx-zynqmp.o
  CC      aarch64-softmmu/hw/arm/xlnx-zcu102.o
  CC      aarch64-softmmu/hw/arm/xlnx-versal.o
  CC      aarch64-softmmu/hw/arm/xlnx-versal-virt.o
  CC      aarch64-softmmu/hw/arm/fsl-imx25.o
  CC      aarch64-softmmu/hw/arm/imx25_pdk.o
  CC      aarch64-softmmu/hw/arm/fsl-imx31.o
  CC      aarch64-softmmu/hw/arm/kzm.o
  CC      aarch64-softmmu/hw/arm/fsl-imx6.o
  CC      aarch64-softmmu/hw/arm/sabrelite.o
  CC      aarch64-softmmu/hw/arm/aspeed_soc.o
  CC      aarch64-softmmu/hw/arm/aspeed.o
  CC      aarch64-softmmu/hw/arm/mps2.o
  CC      aarch64-softmmu/hw/arm/mps2-tz.o
make: *** [subdir-x86_64-softmmu] Error 2
make: *** Waiting for unfinished jobs....
  CC      aarch64-softmmu/hw/arm/msf2-soc.o
  CC      aarch64-softmmu/hw/arm/msf2-som.o
  CC      aarch64-softmmu/hw/arm/iotkit.o
  CC      aarch64-softmmu/hw/arm/fsl-imx7.o
  CC      aarch64-softmmu/hw/arm/mcimx7d-sabre.o
  CC      aarch64-softmmu/hw/arm/smmu-common.o
  CC      aarch64-softmmu/hw/arm/smmuv3.o
  CC      aarch64-softmmu/hw/arm/fsl-imx6ul.o
  CC      aarch64-softmmu/hw/arm/mcimx6ul-evk.o
  CC      aarch64-softmmu/hw/arm/nrf51_soc.o
  CC      aarch64-softmmu/hw/arm/microbit.o
  CC      aarch64-softmmu/target/arm/arm-semi.o
  CC      aarch64-softmmu/target/arm/machine.o
  CC      aarch64-softmmu/target/arm/psci.o
  CC      aarch64-softmmu/target/arm/arch_dump.o
  CC      aarch64-softmmu/target/arm/monitor.o
  CC      aarch64-softmmu/target/arm/kvm-stub.o
  CC      aarch64-softmmu/target/arm/translate.o
  CC      aarch64-softmmu/target/arm/op_helper.o
  CC      aarch64-softmmu/target/arm/helper.o
  CC      aarch64-softmmu/target/arm/cpu.o
  CC      aarch64-softmmu/target/arm/neon_helper.o
  CC      aarch64-softmmu/target/arm/iwmmxt_helper.o
  CC      aarch64-softmmu/target/arm/vec_helper.o
  CC      aarch64-softmmu/target/arm/gdbstub.o
  CC      aarch64-softmmu/target/arm/cpu64.o
  CC      aarch64-softmmu/target/arm/translate-a64.o
  CC      aarch64-softmmu/target/arm/helper-a64.o
  CC      aarch64-softmmu/target/arm/gdbstub64.o
  CC      aarch64-softmmu/target/arm/crypto_helper.o
  CC      aarch64-softmmu/target/arm/arm-powerctl.o
  GEN     aarch64-softmmu/target/arm/decode-sve.inc.c
  CC      aarch64-softmmu/target/arm/sve_helper.o
  GEN     trace/generated-helpers.c
  CC      aarch64-softmmu/trace/control-target.o
  CC      aarch64-softmmu/gdbstub-xml.o
  CC      aarch64-softmmu/target/arm/translate-sve.o
  CC      aarch64-softmmu/trace/generated-helpers.o
  LINK    aarch64-softmmu/qemu-system-aarch64
Traceback (most recent call last):
  File "./tests/docker/docker.py", line 563, in <module>
    sys.exit(main())

File "./tests/docker/docker.py", line 560, in main
return args.cmdobj.run(args, argv)
File "./tests/docker/docker.py", line 306, in run
return Docker().run(argv, args.keep, quiet=args.quiet)
File "./tests/docker/docker.py", line 274, in run
quiet=quiet)
File "./tests/docker/docker.py", line 181, in _do_check
return subprocess.check_call(self._command + cmd, **kwargs)
File "/usr/lib64/python2.7/subprocess.py", line 542, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=5499c004f49611e8abd768b59973b7d0', '-u', '1001', '--security-opt', 'seccomp=unconfined', '--rm', '--net=none', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=8', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-elcqpjgq/src/docker-src.2018-11-30-06.51.33.7508:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2 make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-elcqpjgq/src'
make: *** [docker-run-test-quick@centos7] Error 2

real    2m42.112s
user    0m17.347s
sys     0m3.589s

=== OUTPUT END ===

Test command exited with code: 2
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#41 lore raw
In reply to Mikhail Abakumov
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Subject: [Qemu-devel] [PATCH 00/39] Windbg supporting
Message-id: [email protected]

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
17f6c7f windbg: maintainers
97b20af windbg: implement kd_api_query_memory
5635727 windbg: implement kd_api_fill_memory
6677180 windbg: implement kd_api_search_memory
9973f61 windbg: implement kd_api_read_msr and kd_api_write_msr
3c083dc windbg: implement kd_api_get_version
fca59ca windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory c3e495d windbg: implement kd_api_read_io_space and kd_api_write_io_space 4e29a33 windbg: implement kd_api_continue
5ca2f2f windbg: debug exception subscribing
dc31c84 windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint 0e915cc windbg: implement kd_api_read_control_space and kd_api_write_control_space 915f355 windbg: implement kd_api_get_context_ex and kd_api_set_context_ex 97cd6e2 windbg: implement kd_api_get_context and kd_api_set_context 6bf0cf1 windbg: [de]serialization cpu spec registers
fac3d74 windbg: [de]serialization cpu context
b0be5e5 windbg: add helper functions
0c2dacc windbg: some kernel structures
753465e windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory 8eb2ea2 windbg: implement windbg_process_manipulate_packet
05a53e5 windbg: implement windbg_process_data_packet
b41ab55 windbg: implement windbg_process_control_packet
008a6da windbg: generate ExceptionStateChange and LoadSymbolsStateChange e1bff4f windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
4022b99 windbg: handler of parsing context
bfc2e66 windbg: send data and control packets
b84f44e windbg: parsing data stream
86cf35e windbg: implement find_kdDebuggerDataBlock
e9afd1f windbg: add windbg_search_vmaddr
70d6fbe windbg: implement find_kdVersion
30eb118 windbg: implement find_KPCR
c909786 windbg: implement windbg_on_load
16531ab windbg: hook to wrmsr operation
bfc9fb5 windbg: add chardev
a8d8787 windbg: add WindbgState
3a5b5bf windbg: add helper features
e53a519 windbg: add -windbg option
7995ade windbg: add windbg's KD header file
5ed26b5 windbg: add empty windbgstub files

=== OUTPUT BEGIN ===
Checking PATCH 1/39: windbg: add empty windbgstub files...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #35:
new file mode 100644

total: 0 errors, 1 warnings, 121 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 2/39: windbg: add windbg's KD header file...
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #14:
new file mode 100644

total: 0 errors, 1 warnings, 934 lines checked

Your patch has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
Checking PATCH 3/39: windbg: add -windbg option...
Checking PATCH 4/39: windbg: add helper features...
Checking PATCH 5/39: windbg: add WindbgState...
Checking PATCH 6/39: windbg: add chardev...
Checking PATCH 7/39: windbg: hook to wrmsr operation...
Checking PATCH 8/39: windbg: implement windbg_on_load...
Checking PATCH 9/39: windbg: implement find_KPCR...
Checking PATCH 10/39: windbg: implement find_kdVersion...
Checking PATCH 11/39: windbg: add windbg_search_vmaddr...
Checking PATCH 12/39: windbg: implement find_kdDebuggerDataBlock...
Checking PATCH 13/39: windbg: parsing data stream...
Checking PATCH 14/39: windbg: send data and control packets...
Checking PATCH 15/39: windbg: handler of parsing context...
Checking PATCH 16/39: windbg: init DBGKD_ANY_WAIT_STATE_CHANGE...
Checking PATCH 17/39: windbg: generate ExceptionStateChange and LoadSymbolsStateChange... Checking PATCH 18/39: windbg: implement windbg_process_control_packet...
Checking PATCH 19/39: windbg: implement windbg_process_data_packet...
Checking PATCH 20/39: windbg: implement windbg_process_manipulate_packet...
Checking PATCH 21/39: windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory... Checking PATCH 22/39: windbg: some kernel structures...
Checking PATCH 23/39: windbg: add helper functions...
ERROR: Macros with multiple statements should be enclosed in a do - while loop
#126: FILE: target/i386/windbgstub.c:387:

+#define CASE_FIELD(srct, field, field_size, block)                             \
+    case offsetof(srct, field):                                                \
+        field_size = sizeof_field(srct, field);                                \
+        block;                                                                 \

+ break;

total: 1 errors, 0 warnings, 129 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 24/39: windbg: [de]serialization cpu context...
Checking PATCH 25/39: windbg: [de]serialization cpu spec registers...
Checking PATCH 26/39: windbg: implement kd_api_get_context and kd_api_set_context... Checking PATCH 27/39: windbg: implement kd_api_get_context_ex and kd_api_set_context_ex... Checking PATCH 28/39: windbg: implement kd_api_read_control_space and kd_api_write_control_space... Checking PATCH 29/39: windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint... Checking PATCH 30/39: windbg: debug exception subscribing...
Checking PATCH 31/39: windbg: implement kd_api_continue...
Checking PATCH 32/39: windbg: implement kd_api_read_io_space and kd_api_write_io_space... Checking PATCH 33/39: windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory... Checking PATCH 34/39: windbg: implement kd_api_get_version...
Checking PATCH 35/39: windbg: implement kd_api_read_msr and kd_api_write_msr... Checking PATCH 36/39: windbg: implement kd_api_search_memory...
Checking PATCH 37/39: windbg: implement kd_api_fill_memory...
Checking PATCH 38/39: windbg: implement kd_api_query_memory...
Checking PATCH 39/39: windbg: maintainers...
=== OUTPUT END ===

Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#42 lore raw
In reply to Mikhail Abakumov

I applied on top of latest master (tag: v3.1.0-rc3) and encounter below building failure. CONTEXT_CONTROL should be CPU_CONTEXT_CONTROL?

$./configure --enable-kvm --enable-vhost-net --enable-libssh2 --target-list=x86_64-softmmu --enable-sdl --enable-curses --enable-vnc --enable-fdt --enable-debug --enable-debug-info --enable-trace-backends=log $make -j
[...]
CC x86_64-softmmu/trace/generated-helpers.o
/home/changbin/Desktop/work/qemu/windbgstub-utils.c: In function ‘windbg_search_vmaddr’:
/home/changbin/Desktop/work/qemu/windbgstub-utils.c:179:16: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

         return ret;
                ^~~

cc1: all warnings being treated as errors
/home/changbin/Desktop/work/qemu/rules.mak:69: recipe for target 'windbgstub-utils.o' failed
make[1]: *** [windbgstub-utils.o] Error 1
make[1]: *** Waiting for unfinished jobs....
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c: In function ‘windbg_read_context’:
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:569:29: error: ‘CONTEXT_CONTROL’ undeclared (first use in this function); did you mean ‘CPU_CONTEXT_CONTROL’?

             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:391:9: note: in definition of macro ‘CASE_FIELD’
         block;                                                                 \
         ^~~~~
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:568:9: note: in expansion of macro ‘CASE_FIELD_X32_64’
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^~~~~~~~~~~~~~~~~

/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:890:1: note: in expansion of macro ‘GEN_WINDBG_CONTEXT_RW’
GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
^~~~~~~~~~~~~~~~~~~~~
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:569:29: note: each undeclared identifier is reported only once for each function it appears in

             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:391:9: note: in definition of macro ‘CASE_FIELD’
         block;                                                                 \
         ^~~~~
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:568:9: note: in expansion of macro ‘CASE_FIELD_X32_64’
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^~~~~~~~~~~~~~~~~

/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:890:1: note: in expansion of macro ‘GEN_WINDBG_CONTEXT_RW’
GEN_WINDBG_CONTEXT_RW(windbg_read_context, false)
^~~~~~~~~~~~~~~~~~~~~
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c: In function ‘windbg_write_context’:
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:569:29: error: ‘CONTEXT_CONTROL’ undeclared (first use in this function); did you mean ‘CPU_CONTEXT_CONTROL’?

             if (ctx_flags & CONTEXT_CONTROL) {                                 \
                             ^
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:391:9: note: in definition of macro ‘CASE_FIELD’
         block;                                                                 \
         ^~~~~
/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:568:9: note: in expansion of macro ‘CASE_FIELD_X32_64’
         CASE_FIELD_X32_64(CPU_CONTEXT, Esp, Rsp, f_size, {                     \
         ^~~~~~~~~~~~~~~~~

/home/changbin/Desktop/work/qemu/target/i386/windbgstub.c:891:1: note: in expansion of macro ‘GEN_WINDBG_CONTEXT_RW’
GEN_WINDBG_CONTEXT_RW(windbg_write_context, true)
^~~~~~~~~~~~~~~~~~~~~
/home/changbin/Desktop/work/qemu/rules.mak:69: recipe for target 'target/i386/windbgstub.o' failed make[1]: *** [target/i386/windbgstub.o] Error 1
Makefile:483: recipe for target 'subdir-x86_64-softmmu' failed
make: *** [subdir-x86_64-softmmu] Error 2

Quoted 109 lines · Mikhail Abakumov

We made the debugger module WinDbg (like GDB) for QEMU. This is the replacement of the remote server in Windows kernel. Used for remote Windows kernel debugging without debugging mode.

WinDbg is a multipurpose debugger for the Microsoft Windows computer operating system, distributed by Microsoft. Recent versions of WinDbg have been and are being distributed as part of the free Debugging Tools for Windows suite.

How to start debugging QEMU using WinDbg:
Run QEMU with next option:
-windbg pipe:<name>
QEMU will start and pause for waiting WinDbg connection. Run WinDbg with next options:

    -b -k com:pipe,baud=115200,port=\\.\pipe\<name>,resets=0

Wait for debugger connect to kernel.

Note: You can add Symbol Search Path in WinDbg
such as srv*c:\tmp*http://msdl.microsoft.com/download/symbols.

How it works:
The WinDbg debugger has the possibility of connecting to a remote debug server (Kdsrv.exe) in the Windows kernel. Therefore, it is possible to connect to the guest system running in the QEMU emulator. Kernel debugging is possible only with the enabled debugging mode, may change at the same time. Our module of WinDbg debugger for QEMU is an alternative of the remote debugging service in the kernel. Thus, the debugger connects to the debugging module, not to the kernel of the operating system. The module obtains all the necessary information answering debugger requests from the QEMU emulator. At the same time for debugging there is no need to enable debugging mode in the kernel. This leads to hidden debugging. Our module supports all features of WinDbg regarding remote debugging, besides interception of events and exceptions. Supports i386 and x86_64 architectures.

---

Mikhail Abakumov (39):
windbg: add empty windbgstub files
windbg: add windbg's KD header file
windbg: add -windbg option
windbg: add helper features
windbg: add WindbgState
windbg: add chardev
windbg: hook to wrmsr operation
windbg: implement windbg_on_load
windbg: implement find_KPCR
windbg: implement find_kdVersion
windbg: add windbg_search_vmaddr
windbg: implement find_kdDebuggerDataBlock
windbg: parsing data stream
windbg: send data and control packets
windbg: handler of parsing context
windbg: init DBGKD_ANY_WAIT_STATE_CHANGE
windbg: generate ExceptionStateChange and LoadSymbolsStateChange
windbg: implement windbg_process_control_packet
windbg: implement windbg_process_data_packet
windbg: implement windbg_process_manipulate_packet
windbg: implement kd_api_read_virtual_memory and kd_api_write_virtual_memory
windbg: some kernel structures
windbg: add helper functions
windbg: [de]serialization cpu context
windbg: [de]serialization cpu spec registers
windbg: implement kd_api_get_context and kd_api_set_context
windbg: implement kd_api_get_context_ex and kd_api_set_context_ex
windbg: implement kd_api_read_control_space and kd_api_write_control_space
windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint
windbg: debug exception subscribing
windbg: implement kd_api_continue
windbg: implement kd_api_read_io_space and kd_api_write_io_space
windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory
windbg: implement kd_api_get_version
windbg: implement kd_api_read_msr and kd_api_write_msr
windbg: implement kd_api_search_memory
windbg: implement kd_api_fill_memory
windbg: implement kd_api_query_memory
windbg: maintainers

 MAINTAINERS                      |   12 
 Makefile.target                  |    3 
 cpus.c                           |   19 +
 default-configs/i386-softmmu.mak |    1 
 gdbstub.c                        |    4 
 include/exec/windbgkd.h          |  928 ++++++++++++++++++++++++++
 include/exec/windbgstub-utils.h  |  104 +++
 include/exec/windbgstub.h        |   25 +
 include/sysemu/sysemu.h          |    2 
 qemu-options.hx                  |    8 
 stubs/Makefile.objs              |    1 
 stubs/windbgstub.c               |   22 +
 target/i386/Makefile.objs        |    1 
 target/i386/cpu.h                |    5 
 target/i386/misc_helper.c        |   38 +
 target/i386/windbgstub.c         | 1368 ++++++++++++++++++++++++++++++++++++++
 vl.c                             |    8 
 windbgstub-utils.c               |  508 ++++++++++++++
 windbgstub.c                     |  545 +++++++++++++++
 19 files changed, 3592 insertions(+), 10 deletions(-)
 create mode 100644 include/exec/windbgkd.h
 create mode 100644 include/exec/windbgstub-utils.h
 create mode 100644 include/exec/windbgstub.h
 create mode 100644 stubs/windbgstub.c
 create mode 100644 target/i386/windbgstub.c
 create mode 100644 windbgstub-utils.c
 create mode 100644 windbgstub.c

--
Mikhail Abakumov

Signature · 2 lines
Cheers,
Changbin Du