softmmu: Add probe_write()

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.

Backports commit 3b4afc9e75ab1a95f33e41f462921093f8a109c4 from qemu
This commit is contained in:
Yongbok Kim 2018-02-27 12:17:15 -05:00 committed by Lioncash
parent 1c9c8d3f10
commit 79e4c001a9
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
17 changed files with 40 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -2302,6 +2302,7 @@ symbols = (
'print_type_number',
'print_type_size',
'print_type_str',
'probe_write',
'propagateFloat128NaN',
'propagateFloat32MulAddNaN',
'propagateFloat32NaN',

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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