public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64
@ 2010-09-28 23:12 Rafael J. Wysocki
  2010-09-28 23:28 ` H. Peter Anvin
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2010-09-28 23:12 UTC (permalink / raw)
  To: Linux-pm mailing list; +Cc: H. Peter Anvin, LKML, Nigel Cunningham

From: Rafael J. Wysocki <rjw@sisk.pl>

On x86_64 the configuration and version of the kernel that
hibernates and creates a system image may be different from the
configuration and version of the boot kernel that loads the image.
So long as both these kernels are built with the same value of
RESTORE_MAGIC, the image created by one of them should be
successfully loaded and restored by the other one.

It wasn't necessary to modify RESTORE_MAGIC in the past, but now
that we are adding compression to the in-kernel hibernate code,
change the value of RESTORE_MAGIC so that earlier kernels don't
try to load compressed images they can't handle.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================
--- linux-2.6.orig/arch/x86/power/hibernate_64.c
+++ linux-2.6/arch/x86/power/hibernate_64.c
@@ -137,7 +137,7 @@ struct restore_data_record {
 	unsigned long magic;
 };
 
-#define RESTORE_MAGIC	0x0123456789ABCDEFUL
+#define RESTORE_MAGIC	0x0123456789ABCDF0UL
 
 /**
  *	arch_hibernation_header_save - populate the architecture specific part

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64
  2010-09-28 23:12 [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64 Rafael J. Wysocki
@ 2010-09-28 23:28 ` H. Peter Anvin
  2010-09-29 10:58   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: H. Peter Anvin @ 2010-09-28 23:28 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux-pm mailing list, LKML, Nigel Cunningham

On 09/28/2010 04:12 PM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> On x86_64 the configuration and version of the kernel that
> hibernates and creates a system image may be different from the
> configuration and version of the boot kernel that loads the image.
> So long as both these kernels are built with the same value of
> RESTORE_MAGIC, the image created by one of them should be
> successfully loaded and restored by the other one.
> 
> It wasn't necessary to modify RESTORE_MAGIC in the past, but now
> that we are adding compression to the in-kernel hibernate code,
> change the value of RESTORE_MAGIC so that earlier kernels don't
> try to load compressed images they can't handle.
> 
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> ---
>  arch/x86/power/hibernate_64.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux-2.6/arch/x86/power/hibernate_64.c
> ===================================================================
> --- linux-2.6.orig/arch/x86/power/hibernate_64.c
> +++ linux-2.6/arch/x86/power/hibernate_64.c
> @@ -137,7 +137,7 @@ struct restore_data_record {
>  	unsigned long magic;
>  };
>  
> -#define RESTORE_MAGIC	0x0123456789ABCDEFUL
> +#define RESTORE_MAGIC	0x0123456789ABCDF0UL
>  

Two issues with this:

a) shouldn't we only set this when the image is actually compressed?

b) using systematic magics like this is pessimal in terms of collision
avoidance.  It's much better to use a true random number.

Hence, I propose:

: anacreon 95 ; ranpwd -xc 16
0x4ddedd3236f1e6e1

	-hpa

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64
  2010-09-28 23:28 ` H. Peter Anvin
@ 2010-09-29 10:58   ` Rafael J. Wysocki
  2010-09-29 20:05     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2010-09-29 10:58 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Linux-pm mailing list, LKML, Nigel Cunningham

On Wednesday, September 29, 2010, H. Peter Anvin wrote:
> On 09/28/2010 04:12 PM, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> > 
> > On x86_64 the configuration and version of the kernel that
> > hibernates and creates a system image may be different from the
> > configuration and version of the boot kernel that loads the image.
> > So long as both these kernels are built with the same value of
> > RESTORE_MAGIC, the image created by one of them should be
> > successfully loaded and restored by the other one.
> > 
> > It wasn't necessary to modify RESTORE_MAGIC in the past, but now
> > that we are adding compression to the in-kernel hibernate code,
> > change the value of RESTORE_MAGIC so that earlier kernels don't
> > try to load compressed images they can't handle.
> > 
> > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > ---
> >  arch/x86/power/hibernate_64.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > Index: linux-2.6/arch/x86/power/hibernate_64.c
> > ===================================================================
> > --- linux-2.6.orig/arch/x86/power/hibernate_64.c
> > +++ linux-2.6/arch/x86/power/hibernate_64.c
> > @@ -137,7 +137,7 @@ struct restore_data_record {
> >  	unsigned long magic;
> >  };
> >  
> > -#define RESTORE_MAGIC	0x0123456789ABCDEFUL
> > +#define RESTORE_MAGIC	0x0123456789ABCDF0UL
> >  
> 
> Two issues with this:
> 
> a) shouldn't we only set this when the image is actually compressed?

Well, in fact, this is a workaround, because the compression happens in a
different layer.  However, that other layer doesn't have any compatibility
checks (at least on x86-64), other than seeing that the image metadata
don't make sense at one point.

> b) using systematic magics like this is pessimal in terms of collision
> avoidance.  It's much better to use a true random number.
> 
> Hence, I propose:
> 
> : anacreon 95 ; ranpwd -xc 16
> 0x4ddedd3236f1e6e1

Fine with me, although I don't expect it will be necessary to do that in
the future.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64
  2010-09-29 10:58   ` Rafael J. Wysocki
@ 2010-09-29 20:05     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2010-09-29 20:05 UTC (permalink / raw)
  To: H. Peter Anvin; +Cc: Linux-pm mailing list, LKML, Nigel Cunningham

On Wednesday, September 29, 2010, Rafael J. Wysocki wrote:
> On Wednesday, September 29, 2010, H. Peter Anvin wrote:
> > On 09/28/2010 04:12 PM, Rafael J. Wysocki wrote:
> > > From: Rafael J. Wysocki <rjw@sisk.pl>
> > > 
> > > On x86_64 the configuration and version of the kernel that
> > > hibernates and creates a system image may be different from the
> > > configuration and version of the boot kernel that loads the image.
> > > So long as both these kernels are built with the same value of
> > > RESTORE_MAGIC, the image created by one of them should be
> > > successfully loaded and restored by the other one.
> > > 
> > > It wasn't necessary to modify RESTORE_MAGIC in the past, but now
> > > that we are adding compression to the in-kernel hibernate code,
> > > change the value of RESTORE_MAGIC so that earlier kernels don't
> > > try to load compressed images they can't handle.
> > > 
> > > Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> > > ---
> > >  arch/x86/power/hibernate_64.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > Index: linux-2.6/arch/x86/power/hibernate_64.c
> > > ===================================================================
> > > --- linux-2.6.orig/arch/x86/power/hibernate_64.c
> > > +++ linux-2.6/arch/x86/power/hibernate_64.c
> > > @@ -137,7 +137,7 @@ struct restore_data_record {
> > >  	unsigned long magic;
> > >  };
> > >  
> > > -#define RESTORE_MAGIC	0x0123456789ABCDEFUL
> > > +#define RESTORE_MAGIC	0x0123456789ABCDF0UL
> > >  
> > 
> > Two issues with this:
> > 
> > a) shouldn't we only set this when the image is actually compressed?
> 
> Well, in fact, this is a workaround, because the compression happens in a
> different layer.  However, that other layer doesn't have any compatibility
> checks (at least on x86-64), other than seeing that the image metadata
> don't make sense at one point.

Sorry, I was wrong.  This patch shouldn't be necessary, I'll send another one
that only touches things in kernel/power.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-29 20:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-28 23:12 [RFC][PATCH] PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64 Rafael J. Wysocki
2010-09-28 23:28 ` H. Peter Anvin
2010-09-29 10:58   ` Rafael J. Wysocki
2010-09-29 20:05     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox