[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/20] accel/tcg: Use probe_access_internal for softmmu get_page_a
From: |
Richard Henderson |
Subject: |
[PULL 12/20] accel/tcg: Use probe_access_internal for softmmu get_page_addr_code_hostp |
Date: |
Thu, 1 Sep 2022 07:52:02 +0100 |
Simplify the implementation of get_page_addr_code_hostp
by reusing the existing probe_access infrastructure.
Acked-by: Ilya Leoshkevich <iii@linux.ibm.com>
Tested-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
accel/tcg/cputlb.c | 76 ++++++++++++++++------------------------------
1 file changed, 26 insertions(+), 50 deletions(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 80a3eb4f1c..8fad2d9b83 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1482,56 +1482,6 @@ 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)
-/*
- * Return a ram_addr_t for the virtual address for execution.
- *
- * Return -1 if we can't translate and execute from an entire page
- * of RAM. This will force us to execute by loading and translating
- * one insn at a time, without caching.
- *
- * NOTE: This function will trigger an exception if the page is
- * not executable.
- */
-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);
- CPUTLBEntry *entry = tlb_entry(env, mmu_idx, addr);
- void *p;
-
- if (unlikely(!tlb_hit(entry->addr_code, addr))) {
- if (!VICTIM_TLB_HIT(addr_code, addr)) {
- tlb_fill(env_cpu(env), addr, 0, MMU_INST_FETCH, mmu_idx, 0);
- index = tlb_index(env, mmu_idx, addr);
- entry = tlb_entry(env, mmu_idx, addr);
-
- if (unlikely(entry->addr_code & TLB_INVALID_MASK)) {
- /*
- * The MMU protection covers a smaller range than a target
- * page, so we must redo the MMU check for every insn.
- */
- return -1;
- }
- }
- assert(tlb_hit(entry->addr_code, 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);
-}
-
static void notdirty_write(CPUState *cpu, vaddr mem_vaddr, unsigned size,
CPUIOTLBEntry *iotlbentry, uintptr_t retaddr)
{
@@ -1687,6 +1637,32 @@ void *tlb_vaddr_to_host(CPUArchState *env, abi_ptr addr,
return flags ? NULL : host;
}
+/*
+ * Return a ram_addr_t for the virtual address for execution.
+ *
+ * Return -1 if we can't translate and execute from an entire page
+ * of RAM. This will force us to execute by loading and translating
+ * one insn at a time, without caching.
+ *
+ * NOTE: This function will trigger an exception if the page is
+ * not executable.
+ */
+tb_page_addr_t get_page_addr_code_hostp(CPUArchState *env, target_ulong addr,
+ void **hostp)
+{
+ void *p;
+
+ (void)probe_access_internal(env, addr, 1, MMU_INST_FETCH,
+ cpu_mmu_index(env, true), false, &p, 0);
+ if (p == NULL) {
+ return -1;
+ }
+ if (hostp) {
+ *hostp = p;
+ }
+ return qemu_ram_addr_from_host_nofail(p);
+}
+
#ifdef CONFIG_PLUGIN
/*
* Perform a TLB lookup and populate the qemu_plugin_hwaddr structure.
--
2.34.1
- [PULL 00/20] tcg patch queue, Richard Henderson, 2022/09/01
- [PULL 01/20] linux-user/arm: Mark the commpage executable, Richard Henderson, 2022/09/01
- [PULL 1/4] target/avr: Support probe argument to tlb_fill, Richard Henderson, 2022/09/01
- [PULL 02/20] linux-user/hppa: Allocate page zero as a commpage, Richard Henderson, 2022/09/01
- [PULL 2/4] target/avr: Call avr_cpu_do_interrupt directly, Richard Henderson, 2022/09/01
- [PULL 06/20] tests/tcg/i386: Move smc_code2 to an executable section, Richard Henderson, 2022/09/01
- [PULL 10/20] accel/tcg: Make tb_htable_lookup static, Richard Henderson, 2022/09/01
- [PULL 05/20] linux-user: Clear translations on mprotect(), Richard Henderson, 2022/09/01
- [PULL 07/20] accel/tcg: Introduce is_same_page(), Richard Henderson, 2022/09/01
- [PULL 12/20] accel/tcg: Use probe_access_internal for softmmu get_page_addr_code_hostp,
Richard Henderson <=
- [PULL 4/4] target/avr: Disable interrupts when env->skip set, Richard Henderson, 2022/09/01
- [PULL 11/20] accel/tcg: Move qemu_ram_addr_from_host_nofail to physmem.c, Richard Henderson, 2022/09/01
- [PULL 03/20] linux-user/x86_64: Allocate vsyscall page as a commpage, Richard Henderson, 2022/09/01
- [PULL 3/4] target/avr: Only execute one interrupt at a time, Richard Henderson, 2022/09/01
- [PULL 04/20] linux-user: Honor PT_GNU_STACK, Richard Henderson, 2022/09/01
- [PULL 14/20] accel/tcg: Remove translator_ldsw, Richard Henderson, 2022/09/01
- [PULL 09/20] accel/tcg: Unlock mmap_lock after longjmp, Richard Henderson, 2022/09/01
- [PULL 08/20] accel/tcg: Properly implement get_page_addr_code for user-only, Richard Henderson, 2022/09/01
- [PULL 13/20] accel/tcg: Document the faulting lookup in tb_lookup_cmp, Richard Henderson, 2022/09/01
- [PULL 15/20] accel/tcg: Add pc and host_pc params to gen_intermediate_code, Richard Henderson, 2022/09/01