Skip to content

Instantly share code, notes, and snippets.

@sorear
Created March 10, 2018 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorear/2994acbe327d8741ea0ad892c2619de9 to your computer and use it in GitHub Desktop.
Save sorear/2994acbe327d8741ea0ad892c2619de9 to your computer and use it in GitHub Desktop.
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
index 8912fea..08af864 100644
--- a/target/riscv/op_helper.c
+++ b/target/riscv/op_helper.c
@@ -133,6 +133,7 @@ void csr_write_helper(CPURISCVState *env, target_ulong val_to_write,
MSTATUS_MPP | MSTATUS_MXR;
}
mstatus = (mstatus & ~mask) | (val_to_write & mask);
+ if (mstatus & MSTATUS_FS) mstatus |= MSTATUS_FS; /* FP is always dirty if enabled */
int dirty = (mstatus & MSTATUS_FS) == MSTATUS_FS;
dirty |= (mstatus & MSTATUS_XS) == MSTATUS_XS;
mstatus = set_field(mstatus, MSTATUS_SD, dirty);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment