arch-riscv: make accesses to CSRs SerializeAfter.
authorNils Asmussen <nils.asmussen@barkhauseninstitut.org>
Fri, 14 Feb 2020 16:35:30 +0000 (17:35 +0100)
committerNils Asmussen <nils.asmussen@barkhauseninstitut.org>
Wed, 29 Apr 2020 11:41:55 +0000 (11:41 +0000)
According to page 57 in the RISC-V manual, CSR accesses "need to be
performed in program order with respect to those instructions whose
execution behavior is affected by the state of the accessed CSR".

Thus, we need to make them SerializeAfter to ensure that the following
instructions are executed with the potential changes to the CSR. In
theory, we could be smarter here by only considering write accesses to
CSRs and considering the following instructions, but for now we simply
serialize for every CSR access.

Change-Id: I69391fccaec31c34d944c55bac2f04d37947ebfe
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25655
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gem5 Cloud Project GCB service account <345032938727@cloudbuild.gserviceaccount.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>

src/arch/riscv/isa/decoder.isa

index 8dad14caa425fdbecfd9f206739c63eaf3f5ed18..9e65ecf5c5047f0ead381dc61cad75d312864f80 100644 (file)
@@ -1842,27 +1842,27 @@ decode QUADRANT default Unknown::unknown() {
                 0x1: csrrw({{
                     Rd = data;
                     data = Rs1;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
                 0x2: csrrs({{
                     Rd = data;
                     data |= Rs1;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
                 0x3: csrrc({{
                     Rd = data;
                     data &= ~Rs1;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
                 0x5: csrrwi({{
                     Rd = data;
                     data = uimm;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
                 0x6: csrrsi({{
                     Rd = data;
                     data |= uimm;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
                 0x7: csrrci({{
                     Rd = data;
                     data &= ~uimm;
-                }}, IsNonSpeculative, No_OpClass);
+                }}, IsSerializeAfter, IsNonSpeculative, No_OpClass);
             }
         }