x86: make arch/x86/kernel/acpi/wakeup_32.S use a separate
While examining vmlinux namelist on i386 (nm -v vmlinux) I noticed :
c01021d0 t es7000_rename_gsi
c010221a T es7000_start_cpu
<Big Hole>
c0103000 T thread_saved_pc
and
c0113218 T acpi_restore_state_mem
c0113219 T acpi_save_state_mem
<Big Hole>
c0114000 t wakeup_code
This is because arch/x86/kernel/acpi/wakeup_32.S forces a .text alignment
of 4096 bytes. (I have no idea if it is really needed, since
arch/x86/kernel/acpi/wakeup_64.S uses a 16 bytes alignment *only*)
So arch/x86/kernel/built-in.o also has this alignment
arch/x86/kernel/built-in.o: file format elf32-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00018c94 00000000 00000000 00001000 2**12
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
But as arch/x86/kernel/acpi/wakeup_32.o is not the first object linked
into arch/x86/kernel/built-in.o, linker had to build several holes to meet
alignement requirements, because of .o nestings in the kbuild process.
This can be solved by using a special section, .text.page_aligned, so that
no holes are needed.
# size vmlinux.before vmlinux.after
text data bss dec hex filename
4619942 422838 458752 5501532 53f25c vmlinux.before
4610534 422838 458752 5492124 53cd9c vmlinux.after
This saves 9408 bytes
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-01-30 13:32:50 +01:00
.section .text .page_aligned
2005-04-16 15:20:36 -07:00
# include < l i n u x / l i n k a g e . h >
# include < a s m / s e g m e n t . h >
# include < a s m / p a g e . h >
2008-04-10 23:28:10 +02:00
# Copyright 2 0 0 3 , 2 0 0 8 P a v e l M a c h e k < p a v e l @suse.cz>, distribute under GPLv2
2005-04-16 15:20:36 -07:00
.code32
ALIGN
2008-04-10 23:28:10 +02:00
ENTRY( w a k e u p _ p m o d e _ r e t u r n )
2005-04-16 15:20:36 -07:00
wakeup_pmode_return :
movw $ _ _ K E R N E L _ D S , % a x
movw % a x , % s s
movw % a x , % d s
movw % a x , % e s
movw % a x , % f s
movw % a x , % g s
# reload t h e g d t , a s w e n e e d t h e f u l l 3 2 b i t a d d r e s s
lgdt s a v e d _ g d t
lidt s a v e d _ i d t
lldt s a v e d _ l d t
2008-04-10 23:28:10 +02:00
ljmp $ ( _ _ K E R N E L _ C S ) , $ 1 f
2005-04-16 15:20:36 -07:00
1 :
movl % c r3 , % e a x
movl % e a x , % c r3
wbinvd
# and r e s t o r e t h e s t a c k . . . b u t y o u n e e d g d t f o r t h i s t o w o r k
movl s a v e d _ c o n t e x t _ e s p , % e s p
movl % c s : s a v e d _ m a g i c , % e a x
cmpl $ 0 x12 3 4 5 6 7 8 , % e a x
jne b o g u s _ m a g i c
# jump t o p l a c e w h e r e w e l e f t o f f
2008-04-10 23:28:10 +02:00
movl s a v e d _ e i p , % e a x
2005-04-16 15:20:36 -07:00
jmp * % e a x
bogus_magic :
jmp b o g u s _ m a g i c
2008-04-10 23:28:10 +02:00
save_registers :
2005-04-16 15:20:36 -07:00
sgdt s a v e d _ g d t
sidt s a v e d _ i d t
sldt s a v e d _ l d t
str s a v e d _ t s s
leal 4 ( % e s p ) , % e a x
movl % e a x , s a v e d _ c o n t e x t _ e s p
2008-04-10 23:28:10 +02:00
movl % e b x , s a v e d _ c o n t e x t _ e b x
movl % e b p , s a v e d _ c o n t e x t _ e b p
movl % e s i , s a v e d _ c o n t e x t _ e s i
movl % e d i , s a v e d _ c o n t e x t _ e d i
pushfl
popl s a v e d _ c o n t e x t _ e f l a g s
movl $ r e t _ p o i n t , s a v e d _ e i p
2005-04-16 15:20:36 -07:00
ret
restore_registers :
2008-04-10 23:28:10 +02:00
movl s a v e d _ c o n t e x t _ e b p , % e b p
movl s a v e d _ c o n t e x t _ e b x , % e b x
movl s a v e d _ c o n t e x t _ e s i , % e s i
movl s a v e d _ c o n t e x t _ e d i , % e d i
pushl s a v e d _ c o n t e x t _ e f l a g s
popfl
ret
2005-04-16 15:20:36 -07:00
ENTRY( d o _ s u s p e n d _ l o w l e v e l )
call s a v e _ p r o c e s s o r _ s t a t e
call s a v e _ r e g i s t e r s
pushl $ 3
call a c p i _ e n t e r _ s l e e p _ s t a t e
addl $ 4 , % e s p
2006-08-14 22:37:31 -07:00
# In c a s e o f S 3 f a i l u r e , w e ' l l e m e r g e h e r e . J u m p
# to r e t _ p o i n t t o r e c o v e r
jmp r e t _ p o i n t
2005-04-16 15:20:36 -07:00
.p2align 4 , , 7
ret_point :
call r e s t o r e _ r e g i s t e r s
call r e s t o r e _ p r o c e s s o r _ s t a t e
ret
2006-06-23 02:04:50 -07:00
.data
2005-04-16 15:20:36 -07:00
ALIGN
2006-06-23 02:04:50 -07:00
ENTRY( s a v e d _ m a g i c ) . l o n g 0
ENTRY( s a v e d _ e i p ) . l o n g 0
2005-04-16 15:20:36 -07:00
# saved r e g i s t e r s
saved_gdt : .long 0 , 0
saved_idt : .long 0 , 0
saved_ldt : .long 0
saved_tss : .long 0