diff --git a/qemu/aarch64.h b/qemu/aarch64.h index 7c3182bd..e13aef52 100644 --- a/qemu/aarch64.h +++ b/qemu/aarch64.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_aarch64 #define print_type_size print_type_size_aarch64 #define print_type_str print_type_str_aarch64 +#define probe_write probe_write_aarch64 #define propagateFloat128NaN propagateFloat128NaN_aarch64 #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_aarch64 #define propagateFloat32NaN propagateFloat32NaN_aarch64 diff --git a/qemu/aarch64eb.h b/qemu/aarch64eb.h index 0bb37d42..4a5c5093 100644 --- a/qemu/aarch64eb.h +++ b/qemu/aarch64eb.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_aarch64eb #define print_type_size print_type_size_aarch64eb #define print_type_str print_type_str_aarch64eb +#define probe_write probe_write_aarch64eb #define propagateFloat128NaN propagateFloat128NaN_aarch64eb #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_aarch64eb #define propagateFloat32NaN propagateFloat32NaN_aarch64eb diff --git a/qemu/arm.h b/qemu/arm.h index f124969f..39d422a3 100644 --- a/qemu/arm.h +++ b/qemu/arm.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_arm #define print_type_size print_type_size_arm #define print_type_str print_type_str_arm +#define probe_write probe_write_arm #define propagateFloat128NaN propagateFloat128NaN_arm #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_arm #define propagateFloat32NaN propagateFloat32NaN_arm diff --git a/qemu/armeb.h b/qemu/armeb.h index eb6e3187..89c56c0e 100644 --- a/qemu/armeb.h +++ b/qemu/armeb.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_armeb #define print_type_size print_type_size_armeb #define print_type_str print_type_str_armeb +#define probe_write probe_write_armeb #define propagateFloat128NaN propagateFloat128NaN_armeb #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_armeb #define propagateFloat32NaN propagateFloat32NaN_armeb diff --git a/qemu/header_gen.py b/qemu/header_gen.py index 37fb3579..432f28b3 100644 --- a/qemu/header_gen.py +++ b/qemu/header_gen.py @@ -2302,6 +2302,7 @@ symbols = ( 'print_type_number', 'print_type_size', 'print_type_str', + 'probe_write', 'propagateFloat128NaN', 'propagateFloat32MulAddNaN', 'propagateFloat32NaN', diff --git a/qemu/include/exec/exec-all.h b/qemu/include/exec/exec-all.h index 1565c0c3..4ce5880f 100644 --- a/qemu/include/exec/exec-all.h +++ b/qemu/include/exec/exec-all.h @@ -172,6 +172,8 @@ void tlb_set_page(CPUState *cpu, target_ulong vaddr, int mmu_idx, target_ulong size); void tb_invalidate_phys_addr(AddressSpace *as, hwaddr addr); +void probe_write(CPUArchState *env, target_ulong addr, int mmu_idx, + uintptr_t retaddr); #else static inline void tlb_flush_page(CPUState *cpu, target_ulong addr) diff --git a/qemu/m68k.h b/qemu/m68k.h index 61781513..dabad58b 100644 --- a/qemu/m68k.h +++ b/qemu/m68k.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_m68k #define print_type_size print_type_size_m68k #define print_type_str print_type_str_m68k +#define probe_write probe_write_m68k #define propagateFloat128NaN propagateFloat128NaN_m68k #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_m68k #define propagateFloat32NaN propagateFloat32NaN_m68k diff --git a/qemu/mips.h b/qemu/mips.h index 67b2e280..39892df1 100644 --- a/qemu/mips.h +++ b/qemu/mips.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_mips #define print_type_size print_type_size_mips #define print_type_str print_type_str_mips +#define probe_write probe_write_mips #define propagateFloat128NaN propagateFloat128NaN_mips #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_mips #define propagateFloat32NaN propagateFloat32NaN_mips diff --git a/qemu/mips64.h b/qemu/mips64.h index 90fd4235..7e58ff86 100644 --- a/qemu/mips64.h +++ b/qemu/mips64.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_mips64 #define print_type_size print_type_size_mips64 #define print_type_str print_type_str_mips64 +#define probe_write probe_write_mips64 #define propagateFloat128NaN propagateFloat128NaN_mips64 #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_mips64 #define propagateFloat32NaN propagateFloat32NaN_mips64 diff --git a/qemu/mips64el.h b/qemu/mips64el.h index 7a4e7856..22f9858b 100644 --- a/qemu/mips64el.h +++ b/qemu/mips64el.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_mips64el #define print_type_size print_type_size_mips64el #define print_type_str print_type_str_mips64el +#define probe_write probe_write_mips64el #define propagateFloat128NaN propagateFloat128NaN_mips64el #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_mips64el #define propagateFloat32NaN propagateFloat32NaN_mips64el diff --git a/qemu/mipsel.h b/qemu/mipsel.h index cdf9e93c..3cca3645 100644 --- a/qemu/mipsel.h +++ b/qemu/mipsel.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_mipsel #define print_type_size print_type_size_mipsel #define print_type_str print_type_str_mipsel +#define probe_write probe_write_mipsel #define propagateFloat128NaN propagateFloat128NaN_mipsel #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_mipsel #define propagateFloat32NaN propagateFloat32NaN_mipsel diff --git a/qemu/powerpc.h b/qemu/powerpc.h index 8a95a0f0..4203ed54 100644 --- a/qemu/powerpc.h +++ b/qemu/powerpc.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_powerpc #define print_type_size print_type_size_powerpc #define print_type_str print_type_str_powerpc +#define probe_write probe_write_powerpc #define propagateFloat128NaN propagateFloat128NaN_powerpc #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_powerpc #define propagateFloat32NaN propagateFloat32NaN_powerpc diff --git a/qemu/softmmu_template.h b/qemu/softmmu_template.h index f5eb43da..104304b4 100644 --- a/qemu/softmmu_template.h +++ b/qemu/softmmu_template.h @@ -833,6 +833,28 @@ void helper_be_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } #endif /* DATA_SIZE > 1 */ +#if DATA_SIZE == 1 +/* 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). + * Otherwise the function will return, and there will be a valid + * entry in the TLB for this access. + */ +void probe_write(CPUArchState *env, target_ulong addr, int mmu_idx, + uintptr_t retaddr) +{ + int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); + target_ulong tlb_addr = env->tlb_table[mmu_idx][index].addr_write; + + if ((addr & TARGET_PAGE_MASK) + != (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) { + /* TLB entry is for a different page */ + if (!VICTIM_TLB_HIT(addr_write, addr)) { + tlb_fill(ENV_GET_CPU(env), addr, MMU_DATA_STORE, mmu_idx, retaddr); + } + } +} +#endif #endif /* !defined(SOFTMMU_CODE_ACCESS) */ #undef READ_ACCESS_TYPE diff --git a/qemu/sparc.h b/qemu/sparc.h index 3268fed9..c6f5bde3 100644 --- a/qemu/sparc.h +++ b/qemu/sparc.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_sparc #define print_type_size print_type_size_sparc #define print_type_str print_type_str_sparc +#define probe_write probe_write_sparc #define propagateFloat128NaN propagateFloat128NaN_sparc #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_sparc #define propagateFloat32NaN propagateFloat32NaN_sparc diff --git a/qemu/sparc64.h b/qemu/sparc64.h index b7f692a1..b2b6e3dd 100644 --- a/qemu/sparc64.h +++ b/qemu/sparc64.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_sparc64 #define print_type_size print_type_size_sparc64 #define print_type_str print_type_str_sparc64 +#define probe_write probe_write_sparc64 #define propagateFloat128NaN propagateFloat128NaN_sparc64 #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_sparc64 #define propagateFloat32NaN propagateFloat32NaN_sparc64 diff --git a/qemu/target-mips/op_helper.c b/qemu/target-mips/op_helper.c index 71f02db2..6aaaf8dd 100644 --- a/qemu/target-mips/op_helper.c +++ b/qemu/target-mips/op_helper.c @@ -4118,11 +4118,10 @@ static inline void ensure_writable_pages(CPUMIPSState *env, target_ulong page_addr; if (unlikely(MSA_PAGESPAN(addr))) { /* first page */ - // UNICORN: Commented out - //probe_write(env, addr, mmu_idx, retaddr); + probe_write(env, addr, mmu_idx, retaddr); /* second page */ page_addr = (addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; - //probe_write(env, page_addr, mmu_idx, retaddr); + probe_write(env, page_addr, mmu_idx, retaddr); } #endif } diff --git a/qemu/x86_64.h b/qemu/x86_64.h index 5e8d97bf..86c11880 100644 --- a/qemu/x86_64.h +++ b/qemu/x86_64.h @@ -2296,6 +2296,7 @@ #define print_type_number print_type_number_x86_64 #define print_type_size print_type_size_x86_64 #define print_type_str print_type_str_x86_64 +#define probe_write probe_write_x86_64 #define propagateFloat128NaN propagateFloat128NaN_x86_64 #define propagateFloat32MulAddNaN propagateFloat32MulAddNaN_x86_64 #define propagateFloat32NaN propagateFloat32NaN_x86_64