cpu: Make cpu_init() return QOM object
cover cpu: Make cpu_init() return QOM object
This series changes cpu_init() to return a CPU QOM object, and changes existing arch-specific code to use the corresponding arch-specific function instead of cpu_init().
With this, the only remaining users of cpu_init() are linux-user and bsd-user.
Eduardo Habkost (4):
target-unicore32: Make uc32_cpu_init() return UniCore32CPU
m68k: Use cpu_m68k_init()
unicore32: Use uc32_cpu_init()
cpu: Make cpu_init() return QOM object
bsd-user/main.c | 6 +++--- hw/m68k/dummy_m68k.c | 6 ++++-- hw/unicore32/puv3.c | 6 ++++-- linux-user/main.c | 6 +++--- target-alpha/cpu.h | 9 +-------- target-arm/cpu.h | 9 +-------- target-cris/cpu.h | 9 +-------- target-i386/cpu.h | 9 +-------- target-lm32/cpu.h | 9 +-------- target-m68k/cpu.h | 9 +-------- target-microblaze/cpu.h | 9 +-------- target-mips/cpu.h | 9 +-------- target-moxie/cpu.h | 9 +-------- target-openrisc/cpu.h | 9 +-------- target-ppc/cpu.h | 9 +-------- target-s390x/cpu.h | 2 +- target-sh4/cpu.h | 9 +-------- target-sparc/cpu.h | 9 +-------- target-tricore/cpu.h | 10 +--------- target-unicore32/cpu.h | 6 ++++-- target-unicore32/helper.c | 10 ++-------- target-xtensa/cpu.h | 9 +-------- 22 files changed, 36 insertions(+), 142 deletions(-)
Signature · 1 line
2.1.0
PATCH 1/4 target-unicore32: Make uc32_cpu_init() return UniCore32CPU
This way, the cpu_init() function in target-unicore32 will follow the same pattern used on all other architectures.
--- target-unicore32/cpu.h | 14 ++++++++++++-- target-unicore32/helper.c | 10 ++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
target-unicore32/cpu.h +12 -2
@@ -122,11 +122,9 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)#define UC32_HWCAP_CMOV 4/* 1 << 2 */ #define UC32_HWCAP_UCF64 8/* 1 << 3 */ -#define cpu_init uc32_cpu_init#define cpu_exec uc32_cpu_exec#define cpu_signal_handler uc32_cpu_signal_handler -CPUUniCore32State *uc32_cpu_init (const char *cpu_model);int uc32_cpu_exec (CPUUniCore32State *s);int uc32_cpu_signal_handler (int host_signum,void *pinfo,void *puc);
@@ -143,6 +141,18 @@ static inline int cpu_mmu_index(CPUUniCore32State *env)#include "cpu-qom.h" #include "exec/exec-all.h" +UniCore32CPU *uc32_cpu_init (const char *cpu_model); + +static inline CPUUniCore32State *cpu_init (const char *cpu_model) +{ +UniCore32CPU *cpu =uc32_cpu_init (cpu_model); +if (cpu ==NULL ) { +return NULL ; + } +return &cpu->env; + +} +static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc,target_ulong *cs_base,int *flags) {
target-unicore32/helper.c +2 -8
@@ -25,15 +25,9 @@#define DPRINTF (fmt, ...) do {} while (0)#endif -CPUUniCore32State *uc32_cpu_init (const char *cpu_model) +UniCore32CPU *uc32_cpu_init (const char *cpu_model) { -UniCore32CPU *cpu; - - cpu =UNICORE32_CPU (cpu_generic_init (TYPE_UNICORE32_CPU , cpu_model)); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; +return UNICORE32_CPU (cpu_generic_init (TYPE_UNICORE32_CPU , cpu_model)); }uint32_t HELPER (clo )(uint32_t x)
Signature · 1 line
2.1.0
PATCH 2/4 m68k: Use cpu_m68k_init()
In reply to Eduardo HabkostInstead of using the legacy cpu_init() function, use cpu_m68k_init() directly to create a M68kCPU object.
--- hw/m68k/dummy_m68k.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/m68k/dummy_m68k.c +4 -2
@@ -21,6 +21,7 @@ static void dummy_m68k_init(MachineState *machine)ram_addr_t ram_size = machine->ram_size;const char *cpu_model = machine->cpu_model;const char *kernel_filename = machine->kernel_filename; +M68kCPU *cpu;CPUM68KState *env;MemoryRegion *address_space_mem =get_system_memory ();MemoryRegion *ram =g_new (MemoryRegion,1 );
@@ -30,11 +31,12 @@ static void dummy_m68k_init(MachineState *machine)if (!cpu_model) cpu_model ="cfv4e" ; - env =cpu_init (cpu_model); -if (!env) { + cpu =cpu_m68k_init (cpu_model); +if (!cpu) {fprintf (stderr,"Unable to find m68k CPU definition\n" );exit (1 ); } + env = &cpu->env;/* Initialize CPU registers. */ env->vbr =0 ;
Signature · 1 line
2.1.0
PATCH 3/4 unicore32: Use uc32_cpu_init()
In reply to Eduardo HabkostInstead of using the legacy cpu_init() function, use uc32_cpu_init() to create a UniCore32CPU object.
--- hw/unicore32/puv3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/unicore32/puv3.c +4 -2
@@ -109,6 +109,7 @@ static void puv3_init(MachineState *machine)const char *kernel_filename = machine->kernel_filename;const char *initrd_filename = machine->initrd_filename;CPUUniCore32State *env; +UniCore32CPU *cpu;if (initrd_filename) {hw_error ("Please use kernel built-in initramdisk.\n" );
@@ -118,10 +119,11 @@ static void puv3_init(MachineState *machine) cpu_model ="UniCore-II" ; } - env =cpu_init (cpu_model); -if (!env) { + cpu =uc32_cpu_init (cpu_model); +if (!cpu) {hw_error ("Unable to find CPU definition\n" ); } + env = &cpu->env;puv3_soc_init (env);puv3_board_init (env, ram_size);
Signature · 1 line
2.1.0
PATCH 4/4 cpu: Make cpu_init() return QOM object
In reply to Eduardo HabkostInstead of making cpu_init() return CPUArchState, return a CPU object.
Changes were made using the Coccinelle semantic patch below.
@@
typedef CPUState;
identifier e;
expression args;
type CPUArchState;
@@
- e =
+ cpu =
cpu_init(args);
- if (!e) {
+ if (!cpu) {
...
} - cpu = ENV_GET_CPU(env);
+ e = cpu->env_ptr;
@@
identifier new_env, new_cpu, env, cpu;
type CPUArchState;
expression args;
@@
-{
- CPUState *cpu = ENV_GET_CPU(env);
- CPUArchState *new_env = cpu_init(args);
- CPUState *new_cpu = ENV_GET_CPU(new_env);
+{
+ CPUState *cpu = ENV_GET_CPU(env);
+ CPUState *new_cpu = cpu_init(args);
+ CPUArchState *new_env = new_cpu->env_ptr;
...}
@@
identifier c, cpu_init_func, cpu_model;
type StateType, CPUType;
@@
-static inline StateType* cpu_init(const char *cpu_model) -{
- CPUType *c = cpu_init_func(cpu_model);
(
- if (c == NULL) {
- return NULL;
- }
- return &c->env;
|
- if (c) {
- return &c->env;
- }
- return NULL;
)
-}
+#define cpu_init(cpu_model) CPU(cpu_init_func(cpu_model))
@@
identifier cpu_init_func;
identifier model;
@@
-#define cpu_init(model) (&cpu_init_func(model)->env) +#define cpu_init(model) CPU(cpu_init_func(model))
--- bsd-user/main.c | 6 +++--- linux-user/main.c | 6 +++--- target-alpha/cpu.h | 9 +-------- target-arm/cpu.h | 9 +-------- target-cris/cpu.h | 9 +-------- target-i386/cpu.h | 9 +-------- target-lm32/cpu.h | 9 +-------- target-m68k/cpu.h | 9 +-------- target-microblaze/cpu.h | 9 +-------- target-mips/cpu.h | 9 +-------- target-moxie/cpu.h | 9 +-------- target-openrisc/cpu.h | 9 +-------- target-ppc/cpu.h | 9 +-------- target-s390x/cpu.h | 2 +- target-sh4/cpu.h | 9 +-------- target-sparc/cpu.h | 9 +-------- target-tricore/cpu.h | 10 +--------- target-unicore32/cpu.h | 10 +--------- target-xtensa/cpu.h | 9 +-------- 19 files changed, 23 insertions(+), 137 deletions(-)
bsd-user/main.c +3 -3
@@ -908,12 +908,12 @@ int main(int argc, char **argv)cpu_exec_init_all ();/* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ - env =cpu_init (cpu_model); -if (!env) { + cpu =cpu_init (cpu_model); +if (!cpu) {fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - cpu =ENV_GET_CPU (env); + env = cpu->env_ptr;#if defined(TARGET_SPARC ) || defined(TARGET_PPC )cpu_reset (cpu);#endif
linux-user/main.c +3 -3
@@ -3939,12 +3939,12 @@ int main(int argc, char **argv, char **envp)cpu_exec_init_all ();/* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ - env =cpu_init (cpu_model); -if (!env) { + cpu =cpu_init (cpu_model); +if (!cpu) {fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - cpu =ENV_GET_CPU (env); + env = cpu->env_ptr;cpu_reset (cpu); thread_cpu = cpu;
target-alpha/cpu.h +1 -8
@@ -429,14 +429,7 @@ void alpha_translate_init(void);AlphaCPU *cpu_alpha_init (const char *cpu_model); -static inline CPUAlphaState *cpu_init (const char *cpu_model) -{ -AlphaCPU *cpu =cpu_alpha_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_alpha_init(cpu_model))void alpha_cpu_list (FILE *f,fprintf_function cpu_fprintf);int cpu_alpha_exec (CPUAlphaState *s);
target-arm/cpu.h +1 -8
@@ -1569,14 +1569,7 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx)return unmasked || pstate_unmasked; } -static inline CPUARMState *cpu_init (const char *cpu_model) -{ -ARMCPU *cpu =cpu_arm_init (cpu_model); -if (cpu) { -return &cpu->env; - } -return NULL ; -} +#define cpu_init (cpu_model) CPU(cpu_arm_init(cpu_model))#define cpu_exec cpu_arm_exec#define cpu_gen_code cpu_arm_gen_code
target-cris/cpu.h +1 -8
@@ -221,14 +221,7 @@ enum {#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 -static inline CPUCRISState *cpu_init (const char *cpu_model) -{ -CRISCPU *cpu =cpu_cris_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_cris_init(cpu_model))#define cpu_exec cpu_cris_exec#define cpu_gen_code cpu_cris_gen_code
target-i386/cpu.h +1 -8
@@ -1171,14 +1171,7 @@ uint64_t cpu_get_tsc(CPUX86State *env);# define PHYS_ADDR_MASK 0xfffffffffLL# endif -static inline CPUX86State *cpu_init (const char *cpu_model) -{ -X86CPU *cpu =cpu_x86_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_x86_init(cpu_model))#define cpu_exec cpu_x86_exec#define cpu_gen_code cpu_x86_gen_code
target-lm32/cpu.h +1 -8
@@ -217,14 +217,7 @@ void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,void lm32_watchpoint_remove (CPULM32State *env,int index);bool lm32_cpu_do_semihosting (CPUState *cs); -static inline CPULM32State *cpu_init (const char *cpu_model) -{ -LM32CPU *cpu =cpu_lm32_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_lm32_init(cpu_model))#define cpu_list lm32_cpu_list#define cpu_exec cpu_lm32_exec
target-m68k/cpu.h +1 -8
@@ -212,14 +212,7 @@ void register_m68k_insns (CPUM68KState *env);#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 -static inline CPUM68KState *cpu_init (const char *cpu_model) -{ -M68kCPU *cpu =cpu_m68k_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_m68k_init(cpu_model))#define cpu_exec cpu_m68k_exec#define cpu_gen_code cpu_m68k_gen_code
target-microblaze/cpu.h +1 -8
@@ -297,14 +297,7 @@ enum {#define TARGET_PHYS_ADDR_SPACE_BITS 32#define TARGET_VIRT_ADDR_SPACE_BITS 32 -static inline CPUMBState *cpu_init (const char *cpu_model) -{ -MicroBlazeCPU *cpu =cpu_mb_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_mb_init(cpu_model))#define cpu_exec cpu_mb_exec#define cpu_gen_code cpu_mb_gen_code
target-mips/cpu.h +1 -8
@@ -739,14 +739,7 @@ void mips_tcg_init(void);MIPSCPU *cpu_mips_init (const char *cpu_model);int cpu_mips_signal_handler (int host_signum,void *pinfo,void *puc); -static inline CPUMIPSState *cpu_init (const char *cpu_model) -{ -MIPSCPU *cpu =cpu_mips_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_mips_init(cpu_model))/* TODO QOM'ify CPU reset and remove */ void cpu_state_reset (CPUMIPSState *s);
target-moxie/cpu.h +1 -8
@@ -121,14 +121,7 @@ void moxie_translate_init(void);int cpu_moxie_signal_handler (int host_signum,void *pinfo,void *puc); -static inline CPUMoxieState *cpu_init (const char *cpu_model) -{ -MoxieCPU *cpu =cpu_moxie_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_moxie_init(cpu_model))#define cpu_exec cpu_moxie_exec#define cpu_gen_code cpu_moxie_gen_code
target-openrisc/cpu.h +1 -8
@@ -389,14 +389,7 @@ int cpu_openrisc_get_phys_data(OpenRISCCPU *cpu, int *prot, target_ulong address, int rw);#endif -static inline CPUOpenRISCState *cpu_init (const char *cpu_model) -{ -OpenRISCCPU *cpu =cpu_openrisc_init (cpu_model); -if (cpu) { -return &cpu->env; - } -return NULL ; -} +#define cpu_init (cpu_model) CPU(cpu_openrisc_init(cpu_model))#include "exec/cpu-all.h"
target-ppc/cpu.h +1 -8
@@ -1237,14 +1237,7 @@ static inline uint64_t ppc_dump_gpr(CPUPPCState *env, int gprn)int ppc_dcr_read (ppc_dcr_t *dcr_env,int dcrn,uint32_t *valp);int ppc_dcr_write (ppc_dcr_t *dcr_env,int dcrn,uint32_t val); -static inline CPUPPCState *cpu_init (const char *cpu_model) -{ -PowerPCCPU *cpu =cpu_ppc_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_ppc_init(cpu_model))#define cpu_exec cpu_ppc_exec#define cpu_gen_code cpu_ppc_gen_code
target-s390x/cpu.h +1 -1
@@ -461,7 +461,7 @@ int css_do_rchp(uint8_t cssid, uint8_t chpid);bool css_present (uint8_t cssid);#endif -#define cpu_init (model) (&cpu_s390x_init(model)->env) +#define cpu_init (model) CPU(cpu_s390x_init(model))#define cpu_exec cpu_s390x_exec#define cpu_gen_code cpu_s390x_gen_code#define cpu_signal_handler cpu_s390x_signal_handler
target-sh4/cpu.h +1 -8
@@ -221,14 +221,7 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr);void cpu_load_tlb (CPUSH4State * env); -static inline CPUSH4State *cpu_init (const char *cpu_model) -{ -SuperHCPU *cpu =cpu_sh4_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_sh4_init(cpu_model))#define cpu_exec cpu_sh4_exec#define cpu_gen_code cpu_sh4_gen_code
target-sparc/cpu.h +1 -8
@@ -594,14 +594,7 @@ hwaddr cpu_get_phys_page_nofault(CPUSPARCState *env, target_ulong addr,int cpu_sparc_signal_handler (int host_signum,void *pinfo,void *puc);#ifndef NO_CPU_IO_DEFS -static inline CPUSPARCState *cpu_init (const char *cpu_model) -{ -SPARCCPU *cpu =cpu_sparc_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_sparc_init(cpu_model))#endif #define cpu_exec cpu_sparc_exec
target-tricore/cpu.h +1 -9
@@ -378,15 +378,7 @@ static inline void cpu_get_tb_cpu_state(CPUTriCoreState *env, target_ulong *pc,TriCoreCPU *cpu_tricore_init (const char *cpu_model); -static inline CPUTriCoreState *cpu_init (const char *cpu_model) -{ -TriCoreCPU *cpu =cpu_tricore_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; - -} +#define cpu_init (cpu_model) CPU(cpu_tricore_init(cpu_model))/* helpers.c */
target-unicore32/cpu.h +1 -9
@@ -143,15 +143,7 @@ static inline int cpu_mmu_index(CPUUniCore32State *env)UniCore32CPU *uc32_cpu_init (const char *cpu_model); -static inline CPUUniCore32State *cpu_init (const char *cpu_model) -{ -UniCore32CPU *cpu =uc32_cpu_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; - -} +#define cpu_init (cpu_model) CPU(uc32_cpu_init(cpu_model))static inline void cpu_get_tb_cpu_state (CPUUniCore32State *env,target_ulong *pc,target_ulong *cs_base,int *flags)
target-xtensa/cpu.h +1 -8
@@ -379,14 +379,7 @@ typedef struct CPUXtensaState {XtensaCPU *cpu_xtensa_init (const char *cpu_model); -static inline CPUXtensaState *cpu_init (const char *cpu_model) -{ -XtensaCPU *cpu =cpu_xtensa_init (cpu_model); -if (cpu ==NULL ) { -return NULL ; - } -return &cpu->env; -} +#define cpu_init (cpu_model) CPU(cpu_xtensa_init(cpu_model))void xtensa_translate_init (void );void xtensa_breakpoint_handler (CPUState *cs);
Signature · 1 line
2.1.0
Am 26.02.2015 um 21:37 schrieb Eduardo Habkost:
Quoted 2 lines
Instead of making
cpu_init()return CPUArchState, return a CPU object.
[snip]
In file included from /home/andreas/QEMU/qemu-cpu/include/exec/cpu-all.h:26:0,
from /home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:296, from /home/andreas/QEMU/qemu-cpu/linux-user/qemu.h:7, from /home/andreas/QEMU/qemu-cpu/linux-user/main.c:29:/home/andreas/QEMU/qemu-cpu/linux-user/main.c: In function ‘cpu_copy’:/home/andreas/QEMU/qemu-cpu/include/qom/cpu.h:60:18: error:
initialization from incompatible pointer type [-Werror]
#define CPU(obj) ((CPUState *)(obj))
^
/home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:432:29: note: in
expansion of macro ‘CPU’
#define cpu_init(cpu_model) CPU(cpu_alpha_init(cpu_model))
^
/home/andreas/QEMU/qemu-cpu/linux-user/main.c:3455:29: note: in
expansion of macro ‘cpu_init’
CPUArchState *new_env = cpu_init(cpu_model);
^cc1: all warnings being treated as errors /home/andreas/QEMU/qemu-cpu/rules.mak:57: recipe for target 'linux-user/main.o' failed
make[1]: *** [linux-user/main.o] Error 1
Is there a prereq that I'm missing?
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Am 10.03.2015 um 17:16 schrieb Andreas Färber:
Quoted 23 lines
Am 26.02.2015 um 21:37 schrieb Eduardo Habkost:
Quoted 2 lines
Instead of making
cpu_init()return CPUArchState, return a CPU object.[snip]
In file included from
/home/andreas/QEMU/qemu-cpu/include/exec/cpu-all.h:26:0,
from/home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:296, from/home/andreas/QEMU/qemu-cpu/linux-user/qemu.h:7, from/home/andreas/QEMU/qemu-cpu/linux-user/main.c:29:/home/andreas/QEMU/qemu-cpu/linux-user/main.c: In function ‘cpu_copy’:/home/andreas/QEMU/qemu-cpu/include/qom/cpu.h:60:18: error:
initialization from incompatible pointer type [-Werror]#define CPU(obj) ((CPUState *)(obj)) ^ /home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:432:29: note: in expansion of macro ‘CPU’ #define cpu_init(cpu_model) CPU(cpu_alpha_init(cpu_model)) ^ /home/andreas/QEMU/qemu-cpu/linux-user/main.c:3455:29: note: in expansion of macro ‘cpu_init’ CPUArchState *new_env = cpu_init(cpu_model); ^
Quoted 4 lines
cc1: all warnings being treated as errors
/home/andreas/QEMU/qemu-cpu/rules.mak:57: recipe for target 'linux-user/main.o' failed
make[1]: *** [linux-user/main.o] Error 1
The following fixes it for me:
linux-user/main.c +2 -2
@@ -3452,8 +3452,8 @@ void init_task_state(TaskState *ts)CPUArchState *cpu_copy (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env); -CPUArchState *new_env =cpu_init (cpu_model); -CPUState *new_cpu =ENV_GET_CPU (new_env); +CPUState *new_cpu =cpu_init (cpu_model); +CPUArchState *new_env = cpu->env_ptr;CPUBreakpoint *bp;CPUWatchpoint *wp;
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Quoted 36 lines · Andreas Färber
Am 10.03.2015 um 17:16 schrieb Andreas Färber:
Quoted 23 lines
Am 26.02.2015 um 21:37 schrieb Eduardo Habkost:
Quoted 2 lines
Instead of making
cpu_init()return CPUArchState, return a CPU object.[snip]
In file included from
/home/andreas/QEMU/qemu-cpu/include/exec/cpu-all.h:26:0,
from/home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:296, from/home/andreas/QEMU/qemu-cpu/linux-user/qemu.h:7, from/home/andreas/QEMU/qemu-cpu/linux-user/main.c:29:/home/andreas/QEMU/qemu-cpu/linux-user/main.c: In function ‘cpu_copy’:/home/andreas/QEMU/qemu-cpu/include/qom/cpu.h:60:18: error:
initialization from incompatible pointer type [-Werror]#define CPU(obj) ((CPUState *)(obj)) ^ /home/andreas/QEMU/qemu-cpu/target-alpha/cpu.h:432:29: note: in expansion of macro ‘CPU’ #define cpu_init(cpu_model) CPU(cpu_alpha_init(cpu_model)) ^ /home/andreas/QEMU/qemu-cpu/linux-user/main.c:3455:29: note: in expansion of macro ‘cpu_init’ CPUArchState *new_env = cpu_init(cpu_model); ^Quoted 4 lines
cc1: all warnings being treated as errors
/home/andreas/QEMU/qemu-cpu/rules.mak:57: recipe for target 'linux-user/main.o' failed
make[1]: *** [linux-user/main.o] Error 1The following fixes it for me:
linux-user/main.c +0
-0
linux-user/main.c void init_task_state(TaskState *ts) · line 3458
Quoted 9 lines
linux-user/main.c +2
-2@@ -3452,8 +3452,8 @@ void init_task_state(TaskState *ts)CPUArchState *cpu_copy (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env); -CPUArchState *new_env =cpu_init (cpu_model); -CPUState *new_cpu =ENV_GET_CPU (new_env); +CPUState *new_cpu =cpu_init (cpu_model); +CPUArchState *new_env = cpu->env_ptr;CPUBreakpoint *bp;CPUWatchpoint *wp;
Oops. That change was supposed to be done by the Coccinelle patch. I am sure that some previous version of the Coccinelle patch was doing it right, but for some reason the latest version (the one I submitted) was broken (and I can't understand why).
I guess I shouldn't have insisted in making a pure coccinelle-based patch and should have changed cpu_copy() manually instead (like you just did).
Signature · 1 line
Eduardo
Hi Eduardo,
Am 26.02.2015 um 21:37 schrieb Eduardo Habkost:
Quoted 10 lines
This series changes
cpu_init()to return a CPU QOM object, and changes existing arch-specific code to use the corresponding arch-specific function instead ofcpu_init().With this, the only remaining users of
cpu_init()are linux-user and bsd-user.Eduardo Habkost (4):
target-unicore32: Makeuc32_cpu_init()return UniCore32CPU
m68k: Usecpu_m68k_init()
unicore32: Useuc32_cpu_init()
This part looks good to me. At the time, I propagated *CPU only for those machines that needed it for function calls or field accesses.
Quoted 1 line
cpu: Make
cpu_init()return QOM object
As for this patch, the Coccinelle based approach looks cool! However I would like to give this a bit more thought as to whether 1) this causes churn with regards to the next steps I outlined, and 2) whether more simplifications can be done while at it. Could be done as follow-ups.
Let's also keep in mind that target-tilegx patches are on the list.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)
Am 27.02.2015 um 15:40 schrieb Andreas Färber:
Quoted 17 lines
Hi Eduardo,
Am 26.02.2015 um 21:37 schrieb Eduardo Habkost:
Quoted 10 lines
This series changes
cpu_init()to return a CPU QOM object, and changes existing arch-specific code to use the corresponding arch-specific function instead ofcpu_init().With this, the only remaining users of
cpu_init()are linux-user and bsd-user.Eduardo Habkost (4):
target-unicore32: Makeuc32_cpu_init()return UniCore32CPU
m68k: Usecpu_m68k_init()
unicore32: Useuc32_cpu_init()This part looks good to me. At the time, I propagated *CPU only for those machines that needed it for function calls or field accesses.
Quoted 6 lines
Quoted 1 line
cpu: Make
cpu_init()return QOM objectAs for this patch, the Coccinelle based approach looks cool! However I would like to give this a bit more thought as to whether 1) this causes churn with regards to the next steps I outlined, and 2) whether more simplifications can be done while at it. Could be done as follow-ups.
Not hearing any objection from machine maintainers, I've gone ahead and applied the fourth patch as well:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu
One of the concerns I had was whether we might use cpu_generic_init() in the macro directly, where applicable. But that seems to depend on whether machines will continue to use FooCPU *cpu_foo_init(), which depends on how we proceed with CPU (hot-plug) remodeling, etc.
Thanks,
Andreas
Quoted 5 lines
Let's also keep in mind that target-tilegx patches are on the list.
Regards,
Andreas
Signature · 3 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG Nürnberg)