Author: jrtc27
Date: Mon Apr  6 22:31:30 2020
New Revision: 359672
URL: https://svnweb.freebsd.org/changeset/base/359672

Log:
  riscv: Make sure local hart's icache is synced in pmap_sync_icache
  
  The only way to flush the local hart's icache is with a FENCE.I (or an
  equivalent SBI call); a normal FENCE is insufficient and, for the
  single-hart case, unnecessary.
  
  Reviewed by:  jhb (mentor), markj
  Approved by:  jhb (mentor), markj
  Differential Revision:        https://reviews.freebsd.org/D24317

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==============================================================================
--- head/sys/riscv/riscv/pmap.c Mon Apr  6 22:29:15 2020        (r359671)
+++ head/sys/riscv/riscv/pmap.c Mon Apr  6 22:31:30 2020        (r359672)
@@ -4335,13 +4335,20 @@ pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_
         * RISC-V harts, the writing hart has to execute a data FENCE
         * before requesting that all remote RISC-V harts execute a
         * FENCE.I."
+        *
+        * However, this is slightly misleading; we still need to
+        * perform a FENCE.I for the local hart, as FENCE does nothing
+        * for its icache. FENCE.I alone is also sufficient for the
+        * local hart.
         */
        sched_pin();
        mask = all_harts;
        CPU_CLR(PCPU_GET(hart), &mask);
-       fence();
-       if (!CPU_EMPTY(&mask) && smp_started)
+       fence_i()
+       if (!CPU_EMPTY(&mask) && smp_started) {
+               fence();
                sbi_remote_fence_i(mask.__bits);
+       }
        sched_unpin();
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to