swap image signature check upon resume
Hi Pavel,
hi Rafael,
after a quick search i couldn't find anything dealing with the topic in the subject line so here we go:
One sometimes can mix up (and by one i mean me) the
kernel images one boots after having suspended the machine previously. There can be at least two reasons for that:
1. too many kernels in grub and having forgotten with which i suspended.
2. compile and install a new kernel and forget about it, suspend in the evening and then boot with the new kernel;
in both cases you end up staring at fsck since they filesystems haven't been unmounted, of course. Or at least see the warning message of some journal recovery whisk away.
In order to alleviate that, one could probably go, imho, and write in the swsusp_header the kernel version which suspended the machine (UTS_RELEASE) alongside SWSUSP_SIG and check that against the kernel version of the image just booting. If they match then all is well, if not, one could
a) issue a BIG FAT WARNING and reboot telling the user to select the proper image
b) ask the user what to do:
- proceed as if "noresume" has been entered on the kernel command line
- reboot after issuing the kernel version which suspended the machine -
c)...
In case you guys think something like that might be of use i can come up with a patch in the next coupla days...
Signature · 2 lines
Regards/Gruß,
Boris.Quoted 30 lines · Borislav Petkov
Hi Pavel,
hi Rafael,after a quick search i couldn't find anything dealing with the topic in the subject line so here we go:
One sometimes can mix up (and by one i mean me) the
kernel images one boots after having suspended the machine previously. There can be at least two reasons for that:1. too many kernels in grub and having forgotten with which i suspended.
2. compile and install a new kernel and forget about it, suspend in the evening and then boot with the new kernel;in both cases you end up staring at fsck since they filesystems haven't been unmounted, of course. Or at least see the warning message of some journal recovery whisk away.
In order to alleviate that, one could probably go, imho, and write in the
swsusp_headerthe kernel version which suspended the machine (UTS_RELEASE) alongsideSWSUSP_SIGand check that against the kernel version of the image just booting. If they match then all is well, if not, one coulda) issue a BIG FAT WARNING and reboot telling the user to select the proper image
b) ask the user what to do:
- proceed as if "noresume" has been entered on the kernel command line
- reboot after issuing the kernel version which suspended the machine -
c)...
Quoted 2 lines
In case you guys think something like that might be of use i can come up with a patch in the next coupla days...
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
Greetings,
Rafael
Quoted 34 lines · Rafael J. Wysocki
Quoted 30 lines · Borislav Petkov
Hi Pavel,
hi Rafael,after a quick search i couldn't find anything dealing with the topic in the subject line so here we go:
One sometimes can mix up (and by one i mean me) the
kernel images one boots after having suspended the machine previously. There can be at least two reasons for that:1. too many kernels in grub and having forgotten with which i suspended.
2. compile and install a new kernel and forget about it, suspend in the evening and then boot with the new kernel;in both cases you end up staring at fsck since they filesystems haven't been unmounted, of course. Or at least see the warning message of some journal recovery whisk away.
In order to alleviate that, one could probably go, imho, and write in the
swsusp_headerthe kernel version which suspended the machine (UTS_RELEASE) alongsideSWSUSP_SIGand check that against the kernel version of the image just booting. If they match then all is well, if not, one coulda) issue a BIG FAT WARNING and reboot telling the user to select the proper image
b) ask the user what to do:
- proceed as if "noresume" has been entered on the kernel command line
- reboot after issuing the kernel version which suspended the machine -
c)...Quoted 2 lines
In case you guys think something like that might be of use i can come up with a patch in the next coupla days...
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is d307c4a8e826c44f9633bd3f7e60d0491e7d885a (Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g. CONFIG_ARCH_HIBERNATION_HEADER etc..) and arch-specific save and restore functions?
Signature · 2 lines
Regards/Gruß,
Boris.Quoted 40 lines · Borislav Petkov
Quoted 39 lines · Rafael J. Wysocki
Quoted 30 lines · Borislav Petkov
Hi Pavel,
hi Rafael,after a quick search i couldn't find anything dealing with the topic in the subject line so here we go:
One sometimes can mix up (and by one i mean me) the
kernel images one boots after having suspended the machine previously. There can be at least two reasons for that:1. too many kernels in grub and having forgotten with which i suspended.
2. compile and install a new kernel and forget about it, suspend in the evening and then boot with the new kernel;in both cases you end up staring at fsck since they filesystems haven't been unmounted, of course. Or at least see the warning message of some journal recovery whisk away.
In order to alleviate that, one could probably go, imho, and write in the
swsusp_headerthe kernel version which suspended the machine (UTS_RELEASE) alongsideSWSUSP_SIGand check that against the kernel version of the image just booting. If they match then all is well, if not, one coulda) issue a BIG FAT WARNING and reboot telling the user to select the proper image
b) ask the user what to do:
- proceed as if "noresume" has been entered on the kernel command line
- reboot after issuing the kernel version which suspended the machine -
c)...Quoted 2 lines
In case you guys think something like that might be of use i can come up with a patch in the next coupla days...
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
Quoted 6 lines
Quoted 1 line
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?
No, this code is fully functional. :-)
The arch save and restore functions are in arch/x86/kernel/suspend_64.c .
As I said, i386 is not yet supported.
Greetings,
Rafael
On Fri, Dec 07, 2007 at 09:19:09PM +0100, Rafael J. Wysocki wrote:
...
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?
Quoted 5 lines
No, this code is fully functional. :-)
The arch save and restore functions are in
arch/x86/kernel/suspend_64.c.As I said, i386 is not yet supported.
nice, holler if you need a tester when you have some prototypes ready. By the way, what do you do when the suspend image header mismatches and it is unsafe to continue booting? Also, there's a freakishly long comment in suspend_64.c, might wanna shorten it:
arch/x86/kernel/suspend_64.c +6 -2
@@ -118,7 +118,12 @@ void fix_processor_context(void)int cpu =smp_processor_id ();struct tss_struct *t = &per_cpu (init_tss, cpu); -set_tss_desc (cpu,t);/* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */ +/* +* This just modifies memory; should not be necessary. But... This +* is necessary, because 386 hardware has concept of busy TSS or some +* similar stupidity. +*/ +set_tss_desc (cpu,t);cpu_gdt (cpu)[GDT_ENTRY_TSS ].type =9 ;
@@ -138,7 +143,6 @@ void fix_processor_context(void)loaddebug (¤t->thread,6 );loaddebug (¤t->thread,7 ); } - }#ifdef CONFIG_HIBERNATION
Signature · 2 lines
Regards/Gruß,
Boris.Quoted 16 lines · Borislav Petkov
On Fri, Dec 07, 2007 at 09:19:09PM +0100, Rafael J. Wysocki wrote:
...
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?
Quoted 8 lines
Quoted 5 lines
No, this code is fully functional. :-)
The arch save and restore functions are in
arch/x86/kernel/suspend_64.c.As I said, i386 is not yet supported.
nice, holler if you need a tester when you have some prototypes ready. By the way, what do you do when the suspend image header mismatches and it is unsafe to continue booting?
If the image header doesn't match, we don't load it and return an error code, which usually results in the boot kernel continuing to boot.
Quoted 1 line
Also, there's a freakishly long comment in
suspend_64.c, might wanna shorten it:
Ah, OK.
I'll take your patch for 2.6.25, thanks.
Quoted 29 lines
Signed-off-by Borislav Petkov <[email protected]>arch/x86/kernel/suspend_64.c +6
-2@@ -118,7 +118,12 @@ void fix_processor_context(void)int cpu =smp_processor_id ();struct tss_struct *t = &per_cpu (init_tss, cpu); -set_tss_desc (cpu,t);/* This just modifies memory; should not be necessary. But... This is necessary, because 386 hardware has concept of busy TSS or some similar stupidity. */ +/* +* This just modifies memory; should not be necessary. But... This +* is necessary, because 386 hardware has concept of busy TSS or some +* similar stupidity. +*/ +set_tss_desc (cpu,t);cpu_gdt (cpu)[GDT_ENTRY_TSS ].type =9 ;@@ -138,7 +143,6 @@ void fix_processor_context(void)loaddebug (¤t->thread,6 );loaddebug (¤t->thread,7 ); } - }#ifdef CONFIG_HIBERNATION
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Borislav Petkov
On Fri, Dec 07, 2007 at 09:19:09PM +0100, Rafael J. Wysocki wrote:
...
Quoted 16 lines
Quoted 11 lines
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?No, this code is fully functional. :-)
The arch save and restore functions are in
arch/x86/kernel/suspend_64.c.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
As I said, i386 is not yet supported.
nice, holler if you need a tester when you have some prototypes ready. By the way, what do you do when the suspend image header mismatches and it is unsafe to continue booting?
If the image header doesn't match, we don't load it and return an error code, which usually results in the boot kernel continuing to boot.
But if you continue to boot the filesystems were still mounted and fsck has to go over them and check for errors. In the case of ext2 this takes relatively long depending on the size of the partition. However, this is only the smaller problem, the problem of data loss is what worries me.
Instead, I'd rather issue a warning that the swsusp header mismatches, say with which kernel the machine got suspended with and then start the countdown for reboot. Thoughts?
Signature · 2 lines
Regards/Gruß,
Boris.Quoted 27 lines · Borislav Petkov
Quoted 26 lines · Rafael J. Wysocki
Quoted 24 lines · Borislav Petkov
On Fri, Dec 07, 2007 at 09:19:09PM +0100, Rafael J. Wysocki wrote:
...
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?Quoted 5 lines
No, this code is fully functional. :-)
The arch save and restore functions are in
arch/x86/kernel/suspend_64.c.As I said, i386 is not yet supported.
nice, holler if you need a tester when you have some prototypes ready. By the way, what do you do when the suspend image header mismatches and it is unsafe to continue booting?
Quoted 7 lines
Quoted 2 lines
If the image header doesn't match, we don't load it and return an error code, which usually results in the boot kernel continuing to boot.
But if you continue to boot the filesystems were still mounted and fsck has to go over them and check for errors. In the case of ext2 this takes relatively long depending on the size of the partition. However, this is only the smaller problem, the problem of data loss is what worries me.
The filesystems are synced before the hibernation, so there shouldn't be data any loss.
Quoted 2 lines
Instead, I'd rather issue a warning that the swsusp header mismatches, say with which kernel the machine got suspended with and then start the countdown for reboot.
What exactly would that change? You need to reboot anyway and fsck will run on the filesystems regardless of which kernel you boot with.
Rafael
Quoted 31 lines · Rafael J. Wysocki
Quoted 30 lines · Borislav Petkov
Quoted 28 lines · Rafael J. Wysocki
Quoted 16 lines · Borislav Petkov
On Fri, Dec 07, 2007 at 09:19:09PM +0100, Rafael J. Wysocki wrote:
...
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines
Well, there's a patchset in the current mainline that allows you to use arbitrary (sufficiently new) kernel to load the image and then restore the image kernel. So, you can hibernate 2.6.24-rc3 and use 2.6.24-rc2 to restore it, for example.
I'm going to do that for i386 too.
right, this is
d307c4a8e826c44f9633bd3f7e60d0491e7d885a(Hibernation: Arbitrary boot kernel support - generic code), i should've seen that. What's the status of those bits, from a quick scan it seems they need some rewiring (Kconfig, e.g.CONFIG_ARCH_HIBERNATION_HEADERetc..) and arch-specific save and restore functions?Quoted 8 lines
Quoted 5 lines
No, this code is fully functional. :-)
The arch save and restore functions are in
arch/x86/kernel/suspend_64.c.As I said, i386 is not yet supported.
nice, holler if you need a tester when you have some prototypes ready. By the way, what do you do when the suspend image header mismatches and it is unsafe to continue booting?
If the image header doesn't match, we don't load it and return an error code, which usually results in the boot kernel continuing to boot.
Quoted 7 lines
Quoted 4 lines
But if you continue to boot the filesystems were still mounted and fsck has to go over them and check for errors. In the case of ext2 this takes relatively long depending on the size of the partition. However, this is only the smaller problem, the problem of data loss is what worries me.
The filesystems are synced before the hibernation, so there shouldn't be data any loss.
s/data any loss/any data loss/ (sorry).
On Sun, Dec 09, 2007 at 03:27:57PM +0100, Rafael J. Wysocki wrote:
...
Quoted 5 lines
Quoted 2 lines
Instead, I'd rather issue a warning that the swsusp header mismatches, say with which kernel the machine got suspended with and then start the countdown for reboot.
What exactly would that change? You need to reboot anyway and fsck will run on the filesystems regardless of which kernel you boot with.
well, you'll have the chance to reboot with the kernel the machine got suspended with and then the swsusp image header _will_ match so no fsck-ing. or am i missing something...
Signature · 2 lines
Regards/Gruß,
Boris.Quoted 6 lines · Borislav Petkov
On Sun, Dec 09, 2007 at 03:27:57PM +0100, Rafael J. Wysocki wrote:
...Quoted 3 lines
Quoted 2 lines
Instead, I'd rather issue a warning that the swsusp header mismatches, say with which kernel the machine got suspended with and then start the countdown for reboot.
Quoted 6 lines
Quoted 2 lines
What exactly would that change? You need to reboot anyway and fsck will run on the filesystems regardless of which kernel you boot with.
well, you'll have the chance to reboot with the kernel the machine got suspended with and then the swsusp image header _will_ match so no fsck-ing. or am i missing something...
Yes, you are. :-)
With the new code (which BTW I'm assuming we are talking about) the images are not matched against the kernel they were created by, but against a hard-coded magic number (defined in suspend_64.c) playing the role of the "header protocol version" and against some system parameters, like the amount of RAM etc. Since all kernels containing the new code use the same magic number, all of them will match or none of them will match.
Of course, we may want to change the magic at some point and in that case there you will have some non-matching kernels. If you're worried about that, use the userland hibernation tools from suspend.sf.net (they handle such situations quite well).
Greetings,
Rafael
Quoted 14 lines · Rafael J. Wysocki
Quoted 6 lines · Borislav Petkov
On Sun, Dec 09, 2007 at 03:27:57PM +0100, Rafael J. Wysocki wrote:
...Quoted 3 lines
Quoted 2 lines
Instead, I'd rather issue a warning that the swsusp header mismatches, say with which kernel the machine got suspended with and then start the countdown for reboot.
Quoted 6 lines
Quoted 2 lines
What exactly would that change? You need to reboot anyway and fsck will run on the filesystems regardless of which kernel you boot with.
well, you'll have the chance to reboot with the kernel the machine got suspended with and then the swsusp image header _will_ match so no fsck-ing. or am i missing something...
Quoted 8 lines
Yes, you are. :-)
With the new code (which BTW I'm assuming we are talking about) the images are not matched against the kernel they were created by, but against a hard-coded magic number (defined in
suspend_64.c) playing the role of the "header protocol version" and against some system parameters, like the amount of RAM etc. Since all kernels containing the new code use the same magic number, all of them will match or none of them will match.
right, i was kinda wondering when actually a swsusp image won't match after looking at check_image_kernel() but missed that arch-specific RESTORE_MAGIC bit. Thanks for clearing that up.
Signature · 2 lines
Regards/Gruß,
Boris.