[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2 37/39] windbg: implement kd_api_fill_memory
From: |
Mikhail Abakumov |
Subject: |
[Qemu-devel] [PATCH 2 37/39] windbg: implement kd_api_fill_memory |
Date: |
Wed, 05 Dec 2018 15:55:30 +0300 |
User-agent: |
StGit/0.17.1-dirty |
Signed-off-by: Mikhail Abakumov <address@hidden>
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
include/exec/windbgstub-utils.h | 1 +
windbgstub-utils.c | 41 +++++++++++++++++++++++++++++++++++++++
windbgstub.c | 4 ++++
3 files changed, 46 insertions(+)
diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h
index 4eb976260b..8192a7b849 100644
--- a/include/exec/windbgstub-utils.h
+++ b/include/exec/windbgstub-utils.h
@@ -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);
diff --git a/windbgstub-utils.c b/windbgstub-utils.c
index 848d52046b..80f87c862b 100644
--- a/windbgstub-utils.c
+++ b/windbgstub-utils.c
@@ -438,6 +438,47 @@ void kd_api_clear_all_internal_breakpoints(CPUState *cs,
PacketData *pd)
{
}
+void kd_api_fill_memory(CPUState *cs, PacketData *pd)
+{
+ DBGKD_FILL_MEMORY *m64c = &pd->m64.u.FillMemory;
+ uint32_t len = ldl_p(&m64c->Length);
+ target_ulong addr = ldq_p(&m64c->Address);
+ uint16_t pattern = MIN(ldl_p(&m64c->PatternLength), pd->extra_size);
+ uint16_t flags = ldl_p(&m64c->Flags);
+ int err, offset = 0;
+
+ uint8_t *mem = g_new(uint8_t, pattern);
+ memcpy(mem, pd->extra, pattern);
+
+ pd->extra_size = 0;
+
+ switch (flags) {
+ case DBGKD_FILL_MEMORY_VIRTUAL:
+ while (offset < len) {
+ err = cpu_memory_rw_debug(cs, addr + offset, mem,
+ MIN(pattern, len - offset), 1);
+ offset += pattern;
+ if (err) {
+ DPRINTF("fill_memory: No physical page mapped: " FMT_ADDR "\n",
+ addr);
+ }
+ }
+ break;
+
+ case DBGKD_FILL_MEMORY_PHYSICAL:
+ while (offset < len) {
+ cpu_physical_memory_rw(addr, mem, MIN(pattern, len - offset), 1);
+ offset += pattern;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ g_free(mem);
+}
+
void kd_api_unsupported(CPUState *cs, PacketData *pd)
{
WINDBG_ERROR("Caught unimplemented api %s",
kd_api_name(pd->m64.ApiNumber));
diff --git a/windbgstub.c b/windbgstub.c
index a50de68db5..daf6d37aa1 100644
--- a/windbgstub.c
+++ b/windbgstub.c
@@ -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;
- [Qemu-devel] [PATCH 2 28/39] windbg: implement kd_api_read_control_space and kd_api_write_control_space, (continued)
- [Qemu-devel] [PATCH 2 28/39] windbg: implement kd_api_read_control_space and kd_api_write_control_space, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 29/39] windbg: implement kd_api_write_breakpoint and kd_api_restore_breakpoint, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 30/39] windbg: debug exception subscribing, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 31/39] windbg: implement kd_api_continue, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 33/39] windbg: implement kd_api_read_physical_memory and kd_api_write_physical_memory, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 32/39] windbg: implement kd_api_read_io_space and kd_api_write_io_space, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 34/39] windbg: implement kd_api_get_version, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 36/39] windbg: implement kd_api_search_memory, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 35/39] windbg: implement kd_api_read_msr and kd_api_write_msr, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 37/39] windbg: implement kd_api_fill_memory,
Mikhail Abakumov <=
- [Qemu-devel] [PATCH 2 38/39] windbg: implement kd_api_query_memory, Mikhail Abakumov, 2018/12/05
- [Qemu-devel] [PATCH 2 39/39] windbg: maintainers, Mikhail Abakumov, 2018/12/05
- Re: [Qemu-devel] [PATCH 2 00/39] Windbg supporting, no-reply, 2018/12/05
- Re: [Qemu-devel] [PATCH 2 00/39] Windbg supporting, no-reply, 2018/12/05
- Re: [Qemu-devel] [PATCH 2 00/39] Windbg supporting, no-reply, 2018/12/05