From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2ILM-0008AH-MV for qemu-devel@nongnu.org; Mon, 16 May 2016 09:13:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2ILI-0001YG-DU for qemu-devel@nongnu.org; Mon, 16 May 2016 09:13:55 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:34397) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2ILH-0001YA-6a for qemu-devel@nongnu.org; Mon, 16 May 2016 09:13:52 -0400 Received: by mail-lf0-x229.google.com with SMTP id m64so116320119lfd.1 for ; Mon, 16 May 2016 06:13:50 -0700 (PDT) From: Sergey Fedorov Date: Mon, 16 May 2016 16:13:00 +0300 Message-Id: <1463404380-29302-1-git-send-email-sergey.fedorov@linaro.org> Subject: [Qemu-devel] [PATCH] cpu-exec: Fix direct jump to TB spanning page List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Sergey Fedorov , Sergey Fedorov , Paolo Bonzini , Peter Crosthwaite , Richard Henderson From: Sergey Fedorov It is not safe to make a direct jump to a TB spanning two pages in system emulation because the mapping for the second page can get changed but we don't take care of direct jumps in this case. However in user mode emulation, this is not the case because there's only static address translation and TBs are always invalidated properly. Fixes: 5b053a4a2827 ("tcg: Clean up direct block chaining safety checks") Reported-by: Max Filippov Signed-off-by: Sergey Fedorov Signed-off-by: Sergey Fedorov --- cpu-exec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpu-exec.c b/cpu-exec.c index 14df1aacf42a..ec2364df624d 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -344,6 +344,15 @@ static inline TranslationBlock *tb_find_fast(CPUState *cpu, *last_tb = NULL; cpu->tb_flushed = false; } +#ifndef CONFIG_USER_ONLY + /* We don't take care of direct jumps when address mapping changes in + * system emulation. So it's not safe to make a direct jump to a TB + * spanning two pages because the mapping for the second page can change. + */ + if (tb->page_addr[1] != -1) { + *last_tb = NULL; + } +#endif /* See if we can patch the calling TB. */ if (*last_tb && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { tb_add_jump(*last_tb, tb_exit, tb); -- 1.9.1