Skip to content

Commit 2710342

Browse files
committed
cpu: Move exception_index field from CPU_COMMON to CPUState
Signed-off-by: Andreas Färber <afaerber@suse.de>
1 parent 6f03bef commit 2710342

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+389
-319
lines changed

cpu-exec.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void cpu_resume_from_signal(CPUArchState *env, void *puc)
4141

4242
/* XXX: restore cpu registers saved in host registers */
4343

44-
env->exception_index = -1;
44+
cpu->exception_index = -1;
4545
siglongjmp(cpu->jmp_env, 1);
4646
}
4747
#endif
@@ -282,16 +282,16 @@ int cpu_exec(CPUArchState *env)
282282
#else
283283
#error unsupported target CPU
284284
#endif
285-
env->exception_index = -1;
285+
cpu->exception_index = -1;
286286

287287
/* prepare setjmp context for exception handling */
288288
for(;;) {
289289
if (sigsetjmp(cpu->jmp_env, 0) == 0) {
290290
/* if an exception is pending, we execute it here */
291-
if (env->exception_index >= 0) {
292-
if (env->exception_index >= EXCP_INTERRUPT) {
291+
if (cpu->exception_index >= 0) {
292+
if (cpu->exception_index >= EXCP_INTERRUPT) {
293293
/* exit request from the cpu execution loop */
294-
ret = env->exception_index;
294+
ret = cpu->exception_index;
295295
if (ret == EXCP_DEBUG) {
296296
cpu_handle_debug_exception(env);
297297
}
@@ -304,11 +304,11 @@ int cpu_exec(CPUArchState *env)
304304
#if defined(TARGET_I386)
305305
cc->do_interrupt(cpu);
306306
#endif
307-
ret = env->exception_index;
307+
ret = cpu->exception_index;
308308
break;
309309
#else
310310
cc->do_interrupt(cpu);
311-
env->exception_index = -1;
311+
cpu->exception_index = -1;
312312
#endif
313313
}
314314
}
@@ -323,7 +323,7 @@ int cpu_exec(CPUArchState *env)
323323
}
324324
if (interrupt_request & CPU_INTERRUPT_DEBUG) {
325325
cpu->interrupt_request &= ~CPU_INTERRUPT_DEBUG;
326-
env->exception_index = EXCP_DEBUG;
326+
cpu->exception_index = EXCP_DEBUG;
327327
cpu_loop_exit(env);
328328
}
329329
#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_MIPS) || \
@@ -332,7 +332,7 @@ int cpu_exec(CPUArchState *env)
332332
if (interrupt_request & CPU_INTERRUPT_HALT) {
333333
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
334334
cpu->halted = 1;
335-
env->exception_index = EXCP_HLT;
335+
cpu->exception_index = EXCP_HLT;
336336
cpu_loop_exit(env);
337337
}
338338
#endif
@@ -347,7 +347,7 @@ int cpu_exec(CPUArchState *env)
347347
cpu_svm_check_intercept_param(env, SVM_EXIT_INIT,
348348
0);
349349
do_cpu_init(x86_cpu);
350-
env->exception_index = EXCP_HALTED;
350+
cpu->exception_index = EXCP_HALTED;
351351
cpu_loop_exit(env);
352352
} else if (interrupt_request & CPU_INTERRUPT_SIPI) {
353353
do_cpu_sipi(x86_cpu);
@@ -419,7 +419,7 @@ int cpu_exec(CPUArchState *env)
419419
#elif defined(TARGET_LM32)
420420
if ((interrupt_request & CPU_INTERRUPT_HARD)
421421
&& (env->ie & IE_IE)) {
422-
env->exception_index = EXCP_IRQ;
422+
cpu->exception_index = EXCP_IRQ;
423423
cc->do_interrupt(cpu);
424424
next_tb = 0;
425425
}
@@ -428,15 +428,15 @@ int cpu_exec(CPUArchState *env)
428428
&& (env->sregs[SR_MSR] & MSR_IE)
429429
&& !(env->sregs[SR_MSR] & (MSR_EIP | MSR_BIP))
430430
&& !(env->iflags & (D_FLAG | IMM_FLAG))) {
431-
env->exception_index = EXCP_IRQ;
431+
cpu->exception_index = EXCP_IRQ;
432432
cc->do_interrupt(cpu);
433433
next_tb = 0;
434434
}
435435
#elif defined(TARGET_MIPS)
436436
if ((interrupt_request & CPU_INTERRUPT_HARD) &&
437437
cpu_mips_hw_interrupts_pending(env)) {
438438
/* Raise it */
439-
env->exception_index = EXCP_EXT_INTERRUPT;
439+
cpu->exception_index = EXCP_EXT_INTERRUPT;
440440
env->error_code = 0;
441441
cc->do_interrupt(cpu);
442442
next_tb = 0;
@@ -453,7 +453,7 @@ int cpu_exec(CPUArchState *env)
453453
idx = EXCP_TICK;
454454
}
455455
if (idx >= 0) {
456-
env->exception_index = idx;
456+
cpu->exception_index = idx;
457457
cc->do_interrupt(cpu);
458458
next_tb = 0;
459459
}
@@ -468,7 +468,7 @@ int cpu_exec(CPUArchState *env)
468468
if (((type == TT_EXTINT) &&
469469
cpu_pil_allowed(env, pil)) ||
470470
type != TT_EXTINT) {
471-
env->exception_index = env->interrupt_index;
471+
cpu->exception_index = env->interrupt_index;
472472
cc->do_interrupt(cpu);
473473
next_tb = 0;
474474
}
@@ -477,7 +477,7 @@ int cpu_exec(CPUArchState *env)
477477
#elif defined(TARGET_ARM)
478478
if (interrupt_request & CPU_INTERRUPT_FIQ
479479
&& !(env->daif & PSTATE_F)) {
480-
env->exception_index = EXCP_FIQ;
480+
cpu->exception_index = EXCP_FIQ;
481481
cc->do_interrupt(cpu);
482482
next_tb = 0;
483483
}
@@ -493,14 +493,14 @@ int cpu_exec(CPUArchState *env)
493493
if (interrupt_request & CPU_INTERRUPT_HARD
494494
&& ((IS_M(env) && env->regs[15] < 0xfffffff0)
495495
|| !(env->daif & PSTATE_I))) {
496-
env->exception_index = EXCP_IRQ;
496+
cpu->exception_index = EXCP_IRQ;
497497
cc->do_interrupt(cpu);
498498
next_tb = 0;
499499
}
500500
#elif defined(TARGET_UNICORE32)
501501
if (interrupt_request & CPU_INTERRUPT_HARD
502502
&& !(env->uncached_asr & ASR_I)) {
503-
env->exception_index = UC32_EXCP_INTR;
503+
cpu->exception_index = UC32_EXCP_INTR;
504504
cc->do_interrupt(cpu);
505505
next_tb = 0;
506506
}
@@ -535,7 +535,7 @@ int cpu_exec(CPUArchState *env)
535535
}
536536
}
537537
if (idx >= 0) {
538-
env->exception_index = idx;
538+
cpu->exception_index = idx;
539539
env->error_code = 0;
540540
cc->do_interrupt(cpu);
541541
next_tb = 0;
@@ -545,7 +545,7 @@ int cpu_exec(CPUArchState *env)
545545
if (interrupt_request & CPU_INTERRUPT_HARD
546546
&& (env->pregs[PR_CCS] & I_FLAG)
547547
&& !env->locked_irq) {
548-
env->exception_index = EXCP_IRQ;
548+
cpu->exception_index = EXCP_IRQ;
549549
cc->do_interrupt(cpu);
550550
next_tb = 0;
551551
}
@@ -557,7 +557,7 @@ int cpu_exec(CPUArchState *env)
557557
m_flag_archval = M_FLAG_V32;
558558
}
559559
if ((env->pregs[PR_CCS] & m_flag_archval)) {
560-
env->exception_index = EXCP_NMI;
560+
cpu->exception_index = EXCP_NMI;
561561
cc->do_interrupt(cpu);
562562
next_tb = 0;
563563
}
@@ -571,7 +571,7 @@ int cpu_exec(CPUArchState *env)
571571
hardware doesn't rely on this, so we
572572
provide/save the vector when the interrupt is
573573
first signalled. */
574-
env->exception_index = env->pending_vector;
574+
cpu->exception_index = env->pending_vector;
575575
do_interrupt_m68k_hardirq(env);
576576
next_tb = 0;
577577
}
@@ -583,7 +583,7 @@ int cpu_exec(CPUArchState *env)
583583
}
584584
#elif defined(TARGET_XTENSA)
585585
if (interrupt_request & CPU_INTERRUPT_HARD) {
586-
env->exception_index = EXC_IRQ;
586+
cpu->exception_index = EXC_IRQ;
587587
cc->do_interrupt(cpu);
588588
next_tb = 0;
589589
}
@@ -599,7 +599,7 @@ int cpu_exec(CPUArchState *env)
599599
}
600600
if (unlikely(cpu->exit_request)) {
601601
cpu->exit_request = 0;
602-
env->exception_index = EXCP_INTERRUPT;
602+
cpu->exception_index = EXCP_INTERRUPT;
603603
cpu_loop_exit(env);
604604
}
605605
spin_lock(&tcg_ctx.tb_ctx.tb_lock);
@@ -669,7 +669,7 @@ int cpu_exec(CPUArchState *env)
669669
/* Execute remaining instructions. */
670670
cpu_exec_nocache(env, insns_left, tb);
671671
}
672-
env->exception_index = EXCP_INTERRUPT;
672+
cpu->exception_index = EXCP_INTERRUPT;
673673
next_tb = 0;
674674
cpu_loop_exit(env);
675675
}

exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ static void check_watchpoint(int offset, int len_mask, int flags)
15951595
env->watchpoint_hit = wp;
15961596
tb_check_watchpoint(env);
15971597
if (wp->flags & BP_STOP_BEFORE_ACCESS) {
1598-
env->exception_index = EXCP_DEBUG;
1598+
cpu->exception_index = EXCP_DEBUG;
15991599
cpu_loop_exit(env);
16001600
} else {
16011601
cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags);

hw/ppc/e500.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,13 @@ static void ppce500_cpu_reset_sec(void *opaque)
472472
{
473473
PowerPCCPU *cpu = opaque;
474474
CPUState *cs = CPU(cpu);
475-
CPUPPCState *env = &cpu->env;
476475

477476
cpu_reset(cs);
478477

479478
/* Secondary CPU starts in halted state for now. Needs to change when
480479
implementing non-kernel boot. */
481480
cs->halted = 1;
482-
env->exception_index = EXCP_HLT;
481+
cs->exception_index = EXCP_HLT;
483482
}
484483

485484
static void ppce500_cpu_reset(void *opaque)

hw/ppc/ppce500_spin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static void spin_kick(void *data)
117117
mmubooke_create_initial_mapping(env, 0, map_start, map_size);
118118

119119
cpu->halted = 0;
120-
env->exception_index = -1;
120+
cpu->exception_index = -1;
121121
cpu->stopped = false;
122122
qemu_cpu_kick(cpu);
123123
}

hw/ppc/spapr_hcall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static target_ulong h_cede(PowerPCCPU *cpu, sPAPREnvironment *spapr,
529529
hreg_compute_hflags(env);
530530
if (!cpu_has_work(cs)) {
531531
cs->halted = 1;
532-
env->exception_index = EXCP_HLT;
532+
cs->exception_index = EXCP_HLT;
533533
cs->exit_request = 1;
534534
}
535535
return H_SUCCESS;

hw/s390x/s390-virtio.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,23 @@ static unsigned s390_running_cpus;
135135
void s390_add_running_cpu(S390CPU *cpu)
136136
{
137137
CPUState *cs = CPU(cpu);
138-
CPUS390XState *env = &cpu->env;
139138

140139
if (cs->halted) {
141140
s390_running_cpus++;
142141
cs->halted = 0;
143-
env->exception_index = -1;
142+
cs->exception_index = -1;
144143
}
145144
}
146145

147146
unsigned s390_del_running_cpu(S390CPU *cpu)
148147
{
149148
CPUState *cs = CPU(cpu);
150-
CPUS390XState *env = &cpu->env;
151149

152150
if (cs->halted == 0) {
153151
assert(s390_running_cpus >= 1);
154152
s390_running_cpus--;
155153
cs->halted = 1;
156-
env->exception_index = EXCP_HLT;
154+
cs->exception_index = EXCP_HLT;
157155
}
158156
return s390_running_cpus;
159157
}
@@ -196,7 +194,7 @@ void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys)
196194

197195
ipi_states[i] = cpu;
198196
cs->halted = 1;
199-
cpu->env.exception_index = EXCP_HLT;
197+
cs->exception_index = EXCP_HLT;
200198
cpu->env.storage_keys = storage_keys;
201199
}
202200
}

include/exec/cpu-defs.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ typedef struct CPUWatchpoint {
139139
QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \
140140
CPUWatchpoint *watchpoint_hit; \
141141
\
142-
/* Core interrupt code */ \
143-
int exception_index; \
144-
\
145142
/* user data */ \
146143
void *opaque; \
147144

include/qom/cpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct CPUState {
249249
icount_decr_u16 u16;
250250
} icount_decr;
251251
uint32_t can_do_io;
252+
int32_t exception_index; /* used by m68k TCG */
252253
};
253254

254255
QTAILQ_HEAD(CPUTailQ, CPUState);

linux-user/signal.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,9 @@ static int
774774
setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate,
775775
CPUX86State *env, abi_ulong mask, abi_ulong fpstate_addr)
776776
{
777-
int err = 0;
778-
uint16_t magic;
777+
CPUState *cs = CPU(x86_env_get_cpu(env));
778+
int err = 0;
779+
uint16_t magic;
779780

780781
/* already locked in setup_frame() */
781782
err |= __put_user(env->segs[R_GS].selector, (unsigned int *)&sc->gs);
@@ -790,7 +791,7 @@ setup_sigcontext(struct target_sigcontext *sc, struct target_fpstate *fpstate,
790791
err |= __put_user(env->regs[R_EDX], &sc->edx);
791792
err |= __put_user(env->regs[R_ECX], &sc->ecx);
792793
err |= __put_user(env->regs[R_EAX], &sc->eax);
793-
err |= __put_user(env->exception_index, &sc->trapno);
794+
err |= __put_user(cs->exception_index, &sc->trapno);
794795
err |= __put_user(env->error_code, &sc->err);
795796
err |= __put_user(env->eip, &sc->eip);
796797
err |= __put_user(env->segs[R_CS].selector, (unsigned int *)&sc->cs);

target-alpha/helper.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr address,
173173
{
174174
AlphaCPU *cpu = ALPHA_CPU(cs);
175175

176-
cpu->env.exception_index = EXCP_MMFAULT;
176+
cs->exception_index = EXCP_MMFAULT;
177177
cpu->env.trap_arg0 = address;
178178
return 1;
179179
}
@@ -338,7 +338,7 @@ int alpha_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int rw,
338338

339339
fail = get_physical_address(env, addr, 1 << rw, mmu_idx, &phys, &prot);
340340
if (unlikely(fail >= 0)) {
341-
env->exception_index = EXCP_MMFAULT;
341+
cs->exception_index = EXCP_MMFAULT;
342342
env->trap_arg0 = addr;
343343
env->trap_arg1 = fail;
344344
env->trap_arg2 = (rw == 2 ? -1 : rw);
@@ -355,7 +355,7 @@ void alpha_cpu_do_interrupt(CPUState *cs)
355355
{
356356
AlphaCPU *cpu = ALPHA_CPU(cs);
357357
CPUAlphaState *env = &cpu->env;
358-
int i = env->exception_index;
358+
int i = cs->exception_index;
359359

360360
if (qemu_loglevel_mask(CPU_LOG_INT)) {
361361
static int count;
@@ -406,7 +406,7 @@ void alpha_cpu_do_interrupt(CPUState *cs)
406406
++count, name, env->error_code, env->pc, env->ir[IR_SP]);
407407
}
408408

409-
env->exception_index = -1;
409+
cs->exception_index = -1;
410410

411411
#if !defined(CONFIG_USER_ONLY)
412412
switch (i) {
@@ -508,7 +508,10 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
508508
We expect that ENV->PC has already been updated. */
509509
void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
510510
{
511-
env->exception_index = excp;
511+
AlphaCPU *cpu = alpha_env_get_cpu(env);
512+
CPUState *cs = CPU(cpu);
513+
514+
cs->exception_index = excp;
512515
env->error_code = error;
513516
cpu_loop_exit(env);
514517
}
@@ -517,7 +520,10 @@ void QEMU_NORETURN helper_excp(CPUAlphaState *env, int excp, int error)
517520
void QEMU_NORETURN dynamic_excp(CPUAlphaState *env, uintptr_t retaddr,
518521
int excp, int error)
519522
{
520-
env->exception_index = excp;
523+
AlphaCPU *cpu = alpha_env_get_cpu(env);
524+
CPUState *cs = CPU(cpu);
525+
526+
cs->exception_index = excp;
521527
env->error_code = error;
522528
if (retaddr) {
523529
cpu_restore_state(env, retaddr);

0 commit comments

Comments
 (0)