target/s390x: fix adj_len_to_page
authorAurelien Jarno <aurelien@aurel32.net>
Wed, 31 May 2017 22:01:18 +0000 (00:01 +0200)
committerRichard Henderson <rth@twiddle.net>
Tue, 6 Jun 2017 22:20:43 +0000 (15:20 -0700)
adj_len_to_page doesn't return the correct result when the address
is already page aligned and the length is bigger than a page. Fix that.

Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Message-Id: <20170531220129.27724-20-aurelien@aurel32.net>
Signed-off-by: Richard Henderson <rth@twiddle.net>
target/s390x/mem_helper.c

index 4ed0b65751e354367274a92c1a203e44ebec2f2b..2326f0bdb9046d97bfba9e134701c9c74d41a7fd 100644 (file)
@@ -61,7 +61,7 @@ static inline uint32_t adj_len_to_page(uint32_t len, uint64_t addr)
 {
 #ifndef CONFIG_USER_ONLY
     if ((addr & ~TARGET_PAGE_MASK) + len - 1 >= TARGET_PAGE_SIZE) {
-        return -addr & ~TARGET_PAGE_MASK;
+        return -(addr | TARGET_PAGE_MASK);
     }
 #endif
     return len;