suspend-to-ram: don't crash when kernel gets big
Hi!
When kernel is too big (like 2.5.49 with pretty minimal options :-), s3 triplefaults during resume. This fixes it, please apply,
Pavel
arch/i386/kernel/acpi.c +13 -65
@@ -446,74 +446,11 @@#ifdef CONFIG_ACPI_SLEEP -#define DEBUG - -#ifdef DEBUG -#include <linux/serial.h> -#endif -/* address in low memory of the wakeup routine. */ unsigned long acpi_wakeup_address =0 ; -/* new page directory that we will be using */ -static pmd_t *pmd; - -/* saved page directory */ -static pmd_t saved_pmd; - -/* page which we'll use for the new page directory */ -static pte_t *ptep; -extern unsigned long FASTCALL (acpi_copy_wakeup_routine (unsigned long )); -/* -* acpi_create_identity_pmd -* -* Create a new, identity mapped pmd. -* -* Do this by creating new page directory, and marking all the pages as R/W -* Then set it as the new Page Middle Directory. -* And, of course, flush the TLB so it takes effect. -* -* We save the address of the old one, for later restoration. -*/ -static void acpi_create_identity_pmd (void ) -{ -pgd_t *pgd; -int i; - - ptep = (pte_t *)__get_free_page (GFP_KERNEL ); - -/* fill page with low mapping */ -for (i =0 ; i <PTRS_PER_PTE ; i++) -set_pte (ptep + i,pfn_pte (i,PAGE_SHARED )); - - pgd =pgd_offset (current->active_mm,0 ); - pmd =pmd_alloc (current->mm,pgd,0 ); - -/* save the old pmd */ - saved_pmd = *pmd; - -/* set the new one */ -set_pmd (pmd,__pmd (_PAGE_TABLE +__pa (ptep))); - -/* flush the TLB */ -local_flush_tlb (); -} - -/* -* acpi_restore_pmd -* -* Restore the old pmd saved by acpi_create_identity_pmd and -* free the page that said function alloc'd -*/ -static void acpi_restore_pmd (void ) -{ -set_pmd (pmd, saved_pmd); -local_flush_tlb (); -free_page ((unsigned long )ptep); -} -/** * acpi_save_state_mem - save kernel state *
@@ -522,7 +459,15 @@*/ int acpi_save_state_mem (void ) { -acpi_create_identity_pmd (); +if (!cpu_has_pse) { +printk (KERN_ERR "You have S3 capable machine without pse? Wow!" ); +return 1 ; + } +#if CONFIG_X86_PAE +panic ("S3 and PAE do not like each other for now." ); +return 1 ; +#endif +init_physical_mapping (swapper_pg_dir,0 ,USER_PTRS_PER_PGD );acpi_copy_wakeup_routine (acpi_wakeup_address);return 0 ;
@@ -542,7 +487,7 @@*/ void acpi_restore_state_mem (void ) { -acpi_restore_pmd (); +zap_low_mappings (); }/**
@@ -555,7 +500,10 @@*/ void __init acpi_reserve_bootmem (void ) { +extern long wakeup_start, wakeup_end; acpi_wakeup_address = (unsigned long )alloc_bootmem_low (PAGE_SIZE ); +if ((&wakeup_end - &wakeup_start) >PAGE_SIZE ) +printk (KERN_CRIT "ACPI: Wakeup code way too big, will crash on attempt to suspend\n" );printk (KERN_DEBUG "ACPI: have wakeup address 0x%8.8lx\n" , acpi_wakeup_address); }
arch/i386/kernel/acpi_wakeup.S +61 -35
162 lines not on this page · raw message
arch/i386/mm/init.c +14 -10
@@ -117,24 +117,18 @@ } } -/* -* This maps the physical memory to kernel virtual address space, a total -* of max_low_pfn pages, by creating page tables starting from address -* PAGE_OFFSET. -*/ -static void __init kernel_physical_mapping_init (pgd_t *pgd_base) +void init_physical_mapping (pgd_t *pgd_base,int pgd_ofs,int pgd_limit) {unsigned long pfn;pgd_t *pgd;pmd_t *pmd;pte_t *pte; -int pgd_ofs, pmd_ofs, pte_ofs; +int pmd_ofs, pte_ofs; - pgd_ofs =__pgd_offset (PAGE_OFFSET ); pgd = pgd_base + pgd_ofs; pfn =0 ; -for (; pgd_ofs <PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_ofs++) { +for (; pgd_ofs < pgd_limit && pfn < max_low_pfn; pgd++, pgd_ofs++) { pmd =one_md_table_init (pgd);for (pmd_ofs =0 ; pmd_ofs <PTRS_PER_PMD && pfn < max_low_pfn; pmd++, pmd_ofs++) {/* Map with big pages if possible, otherwise create normal page tables. */
@@ -151,6 +145,16 @@ } } +/* +* This maps the physical memory to kernel virtual address space, a total +* of max_low_pfn pages, by creating page tables starting from address +* PAGE_OFFSET. +*/ +static void __init kernel_physical_mapping_init (pgd_t *pgd_base) +{ +init_physical_mapping (pgd_base,__pgd_offset (PAGE_OFFSET ),PTRS_PER_PGD ); +} +static inline int page_kills_ppro (unsigned long pagenr) {if (pagenr >=0x70000 && pagenr <=0x7003F )
@@ -299,7 +303,7 @@#endif } -void __init zap_low_mappings (void ) +void zap_low_mappings (void ) {int i;/*
Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net. What goes next? Inserting advertisment *into* email?
Hi!
arch/i386/kernel/acpi_wakeup.S line 44
Quoted 4 lines
arch/i386/kernel/acpi_wakeup.S +4
-0+ pushl $0 # Kill any dangerous flags + popfl + cli + cld
Seems like you're trying to be 200% sure ;-)
Have a nice fortnight
Signature · 3 lines
Martin `MJ' Mares <[email protected]> http://atrey.karlin.mff.cuni.cz/~mj/ Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth First law of socio-genetics: Celibacy is not hereditary.
Hi!
Quoted 6 lines
arch/i386/kernel/acpi_wakeup.S line 44
Quoted 4 lines
arch/i386/kernel/acpi_wakeup.S +4
-0+ pushl $0 # Kill any dangerous flags + popfl + cli + cldSeems like you're trying to be 200% sure ;-)
I was not sure if cli really *clears* it as name implies :-).
Pavel
Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building, cryptography in U.S.A. and free speech in Czech Republic.
On Sun, 24 Nov 2002, Pavel Machek wrote:
| Hi! | | > > + pushl $0 # Kill any dangerous flags | > > + popfl | > > + cli | > > + cld | > | > Seems like you're trying to be 200% sure ;-) | | I was not sure if cli really *clears* it as name implies :-).
Yes, as Martin suggested. 8;)
Signature · 1 line
~Randy
Hi!
Quoted 10 lines
| > > + pushl $0 # Kill any dangerous flags | > > + popfl | > > + cli | > > + cld | > | > Seems like you're trying to be 200% sure ;-) | | I was not sure if cli really *clears* it as name implies :-).Yes, as Martin suggested. 8;)
Actually, as following proves, I wanted to be *300%* sure ;-).
cli
cld
# We are now probably running at something like 0x0000 : 0x1000
call here
here:
pop %bx
subw $(here-wakeup_start), %bx
shrw $4, %bx
# setup data segment
movw %cs, %ax
addw %bx, %ax
movw %ax, %ds # Make
ds:0 point to wakeup_start
movw %ax, %ss
mov $(wakeup_stack-wakeup_code), %sp #
Private stack is needed for ASUS board
movw $0x0e00 + 'S', %fs:(0x12)
pushl $0 # Kill
any dangerous flags
popfl
cli
cld
Fixed now. [Not that it matters.]
Pavel
Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building, cryptography in U.S.A. and free speech in Czech Republic.