Skip to contentSkip to conversation

PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64

RFC PATCH In review Rafael J. Wysocki 2 participants 6 messages Sep 28, 2010 – Sep 29, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 PM / Hibernate / x86: Change RESTORE_MAGIC on x86_64

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/power/hibernate_64.c +1 -1
Index: 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
#1 lore raw
Quoted 24 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================

arch/x86/power/hibernate_64.c struct restore_data_record { · line 141

Quoted 6 lines
arch/x86/power/hibernate_64.c +1 -1
@@ -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

#2 lore raw
Quoted 28 lines · H. Peter Anvin
Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================

arch/x86/power/hibernate_64.c +0 -0
@@ -137,7 +137,7 @@ struct restore_data_record {
 	unsigned long magic;
 };
 
Quoted 7 lines

arch/x86/power/hibernate_64.c struct restore_data_record { · line 141

Quoted 3 lines
arch/x86/power/hibernate_64.c +1 -1
-#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.

Quoted 7 lines

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

#3 lore raw
In reply to H. Peter Anvin
Quoted 28 lines · H. Peter Anvin
Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================

arch/x86/power/hibernate_64.c +0 -0
@@ -137,7 +137,7 @@ struct restore_data_record {
 	unsigned long magic;
 };
 
Quoted 7 lines

arch/x86/power/hibernate_64.c struct restore_data_record { · line 141

Quoted 3 lines
arch/x86/power/hibernate_64.c +1 -1
-#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.

Quoted 7 lines

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

#4 lore raw
Quoted 35 lines · Rafael J. Wysocki
Quoted 34 lines · H. Peter Anvin
Quoted 24 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================

arch/x86/power/hibernate_64.c struct restore_data_record { · line 141

Quoted 6 lines
arch/x86/power/hibernate_64.c +1 -1
@@ -137,7 +137,7 @@ struct restore_data_record {
 	unsigned long magic;
 };
 
-#define RESTORE_MAGIC	0x0123456789ABCDEFUL
+#define RESTORE_MAGIC	0x0123456789ABCDF0UL
 

Two issues with this:

Quoted 6 lines
Quoted 1 line

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

#5 lore raw
In reply to Rafael J. Wysocki
Quoted 35 lines · Rafael J. Wysocki
Quoted 34 lines · H. Peter Anvin
Quoted 24 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

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.

---
 arch/x86/power/hibernate_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/power/hibernate_64.c
===================================================================

arch/x86/power/hibernate_64.c struct restore_data_record { · line 141

Quoted 6 lines
arch/x86/power/hibernate_64.c +1 -1
@@ -137,7 +137,7 @@ struct restore_data_record {
 	unsigned long magic;
 };
 
-#define RESTORE_MAGIC	0x0123456789ABCDEFUL
+#define RESTORE_MAGIC	0x0123456789ABCDF0UL
 

Two issues with this:

Quoted 6 lines
Quoted 1 line

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