mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-02-01 23:21:08 +00:00
i386: keep cpu_model field in MachineState uptodate
Considering that features are converted to global properties and global properties are automatically applied to every new instance of created CPU (at object_new() time), there is no point in parsing cpu_model string every time a CPU created. So move parsing outside CPU creation loop and do it only once. Parsing also should be done before any CPU is created so that features would affect the first CPU a well. Backports commit 6aff24c6a61c6fec31e555c7748ba6085b7b2c06 from qemu
This commit is contained in:
parent
8344a5a63c
commit
9c5153270f
|
@ -116,7 +116,7 @@ static X86CPU *pc_new_cpu(struct uc_struct *uc, const char *typename, int64_t ap
|
|||
return cpu;
|
||||
}
|
||||
|
||||
int pc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
||||
int pc_cpus_init(struct uc_struct *uc, PCMachineState *pcms)
|
||||
{
|
||||
int i;
|
||||
CPUClass *cc;
|
||||
|
@ -124,13 +124,14 @@ int pc_cpus_init(struct uc_struct *uc, const char *cpu_model)
|
|||
const char *typename;
|
||||
gchar **model_pieces;
|
||||
Error *error = NULL;
|
||||
MachineState *machine = MACHINE(uc, pcms);
|
||||
|
||||
/* init CPUs */
|
||||
if (cpu_model == NULL) {
|
||||
if (machine->cpu_model == NULL) {
|
||||
#ifdef TARGET_X86_64
|
||||
cpu_model = "qemu64";
|
||||
machine->cpu_model = "qemu64";
|
||||
#else
|
||||
cpu_model = "qemu32";
|
||||
machine->cpu_model = "qemu32";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
/* PC hardware initialisation */
|
||||
static int pc_init1(struct uc_struct *uc, MachineState *machine)
|
||||
{
|
||||
return pc_cpus_init(uc, machine->cpu_model);
|
||||
PCMachineState *pcms = PC_MACHINE(uc, machine);
|
||||
return pc_cpus_init(uc, pcms);
|
||||
}
|
||||
|
||||
static void pc_compat_2_2(struct uc_struct *uc, MachineState *machine)
|
||||
|
|
|
@ -32,7 +32,7 @@ struct PCMachineClass {
|
|||
#define PC_MACHINE_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(PCMachineClass, (klass), TYPE_PC_MACHINE)
|
||||
|
||||
int pc_cpus_init(struct uc_struct *uc, const char *cpu_model);
|
||||
int pc_cpus_init(struct uc_struct *uc, PCMachineState *pcms);
|
||||
|
||||
FWCfgState *pc_memory_init(MachineState *machine,
|
||||
MemoryRegion *system_memory,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "qemu/osdep.h"
|
||||
#include "qemu/cutils.h"
|
||||
#include "unicorn/platform.h"
|
||||
#include "uc_priv.h"
|
||||
|
||||
#include "cpu.h"
|
||||
#include "exec/exec-all.h"
|
||||
|
|
|
@ -1211,7 +1211,6 @@ typedef struct CPUX86State {
|
|||
|
||||
// Unicorn engine
|
||||
struct uc_struct *uc;
|
||||
bool cpu_globals_initialized;
|
||||
} CPUX86State;
|
||||
|
||||
/**
|
||||
|
@ -1298,6 +1297,9 @@ typedef struct X86CPU {
|
|||
FeatureWordArray plus_features;
|
||||
/* Features to be removed */
|
||||
FeatureWordArray minus_features;
|
||||
|
||||
// Unicorn: Moved here to prevent a local static
|
||||
bool cpu_globals_initialized;
|
||||
} X86CPU;
|
||||
|
||||
static inline X86CPU *x86_env_get_cpu(CPUX86State *env)
|
||||
|
|
Loading…
Reference in a new issue