12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- From a64af206b15f9b7ffc16e0b9b7bba3cb26d20194 Mon Sep 17 00:00:00 2001
- From: Frank Chang <frank.chang@sifive.com>
- Date: Mon, 13 Sep 2021 20:39:21 +0800
- Subject: [PATCH 107/107] target/riscv: Force to set mstatus_hs.[SD|VS] bits in
- mark_vs_dirty()
- When V=1, both vsstauts.VS and HS-level sstatus.VS are in effect.
- Modifying the floating-point state when V=1 causes both fields to
- be set to 3 (Dirty).
- However, it's possible that HS-level sstatus.VS is Clean and VS-level
- vsstatus.VS is Dirty at the time mark_vs_dirty() is called when V=1.
- We can't early return for this case because we still need to set
- sstatus.VS to Dirty according to spec.
- Signed-off-by: Frank Chang <frank.chang@sifive.com>
- Reviewed-by: Vincent Chen <vincent.chen@sifive.com>
- Tested-by: Vincent Chen <vincent.chen@sifive.com>
- ---
- target/riscv/translate.c | 15 ++++++++++-----
- 1 file changed, 10 insertions(+), 5 deletions(-)
- diff --git a/target/riscv/translate.c b/target/riscv/translate.c
- index f6c534ce47..744b4ffaa7 100644
- --- a/target/riscv/translate.c
- +++ b/target/riscv/translate.c
- @@ -435,9 +435,19 @@ static inline void mark_fs_dirty(DisasContext *ctx) { }
- static void mark_vs_dirty(DisasContext *ctx)
- {
- TCGv tmp;
- +
- + if (ctx->virt_enabled) {
- + tmp = tcg_temp_new();
- + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
- + tcg_gen_ori_tl(tmp, tmp, MSTATUS_VS | MSTATUS_SD);
- + tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
- + tcg_temp_free(tmp);
- + }
- +
- if (ctx->mstatus_vs == MSTATUS_VS) {
- return;
- }
- +
- /* Remember the state change for the rest of the TB. */
- ctx->mstatus_vs = MSTATUS_VS;
-
- @@ -446,11 +456,6 @@ static void mark_vs_dirty(DisasContext *ctx)
- tcg_gen_ori_tl(tmp, tmp, MSTATUS_VS | MSTATUS_SD);
- tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
-
- - if (ctx->virt_enabled) {
- - tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
- - tcg_gen_ori_tl(tmp, tmp, MSTATUS_VS | MSTATUS_SD);
- - tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus_hs));
- - }
- tcg_temp_free(tmp);
- }
- #else
- --
- 2.33.1
|