mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-18 14:57:12 +00:00
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:
parent
8c89344517
commit
c5730ff194
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
12
qemu/cpus.c
12
qemu/cpus.c
|
@ -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)) {
|
||||
|
|
|
@ -2671,6 +2671,7 @@ symbols = (
|
|||
'qemu_st_helpers',
|
||||
'qemu_strnlen',
|
||||
'qemu_strsep',
|
||||
'qemu_tcg_configure',
|
||||
'qemu_tcg_init_vcpu',
|
||||
'qemu_try_memalign',
|
||||
'qentry_destroy',
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -17,4 +17,6 @@ extern int smp_threads;
|
|||
#define smp_threads 1
|
||||
#endif
|
||||
|
||||
void qemu_tcg_configure(struct uc_struct *uc);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue