Skip to content

Commit 196cf0d

Browse files
Yinghai LuIngo Molnar
authored andcommitted
x86: Make sure wakeup trampoline code is below 1MB
Instead of using bootmem, try find_e820_area()/reserve_early(), and call acpi_reserve_memory() early, to allocate the wakeup trampoline code area below 1M. This is more reliable, and it also removes a dependency on bootmem. -v2: change function name to acpi_reserve_wakeup_memory(), as suggested by Rafael. Signed-off-by: Yinghai Lu <[email protected]> Acked-by: H. Peter Anvin <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Cc: pm list <[email protected]> Cc: Len Brown <[email protected]> Cc: Linus Torvalds <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 0420101 commit 196cf0d

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

arch/x86/include/asm/acpi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ extern void acpi_restore_state_mem(void);
118118
extern unsigned long acpi_wakeup_address;
119119

120120
/* early initialization routine */
121-
extern void acpi_reserve_bootmem(void);
121+
extern void acpi_reserve_wakeup_memory(void);
122122

123123
/*
124124
* Check if the CPU can handle C2 and deeper

arch/x86/kernel/acpi/sleep.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,29 +119,32 @@ void acpi_restore_state_mem(void)
119119

120120

121121
/**
122-
* acpi_reserve_bootmem - do _very_ early ACPI initialisation
122+
* acpi_reserve_wakeup_memory - do _very_ early ACPI initialisation
123123
*
124124
* We allocate a page from the first 1MB of memory for the wakeup
125125
* routine for when we come back from a sleep state. The
126126
* runtime allocator allows specification of <16MB pages, but not
127127
* <1MB pages.
128128
*/
129-
void __init acpi_reserve_bootmem(void)
129+
void __init acpi_reserve_wakeup_memory(void)
130130
{
131+
unsigned long mem;
132+
131133
if ((&wakeup_code_end - &wakeup_code_start) > WAKEUP_SIZE) {
132134
printk(KERN_ERR
133135
"ACPI: Wakeup code way too big, S3 disabled.\n");
134136
return;
135137
}
136138

137-
acpi_realmode = (unsigned long)alloc_bootmem_low(WAKEUP_SIZE);
139+
mem = find_e820_area(0, 1<<20, WAKEUP_SIZE, PAGE_SIZE);
138140

139-
if (!acpi_realmode) {
141+
if (mem == -1L) {
140142
printk(KERN_ERR "ACPI: Cannot allocate lowmem, S3 disabled.\n");
141143
return;
142144
}
143-
144-
acpi_wakeup_address = virt_to_phys((void *)acpi_realmode);
145+
acpi_realmode = (unsigned long) phys_to_virt(mem);
146+
acpi_wakeup_address = mem;
147+
reserve_early(mem, mem + WAKEUP_SIZE, "ACPI WAKEUP");
145148
}
146149

147150

arch/x86/kernel/setup.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,13 @@ void __init setup_arch(char **cmdline_p)
897897

898898
reserve_brk();
899899

900+
#ifdef CONFIG_ACPI_SLEEP
901+
/*
902+
* Reserve low memory region for sleep support.
903+
* even before init_memory_mapping
904+
*/
905+
acpi_reserve_wakeup_memory();
906+
#endif
900907
init_gbpages();
901908

902909
/* max_pfn_mapped is updated here */
@@ -948,12 +955,6 @@ void __init setup_arch(char **cmdline_p)
948955

949956
initmem_init(0, max_pfn, acpi, k8);
950957

951-
#ifdef CONFIG_ACPI_SLEEP
952-
/*
953-
* Reserve low memory region for sleep support.
954-
*/
955-
acpi_reserve_bootmem();
956-
#endif
957958
/*
958959
* Find and reserve possible boot-time SMP configuration:
959960
*/

0 commit comments

Comments
 (0)