Skip to content

Commit

Permalink
s390x/tcg: MVN: Fault-safe handling
Browse files Browse the repository at this point in the history
We can process a maximum of 256 bytes, crossing two pages.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
  • Loading branch information
davidhildenbrand committed Sep 23, 2019
1 parent 65a27df commit ab8bab6
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions target/s390x/mem_helper.c
Expand Up @@ -500,13 +500,22 @@ void HELPER(mvcin)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src)
/* move numerics */
void HELPER(mvn)(CPUS390XState *env, uint32_t l, uint64_t dest, uint64_t src)
{
const int mmu_idx = cpu_mmu_index(env, false);
S390Access srca1, srca2, desta;
uintptr_t ra = GETPC();
int i;

for (i = 0; i <= l; i++) {
uint8_t v = cpu_ldub_data_ra(env, dest + i, ra) & 0xf0;
v |= cpu_ldub_data_ra(env, src + i, ra) & 0x0f;
cpu_stb_data_ra(env, dest + i, v, ra);
/* MVN always copies one more byte than specified - maximum is 256 */
l++;

srca1 = access_prepare(env, src, l, MMU_DATA_LOAD, mmu_idx, ra);
srca2 = access_prepare(env, dest, l, MMU_DATA_LOAD, mmu_idx, ra);
desta = access_prepare(env, dest, l, MMU_DATA_STORE, mmu_idx, ra);
for (i = 0; i < l; i++) {
const uint8_t x = (access_get_byte(env, &srca1, i, ra) & 0x0f) |
(access_get_byte(env, &srca2, i, ra) & 0xf0);

access_set_byte(env, &desta, i, x, ra);
}
}

Expand Down

0 comments on commit ab8bab6

Please sign in to comment.