Author: markj
Date: Fri Dec  7 15:55:23 2018
New Revision: 341693
URL: https://svnweb.freebsd.org/changeset/base/341693

Log:
  Rename sptbr to satp per v1.10 of the privileged architecture spec.
  
  Add a subroutine for updating satp, for use when updating the
  active pmap.  No functional change intended.
  
  Reviewed by:  jhb
  MFC after:    1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:        https://reviews.freebsd.org/D18462

Modified:
  head/sys/riscv/include/cpufunc.h
  head/sys/riscv/riscv/locore.S
  head/sys/riscv/riscv/pmap.c
  head/sys/riscv/riscv/swtch.S

Modified: head/sys/riscv/include/cpufunc.h
==============================================================================
--- head/sys/riscv/include/cpufunc.h    Fri Dec  7 15:52:50 2018        
(r341692)
+++ head/sys/riscv/include/cpufunc.h    Fri Dec  7 15:55:23 2018        
(r341693)
@@ -109,6 +109,13 @@ sfence_vma_page(uintptr_t addr)
 #define        rdinstret()                     csr_read64(instret)
 #define        rdhpmcounter(n)                 csr_read64(hpmcounter##n)
 
+static __inline void
+load_satp(uint64_t val)
+{
+
+       __asm __volatile("csrw satp, %0" :: "r"(val));
+}
+
 #define        cpufunc_nullop()                riscv_nullop()
 
 void riscv_nullop(void);

Modified: head/sys/riscv/riscv/locore.S
==============================================================================
--- head/sys/riscv/riscv/locore.S       Fri Dec  7 15:52:50 2018        
(r341692)
+++ head/sys/riscv/riscv/locore.S       Fri Dec  7 15:55:23 2018        
(r341693)
@@ -152,7 +152,7 @@ _start:
        li      t0, SATP_MODE_SV39
        or      s2, s2, t0
        sfence.vma
-       csrw    sptbr, s2
+       csrw    satp, s2
 
        .align 2
 va:
@@ -297,7 +297,7 @@ ENTRY(mpentry)
        li      t0, SATP_MODE_SV39
        or      s2, s2, t0
        sfence.vma
-       csrw    sptbr, s2
+       csrw    satp, s2
 
        .align 2
 mpva:

Modified: head/sys/riscv/riscv/pmap.c
==============================================================================
--- head/sys/riscv/riscv/pmap.c Fri Dec  7 15:52:50 2018        (r341692)
+++ head/sys/riscv/riscv/pmap.c Fri Dec  7 15:55:23 2018        (r341693)
@@ -3302,7 +3302,7 @@ pmap_activate(struct thread *td)
 
        reg = SATP_MODE_SV39;
        reg |= (td->td_pcb->pcb_l1addr >> PAGE_SHIFT);
-       __asm __volatile("csrw sptbr, %0" :: "r"(reg));
+       load_satp(reg);
 
        pmap_invalidate_all(pmap);
        critical_exit();

Modified: head/sys/riscv/riscv/swtch.S
==============================================================================
--- head/sys/riscv/riscv/swtch.S        Fri Dec  7 15:52:50 2018        
(r341692)
+++ head/sys/riscv/riscv/swtch.S        Fri Dec  7 15:55:23 2018        
(r341693)
@@ -223,7 +223,7 @@ ENTRY(cpu_throw)
        srli    t0, t0, PAGE_SHIFT
        li      t1, SATP_MODE_SV39
        or      t0, t0, t1
-       csrw    sptbr, t0
+       csrw    satp, t0
 
        /* TODO: Invalidate the TLB */
 
@@ -341,7 +341,7 @@ ENTRY(cpu_switch)
        srli    t0, t0, PAGE_SHIFT
        li      t1, SATP_MODE_SV39
        or      t0, t0, t1
-       csrw    sptbr, t0
+       csrw    satp, t0
 
        /* TODO: Invalidate the TLB */
 
_______________________________________________
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