Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/sparc64 sun4v: handle spill normal user tra...



details:   https://anonhg.NetBSD.org/src/rev/921401aace15
branches:  trunk
changeset: 952963:921401aace15
user:      palle <palle%NetBSD.org@localhost>
date:      Mon Feb 22 09:56:42 2021 +0000

description:
sun4v: handle spill normal user traps properly when current trap level is 1 - registers are spilled to the PA of the stack to avoid further mmu-related traps, since sun4v only has 2 trap levels

diffstat:

 sys/arch/sparc64/sparc64/locore.s |  56 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 54 insertions(+), 2 deletions(-)

diffs (77 lines):

diff -r 4b2748b00103 -r 921401aace15 sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Mon Feb 22 09:29:38 2021 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Mon Feb 22 09:56:42 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.424 2020/12/20 11:58:58 palle Exp $       */
+/*     $NetBSD: locore.s,v 1.425 2021/02/22 09:56:42 palle Exp $       */
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -228,7 +228,7 @@
        .endm
 
        .macro sun4v_tl1_uspill_normal
-       ba,a,pt %xcc, pcbspill_normals
+       ba,a,pt %xcc, spill_normal_to_user_stack
         nop
        .align 128
        .endm
@@ -3485,6 +3485,58 @@
        Debugger()
        NOTREACHED
 
+spill_normal_to_user_stack:
+       mov     %sp, %g6                                                ! calculate virtual address of destination stack
+       add     %g6, BIAS, %g6
+
+       mov     CTX_SECONDARY, %g2                              ! Is this context ok or should it be CTX_PRIMARY? XXX
+       GET_MMU_CONTEXTID %g3, %g2, %g1
+       sllx    %g3, 3, %g3                                     ! Make it into an offset into ctxbusy (see below)
+       
+       GET_CTXBUSY %g1
+       ldx     [%g1 + %g3], %g1                                ! Fetch pmap for current context id
+
+       ! Start of code to extract PA   
+       srlx    %g6, STSHIFT, %g7
+       and     %g7, STMASK, %g7
+       sll     %g7, 3, %g7                                             ! byte offset into ctxbusy
+       add     %g7, %g1, %g1
+       ldxa    [%g1] ASI_PHYS_CACHED, %g1      ! Load pointer to directory
+       srlx    %g6, PDSHIFT, %g7                       ! Do page directory
+       and     %g7, PDMASK, %g7
+       sll     %g7, 3, %g7
+       brz,pn  %g1, spill_normal_to_user_stack_fail
+        add    %g7, %g1, %g1
+
+       ldxa    [%g1] ASI_PHYS_CACHED, %g1
+       srlx    %g6, PTSHIFT, %g7                       ! Convert to ptab offset
+       and     %g7, PTMASK, %g7
+       brz     %g1, spill_normal_to_user_stack_fail
+        sll    %g7, 3, %g7
+       
+       add     %g1, %g7, %g7
+       ldxa    [%g7] ASI_PHYS_CACHED, %g7      ! This one is not
+       brgez   %g7, spill_normal_to_user_stack_fail
+        srlx   %g7, PGSHIFT, %g7                       ! Isolate PA part
+       
+       sll     %g6, 32-PGSHIFT, %g6                    ! And offset
+       sllx    %g7, PGSHIFT+8, %g7                     ! There are 8 bits to the left of the PA in the TTE
+       srl     %g6, 32-PGSHIFT, %g6
+       srax    %g7, 8, %g7
+       or      %g7, %g6, %g6                                   ! Then combine them to form PA
+       ! End of code to extract PA
+
+       wr      %g0, ASI_PHYS_CACHED, %asi              ! Use ASI_PHYS_CACHED to prevent possible page faults
+       SPILL   stxa, %g6, 8, %asi                      ! Store the locals and ins
+       saved
+
+       retry
+       NOTREACHED
+
+spill_normal_to_user_stack_fail:
+       sir
+        nop
+       
 /*
  * End of traps for sun4v.
  */



Home | Main Index | Thread Index | Old Index