From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50717) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atGnj-0000uT-SD for qemu-devel@nongnu.org; Thu, 21 Apr 2016 11:45:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atGne-0002M3-Qt for qemu-devel@nongnu.org; Thu, 21 Apr 2016 11:45:55 -0400 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:37430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atGne-0002Lp-AB for qemu-devel@nongnu.org; Thu, 21 Apr 2016 11:45:50 -0400 Received: by mail-wm0-x230.google.com with SMTP id n3so140112789wmn.0 for ; Thu, 21 Apr 2016 08:45:50 -0700 (PDT) References: <1461186921-14977-1-git-send-email-sergey.fedorov@linaro.org> <1461186921-14977-10-git-send-email-sergey.fedorov@linaro.org> <87y487t80x.fsf@linaro.org> <5718ED04.5080403@gmail.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <5718ED04.5080403@gmail.com> Date: Thu, 21 Apr 2016 16:45:47 +0100 Message-ID: <87vb3bt178.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v4 09/10] tcg: Clean up direct block chaining safety checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov Cc: Sergey Fedorov , qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite , Richard Henderson , Peter Maydell , "Edgar E. Iglesias" , Eduardo Habkost , Alexander Graf , qemu-arm@nongnu.org Sergey Fedorov writes: > On 21/04/16 16:18, Alex Bennée wrote: >> Sergey Fedorov writes: >>> diff --git a/cpu-exec.c b/cpu-exec.c >>> index bbfcbfb54385..065cc9159477 100644 >>> --- a/cpu-exec.c >>> +++ b/cpu-exec.c >>> @@ -508,11 +508,8 @@ int cpu_exec(CPUState *cpu) >>> next_tb = 0; >>> tcg_ctx.tb_ctx.tb_invalidated_flag = 0; >>> } >>> - /* see if we can patch the calling TB. When the TB >>> - spans two pages, we cannot safely do a direct >>> - jump. */ >>> - if (next_tb != 0 && tb->page_addr[1] == -1 >>> - && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { >>> + /* See if we can patch the calling TB. */ >>> + if (next_tb != 0 && >>> !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) { >> A pointer to the definitive comment helps ;-) >> >> /* See if we can patch the calling TB, see tcg_gen_goto_tb */ > > I'm not so sure that the comment for tcg_gen_goto_tb() would be of much > use here. Actually, what we check here is if we know the calling TB > (what is called 'next_tb' here so far) and if logging settings don't > forbid us to chain TBs. The note in the comment for tcg_gen_goto_tb() is > all about when goto_tb TCG ops can be emitted by the target translation > code, not so relevant here, I suppose. True, it makes more sense on the following patches. It's not a major thing. > > Kind regards, > Sergey > >> >>> tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK), >>> next_tb & TB_EXIT_MASK, tb); >>> } > (snip) >>> diff --git a/tcg/tcg-op.h b/tcg/tcg-op.h >>> index c446d3dc7293..ace39619ef89 100644 >>> --- a/tcg/tcg-op.h >>> +++ b/tcg/tcg-op.h >>> @@ -753,6 +753,16 @@ static inline void tcg_gen_exit_tb(uintptr_t val) >>> tcg_gen_op1i(INDEX_op_exit_tb, val); >>> } >>> >>> +/** >>> + * tcg_gen_goto_tb() - output goto_tb TCG operation >>> + * @idx: Direct jump slot index (0 or 1) >>> + * >>> + * See tcg/README for more info about this TCG operation. >>> + * >>> + * NOTE: Direct jumps with goto_tb are only safe within the pages this TB >>> + * resides in because we don't take care of direct jumps when address mapping >>> + * changes, e.g. in tlb_flush(). >>> + */ >>> void tcg_gen_goto_tb(unsigned idx); >>> >>> #if TARGET_LONG_BITS == 32 -- Alex Bennée