From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5AoN-0004aB-IV for qemu-devel@nongnu.org; Wed, 17 Jun 2015 06:43:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5AoK-0005WN-DO for qemu-devel@nongnu.org; Wed, 17 Jun 2015 06:43:15 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52305 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5AoK-0005VT-4d for qemu-devel@nongnu.org; Wed, 17 Jun 2015 06:43:12 -0400 From: Alexander Graf Date: Wed, 17 Jun 2015 12:42:55 +0200 Message-Id: <1434537789-63782-13-git-send-email-agraf@suse.de> In-Reply-To: <1434537789-63782-1-git-send-email-agraf@suse.de> References: <1434537789-63782-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PULL 12/26] target-s390x: function to adjust the length wrt page boundary List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Aurelien Jarno From: Aurelien Jarno This patch adds a function to adjust the length of a transfer so that it doesn't cross a page boundary in softmmu mode. It does nothing in user mode. Signed-off-by: Aurelien Jarno Signed-off-by: Alexander Graf --- target-s390x/mem_helper.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index b4e5d44..b8d3a5f 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -54,6 +54,17 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx, #define HELPER_LOG(x...) #endif +/* 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) +{ +#ifndef CONFIG_USER_ONLY + if ((addr & ~TARGET_PAGE_MASK) + len - 1 >= TARGET_PAGE_SIZE) { + return -addr & ~TARGET_PAGE_MASK; + } +#endif + return len; +} + #ifndef CONFIG_USER_ONLY static void mvc_fast_memset(CPUS390XState *env, uint32_t l, uint64_t dest, uint8_t byte) -- 1.7.12.4