提交 40a2e657 编写于 作者: T ths

Add option to disable TB cache, by Herve Poussineau.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3930 c046a42c-6fe2-441c-8c8c-71466251a162
上级 c304f7e2
...@@ -787,6 +787,20 @@ void cpu_set_log(int log_flags); ...@@ -787,6 +787,20 @@ void cpu_set_log(int log_flags);
void cpu_set_log_filename(const char *filename); void cpu_set_log_filename(const char *filename);
int cpu_str_to_log_mask(const char *str); int cpu_str_to_log_mask(const char *str);
#define CPU_SETTING_NO_CACHE (1 << 0)
/* define translation settings */
typedef struct CPUTranslationSetting {
int mask;
const char *name;
const char *help;
} CPUTranslationSetting;
extern CPUTranslationSetting cpu_translation_settings[];
void cpu_set_translation_settings(int translation_flags);
int cpu_str_to_translation_mask(const char *str);
/* IO ports API */ /* IO ports API */
/* NOTE: as these functions may be even used when there is an isa /* NOTE: as these functions may be even used when there is an isa
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include "exec.h" #include "exec.h"
#include "disas.h" #include "disas.h"
#include <string.h>
#if !defined(CONFIG_SOFTMMU) #if !defined(CONFIG_SOFTMMU)
#undef EAX #undef EAX
...@@ -40,6 +41,9 @@ int tb_invalidated_flag; ...@@ -40,6 +41,9 @@ int tb_invalidated_flag;
//#define DEBUG_EXEC //#define DEBUG_EXEC
//#define DEBUG_SIGNAL //#define DEBUG_SIGNAL
/* translation settings */
int translation_settings = 0;
#define SAVE_GLOBALS() #define SAVE_GLOBALS()
#define RESTORE_GLOBALS() #define RESTORE_GLOBALS()
...@@ -120,6 +124,56 @@ void cpu_resume_from_signal(CPUState *env1, void *puc) ...@@ -120,6 +124,56 @@ void cpu_resume_from_signal(CPUState *env1, void *puc)
longjmp(env->jmp_env, 1); longjmp(env->jmp_env, 1);
} }
CPUTranslationSetting cpu_translation_settings[] = {
{ CPU_SETTING_NO_CACHE, "no-cache",
"Do not use translation blocks cache (very slow!)" },
{ 0, NULL, NULL },
};
void cpu_set_translation_settings(int translation_flags)
{
translation_settings = translation_flags;
}
static int cmp1(const char *s1, int n, const char *s2)
{
if (strlen(s2) != n)
return 0;
return memcmp(s1, s2, n) == 0;
}
/* takes a comma separated list of translation settings. Return 0 if error. */
int cpu_str_to_translation_mask(const char *str)
{
CPUTranslationSetting *setting;
int mask;
const char *p, *p1;
p = str;
mask = 0;
for(;;) {
p1 = strchr(p, ',');
if (!p1)
p1 = p + strlen(p);
if(cmp1(p,p1-p,"all")) {
for(setting = cpu_translation_settings; setting->mask != 0; setting++) {
mask |= setting->mask;
}
} else {
for(setting = cpu_translation_settings; setting->mask != 0; setting++) {
if (cmp1(p, p1 - p, setting->name))
goto found;
}
return 0;
}
found:
mask |= setting->mask;
if (*p1 != ',')
break;
p = p1 + 1;
}
return mask;
}
static TranslationBlock *tb_find_slow(target_ulong pc, static TranslationBlock *tb_find_slow(target_ulong pc,
target_ulong cs_base, target_ulong cs_base,
...@@ -141,6 +195,9 @@ static TranslationBlock *tb_find_slow(target_ulong pc, ...@@ -141,6 +195,9 @@ static TranslationBlock *tb_find_slow(target_ulong pc,
phys_pc = get_phys_addr_code(env, pc); phys_pc = get_phys_addr_code(env, pc);
phys_page1 = phys_pc & TARGET_PAGE_MASK; phys_page1 = phys_pc & TARGET_PAGE_MASK;
phys_page2 = -1; phys_page2 = -1;
if (translation_settings & CPU_SETTING_NO_CACHE)
goto not_found;
h = tb_phys_hash_func(phys_pc); h = tb_phys_hash_func(phys_pc);
ptb1 = &tb_phys_hash[h]; ptb1 = &tb_phys_hash[h];
for(;;) { for(;;) {
...@@ -264,6 +321,9 @@ static inline TranslationBlock *tb_find_fast(void) ...@@ -264,6 +321,9 @@ static inline TranslationBlock *tb_find_fast(void)
#else #else
#error unsupported CPU #error unsupported CPU
#endif #endif
if (translation_settings & CPU_SETTING_NO_CACHE)
tb = NULL;
else
tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)]; tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
if (__builtin_expect(!tb || tb->pc != pc || tb->cs_base != cs_base || if (__builtin_expect(!tb || tb->pc != pc || tb->cs_base != cs_base ||
tb->flags != flags, 0)) { tb->flags != flags, 0)) {
......
...@@ -363,6 +363,17 @@ Set the initial date of the real time clock. Valid format for ...@@ -363,6 +363,17 @@ Set the initial date of the real time clock. Valid format for
@var{date} are: @code{now} or @code{2006-06-17T16:01:21} or @var{date} are: @code{now} or @code{2006-06-17T16:01:21} or
@code{2006-06-17}. The default value is @code{now}. @code{2006-06-17}. The default value is @code{now}.
@item -translation @var{setting1[,...]}
Select dynamic translation options @var{setting}, @code{-translation ?}
shows a list of settings. Valid settings are:
@table @code
@item @var{no-cache}
This option disables caching of translated code. Is useful for low-level
debugging of the emulated environment. This option incurs a massive
slow-down in emulation speed.
@end table
@item -pidfile @var{file} @item -pidfile @var{file}
Store the QEMU process PID in @var{file}. It is useful if you launch QEMU Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
from a script. from a script.
......
...@@ -240,6 +240,8 @@ static CPUState *cur_cpu; ...@@ -240,6 +240,8 @@ static CPUState *cur_cpu;
static CPUState *next_cpu; static CPUState *next_cpu;
static int event_pending = 1; static int event_pending = 1;
extern char *logfilename;
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
/***********************************************************/ /***********************************************************/
...@@ -7661,6 +7663,9 @@ static void help(int exitcode) ...@@ -7661,6 +7663,9 @@ static void help(int exitcode)
#endif #endif
"-clock force the use of the given methods for timer alarm.\n" "-clock force the use of the given methods for timer alarm.\n"
" To see what timers are available use -clock help\n" " To see what timers are available use -clock help\n"
"-startdate select initial date of the Qemu clock\n"
"-translation setting1,... configures code translation\n"
" (use -translation ? for a list of settings)\n"
"\n" "\n"
"During emulation, the following keys are useful:\n" "During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n" "ctrl-alt-f toggle full screen\n"
...@@ -7676,7 +7681,7 @@ static void help(int exitcode) ...@@ -7676,7 +7681,7 @@ static void help(int exitcode)
DEFAULT_NETWORK_DOWN_SCRIPT, DEFAULT_NETWORK_DOWN_SCRIPT,
#endif #endif
DEFAULT_GDBSTUB_PORT, DEFAULT_GDBSTUB_PORT,
"/tmp/qemu.log"); logfilename);
exit(exitcode); exit(exitcode);
} }
...@@ -7763,6 +7768,7 @@ enum { ...@@ -7763,6 +7768,7 @@ enum {
QEMU_OPTION_old_param, QEMU_OPTION_old_param,
QEMU_OPTION_clock, QEMU_OPTION_clock,
QEMU_OPTION_startdate, QEMU_OPTION_startdate,
QEMU_OPTION_translation,
}; };
typedef struct QEMUOption { typedef struct QEMUOption {
...@@ -7871,6 +7877,7 @@ const QEMUOption qemu_options[] = { ...@@ -7871,6 +7877,7 @@ const QEMUOption qemu_options[] = {
#endif #endif
{ "clock", HAS_ARG, QEMU_OPTION_clock }, { "clock", HAS_ARG, QEMU_OPTION_clock },
{ "startdate", HAS_ARG, QEMU_OPTION_startdate }, { "startdate", HAS_ARG, QEMU_OPTION_startdate },
{ "translation", HAS_ARG, QEMU_OPTION_translation },
{ NULL }, { NULL },
}; };
...@@ -8713,6 +8720,22 @@ int main(int argc, char **argv) ...@@ -8713,6 +8720,22 @@ int main(int argc, char **argv)
} }
} }
break; break;
case QEMU_OPTION_translation:
{
int mask;
CPUTranslationSetting *setting;
mask = cpu_str_to_translation_mask(optarg);
if (!mask) {
printf("Translation settings (comma separated):\n");
for(setting = cpu_translation_settings; setting->mask != 0; setting++) {
printf("%-10s %s\n", setting->name, setting->help);
}
exit(1);
}
cpu_set_translation_settings(mask);
}
break;
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册