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 / 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 >
2008-05-12 17:43:38 +04:00
# include < a s m / p r o c e s s o r - f l a g s . h >
2009-01-13 14:41:35 +03:00
# include < a s m / p e r c p u . 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
* /
2008-06-25 08:19:16 +04:00
# define p u d _ i n d e x ( x ) ( ( ( x ) > > P U D _ S H I F T ) & ( P T R S _ P E R _ P U D - 1 ) )
L4 _ P A G E _ O F F S E T = p g d _ i n d e x ( _ _ P A G E _ O F F S E T )
L3 _ P A G E _ O F F S E T = p u d _ i n d e x ( _ _ P A G E _ O F F S E T )
L4 _ S T A R T _ K E R N E L = p g d _ i n d e x ( _ _ S T A R T _ K E R N E L _ m a p )
L3 _ S T A R T _ K E R N E L = p u d _ i n d e x ( _ _ S T A R T _ K E R N E L _ m a p )
2005-04-17 02:20:36 +04:00
.text
2009-09-17 00:44:28 +04:00
_ _ 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
2008-02-04 18:48:08 +03:00
andl $ ~ P M D _ P A G E _ M A S K , % e a x
2007-05-02 21:27:07 +04:00
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 )
2008-06-25 08:19:16 +04:00
addq % r b p , i n i t _ l e v e l 4 _ p g t + ( L 4 _ P A G E _ O F F S E T * 8 ) ( % r i p )
addq % r b p , i n i t _ l e v e l 4 _ p g t + ( L 4 _ S T A R T _ K E R N E L * 8 ) ( % r i p )
2007-05-02 21:27:07 +04:00
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
2008-02-04 18:48:08 +03:00
andq $ P M D _ P A G E _ M A S K , % r d i
2007-05-02 21:27:07 +04:00
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
2008-09-24 01:00:36 +04:00
leaq _ _ P A G E _ K E R N E L _ I D E N T _ L A R G E _ E X E C ( % r d i ) , % r d x
2007-05-02 21:27:07 +04:00
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 :
2008-02-15 19:29:12 +03:00
/ *
* 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 . N o t e t h a t
* we m i g h t w r i t e i n v a l i d p m d s , w h e n t h e k e r n e l i s r e l o c a t e d
* cleanup_ h i g h m a p ( ) f i x e s t h i s u p a l o n g w i t h t h e m a p p i n g s
* beyond _ e n d .
2007-05-02 21:27:07 +04:00
* /
2008-02-15 19:29:12 +03:00
2007-05-02 21:27:07 +04:00
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
2008-07-05 02:05:30 +04:00
# ifdef C O N F I G _ X 8 6 _ T R A M P O L I N E
2007-05-02 21:27:07 +04:00
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
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 */
2008-05-13 21:14:22 +04:00
movl $ ( X 8 6 _ C R 4 _ P A E | X 8 6 _ C R 4 _ P G E ) , % e a x
2005-04-17 02:20:36 +04:00
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 */
2008-05-12 17:43:38 +04:00
# define C R 0 _ S T A T E ( X 8 6 _ C R 0 _ P E | X 8 6 _ C R 0 _ M P | X 8 6 _ C R 0 _ E T | \
X8 6 _ C R 0 _ N E | X 8 6 _ C R 0 _ W P | X 8 6 _ C R 0 _ A M | \
X8 6 _ C R 0 _ P G )
movl $ C R 0 _ S T A T E , % 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 */
2008-05-28 05:22:54 +04:00
movq s t a c k _ s t a r t ( % r i p ) ,% r s p
2005-04-17 02:20:36 +04:00
/* 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 .
* /
2008-05-29 03:19:53 +04:00
lgdt e a r l y _ g d t _ d e s c r ( % r i p )
2005-04-17 02:20:36 +04:00
2009-11-25 19:17:36 +03:00
/* set up data segments */
xorl % e a x ,% e a x
2007-02-13 15:26:24 +03:00
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
2009-01-13 14:41:35 +03:00
/ * Set u p % g s .
*
2009-01-19 06:21:28 +03:00
* The b a s e o f % g s a l w a y s p o i n t s t o t h e b o t t o m o f t h e i r q s t a c k
* union. I f t h e s t a c k p r o t e c t o r c a n a r y i s e n a b l e d , i t i s
* located a t % g s : 4 0 . N o t e t h a t , o n S M P , t h e b o o t c p u u s e s
* init d a t a s e c t i o n t i l l p e r c p u a r e a s a r e s e t u p .
2009-01-13 14:41:35 +03:00
* /
2005-04-17 02:20:36 +04:00
movl $ M S R _ G S _ B A S E ,% e c x
2009-01-13 14:41:35 +03:00
movq i n i t i a l _ g s ( % r i p ) ,% r a x
2005-04-17 02:20:36 +04:00
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 */
2008-02-17 15:22:59 +03:00
_ _ REFDATA
2006-03-25 18:30:01 +03:00
.align 8
2008-02-07 00:39:45 +03:00
ENTRY( i n i t i a l _ c o d e )
2005-04-17 02:20:36 +04:00
.quad x86_64_start_kernel
2009-01-13 14:41:35 +03:00
ENTRY( i n i t i a l _ g s )
2009-02-08 17:58:39 +03:00
.quad INIT_ P E R _ C P U _ V A R ( i r q _ s t a c k _ u n i o n )
2008-02-07 00:39:45 +03:00
2008-05-28 05:22:54 +04:00
ENTRY( s t a c k _ s t a r t )
2005-04-17 02:20:36 +04:00
.quad init_ t h r e a d _ u n i o n + T H R E A D _ S I Z E - 8
2008-05-28 05:22:54 +04:00
.word 0
2009-10-15 01:46:55 +04:00
_ _ FINITDATA
2005-04-17 02:20:36 +04:00
2007-05-02 21:27:07 +04:00
bad_address :
jmp b a d _ a d d r e s s
2008-03-11 04:23:21 +03:00
.section " .init .text " , " ax"
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
.globl early_idt_handlers
early_idt_handlers :
2008-03-11 04:23:22 +03:00
i = 0
.rept NUM_EXCEPTION_VECTORS
movl $ i , % e s i
jmp e a r l y _ i d t _ h a n d l e r
i = i + 1
.endr
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
2009-01-04 02:27:09 +03:00
movq 0 ( % r s p ) ,% r s i # g e t r i p a g a i n
2006-02-17 01:42:10 +03:00
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 * /
2008-03-11 04:23:21 +03:00
.previous
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 */
2008-05-13 20:55:40 +04:00
# 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 < < P M D _ S H I F T ) + ( P E R M ) ; \
i = i + 1 ; \
2007-05-02 21:27:06 +04:00
.endr
2009-10-15 01:46:55 +04:00
.data
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
2008-06-25 08:19:16 +04:00
.org init_level4_pgt + L4 _ P A G E _ O F F S E T * 8 , 0
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
2008-06-25 08:19:16 +04:00
.org init_level4_pgt + L4 _ S T A R T _ K E R N E L * 8 , 0
2007-05-02 21:27:07 +04:00
/* (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 )
2008-06-25 08:19:16 +04:00
.fill L3 _ S T A R T _ K E R N E L ,8 ,0
2005-04-17 02:20:36 +04:00
/* (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 )
2008-07-10 00:32:33 +04:00
.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 )
2007-07-16 10:37:28 +04:00
.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 .
* /
2008-09-24 01:00:36 +04:00
PMDS( 0 , _ _ P A G E _ K E R N E L _ I D E N T _ 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 )
2008-02-21 13:04:11 +03:00
/ *
2008-02-21 14:50:51 +03:00
* 5 1 2 MB k e r n e l m a p p i n g . W e s p e n d a f u l l p a g e o n t h i s p a g e t a b l e
2008-02-21 13:04:11 +03:00
* anyway.
*
* The k e r n e l c o d e + d a t a + b s s m u s t n o t b e b i g g e r t h a n t h a t .
*
2008-02-21 14:50:51 +03:00
* ( NOTE : at + 5 1 2 M B s t a r t s t h e m o d u l e a r e a , s e e M O D U L E S _ V A D D R .
2008-02-21 13:04:11 +03:00
* If y o u w a n t t o i n c r e a s e t h i s t h e n i n c r e a s e M O D U L E S _ V A D D R
* too. )
* /
2008-07-02 03:46:35 +04:00
PMDS( 0 , _ _ P A G E _ K E R N E L _ L A R G E _ E X E C ,
2008-02-21 15:39:30 +03:00
KERNEL_ I M A G E _ S I Z E / P M D _ S I Z E )
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 )
2008-02-21 13:04:11 +03:00
.fill 5 1 2 , 8 , 0
2007-05-02 21:27:07 +04:00
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
2008-05-29 03:19:53 +04:00
.globl early_gdt_descr
early_gdt_descr :
.word GDT_ E N T R I E S * 8 - 1
2009-01-13 14:41:35 +03:00
early_gdt_descr_base :
2009-02-08 17:58:39 +03:00
.quad INIT_ P E R _ C P U _ V A R ( g d t _ p a g e )
2005-04-17 02:20:36 +04:00
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
2008-07-09 02:06:44 +04:00
# include " . . / . . / x86 / x e n / x e n - h e a d . S "
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 )
2009-02-23 22:56:58 +03:00
.skip IDT_ENTRIES * 1 6
2005-04-17 02:20:36 +04:00
2009-09-21 02:14:14 +04:00
_ _ PAGE_ A L I G N E D _ B S S
2006-03-25 18:30:01 +03:00
.align PAGE_SIZE
ENTRY( e m p t y _ z e r o _ p a g e )
.skip PAGE_SIZE