xref: /openbmc/qemu/target/riscv/insn_trans/trans_svinval.c.inc (revision f21b36a022bb23a696058133bc938e4d91b4d4b8)
1c5d77dddSWeiwei Li/*
2c5d77dddSWeiwei Li * RISC-V translation routines for the Svinval Standard Instruction Set.
3c5d77dddSWeiwei Li *
4c5d77dddSWeiwei Li * Copyright (c) 2020-2022 PLCT lab
5c5d77dddSWeiwei Li *
6c5d77dddSWeiwei Li * This program is free software; you can redistribute it and/or modify it
7c5d77dddSWeiwei Li * under the terms and conditions of the GNU General Public License,
8c5d77dddSWeiwei Li * version 2 or later, as published by the Free Software Foundation.
9c5d77dddSWeiwei Li *
10c5d77dddSWeiwei Li * This program is distributed in the hope it will be useful, but WITHOUT
11c5d77dddSWeiwei Li * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12c5d77dddSWeiwei Li * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13c5d77dddSWeiwei Li * more details.
14c5d77dddSWeiwei Li *
15c5d77dddSWeiwei Li * You should have received a copy of the GNU General Public License along with
16c5d77dddSWeiwei Li * this program.  If not, see <http://www.gnu.org/licenses/>.
17c5d77dddSWeiwei Li */
18c5d77dddSWeiwei Li
19c5d77dddSWeiwei Li#define REQUIRE_SVINVAL(ctx) do {          \
20c5d77dddSWeiwei Li    if (!ctx->cfg_ptr->ext_svinval) {      \
21c5d77dddSWeiwei Li        return false;                      \
22c5d77dddSWeiwei Li    }                                      \
23c5d77dddSWeiwei Li} while (0)
24c5d77dddSWeiwei Li
25c5d77dddSWeiwei Listatic bool trans_sinval_vma(DisasContext *ctx, arg_sinval_vma *a)
26c5d77dddSWeiwei Li{
27c5d77dddSWeiwei Li    REQUIRE_SVINVAL(ctx);
28c5d77dddSWeiwei Li    /* Do the same as sfence.vma currently */
29c5d77dddSWeiwei Li    REQUIRE_EXT(ctx, RVS);
30c5d77dddSWeiwei Li#ifndef CONFIG_USER_ONLY
31*f21b36a0SDeepak Gupta    decode_save_opc(ctx, 0);
32ad75a51eSRichard Henderson    gen_helper_tlb_flush(tcg_env);
33c5d77dddSWeiwei Li    return true;
34c5d77dddSWeiwei Li#endif
35c5d77dddSWeiwei Li    return false;
36c5d77dddSWeiwei Li}
37c5d77dddSWeiwei Li
38c5d77dddSWeiwei Listatic bool trans_sfence_w_inval(DisasContext *ctx, arg_sfence_w_inval *a)
39c5d77dddSWeiwei Li{
40c5d77dddSWeiwei Li    REQUIRE_SVINVAL(ctx);
41c5d77dddSWeiwei Li    REQUIRE_EXT(ctx, RVS);
42c5d77dddSWeiwei Li    /* Do nothing currently */
43c5d77dddSWeiwei Li    return true;
44c5d77dddSWeiwei Li}
45c5d77dddSWeiwei Li
46c5d77dddSWeiwei Listatic bool trans_sfence_inval_ir(DisasContext *ctx, arg_sfence_inval_ir *a)
47c5d77dddSWeiwei Li{
48c5d77dddSWeiwei Li    REQUIRE_SVINVAL(ctx);
49c5d77dddSWeiwei Li    REQUIRE_EXT(ctx, RVS);
50c5d77dddSWeiwei Li    /* Do nothing currently */
51c5d77dddSWeiwei Li    return true;
52c5d77dddSWeiwei Li}
53c5d77dddSWeiwei Li
54c5d77dddSWeiwei Listatic bool trans_hinval_vvma(DisasContext *ctx, arg_hinval_vvma *a)
55c5d77dddSWeiwei Li{
56c5d77dddSWeiwei Li    REQUIRE_SVINVAL(ctx);
57c5d77dddSWeiwei Li    /* Do the same as hfence.vvma currently */
58c5d77dddSWeiwei Li    REQUIRE_EXT(ctx, RVH);
59c5d77dddSWeiwei Li#ifndef CONFIG_USER_ONLY
60*f21b36a0SDeepak Gupta    decode_save_opc(ctx, 0);
61ad75a51eSRichard Henderson    gen_helper_hyp_tlb_flush(tcg_env);
62c5d77dddSWeiwei Li    return true;
63c5d77dddSWeiwei Li#endif
64c5d77dddSWeiwei Li    return false;
65c5d77dddSWeiwei Li}
66c5d77dddSWeiwei Li
67c5d77dddSWeiwei Listatic bool trans_hinval_gvma(DisasContext *ctx, arg_hinval_gvma *a)
68c5d77dddSWeiwei Li{
69c5d77dddSWeiwei Li    REQUIRE_SVINVAL(ctx);
70c5d77dddSWeiwei Li    /* Do the same as hfence.gvma currently */
71c5d77dddSWeiwei Li    REQUIRE_EXT(ctx, RVH);
72c5d77dddSWeiwei Li#ifndef CONFIG_USER_ONLY
73*f21b36a0SDeepak Gupta    decode_save_opc(ctx, 0);
74ad75a51eSRichard Henderson    gen_helper_hyp_gvma_tlb_flush(tcg_env);
75c5d77dddSWeiwei Li    return true;
76c5d77dddSWeiwei Li#endif
77c5d77dddSWeiwei Li    return false;
78c5d77dddSWeiwei Li}
79