2005-04-16 15:20:36 -07:00
/ * tlb- m i s s . S : T L B m i s s h a n d l e r s
*
* Copyright ( C ) 2 0 0 4 R e d H a t , I n c . A l l R i g h t s R e s e r v e d .
* Written b y D a v i d H o w e l l s ( d h o w e l l s @redhat.com)
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or
* modify i t u n d e r t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e
* as p u b l i s h e d b y t h e F r e e S o f t w a r e F o u n d a t i o n ; either version
* 2 of t h e L i c e n s e , o r ( a t y o u r o p t i o n ) a n y l a t e r v e r s i o n .
* /
# include < l i n u x / s y s . h >
# include < l i n u x / l i n k a g e . h >
# include < a s m / p a g e . h >
# include < a s m / p g t a b l e . h >
# include < a s m / s p r - r e g s . h >
2010-02-20 01:03:56 +01:00
.section .text . .tlbmiss
2005-04-16 15:20:36 -07:00
.balign 4
.globl __entry_insn_mmu_miss
__entry_insn_mmu_miss :
break
nop
.globl __entry_insn_mmu_exception
__entry_insn_mmu_exception :
break
nop
.globl __entry_data_mmu_miss
__entry_data_mmu_miss :
break
nop
.globl __entry_data_mmu_exception
__entry_data_mmu_exception :
break
nop
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# handle a l o o k u p f a i l u r e o f o n e s o r t o r a n o t h e r i n a k e r n e l T L B h a n d l e r
# On e n t r y :
# GR2 9 - f a u l t i n g a d d r e s s
# SCR2 - s a v e d C C R
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type _ _ tlb_ k e r n e l _ f a u l t ,@function
__tlb_kernel_fault :
# see i f w e ' r e s u p p o s e d t o r e - e n a b l e s i n g l e - s t e p m o d e u p o n r e t u r n
sethi. p % h i ( _ _ b r e a k _ t l b _ m i s s _ r e t u r n _ b r e a k ) ,g r30
setlo % l o ( _ _ b r e a k _ t l b _ m i s s _ r e t u r n _ b r e a k ) ,g r30
movsg p c s r ,g r31
subcc g r31 ,g r30 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t _ s s t e p
movsg s c r2 ,g r30
movgs g r30 ,c c r
movgs g r29 ,s c r2 / * s a v e E A R 0 v a l u e * /
sethi. p % h i ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
setlo % l o ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
ldi. p @(gr29,#0),gr29 /* restore GR29 */
bra _ _ e n t r y _ k e r n e l _ h a n d l e _ m m u _ f a u l t
# we' v e g o t t o r e - e n a b l e s i n g l e - s t e p p i n g
__tlb_kernel_fault_sstep :
sethi. p % h i ( _ _ b r e a k _ t l b _ m i s s _ r e a l _ r e t u r n _ i n f o ) ,g r30
setlo % l o ( _ _ b r e a k _ t l b _ m i s s _ r e a l _ r e t u r n _ i n f o ) ,g r30
lddi @(gr30,0),gr30
movgs g r30 ,p c s r
movgs g r31 ,p s r
movsg s c r2 ,g r30
movgs g r30 ,c c r
movgs g r29 ,s c r2 / * s a v e E A R 0 v a l u e * /
sethi. p % h i ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
setlo % l o ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
ldi. p @(gr29,#0),gr29 /* restore GR29 */
bra _ _ e n t r y _ k e r n e l _ h a n d l e _ m m u _ f a u l t _ s s t e p
.size _ _ tlb_ k e r n e l _ f a u l t , . - _ _ t l b _ k e r n e l _ f a u l t
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# handle a l o o k u p f a i l u r e o f o n e s o r t o r a n o t h e r i n a u s e r T L B h a n d l e r
# On e n t r y :
# GR2 8 - f a u l t i n g a d d r e s s
# SCR2 - s a v e d C C R
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.type _ _ tlb_ u s e r _ f a u l t ,@function
__tlb_user_fault :
# see i f w e ' r e s u p p o s e d t o r e - e n a b l e s i n g l e - s t e p m o d e u p o n r e t u r n
sethi. p % h i ( _ _ b r e a k _ t l b _ m i s s _ r e t u r n _ b r e a k ) ,g r30
setlo % l o ( _ _ b r e a k _ t l b _ m i s s _ r e t u r n _ b r e a k ) ,g r30
movsg p c s r ,g r31
subcc g r31 ,g r30 ,g r0 ,i c c0
beq i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t _ s s t e p
movsg s c r2 ,g r30
movgs g r30 ,c c r
bra _ _ e n t r y _ u s p a c e _ h a n d l e _ m m u _ f a u l t
# we' v e g o t t o r e - e n a b l e s i n g l e - s t e p p i n g
__tlb_user_fault_sstep :
sethi. p % h i ( _ _ b r e a k _ t l b _ m i s s _ r e a l _ r e t u r n _ i n f o ) ,g r30
setlo % l o ( _ _ b r e a k _ t l b _ m i s s _ r e a l _ r e t u r n _ i n f o ) ,g r30
lddi @(gr30,0),gr30
movgs g r30 ,p c s r
movgs g r31 ,p s r
movsg s c r2 ,g r30
movgs g r30 ,c c r
bra _ _ e n t r y _ u s p a c e _ h a n d l e _ m m u _ f a u l t _ s s t e p
.size _ _ tlb_ u s e r _ f a u l t , . - _ _ t l b _ u s e r _ f a u l t
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Kernel i n s t r u c t i o n T L B m i s s h a n d l e r
# On e n t r y :
# GR1 - k e r n e l s t a c k p o i n t e r
# GR2 8 - s a v e d e x c e p t i o n f r a m e p o i n t e r
# GR2 9 - f a u l t i n g a d d r e s s
# GR3 1 - E A R 0 ^ S C R 0
# SCR0 - b a s e o f v i r t u a l r a n g e c o v e r e d b y c a c h e d P G E f r o m l a s t I T L B m i s s ( o r 0 x f f f f f f f f )
# DAMR3 - m a p p e d p a g e d i r e c t o r y
# DAMR4 - m a p p e d p a g e t a b l e a s m a t c h e d b y S C R 0
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __entry_kernel_insn_tlb_miss
.type _ _ entry_ k e r n e l _ i n s n _ t l b _ m i s s ,@function
__entry_kernel_insn_tlb_miss :
# if 0
sethi. p % h i ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
setlo % l o ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
st g r0 ,@(gr30,gr0)
sethi. p % h i ( 0 x f f c00 1 0 0 ) ,g r30
setlo % l o ( 0 x f f c00 1 0 0 ) ,g r30
sth g r30 ,@(gr30,gr0)
membar
# endif
movsg c c r ,g r30 / * s a v e C C R * /
movgs g r30 ,s c r2
# see i f t h e c a c h e d p a g e t a b l e m a p p i n g i s a p p r o p r i a t e
srlicc. p g r31 ,#26 ,g r0 ,i c c0
setlos 0 x3 f f c ,g r30
srli. p g r29 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bne i c c0 ,#0 ,_ _ i t l b _ k _ P T D _ m i s s
__itlb_k_PTD_mapped :
# access t h e P T D w i t h E A R 0 [ 2 5 : 1 4 ]
# - DAMLR4 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e a p p r o p r i a t e p a g e t a b l e
# - the P T D h o l d s 4 0 9 6 P T E s
# - the P T D m u s t b e a c c e s s e d u n c a c h e d
# - the P T E m u s t b e m a r k e d a c c e s s e d i f i t w a s v a l i d
#
and g r31 ,g r30 ,g r31
movsg d a m l r4 ,g r30
add g r30 ,g r31 ,g r31
ldi @(gr31,#0),gr30 /* fetch the PTE */
andicc g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
ori. p g r30 ,#_ P A G E _ A C C E S S E D , g r 30
beq i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t / * j u m p i f P T E i n v a l i d * /
sti. p g r30 ,@(gr31,#0) /* update the PTE */
andi g r30 ,#~ _ P A G E _ A C C E S S E D , g r 30
# we' r e u s i n g I A M R 1 a s a n e x t r a T L B e n t r y
# - punt t h e e n t r y h e r e ( i f v a l i d ) t o t h e r e a l T L B a n d t h e n r e p l a c e w i t h t h e n e w P T E
# - need t o c h e c k D A M R 1 l e s t w e c a u s e a n m u l t i p l e - D A T - h i t e x c e p t i o n
# - IAMPR1 h a s n o W P b i t , a n d w e m u s t n ' t l o s e W P i n f o r m a t i o n
movsg i a m p r1 ,g r31
andicc g r31 ,#x A M P R x _ V , g r 0 ,i c c0
setlos. p 0 x f f f f f00 0 ,g r31
beq i c c0 ,#0 ,_ _ i t l b _ k _ n o p u n t / * p u n t n o t r e q u i r e d * /
movsg i a m l r1 ,g r31
movgs g r31 ,t p l r / * s e t T P L R . C X N * /
tlbpr g r31 ,g r0 ,#4 ,#0 / * d e l e t e m a t c h e s f r o m T L B , I A M R 1 , D A M R 1 * /
movsg d a m p r1 ,g r31
ori g r31 ,#x A M P R x _ V , g r 31 / * e n t r y w a s i n v a l i d a t e d b y t l b p r #4 * /
movgs g r31 ,t p p r
movsg i a m l r1 ,g r31 / * s e t T P L R . C X N * /
movgs g r31 ,t p l r
tlbpr g r31 ,g r0 ,#2 ,#0 / * s a v e t o t h e T L B * /
movsg t p x r ,g r31 / * c h e c k t h e T L B w r i t e e r r o r f l a g * /
andicc. p g r31 ,#T P X R _ E , g r 0 ,i c c0
setlos #0xfffff000 ,g r31
bne i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t
__itlb_k_nopunt :
# assemble t h e n e w T L B e n t r y
and g r29 ,g r31 ,g r29
movsg c x n r ,g r31
or g r29 ,g r31 ,g r29
movgs g r29 ,i a m l r1 / * x A M L R = a d d r e s s | c o n t e x t n u m b e r * /
movgs g r30 ,i a m p r1
movgs g r29 ,d a m l r1
movgs g r30 ,d a m p r1
# return, r e s t o r i n g r e g i s t e r s
movsg s c r2 ,g r30
movgs g r30 ,c c r
sethi. p % h i ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
setlo % l o ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
ldi @(gr29,#0),gr29
rett #0
beq i c c0 ,#3 ,0 / * p r e v e n t i c a c h e p r e f e t c h * /
# the P T E w e w a n t w a s n ' t i n t h e P T D w e h a v e m a p p e d , s o w e n e e d t o g o l o o k i n g f o r a m o r e
# appropriate p a g e t a b l e a n d m a p t h a t i n s t e a d
# - access t h e P G D w i t h E A R 0 [ 3 1 : 2 6 ]
# - DAMLR3 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e p a g e d i r e c t o r y
# - the P G D h o l d s 6 4 P G E s a n d e a c h P G E / P M E p o i n t s t o a s e t o f p a g e t a b l e s
__itlb_k_PTD_miss :
srli g r29 ,#26 ,g r31 / * c a l c u l a t e P G E o f f s e t * /
slli g r31 ,#8 ,g r31 / * a n d c l e a r b o t t o m b i t s * /
movsg d a m l r3 ,g r30
ld @(gr31,gr30),gr30 /* access the PGE */
andicc. p g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
andicc g r30 ,#x A M P R x _ S S , g r 0 ,i c c1
# map t h i s P T D i n s t e a d a n d r e c o r d c o v e r a g e a d d r e s s
ori. p g r30 ,#x A M P R x _ L | x A M P R x _ S S _ 16 K b | x A M P R x _ S | x A M P R x _ C | x A M P R x _ V ,g r30
beq i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t / * j u m p i f P G E n o t p r e s e n t * /
slli. p g r31 ,#18 ,g r31
bne i c c1 ,#0 ,_ _ i t l b _ k _ b i g p a g e
movgs g r30 ,d a m p r4
movgs g r31 ,s c r0
# we c a n n o w r e s u m e n o r m a l s e r v i c e
setlos 0 x3 f f c ,g r30
srli. p g r29 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bra _ _ i t l b _ k _ P T D _ m a p p e d
__itlb_k_bigpage :
break
nop
.size _ _ entry_ k e r n e l _ i n s n _ t l b _ m i s s , . - _ _ e n t r y _ k e r n e l _ i n s n _ t l b _ m i s s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Kernel d a t a T L B m i s s h a n d l e r
# On e n t r y :
# GR1 - k e r n e l s t a c k p o i n t e r
# GR2 8 - s a v e d e x c e p t i o n f r a m e p o i n t e r
# GR2 9 - f a u l t i n g a d d r e s s
# GR3 1 - E A R 0 ^ S C R 1
# SCR1 - b a s e o f v i r t u a l r a n g e c o v e r e d b y c a c h e d P G E f r o m l a s t D T L B m i s s ( o r 0 x f f f f f f f f )
# DAMR3 - m a p p e d p a g e d i r e c t o r y
# DAMR5 - m a p p e d p a g e t a b l e a s m a t c h e d b y S C R 1
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __entry_kernel_data_tlb_miss
.type _ _ entry_ k e r n e l _ d a t a _ t l b _ m i s s ,@function
__entry_kernel_data_tlb_miss :
# if 0
sethi. p % h i ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
setlo % l o ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
st g r0 ,@(gr30,gr0)
sethi. p % h i ( 0 x f f c00 1 0 0 ) ,g r30
setlo % l o ( 0 x f f c00 1 0 0 ) ,g r30
sth g r30 ,@(gr30,gr0)
membar
# endif
movsg c c r ,g r30 / * s a v e C C R * /
movgs g r30 ,s c r2
# see i f t h e c a c h e d p a g e t a b l e m a p p i n g i s a p p r o p r i a t e
srlicc. p g r31 ,#26 ,g r0 ,i c c0
setlos 0 x3 f f c ,g r30
srli. p g r29 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bne i c c0 ,#0 ,_ _ d t l b _ k _ P T D _ m i s s
__dtlb_k_PTD_mapped :
# access t h e P T D w i t h E A R 0 [ 2 5 : 1 4 ]
# - DAMLR5 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e a p p r o p r i a t e p a g e t a b l e
# - the P T D h o l d s 4 0 9 6 P T E s
# - the P T D m u s t b e a c c e s s e d u n c a c h e d
# - the P T E m u s t b e m a r k e d a c c e s s e d i f i t w a s v a l i d
#
and g r31 ,g r30 ,g r31
movsg d a m l r5 ,g r30
add g r30 ,g r31 ,g r31
ldi @(gr31,#0),gr30 /* fetch the PTE */
andicc g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
ori. p g r30 ,#_ P A G E _ A C C E S S E D , g r 30
beq i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t / * j u m p i f P T E i n v a l i d * /
sti. p g r30 ,@(gr31,#0) /* update the PTE */
andi g r30 ,#~ _ P A G E _ A C C E S S E D , g r 30
# we' r e u s i n g D A M R 1 a s a n e x t r a T L B e n t r y
# - punt t h e e n t r y h e r e ( i f v a l i d ) t o t h e r e a l T L B a n d t h e n r e p l a c e w i t h t h e n e w P T E
# - need t o c h e c k I A M R 1 l e s t w e c a u s e a n m u l t i p l e - D A T - h i t e x c e p t i o n
movsg d a m p r1 ,g r31
andicc g r31 ,#x A M P R x _ V , g r 0 ,i c c0
setlos. p 0 x f f f f f00 0 ,g r31
beq i c c0 ,#0 ,_ _ d t l b _ k _ n o p u n t / * p u n t n o t r e q u i r e d * /
movsg d a m l r1 ,g r31
movgs g r31 ,t p l r / * s e t T P L R . C X N * /
tlbpr g r31 ,g r0 ,#4 ,#0 / * d e l e t e m a t c h e s f r o m T L B , I A M R 1 , D A M R 1 * /
movsg d a m p r1 ,g r31
ori g r31 ,#x A M P R x _ V , g r 31 / * e n t r y w a s i n v a l i d a t e d b y t l b p r #4 * /
movgs g r31 ,t p p r
movsg d a m l r1 ,g r31 / * s e t T P L R . C X N * /
movgs g r31 ,t p l r
tlbpr g r31 ,g r0 ,#2 ,#0 / * s a v e t o t h e T L B * /
movsg t p x r ,g r31 / * c h e c k t h e T L B w r i t e e r r o r f l a g * /
andicc. p g r31 ,#T P X R _ E , g r 0 ,i c c0
setlos #0xfffff000 ,g r31
bne i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t
__dtlb_k_nopunt :
# assemble t h e n e w T L B e n t r y
and g r29 ,g r31 ,g r29
movsg c x n r ,g r31
or g r29 ,g r31 ,g r29
movgs g r29 ,i a m l r1 / * x A M L R = a d d r e s s | c o n t e x t n u m b e r * /
movgs g r30 ,i a m p r1
movgs g r29 ,d a m l r1
movgs g r30 ,d a m p r1
# return, r e s t o r i n g r e g i s t e r s
movsg s c r2 ,g r30
movgs g r30 ,c c r
sethi. p % h i ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
setlo % l o ( _ _ k e r n e l _ c u r r e n t _ t a s k ) ,g r29
ldi @(gr29,#0),gr29
rett #0
beq i c c0 ,#3 ,0 / * p r e v e n t i c a c h e p r e f e t c h * /
# the P T E w e w a n t w a s n ' t i n t h e P T D w e h a v e m a p p e d , s o w e n e e d t o g o l o o k i n g f o r a m o r e
# appropriate p a g e t a b l e a n d m a p t h a t i n s t e a d
# - access t h e P G D w i t h E A R 0 [ 3 1 : 2 6 ]
# - DAMLR3 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e p a g e d i r e c t o r y
# - the P G D h o l d s 6 4 P G E s a n d e a c h P G E / P M E p o i n t s t o a s e t o f p a g e t a b l e s
__dtlb_k_PTD_miss :
srli g r29 ,#26 ,g r31 / * c a l c u l a t e P G E o f f s e t * /
slli g r31 ,#8 ,g r31 / * a n d c l e a r b o t t o m b i t s * /
movsg d a m l r3 ,g r30
ld @(gr31,gr30),gr30 /* access the PGE */
andicc. p g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
andicc g r30 ,#x A M P R x _ S S , g r 0 ,i c c1
# map t h i s P T D i n s t e a d a n d r e c o r d c o v e r a g e a d d r e s s
ori. p g r30 ,#x A M P R x _ L | x A M P R x _ S S _ 16 K b | x A M P R x _ S | x A M P R x _ C | x A M P R x _ V ,g r30
beq i c c0 ,#0 ,_ _ t l b _ k e r n e l _ f a u l t / * j u m p i f P G E n o t p r e s e n t * /
slli. p g r31 ,#18 ,g r31
bne i c c1 ,#0 ,_ _ d t l b _ k _ b i g p a g e
movgs g r30 ,d a m p r5
movgs g r31 ,s c r1
# we c a n n o w r e s u m e n o r m a l s e r v i c e
setlos 0 x3 f f c ,g r30
srli. p g r29 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bra _ _ d t l b _ k _ P T D _ m a p p e d
__dtlb_k_bigpage :
break
nop
.size _ _ entry_ k e r n e l _ d a t a _ t l b _ m i s s , . - _ _ e n t r y _ k e r n e l _ d a t a _ t l b _ m i s s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Userspace i n s t r u c t i o n T L B m i s s h a n d l e r ( w i t h P G E p r e d i c t i o n )
# On e n t r y :
# GR2 8 - f a u l t i n g a d d r e s s
# GR3 1 - E A R 0 ^ S C R 0
# SCR0 - b a s e o f v i r t u a l r a n g e c o v e r e d b y c a c h e d P G E f r o m l a s t I T L B m i s s ( o r 0 x f f f f f f f f )
# DAMR3 - m a p p e d p a g e d i r e c t o r y
# DAMR4 - m a p p e d p a g e t a b l e a s m a t c h e d b y S C R 0
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __entry_user_insn_tlb_miss
.type _ _ entry_ u s e r _ i n s n _ t l b _ m i s s ,@function
__entry_user_insn_tlb_miss :
# if 0
sethi. p % h i ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
setlo % l o ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
st g r0 ,@(gr30,gr0)
sethi. p % h i ( 0 x f f c00 1 0 0 ) ,g r30
setlo % l o ( 0 x f f c00 1 0 0 ) ,g r30
sth g r30 ,@(gr30,gr0)
membar
# endif
movsg c c r ,g r30 / * s a v e C C R * /
movgs g r30 ,s c r2
# see i f t h e c a c h e d p a g e t a b l e m a p p i n g i s a p p r o p r i a t e
srlicc. p g r31 ,#26 ,g r0 ,i c c0
setlos 0 x3 f f c ,g r30
srli. p g r28 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bne i c c0 ,#0 ,_ _ i t l b _ u _ P T D _ m i s s
__itlb_u_PTD_mapped :
# access t h e P T D w i t h E A R 0 [ 2 5 : 1 4 ]
# - DAMLR4 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e a p p r o p r i a t e p a g e t a b l e
# - the P T D h o l d s 4 0 9 6 P T E s
# - the P T D m u s t b e a c c e s s e d u n c a c h e d
# - the P T E m u s t b e m a r k e d a c c e s s e d i f i t w a s v a l i d
#
and g r31 ,g r30 ,g r31
movsg d a m l r4 ,g r30
add g r30 ,g r31 ,g r31
ldi @(gr31,#0),gr30 /* fetch the PTE */
andicc g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
ori. p g r30 ,#_ P A G E _ A C C E S S E D , g r 30
beq i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t / * j u m p i f P T E i n v a l i d * /
sti. p g r30 ,@(gr31,#0) /* update the PTE */
andi g r30 ,#~ _ P A G E _ A C C E S S E D , g r 30
# we' r e u s i n g I A M R 1 / D A M R 1 a s a n e x t r a T L B e n t r y
# - punt t h e e n t r y h e r e ( i f v a l i d ) t o t h e r e a l T L B a n d t h e n r e p l a c e w i t h t h e n e w P T E
movsg d a m p r1 ,g r31
andicc g r31 ,#x A M P R x _ V , g r 0 ,i c c0
setlos. p 0 x f f f f f00 0 ,g r31
beq i c c0 ,#0 ,_ _ i t l b _ u _ n o p u n t / * p u n t n o t r e q u i r e d * /
movsg d a m p r1 ,g r31
movgs g r31 ,t p p r
movsg d a m l r1 ,g r31 / * s e t T P L R . C X N * /
movgs g r31 ,t p l r
tlbpr g r31 ,g r0 ,#2 ,#0 / * s a v e t o t h e T L B * /
movsg t p x r ,g r31 / * c h e c k t h e T L B w r i t e e r r o r f l a g * /
andicc. p g r31 ,#T P X R _ E , g r 0 ,i c c0
setlos #0xfffff000 ,g r31
bne i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t
__itlb_u_nopunt :
# assemble t h e n e w T L B e n t r y
and g r28 ,g r31 ,g r28
movsg c x n r ,g r31
or g r28 ,g r31 ,g r28
movgs g r28 ,i a m l r1 / * x A M L R = a d d r e s s | c o n t e x t n u m b e r * /
movgs g r30 ,i a m p r1
movgs g r28 ,d a m l r1
movgs g r30 ,d a m p r1
# return, r e s t o r i n g r e g i s t e r s
movsg s c r2 ,g r30
movgs g r30 ,c c r
rett #0
beq i c c0 ,#3 ,0 / * p r e v e n t i c a c h e p r e f e t c h * /
# the P T E w e w a n t w a s n ' t i n t h e P T D w e h a v e m a p p e d , s o w e n e e d t o g o l o o k i n g f o r a m o r e
# appropriate p a g e t a b l e a n d m a p t h a t i n s t e a d
# - access t h e P G D w i t h E A R 0 [ 3 1 : 2 6 ]
# - DAMLR3 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e p a g e d i r e c t o r y
# - the P G D h o l d s 6 4 P G E s a n d e a c h P G E / P M E p o i n t s t o a s e t o f p a g e t a b l e s
__itlb_u_PTD_miss :
srli g r28 ,#26 ,g r31 / * c a l c u l a t e P G E o f f s e t * /
slli g r31 ,#8 ,g r31 / * a n d c l e a r b o t t o m b i t s * /
movsg d a m l r3 ,g r30
ld @(gr31,gr30),gr30 /* access the PGE */
andicc. p g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
andicc g r30 ,#x A M P R x _ S S , g r 0 ,i c c1
# map t h i s P T D i n s t e a d a n d r e c o r d c o v e r a g e a d d r e s s
ori. p g r30 ,#x A M P R x _ L | x A M P R x _ S S _ 16 K b | x A M P R x _ S | x A M P R x _ C | x A M P R x _ V ,g r30
beq i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t / * j u m p i f P G E n o t p r e s e n t * /
slli. p g r31 ,#18 ,g r31
bne i c c1 ,#0 ,_ _ i t l b _ u _ b i g p a g e
movgs g r30 ,d a m p r4
movgs g r31 ,s c r0
# we c a n n o w r e s u m e n o r m a l s e r v i c e
setlos 0 x3 f f c ,g r30
srli. p g r28 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bra _ _ i t l b _ u _ P T D _ m a p p e d
__itlb_u_bigpage :
break
nop
.size _ _ entry_ u s e r _ i n s n _ t l b _ m i s s , . - _ _ e n t r y _ u s e r _ i n s n _ t l b _ m i s s
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# Userspace d a t a T L B m i s s h a n d l e r
# On e n t r y :
# GR2 8 - f a u l t i n g a d d r e s s
# GR3 1 - E A R 0 ^ S C R 1
# SCR1 - b a s e o f v i r t u a l r a n g e c o v e r e d b y c a c h e d P G E f r o m l a s t D T L B m i s s ( o r 0 x f f f f f f f f )
# DAMR3 - m a p p e d p a g e d i r e c t o r y
# DAMR5 - m a p p e d p a g e t a b l e a s m a t c h e d b y S C R 1
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
.globl __entry_user_data_tlb_miss
.type _ _ entry_ u s e r _ d a t a _ t l b _ m i s s ,@function
__entry_user_data_tlb_miss :
# if 0
sethi. p % h i ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
setlo % l o ( 0 x e 1 2 0 0 0 0 4 ) ,g r30
st g r0 ,@(gr30,gr0)
sethi. p % h i ( 0 x f f c00 1 0 0 ) ,g r30
setlo % l o ( 0 x f f c00 1 0 0 ) ,g r30
sth g r30 ,@(gr30,gr0)
membar
# endif
movsg c c r ,g r30 / * s a v e C C R * /
movgs g r30 ,s c r2
# see i f t h e c a c h e d p a g e t a b l e m a p p i n g i s a p p r o p r i a t e
srlicc. p g r31 ,#26 ,g r0 ,i c c0
setlos 0 x3 f f c ,g r30
srli. p g r28 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bne i c c0 ,#0 ,_ _ d t l b _ u _ P T D _ m i s s
__dtlb_u_PTD_mapped :
# access t h e P T D w i t h E A R 0 [ 2 5 : 1 4 ]
# - DAMLR5 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e a p p r o p r i a t e p a g e t a b l e
# - the P T D h o l d s 4 0 9 6 P T E s
# - the P T D m u s t b e a c c e s s e d u n c a c h e d
# - the P T E m u s t b e m a r k e d a c c e s s e d i f i t w a s v a l i d
#
and g r31 ,g r30 ,g r31
movsg d a m l r5 ,g r30
__dtlb_u_using_iPTD :
add g r30 ,g r31 ,g r31
ldi @(gr31,#0),gr30 /* fetch the PTE */
andicc g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
ori. p g r30 ,#_ P A G E _ A C C E S S E D , g r 30
beq i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t / * j u m p i f P T E i n v a l i d * /
sti. p g r30 ,@(gr31,#0) /* update the PTE */
andi g r30 ,#~ _ P A G E _ A C C E S S E D , g r 30
# we' r e u s i n g D A M R 1 a s a n e x t r a T L B e n t r y
# - punt t h e e n t r y h e r e ( i f v a l i d ) t o t h e r e a l T L B a n d t h e n r e p l a c e w i t h t h e n e w P T E
movsg d a m p r1 ,g r31
andicc g r31 ,#x A M P R x _ V , g r 0 ,i c c0
setlos. p 0 x f f f f f00 0 ,g r31
beq i c c0 ,#0 ,_ _ d t l b _ u _ n o p u n t / * p u n t n o t r e q u i r e d * /
movsg d a m p r1 ,g r31
movgs g r31 ,t p p r
movsg d a m l r1 ,g r31 / * s e t T P L R . C X N * /
movgs g r31 ,t p l r
tlbpr g r31 ,g r0 ,#2 ,#0 / * s a v e t o t h e T L B * /
movsg t p x r ,g r31 / * c h e c k t h e T L B w r i t e e r r o r f l a g * /
andicc. p g r31 ,#T P X R _ E , g r 0 ,i c c0
setlos #0xfffff000 ,g r31
bne i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t
__dtlb_u_nopunt :
# assemble t h e n e w T L B e n t r y
and g r28 ,g r31 ,g r28
movsg c x n r ,g r31
or g r28 ,g r31 ,g r28
movgs g r28 ,i a m l r1 / * x A M L R = a d d r e s s | c o n t e x t n u m b e r * /
movgs g r30 ,i a m p r1
movgs g r28 ,d a m l r1
movgs g r30 ,d a m p r1
# return, r e s t o r i n g r e g i s t e r s
movsg s c r2 ,g r30
movgs g r30 ,c c r
rett #0
beq i c c0 ,#3 ,0 / * p r e v e n t i c a c h e p r e f e t c h * /
# the P T E w e w a n t w a s n ' t i n t h e P T D w e h a v e m a p p e d , s o w e n e e d t o g o l o o k i n g f o r a m o r e
# appropriate p a g e t a b l e a n d m a p t h a t i n s t e a d
# - first o f a l l , c h e c k t h e i n s n P G E c a c h e - w e m a y w e l l g e t a h i t t h e r e
# - access t h e P G D w i t h E A R 0 [ 3 1 : 2 6 ]
# - DAMLR3 p o i n t s t o t h e v i r t u a l a d d r e s s o f t h e p a g e d i r e c t o r y
# - the P G D h o l d s 6 4 P G E s a n d e a c h P G E / P M E p o i n t s t o a s e t o f p a g e t a b l e s
__dtlb_u_PTD_miss :
movsg s c r0 ,g r31 / * c o n s u l t t h e i n s n - P G E - c a c h e k e y * /
xor g r28 ,g r31 ,g r31
srlicc g r31 ,#26 ,g r0 ,i c c0
srli g r28 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bne i c c0 ,#0 ,_ _ d t l b _ u _ i P G E _ m i s s
# what w e ' r e l o o k i n g f o r i s c o v e r e d b y t h e i n s n - P G E - c a c h e
setlos 0 x3 f f c ,g r30
and g r31 ,g r30 ,g r31
movsg d a m l r4 ,g r30
bra _ _ d t l b _ u _ u s i n g _ i P T D
__dtlb_u_iPGE_miss :
srli g r28 ,#26 ,g r31 / * c a l c u l a t e P G E o f f s e t * /
slli g r31 ,#8 ,g r31 / * a n d c l e a r b o t t o m b i t s * /
movsg d a m l r3 ,g r30
ld @(gr31,gr30),gr30 /* access the PGE */
andicc. p g r30 ,#_ P A G E _ P R E S E N T , g r 0 ,i c c0
andicc g r30 ,#x A M P R x _ S S , g r 0 ,i c c1
# map t h i s P T D i n s t e a d a n d r e c o r d c o v e r a g e a d d r e s s
ori. p g r30 ,#x A M P R x _ L | x A M P R x _ S S _ 16 K b | x A M P R x _ S | x A M P R x _ C | x A M P R x _ V ,g r30
beq i c c0 ,#0 ,_ _ t l b _ u s e r _ f a u l t / * j u m p i f P G E n o t p r e s e n t * /
slli. p g r31 ,#18 ,g r31
bne i c c1 ,#0 ,_ _ d t l b _ u _ b i g p a g e
movgs g r30 ,d a m p r5
movgs g r31 ,s c r1
# we c a n n o w r e s u m e n o r m a l s e r v i c e
setlos 0 x3 f f c ,g r30
srli. p g r28 ,#12 ,g r31 / * u s e E A R 0 [ 2 5 : 1 4 ] a s P T E i n d e x * /
bra _ _ d t l b _ u _ P T D _ m a p p e d
__dtlb_u_bigpage :
break
nop
.size _ _ entry_ u s e r _ d a t a _ t l b _ m i s s , . - _ _ e n t r y _ u s e r _ d a t a _ t l b _ m i s s