@@ -3768,6 +3768,16 @@ void stq_be_phys(AddressSpace *as, hwaddr addr, uint64_t val)
address_space_stq_be(as, addr, val, MEMTXATTRS_UNSPECIFIED, NULL);
}
+void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf,
+ int len, int is_write)
+{
+ MemTxAttrs attrs;
+
+ attrs = MEMTXATTRS_UNSPECIFIED;
+
+ 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)
@@ -61,6 +61,8 @@ const char *qemu_ram_get_idstr(RAMBlock *rb);
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)
{
@@ -71,6 +73,16 @@ static inline void cpu_physical_memory_write(hwaddr addr,
{
cpu_physical_memory_rw(addr, (void *)buf, len, 1);
}
+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);
+}
void *cpu_physical_memory_map(hwaddr addr,
hwaddr *plen,
int is_write);
The patch adds the following new APIs: - cpu_physical_memory_read_debug - cpu_physical_memory_write_debug These API's can be used when reading/writing guest physical memory for debugging purposes. In next patch will update the hmp monitor memory dump commands (xp, info mem, info tlb etc) to use this API instead of cpu_physical_memory_read() to access the guest physical memory. The idea behind this patch is that in case of SEV-enabled guest we need a method to identify whether the memory access is for debug purposes. If all the debug access requests are done through these API's then we can create/set special sev specific MemTxAttrs to indicate that RAM access is for debugg purposes and use SEV debug commands to read and write guest memory for debug purposes. Signed-off-by: Brijesh Singh <brijesh.singh@amd.com> --- exec.c | 10 ++++++++++ include/exec/cpu-common.h | 12 ++++++++++++ 2 files changed, 22 insertions(+)