sockets: avoid string truncation warnings when copying UNIX path
[qemu/ar7.git] / target / riscv / insn_trans / trans_privileged.inc.c
blobacb605923e6810e83adf1ba43bec9ca592b6f1ee
1 /*
2 * RISC-V translation routines for the RISC-V privileged instructions.
4 * Copyright (c) 2016-2017 Sagar Karandikar, sagark@eecs.berkeley.edu
5 * Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de
6 * Bastian Koppelmann, kbastian@mail.uni-paderborn.de
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2 or later, as published by the Free Software Foundation.
12 * This program is distributed in the hope it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
21 static bool trans_ecall(DisasContext *ctx, arg_ecall *a)
23 /* always generates U-level ECALL, fixed in do_interrupt handler */
24 generate_exception(ctx, RISCV_EXCP_U_ECALL);
25 tcg_gen_exit_tb(NULL, 0); /* no chaining */
26 ctx->base.is_jmp = DISAS_NORETURN;
27 return true;
30 static bool trans_ebreak(DisasContext *ctx, arg_ebreak *a)
32 generate_exception(ctx, RISCV_EXCP_BREAKPOINT);
33 tcg_gen_exit_tb(NULL, 0); /* no chaining */
34 ctx->base.is_jmp = DISAS_NORETURN;
35 return true;
38 static bool trans_uret(DisasContext *ctx, arg_uret *a)
40 return false;
43 static bool trans_sret(DisasContext *ctx, arg_sret *a)
45 #ifndef CONFIG_USER_ONLY
46 tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next);
48 if (has_ext(ctx, RVS)) {
49 gen_helper_sret(cpu_pc, cpu_env, cpu_pc);
50 tcg_gen_exit_tb(NULL, 0); /* no chaining */
51 ctx->base.is_jmp = DISAS_NORETURN;
52 } else {
53 return false;
55 return true;
56 #else
57 return false;
58 #endif
61 static bool trans_hret(DisasContext *ctx, arg_hret *a)
63 return false;
66 static bool trans_mret(DisasContext *ctx, arg_mret *a)
68 #ifndef CONFIG_USER_ONLY
69 tcg_gen_movi_tl(cpu_pc, ctx->base.pc_next);
70 gen_helper_mret(cpu_pc, cpu_env, cpu_pc);
71 tcg_gen_exit_tb(NULL, 0); /* no chaining */
72 ctx->base.is_jmp = DISAS_NORETURN;
73 return true;
74 #else
75 return false;
76 #endif
79 static bool trans_wfi(DisasContext *ctx, arg_wfi *a)
81 #ifndef CONFIG_USER_ONLY
82 tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn);
83 gen_helper_wfi(cpu_env);
84 return true;
85 #else
86 return false;
87 #endif
90 static bool trans_sfence_vma(DisasContext *ctx, arg_sfence_vma *a)
92 #ifndef CONFIG_USER_ONLY
93 if (ctx->priv_ver == PRIV_VERSION_1_10_0) {
94 gen_helper_tlb_flush(cpu_env);
95 return true;
97 #endif
98 return false;
101 static bool trans_sfence_vm(DisasContext *ctx, arg_sfence_vm *a)
103 #ifndef CONFIG_USER_ONLY
104 if (ctx->priv_ver <= PRIV_VERSION_1_09_1) {
105 gen_helper_tlb_flush(cpu_env);
106 return true;
108 #endif
109 return false;