diff mbox series

[2/2] target/riscv: Fix sfence.vm/a both available in any priv version

Message ID 20181108120628.29926-3-kbastian@mail.uni-paderborn.de (mailing list archive)
State New, archived
Headers show
Series target/riscv: Bugfixes found in decodetree conversion | expand

Commit Message

Bastian Koppelmann Nov. 8, 2018, 12:06 p.m. UTC
sfence.vm has been replaced in priv v1.10 spec by sfence.vma.

Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 target/riscv/translate.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Richard Henderson Nov. 8, 2018, 3:43 p.m. UTC | #1
On 11/8/18 1:06 PM, Bastian Koppelmann wrote:
> sfence.vm has been replaced in priv v1.10 spec by sfence.vma.
> 
> Reported-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
>  target/riscv/translate.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Alistair Francis Nov. 13, 2018, 8:07 p.m. UTC | #2
On Thu, Nov 8, 2018 at 4:07 AM Bastian Koppelmann
<kbastian@mail.uni-paderborn.de> wrote:
>
> sfence.vm has been replaced in priv v1.10 spec by sfence.vma.
>
> Reported-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/translate.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/target/riscv/translate.c b/target/riscv/translate.c
> index 5359088e24..f44eb9c41b 100644
> --- a/target/riscv/translate.c
> +++ b/target/riscv/translate.c
> @@ -1292,10 +1292,14 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
>  #ifndef CONFIG_USER_ONLY
>      /* Extract funct7 value and check whether it matches SFENCE.VMA */
>      if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) {
> -        /* sfence.vma */
> -        /* TODO: handle ASID specific fences */
> -        gen_helper_tlb_flush(cpu_env);
> -        return;
> +        if (env->priv_ver == PRIV_VERSION_1_10_0) {
> +            /* sfence.vma */
> +            /* TODO: handle ASID specific fences */
> +            gen_helper_tlb_flush(cpu_env);
> +            return;
> +        } else {
> +            gen_exception_illegal(ctx);
> +        }
>      }
>  #endif
>
> @@ -1342,7 +1346,11 @@ static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
>              gen_helper_wfi(cpu_env);
>              break;
>          case 0x104: /* SFENCE.VM */
> -            gen_helper_tlb_flush(cpu_env);
> +            if (env->priv_ver <= PRIV_VERSION_1_09_1) {
> +                gen_helper_tlb_flush(cpu_env);
> +            } else {
> +                gen_exception_illegal(ctx);
> +            }
>              break;
>  #endif
>          default:
> --
> 2.19.1
>
>
diff mbox series

Patch

diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 5359088e24..f44eb9c41b 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1292,10 +1292,14 @@  static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
 #ifndef CONFIG_USER_ONLY
     /* Extract funct7 value and check whether it matches SFENCE.VMA */
     if ((opc == OPC_RISC_ECALL) && ((csr >> 5) == 9)) {
-        /* sfence.vma */
-        /* TODO: handle ASID specific fences */
-        gen_helper_tlb_flush(cpu_env);
-        return;
+        if (env->priv_ver == PRIV_VERSION_1_10_0) {
+            /* sfence.vma */
+            /* TODO: handle ASID specific fences */
+            gen_helper_tlb_flush(cpu_env);
+            return;
+        } else {
+            gen_exception_illegal(ctx);
+        }
     }
 #endif
 
@@ -1342,7 +1346,11 @@  static void gen_system(CPURISCVState *env, DisasContext *ctx, uint32_t opc,
             gen_helper_wfi(cpu_env);
             break;
         case 0x104: /* SFENCE.VM */
-            gen_helper_tlb_flush(cpu_env);
+            if (env->priv_ver <= PRIV_VERSION_1_09_1) {
+                gen_helper_tlb_flush(cpu_env);
+            } else {
+                gen_exception_illegal(ctx);
+            }
             break;
 #endif
         default: