2005-04-17 02:20:36 +04:00
/ *
* linux/ a r c h / x86 _ 6 4 / k e r n e l / h e a d . S - - s t a r t i n 3 2 b i t a n d s w i t c h t o 6 4 b i t
*
* Copyright ( C ) 2 0 0 0 A n d r e a A r c a n g e l i < a n d r e a @suse.de> SuSE
* Copyright ( C ) 2 0 0 0 P a v e l M a c h e k < p a v e l @suse.cz>
* Copyright ( C ) 2 0 0 0 K a r s t e n K e i l < k k e i l @suse.de>
* Copyright ( C ) 2 0 0 1 ,2 0 0 2 A n d i K l e e n < a k @suse.de>
2007-05-02 21:27:07 +04:00
* Copyright ( C ) 2 0 0 5 E r i c B i e d e r m a n < e b i e d e r m @xmission.com>
2005-04-17 02:20:36 +04:00
* /
# include < l i n u x / l i n k a g e . h >
# include < l i n u x / t h r e a d s . h >
2005-11-05 19:25:53 +03:00
# include < l i n u x / i n i t . h >
2005-04-17 02:20:36 +04:00
# include < a s m / d e s c . h >
# include < a s m / s e g m e n t . h >
2007-05-02 21:27:06 +04:00
# include < a s m / p g t a b l e . h >
2005-04-17 02:20:36 +04:00
# include < a s m / p a g e . h >
# include < a s m / m s r . h >
# include < a s m / c a c h e . h >
2007-05-02 21:27:07 +04:00
2008-01-30 15:31:10 +03:00
# ifdef C O N F I G _ P A R A V I R T
# include < a s m / a s m - o f f s e t s . h >
# include < a s m / p a r a v i r t . h >
# else
# define G E T _ C R 2 _ I N T O _ R C X m o v q % c r2 , % r c x
# endif
2005-04-17 02:20:36 +04:00
/ * we a r e n o t a b l e t o s w i t c h i n o n e s t e p t o t h e f i n a l K E R N E L A D R E S S S P A C E
2007-05-02 21:27:07 +04:00
* because w e n e e d i d e n t i t y - m a p p e d p a g e s .
*
2005-04-17 02:20:36 +04:00
* /
.text
2007-07-22 13:12:45 +04:00
.section .text .head
2007-05-02 21:27:07 +04:00
.code64
.globl startup_64
startup_64 :
2005-04-17 02:20:36 +04:00
/ *
2007-05-02 21:27:07 +04:00
* At t h i s p o i n t t h e C P U r u n s i n 6 4 b i t m o d e C S . L = 1 C S . D = 1 ,
* and s o m e o n e h a s l o a d e d a n i d e n t i t y m a p p e d p a g e t a b l e
* for u s . T h e s e i d e n t i t y m a p p e d p a g e t a b l e s m a p a l l o f t h e
* kernel p a g e s a n d p o s s i b l y a l l o f m e m o r y .
*
* % esi h o l d s a p h y s i c a l p o i n t e r t o r e a l _ m o d e _ d a t a .
*
* We c o m e h e r e e i t h e r d i r e c t l y f r o m a 6 4 b i t b o o t l o a d e r , o r f r o m
* arch/ x86 _ 6 4 / b o o t / c o m p r e s s e d / h e a d . S .
*
* We o n l y c o m e h e r e i n i t i a l l y a t b o o t n o t h i n g e l s e c o m e s h e r e .
*
* Since w e m a y b e l o a d e d a t a n a d d r e s s d i f f e r e n t f r o m w h a t w e w e r e
* compiled t o r u n a t w e f i r s t f i x u p t h e p h y s i c a l a d d r e s s e s i n o u r p a g e
* tables a n d t h e n r e l o a d t h e m .
2005-04-17 02:20:36 +04:00
* /
2007-05-02 21:27:07 +04:00
/ * Compute t h e d e l t a b e t w e e n t h e a d d r e s s I a m c o m p i l e d t o r u n a t a n d t h e
* address I a m a c t u a l l y r u n n i n g a t .
2005-04-17 02:20:36 +04:00
* /
2007-05-02 21:27:07 +04:00
leaq _ t e x t ( % r i p ) , % r b p
subq $ _ t e x t - _ _ S T A R T _ K E R N E L _ m a p , % r b p
/* Is the address not 2M aligned? */
movq % r b p , % r a x
andl $ ~ L A R G E _ P A G E _ M A S K , % e a x
testl % e a x , % e a x
jnz b a d _ a d d r e s s
/* Is the address too large? */
leaq _ t e x t ( % r i p ) , % r d x
movq $ P G D I R _ S I Z E , % r a x
cmpq % r a x , % r d x
jae b a d _ a d d r e s s
/ * Fixup t h e p h y s i c a l a d d r e s s e s i n t h e p a g e t a b l e
2005-04-17 02:20:36 +04:00
* /
2007-05-02 21:27:07 +04:00
addq % r b p , i n i t _ l e v e l 4 _ p g t + 0 ( % r i p )
addq % r b p , i n i t _ l e v e l 4 _ p g t + ( 2 5 8 * 8 ) ( % r i p )
addq % r b p , i n i t _ l e v e l 4 _ p g t + ( 5 1 1 * 8 ) ( % r i p )
addq % r b p , l e v e l 3 _ i d e n t _ p g t + 0 ( % r i p )
2007-07-16 10:37:28 +04:00
2007-05-02 21:27:07 +04:00
addq % r b p , l e v e l 3 _ k e r n e l _ p g t + ( 5 1 0 * 8 ) ( % r i p )
2007-07-16 10:37:28 +04:00
addq % r b p , l e v e l 3 _ k e r n e l _ p g t + ( 5 1 1 * 8 ) ( % r i p )
addq % r b p , l e v e l 2 _ f i x m a p _ p g t + ( 5 0 6 * 8 ) ( % r i p )
2007-05-02 21:27:07 +04:00
/* Add an Identity mapping if I am above 1G */
leaq _ t e x t ( % r i p ) , % r d i
andq $ L A R G E _ P A G E _ M A S K , % r d i
movq % r d i , % r a x
shrq $ P U D _ S H I F T , % r a x
andq $ ( P T R S _ P E R _ P U D - 1 ) , % r a x
jz i d e n t _ c o m p l e t e
leaq ( l e v e l 2 _ s p a r e _ p g t - _ _ S T A R T _ K E R N E L _ m a p + _ K E R N P G _ T A B L E ) ( % r b p ) , % r d x
leaq l e v e l 3 _ i d e n t _ p g t ( % r i p ) , % r b x
movq % r d x , 0 ( % r b x , % r a x , 8 )
movq % r d i , % r a x
shrq $ P M D _ S H I F T , % r a x
andq $ ( P T R S _ P E R _ P M D - 1 ) , % r a x
leaq _ _ P A G E _ K E R N E L _ L A R G E _ E X E C ( % r d i ) , % r d x
leaq l e v e l 2 _ s p a r e _ p g t ( % r i p ) , % r b x
movq % r d x , 0 ( % r b x , % r a x , 8 )
ident_complete :
/ * Fixup t h e k e r n e l t e x t + d a t a v i r t u a l a d d r e s s e s
* /
leaq l e v e l 2 _ k e r n e l _ p g t ( % r i p ) , % r d i
leaq 4 0 9 6 ( % r d i ) , % r8
/* See if it is a valid page table entry */
1 : testq $ 1 , 0 ( % r d i )
jz 2 f
addq % r b p , 0 ( % r d i )
/* Go to the next page */
2 : addq $ 8 , % r d i
cmp % r8 , % r d i
jne 1 b
/* Fixup phys_base */
addq % r b p , p h y s _ b a s e ( % r i p )
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:07 +04:00
# ifdef C O N F I G _ S M P
addq % r b p , t r a m p o l i n e _ l e v e l 4 _ p g t + 0 ( % r i p )
addq % r b p , t r a m p o l i n e _ l e v e l 4 _ p g t + ( 5 1 1 * 8 ) ( % r i p )
# endif
2007-07-28 11:33:16 +04:00
# ifdef C O N F I G _ A C P I _ S L E E P
2007-05-02 21:27:07 +04:00
addq % r b p , w a k e u p _ l e v e l 4 _ p g t + 0 ( % r i p )
addq % r b p , w a k e u p _ l e v e l 4 _ p g t + ( 5 1 1 * 8 ) ( % r i p )
# endif
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:07 +04:00
/ * Due t o E N T R Y ( ) , s o m e t i m e s t h e e m p t y s p a c e g e t s f i l l e d w i t h
* zeros. B e t t e r t a k e a j m p t h a n r e l y i n g o n e m p t y s p a c e b e i n g
* filled w i t h 0 x90 ( n o p )
2005-04-17 02:20:36 +04:00
* /
2007-05-02 21:27:07 +04:00
jmp s e c o n d a r y _ s t a r t u p _ 6 4
2007-05-02 21:27:07 +04:00
ENTRY( s e c o n d a r y _ s t a r t u p _ 6 4 )
2007-05-02 21:27:07 +04:00
/ *
* At t h i s p o i n t t h e C P U r u n s i n 6 4 b i t m o d e C S . L = 1 C S . D = 1 ,
* and s o m e o n e h a s l o a d e d a m a p p e d p a g e t a b l e .
*
* % esi h o l d s a p h y s i c a l p o i n t e r t o r e a l _ m o d e _ d a t a .
*
* We c o m e h e r e e i t h e r f r o m s t a r t u p _ 6 4 ( u s i n g p h y s i c a l a d d r e s s e s )
* or f r o m t r a m p o l i n e . S ( u s i n g v i r t u a l a d d r e s s e s ) .
*
* Using v i r t u a l a d d r e s s e s f r o m t r a m p o l i n e . S r e m o v e s t h e n e e d
* to h a v e a n y i d e n t i t y m a p p e d p a g e s i n t h e k e r n e l p a g e t a b l e
* after t h e b o o t p r o c e s s o r e x e c u t e s t h i s c o d e .
2005-04-17 02:20:36 +04:00
* /
/* Enable PAE mode and PGE */
xorq % r a x , % r a x
btsq $ 5 , % r a x
btsq $ 7 , % r a x
movq % r a x , % c r4
/* Setup early boot stage 4 level pagetables. */
2007-05-02 21:27:07 +04:00
movq $ ( i n i t _ l e v e l 4 _ p g t - _ _ S T A R T _ K E R N E L _ m a p ) , % r a x
2007-05-02 21:27:07 +04:00
addq p h y s _ b a s e ( % r i p ) , % r a x
2005-04-17 02:20:36 +04:00
movq % r a x , % c r3
2007-05-02 21:27:07 +04:00
/* Ensure I am executing from virtual addresses */
movq $ 1 f , % r a x
jmp * % r a x
1 :
2005-04-17 02:20:36 +04:00
/* Check if nx is implemented */
movl $ 0 x80 0 0 0 0 0 1 , % e a x
cpuid
movl % e d x ,% e d i
/* Setup EFER (Extended Feature Enable Register) */
movl $ M S R _ E F E R , % e c x
rdmsr
2007-05-02 21:27:07 +04:00
btsl $ _ E F E R _ S C E , % e a x / * E n a b l e S y s t e m C a l l * /
btl $ 2 0 ,% e d i / * N o E x e c u t e s u p p o r t e d ? * /
2005-04-17 02:20:36 +04:00
jnc 1 f
btsl $ _ E F E R _ N X , % e a x
2007-05-02 21:27:07 +04:00
1 : wrmsr / * M a k e c h a n g e s e f f e c t i v e * /
2005-04-17 02:20:36 +04:00
/* Setup cr0 */
2005-07-29 08:15:48 +04:00
# define C R 0 _ P M 1 / * p r o t e c t e d m o d e * /
# define C R 0 _ M P ( 1 < < 1 )
# define C R 0 _ E T ( 1 < < 4 )
# define C R 0 _ N E ( 1 < < 5 )
# define C R 0 _ W P ( 1 < < 1 6 )
# define C R 0 _ A M ( 1 < < 1 8 )
# define C R 0 _ P A G I N G ( 1 < < 3 1 )
movl $ C R 0 _ P M | C R 0 _ M P | C R 0 _ E T | C R 0 _ N E | C R 0 _ W P | C R 0 _ A M | C R 0 _ P A G I N G ,% e a x
2005-04-17 02:20:36 +04:00
/* Make changes effective */
movq % r a x , % c r0
/* Setup a boot time stack */
movq i n i t _ r s p ( % r i p ) ,% r s p
/* zero EFLAGS after setting rsp */
pushq $ 0
popfq
/ *
* We m u s t s w i t c h t o a n e w d e s c r i p t o r i n k e r n e l s p a c e f o r t h e G D T
* because s o o n t h e k e r n e l w o n ' t h a v e a c c e s s a n y m o r e t o t h e u s e r s p a c e
* addresses w h e r e w e ' r e c u r r e n t l y r u n n i n g o n . W e h a v e t o d o t h a t h e r e
* because i n 3 2 b i t w e c o u l d n ' t l o a d a 6 4 b i t l i n e a r a d d r e s s .
* /
2007-05-02 21:27:07 +04:00
lgdt c p u _ g d t _ d e s c r ( % r i p )
2005-04-17 02:20:36 +04:00
2007-02-13 15:26:24 +03:00
/* set up data segments. actually 0 would do too */
movl $ _ _ K E R N E L _ D S ,% e a x
movl % e a x ,% d s
movl % e a x ,% s s
movl % e a x ,% e s
/ *
* We d o n ' t r e a l l y n e e d t o l o a d % f s o r % g s , b u t l o a d t h e m a n y w a y
* to k i l l a n y s t a l e r e a l m o d e s e l e c t o r s . T h i s a l l o w s e x e c u t i o n
* under V T h a r d w a r e .
* /
movl % e a x ,% f s
movl % e a x ,% g s
2005-04-17 02:20:36 +04:00
/ *
* Setup u p a d u m m y P D A . t h i s i s j u s t f o r s o m e e a r l y b o o t u p c o d e
* that d o e s i n _ i n t e r r u p t ( )
* /
movl $ M S R _ G S _ B A S E ,% e c x
movq $ e m p t y _ z e r o _ p a g e ,% r a x
movq % r a x ,% r d x
shrq $ 3 2 ,% r d x
wrmsr
/ * esi i s p o i n t e r t o r e a l m o d e s t r u c t u r e w i t h i n t e r e s t i n g i n f o .
pass i t t o C * /
movl % e s i , % e d i
/ * Finally j u m p t o r u n C c o d e a n d t o b e o n r e a l k e r n e l a d d r e s s
* Since w e a r e r u n n i n g o n i d e n t i t y - m a p p e d s p a c e w e h a v e t o j u m p
2006-09-26 12:52:38 +04:00
* to t h e f u l l 6 4 b i t a d d r e s s , t h i s i s o n l y p o s s i b l e a s i n d i r e c t
* jump. I n a d d i t i o n w e n e e d t o e n s u r e % c s i s s e t s o w e m a k e t h i s
* a f a r r e t u r n .
2005-04-17 02:20:36 +04:00
* /
movq i n i t i a l _ c o d e ( % r i p ) ,% r a x
2006-09-26 12:52:38 +04:00
pushq $ 0 # f a k e r e t u r n a d d r e s s t o s t o p u n w i n d e r
pushq $ _ _ K E R N E L _ C S # s e t c o r r e c t c s
pushq % r a x # t a r g e t a d d r e s s i n n e g a t i v e s p a c e
lretq
2005-04-17 02:20:36 +04:00
2006-03-25 18:30:01 +03:00
/* SMP bootup changes these two */
2007-07-22 13:12:45 +04:00
# ifndef C O N F I G _ H O T P L U G _ C P U
.pushsection .init .data
# endif
2006-03-25 18:30:01 +03:00
.align 8
2005-04-17 02:20:36 +04:00
.globl initial_code
initial_code :
.quad x86_64_start_kernel
2007-07-22 13:12:45 +04:00
# ifndef C O N F I G _ H O T P L U G _ C P U
.popsection
# endif
2005-04-17 02:20:36 +04:00
.globl init_rsp
init_rsp :
.quad init_ t h r e a d _ u n i o n + T H R E A D _ S I Z E - 8
2007-05-02 21:27:07 +04:00
bad_address :
jmp b a d _ a d d r e s s
2008-01-30 15:33:06 +03:00
# ifdef C O N F I G _ E A R L Y _ P R I N T K
2008-01-30 15:33:06 +03:00
.macro early_idt_tramp first, l a s t
.ifgt \ last- \ f i r s t
early_ i d t _ t r a m p \ f i r s t , \ l a s t - 1
.endif
movl $ \ l a s t ,% e s i
jmp e a r l y _ i d t _ h a n d l e r
.endm
.globl early_idt_handlers
early_idt_handlers :
early_ i d t _ t r a m p 0 , 6 3
early_ i d t _ t r a m p 6 4 , 1 2 7
early_ i d t _ t r a m p 1 2 8 , 1 9 1
early_ i d t _ t r a m p 1 9 2 , 2 5 5
2008-01-30 15:33:06 +03:00
# endif
2008-01-30 15:33:06 +03:00
2005-04-17 02:20:36 +04:00
ENTRY( e a r l y _ i d t _ h a n d l e r )
2008-01-30 15:33:06 +03:00
# ifdef C O N F I G _ E A R L Y _ P R I N T K
2005-04-17 02:25:00 +04:00
cmpl $ 2 ,e a r l y _ r e c u r s i o n _ f l a g ( % r i p )
jz 1 f
incl e a r l y _ r e c u r s i o n _ f l a g ( % r i p )
2008-01-30 15:31:10 +03:00
GET_ C R 2 _ I N T O _ R C X
2008-01-30 15:33:06 +03:00
movq % r c x ,% r9
xorl % r8 d ,% r8 d # z e r o f o r e r r o r c o d e
movl % e s i ,% e c x # g e t v e c t o r n u m b e r
# Test % e c x a g a i n s t m a s k o f v e c t o r s t h a t p u s h e r r o r c o d e .
cmpl $ 3 1 ,% e c x
ja 0 f
movl $ 1 ,% e a x
salq % c l ,% r a x
testl $ 0 x27 d00 ,% e a x
je 0 f
popq % r8 # g e t e r r o r c o d e
0 : movq 0 ( % r s p ) ,% r c x # g e t i p
movq 8 ( % r s p ) ,% r d x # g e t c s
xorl % e a x ,% e a x
2005-04-17 02:20:36 +04:00
leaq e a r l y _ i d t _ m s g ( % r i p ) ,% r d i
call e a r l y _ p r i n t k
2005-04-17 02:25:00 +04:00
cmpl $ 2 ,e a r l y _ r e c u r s i o n _ f l a g ( % r i p )
jz 1 f
call d u m p _ s t a c k
2006-02-17 01:42:10 +03:00
# ifdef C O N F I G _ K A L L S Y M S
leaq e a r l y _ i d t _ r i p m s g ( % r i p ) ,% r d i
movq 8 ( % r s p ) ,% r s i # g e t r i p a g a i n
call _ _ p r i n t _ s y m b o l
# endif
2008-01-30 15:33:06 +03:00
# endif / * E A R L Y _ P R I N T K * /
2005-04-17 02:20:36 +04:00
1 : hlt
jmp 1 b
2008-01-30 15:33:06 +03:00
# ifdef C O N F I G _ E A R L Y _ P R I N T K
2005-04-17 02:25:00 +04:00
early_recursion_flag :
.long 0
2005-04-17 02:20:36 +04:00
early_idt_msg :
2008-01-30 15:33:06 +03:00
.asciz " PANIC : early e x c e p t i o n % 0 2 l x r i p % l x : % l x e r r o r % l x c r2 % l x \ n "
2006-02-17 01:42:10 +03:00
early_idt_ripmsg :
.asciz " RIP % s \ n "
2008-01-30 15:33:06 +03:00
# endif / * C O N F I G _ E A R L Y _ P R I N T K * /
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:07 +04:00
.balign PAGE_SIZE
2005-04-17 02:20:36 +04:00
2006-01-17 09:03:32 +03:00
# define N E X T _ P A G E ( n a m e ) \
2007-05-02 21:27:06 +04:00
.balign PAGE_ S I Z E ; \
2006-01-17 09:03:32 +03:00
ENTRY( n a m e )
2007-05-02 21:27:06 +04:00
/* Automate the creation of 1 to 1 mapping pmd entries */
# define P M D S ( S T A R T , P E R M , C O U N T ) \
i = 0 ; \
.rept ( COUNT) ; \
.quad ( START) + ( i < < 2 1 ) + ( P E R M ) ; \
i = i + 1 ; \
.endr
2007-05-02 21:27:07 +04:00
/ *
* This d e f a u l t s e t t i n g g e n e r a t e s a n i d e n t m a p p i n g a t a d d r e s s 0 x10 0 0 0 0
* and a m a p p i n g f o r t h e k e r n e l t h a t p r e c i s e l y m a p s v i r t u a l a d d r e s s
* 0 xffffffff8 0 0 0 0 0 0 0 t o p h y s i c a l a d d r e s s 0 x00 0 0 0 0 . ( a l w a y s u s i n g
* 2 Mbyte l a r g e p a g e s p r o v i d e d b y P A E m o d e )
* /
2006-01-17 09:03:32 +03:00
NEXT_ P A G E ( i n i t _ l e v e l 4 _ p g t )
2007-05-02 21:27:07 +04:00
.quad level3_ident_pgt - _ _ START_ K E R N E L _ m a p + _ K E R N P G _ T A B L E
.fill 2 5 7 , 8 , 0
.quad level3_ident_pgt - _ _ START_ K E R N E L _ m a p + _ K E R N P G _ T A B L E
.fill 2 5 2 , 8 , 0
/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
.quad level3_kernel_pgt - _ _ START_ K E R N E L _ m a p + _ P A G E _ T A B L E
2005-04-17 02:20:36 +04:00
2006-01-17 09:03:32 +03:00
NEXT_ P A G E ( l e v e l 3 _ i d e n t _ p g t )
2007-05-02 21:27:06 +04:00
.quad level2_ident_pgt - _ _ START_ K E R N E L _ m a p + _ K E R N P G _ T A B L E
2005-04-17 02:20:36 +04:00
.fill 5 1 1 , 8 , 0
2006-01-17 09:03:32 +03:00
NEXT_ P A G E ( l e v e l 3 _ k e r n e l _ p g t )
2005-04-17 02:20:36 +04:00
.fill 5 1 0 , 8 , 0
/* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
2007-05-02 21:27:06 +04:00
.quad level2_kernel_pgt - _ _ START_ K E R N E L _ m a p + _ K E R N P G _ T A B L E
2007-07-16 10:37:28 +04:00
.quad level2_fixmap_pgt - _ _ START_ K E R N E L _ m a p + _ P A G E _ T A B L E
NEXT_ P A G E ( l e v e l 2 _ f i x m a p _ p g t )
.fill 5 0 6 , 8 , 0
.quad level1_fixmap_pgt - _ _ START_ K E R N E L _ m a p + _ P A G E _ T A B L E
/* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
.fill 5 , 8 , 0
NEXT_ P A G E ( l e v e l 1 _ f i x m a p _ p g t )
.fill 5 1 2 , 8 , 0
2005-04-17 02:20:36 +04:00
2006-01-17 09:03:32 +03:00
NEXT_ P A G E ( l e v e l 2 _ i d e n t _ p g t )
2007-05-02 21:27:06 +04:00
/ * Since I e a s i l y c a n , m a p t h e f i r s t 1 G .
* Don' t s e t N X b e c a u s e c o d e r u n s f r o m t h e s e p a g e s .
* /
PMDS( 0 x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 , _ _ P A G E _ K E R N E L _ L A R G E _ E X E C , P T R S _ P E R _ P M D )
2007-05-02 21:27:07 +04:00
2006-01-17 09:03:32 +03:00
NEXT_ P A G E ( l e v e l 2 _ k e r n e l _ p g t )
2005-04-17 02:20:36 +04:00
/ * 4 0 MB k e r n e l m a p p i n g . T h e k e r n e l c o d e c a n n o t b e b i g g e r t h a n t h a t .
When y o u c h a n g e t h i s c h a n g e K E R N E L _ T E X T _ S I Z E i n p a g e . h t o o . * /
/* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */
2007-08-15 04:40:36 +04:00
PMDS( 0 x00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 , _ _ P A G E _ K E R N E L _ L A R G E _ E X E C | _ P A G E _ G L O B A L , K E R N E L _ T E X T _ S I Z E / P M D _ S I Z E )
2005-04-17 02:20:36 +04:00
/* Module mapping starts here */
2007-05-02 21:27:06 +04:00
.fill ( PTRS_ P E R _ P M D - ( K E R N E L _ T E X T _ S I Z E / P M D _ S I Z E ) ) ,8 ,0
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:07 +04:00
NEXT_ P A G E ( l e v e l 2 _ s p a r e _ p g t )
.fill 5 1 2 , 8 , 0
2007-05-02 21:27:06 +04:00
# undef P M D S
2006-01-17 09:03:32 +03:00
# undef N E X T _ P A G E
2005-04-17 02:20:36 +04:00
2006-01-17 09:03:32 +03:00
.data
2005-04-17 02:20:36 +04:00
.align 16
.globl cpu_gdt_descr
cpu_gdt_descr :
2006-03-25 18:30:01 +03:00
.word gdt_ e n d - c p u _ g d t _ t a b l e - 1
2005-04-17 02:20:36 +04:00
gdt :
.quad cpu_gdt_table
# ifdef C O N F I G _ S M P
.rept NR_ C P U S - 1
.word 0
.quad 0
.endr
# endif
2007-05-02 21:27:07 +04:00
ENTRY( p h y s _ b a s e )
/* This must match the first entry in level2_kernel_pgt */
.quad 0x0000000000000000
2005-04-17 02:20:36 +04:00
/ * We n e e d v a l i d k e r n e l s e g m e n t s f o r d a t a a n d c o d e i n l o n g m o d e t o o
* IRET w i l l c h e c k t h e s e g m e n t t y p e s k k e i l 2 0 0 0 / 1 0 / 2 8
* Also s y s r e t m a n d a t e s a s p e c i a l G D T l a y o u t
* /
2006-03-25 18:30:01 +03:00
.section .data .page_aligned , " aw"
.align PAGE_SIZE
2005-04-17 02:20:36 +04:00
/ * The T L S d e s c r i p t o r s a r e c u r r e n t l y a t a d i f f e r e n t p l a c e c o m p a r e d t o i 3 8 6 .
Hopefully n o b o d y e x p e c t s t h e m a t a f i x e d p l a c e ( W i n e ? ) * /
ENTRY( c p u _ g d t _ t a b l e )
.quad 0x0000000000000000 /* NULL descriptor */
2007-05-02 21:27:07 +04:00
.quad 0x00cf9b000000ffff /* __KERNEL32_CS */
.quad 0x00af9b000000ffff /* __KERNEL_CS */
.quad 0x00cf93000000ffff /* __KERNEL_DS */
.quad 0x00cffb000000ffff /* __USER32_CS */
.quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
.quad 0x00affb000000ffff /* __USER_CS */
2006-01-12 00:46:24 +03:00
.quad 0x0 /* unused */
2005-04-17 02:20:36 +04:00
.quad 0 , 0 /* TSS */
.quad 0 , 0 /* LDT */
.quad 0 , 0 , 0 /* three TLS descriptors */
2006-09-26 12:52:28 +04:00
.quad 0x0000f40000000000 /* node/CPU stored in limit */
2005-04-17 02:20:36 +04:00
gdt_end :
/* asm/segment.h:GDT_ENTRIES must match this */
/* This should be a multiple of the cache line size */
2006-01-12 00:43:57 +03:00
/* GDTs of other CPUs are now dynamically allocated */
/* zero the remaining page */
.fill PAGE_SIZE / 8 - GDT_ E N T R I E S ,8 ,0
2005-04-17 02:20:36 +04:00
2006-03-25 18:30:01 +03:00
.section .bss , " aw" , @nobits
.align L1_CACHE_BYTES
ENTRY( i d t _ t a b l e )
.skip 256 * 1 6
2005-04-17 02:20:36 +04:00
2006-03-25 18:30:01 +03:00
.section .bss .page_aligned , " aw" , @nobits
.align PAGE_SIZE
ENTRY( e m p t y _ z e r o _ p a g e )
.skip PAGE_SIZE