[Git][ghc/ghc][wip/supersven/riscv64-ncg] adjustor: Fence for generated code

Sven Tennie (@supersven) gitlab at gitlab.haskell.org
Mon Mar 18 17:37:33 UTC 2024



Sven Tennie pushed to branch wip/supersven/riscv64-ncg at Glasgow Haskell Compiler / GHC


Commits:
c9f1189f by Sven Tennie at 2024-03-18T18:36:34+01:00
adjustor: Fence for generated code

- - - - -


1 changed file:

- rts/adjustor/LibffiAdjustor.c


Changes:

=====================================
rts/adjustor/LibffiAdjustor.c
=====================================
@@ -187,5 +187,16 @@ createAdjustor (int cconv,
         barf("createAdjustor: failed to allocate memory");
     }
 
+#if defined(riscv64_HOST_ARCH)
+    // Synchronize the memory and instruction cache to prevent illegal
+    // instruction exceptions. fence.i works per hart. I'm not sure what happens
+    // when the generated code is called on another hart. Probably, the fence on
+    // read/write is good enough for that. However, if there are illegal
+    // instruction exceptions, this is the place to look at (maybe, that the
+    // fence.i needs to be moved closely before the call.)
+    asm volatile ("fence rw, rw"  : : : "memory");
+    asm volatile ("fence.i" ::: "memory");
+#endif
+
     return (void*)code;
 }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f1189f524bd1b19bb4410082e2b669155dec67

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c9f1189f524bd1b19bb4410082e2b669155dec67
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240318/a9c13198/attachment.html>


More information about the ghc-commits mailing list