cpu: Add CPUArchState pointer to CPUState
The target-specific ENV_GET_CPU() macros have allowed us to navigate from CPUArchState to CPUState. The reverse direction was not supported. Avoid introducing CPU_GET_ENV() macros by initializing an untyped pointer that is initialized in derived instance_init functions. The field may not be called "env" due to it being poisoned. Acked-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
907a5e32f2
commit
c05efcb18e
@ -71,6 +71,7 @@ struct kvm_run;
|
|||||||
* @created: Indicates whether the CPU thread has been successfully created.
|
* @created: Indicates whether the CPU thread has been successfully created.
|
||||||
* @stop: Indicates a pending stop request.
|
* @stop: Indicates a pending stop request.
|
||||||
* @stopped: Indicates the CPU has been artificially stopped.
|
* @stopped: Indicates the CPU has been artificially stopped.
|
||||||
|
* @env_ptr: Pointer to subclass-specific CPUArchState field.
|
||||||
* @current_tb: Currently executing TB.
|
* @current_tb: Currently executing TB.
|
||||||
* @kvm_fd: vCPU file descriptor for KVM.
|
* @kvm_fd: vCPU file descriptor for KVM.
|
||||||
*
|
*
|
||||||
@ -100,6 +101,7 @@ struct CPUState {
|
|||||||
bool stopped;
|
bool stopped;
|
||||||
volatile sig_atomic_t exit_request;
|
volatile sig_atomic_t exit_request;
|
||||||
|
|
||||||
|
void *env_ptr; /* CPUArchState */
|
||||||
struct TranslationBlock *current_tb;
|
struct TranslationBlock *current_tb;
|
||||||
|
|
||||||
int kvm_fd;
|
int kvm_fd;
|
||||||
|
@ -233,9 +233,11 @@ static const TypeInfo ev68_cpu_type_info = {
|
|||||||
|
|
||||||
static void alpha_cpu_initfn(Object *obj)
|
static void alpha_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
AlphaCPU *cpu = ALPHA_CPU(obj);
|
AlphaCPU *cpu = ALPHA_CPU(obj);
|
||||||
CPUAlphaState *env = &cpu->env;
|
CPUAlphaState *env = &cpu->env;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
tlb_flush(env, 1);
|
tlb_flush(env, 1);
|
||||||
|
|
||||||
|
@ -134,9 +134,11 @@ static inline void set_feature(CPUARMState *env, int feature)
|
|||||||
|
|
||||||
static void arm_cpu_initfn(Object *obj)
|
static void arm_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
ARMCPU *cpu = ARM_CPU(obj);
|
ARMCPU *cpu = ARM_CPU(obj);
|
||||||
static bool inited;
|
static bool inited;
|
||||||
|
|
||||||
|
cs->env_ptr = &cpu->env;
|
||||||
cpu_exec_init(&cpu->env);
|
cpu_exec_init(&cpu->env);
|
||||||
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
|
cpu->cp_regs = g_hash_table_new_full(g_int_hash, g_int_equal,
|
||||||
g_free, g_free);
|
g_free, g_free);
|
||||||
|
@ -146,11 +146,13 @@ static void cris_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void cris_cpu_initfn(Object *obj)
|
static void cris_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
CRISCPU *cpu = CRIS_CPU(obj);
|
CRISCPU *cpu = CRIS_CPU(obj);
|
||||||
CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj);
|
CRISCPUClass *ccc = CRIS_CPU_GET_CLASS(obj);
|
||||||
CPUCRISState *env = &cpu->env;
|
CPUCRISState *env = &cpu->env;
|
||||||
static bool tcg_initialized;
|
static bool tcg_initialized;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
env->pregs[PR_VR] = ccc->vr;
|
env->pregs[PR_VR] = ccc->vr;
|
||||||
|
@ -2164,6 +2164,7 @@ static void x86_cpu_initfn(Object *obj)
|
|||||||
CPUX86State *env = &cpu->env;
|
CPUX86State *env = &cpu->env;
|
||||||
static int inited;
|
static int inited;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
object_property_add(obj, "family", "int",
|
object_property_add(obj, "family", "int",
|
||||||
|
@ -56,10 +56,12 @@ static void lm32_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void lm32_cpu_initfn(Object *obj)
|
static void lm32_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
LM32CPU *cpu = LM32_CPU(obj);
|
LM32CPU *cpu = LM32_CPU(obj);
|
||||||
CPULM32State *env = &cpu->env;
|
CPULM32State *env = &cpu->env;
|
||||||
static bool tcg_initialized;
|
static bool tcg_initialized;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
env->flags = 0;
|
env->flags = 0;
|
||||||
|
@ -154,10 +154,12 @@ static void m68k_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void m68k_cpu_initfn(Object *obj)
|
static void m68k_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
M68kCPU *cpu = M68K_CPU(obj);
|
M68kCPU *cpu = M68K_CPU(obj);
|
||||||
CPUM68KState *env = &cpu->env;
|
CPUM68KState *env = &cpu->env;
|
||||||
static bool inited;
|
static bool inited;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
if (tcg_enabled() && !inited) {
|
if (tcg_enabled() && !inited) {
|
||||||
|
@ -98,10 +98,12 @@ static void mb_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void mb_cpu_initfn(Object *obj)
|
static void mb_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj);
|
MicroBlazeCPU *cpu = MICROBLAZE_CPU(obj);
|
||||||
CPUMBState *env = &cpu->env;
|
CPUMBState *env = &cpu->env;
|
||||||
static bool tcg_initialized;
|
static bool tcg_initialized;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
|
set_float_rounding_mode(float_round_nearest_even, &env->fp_status);
|
||||||
|
@ -55,9 +55,11 @@ static void mips_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void mips_cpu_initfn(Object *obj)
|
static void mips_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
MIPSCPU *cpu = MIPS_CPU(obj);
|
MIPSCPU *cpu = MIPS_CPU(obj);
|
||||||
CPUMIPSState *env = &cpu->env;
|
CPUMIPSState *env = &cpu->env;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
if (tcg_enabled()) {
|
if (tcg_enabled()) {
|
||||||
|
@ -75,9 +75,11 @@ static void openrisc_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void openrisc_cpu_initfn(Object *obj)
|
static void openrisc_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
OpenRISCCPU *cpu = OPENRISC_CPU(obj);
|
OpenRISCCPU *cpu = OPENRISC_CPU(obj);
|
||||||
static int inited;
|
static int inited;
|
||||||
|
|
||||||
|
cs->env_ptr = &cpu->env;
|
||||||
cpu_exec_init(&cpu->env);
|
cpu_exec_init(&cpu->env);
|
||||||
|
|
||||||
#ifndef CONFIG_USER_ONLY
|
#ifndef CONFIG_USER_ONLY
|
||||||
|
@ -10529,11 +10529,13 @@ static void ppc_cpu_reset(CPUState *s)
|
|||||||
|
|
||||||
static void ppc_cpu_initfn(Object *obj)
|
static void ppc_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
PowerPCCPU *cpu = POWERPC_CPU(obj);
|
PowerPCCPU *cpu = POWERPC_CPU(obj);
|
||||||
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
|
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
ppc_def_t *def = pcc->info;
|
ppc_def_t *def = pcc->info;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
env->msr_mask = def->msr_mask;
|
env->msr_mask = def->msr_mask;
|
||||||
|
@ -110,6 +110,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void s390_cpu_initfn(Object *obj)
|
static void s390_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
S390CPU *cpu = S390_CPU(obj);
|
S390CPU *cpu = S390_CPU(obj);
|
||||||
CPUS390XState *env = &cpu->env;
|
CPUS390XState *env = &cpu->env;
|
||||||
static bool inited;
|
static bool inited;
|
||||||
@ -118,6 +119,7 @@ static void s390_cpu_initfn(Object *obj)
|
|||||||
struct tm tm;
|
struct tm tm;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
#if !defined(CONFIG_USER_ONLY)
|
#if !defined(CONFIG_USER_ONLY)
|
||||||
qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
|
qemu_register_reset(s390_cpu_machine_reset_cb, cpu);
|
||||||
|
@ -67,9 +67,11 @@ static void superh_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void superh_cpu_initfn(Object *obj)
|
static void superh_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
SuperHCPU *cpu = SUPERH_CPU(obj);
|
SuperHCPU *cpu = SUPERH_CPU(obj);
|
||||||
CPUSH4State *env = &cpu->env;
|
CPUSH4State *env = &cpu->env;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
env->movcal_backup_tail = &(env->movcal_backup);
|
env->movcal_backup_tail = &(env->movcal_backup);
|
||||||
|
@ -860,9 +860,11 @@ static void sparc_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void sparc_cpu_initfn(Object *obj)
|
static void sparc_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
SPARCCPU *cpu = SPARC_CPU(obj);
|
SPARCCPU *cpu = SPARC_CPU(obj);
|
||||||
CPUSPARCState *env = &cpu->env;
|
CPUSPARCState *env = &cpu->env;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
if (tcg_enabled()) {
|
if (tcg_enabled()) {
|
||||||
|
@ -93,10 +93,12 @@ static void uc32_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void uc32_cpu_initfn(Object *obj)
|
static void uc32_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
UniCore32CPU *cpu = UNICORE32_CPU(obj);
|
UniCore32CPU *cpu = UNICORE32_CPU(obj);
|
||||||
CPUUniCore32State *env = &cpu->env;
|
CPUUniCore32State *env = &cpu->env;
|
||||||
static bool inited;
|
static bool inited;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
#ifdef CONFIG_USER_ONLY
|
#ifdef CONFIG_USER_ONLY
|
||||||
|
@ -69,10 +69,12 @@ static void xtensa_cpu_realizefn(DeviceState *dev, Error **errp)
|
|||||||
|
|
||||||
static void xtensa_cpu_initfn(Object *obj)
|
static void xtensa_cpu_initfn(Object *obj)
|
||||||
{
|
{
|
||||||
|
CPUState *cs = CPU(obj);
|
||||||
XtensaCPU *cpu = XTENSA_CPU(obj);
|
XtensaCPU *cpu = XTENSA_CPU(obj);
|
||||||
CPUXtensaState *env = &cpu->env;
|
CPUXtensaState *env = &cpu->env;
|
||||||
static bool tcg_inited;
|
static bool tcg_inited;
|
||||||
|
|
||||||
|
cs->env_ptr = env;
|
||||||
cpu_exec_init(env);
|
cpu_exec_init(env);
|
||||||
|
|
||||||
if (tcg_enabled() && !tcg_inited) {
|
if (tcg_enabled() && !tcg_inited) {
|
||||||
|
Loading…
Reference in New Issue
Block a user