[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 18/54] cputlb: introduce get_page_addr_code_hostp
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v4 18/54] cputlb: introduce get_page_addr_code_hostp |
Date: |
Wed, 31 Jul 2019 17:06:43 +0100 |
From: "Emilio G. Cota" <address@hidden>
This will be used by plugins to get the host address
of instructions.
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Alex Bennée <address@hidden>
---
accel/tcg/cputlb.c | 14 +++++++++++++-
include/exec/exec-all.h | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index a01e04c5416..21ba71ea9dd 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1015,7 +1015,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t
mmu_idx, size_t index,
victim_tlb_hit(env, mmu_idx, index, offsetof(CPUTLBEntry, TY), \
(ADDR) & TARGET_PAGE_MASK)
-tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
+ void **hostp)
{
uintptr_t mmu_idx = cpu_mmu_index(env, true);
uintptr_t index = tlb_index(env, mmu_idx, addr);
@@ -1040,13 +1041,24 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env,
target_ulong addr)
* than a target page, so we must redo the MMU check every insn
* - TLB_MMIO: region is not backed by RAM
*/
+ if (hostp) {
+ *hostp = NULL;
+ }
return -1;
}
p = (void *)((uintptr_t)addr + entry->addend);
+ if (hostp) {
+ *hostp = p;
+ }
return qemu_ram_addr_from_host_nofail(p);
}
+tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr)
+{
+ return get_page_addr_code_hostp(env, addr, NULL);
+}
+
/* Probe for whether the specified guest write access is permitted.
* If it is not permitted then an exception will be taken in the same
* way as if this were a real write access (and we will not return).
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 8b1c3d5b9db..90045e77c1f 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -21,6 +21,7 @@
#define EXEC_ALL_H
#include "exec/tb-context.h"
+#include "exec/cpu_ldst.h"
#include "sysemu/cpus.h"
/* allow to see translation results - the slowdown should be negligible, so we
leave it */
@@ -492,6 +493,26 @@ static inline tb_page_addr_t
get_page_addr_code(CPUArchState *env,
{
return addr;
}
+
+/**
+ * get_page_addr_code_hostp() - user-mode version
+ * @env: CPUArchState
+ * @addr: guest virtual address of guest code
+ *
+ * Returns @addr.
+ *
+ * If @hostp is non-NULL, sets *@hostp to the host address where @addr's
content
+ * is kept.
+ */
+static inline tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env,
+ target_ulong addr,
+ void **hostp)
+{
+ if (hostp) {
+ *hostp = g2h(addr);
+ }
+ return addr;
+}
#else
static inline void mmap_lock(void) {}
static inline void mmap_unlock(void) {}
@@ -509,6 +530,23 @@ static inline void mmap_unlock(void) {}
*/
tb_page_addr_t get_page_addr_code(CPUArchState *env, target_ulong addr);
+/**
+ * get_page_addr_code_hostp() - full-system version
+ * @env: CPUArchState
+ * @addr: guest virtual address of guest code
+ *
+ * See get_page_addr_code() (full-system version) for documentation on the
+ * return value.
+ *
+ * Sets *@hostp (when @hostp is non-NULL) as follows.
+ * If the return value is -1, sets *@hostp to NULL. Otherwise, sets *@hostp
+ * to the host address where @addr's content is kept.
+ *
+ * Note: this function can trigger an exception.
+ */
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
+ void **hostp);
+
void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length);
void tlb_set_dirty(CPUState *cpu, target_ulong vaddr);
--
2.20.1
- [Qemu-devel] [PATCH v4 45/54] linux-user: support -plugin option, (continued)
- [Qemu-devel] [PATCH v4 45/54] linux-user: support -plugin option, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 53/54] include/exec: wrap cpu_ldst.h in CONFIG_TCG, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 33/54] target/sh4: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 42/54] translator: inject instrumentation from plugins, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 19/54] tcg: add tcg_gen_st_ptr, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 54/54] include/exec/cpu-defs.h: fix typo, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 40/54] target/xtensa: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 31/54] target/arm: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 30/54] translator: add translator_ld{ub, sw, uw, l, q}, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 39/54] target/sparc: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 18/54] cputlb: introduce get_page_addr_code_hostp,
Alex Bennée <=
- [Qemu-devel] [PATCH v4 41/54] target/openrisc: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 27/54] *-user: plugin syscalls, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 51/54] tests/plugin: add hotpages plugin to breakdown memory access patterns, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 25/54] translate-all: notify plugin code of tb_flush, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 50/54] tests/plugin: add instruction execution breakdown, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 23/54] tcg: let plugins instrument virtual memory accesses, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 20/54] plugin-gen: add module for TCG-related code, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 17/54] cputlb: document get_page_addr_code, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 38/54] target/riscv: fetch code with translator_ld, Alex Bennée, 2019/07/31
- [Qemu-devel] [PATCH v4 36/54] target/m68k: fetch code with translator_ld, Alex Bennée, 2019/07/31