2679
tcg_gen_movi_tl(cpu_lr, nip);
2680
}
2681
2682
-/*** System linkage ***/
2683
-
2684
-/* rfi (supervisor only) */
2685
-static void gen_rfi(DisasContext *ctx)
2686
-{
2687
-#if defined(CONFIG_USER_ONLY)
2688
- GEN_PRIV(ctx);
2689
-#else
2690
- /*
2691
- * This instruction doesn't exist anymore on 64-bit server
2692
- * processors compliant with arch 2.x
2693
- */
2694
- if (is_book3s_arch2x(ctx)) {
2695
- gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL);
2696
- return;
2697
- }
2698
- /* Restore CPU state */
2699
- CHK_SV(ctx);
2700
- translator_io_start(&ctx->base);
2701
- gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_NORECORD);
2702
- gen_helper_rfi(tcg_env);
2703
- ctx->base.is_jmp = DISAS_EXIT;
2704
-#endif
2705
-}
2706
-
2707
-#if defined(TARGET_PPC64)
2708
-static void gen_rfid(DisasContext *ctx)
2709
-{
2710
-#if defined(CONFIG_USER_ONLY)
2711
- GEN_PRIV(ctx);
2712
-#else
2713
- /* Restore CPU state */
2714
- CHK_SV(ctx);
2715
- translator_io_start(&ctx->base);
2716
- gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_NORECORD);
2717
- gen_helper_rfid(tcg_env);
2718
- ctx->base.is_jmp = DISAS_EXIT;
2719
-#endif
2720
-}
2721
-
2722
-#if !defined(CONFIG_USER_ONLY)
2723
-static void gen_rfscv(DisasContext *ctx)
2724
-{
2725
-#if defined(CONFIG_USER_ONLY)
2726
- GEN_PRIV(ctx);
2727
-#else
2728
- /* Restore CPU state */
2729
- CHK_SV(ctx);
2730
- translator_io_start(&ctx->base);
2731
- gen_update_branch_history(ctx, ctx->cia, NULL, BHRB_TYPE_NORECORD);
2732
- gen_helper_rfscv(tcg_env);
2733
- ctx->base.is_jmp = DISAS_EXIT;
2734
-#endif
2735
-}
2736
-#endif
2737
-
2738
-static void gen_hrfid(DisasContext *ctx)
2739
-{
2740
-#if defined(CONFIG_USER_ONLY)
2741
- GEN_PRIV(ctx);
2742
-#else
2743
- /* Restore CPU state */
2744
- CHK_HV(ctx);
2745
- translator_io_start(&ctx->base);
2746
- gen_helper_hrfid(tcg_env);
2747
- ctx->base.is_jmp = DISAS_EXIT;
2748
-#endif
2749
-}
2750
-#endif
2751
-
2752
-/* sc */
2753
-#if defined(CONFIG_USER_ONLY)
2754
-#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL_USER
2755
-#else
2756
-#define POWERPC_SYSCALL POWERPC_EXCP_SYSCALL
2757
-#endif
2758
-static void gen_sc(DisasContext *ctx)
2759
-{
2760
- uint32_t lev;
2761
-
2762
- /*
2763
- * LEV is a 7-bit field, but the top 6 bits are treated as a reserved
2764
- * field (i.e., ignored). ISA v3.1 changes that to 5 bits, but that is
2765
- * for Ultravisor which TCG does not support, so just ignore the top 6.
2766
- */
2767
- lev = (ctx->opcode >> 5) & 0x1;
2768
- gen_exception_err(ctx, POWERPC_SYSCALL, lev);
2769
-}
2770
-
2771
-#if defined(TARGET_PPC64)
2772
-#if !defined(CONFIG_USER_ONLY)
2773
-static void gen_scv(DisasContext *ctx)
2774
-{
2775
- uint32_t lev = (ctx->opcode >> 5) & 0x7F;
2776
-
2777
- /* Set the PC back to the faulting instruction. */
2778
- gen_update_nip(ctx, ctx->cia);
2779
- gen_helper_scv(tcg_env, tcg_constant_i32(lev));
2780
-
2781
- ctx->base.is_jmp = DISAS_NORETURN;
2782
-}
2783
-#endif
2784
-#endif
2785
-
2682
/*** Trap ***/
2683
2684
/* Check for unconditional traps (always or never) */
4051
#define TRANS64(NAME, FUNC, ...) \
4052
static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4053
{ REQUIRE_64BIT(ctx); return FUNC(ctx, a, ##__VA_ARGS__); }
4054
+#define TRANS64_FLAGS(FLAGS, NAME, FUNC, ...) \
4055
+ static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4056
+ { \
4057
+ REQUIRE_64BIT(ctx); \
4058
+ REQUIRE_INSNS_FLAGS(ctx, FLAGS); \
4059
+ return FUNC(ctx, a, ##__VA_ARGS__); \
4060
+ }
4061
#define TRANS64_FLAGS2(FLAGS2, NAME, FUNC, ...) \
4062
static bool trans_##NAME(DisasContext *ctx, arg_##NAME *a) \
4063
{ \
4432
GEN_HANDLER_E(dform39, 0x39, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
4433
/* handles stfdp, stxsd, stxssp */
4434
GEN_HANDLER_E(dform3D, 0x3D, 0xFF, 0xFF, 0x00000000, PPC_NONE, PPC2_ISA205),
4532
-/* ISA v3.0 changed the extended opcode from 62 to 30 */
4533
-GEN_HANDLER(rfi, 0x13, 0x12, 0x01, 0x03FF8001, PPC_FLOW),
4534
-#if defined(TARGET_PPC64)
4535
-GEN_HANDLER(rfid, 0x13, 0x12, 0x00, 0x03FF8001, PPC_64B),
4536
-#if !defined(CONFIG_USER_ONLY)
4537
-/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
4538
-GEN_HANDLER_E(scv, 0x11, 0x10, 0xFF, 0x03FFF01E, PPC_NONE, PPC2_ISA300),
4539
-GEN_HANDLER_E(scv, 0x11, 0x00, 0xFF, 0x03FFF01E, PPC_NONE, PPC2_ISA300),
4540
-GEN_HANDLER_E(rfscv, 0x13, 0x12, 0x02, 0x03FF8001, PPC_NONE, PPC2_ISA300),
4541
-#endif
4542
-GEN_HANDLER(hrfid, 0x13, 0x12, 0x08, 0x03FF8001, PPC_64H),
4543
-#endif
4544
-/* Top bit of opc2 corresponds with low bit of LEV, so use two handlers */
4545
-GEN_HANDLER(sc, 0x11, 0x11, 0xFF, 0x03FFF01D, PPC_FLOW),
4546
-GEN_HANDLER(sc, 0x11, 0x01, 0xFF, 0x03FFF01D, PPC_FLOW),
4435
GEN_HANDLER(mcrxr, 0x1F, 0x00, 0x10, 0x007FF801, PPC_MISC),
4436
GEN_HANDLER(mfspr, 0x1F, 0x13, 0x0A, 0x00000001, PPC_MISC),
4437
GEN_HANDLER(mftb, 0x1F, 0x13, 0x0B, 0x00000001, PPC_MFTB),