xref: /qemu/accel/tcg/tb-internal.h (revision 3e6bfabfbb12fbc19b92b03b72b948dc4f40d144)
193ef2c2fSPhilippe Mathieu-Daudé /*
293ef2c2fSPhilippe Mathieu-Daudé  * TranslationBlock internal declarations (target specific)
393ef2c2fSPhilippe Mathieu-Daudé  *
493ef2c2fSPhilippe Mathieu-Daudé  *  Copyright (c) 2003 Fabrice Bellard
593ef2c2fSPhilippe Mathieu-Daudé  *
693ef2c2fSPhilippe Mathieu-Daudé  * SPDX-License-Identifier: LGPL-2.1-or-later
793ef2c2fSPhilippe Mathieu-Daudé  */
893ef2c2fSPhilippe Mathieu-Daudé 
993ef2c2fSPhilippe Mathieu-Daudé #ifndef ACCEL_TCG_TB_INTERNAL_TARGET_H
1093ef2c2fSPhilippe Mathieu-Daudé #define ACCEL_TCG_TB_INTERNAL_TARGET_H
1193ef2c2fSPhilippe Mathieu-Daudé 
12*3e6bfabfSPhilippe Mathieu-Daudé #include "exec/cpu-all.h"
13*3e6bfabfSPhilippe Mathieu-Daudé #include "exec/exec-all.h"
14*3e6bfabfSPhilippe Mathieu-Daudé #include "exec/translation-block.h"
15*3e6bfabfSPhilippe Mathieu-Daudé 
16*3e6bfabfSPhilippe Mathieu-Daudé #ifdef CONFIG_USER_ONLY
17*3e6bfabfSPhilippe Mathieu-Daudé #include "user/page-protection.h"
18*3e6bfabfSPhilippe Mathieu-Daudé /*
19*3e6bfabfSPhilippe Mathieu-Daudé  * For user-only, page_protect sets the page read-only.
20*3e6bfabfSPhilippe Mathieu-Daudé  * Since most execution is already on read-only pages, and we'd need to
21*3e6bfabfSPhilippe Mathieu-Daudé  * account for other TBs on the same page, defer undoing any page protection
22*3e6bfabfSPhilippe Mathieu-Daudé  * until we receive the write fault.
23*3e6bfabfSPhilippe Mathieu-Daudé  */
24*3e6bfabfSPhilippe Mathieu-Daudé static inline void tb_lock_page0(tb_page_addr_t p0)
25*3e6bfabfSPhilippe Mathieu-Daudé {
26*3e6bfabfSPhilippe Mathieu-Daudé     page_protect(p0);
27*3e6bfabfSPhilippe Mathieu-Daudé }
28*3e6bfabfSPhilippe Mathieu-Daudé 
29*3e6bfabfSPhilippe Mathieu-Daudé static inline void tb_lock_page1(tb_page_addr_t p0, tb_page_addr_t p1)
30*3e6bfabfSPhilippe Mathieu-Daudé {
31*3e6bfabfSPhilippe Mathieu-Daudé     page_protect(p1);
32*3e6bfabfSPhilippe Mathieu-Daudé }
33*3e6bfabfSPhilippe Mathieu-Daudé 
34*3e6bfabfSPhilippe Mathieu-Daudé static inline void tb_unlock_page1(tb_page_addr_t p0, tb_page_addr_t p1) { }
35*3e6bfabfSPhilippe Mathieu-Daudé static inline void tb_unlock_pages(TranslationBlock *tb) { }
36*3e6bfabfSPhilippe Mathieu-Daudé #else
37*3e6bfabfSPhilippe Mathieu-Daudé void tb_lock_page0(tb_page_addr_t);
38*3e6bfabfSPhilippe Mathieu-Daudé void tb_lock_page1(tb_page_addr_t, tb_page_addr_t);
39*3e6bfabfSPhilippe Mathieu-Daudé void tb_unlock_page1(tb_page_addr_t, tb_page_addr_t);
40*3e6bfabfSPhilippe Mathieu-Daudé void tb_unlock_pages(TranslationBlock *);
41*3e6bfabfSPhilippe Mathieu-Daudé #endif
42*3e6bfabfSPhilippe Mathieu-Daudé 
43*3e6bfabfSPhilippe Mathieu-Daudé #ifdef CONFIG_SOFTMMU
44*3e6bfabfSPhilippe Mathieu-Daudé void tb_invalidate_phys_range_fast(ram_addr_t ram_addr,
45*3e6bfabfSPhilippe Mathieu-Daudé                                    unsigned size,
46*3e6bfabfSPhilippe Mathieu-Daudé                                    uintptr_t retaddr);
47*3e6bfabfSPhilippe Mathieu-Daudé #endif /* CONFIG_SOFTMMU */
48*3e6bfabfSPhilippe Mathieu-Daudé 
49*3e6bfabfSPhilippe Mathieu-Daudé bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc);
50*3e6bfabfSPhilippe Mathieu-Daudé 
5193ef2c2fSPhilippe Mathieu-Daudé void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
5293ef2c2fSPhilippe Mathieu-Daudé 
5393ef2c2fSPhilippe Mathieu-Daudé #endif
54