Skip to content
Snippets Groups Projects
  1. Jun 05, 2015
  2. Jun 04, 2015
    • Alexander Graf's avatar
      target-s390x: Only access allocated storage keys · 9814fed0
      Alexander Graf authored
      
      We allocate ram_size / PAGE_SIZE storage keys, so we need to make sure that
      we only access that many. Unfortunately the code can overrun this array by
      one, potentially overwriting unrelated memory.
      
      Fix it by limiting storage keys to their scope.
      
      Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
      Reviewed-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      9814fed0
    • Aurelien Jarno's avatar
      target-s390x: fix MVC instruction when areas overlap · 068593de
      Aurelien Jarno authored
      
      The MVC instruction and the memmove C funtion do not have the same
      semantic when memory areas overlap:
      
      MVC: When the operands overlap, the result is obtained as if the
      operands were processed one byte at a time and each result byte were
      stored immediately after fetching the necessary operand byte.
      
      memmove: Copying takes place as though the bytes in src are first copied
      into a temporary array that does not overlap src or dest, and the bytes
      are then copied from the temporary array to dest.
      
      The behaviour is therefore the same when the destination is at a lower
      address than the source, but not in the other case. This is actually a
      trick for propagating a value to an area. While the current code detects
      that and call memset in that case, it only does for 1-byte value. This
      trick can and is used for propagating two or more bytes to an area.
      
      In the softmmu case, the call to mvc_fast_memmove is correct as the
      above tests verify that source and destination are each within a page,
      and both in a different page. The part doing the move 8 bytes by 8 bytes
      is wrong and we need to check that if the source and destination
      overlap, they do with a distance of minimum 8 bytes before copying 8
      bytes at a time.
      
      In the user code, we should check check that the destination is at a
      lower address than source or than the end of the source is at a lower
      address than the destination before calling memmove. In the opposite
      case we fallback to the same code as the softmmu one. Note that l
      represents (length - 1).
      
      Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
      068593de
    • Aurelien Jarno's avatar
      target-s390x: use softmmu functions for mvcp/mvcs · a3084e80
      Aurelien Jarno authored
      
      mvcp and mvcs helper get access to the physical memory by a call to
      mmu_translate for the virtual to real conversion and then using ldb_phys
      and stb_phys to physically access the data. In practice this is quite
      slow because it bypasses the QEMU softmmu TLB and because stb_phys calls
      try to invalidate the corresponding memory for each access.
      
      Instead use cpu_ldb_{primary,secondary} for the loads and
      cpu_stb_{primary,secondary} for the stores. Ideally this should be
      further optimized by a call to memcpy, but that already improves the
      boot time of a guest by a factor 1.8.
      
      Signed-off-by: default avatarAurelien Jarno <aurelien@aurel32.net>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
      a3084e80
Loading