Skip to content

Commit

Permalink
accel/tcg: Introduce translator_use_goto_tb
Browse files Browse the repository at this point in the history
Add a generic version of the common use_goto_tb test.

Various targets avoid the page crossing test for CONFIG_USER_ONLY,
but that is wrong: mmap and mprotect can change page permissions.

Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jul 9, 2021
1 parent a439064 commit d3a2a1d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions accel/tcg/translator.c
Expand Up @@ -31,6 +31,17 @@ void translator_loop_temp_check(DisasContextBase *db)
}
}

bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest)
{
/* Suppress goto_tb in the case of single-steping. */
if (db->singlestep_enabled || singlestep) {
return false;
}

/* Check for the dest on the same page as the start of the TB. */
return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0;
}

void translator_loop(const TranslatorOps *ops, DisasContextBase *db,
CPUState *cpu, TranslationBlock *tb, int max_insns)
{
Expand Down
10 changes: 10 additions & 0 deletions include/exec/translator.h
Expand Up @@ -145,6 +145,16 @@ void translator_loop(const TranslatorOps *ops, DisasContextBase *db,

void translator_loop_temp_check(DisasContextBase *db);

/**
* translator_use_goto_tb
* @db: Disassembly context
* @dest: target pc of the goto
*
* Return true if goto_tb is allowed between the current TB
* and the destination PC.
*/
bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest);

/*
* Translator Load Functions
*
Expand Down

0 comments on commit d3a2a1d

Please sign in to comment.