Signed-off-by: Mihail Abakumov <mikhail.abaku...@ispras.ru> Signed-off-by: Pavel Dovgalyuk <dovga...@ispras.ru> Signed-off-by: Dmitriy Koltunov <koltu...@ispras.ru> --- include/exec/windbgstub-utils.h | 1 + windbgstub-utils.c | 36 ++++++++++++++++++++++++++++++++++++ windbgstub.c | 4 ++++ 3 files changed, 41 insertions(+)
diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h index ba001ddb42..d1a10c862e 100755 --- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -119,6 +119,7 @@ void kd_api_get_version(CPUState *cpu, PacketData *pd); void kd_api_read_msr(CPUState *cpu, PacketData *pd); void kd_api_write_msr(CPUState *cpu, PacketData *pd); void kd_api_search_memory(CPUState *cpu, PacketData *pd); +void kd_api_fill_memory(CPUState *cpu, PacketData *pd); void kd_api_unsupported(CPUState *cpu, PacketData *pd); SizedBuf kd_gen_exception_sc(CPUState *cpu); diff --git a/windbgstub-utils.c b/windbgstub-utils.c index 2d3fbcc41c..3832e0b116 100755 --- a/windbgstub-utils.c +++ b/windbgstub-utils.c @@ -1570,6 +1570,42 @@ void kd_api_search_memory(CPUState *cpu, PacketData *pd) pd->extra_size = 0; } +void kd_api_fill_memory(CPUState *cpu, 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 = ldl_p(&m64c->PatternLength); + uint16_t flags = ldl_p(&m64c->Flags); + + uint8_t mem[len]; + int i, err; + for (i = 0; i < len; ++i) { + mem[i] = pd->extra[i % pattern]; + } + + switch (flags) { + case DBGKD_FILL_MEMORY_VIRTUAL: + err = cpu_memory_rw_debug(cpu, addr, mem, len, 1); + if (err) { + pd->m64.ReturnStatus = STATUS_UNSUCCESSFUL; + WINDBG_DEBUG("fill_memory: No physical page mapped: " FMT_ADDR, + addr); + } + break; + + case DBGKD_FILL_MEMORY_PHYSICAL: + cpu_physical_memory_rw(addr, mem, len, 1); + break; + + default: + break; + } + + pd->extra_size = 0; +} + void kd_api_unsupported(CPUState *cpu, PacketData *pd) { WINDBG_ERROR("Catched unimplemented api %s", diff --git a/windbgstub.c b/windbgstub.c index 7cff6bc514..b01ddcf009 100755 --- a/windbgstub.c +++ b/windbgstub.c @@ -209,6 +209,10 @@ static void windbg_process_manipulate_packet(ParsingContext *ctx) kd_api_search_memory(cpu, &ctx->data); break; + case DbgKdFillMemoryApi: + kd_api_fill_memory(cpu, &ctx->data); + break; + default: kd_api_unsupported(cpu, &ctx->data); break;