swsusp: fix swsusp with intel-agp
Hi!
swsusp contained rather nasty bug where it killed machine when intel-agp or anything else split kernel 4MB mapping. Herbert Xu diagnosed this. Fixed by switching to "known good" mapping for during suspend/resume.
Please apply,
Pavel
arch/i386/mm/init.c renamed from linux/arch/i386/mm/init.c +7 -0
@@ -331,6 +331,13 @@void zap_low_mappings (void ) {int i; + +#ifdef CONFIG_SOFTWARE_SUSPEND + { +extern char swsusp_pg_dir[PAGE_SIZE ]; +memcpy (swsusp_pg_dir, swapper_pg_dir,PAGE_SIZE ); + } +#endif /* * Zap initial low-memory mappings. *
arch/i386/power/cpu.c renamed from linux/arch/i386/power/cpu.c +4 -0
@@ -35,6 +35,10 @@unsigned long saved_context_esi, saved_context_edi;unsigned long saved_context_eflags; +/* Special page directory for resume */ +char __nosavedata swsusp_pg_dir[PAGE_SIZE] + __attribute__ ((aligned (PAGE_SIZE))); +extern void enable_sep_cpu (void *);void save_processor_state (void )
arch/i386/power/swsusp.S renamed from linux/arch/i386/power/swsusp.S +1 -3
@@ -36,7 +38,7 @@ jmp .L1449 .p2align 4,,7 .L1450: - movl $swapper_pg_dir-__PAGE_OFFSET,%ecx + movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 call do_magic_resume_1
@@ -56,8 +58,6 @@ movl (%ecx,%eax),%eax movb (%edx,%eax),%al movb %al,(%edx,%ebx) - movl %cr3, %eax; - movl %eax, %cr3; # flush TLB movl loop2,%eax leal 1(%eax),%edx
include/asm-i386/suspend.h renamed from linux/include/asm-i386/suspend.h +3 -0
@@ -9,6 +9,9 @@static inline int arch_prepare_suspend (void ) { +/* If you want to make non-PSE machine work, turn off paging +in do_magic. swsusp_pg_dir should have identity mapping, so +it could work... */ if (!cpu_has_pse)return -EPERM ;return 0 ;
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 9 lines · Pavel Machek
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void) { int i; + +#ifdef CONFIG_SOFTWARE_SUSPEND
Can you please define this for CONFIG_PM_DISK as well? Alternatively, you can do the same as you did in cpu.c and define this for CONFIG_PM.
*
arch/i386/power/cpu.c 2004-05-20 23:10:50.000000000 +0200 line 42
Quoted 11 lines
arch/i386/power/cpu.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/power/cpu.c 2004-05-20 23:08:05.000000000 +0200 +4
-0@@ -35,6 +35,10 @@ unsigned long saved_context_esi, saved_context_edi; unsigned long saved_context_eflags; +/* Special page directory for resume */ +char __nosavedata swsusp_pg_dir[PAGE_SIZE] + __attribute__ ((aligned (PAGE_SIZE))); + extern void enable_sep_cpu(void *);
Thanks,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHi!
Quoted 4 lines
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +0
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void)
Quoted 8 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0{ int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
That would need few more parts to actually do something usefull on pmdisk, right? Lowlevel code needs to know how to switch.
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 14 lines · Pavel Machek
Quoted 13 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 9 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void) { int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
Quoted 2 lines
That would need few more parts to actually do something usefull on pmdisk, right? Lowlevel code needs to know how to switch.
Well once you do this then pmdisk.S can be easily patched to do the same thing as swsusp.S :)
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtQuoted 14 lines · herbert
Quoted 13 lines · Pavel Machek
Quoted 13 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 9 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void) { int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
Would you object to a patch that converted current uses of CONFIG_SOFTWARE_SUSPEND/CONFIG_PM to a new symbol that is turned on iff one of CONFIG_SOFTWARE_SUSPEND/CONFIG_PM_DISK is enabled?
Perhaps we can call it CONFIG_PM_DISK_COMMON?
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHi!
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +0
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void)Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0{ int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
Quoted 4 lines
Would you object to a patch that converted current uses of CONFIG_SOFTWARE_SUSPEND/CONFIG_PM to a new symbol that is turned on iff one of CONFIG_SOFTWARE_SUSPEND/CONFIG_PM_DISK is enabled?
I guess that open-coding #if defined() || defined() is right thing to do for now.
Suspend2 when/if merged might not need this... This one is not really specific to suspend-to-disk. It is specific to swsusp way of doing things, which happens to be same as pmdisk way of doing it...
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 7 lines · Pavel Machek
I guess that open-coding #if
defined()||defined()is right thing to do for now.Suspend2 when/if merged might not need this... This one is not really specific to suspend-to-disk. It is specific to swsusp way of doing things, which happens to be same as pmdisk way of doing it...
Well that symbol would not apply to just this case. We can also use it for arch/i386/power/cpu.c itself. It appears to be used solely for the purpose of suspending to disk.
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHi!
Quoted 10 lines
Quoted 6 lines
I guess that open-coding #if
defined()||defined()is right thing to do for now.Suspend2 when/if merged might not need this... This one is not really specific to suspend-to-disk. It is specific to swsusp way of doing things, which happens to be same as pmdisk way of doing it...
Well that symbol would not apply to just this case. We can also use it for
arch/i386/power/cpu.citself. It appears to be used solely for the purpose of suspending to disk.
Well, all those symbols might get pretty confusing, but I guess we can live with that.
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Hi.
Quoted 1 line · Pavel Machek
Suspend2 when/if merged might not need this... This one is not really
I use it too :>
Nigel
Signature · 7 lines
Nigel & Michelle Cunningham C/- Westminster Presbyterian Church Belconnen 61 Templeton Street, Cook, ACT 2614. +61 (2) 6251 7727(wk); +61 (2) 6254 0216 (home) Evolution (n): A hypothetical process whereby infinitely improbable events occur with alarming frequency, order arises from chaos, and no one is given credit.
Hi!
Quoted 3 lines
Quoted 1 line
Suspend2 when/if merged might not need this... This one is not really
I use it too :>
Aha, okay then. How should the option be called, then?
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 6 lines · Pavel Machek
Quoted 4 lines
Quoted 2 lines
Suspend2 when/if merged might not need this... This one is not really
I use it too :>
Aha, okay then. How should the option be called, then?
I like PM_DISK but that's taken already. Perhaps PM_DISK_COMMON?
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHi.
Quoted 1 line · Pavel Machek
Aha, okay then. How should the option be called, then?
Since we're all using it, is there a problem with just using CONFIG_PM?
Nigel
Signature · 7 lines
Nigel & Michelle Cunningham C/- Westminster Presbyterian Church Belconnen 61 Templeton Street, Cook, ACT 2614. +61 (2) 6251 7727(wk); +61 (2) 6254 0216 (home) Evolution (n): A hypothetical process whereby infinitely improbable events occur with alarming frequency, order arises from chaos, and no one is given credit.
Quoted 5 lines · Nigel Cunningham
Quoted 1 line · Pavel Machek
Aha, okay then. How should the option be called, then?
Since we're all using it, is there a problem with just using
CONFIG_PM?
Well it is possible to use CONFIG_PM without doing suspend-to-disk, but I guess no one will notice if we just slipped it in :)
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtswsusp vs. pmdisk [was Re: swsusp: fix swsusp with intel-agp]
In reply to Pavel MachekHi!
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +0
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void)Quoted 8 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 4 lines
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0{ int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
Quoted 2 lines
That would need few more parts to actually do something usefull on pmdisk, right? Lowlevel code needs to know how to switch.
What about killing pmdisk code, instead?
Its old, its not maintained any more, and it is unneccessary duplicity of swsusp code.
Patrick, in middle of april you claimed you'll have something "by the end of month". Can you either start looking after your code or give up and let me remove it?
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Re: swsusp vs. pmdisk [was Re: swsusp: fix swsusp with intel-agp]
Quoted 9 lines · Pavel Machek
What about killing pmdisk code, instead?
Its old, its not maintained any more, and it is unneccessary duplicity of swsusp code.
Patrick, in middle of april you claimed you'll have something "by the end of month". Can you either start looking after your code or give up and let me remove it?
Well if Patrick doesn't have the time to do it, I'd like to maintain pmdisk. It might be a bit out-of-date, by with a bit of work, it can easily catch up again since the underlying structure is quite nice.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtRe: swsusp vs. pmdisk [was Re: swsusp: fix swsusp with intel-agp]
Hi!
Quoted 5 lines
Quoted 5 lines
What about killing pmdisk code, instead?
Its old, its not maintained any more, and it is unneccessary duplicity of swsusp code.
Quoted 7 lines
Quoted 3 lines
Patrick, in middle of april you claimed you'll have something "by the end of month". Can you either start looking after your code or give up and let me remove it?
Well if Patrick doesn't have the time to do it, I'd like to maintain pmdisk. It might be a bit out-of-date, by with a bit of work, it can easily catch up again since the underlying structure is quite nice.
What if you instead forward-ported same cleanups to swsusp? If done in reasonably-sized chunks, it would be very welcome.
Of course, having maintained pmdisk in kernel is *way* better than having umaintained pmdisk in kernel. So feel free to add yourself an entry in MAINTAINERS file...
Alternatively if you bring pmdisk up-to-date (and maintain it), I might as well kill swsusp. But I like the name (SWap SUSPend) slightly better than pmdisk... :-).
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 14 lines · Herbert Xu
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 line 335
Quoted 9 lines · Pavel Machek
arch/i386/mm/init.c 2004-05-20 23:10:50.000000000 +0200 renamed from linux/arch/i386/mm/init.c 2004-05-20 23:08:05.000000000 +0200 +2
-0@@ -331,6 +331,13 @@ void zap_low_mappings (void) { int i; + +#ifdef CONFIG_SOFTWARE_SUSPENDCan you please define this for
CONFIG_PM_DISKas well? Alternatively, you can do the same as you did incpu.cand define this forCONFIG_PM.
Pleeeeeze don't remove me from Cc when replying to emails. Thanks.
arch/i386/mm/init.c line 340
Quoted 7 lines · Pavel Machek
arch/i386/mm/init.c renamed from linux/arch/i386/mm/init.c +6
-0+#ifdef CONFIG_SOFTWARE_SUSPEND + { +extern char swsusp_pg_dir[PAGE_SIZE ]; +memcpy (swsusp_pg_dir, swapper_pg_dir,PAGE_SIZE ); + } +#endif
Please move the declaration of swsusp_pg_dir[] to a header file where it is visible to both the users and the definition site, then resend. Thanks.
Hi!
Quoted 10 lines
Review
Quoted 7 lines
(quoted diff) +6
-0+#ifdef CONFIG_SOFTWARE_SUSPEND + { + extern char swsusp_pg_dir[PAGE_SIZE]; + memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE); + } +#endifPlease move the declaration of swsusp_pg_dir[] to a header file where it is visible to both the users and the definition site, then resend.
Hmm, on second thought, it is accessed from one C file and once from assembly => prototype should not be needed.
Upon popular request I made it depend on CONFIG_PM (pmdisk will need it, too, and suspend2 wants it also). If you don't like that please simply replace CONFIG_PM with CONFIG_SOFTWARE_SUSPEND...
Pavel
arch/i386/power/swsusp.S +1 -1
@@ -36,7 +38,7 @@ jmp .L1449 .p2align 4,,7 .L1450: - movl $swapper_pg_dir-__PAGE_OFFSET,%ecx + movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 call do_magic_resume_1
arch/i386/mm/init.c +11 -0
@@ -328,9 +328,20 @@#endif } +#ifdef CONFIG_PM +/* Swap suspend & friends need this for resume */ +char __nosavedata swsusp_pg_dir[PAGE_SIZE] + __attribute__ ((aligned (PAGE_SIZE))); +#endif +void zap_low_mappings (void ) {int i; + +#ifdef CONFIG_PM +memcpy (swsusp_pg_dir, swapper_pg_dir,PAGE_SIZE ); +#endif +/* * Zap initial low-memory mappings. *
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 12 lines · Pavel Machek
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +6
-0+#ifdef CONFIG_SOFTWARE_SUSPEND + { + extern char swsusp_pg_dir[PAGE_SIZE]; + memcpy(swsusp_pg_dir, swapper_pg_dir, PAGE_SIZE); + } +#endifPlease move the declaration of swsusp_pg_dir[] to a header file where it is visible to both the users and the definition site, then resend.
Quoted 6 lines
Hmm, on second thought, it is accessed from one C file and once from assembly => prototype should not be needed.
Upon popular request I made it depend on
CONFIG_PM(pmdisk will need it, too, and suspend2 wants it also). If you don't like that please simply replaceCONFIG_PMwithCONFIG_SOFTWARE_SUSPEND...
Mabe it's a sign of advancing years, but I still think that 4k is worth saving ;) I ended up with the below.
You say that pmdisk needs this. I assume that means that we should also replace swapper_pg_dir with swsusp_pg_dir in pmdisk.S?
From: Pavel Machek <[email protected]>
swsusp contained rather nasty bug where it killed machine when intel-agp or anything else split kernel 4MB mapping. Herbert Xu diagnosed this. Fixed by switching to "known good" mapping for during suspend/resume.
---
25-akpm/arch/i386/mm/init.c | 21 +++++++++++++++++++++ 25-akpm/arch/i386/power/swsusp.S | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-)
arch/i386/mm/init.c renamed from arch/i386/mm/init.c~swsusp-fix-swsusp-with-intel-agp +21 -0
@@ -327,9 +327,30 @@ static void __init pagetable_init (void)#endif } +#if defined(CONFIG_PM_DISK ) || defined(CONFIG_SOFTWARE_SUSPEND ) +/* +* Swap suspend & friends need this for resume because things like the intel-agp +* driver might have split up a kernel 4MB mapping. +*/ +char __nosavedata swsusp_pg_dir[PAGE_SIZE] + __attribute__ ((aligned (PAGE_SIZE))); + +static inline void save_pg_dir (void ) +{ +memcpy (swsusp_pg_dir, swapper_pg_dir,PAGE_SIZE ); +} +#else +static inline void save_pg_dir (void ) +{ +} +#endif +void zap_low_mappings (void ) {int i; + +save_pg_dir (); +/* * Zap initial low-memory mappings. *
arch/i386/power/swsusp.S renamed from arch/i386/power/swsusp.S~swsusp-fix-swsusp-with-intel-agp +1 -1
@@ -36,7 +36,7 @@ ENTRY(do_magic) jmp .L1449 .p2align 4,,7 .L1450: - movl $swapper_pg_dir-__PAGE_OFFSET,%ecx + movl $swsusp_pg_dir-__PAGE_OFFSET,%ecx movl %ecx,%cr3 call do_magic_resume_1
_
Hi!
Quoted 14 lines
Quoted 14 lines
Quoted 10 lines
arch/i386/mm/init.c static void __init pagetable_init (void) · line 346
Quoted 7 lines
arch/i386/mm/init.c renamed from arch/i386/mm/init.c~swsusp-fix-swsusp-with-intel-agp +6
-0+#ifdef CONFIG_SOFTWARE_SUSPEND + { +extern char swsusp_pg_dir[PAGE_SIZE ]; +memcpy (swsusp_pg_dir, swapper_pg_dir,PAGE_SIZE ); + } +#endif Please move the declaration of swsusp_pg_dir[] to a header file where it is visible to both the users and the definition site, then resend.
Hmm, on second thought, it is accessed from one C file and once from assembly => prototype should not be needed.
Quoted 6 lines
Quoted 3 lines
Upon popular request I made it depend on
CONFIG_PM(pmdisk will need it, too, and suspend2 wants it also). If you don't like that please simply replaceCONFIG_PMwithCONFIG_SOFTWARE_SUSPEND...Mabe it's a sign of advancing years, but I still think that 4k is worth saving ;) I ended up with the below.
Ok, thanks ;-).
Quoted 2 lines
You say that pmdisk needs this. I assume that means that we should also replace
swapper_pg_dirwithswsusp_pg_dirinpmdisk.S?
Yes, that should do the trick.
Pavel
Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
Quoted 1 line · Andrew Morton
+#if
defined(CONFIG_PM_DISK)||defined(CONFIG_SOFTWARE_SUSPEND)
Okay. So I'll just patch it to add || defined(CONFIG_SOFTWARE_SUSPEND2) for now :>
Nigel
Signature · 7 lines
Nigel & Michelle Cunningham C/- Westminster Presbyterian Church Belconnen 61 Templeton Street, Cook, ACT 2614. +61 (2) 6251 7727(wk); +61 (2) 6254 0216 (home) Evolution (n): A hypothetical process whereby infinitely improbable events occur with alarming frequency, order arises from chaos, and no one is given credit.