Pass CPUState to cpu_exec_{start,end}() functions.
Signed-off-by: Andreas Färber <afaerber@suse.de>
int exception_index; \
\
CPUArchState *next_cpu; /* next CPU sharing TB cache */ \
int exception_index; \
\
CPUArchState *next_cpu; /* next CPU sharing TB cache */ \
- int running; /* Nonzero if cpu is currently running(usermode). */ \
/* user data */ \
void *opaque; \
\
/* user data */ \
void *opaque; \
\
* @nr_threads: Number of threads within this CPU.
* @numa_node: NUMA node this CPU is belonging to.
* @host_tid: Host thread ID.
* @nr_threads: Number of threads within this CPU.
* @numa_node: NUMA node this CPU is belonging to.
* @host_tid: Host thread ID.
+ * @running: #true if CPU is currently running (usermode).
* @created: Indicates whether the CPU thread has been successfully created.
* @stop: Indicates a pending stop request.
* @stopped: Indicates the CPU has been artificially stopped.
* @created: Indicates whether the CPU thread has been successfully created.
* @stop: Indicates a pending stop request.
* @stopped: Indicates the CPU has been artificially stopped.
#endif
int thread_id;
uint32_t host_tid;
#endif
int thread_id;
uint32_t host_tid;
struct QemuCond *halt_cond;
struct qemu_work_item *queued_work_first, *queued_work_last;
bool thread_kicked;
struct QemuCond *halt_cond;
struct qemu_work_item *queued_work_first, *queued_work_last;
bool thread_kicked;
static inline void start_exclusive(void)
{
CPUArchState *other;
static inline void start_exclusive(void)
{
CPUArchState *other;
pthread_mutex_lock(&exclusive_lock);
exclusive_idle();
pending_cpus = 1;
/* Make all other cpus stop executing. */
for (other = first_cpu; other; other = other->next_cpu) {
pthread_mutex_lock(&exclusive_lock);
exclusive_idle();
pending_cpus = 1;
/* Make all other cpus stop executing. */
for (other = first_cpu; other; other = other->next_cpu) {
+ other_cpu = ENV_GET_CPU(other);
+ if (other_cpu->running) {
pending_cpus++;
cpu_exit(other);
}
pending_cpus++;
cpu_exit(other);
}
}
/* Wait for exclusive ops to finish, and begin cpu execution. */
}
/* Wait for exclusive ops to finish, and begin cpu execution. */
-static inline void cpu_exec_start(CPUArchState *env)
+static inline void cpu_exec_start(CPUState *cpu)
{
pthread_mutex_lock(&exclusive_lock);
exclusive_idle();
{
pthread_mutex_lock(&exclusive_lock);
exclusive_idle();
pthread_mutex_unlock(&exclusive_lock);
}
/* Mark cpu as not executing, and release pending exclusive ops. */
pthread_mutex_unlock(&exclusive_lock);
}
/* Mark cpu as not executing, and release pending exclusive ops. */
-static inline void cpu_exec_end(CPUArchState *env)
+static inline void cpu_exec_end(CPUState *cpu)
{
pthread_mutex_lock(&exclusive_lock);
{
pthread_mutex_lock(&exclusive_lock);
if (pending_cpus > 1) {
pending_cpus--;
if (pending_cpus == 1) {
if (pending_cpus > 1) {
pending_cpus--;
if (pending_cpus == 1) {
}
#else /* if !CONFIG_USE_NPTL */
/* These are no-ops because we are not threadsafe. */
}
#else /* if !CONFIG_USE_NPTL */
/* These are no-ops because we are not threadsafe. */
-static inline void cpu_exec_start(CPUArchState *env)
+static inline void cpu_exec_start(CPUState *cpu)
-static inline void cpu_exec_end(CPUArchState *env)
+static inline void cpu_exec_end(CPUState *cpu)
void cpu_loop(CPUARMState *env)
{
void cpu_loop(CPUARMState *env)
{
+ CPUState *cs = CPU(arm_env_get_cpu(env));
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
uint32_t addr;
for(;;) {
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
uint32_t addr;
for(;;) {
trapnr = cpu_arm_exec(env);
trapnr = cpu_arm_exec(env);
switch(trapnr) {
case EXCP_UDEF:
{
switch(trapnr) {
case EXCP_UDEF:
{
void cpu_loop(CPUUniCore32State *env)
{
void cpu_loop(CPUUniCore32State *env)
{
+ CPUState *cs = CPU(uc32_env_get_cpu(env));
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
for (;;) {
int trapnr;
unsigned int n, insn;
target_siginfo_t info;
for (;;) {
trapnr = uc32_cpu_exec(env);
trapnr = uc32_cpu_exec(env);
switch (trapnr) {
case UC32_EXCP_PRIV:
{
switch (trapnr) {
case UC32_EXCP_PRIV:
{
void cpu_loop(CPUPPCState *env)
{
void cpu_loop(CPUPPCState *env)
{
+ CPUState *cs = CPU(ppc_env_get_cpu(env));
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
target_siginfo_t info;
int trapnr;
target_ulong ret;
for(;;) {
trapnr = cpu_ppc_exec(env);
trapnr = cpu_ppc_exec(env);
switch(trapnr) {
case POWERPC_EXCP_NONE:
/* Just go on */
switch(trapnr) {
case POWERPC_EXCP_NONE:
/* Just go on */
void cpu_loop(CPUMIPSState *env)
{
void cpu_loop(CPUMIPSState *env)
{
+ CPUState *cs = CPU(mips_env_get_cpu(env));
target_siginfo_t info;
int trapnr, ret;
unsigned int syscall_num;
for(;;) {
target_siginfo_t info;
int trapnr, ret;
unsigned int syscall_num;
for(;;) {
trapnr = cpu_mips_exec(env);
trapnr = cpu_mips_exec(env);
switch(trapnr) {
case EXCP_SYSCALL:
syscall_num = env->active_tc.gpr[2] - 4000;
switch(trapnr) {
case EXCP_SYSCALL:
syscall_num = env->active_tc.gpr[2] - 4000;