Unbreak linux-user targets
PATCH 1/1 Unbreak linux-user targets
Currently linux-user targets are broken as current-accel is used but not linked in. Move common accel code to separate file that will be linked with both targets.
Signed-off-by Dmitry Baryshkov <[email protected]>
Cc Glauber Costa <[email protected]>
--- Makefile.target | 2 +- accel.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ accel.h | 27 +++++------------ kqemu.c | 2 + linux-user/main.c | 2 + vl.c | 55 +---------------------------------- 6 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 accel.c
Makefile.target +1 -1
@@ -186,7 +186,7 @@ all: $(PROGS) ######################################################### # cpu emulator library -LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\ +LIBOBJS=accel.o exec.o kqemu.o translate-all.o cpu-exec.o\ translate.o host-utils.o ifdef CONFIG_DYNGEN_OP exec.o: dyngen-opc.h
accel.c new file +83 -0
83 lines not on this page · raw message
accel.h +8 -19
@@ -10,7 +10,9 @@ typedef struct QEMUAccel {int (*profile)(CPUState *env,char *buf);void (*set_notdirty)(ram_addr_t addr);void (*modify_page)(ram_addr_t addr,int dirty_flags); +#ifndef CONFIG_USER_ONLY uint64_t (*get_real_ticks)(void ); +#endif void (*register_physical_memory)(uint64_t start_addr,ram_addr_t size,ram_addr_t phys_offset);void (*trace_io)(CPUState *env);
@@ -73,25 +75,7 @@ static inline void accel_cpu_interrupt(CPUState *env) current_accel->cpu_interrupt (env); } -static inline int accel_start (void ) -{ -int status =-1 ; - -/* The top accelerator in the list gets tried first, but if it fails, -* keep trying until one of them succeeds or we exhaust the list */ -QEMUCont *tmp = head; -while (tmp) { -if (tmp->acc && tmp->acc->start && (!(tmp->acc->start ())) ) { - tmp->active =1 ; - current_accel = tmp->acc; - status =0 ; -break ; - } - tmp = tmp->next; - } - -return status; -} +extern int accel_start (void );static inline CPUState *accel_get_env (void ) {
@@ -133,12 +117,14 @@ static inline void accel_modify_page(target_ulong addr, int dirty_flags) current_accel->modify_page (addr, dirty_flags); } +#ifndef CONFIG_USER_ONLY int64_t cpu_get_ticks (void );static inline uint64_t accel_get_real_ticks (void ) {return current_accel->get_real_ticks (); } +#endif static inline void accel_register_phys_mem(uint64_t start_addr, ram_addr_t size,
@@ -156,3 +142,6 @@ static inline int accel_break_loop(CPUState *env) {return current_accel->break_loop (env); } + +extern void accel_add (const char *name); +
kqemu.c +2 -0
@@ -464,7 +464,9 @@ QEMUAccel kqemu_accel = {/* Note: when using kqemu, it is more logical to return the host TSC because kqemu does not trap the RDTSC instruction for performance reasons */ +#ifndef CONFIG_USER_ONLY .get_real_ticks = cpu_get_real_ticks, +#endif .register_physical_memory = kqemu_set_phys_mem, .trace_io = kqemu_trace_io, .break_loop = kqemu_break_loop,
linux-user/main.c +2 -0
@@ -28,6 +28,7 @@#include "qemu-common.h" /* For tb_lock */ #include "exec-all.h" +#include "accel.h" #define DEBUG_LOGFILE "/tmp/qemu.log"
@@ -2354,6 +2355,7 @@ int main(int argc, char **argv)#endif }cpu_exec_init_all (0 ); +accel_start ();/* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ env =cpu_init (cpu_model);
vl.c +1 -54
73 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Quoted 4 lines · Dmitry Baryshkov
Currently linux-user targets are broken as current-accel is used but not linked in. Move common accel code to separate file that will be linked with both targets.
I've updated the repo with this patch.
Thanks for spotting this.
Quoted 294 lines
Signed-off-by Dmitry Baryshkov <[email protected]>Cc Glauber Costa <[email protected]>--- Makefile.target | 2 +- accel.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ accel.h | 27 +++++------------ kqemu.c | 2 + linux-user/main.c | 2 + vl.c | 55 +---------------------------------- 6 files changed, 97 insertions(+), 74 deletions(-) create mode 100644 accel.cMakefile.target +1
-1@@ -186,7 +186,7 @@ all: $(PROGS) ######################################################### # cpu emulator library -LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\ +LIBOBJS=accel.o exec.o kqemu.o translate-all.o cpu-exec.o\ translate.o host-utils.o ifdef CONFIG_DYNGEN_OP exec.o: dyngen-opc.haccel.c new file +83
-0@@ -0,0 +1,83 @@ +#include "hw/hw.h" +#include "accel.h" + +QEMUAccel *current_accel; +QEMUCont *head =NULL ; + +int _accel_nop (void ) +{ +return 0 ; +} + +int noaccel_info (CPUState *env,char *buf) +{ +return sprintf (buf,"no accelerator present.\n" ); +} + +CPUState *noaccel_get_env (void ) +{ +return qemu_mallocz (sizeof (CPUState)); +} + +/* Accelerator wrapper for the no-accel (raw qemu) case */ +QEMUAccel noaccel = { + .name =NULL , + .cpu_interrupt = accel_nop, + .init_env = accel_nop, + .get_env = noaccel_get_env, + .start = accel_nop, + .flush_cache = accel_nop, + .flush_page = accel_nop, + .info = noaccel_info, + .profile = accel_nop, + .set_notdirty = accel_nop, + .modify_page = accel_nop, +#ifndef CONFIG_USER_ONLY + .get_real_ticks = cpu_get_ticks, +#endif + .register_physical_memory = accel_nop, + .trace_io = accel_nop, + .break_loop = accel_nop, +}; + +QEMUAccel *available_accels[] = { +/* list of available accelerators */ +#ifdef USE_KQEMU + &kqemu_accel, +#endif +}; + +int accel_start (void ) +{ +int status =-1 ; +QEMUCont *tmp; + +/* Basic handler for the noaccel case */ +register_qemu_accel (&noaccel); + +/* The top accelerator in the list gets tried first, but if it fails, +* keep trying until one of them succeeds or we exhaust the list */ + tmp = head; +while (tmp) { +if (tmp->acc && tmp->acc->start && (!(tmp->acc->start ())) ) { + tmp->active =1 ; + current_accel = tmp->acc; + status =0 ; +break ; + } + tmp = tmp->next; + } + +return status; +} + +void accel_add (const char *name) +{ +int i; +printf ("adding %s\n" , name); +for (i =0 ; i <ARRAY_SIZE (available_accels); i++) { +printf ("c %s\n" , available_accels[i]->name); +if (!strcasecmp (name, available_accels[i]->name)) +register_qemu_accel (available_accels[i]); + } +}accel.h +8
-19@@ -10,7 +10,9 @@ typedef struct QEMUAccel {int (*profile)(CPUState *env,char *buf);void (*set_notdirty)(ram_addr_t addr);void (*modify_page)(ram_addr_t addr,int dirty_flags); +#ifndef CONFIG_USER_ONLY uint64_t (*get_real_ticks)(void ); +#endif void (*register_physical_memory)(uint64_t start_addr,ram_addr_t size,ram_addr_t phys_offset);void (*trace_io)(CPUState *env);@@ -73,25 +75,7 @@ static inline void accel_cpu_interrupt(CPUState *env) current_accel->cpu_interrupt (env); } -static inline int accel_start (void ) -{ -int status =-1 ; - -/* The top accelerator in the list gets tried first, but if it fails, -* keep trying until one of them succeeds or we exhaust the list */ -QEMUCont *tmp = head; -while (tmp) { -if (tmp->acc && tmp->acc->start && (!(tmp->acc->start ())) ) { - tmp->active =1 ; - current_accel = tmp->acc; - status =0 ; -break ; - } - tmp = tmp->next; - } - -return status; -} +extern int accel_start (void );static inline CPUState *accel_get_env (void ) {@@ -133,12 +117,14 @@ static inline void accel_modify_page(target_ulong addr, int dirty_flags) current_accel->modify_page (addr, dirty_flags); } +#ifndef CONFIG_USER_ONLY int64_t cpu_get_ticks (void );static inline uint64_t accel_get_real_ticks (void ) {return current_accel->get_real_ticks (); } +#endif static inline void accel_register_phys_mem(uint64_t start_addr, ram_addr_t size,@@ -156,3 +142,6 @@ static inline int accel_break_loop(CPUState *env) {return current_accel->break_loop (env); } + +extern void accel_add (const char *name); +kqemu.c +2
-0@@ -464,7 +464,9 @@ QEMUAccel kqemu_accel = {/* Note: when using kqemu, it is more logical to return the host TSC because kqemu does not trap the RDTSC instruction for performance reasons */ +#ifndef CONFIG_USER_ONLY .get_real_ticks = cpu_get_real_ticks, +#endif .register_physical_memory = kqemu_set_phys_mem, .trace_io = kqemu_trace_io, .break_loop = kqemu_break_loop,linux-user/main.c +2
-0@@ -28,6 +28,7 @@#include "qemu-common.h" /* For tb_lock */ #include "exec-all.h" +#include "accel.h" #define DEBUG_LOGFILE "/tmp/qemu.log"@@ -2354,6 +2355,7 @@ int main(int argc, char **argv)#endif }cpu_exec_init_all (0 ); +accel_start ();/* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ env =cpu_init (cpu_model);vl.c +1
-54@@ -259,50 +259,6 @@ static int64_t qemu_icount_bias;QEMUTimer *icount_rt_timer;QEMUTimer *icount_vm_timer; -QEMUAccel *current_accel; -QEMUCont *head =NULL ; - -int _accel_nop (void ) -{ -return 0 ; -} - -int noaccel_info (CPUState *env,char *buf) -{ -return sprintf (buf,"no accelerator present.\n" ); -} - -CPUState *noaccel_get_env (void ) -{ -return qemu_mallocz (sizeof (CPUState)); -} - -/* Accelerator wrapper for the no-accel (raw qemu) case */ -QEMUAccel noaccel = { - .name =NULL , - .cpu_interrupt = accel_nop, - .init_env = accel_nop, - .get_env = noaccel_get_env, - .start = accel_nop, - .flush_cache = accel_nop, - .flush_page = accel_nop, - .info = noaccel_info, - .profile = accel_nop, - .set_notdirty = accel_nop, - .modify_page = accel_nop, - .get_real_ticks = cpu_get_ticks, - .register_physical_memory = accel_nop, - .trace_io = accel_nop, - .break_loop = accel_nop, -}; - -QEMUAccel *available_accels[] = { -/* list of available accelerators */ -#ifdef USE_KQEMU - &kqemu_accel, -#endif -}; -#define TFR (expr) do { if ((expr) != -1) break; } while (errno == EINTR)/***********************************************************/ @@ -8773,13 +8729,7 @@ int main(int argc, char **argv)break ;#endif case QEMU_OPTION_accel: - { -int i; -for (i =0 ; i <ARRAY_SIZE (available_accels); i++) { -if (!strcasecmp (optarg, available_accels[i]->name)) -register_qemu_accel (available_accels[i]); - } - } +accel_add (optarg);break ;case QEMU_OPTION_usb: usb_enabled =1 ;@@ -8905,9 +8855,6 @@ int main(int argc, char **argv) } } -/* Basic handler for the noaccel case */ -register_qemu_accel (&noaccel); -if (nographic) {if (serial_device_index ==0 ) serial_devices[0 ] ="stdio" ;Signature · 1 line
1.5.6.5