Make swsusp work on i386 with PAE
Subsystems (2)
RFC PATCH 1/1 Make swsusp work on i386 with PAE
Hi,
The purpose of the appended patch is to make swsusp work on i386 with PAE, but it should also allow i386 systems without PSE to use swsusp.
The patch creates temporary page tables located in resume-safe page frames during the resume and uses them for restoring the suspend image (the same approach is used on x86-64).
It has been tested on an i386 system with PAE and survived several suspend-resume cycles in a row, but I have no systems without PSE, so that requires some testing.
Comments welcome.
Greetings,
Rafael
--- arch/i386/power/Makefile | 2 arch/i386/power/suspend.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++ arch/i386/power/swsusp.S | 9 ++ kernel/power/Kconfig | 2 4 files changed, 162 insertions(+), 4 deletions(-)
arch/i386/power/swsusp.S +7 -2
@@ -28,8 +28,9 @@ ENTRY(swsusp_arch_suspend) call swsusp_save ret -ENTRY(swsusp_arch_resume) - movl $swsusp_pg_dir-__PAGE_OFFSET, %ecx +ENTRY(restore_image) + movl resume_pg_dir, %ecx + subl $__PAGE_OFFSET, %ecx movl %ecx, %cr3 movl restore_pblist, %edx
@@ -51,6 +52,10 @@ copy_loop: .p2align 4,,7 done: + /* go back to the original page tables */ + movl $swapper_pg_dir, %ecx + subl $__PAGE_OFFSET, %ecx + movl %ecx, %cr3 /* Flush TLB, including "global" things (vmalloc) */ movl mmu_cr4_features, %eax movl %eax, %edx
arch/i386/power/suspend.c new file +153 -0
153 lines not on this page · raw message
arch/i386/power/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-$(CONFIG_PM) += cpu.o -obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o +obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
kernel/power/Kconfig +1 -1
@@ -78,7 +78,7 @@ config PM_SYSFS_DEPRECATED config SOFTWARE_SUSPEND bool "Software Suspend" - depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP) && !X86_PAE) || ((FRV || PPC32) && !SMP)) + depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP)) ---help--- Enable the possibility of suspending the machine. It doesn't need ACPI or APM.
Hi!
Quoted 10 lines
The purpose of the appended patch is to make swsusp work on i386 with PAE, but it should also allow i386 systems without PSE to use swsusp.
The patch creates temporary page tables located in resume-safe page frames during the resume and uses them for restoring the suspend image (the same approach is used on x86-64).
It has been tested on an i386 system with PAE and survived several suspend-resume cycles in a row, but I have no systems without PSE, so that requires some testing.
Thanks, looks okay to me. I guess Andi Kleen would be right person to review it in detail?
Lack of assembly modifications is good.
I guess this should be now removed? (include/asm-i386/suspend.h)
arch_prepare_suspend(void)
{
/* If you want to make non-PSE machine work, turn off paging
in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so
it could work... */
if (!cpu_has_pse) {
printk(KERN_ERR "PSE is required for swsusp.\n");
return -EPERM;
}Quoted 4 lines
arch/i386/power/suspend.c new file +4
-0+/* +* Create a middle page table on a resume-safe page and put a pointer to it in +* the given global directory entry. This only returns the gd entry +* in non-PAE compilation mode, since the middle layer is folded.
arch/i386/power/suspend.c line 39
Quoted 10 lines
arch/i386/power/suspend.c new file +10
-0+*/ +static pmd_t *resume_one_md_table_init (pgd_t *pgd) +{ +pud_t *pud; +pmd_t *pmd_table; + +#ifdef CONFIG_X86_PAE + pmd_table = (pmd_t *)get_safe_page (GFP_ATOMIC ); +if (!pmd_table) +return pmd_table;
I'd do plain old return NULL; here.
arch/i386/power/suspend.c line 109
Quoted 7 lines
arch/i386/power/suspend.c new file +7
-0+/* Map with big pages if possible, otherwise create +* normal page tables. +* NOTE: We can mark everything as executable here +*/ +if (cpu_has_pse) { +set_pmd (pmd,pfn_pmd (pfn,PAGE_KERNEL_LARGE_EXEC )); + pfn +=PTRS_PER_PTE ;
Perhaps disabling PSE here can help getting some testing?
Okay, I guess I should really test this one... Seems good enough for -mm to me, but it should preferably stay there for a _long_ time.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi,
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
The purpose of the appended patch is to make swsusp work on i386 with PAE, but it should also allow i386 systems without PSE to use swsusp.
The patch creates temporary page tables located in resume-safe page frames during the resume and uses them for restoring the suspend image (the same approach is used on x86-64).
Quoted 6 lines
Quoted 3 lines
It has been tested on an i386 system with PAE and survived several suspend-resume cycles in a row, but I have no systems without PSE, so that requires some testing.
Thanks, looks okay to me. I guess Andi Kleen would be right person to review it in detail?
Yes, I think so.
Quoted 5 lines
Lack of assembly modifications is good.
I guess this should be now removed? (
include/asm-i386/suspend.h)
arch_prepare_suspend(void)
Quoted 8 lines
{
/* If you want to make non-PSE machine work, turn off paging
in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so
it could work... */
if (!cpu_has_pse) {
printk(KERN_ERR "PSE is required for swsusp.\n");
return -EPERM;
}Yes, it should. I though it went away when the Kconfig was changed ...
Quoted 8 lines
Quoted 8 lines
arch/i386/power/suspend.c new file +8
-0+/* +* Create a middle page table on a resume-safe page and put a pointer to it in +* the given global directory entry. This only returns the gd entry +* in non-PAE compilation mode, since the middle layer is folded. +*/ +static pmd_t *resume_one_md_table_init (pgd_t *pgd) +{ +pud_t *pud;
Quoted 8 lines
arch/i386/power/suspend.c line 39
Quoted 6 lines
arch/i386/power/suspend.c new file +6
-0+pmd_t *pmd_table; + +#ifdef CONFIG_X86_PAE + pmd_table = (pmd_t *)get_safe_page (GFP_ATOMIC ); +if (!pmd_table) +return pmd_table;I'd do plain old return NULL; here.
OK
Quoted 9 lines
arch/i386/power/suspend.c line 109
Quoted 7 lines
arch/i386/power/suspend.c new file +7
-0+/* Map with big pages if possible, otherwise create +* normal page tables. +* NOTE: We can mark everything as executable here +*/ +if (cpu_has_pse) { +set_pmd (pmd,pfn_pmd (pfn,PAGE_KERNEL_LARGE_EXEC )); + pfn +=PTRS_PER_PTE ;Perhaps disabling PSE here can help getting some testing?
Well, I don't really want to make everyone test the !PSE scenario. ;-)
Quoted 2 lines
Okay, I guess I should really test this one... Seems good enough for -mm to me, but it should preferably stay there for a _long_ time.
I think so too.
Greetings,
Rafael
Signature · 2 lines
You never change things by fighting the existing reality. R. Buckminster Fuller
Quoted 9 lines · Pavel Machek
Hi!
Quoted 7 lines
The purpose of the appended patch is to make swsusp work on i386 with PAE, but it should also allow i386 systems without PSE to use swsusp.
The patch creates temporary page tables located in resume-safe page frames during the resume and uses them for restoring the suspend image (the same approach is used on x86-64).
Quoted 6 lines
Quoted 3 lines
It has been tested on an i386 system with PAE and survived several suspend-resume cycles in a row, but I have no systems without PSE, so that requires some testing.
Thanks, looks okay to me. I guess Andi Kleen would be right person to review it in detail?
I gave it a quick skim, and saw nothing obviously broken fwiw. Thanks for doing this work, it's definitly something that's needed.
Dave
Signature · 1 line
http://www.codemonkey.org.uk
Hi!
Quoted 7 lines
The purpose of the appended patch is to make swsusp work on i386 with PAE, but it should also allow i386 systems without PSE to use swsusp.
The patch creates temporary page tables located in resume-safe page frames during the resume and uses them for restoring the suspend image (the same approach is used on x86-64).
Quoted 5 lines
It has been tested on an i386 system with PAE and survived several suspend-resume cycles in a row, but I have no systems without PSE, so that requires some testing.
Comments welcome.
Just a short update. I actualy tried it, and it seems to work
ok. Thanks!
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html