2 * PowerPC exception emulation helpers for QEMU.
4 * Copyright (c) 2003-2007 Jocelyn Mayer
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #include "qemu/osdep.h"
20 #include "qemu/main-loop.h"
22 #include "exec/helper-proto.h"
23 #include "exec/exec-all.h"
24 #include "exec/cpu_ldst.h"
26 #include "helper_regs.h"
28 /* #define DEBUG_OP */
29 /* #define DEBUG_SOFTWARE_TLB */
30 /* #define DEBUG_EXCEPTIONS */
32 #ifdef DEBUG_EXCEPTIONS
33 # define LOG_EXCP(...) qemu_log(__VA_ARGS__)
35 # define LOG_EXCP(...) do { } while (0)
38 /*****************************************************************************/
39 /* Exception processing */
40 #if defined(CONFIG_USER_ONLY)
41 void ppc_cpu_do_interrupt(CPUState
*cs
)
43 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
44 CPUPPCState
*env
= &cpu
->env
;
46 cs
->exception_index
= POWERPC_EXCP_NONE
;
50 static void ppc_hw_interrupt(CPUPPCState
*env
)
52 CPUState
*cs
= env_cpu(env
);
54 cs
->exception_index
= POWERPC_EXCP_NONE
;
57 #else /* defined(CONFIG_USER_ONLY) */
58 static inline void dump_syscall(CPUPPCState
*env
)
60 qemu_log_mask(CPU_LOG_INT
, "syscall r0=%016" PRIx64
61 " r3=%016" PRIx64
" r4=%016" PRIx64
" r5=%016" PRIx64
62 " r6=%016" PRIx64
" r7=%016" PRIx64
" r8=%016" PRIx64
63 " nip=" TARGET_FMT_lx
"\n",
64 ppc_dump_gpr(env
, 0), ppc_dump_gpr(env
, 3),
65 ppc_dump_gpr(env
, 4), ppc_dump_gpr(env
, 5),
66 ppc_dump_gpr(env
, 6), ppc_dump_gpr(env
, 7),
67 ppc_dump_gpr(env
, 8), env
->nip
);
70 static inline void dump_syscall_vectored(CPUPPCState
*env
)
72 qemu_log_mask(CPU_LOG_INT
, "syscall r0=%016" PRIx64
73 " r3=%016" PRIx64
" r4=%016" PRIx64
" r5=%016" PRIx64
74 " r6=%016" PRIx64
" r7=%016" PRIx64
" r8=%016" PRIx64
75 " nip=" TARGET_FMT_lx
"\n",
76 ppc_dump_gpr(env
, 0), ppc_dump_gpr(env
, 3),
77 ppc_dump_gpr(env
, 4), ppc_dump_gpr(env
, 5),
78 ppc_dump_gpr(env
, 6), ppc_dump_gpr(env
, 7),
79 ppc_dump_gpr(env
, 8), env
->nip
);
82 static inline void dump_hcall(CPUPPCState
*env
)
84 qemu_log_mask(CPU_LOG_INT
, "hypercall r3=%016" PRIx64
85 " r4=%016" PRIx64
" r5=%016" PRIx64
" r6=%016" PRIx64
86 " r7=%016" PRIx64
" r8=%016" PRIx64
" r9=%016" PRIx64
87 " r10=%016" PRIx64
" r11=%016" PRIx64
" r12=%016" PRIx64
88 " nip=" TARGET_FMT_lx
"\n",
89 ppc_dump_gpr(env
, 3), ppc_dump_gpr(env
, 4),
90 ppc_dump_gpr(env
, 5), ppc_dump_gpr(env
, 6),
91 ppc_dump_gpr(env
, 7), ppc_dump_gpr(env
, 8),
92 ppc_dump_gpr(env
, 9), ppc_dump_gpr(env
, 10),
93 ppc_dump_gpr(env
, 11), ppc_dump_gpr(env
, 12),
97 static int powerpc_reset_wakeup(CPUState
*cs
, CPUPPCState
*env
, int excp
,
100 /* We no longer are in a PM state */
101 env
->resume_as_sreset
= false;
103 /* Pretend to be returning from doze always as we don't lose state */
104 *msr
|= SRR1_WS_NOLOSS
;
106 /* Machine checks are sent normally */
107 if (excp
== POWERPC_EXCP_MCHECK
) {
111 case POWERPC_EXCP_RESET
:
112 *msr
|= SRR1_WAKERESET
;
114 case POWERPC_EXCP_EXTERNAL
:
117 case POWERPC_EXCP_DECR
:
118 *msr
|= SRR1_WAKEDEC
;
120 case POWERPC_EXCP_SDOOR
:
121 *msr
|= SRR1_WAKEDBELL
;
123 case POWERPC_EXCP_SDOOR_HV
:
124 *msr
|= SRR1_WAKEHDBELL
;
126 case POWERPC_EXCP_HV_MAINT
:
127 *msr
|= SRR1_WAKEHMI
;
129 case POWERPC_EXCP_HVIRT
:
130 *msr
|= SRR1_WAKEHVI
;
133 cpu_abort(cs
, "Unsupported exception %d in Power Save mode\n",
136 return POWERPC_EXCP_RESET
;
139 static uint64_t ppc_excp_vector_offset(CPUState
*cs
, int ail
)
149 case AIL_C000_0000_0000_4000
:
150 offset
= 0xc000000000004000ull
;
153 cpu_abort(cs
, "Invalid AIL combination %d\n", ail
);
160 static inline void powerpc_set_excp_state(PowerPCCPU
*cpu
,
161 target_ulong vector
, target_ulong msr
)
163 CPUState
*cs
= CPU(cpu
);
164 CPUPPCState
*env
= &cpu
->env
;
167 * We don't use hreg_store_msr here as already have treated any
168 * special case that could occur. Just store MSR and update hflags
170 * Note: We *MUST* not use hreg_store_msr() as-is anyway because it
171 * will prevent setting of the HV bit which some exceptions might need
174 env
->msr
= msr
& env
->msr_mask
;
175 hreg_compute_hflags(env
);
177 /* Reset exception state */
178 cs
->exception_index
= POWERPC_EXCP_NONE
;
181 /* Reset the reservation */
182 env
->reserve_addr
= -1;
185 * Any interrupt is context synchronizing, check if TCG TLB needs
186 * a delayed flush on ppc64
188 check_tlb_flush(env
, false);
192 * Note that this function should be greatly optimized when called
193 * with a constant excp, from ppc_hw_interrupt
195 static inline void powerpc_excp(PowerPCCPU
*cpu
, int excp_model
, int excp
)
197 CPUState
*cs
= CPU(cpu
);
198 CPUPPCState
*env
= &cpu
->env
;
199 target_ulong msr
, new_msr
, vector
;
200 int srr0
, srr1
, asrr0
, asrr1
, lev
= -1, ail
;
203 qemu_log_mask(CPU_LOG_INT
, "Raise exception at " TARGET_FMT_lx
204 " => %08x (%02x)\n", env
->nip
, excp
, env
->error_code
);
206 /* new srr1 value excluding must-be-zero bits */
207 if (excp_model
== POWERPC_EXCP_BOOKE
) {
210 msr
= env
->msr
& ~0x783f0000ULL
;
214 * new interrupt handler msr preserves existing HV and ME unless
215 * explicitly overriden
217 new_msr
= env
->msr
& (((target_ulong
)1 << MSR_ME
) | MSR_HVB
);
219 /* target registers */
226 * check for special resume at 0x100 from doze/nap/sleep/winkle on
229 if (env
->resume_as_sreset
) {
230 excp
= powerpc_reset_wakeup(cs
, env
, excp
, &msr
);
234 * Exception targeting modifiers
236 * LPES0 is supported on POWER7/8/9
237 * LPES1 is not supported (old iSeries mode)
239 * On anything else, we behave as if LPES0 is 1
240 * (externals don't alter MSR:HV)
242 * AIL is initialized here but can be cleared by
243 * selected exceptions
245 #if defined(TARGET_PPC64)
246 if (excp_model
== POWERPC_EXCP_POWER7
||
247 excp_model
== POWERPC_EXCP_POWER8
||
248 excp_model
== POWERPC_EXCP_POWER9
) {
249 lpes0
= !!(env
->spr
[SPR_LPCR
] & LPCR_LPES0
);
250 if (excp_model
!= POWERPC_EXCP_POWER7
) {
251 ail
= (env
->spr
[SPR_LPCR
] & LPCR_AIL
) >> LPCR_AIL_SHIFT
;
256 #endif /* defined(TARGET_PPC64) */
263 * Hypervisor emulation assistance interrupt only exists on server
264 * arch 2.05 server or later. We also don't want to generate it if
265 * we don't have HVB in msr_mask (PAPR mode).
267 if (excp
== POWERPC_EXCP_HV_EMU
268 #if defined(TARGET_PPC64)
269 && !(mmu_is_64bit(env
->mmu_model
) && (env
->msr_mask
& MSR_HVB
))
270 #endif /* defined(TARGET_PPC64) */
273 excp
= POWERPC_EXCP_PROGRAM
;
277 case POWERPC_EXCP_NONE
:
278 /* Should never happen */
280 case POWERPC_EXCP_CRITICAL
: /* Critical input */
281 switch (excp_model
) {
282 case POWERPC_EXCP_40x
:
286 case POWERPC_EXCP_BOOKE
:
287 srr0
= SPR_BOOKE_CSRR0
;
288 srr1
= SPR_BOOKE_CSRR1
;
290 case POWERPC_EXCP_G2
:
296 case POWERPC_EXCP_MCHECK
: /* Machine check exception */
299 * Machine check exception is not enabled. Enter
302 fprintf(stderr
, "Machine check while not allowed. "
303 "Entering checkstop state\n");
304 if (qemu_log_separate()) {
305 qemu_log("Machine check while not allowed. "
306 "Entering checkstop state\n");
309 cpu_interrupt_exittb(cs
);
311 if (env
->msr_mask
& MSR_HVB
) {
313 * ISA specifies HV, but can be delivered to guest with HV
314 * clear (e.g., see FWNMI in PAPR).
316 new_msr
|= (target_ulong
)MSR_HVB
;
320 /* machine check exceptions don't have ME set */
321 new_msr
&= ~((target_ulong
)1 << MSR_ME
);
323 /* XXX: should also have something loaded in DAR / DSISR */
324 switch (excp_model
) {
325 case POWERPC_EXCP_40x
:
329 case POWERPC_EXCP_BOOKE
:
330 /* FIXME: choose one or the other based on CPU type */
331 srr0
= SPR_BOOKE_MCSRR0
;
332 srr1
= SPR_BOOKE_MCSRR1
;
333 asrr0
= SPR_BOOKE_CSRR0
;
334 asrr1
= SPR_BOOKE_CSRR1
;
340 case POWERPC_EXCP_DSI
: /* Data storage exception */
341 LOG_EXCP("DSI exception: DSISR=" TARGET_FMT_lx
" DAR=" TARGET_FMT_lx
342 "\n", env
->spr
[SPR_DSISR
], env
->spr
[SPR_DAR
]);
344 case POWERPC_EXCP_ISI
: /* Instruction storage exception */
345 LOG_EXCP("ISI exception: msr=" TARGET_FMT_lx
", nip=" TARGET_FMT_lx
346 "\n", msr
, env
->nip
);
347 msr
|= env
->error_code
;
349 case POWERPC_EXCP_EXTERNAL
: /* External input */
353 new_msr
|= (target_ulong
)MSR_HVB
;
354 new_msr
|= env
->msr
& ((target_ulong
)1 << MSR_RI
);
358 if (env
->mpic_proxy
) {
359 /* IACK the IRQ on delivery */
360 env
->spr
[SPR_BOOKE_EPR
] = ldl_phys(cs
->as
, env
->mpic_iack
);
363 case POWERPC_EXCP_ALIGN
: /* Alignment exception */
364 /* Get rS/rD and rA from faulting opcode */
366 * Note: the opcode fields will not be set properly for a
367 * direct store load/store, but nobody cares as nobody
368 * actually uses direct store segments.
370 env
->spr
[SPR_DSISR
] |= (env
->error_code
& 0x03FF0000) >> 16;
372 case POWERPC_EXCP_PROGRAM
: /* Program exception */
373 switch (env
->error_code
& ~0xF) {
374 case POWERPC_EXCP_FP
:
375 if ((msr_fe0
== 0 && msr_fe1
== 0) || msr_fp
== 0) {
376 LOG_EXCP("Ignore floating point exception\n");
377 cs
->exception_index
= POWERPC_EXCP_NONE
;
383 * FP exceptions always have NIP pointing to the faulting
384 * instruction, so always use store_next and claim we are
385 * precise in the MSR.
388 env
->spr
[SPR_BOOKE_ESR
] = ESR_FP
;
390 case POWERPC_EXCP_INVAL
:
391 LOG_EXCP("Invalid instruction at " TARGET_FMT_lx
"\n", env
->nip
);
393 env
->spr
[SPR_BOOKE_ESR
] = ESR_PIL
;
395 case POWERPC_EXCP_PRIV
:
397 env
->spr
[SPR_BOOKE_ESR
] = ESR_PPR
;
399 case POWERPC_EXCP_TRAP
:
401 env
->spr
[SPR_BOOKE_ESR
] = ESR_PTR
;
404 /* Should never occur */
405 cpu_abort(cs
, "Invalid program exception %d. Aborting\n",
410 case POWERPC_EXCP_SYSCALL
: /* System call exception */
411 lev
= env
->error_code
;
413 if ((lev
== 1) && cpu
->vhyp
) {
420 * We need to correct the NIP which in this case is supposed
421 * to point to the next instruction
425 /* "PAPR mode" built-in hypercall emulation */
426 if ((lev
== 1) && cpu
->vhyp
) {
427 PPCVirtualHypervisorClass
*vhc
=
428 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu
->vhyp
);
429 vhc
->hypercall(cpu
->vhyp
, cpu
);
433 new_msr
|= (target_ulong
)MSR_HVB
;
436 case POWERPC_EXCP_SYSCALL_VECTORED
: /* scv exception */
437 lev
= env
->error_code
;
438 dump_syscall_vectored(env
);
440 new_msr
|= env
->msr
& ((target_ulong
)1 << MSR_EE
);
441 new_msr
|= env
->msr
& ((target_ulong
)1 << MSR_RI
);
443 case POWERPC_EXCP_FPU
: /* Floating-point unavailable exception */
444 case POWERPC_EXCP_APU
: /* Auxiliary processor unavailable */
445 case POWERPC_EXCP_DECR
: /* Decrementer exception */
447 case POWERPC_EXCP_FIT
: /* Fixed-interval timer interrupt */
449 LOG_EXCP("FIT exception\n");
451 case POWERPC_EXCP_WDT
: /* Watchdog timer interrupt */
452 LOG_EXCP("WDT exception\n");
453 switch (excp_model
) {
454 case POWERPC_EXCP_BOOKE
:
455 srr0
= SPR_BOOKE_CSRR0
;
456 srr1
= SPR_BOOKE_CSRR1
;
462 case POWERPC_EXCP_DTLB
: /* Data TLB error */
463 case POWERPC_EXCP_ITLB
: /* Instruction TLB error */
465 case POWERPC_EXCP_DEBUG
: /* Debug interrupt */
466 if (env
->flags
& POWERPC_FLAG_DE
) {
467 /* FIXME: choose one or the other based on CPU type */
468 srr0
= SPR_BOOKE_DSRR0
;
469 srr1
= SPR_BOOKE_DSRR1
;
470 asrr0
= SPR_BOOKE_CSRR0
;
471 asrr1
= SPR_BOOKE_CSRR1
;
472 /* DBSR already modified by caller */
474 cpu_abort(cs
, "Debug exception triggered on unsupported model\n");
477 case POWERPC_EXCP_SPEU
: /* SPE/embedded floating-point unavailable */
478 env
->spr
[SPR_BOOKE_ESR
] = ESR_SPV
;
480 case POWERPC_EXCP_EFPDI
: /* Embedded floating-point data interrupt */
482 cpu_abort(cs
, "Embedded floating point data exception "
483 "is not implemented yet !\n");
484 env
->spr
[SPR_BOOKE_ESR
] = ESR_SPV
;
486 case POWERPC_EXCP_EFPRI
: /* Embedded floating-point round interrupt */
488 cpu_abort(cs
, "Embedded floating point round exception "
489 "is not implemented yet !\n");
490 env
->spr
[SPR_BOOKE_ESR
] = ESR_SPV
;
492 case POWERPC_EXCP_EPERFM
: /* Embedded performance monitor interrupt */
495 "Performance counter exception is not implemented yet !\n");
497 case POWERPC_EXCP_DOORI
: /* Embedded doorbell interrupt */
499 case POWERPC_EXCP_DOORCI
: /* Embedded doorbell critical interrupt */
500 srr0
= SPR_BOOKE_CSRR0
;
501 srr1
= SPR_BOOKE_CSRR1
;
503 case POWERPC_EXCP_RESET
: /* System reset exception */
504 /* A power-saving exception sets ME, otherwise it is unchanged */
506 /* indicate that we resumed from power save mode */
508 new_msr
|= ((target_ulong
)1 << MSR_ME
);
510 if (env
->msr_mask
& MSR_HVB
) {
512 * ISA specifies HV, but can be delivered to guest with HV
513 * clear (e.g., see FWNMI in PAPR, NMI injection in QEMU).
515 new_msr
|= (target_ulong
)MSR_HVB
;
518 cpu_abort(cs
, "Trying to deliver power-saving system reset "
519 "exception %d with no HV support\n", excp
);
524 case POWERPC_EXCP_DSEG
: /* Data segment exception */
525 case POWERPC_EXCP_ISEG
: /* Instruction segment exception */
526 case POWERPC_EXCP_TRACE
: /* Trace exception */
528 case POWERPC_EXCP_HISI
: /* Hypervisor instruction storage exception */
529 msr
|= env
->error_code
;
531 case POWERPC_EXCP_HDECR
: /* Hypervisor decrementer exception */
532 case POWERPC_EXCP_HDSI
: /* Hypervisor data storage exception */
533 case POWERPC_EXCP_HDSEG
: /* Hypervisor data segment exception */
534 case POWERPC_EXCP_HISEG
: /* Hypervisor instruction segment exception */
535 case POWERPC_EXCP_SDOOR_HV
: /* Hypervisor Doorbell interrupt */
536 case POWERPC_EXCP_HV_EMU
:
537 case POWERPC_EXCP_HVIRT
: /* Hypervisor virtualization */
540 new_msr
|= (target_ulong
)MSR_HVB
;
541 new_msr
|= env
->msr
& ((target_ulong
)1 << MSR_RI
);
543 case POWERPC_EXCP_VPU
: /* Vector unavailable exception */
544 case POWERPC_EXCP_VSXU
: /* VSX unavailable exception */
545 case POWERPC_EXCP_FU
: /* Facility unavailable exception */
547 env
->spr
[SPR_FSCR
] |= ((target_ulong
)env
->error_code
<< 56);
550 case POWERPC_EXCP_HV_FU
: /* Hypervisor Facility Unavailable Exception */
552 env
->spr
[SPR_HFSCR
] |= ((target_ulong
)env
->error_code
<< FSCR_IC_POS
);
555 new_msr
|= (target_ulong
)MSR_HVB
;
556 new_msr
|= env
->msr
& ((target_ulong
)1 << MSR_RI
);
559 case POWERPC_EXCP_PIT
: /* Programmable interval timer interrupt */
560 LOG_EXCP("PIT exception\n");
562 case POWERPC_EXCP_IO
: /* IO error exception */
564 cpu_abort(cs
, "601 IO error exception is not implemented yet !\n");
566 case POWERPC_EXCP_RUNM
: /* Run mode exception */
568 cpu_abort(cs
, "601 run mode exception is not implemented yet !\n");
570 case POWERPC_EXCP_EMUL
: /* Emulation trap exception */
572 cpu_abort(cs
, "602 emulation trap exception "
573 "is not implemented yet !\n");
575 case POWERPC_EXCP_IFTLB
: /* Instruction fetch TLB error */
576 switch (excp_model
) {
577 case POWERPC_EXCP_602
:
578 case POWERPC_EXCP_603
:
579 case POWERPC_EXCP_603E
:
580 case POWERPC_EXCP_G2
:
582 case POWERPC_EXCP_7x5
:
584 case POWERPC_EXCP_74xx
:
587 cpu_abort(cs
, "Invalid instruction TLB miss exception\n");
591 case POWERPC_EXCP_DLTLB
: /* Data load TLB miss */
592 switch (excp_model
) {
593 case POWERPC_EXCP_602
:
594 case POWERPC_EXCP_603
:
595 case POWERPC_EXCP_603E
:
596 case POWERPC_EXCP_G2
:
598 case POWERPC_EXCP_7x5
:
600 case POWERPC_EXCP_74xx
:
603 cpu_abort(cs
, "Invalid data load TLB miss exception\n");
607 case POWERPC_EXCP_DSTLB
: /* Data store TLB miss */
608 switch (excp_model
) {
609 case POWERPC_EXCP_602
:
610 case POWERPC_EXCP_603
:
611 case POWERPC_EXCP_603E
:
612 case POWERPC_EXCP_G2
:
614 /* Swap temporary saved registers with GPRs */
615 if (!(new_msr
& ((target_ulong
)1 << MSR_TGPR
))) {
616 new_msr
|= (target_ulong
)1 << MSR_TGPR
;
617 hreg_swap_gpr_tgpr(env
);
620 case POWERPC_EXCP_7x5
:
622 #if defined(DEBUG_SOFTWARE_TLB)
623 if (qemu_log_enabled()) {
625 target_ulong
*miss
, *cmp
;
628 if (excp
== POWERPC_EXCP_IFTLB
) {
631 miss
= &env
->spr
[SPR_IMISS
];
632 cmp
= &env
->spr
[SPR_ICMP
];
634 if (excp
== POWERPC_EXCP_DLTLB
) {
640 miss
= &env
->spr
[SPR_DMISS
];
641 cmp
= &env
->spr
[SPR_DCMP
];
643 qemu_log("6xx %sTLB miss: %cM " TARGET_FMT_lx
" %cC "
644 TARGET_FMT_lx
" H1 " TARGET_FMT_lx
" H2 "
645 TARGET_FMT_lx
" %08x\n", es
, en
, *miss
, en
, *cmp
,
646 env
->spr
[SPR_HASH1
], env
->spr
[SPR_HASH2
],
650 msr
|= env
->crf
[0] << 28;
651 msr
|= env
->error_code
; /* key, D/I, S/L bits */
652 /* Set way using a LRU mechanism */
653 msr
|= ((env
->last_way
+ 1) & (env
->nb_ways
- 1)) << 17;
655 case POWERPC_EXCP_74xx
:
657 #if defined(DEBUG_SOFTWARE_TLB)
658 if (qemu_log_enabled()) {
660 target_ulong
*miss
, *cmp
;
663 if (excp
== POWERPC_EXCP_IFTLB
) {
666 miss
= &env
->spr
[SPR_TLBMISS
];
667 cmp
= &env
->spr
[SPR_PTEHI
];
669 if (excp
== POWERPC_EXCP_DLTLB
) {
675 miss
= &env
->spr
[SPR_TLBMISS
];
676 cmp
= &env
->spr
[SPR_PTEHI
];
678 qemu_log("74xx %sTLB miss: %cM " TARGET_FMT_lx
" %cC "
679 TARGET_FMT_lx
" %08x\n", es
, en
, *miss
, en
, *cmp
,
683 msr
|= env
->error_code
; /* key bit */
686 cpu_abort(cs
, "Invalid data store TLB miss exception\n");
690 case POWERPC_EXCP_FPA
: /* Floating-point assist exception */
692 cpu_abort(cs
, "Floating point assist exception "
693 "is not implemented yet !\n");
695 case POWERPC_EXCP_DABR
: /* Data address breakpoint */
697 cpu_abort(cs
, "DABR exception is not implemented yet !\n");
699 case POWERPC_EXCP_IABR
: /* Instruction address breakpoint */
701 cpu_abort(cs
, "IABR exception is not implemented yet !\n");
703 case POWERPC_EXCP_SMI
: /* System management interrupt */
705 cpu_abort(cs
, "SMI exception is not implemented yet !\n");
707 case POWERPC_EXCP_THERM
: /* Thermal interrupt */
709 cpu_abort(cs
, "Thermal management exception "
710 "is not implemented yet !\n");
712 case POWERPC_EXCP_PERFM
: /* Embedded performance monitor interrupt */
715 "Performance counter exception is not implemented yet !\n");
717 case POWERPC_EXCP_VPUA
: /* Vector assist exception */
719 cpu_abort(cs
, "VPU assist exception is not implemented yet !\n");
721 case POWERPC_EXCP_SOFTP
: /* Soft patch exception */
724 "970 soft-patch exception is not implemented yet !\n");
726 case POWERPC_EXCP_MAINT
: /* Maintenance exception */
729 "970 maintenance exception is not implemented yet !\n");
731 case POWERPC_EXCP_MEXTBR
: /* Maskable external breakpoint */
733 cpu_abort(cs
, "Maskable external exception "
734 "is not implemented yet !\n");
736 case POWERPC_EXCP_NMEXTBR
: /* Non maskable external breakpoint */
738 cpu_abort(cs
, "Non maskable external exception "
739 "is not implemented yet !\n");
743 cpu_abort(cs
, "Invalid PowerPC exception %d. Aborting\n", excp
);
748 if (!(env
->msr_mask
& MSR_HVB
)) {
749 if (new_msr
& MSR_HVB
) {
750 cpu_abort(cs
, "Trying to deliver HV exception (MSR) %d with "
751 "no HV support\n", excp
);
753 if (srr0
== SPR_HSRR0
) {
754 cpu_abort(cs
, "Trying to deliver HV exception (HSRR) %d with "
755 "no HV support\n", excp
);
760 * Sort out endianness of interrupt, this differs depending on the
761 * CPU, the HV mode, etc...
764 if (excp_model
== POWERPC_EXCP_POWER7
) {
765 if (!(new_msr
& MSR_HVB
) && (env
->spr
[SPR_LPCR
] & LPCR_ILE
)) {
766 new_msr
|= (target_ulong
)1 << MSR_LE
;
768 } else if (excp_model
== POWERPC_EXCP_POWER8
) {
769 if (new_msr
& MSR_HVB
) {
770 if (env
->spr
[SPR_HID0
] & HID0_HILE
) {
771 new_msr
|= (target_ulong
)1 << MSR_LE
;
773 } else if (env
->spr
[SPR_LPCR
] & LPCR_ILE
) {
774 new_msr
|= (target_ulong
)1 << MSR_LE
;
776 } else if (excp_model
== POWERPC_EXCP_POWER9
) {
777 if (new_msr
& MSR_HVB
) {
778 if (env
->spr
[SPR_HID0
] & HID0_POWER9_HILE
) {
779 new_msr
|= (target_ulong
)1 << MSR_LE
;
781 } else if (env
->spr
[SPR_LPCR
] & LPCR_ILE
) {
782 new_msr
|= (target_ulong
)1 << MSR_LE
;
784 } else if (msr_ile
) {
785 new_msr
|= (target_ulong
)1 << MSR_LE
;
789 new_msr
|= (target_ulong
)1 << MSR_LE
;
794 * AIL only works if there is no HV transition and we are running
795 * with translations enabled
797 if (!((msr
>> MSR_IR
) & 1) || !((msr
>> MSR_DR
) & 1) ||
798 ((new_msr
& MSR_HVB
) && !(msr
& MSR_HVB
))) {
802 vector
= env
->excp_vectors
[excp
];
803 if (vector
== (target_ulong
)-1ULL) {
804 cpu_abort(cs
, "Raised an exception without defined vector %d\n",
808 vector
|= env
->excp_prefix
;
810 /* If any alternate SRR register are defined, duplicate saved values */
812 env
->spr
[asrr0
] = env
->nip
;
815 env
->spr
[asrr1
] = msr
;
818 #if defined(TARGET_PPC64)
819 if (excp_model
== POWERPC_EXCP_BOOKE
) {
820 if (env
->spr
[SPR_BOOKE_EPCR
] & EPCR_ICM
) {
821 /* Cat.64-bit: EPCR.ICM is copied to MSR.CM */
822 new_msr
|= (target_ulong
)1 << MSR_CM
;
824 vector
= (uint32_t)vector
;
827 if (!msr_isf
&& !mmu_is_64bit(env
->mmu_model
)) {
828 vector
= (uint32_t)vector
;
830 new_msr
|= (target_ulong
)1 << MSR_SF
;
835 if (excp
!= POWERPC_EXCP_SYSCALL_VECTORED
) {
837 env
->spr
[srr0
] = env
->nip
;
840 env
->spr
[srr1
] = msr
;
844 new_msr
|= (1 << MSR_IR
) | (1 << MSR_DR
);
845 vector
|= ppc_excp_vector_offset(cs
, ail
);
848 #if defined(TARGET_PPC64)
850 /* scv AIL is a little different */
852 new_msr
|= (1 << MSR_IR
) | (1 << MSR_DR
);
854 if (ail
== AIL_C000_0000_0000_4000
) {
855 vector
|= 0xc000000000003000ull
;
857 vector
|= 0x0000000000017000ull
;
859 vector
+= lev
* 0x20;
866 powerpc_set_excp_state(cpu
, vector
, new_msr
);
869 void ppc_cpu_do_interrupt(CPUState
*cs
)
871 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
872 CPUPPCState
*env
= &cpu
->env
;
874 powerpc_excp(cpu
, env
->excp_model
, cs
->exception_index
);
877 static void ppc_hw_interrupt(CPUPPCState
*env
)
879 PowerPCCPU
*cpu
= env_archcpu(env
);
883 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_RESET
)) {
884 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_RESET
);
885 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_RESET
);
888 /* Machine check exception */
889 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_MCK
)) {
890 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_MCK
);
891 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_MCHECK
);
895 /* External debug exception */
896 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_DEBUG
)) {
897 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_DEBUG
);
898 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_DEBUG
);
904 * For interrupts that gate on MSR:EE, we need to do something a
905 * bit more subtle, as we need to let them through even when EE is
906 * clear when coming out of some power management states (in order
907 * for them to become a 0x100).
909 async_deliver
= (msr_ee
!= 0) || env
->resume_as_sreset
;
911 /* Hypervisor decrementer exception */
912 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_HDECR
)) {
913 /* LPCR will be clear when not supported so this will work */
914 bool hdice
= !!(env
->spr
[SPR_LPCR
] & LPCR_HDICE
);
915 if ((async_deliver
|| msr_hv
== 0) && hdice
) {
916 /* HDEC clears on delivery */
917 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_HDECR
);
918 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_HDECR
);
923 /* Hypervisor virtualization interrupt */
924 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_HVIRT
)) {
925 /* LPCR will be clear when not supported so this will work */
926 bool hvice
= !!(env
->spr
[SPR_LPCR
] & LPCR_HVICE
);
927 if ((async_deliver
|| msr_hv
== 0) && hvice
) {
928 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_HVIRT
);
933 /* External interrupt can ignore MSR:EE under some circumstances */
934 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_EXT
)) {
935 bool lpes0
= !!(env
->spr
[SPR_LPCR
] & LPCR_LPES0
);
936 bool heic
= !!(env
->spr
[SPR_LPCR
] & LPCR_HEIC
);
937 /* HEIC blocks delivery to the hypervisor */
938 if ((async_deliver
&& !(heic
&& msr_hv
&& !msr_pr
)) ||
939 (env
->has_hv_mode
&& msr_hv
== 0 && !lpes0
)) {
940 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_EXTERNAL
);
945 /* External critical interrupt */
946 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_CEXT
)) {
947 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_CRITICAL
);
951 if (async_deliver
!= 0) {
952 /* Watchdog timer on embedded PowerPC */
953 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_WDT
)) {
954 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_WDT
);
955 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_WDT
);
958 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_CDOORBELL
)) {
959 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_CDOORBELL
);
960 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_DOORCI
);
963 /* Fixed interval timer on embedded PowerPC */
964 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_FIT
)) {
965 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_FIT
);
966 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_FIT
);
969 /* Programmable interval timer on embedded PowerPC */
970 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_PIT
)) {
971 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_PIT
);
972 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_PIT
);
975 /* Decrementer exception */
976 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_DECR
)) {
977 if (ppc_decr_clear_on_delivery(env
)) {
978 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_DECR
);
980 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_DECR
);
983 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_DOORBELL
)) {
984 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_DOORBELL
);
985 if (is_book3s_arch2x(env
)) {
986 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_SDOOR
);
988 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_DOORI
);
992 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_HDOORBELL
)) {
993 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_HDOORBELL
);
994 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_SDOOR_HV
);
997 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_PERFM
)) {
998 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_PERFM
);
999 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_PERFM
);
1002 /* Thermal interrupt */
1003 if (env
->pending_interrupts
& (1 << PPC_INTERRUPT_THERM
)) {
1004 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_THERM
);
1005 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_THERM
);
1010 if (env
->resume_as_sreset
) {
1012 * This is a bug ! It means that has_work took us out of halt without
1013 * anything to deliver while in a PM state that requires getting
1016 * This means we will incorrectly execute past the power management
1017 * instruction instead of triggering a reset.
1019 * It generally means a discrepancy between the wakeup conditions in the
1020 * processor has_work implementation and the logic in this function.
1022 cpu_abort(env_cpu(env
),
1023 "Wakeup from PM state but interrupt Undelivered");
1027 void ppc_cpu_do_system_reset(CPUState
*cs
)
1029 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1030 CPUPPCState
*env
= &cpu
->env
;
1032 powerpc_excp(cpu
, env
->excp_model
, POWERPC_EXCP_RESET
);
1035 void ppc_cpu_do_fwnmi_machine_check(CPUState
*cs
, target_ulong vector
)
1037 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1038 CPUPPCState
*env
= &cpu
->env
;
1039 PowerPCCPUClass
*pcc
= POWERPC_CPU_GET_CLASS(cpu
);
1040 target_ulong msr
= 0;
1043 * Set MSR and NIP for the handler, SRR0/1, DAR and DSISR have already
1046 msr
= (1ULL << MSR_ME
);
1047 msr
|= env
->msr
& (1ULL << MSR_SF
);
1048 if (!(*pcc
->interrupts_big_endian
)(cpu
)) {
1049 msr
|= (1ULL << MSR_LE
);
1052 powerpc_set_excp_state(cpu
, vector
, msr
);
1054 #endif /* !CONFIG_USER_ONLY */
1056 bool ppc_cpu_exec_interrupt(CPUState
*cs
, int interrupt_request
)
1058 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1059 CPUPPCState
*env
= &cpu
->env
;
1061 if (interrupt_request
& CPU_INTERRUPT_HARD
) {
1062 ppc_hw_interrupt(env
);
1063 if (env
->pending_interrupts
== 0) {
1064 cs
->interrupt_request
&= ~CPU_INTERRUPT_HARD
;
1071 #if defined(DEBUG_OP)
1072 static void cpu_dump_rfi(target_ulong RA
, target_ulong msr
)
1074 qemu_log("Return from exception at " TARGET_FMT_lx
" with flags "
1075 TARGET_FMT_lx
"\n", RA
, msr
);
1079 /*****************************************************************************/
1080 /* Exceptions processing helpers */
1082 void raise_exception_err_ra(CPUPPCState
*env
, uint32_t exception
,
1083 uint32_t error_code
, uintptr_t raddr
)
1085 CPUState
*cs
= env_cpu(env
);
1087 cs
->exception_index
= exception
;
1088 env
->error_code
= error_code
;
1089 cpu_loop_exit_restore(cs
, raddr
);
1092 void raise_exception_err(CPUPPCState
*env
, uint32_t exception
,
1093 uint32_t error_code
)
1095 raise_exception_err_ra(env
, exception
, error_code
, 0);
1098 void raise_exception(CPUPPCState
*env
, uint32_t exception
)
1100 raise_exception_err_ra(env
, exception
, 0, 0);
1103 void raise_exception_ra(CPUPPCState
*env
, uint32_t exception
,
1106 raise_exception_err_ra(env
, exception
, 0, raddr
);
1109 void helper_raise_exception_err(CPUPPCState
*env
, uint32_t exception
,
1110 uint32_t error_code
)
1112 raise_exception_err_ra(env
, exception
, error_code
, 0);
1115 void helper_raise_exception(CPUPPCState
*env
, uint32_t exception
)
1117 raise_exception_err_ra(env
, exception
, 0, 0);
1120 #if !defined(CONFIG_USER_ONLY)
1121 void helper_store_msr(CPUPPCState
*env
, target_ulong val
)
1123 uint32_t excp
= hreg_store_msr(env
, val
, 0);
1126 CPUState
*cs
= env_cpu(env
);
1127 cpu_interrupt_exittb(cs
);
1128 raise_exception(env
, excp
);
1132 #if defined(TARGET_PPC64)
1133 void helper_pminsn(CPUPPCState
*env
, powerpc_pm_insn_t insn
)
1141 * The architecture specifies that HDEC interrupts are discarded
1144 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_HDECR
);
1146 /* Condition for waking up at 0x100 */
1147 env
->resume_as_sreset
= (insn
!= PPC_PM_STOP
) ||
1148 (env
->spr
[SPR_PSSCR
] & PSSCR_EC
);
1150 #endif /* defined(TARGET_PPC64) */
1152 static inline void do_rfi(CPUPPCState
*env
, target_ulong nip
, target_ulong msr
)
1154 CPUState
*cs
= env_cpu(env
);
1156 /* MSR:POW cannot be set by any form of rfi */
1157 msr
&= ~(1ULL << MSR_POW
);
1159 #if defined(TARGET_PPC64)
1160 /* Switching to 32-bit ? Crop the nip */
1161 if (!msr_is_64bit(env
, msr
)) {
1162 nip
= (uint32_t)nip
;
1165 nip
= (uint32_t)nip
;
1167 /* XXX: beware: this is false if VLE is supported */
1168 env
->nip
= nip
& ~((target_ulong
)0x00000003);
1169 hreg_store_msr(env
, msr
, 1);
1170 #if defined(DEBUG_OP)
1171 cpu_dump_rfi(env
->nip
, env
->msr
);
1174 * No need to raise an exception here, as rfi is always the last
1177 cpu_interrupt_exittb(cs
);
1178 /* Reset the reservation */
1179 env
->reserve_addr
= -1;
1181 /* Context synchronizing: check if TCG TLB needs flush */
1182 check_tlb_flush(env
, false);
1185 void helper_rfi(CPUPPCState
*env
)
1187 do_rfi(env
, env
->spr
[SPR_SRR0
], env
->spr
[SPR_SRR1
] & 0xfffffffful
);
1190 #define MSR_BOOK3S_MASK
1191 #if defined(TARGET_PPC64)
1192 void helper_rfid(CPUPPCState
*env
)
1195 * The architecture defines a number of rules for which bits can
1196 * change but in practice, we handle this in hreg_store_msr()
1197 * which will be called by do_rfi(), so there is no need to filter
1200 do_rfi(env
, env
->spr
[SPR_SRR0
], env
->spr
[SPR_SRR1
]);
1203 void helper_rfscv(CPUPPCState
*env
)
1205 do_rfi(env
, env
->lr
, env
->ctr
);
1208 void helper_hrfid(CPUPPCState
*env
)
1210 do_rfi(env
, env
->spr
[SPR_HSRR0
], env
->spr
[SPR_HSRR1
]);
1214 /*****************************************************************************/
1215 /* Embedded PowerPC specific helpers */
1216 void helper_40x_rfci(CPUPPCState
*env
)
1218 do_rfi(env
, env
->spr
[SPR_40x_SRR2
], env
->spr
[SPR_40x_SRR3
]);
1221 void helper_rfci(CPUPPCState
*env
)
1223 do_rfi(env
, env
->spr
[SPR_BOOKE_CSRR0
], env
->spr
[SPR_BOOKE_CSRR1
]);
1226 void helper_rfdi(CPUPPCState
*env
)
1228 /* FIXME: choose CSRR1 or DSRR1 based on cpu type */
1229 do_rfi(env
, env
->spr
[SPR_BOOKE_DSRR0
], env
->spr
[SPR_BOOKE_DSRR1
]);
1232 void helper_rfmci(CPUPPCState
*env
)
1234 /* FIXME: choose CSRR1 or MCSRR1 based on cpu type */
1235 do_rfi(env
, env
->spr
[SPR_BOOKE_MCSRR0
], env
->spr
[SPR_BOOKE_MCSRR1
]);
1239 void helper_tw(CPUPPCState
*env
, target_ulong arg1
, target_ulong arg2
,
1242 if (!likely(!(((int32_t)arg1
< (int32_t)arg2
&& (flags
& 0x10)) ||
1243 ((int32_t)arg1
> (int32_t)arg2
&& (flags
& 0x08)) ||
1244 ((int32_t)arg1
== (int32_t)arg2
&& (flags
& 0x04)) ||
1245 ((uint32_t)arg1
< (uint32_t)arg2
&& (flags
& 0x02)) ||
1246 ((uint32_t)arg1
> (uint32_t)arg2
&& (flags
& 0x01))))) {
1247 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1248 POWERPC_EXCP_TRAP
, GETPC());
1252 #if defined(TARGET_PPC64)
1253 void helper_td(CPUPPCState
*env
, target_ulong arg1
, target_ulong arg2
,
1256 if (!likely(!(((int64_t)arg1
< (int64_t)arg2
&& (flags
& 0x10)) ||
1257 ((int64_t)arg1
> (int64_t)arg2
&& (flags
& 0x08)) ||
1258 ((int64_t)arg1
== (int64_t)arg2
&& (flags
& 0x04)) ||
1259 ((uint64_t)arg1
< (uint64_t)arg2
&& (flags
& 0x02)) ||
1260 ((uint64_t)arg1
> (uint64_t)arg2
&& (flags
& 0x01))))) {
1261 raise_exception_err_ra(env
, POWERPC_EXCP_PROGRAM
,
1262 POWERPC_EXCP_TRAP
, GETPC());
1267 #if !defined(CONFIG_USER_ONLY)
1268 /*****************************************************************************/
1269 /* PowerPC 601 specific instructions (POWER bridge) */
1271 void helper_rfsvc(CPUPPCState
*env
)
1273 do_rfi(env
, env
->lr
, env
->ctr
& 0x0000FFFF);
1276 /* Embedded.Processor Control */
1277 static int dbell2irq(target_ulong rb
)
1279 int msg
= rb
& DBELL_TYPE_MASK
;
1283 case DBELL_TYPE_DBELL
:
1284 irq
= PPC_INTERRUPT_DOORBELL
;
1286 case DBELL_TYPE_DBELL_CRIT
:
1287 irq
= PPC_INTERRUPT_CDOORBELL
;
1289 case DBELL_TYPE_G_DBELL
:
1290 case DBELL_TYPE_G_DBELL_CRIT
:
1291 case DBELL_TYPE_G_DBELL_MC
:
1300 void helper_msgclr(CPUPPCState
*env
, target_ulong rb
)
1302 int irq
= dbell2irq(rb
);
1308 env
->pending_interrupts
&= ~(1 << irq
);
1311 void helper_msgsnd(target_ulong rb
)
1313 int irq
= dbell2irq(rb
);
1314 int pir
= rb
& DBELL_PIRTAG_MASK
;
1321 qemu_mutex_lock_iothread();
1323 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1324 CPUPPCState
*cenv
= &cpu
->env
;
1326 if ((rb
& DBELL_BRDCAST
) || (cenv
->spr
[SPR_BOOKE_PIR
] == pir
)) {
1327 cenv
->pending_interrupts
|= 1 << irq
;
1328 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
1331 qemu_mutex_unlock_iothread();
1334 /* Server Processor Control */
1336 static bool dbell_type_server(target_ulong rb
)
1339 * A Directed Hypervisor Doorbell message is sent only if the
1340 * message type is 5. All other types are reserved and the
1341 * instruction is a no-op
1343 return (rb
& DBELL_TYPE_MASK
) == DBELL_TYPE_DBELL_SERVER
;
1346 void helper_book3s_msgclr(CPUPPCState
*env
, target_ulong rb
)
1348 if (!dbell_type_server(rb
)) {
1352 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_HDOORBELL
);
1355 static void book3s_msgsnd_common(int pir
, int irq
)
1359 qemu_mutex_lock_iothread();
1361 PowerPCCPU
*cpu
= POWERPC_CPU(cs
);
1362 CPUPPCState
*cenv
= &cpu
->env
;
1364 /* TODO: broadcast message to all threads of the same processor */
1365 if (cenv
->spr_cb
[SPR_PIR
].default_value
== pir
) {
1366 cenv
->pending_interrupts
|= 1 << irq
;
1367 cpu_interrupt(cs
, CPU_INTERRUPT_HARD
);
1370 qemu_mutex_unlock_iothread();
1373 void helper_book3s_msgsnd(target_ulong rb
)
1375 int pir
= rb
& DBELL_PROCIDTAG_MASK
;
1377 if (!dbell_type_server(rb
)) {
1381 book3s_msgsnd_common(pir
, PPC_INTERRUPT_HDOORBELL
);
1384 #if defined(TARGET_PPC64)
1385 void helper_book3s_msgclrp(CPUPPCState
*env
, target_ulong rb
)
1387 helper_hfscr_facility_check(env
, HFSCR_MSGP
, "msgclrp", HFSCR_IC_MSGP
);
1389 if (!dbell_type_server(rb
)) {
1393 env
->pending_interrupts
&= ~(1 << PPC_INTERRUPT_DOORBELL
);
1397 * sends a message to other threads that are on the same
1398 * multi-threaded processor
1400 void helper_book3s_msgsndp(CPUPPCState
*env
, target_ulong rb
)
1402 int pir
= env
->spr_cb
[SPR_PIR
].default_value
;
1404 helper_hfscr_facility_check(env
, HFSCR_MSGP
, "msgsndp", HFSCR_IC_MSGP
);
1406 if (!dbell_type_server(rb
)) {
1410 /* TODO: TCG supports only one thread */
1412 book3s_msgsnd_common(pir
, PPC_INTERRUPT_DOORBELL
);
1417 void ppc_cpu_do_unaligned_access(CPUState
*cs
, vaddr vaddr
,
1418 MMUAccessType access_type
,
1419 int mmu_idx
, uintptr_t retaddr
)
1421 CPUPPCState
*env
= cs
->env_ptr
;
1424 /* Restore state and reload the insn we executed, for filling in DSISR. */
1425 cpu_restore_state(cs
, retaddr
, true);
1426 insn
= cpu_ldl_code(env
, env
->nip
);
1428 cs
->exception_index
= POWERPC_EXCP_ALIGN
;
1429 env
->error_code
= insn
& 0x03FF0000;