tcg: add options for enabling MTTCG

We know there will be cases where MTTCG won't work until additional work
is done in the front/back ends to support. It will however be useful to
be able to turn it on.

As a result MTTCG will default to off unless the combination is
supported. However the user can turn it on for the sake of testing.

Backports commit 8d4e9146b3568022ea5730d92841345d41275d66 from qemu
This commit is contained in:
KONRAD Frederic 2018-03-02 09:17:49 -05:00 committed by Lioncash
parent 8c89344517
commit c5730ff194
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
20 changed files with 51 additions and 0 deletions

View file

@ -175,6 +175,9 @@ struct uc_struct {
uc_insn_hook_validate insn_hook_validate;
// qemu/cpus.c
bool mttcg_enabled;
// qemu/exec.c
MemoryRegion *system_memory;
MemoryRegion io_mem_rom;

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_aarch64
#define qemu_strnlen qemu_strnlen_aarch64
#define qemu_strsep qemu_strsep_aarch64
#define qemu_tcg_configure qemu_tcg_configure_aarch64
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_aarch64
#define qemu_try_memalign qemu_try_memalign_aarch64
#define qentry_destroy qentry_destroy_aarch64

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_aarch64eb
#define qemu_strnlen qemu_strnlen_aarch64eb
#define qemu_strsep qemu_strsep_aarch64eb
#define qemu_tcg_configure qemu_tcg_configure_aarch64eb
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_aarch64eb
#define qemu_try_memalign qemu_try_memalign_aarch64eb
#define qentry_destroy qentry_destroy_aarch64eb

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_arm
#define qemu_strnlen qemu_strnlen_arm
#define qemu_strsep qemu_strsep_arm
#define qemu_tcg_configure qemu_tcg_configure_arm
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_arm
#define qemu_try_memalign qemu_try_memalign_arm
#define qentry_destroy qentry_destroy_arm

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_armeb
#define qemu_strnlen qemu_strnlen_armeb
#define qemu_strsep qemu_strsep_armeb
#define qemu_tcg_configure qemu_tcg_configure_armeb
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_armeb
#define qemu_try_memalign qemu_try_memalign_armeb
#define qentry_destroy qentry_destroy_armeb

View file

@ -31,6 +31,7 @@
#include "sysemu/sysemu.h"
#include "exec/exec-all.h"
#include "tcg.h"
#include "qemu/thread.h"
#include "sysemu/cpus.h"
@ -45,6 +46,17 @@ static bool tcg_exec_all(struct uc_struct* uc);
static int qemu_tcg_init_vcpu(CPUState *cpu);
static void *qemu_tcg_cpu_loop(struct uc_struct *uc);
static bool default_mttcg_enabled(void)
{
return false;
}
void qemu_tcg_configure(struct uc_struct *uc)
{
uc->mttcg_enabled = default_mttcg_enabled();
}
int vm_start(struct uc_struct* uc)
{
if (resume_all_vcpus(uc)) {

View file

@ -2671,6 +2671,7 @@ symbols = (
'qemu_st_helpers',
'qemu_strnlen',
'qemu_strsep',
'qemu_tcg_configure',
'qemu_tcg_init_vcpu',
'qemu_try_memalign',
'qentry_destroy',

View file

@ -328,6 +328,14 @@ struct CPUState {
struct uc_struct* uc;
};
/**
* qemu_tcg_mttcg_enabled:
* Check whether we are running MultiThread TCG or not.
*
* Returns: %true if we are in MTTCG mode %false otherwise.
*/
extern bool mttcg_enabled;
#define qemu_tcg_mttcg_enabled() (mttcg_enabled)
/**
* cpu_paging_enabled:

View file

@ -17,4 +17,6 @@ extern int smp_threads;
#define smp_threads 1
#endif
void qemu_tcg_configure(struct uc_struct *uc);
#endif

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_m68k
#define qemu_strnlen qemu_strnlen_m68k
#define qemu_strsep qemu_strsep_m68k
#define qemu_tcg_configure qemu_tcg_configure_m68k
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_m68k
#define qemu_try_memalign qemu_try_memalign_m68k
#define qentry_destroy qentry_destroy_m68k

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_mips
#define qemu_strnlen qemu_strnlen_mips
#define qemu_strsep qemu_strsep_mips
#define qemu_tcg_configure qemu_tcg_configure_mips
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_mips
#define qemu_try_memalign qemu_try_memalign_mips
#define qentry_destroy qentry_destroy_mips

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_mips64
#define qemu_strnlen qemu_strnlen_mips64
#define qemu_strsep qemu_strsep_mips64
#define qemu_tcg_configure qemu_tcg_configure_mips64
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_mips64
#define qemu_try_memalign qemu_try_memalign_mips64
#define qentry_destroy qentry_destroy_mips64

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_mips64el
#define qemu_strnlen qemu_strnlen_mips64el
#define qemu_strsep qemu_strsep_mips64el
#define qemu_tcg_configure qemu_tcg_configure_mips64el
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_mips64el
#define qemu_try_memalign qemu_try_memalign_mips64el
#define qentry_destroy qentry_destroy_mips64el

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_mipsel
#define qemu_strnlen qemu_strnlen_mipsel
#define qemu_strsep qemu_strsep_mipsel
#define qemu_tcg_configure qemu_tcg_configure_mipsel
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_mipsel
#define qemu_try_memalign qemu_try_memalign_mipsel
#define qentry_destroy qentry_destroy_mipsel

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_powerpc
#define qemu_strnlen qemu_strnlen_powerpc
#define qemu_strsep qemu_strsep_powerpc
#define qemu_tcg_configure qemu_tcg_configure_powerpc
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_powerpc
#define qemu_try_memalign qemu_try_memalign_powerpc
#define qentry_destroy qentry_destroy_powerpc

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_sparc
#define qemu_strnlen qemu_strnlen_sparc
#define qemu_strsep qemu_strsep_sparc
#define qemu_tcg_configure qemu_tcg_configure_sparc
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_sparc
#define qemu_try_memalign qemu_try_memalign_sparc
#define qentry_destroy qentry_destroy_sparc

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_sparc64
#define qemu_strnlen qemu_strnlen_sparc64
#define qemu_strsep qemu_strsep_sparc64
#define qemu_tcg_configure qemu_tcg_configure_sparc64
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_sparc64
#define qemu_try_memalign qemu_try_memalign_sparc64
#define qentry_destroy qentry_destroy_sparc64

View file

@ -83,6 +83,15 @@ typedef uint64_t tcg_target_ulong;
#error unsupported
#endif
/* Oversized TCG guests make things like MTTCG hard
* as we can't use atomics for cputlb updates.
*/
#if TARGET_LONG_BITS > TCG_TARGET_REG_BITS
#define TCG_OVERSIZED_GUEST 1
#else
#define TCG_OVERSIZED_GUEST 0
#endif
#if TCG_TARGET_NB_REGS <= 32
typedef uint32_t TCGRegSet;
#elif TCG_TARGET_NB_REGS <= 64

View file

@ -137,6 +137,9 @@ int machine_initialize(struct uc_struct *uc)
uc->machine_state = current_machine;
current_machine->uc = uc;
// Unicorn: FIXME: ditto with regards to below
//qemu_tcg_configure(uc);
// Unicorn: FIXME: this should be uncommented
// However due to the "stellar" way unicorn
// handles multiple targets (e.g. the YOLO

View file

@ -2665,6 +2665,7 @@
#define qemu_st_helpers qemu_st_helpers_x86_64
#define qemu_strnlen qemu_strnlen_x86_64
#define qemu_strsep qemu_strsep_x86_64
#define qemu_tcg_configure qemu_tcg_configure_x86_64
#define qemu_tcg_init_vcpu qemu_tcg_init_vcpu_x86_64
#define qemu_try_memalign qemu_try_memalign_x86_64
#define qentry_destroy qentry_destroy_x86_64