[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/11] exec: add debug version of physical memory read and write
From: |
Ashish Kalra |
Subject: |
[PATCH 05/11] exec: add debug version of physical memory read and write API |
Date: |
Mon, 16 Nov 2020 18:51:14 +0000 |
From: Brijesh Singh <brijesh.singh@amd.com>
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
The subsequent patch will make use of the API introduced, to ensure
that the page table walks are handled correctly when debugging an
SEV guest.
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
include/exec/cpu-common.h | 15 +++++++++++++
softmmu/physmem.c | 47 +++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 19805ed6db..d2089e6873 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -71,11 +71,26 @@ size_t qemu_ram_pagesize_largest(void);
void cpu_physical_memory_rw(hwaddr addr, void *buf,
hwaddr len, bool 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, hwaddr len)
{
cpu_physical_memory_rw(addr, buf, len, false);
}
+static inline void cpu_physical_memory_read_debug(hwaddr addr,
+ void *buf, int len)
+{
+ cpu_physical_memory_rw_debug(addr, buf, len, false);
+}
+static inline void cpu_physical_memory_write_debug(hwaddr addr,
+ const void *buf, int len)
+{
+ cpu_physical_memory_rw_debug(addr, (void *)buf, len, true);
+}
+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, hwaddr len)
{
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 2c08624ca8..6945bd5efe 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3354,6 +3354,53 @@ inline MemTxResult
address_space_write_rom_debug(AddressSpace *as,
return MEMTX_OK;
}
+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;
+
+ debug_ops->read(cpu->cpu_ases[asidx].as, addr, attrs,
+ (void *) &val, 4);
+
+ 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;
+
+ debug_ops->read(cpu->cpu_ases[asidx].as, addr, attrs,
+ (void *) &val, 8);
+ 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;
+
+ if (is_write) {
+ debug_ops->write(&address_space_memory, addr,
+ attrs, buf, len);
+ } else {
+ debug_ops->read(&address_space_memory, addr,
+ attrs, buf, len);
+ }
+
+}
+
int64_t address_space_cache_init(MemoryRegionCache *cache,
AddressSpace *as,
hwaddr addr,
--
2.17.1
- [PATCH 00/11] Add QEMU debug support for SEV guests, Ashish Kalra, 2020/11/16
- [PATCH 01/11] memattrs: add debug attribute, Ashish Kalra, 2020/11/16
- [PATCH 02/11] exec: Add new MemoryDebugOps., Ashish Kalra, 2020/11/16
- [PATCH 03/11] exec: add ram_debug_ops support, Ashish Kalra, 2020/11/16
- [PATCH 04/11] exec: Add address_space_read and address_space_write debug helpers., Ashish Kalra, 2020/11/16
- [PATCH 05/11] exec: add debug version of physical memory read and write API,
Ashish Kalra <=
- [PATCH 06/11] monitor/i386: use debug APIs when accessing guest memory, Ashish Kalra, 2020/11/16
- [PATCH 07/11] kvm: introduce debug memory encryption API, Ashish Kalra, 2020/11/16
- [PATCH 08/11] sev/i386: add debug encrypt and decrypt commands, Ashish Kalra, 2020/11/16
- [PATCH 09/11] hw/i386: set ram_debug_ops when memory encryption is enabled, Ashish Kalra, 2020/11/16
- [PATCH 10/11] sev/i386: add SEV specific MemoryDebugOps., Ashish Kalra, 2020/11/16
- [PATCH 11/11] target/i386: clear C-bit when walking SEV guest page table, Ashish Kalra, 2020/11/16