[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 11/54] cputlb: introduce get_page_addr_code_hostp
From: |
Alex Bennée |
Subject: |
[PATCH v6 11/54] cputlb: introduce get_page_addr_code_hostp |
Date: |
Thu, 17 Oct 2019 14:15:32 +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>
Reviewed-by: Richard Henderson <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 a8f9069582..82a5783a2b 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1051,7 +1051,8 @@ static bool victim_tlb_hit(CPUArchState *env, size_t
mmu_idx, size_t index,
* NOTE: This function will trigger an exception if the page is
* not executable.
*/
-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);
@@ -1077,13 +1078,24 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env,
target_ulong addr)
if (unlikely(entry->addr_code & TLB_MMIO)) {
/* The 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);
+}
+
static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,
CPUIOTLBEntry *iotlbentry, uintptr_t retaddr)
{
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index e4206cb173..eadcf29d0c 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -22,6 +22,7 @@
#include "cpu.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 */
@@ -516,6 +517,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) {}
@@ -533,6 +554,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
- [PATCH v6 12/54] tcg: add tcg_gen_st_ptr, (continued)
- [PATCH v6 12/54] tcg: add tcg_gen_st_ptr, Alex Bennée, 2019/10/17
- [PATCH v6 02/54] trace: add mmu_index to mem_info, Alex Bennée, 2019/10/17
- [PATCH v6 06/54] plugin: add user-facing API, Alex Bennée, 2019/10/17
- [PATCH v6 08/54] plugin: add implementation of the api, Alex Bennée, 2019/10/17
- [PATCH v6 05/54] docs/devel: add plugins.rst design document, Alex Bennée, 2019/10/17
- [PATCH v6 09/54] queue: add QTAILQ_REMOVE_SEVERAL, Alex Bennée, 2019/10/17
- [PATCH v6 10/54] cputlb: document get_page_addr_code, Alex Bennée, 2019/10/17
- [PATCH v6 23/54] target/arm: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 21/54] plugin-gen: add plugin_insn_append, Alex Bennée, 2019/10/17
- [PATCH v6 19/54] *-user: plugin syscalls, Alex Bennée, 2019/10/17
- [PATCH v6 11/54] cputlb: introduce get_page_addr_code_hostp,
Alex Bennée <=
- [PATCH v6 07/54] plugin: add core code, Alex Bennée, 2019/10/17
- [PATCH v6 42/54] tests/plugin: add sample plugins, Alex Bennée, 2019/10/17
- [PATCH v6 24/54] target/ppc: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 13/54] plugin-gen: add module for TCG-related code, Alex Bennée, 2019/10/17
- [PATCH v6 39/54] plugin: add qemu_plugin_outs helper, Alex Bennée, 2019/10/17
- [PATCH v6 29/54] target/alpha: fetch code with translator_ld, Alex Bennée, 2019/10/17
- [PATCH v6 50/54] tests/plugin: add hotpages to analyse memory access patterns, Alex Bennée, 2019/10/17
- [PATCH v6 47/54] tests/tcg: enable plugin testing, Alex Bennée, 2019/10/17
- [PATCH v6 37/54] plugin: expand the plugin_init function to include an info block, Alex Bennée, 2019/10/17