2018-02-22 23:01:24 +01:00
|
|
|
From bb5805ddc9a5bfbf78d4ce81b6395452c783ca77 Mon Sep 17 00:00:00 2001
|
2018-02-08 20:55:31 +01:00
|
|
|
From: Brijesh Singh <brijesh.singh@amd.com>
|
2018-02-22 23:01:24 +01:00
|
|
|
Date: Thu, 15 Feb 2018 09:03:20 -0600
|
2018-02-08 20:55:31 +01:00
|
|
|
Subject: [PATCH] exec: add debug version of physical memory read and write API
|
|
|
|
|
|
|
|
Adds the following new APIs
|
|
|
|
- cpu_physical_memory_read_debug
|
|
|
|
- cpu_physical_memory_write_debug
|
|
|
|
- cpu_physical_memory_rw_debug
|
|
|
|
- ldl_phys_debug
|
|
|
|
- ldq_phys_debug
|
|
|
|
|
|
|
|
Cc: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
Cc: Peter Crosthwaite <crosthwaite.peter@gmail.com>
|
|
|
|
Cc: Richard Henderson <rth@twiddle.net>
|
|
|
|
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
|
|
|
|
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
[BR: FATE#322124]
|
|
|
|
Signed-off-by: Bruce Rogers <brogers@suse.com>
|
|
|
|
---
|
2018-02-22 23:01:24 +01:00
|
|
|
exec.c | 40 ++++++++++++++++++++++++++++++++++++++++
|
2018-02-08 20:55:31 +01:00
|
|
|
include/exec/cpu-common.h | 15 +++++++++++++++
|
2018-02-22 23:01:24 +01:00
|
|
|
2 files changed, 55 insertions(+)
|
2018-02-08 20:55:31 +01:00
|
|
|
|
|
|
|
diff --git a/exec.c b/exec.c
|
2018-02-22 23:01:24 +01:00
|
|
|
index fe49807f58..2a297de819 100644
|
2018-02-08 20:55:31 +01:00
|
|
|
--- a/exec.c
|
|
|
|
+++ b/exec.c
|
2018-02-22 23:01:24 +01:00
|
|
|
@@ -3525,6 +3525,46 @@ void address_space_cache_destroy(MemoryRegionCache *cache)
|
2018-02-08 20:55:31 +01:00
|
|
|
#define RCU_READ_UNLOCK() rcu_read_unlock()
|
|
|
|
#include "memory_ldst.inc.c"
|
|
|
|
|
|
|
|
+uint32_t ldl_phys_debug(CPUState *cpu, hwaddr addr)
|
|
|
|
+{
|
|
|
|
+ MemTxAttrs attrs;
|
|
|
|
+ int asidx = cpu_asidx_from_attrs(cpu, attrs);
|
|
|
|
+ uint32_t val;
|
|
|
|
+
|
|
|
|
+ /* set debug attrs to indicate memory access is from the debugger */
|
|
|
|
+ attrs.debug = 1;
|
|
|
|
+
|
2018-02-22 23:01:24 +01:00
|
|
|
+ address_space_rw(cpu->cpu_ases[asidx].as, addr, attrs,
|
|
|
|
+ (void *) &val, 4, 0);
|
|
|
|
+
|
2018-02-08 20:55:31 +01:00
|
|
|
+ return tswap32(val);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+uint64_t ldq_phys_debug(CPUState *cpu, hwaddr addr)
|
|
|
|
+{
|
|
|
|
+ MemTxAttrs attrs;
|
|
|
|
+ int asidx = cpu_asidx_from_attrs(cpu, attrs);
|
|
|
|
+ uint64_t val;
|
|
|
|
+
|
|
|
|
+ /* set debug attrs to indicate memory access is from the debugger */
|
|
|
|
+ attrs.debug = 1;
|
|
|
|
+
|
2018-02-22 23:01:24 +01:00
|
|
|
+ address_space_rw(cpu->cpu_ases[asidx].as, addr, attrs,
|
|
|
|
+ (void *) &val, 8, 0);
|
2018-02-08 20:55:31 +01:00
|
|
|
+ return val;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf,
|
|
|
|
+ int len, int is_write)
|
|
|
|
+{
|
|
|
|
+ MemTxAttrs attrs;
|
|
|
|
+
|
|
|
|
+ /* set debug attrs to indicate memory access is from the debugger */
|
|
|
|
+ attrs.debug = 1;
|
|
|
|
+
|
|
|
|
+ address_space_rw(&address_space_memory, addr, attrs, buf, len, is_write);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/* virtual memory access for debug (includes writing to ROM) */
|
|
|
|
int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
|
|
|
|
uint8_t *buf, int len, int is_write)
|
|
|
|
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
|
|
|
|
index 74341b19d2..fa01385d4f 100644
|
|
|
|
--- a/include/exec/cpu-common.h
|
|
|
|
+++ b/include/exec/cpu-common.h
|
|
|
|
@@ -77,11 +77,26 @@ size_t qemu_ram_pagesize_largest(void);
|
|
|
|
|
|
|
|
void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf,
|
|
|
|
int len, int is_write);
|
|
|
|
+void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf,
|
|
|
|
+ int len, int is_write);
|
|
|
|
static inline void cpu_physical_memory_read(hwaddr addr,
|
|
|
|
void *buf, int len)
|
|
|
|
{
|
|
|
|
cpu_physical_memory_rw(addr, buf, len, 0);
|
|
|
|
}
|
|
|
|
+static inline void cpu_physical_memory_read_debug(hwaddr addr,
|
|
|
|
+ void *buf, int len)
|
|
|
|
+{
|
|
|
|
+ cpu_physical_memory_rw_debug(addr, buf, len, 0);
|
|
|
|
+}
|
|
|
|
+static inline void cpu_physical_memory_write_debug(hwaddr addr,
|
|
|
|
+ const void *buf, int len)
|
|
|
|
+{
|
|
|
|
+ cpu_physical_memory_rw_debug(addr, (void *)buf, len, 1);
|
|
|
|
+}
|
|
|
|
+uint32_t ldl_phys_debug(CPUState *cpu, hwaddr addr);
|
|
|
|
+uint64_t ldq_phys_debug(CPUState *cpu, hwaddr addr);
|
|
|
|
+
|
|
|
|
static inline void cpu_physical_memory_write(hwaddr addr,
|
|
|
|
const void *buf, int len)
|
|
|
|
{
|