target/s390x: Use unwind data for helper_xc

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
Richard Henderson 2017-05-19 09:53:31 -07:00
parent 6fc2606e58
commit 9c009e88e3
2 changed files with 24 additions and 21 deletions

View File

@ -57,7 +57,7 @@ void tlb_fill(CPUState *cs, target_ulong addr, MMUAccessType access_type,
#endif #endif
/* Reduce the length so that addr + len doesn't cross a page boundary. */ /* Reduce the length so that addr + len doesn't cross a page boundary. */
static inline uint64_t adj_len_to_page(uint64_t len, uint64_t addr) static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr)
{ {
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
if ((addr & ~TARGET_PAGE_MASK) + len - 1 >= TARGET_PAGE_SIZE) { if ((addr & ~TARGET_PAGE_MASK) + len - 1 >= TARGET_PAGE_SIZE) {
@ -68,7 +68,7 @@ static inline uint64_t adj_len_to_page(uint64_t len, uint64_t addr)
} }
static void fast_memset(CPUS390XState *env, uint64_t dest, uint8_t byte, static void fast_memset(CPUS390XState *env, uint64_t dest, uint8_t byte,
uint32_t l) uint32_t l, uintptr_t ra)
{ {
int mmu_idx = cpu_mmu_index(env, false); int mmu_idx = cpu_mmu_index(env, false);
@ -76,14 +76,14 @@ static void fast_memset(CPUS390XState *env, uint64_t dest, uint8_t byte,
void *p = tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx); void *p = tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx);
if (p) { if (p) {
/* Access to the whole page in write mode granted. */ /* Access to the whole page in write mode granted. */
int l_adj = adj_len_to_page(l, dest); uint32_t l_adj = adj_len_to_page(l, dest);
memset(p, byte, l_adj); memset(p, byte, l_adj);
dest += l_adj; dest += l_adj;
l -= l_adj; l -= l_adj;
} else { } else {
/* We failed to get access to the whole page. The next write /* We failed to get access to the whole page. The next write
access will likely fill the QEMU TLB for the next iteration. */ access will likely fill the QEMU TLB for the next iteration. */
cpu_stb_data(env, dest, byte); cpu_stb_data_ra(env, dest, byte, ra);
dest++; dest++;
l--; l--;
} }
@ -100,7 +100,7 @@ static void fast_memmove(CPUS390XState *env, uint64_t dest, uint64_t src,
void *dest_p = tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx); void *dest_p = tlb_vaddr_to_host(env, dest, MMU_DATA_STORE, mmu_idx);
if (src_p && dest_p) { if (src_p && dest_p) {
/* Access to both whole pages granted. */ /* Access to both whole pages granted. */
int l_adj = adj_len_to_page(l, src); uint32_t l_adj = adj_len_to_page(l, src);
l_adj = adj_len_to_page(l_adj, dest); l_adj = adj_len_to_page(l_adj, dest);
memmove(dest_p, src_p, l_adj); memmove(dest_p, src_p, l_adj);
src += l_adj; src += l_adj;
@ -144,30 +144,34 @@ uint32_t HELPER(nc)(CPUS390XState *env, uint32_t l, uint64_t dest,
} }
/* xor on array */ /* xor on array */
uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest, static uint32_t do_helper_xc(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src) uint64_t src, uintptr_t ra)
{ {
int i; uint32_t i;
unsigned char x; uint8_t c = 0;
uint32_t cc = 0;
HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n", HELPER_LOG("%s l %d dest %" PRIx64 " src %" PRIx64 "\n",
__func__, l, dest, src); __func__, l, dest, src);
/* xor with itself is the same as memset(0) */ /* xor with itself is the same as memset(0) */
if (src == dest) { if (src == dest) {
fast_memset(env, dest, 0, l + 1); fast_memset(env, dest, 0, l + 1, ra);
return 0; return 0;
} }
for (i = 0; i <= l; i++) { for (i = 0; i <= l; i++) {
x = cpu_ldub_data(env, dest + i) ^ cpu_ldub_data(env, src + i); uint8_t x = cpu_ldub_data_ra(env, src + i, ra);
if (x) { x ^= cpu_ldub_data_ra(env, dest + i, ra);
cc = 1; c |= x;
} cpu_stb_data_ra(env, dest + i, x, ra);
cpu_stb_data(env, dest + i, x);
} }
return cc; return c != 0;
}
uint32_t HELPER(xc)(CPUS390XState *env, uint32_t l, uint64_t dest,
uint64_t src)
{
return do_helper_xc(env, l, dest, src, GETPC());
} }
/* or on array */ /* or on array */
@ -206,7 +210,7 @@ void HELPER(mvc)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src)
/* mvc with source pointing to the byte after the destination is the /* mvc with source pointing to the byte after the destination is the
same as memset with the first source byte */ same as memset with the first source byte */
if (dest == (src + 1)) { if (dest == (src + 1)) {
fast_memset(env, dest, cpu_ldub_data(env, src), l + 1); fast_memset(env, dest, cpu_ldub_data(env, src), l + 1, 0);
return; return;
} }
@ -1235,8 +1239,8 @@ uint32_t HELPER(ex)(CPUS390XState *env, uint32_t cc, uint64_t v1,
get_address(env, 0, b2, d2), 0); get_address(env, 0, b2, d2), 0);
break; break;
case 0x700: case 0x700:
cc = helper_xc(env, l, get_address(env, 0, b1, d1), cc = do_helper_xc(env, l, get_address(env, 0, b1, d1),
get_address(env, 0, b2, d2)); get_address(env, 0, b2, d2), 0);
break; break;
case 0xc00: case 0xc00:
helper_tr(env, l, get_address(env, 0, b1, d1), helper_tr(env, l, get_address(env, 0, b1, d1),

View File

@ -4165,7 +4165,6 @@ static ExitStatus op_xc(DisasContext *s, DisasOps *o)
/* But in general we'll defer to a helper. */ /* But in general we'll defer to a helper. */
o->in2 = get_address(s, 0, b2, d2); o->in2 = get_address(s, 0, b2, d2);
t32 = tcg_const_i32(l); t32 = tcg_const_i32(l);
potential_page_fault(s);
gen_helper_xc(cc_op, cpu_env, t32, o->addr1, o->in2); gen_helper_xc(cc_op, cpu_env, t32, o->addr1, o->in2);
tcg_temp_free_i32(t32); tcg_temp_free_i32(t32);
set_cc_static(s); set_cc_static(s);