accel/tcg: Add CF_NO_GOTO_TB and CF_NO_GOTO_PTR
Move the -d nochain check to bits on tb->cflags. These will be used for more than -d nochain shortly. Set bits during curr_cflags, test them in translator_use_goto_tb, assert we're not doing anything odd in tcg_gen_goto_tb. The test in tcg_gen_exit_tb is redundant with the assert for goto_tb_issue_mask. Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20210717221851.2124573-4-richard.henderson@linaro.org>
This commit is contained in:
		
							parent
							
								
									288a5fe980
								
							
						
					
					
						commit
						84f1561629
					
				@ -147,7 +147,13 @@ static void init_delay_params(SyncClocks *sc, const CPUState *cpu)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
uint32_t curr_cflags(CPUState *cpu)
 | 
					uint32_t curr_cflags(CPUState *cpu)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return cpu->tcg_cflags;
 | 
					    uint32_t cflags = cpu->tcg_cflags;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
 | 
				
			||||||
 | 
					        cflags |= CF_NO_GOTO_TB | CF_NO_GOTO_PTR;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return cflags;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Might cause an exception, so have a longjmp destination ready */
 | 
					/* Might cause an exception, so have a longjmp destination ready */
 | 
				
			||||||
 | 
				
			|||||||
@ -33,6 +33,11 @@ void translator_loop_temp_check(DisasContextBase *db)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
 | 
					bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /* Suppress goto_tb if requested. */
 | 
				
			||||||
 | 
					    if (tb_cflags(db->tb) & CF_NO_GOTO_TB) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Suppress goto_tb in the case of single-steping.  */
 | 
					    /* Suppress goto_tb in the case of single-steping.  */
 | 
				
			||||||
    if (db->singlestep_enabled || singlestep) {
 | 
					    if (db->singlestep_enabled || singlestep) {
 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
 | 
				
			|||||||
@ -494,13 +494,15 @@ struct TranslationBlock {
 | 
				
			|||||||
    uint32_t cflags;    /* compile flags */
 | 
					    uint32_t cflags;    /* compile flags */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Note that TCG_MAX_INSNS is 512; we validate this match elsewhere. */
 | 
					/* Note that TCG_MAX_INSNS is 512; we validate this match elsewhere. */
 | 
				
			||||||
#define CF_COUNT_MASK  0x000001ff
 | 
					#define CF_COUNT_MASK    0x000001ff
 | 
				
			||||||
#define CF_LAST_IO     0x00008000 /* Last insn may be an IO access.  */
 | 
					#define CF_NO_GOTO_TB    0x00000200 /* Do not chain with goto_tb */
 | 
				
			||||||
#define CF_MEMI_ONLY   0x00010000 /* Only instrument memory ops */
 | 
					#define CF_NO_GOTO_PTR   0x00000400 /* Do not chain with goto_ptr */
 | 
				
			||||||
#define CF_USE_ICOUNT  0x00020000
 | 
					#define CF_LAST_IO       0x00008000 /* Last insn may be an IO access.  */
 | 
				
			||||||
#define CF_INVALID     0x00040000 /* TB is stale. Set with @jmp_lock held */
 | 
					#define CF_MEMI_ONLY     0x00010000 /* Only instrument memory ops */
 | 
				
			||||||
#define CF_PARALLEL    0x00080000 /* Generate code for a parallel context */
 | 
					#define CF_USE_ICOUNT    0x00020000
 | 
				
			||||||
#define CF_CLUSTER_MASK 0xff000000 /* Top 8 bits are cluster ID */
 | 
					#define CF_INVALID       0x00040000 /* TB is stale. Set with @jmp_lock held */
 | 
				
			||||||
 | 
					#define CF_PARALLEL      0x00080000 /* Generate code for a parallel context */
 | 
				
			||||||
 | 
					#define CF_CLUSTER_MASK  0xff000000 /* Top 8 bits are cluster ID */
 | 
				
			||||||
#define CF_CLUSTER_SHIFT 24
 | 
					#define CF_CLUSTER_SHIFT 24
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Per-vCPU dynamic tracing state used to generate this TB */
 | 
					    /* Per-vCPU dynamic tracing state used to generate this TB */
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										28
									
								
								tcg/tcg-op.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								tcg/tcg-op.c
									
									
									
									
									
								
							@ -2723,10 +2723,6 @@ void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx)
 | 
				
			|||||||
           seen this numbered exit before, via tcg_gen_goto_tb.  */
 | 
					           seen this numbered exit before, via tcg_gen_goto_tb.  */
 | 
				
			||||||
        tcg_debug_assert(tcg_ctx->goto_tb_issue_mask & (1 << idx));
 | 
					        tcg_debug_assert(tcg_ctx->goto_tb_issue_mask & (1 << idx));
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        /* When not chaining, exit without indicating a link.  */
 | 
					 | 
				
			||||||
        if (qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
 | 
					 | 
				
			||||||
            val = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        /* This is an exit via the exitreq label.  */
 | 
					        /* This is an exit via the exitreq label.  */
 | 
				
			||||||
        tcg_debug_assert(idx == TB_EXIT_REQUESTED);
 | 
					        tcg_debug_assert(idx == TB_EXIT_REQUESTED);
 | 
				
			||||||
@ -2738,6 +2734,8 @@ void tcg_gen_exit_tb(const TranslationBlock *tb, unsigned idx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void tcg_gen_goto_tb(unsigned idx)
 | 
					void tcg_gen_goto_tb(unsigned idx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /* We tested CF_NO_GOTO_TB in translator_use_goto_tb. */
 | 
				
			||||||
 | 
					    tcg_debug_assert(!(tcg_ctx->tb_cflags & CF_NO_GOTO_TB));
 | 
				
			||||||
    /* We only support two chained exits.  */
 | 
					    /* We only support two chained exits.  */
 | 
				
			||||||
    tcg_debug_assert(idx <= TB_EXIT_IDXMAX);
 | 
					    tcg_debug_assert(idx <= TB_EXIT_IDXMAX);
 | 
				
			||||||
#ifdef CONFIG_DEBUG_TCG
 | 
					#ifdef CONFIG_DEBUG_TCG
 | 
				
			||||||
@ -2746,25 +2744,23 @@ void tcg_gen_goto_tb(unsigned idx)
 | 
				
			|||||||
    tcg_ctx->goto_tb_issue_mask |= 1 << idx;
 | 
					    tcg_ctx->goto_tb_issue_mask |= 1 << idx;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    plugin_gen_disable_mem_helpers();
 | 
					    plugin_gen_disable_mem_helpers();
 | 
				
			||||||
    /* When not chaining, we simply fall through to the "fallback" exit.  */
 | 
					    tcg_gen_op1i(INDEX_op_goto_tb, idx);
 | 
				
			||||||
    if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
 | 
					 | 
				
			||||||
        tcg_gen_op1i(INDEX_op_goto_tb, idx);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void tcg_gen_lookup_and_goto_ptr(void)
 | 
					void tcg_gen_lookup_and_goto_ptr(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
 | 
					    TCGv_ptr ptr;
 | 
				
			||||||
        TCGv_ptr ptr;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        plugin_gen_disable_mem_helpers();
 | 
					    if (tcg_ctx->tb_cflags & CF_NO_GOTO_PTR) {
 | 
				
			||||||
        ptr = tcg_temp_new_ptr();
 | 
					 | 
				
			||||||
        gen_helper_lookup_tb_ptr(ptr, cpu_env);
 | 
					 | 
				
			||||||
        tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr));
 | 
					 | 
				
			||||||
        tcg_temp_free_ptr(ptr);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
        tcg_gen_exit_tb(NULL, 0);
 | 
					        tcg_gen_exit_tb(NULL, 0);
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    plugin_gen_disable_mem_helpers();
 | 
				
			||||||
 | 
					    ptr = tcg_temp_new_ptr();
 | 
				
			||||||
 | 
					    gen_helper_lookup_tb_ptr(ptr, cpu_env);
 | 
				
			||||||
 | 
					    tcg_gen_op1i(INDEX_op_goto_ptr, tcgv_ptr_arg(ptr));
 | 
				
			||||||
 | 
					    tcg_temp_free_ptr(ptr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)
 | 
					static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user