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: rft_kernel should pay attent...



details:   https://anonhg.NetBSD.org/src/rev/c1dcfdac8fb3
branches:  trunk
changeset: 343918:c1dcfdac8fb3
user:      palle <palle%NetBSD.org@localhost>
date:      Thu Mar 03 20:45:45 2016 +0000

description:
sun4v: rft_kernel should pay attention to the number of register windows that can be restored. We cannot rely on fill traps to occur, since sun4v only has two trap levels available in privileged 
mode. Based on code from OpenBSD. ok martin@

diffstat:

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

diffs (73 lines):

diff -r 5e18e3a14949 -r c1dcfdac8fb3 sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Thu Mar 03 17:01:31 2016 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Thu Mar 03 20:45:45 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.388 2016/02/14 21:13:33 palle Exp $       */
+/*     $NetBSD: locore.s,v 1.389 2016/03/03 20:45:45 palle Exp $       */
 
 /*
  * Copyright (c) 2006-2010 Matthew R. Green
@@ -355,6 +355,35 @@
 #define CLRTT
 #endif
 
+
+/*
+ * Some macros to load and store a register window
+ */
+
+       .macro  SPILL storer,base,size,asi
+
+       .irpc n,01234567
+               \storer %l\n, [\base + (\n * \size)] \asi
+       .endr
+       .irpc n,01234567
+               \storer %i\n, [\base + ((8+\n) * \size)] \asi
+       .endr
+
+       .endm
+
+       
+       .macro FILL loader, base, size, asi
+       
+       .irpc n,01234567
+               \loader [\base + (\n * \size)] \asi, %l\n
+       .endr
+
+       .irpc n,01234567
+               \loader [\base + ((8+\n) * \size)] \asi, %i\n
+       .endr
+       
+       .endm
+       
 /*
  * Here are some oft repeated traps as macros.
  */
@@ -4079,12 +4108,26 @@
  *
  */
 rft_kernel:
-       rdpr    %tl, %g4                                ! Grab a set of trap registers
+       rdpr    %tl, %g4                        ! Grab a set of trap registers
        inc     %g4
        wrpr    %g4, %g0, %tl
        wrpr    %g3, 0, %tnpc
        wrpr    %g2, 0, %tpc
        wrpr    %g1, 0, %tstate
+
+       rdpr    %canrestore, %g2
+       brnz    %g2, 1f
+        nop
+
+       wr      %g0, ASI_NUCLEUS, %asi
+       rdpr    %cwp, %g1
+       dec     %g1
+       wrpr    %g1, %cwp
+       FILL    ldxa, %sp+BIAS, 8, %asi
+       restored
+       inc     %g1
+       wrpr    %g1, %cwp
+1:
        restore
        rdpr    %tstate, %g1                    ! Since we may have trapped our regs may be toast
        rdpr    %cwp, %g2



Home | Main Index | Thread Index | Old Index