Author: jhb
Date: Thu Jan 30 22:19:48 2020
New Revision: 357313
URL: https://svnweb.freebsd.org/changeset/base/357313

Log:
  Trim duplicate CSR swaps from user exceptions.
  
  The stack pointer is swapped with the sscratch CSR just before the
  jump to cpu_exception_handler_user where the first instruction swaps
  it again.  The two swaps together are a no-op, but the csr swap
  instructions can be expensive (e.g. on Bluespec RISC-V cores csr swap
  instructions force a full pipeline stall).
  
  Reported by:  jrtc27
  Reviewed by:  br
  MFC after:    2 weeks
  Sponsored by: DARPA
  Differential Revision:        https://reviews.freebsd.org/D23394

Modified:
  head/sys/riscv/riscv/exception.S

Modified: head/sys/riscv/riscv/exception.S
==============================================================================
--- head/sys/riscv/riscv/exception.S    Thu Jan 30 20:05:05 2020        
(r357312)
+++ head/sys/riscv/riscv/exception.S    Thu Jan 30 22:19:48 2020        
(r357313)
@@ -208,7 +208,6 @@ ENTRY(cpu_exception_handler)
        csrrw   sp, sscratch, sp
        beqz    sp, 1f
        /* User mode detected */
-       csrrw   sp, sscratch, sp
        j       cpu_exception_handler_user
 1:
        /* Supervisor mode detected */
@@ -225,7 +224,6 @@ ENTRY(cpu_exception_handler_supervisor)
 END(cpu_exception_handler_supervisor)
 
 ENTRY(cpu_exception_handler_user)
-       csrrw   sp, sscratch, sp
        save_registers 0
        mv      a0, sp
        call    _C_LABEL(do_trap_user)
_______________________________________________
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