Skip to contentSkip to conversation

PM / Hibernate: Modify signature used to mark swap

RFC PATCH In review Rafael J. Wysocki 3 participants 9 messages Sep 29, 2010 – Oct 4, 2010

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

RFC PATCH 1/1 PM / Hibernate: Modify signature used to mark swap

From: Rafael J. Wysocki <[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
 kernel/power/swap.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/power/swap.c +3 -3
Index: linux-2.6/kernel/power/swap.c
===================================================================
@@ -29,7 +29,7 @@
 
 #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
 /*
  *	The swap map is a data structure used for keeping track of each page
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
 	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
 	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
 		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);
 		swsusp_header->image = handle->first_sector;
 		swsusp_header->flags = flags;
 		error = hib_bio_write_page(swsusp_resume_block,
@@ -916,7 +916,7 @@ int swsusp_check(void)
 		if (error)
 			goto put;
 
-		if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
+		if (!memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)) {
 			memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
 			/* Reset swap signature now */
 			error = hib_bio_write_page(swsusp_resume_block,
#1 lore raw

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
  kernel/power/swap.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
  #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
  /*
   *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
  	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
  	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
  		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

kernel/power/swap.c int swsusp_check(void) · line 919

Quoted 9 lines
kernel/power/swap.c +1 -1
  		swsusp_header->image = handle->first_sector;
  		swsusp_header->flags = flags;
  		error = hib_bio_write_page(swsusp_resume_block,
@@ -916,7 +916,7 @@ int swsusp_check(void)
  		if (error)
  			goto put;
 
-		if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
+		if (!memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)) {

Reset the signature in either case?

kernel/power/swap.c int swsusp_check(void) · line 922

Quoted 4 lines
kernel/power/swap.c +0 -0
  			memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
  			/* Reset swap signature now */
  			error = hib_bio_write_page(swsusp_resume_block,

Regards,

Nigel

#2 lore raw
In reply to Rafael J. Wysocki

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
  kernel/power/swap.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
  #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
  /*
   *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
  	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
  	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
  		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

kernel/power/swap.c int swsusp_check(void) · line 919

Quoted 9 lines
kernel/power/swap.c +1 -1
  		swsusp_header->image = handle->first_sector;
  		swsusp_header->flags = flags;
  		error = hib_bio_write_page(swsusp_resume_block,
@@ -916,7 +916,7 @@ int swsusp_check(void)
  		if (error)
  			goto put;
 
-		if (!memcmp(SWSUSP_SIG, swsusp_header->sig, 10)) {
+		if (!memcmp(HIBERNATE_SIG, swsusp_header->sig, 10)) {

Reset the signature in either case?

kernel/power/swap.c int swsusp_check(void) · line 922

Quoted 4 lines
kernel/power/swap.c +0 -0
  			memcpy(swsusp_header->sig, swsusp_header->orig_sig, 10);
  			/* Reset swap signature now */
  			error = hib_bio_write_page(swsusp_resume_block,

Regards,

Nigel

#3 lore raw
Quoted 36 lines · Nigel Cunningham

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
  kernel/power/swap.c |    6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
  #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
  /*
   *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
  	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
  	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
  		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

Quoted 7 lines

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

Thanks,
Rafael

#4 lore raw

Hi.

Quoted 41 lines · Rafael J. Wysocki
Quoted 40 lines · Nigel Cunningham

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
   kernel/power/swap.c |    6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
   #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
   /*
    *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
   	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
   	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
   		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

Quoted 8 lines
Quoted 3 lines

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

Okay. I'm just a little weary because if everything I want to get in gets in, we're going to then be changing this signature multiple times. I want to eventually reach a situation where we have a 'proper' header section to the image that stores (among other things) whether compression is enabled and which cryptoapi algorithm is used, allowing a person to en/disable compression at runtime without recompiling or rebooting. I suppose if I seek to put that stuff in earlier rather than later, that will simplify things.

Oh, while I'm writing to you: let's not worry about getting my patches in for 2.6.37. I won't be working on them much today, and want to put the time into making sure they're right before they get merged. As you said - let's seek to get things right first time.

Regards,

Nigel

#5 lore raw
Quoted 48 lines · Nigel Cunningham

Hi.

Quoted 45 lines · Rafael J. Wysocki
Quoted 43 lines · Nigel Cunningham

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
   kernel/power/swap.c |    6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
   #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
   /*
    *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
   	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
   	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
   		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

Quoted 7 lines
Quoted 4 lines

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

Okay. I'm just a little weary because if everything I want to get in gets in, we're going to then be changing this signature multiple times.

That most likely is correct.

Quoted 6 lines

I want to eventually reach a situation where we have a 'proper' header section to the image that stores (among other things) whether compression is enabled and which cryptoapi algorithm is used, allowing a person to en/disable compression at runtime without recompiling or rebooting. I suppose if I seek to put that stuff in earlier rather than later, that will simplify things.

I don't have a problem with changing the signature. If the image format changes, it's probably the best we can do.

Quoted 4 lines

Oh, while I'm writing to you: let's not worry about getting my patches in for 2.6.37. I won't be working on them much today, and want to put the time into making sure they're right before they get merged. As you said - let's seek to get things right first time.

OK

Thanks,
Rafael

#6 lore raw
In reply to Nigel Cunningham
Quoted 48 lines · Nigel Cunningham

Hi.

Quoted 45 lines · Rafael J. Wysocki
Quoted 43 lines · Nigel Cunningham

Hi.

Quoted 27 lines · Rafael J. Wysocki

From: Rafael J. Wysocki<[email protected]>
Subject: PM / Hibernate: Modify signature used to mark swap

Since we are adding compression to the kernel's hibernate code, change signature used by it to mark swap spaces, so that earlier kernels don't attempt to restore compressed images they cannot handle.

---
   kernel/power/swap.c |    6 +++---
   1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
   #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
   /*
    *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
   	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
   	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
   		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

Quoted 7 lines
Quoted 4 lines

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

Okay. I'm just a little weary because if everything I want to get in gets in, we're going to then be changing this signature multiple times.

That most likely is correct.

Quoted 6 lines

I want to eventually reach a situation where we have a 'proper' header section to the image that stores (among other things) whether compression is enabled and which cryptoapi algorithm is used, allowing a person to en/disable compression at runtime without recompiling or rebooting. I suppose if I seek to put that stuff in earlier rather than later, that will simplify things.

I don't have a problem with changing the signature. If the image format changes, it's probably the best we can do.

Quoted 4 lines

Oh, while I'm writing to you: let's not worry about getting my patches in for 2.6.37. I won't be working on them much today, and want to put the time into making sure they're right before they get merged. As you said - let's seek to get things right first time.

OK

Thanks,
Rafael

#7 lore raw
In reply to Rafael J. Wysocki
Quoted 25 lines
Quoted 25 lines
Quoted 15 lines

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
  #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
  /*
   *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
  	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
  	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
  		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

Quoted 9 lines
Quoted 3 lines

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

ACK. Lets keep this simple.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw
In reply to Rafael J. Wysocki
Quoted 25 lines
Quoted 25 lines
Quoted 15 lines

Index: linux-2.6/kernel/power/swap.c
===================================================================

kernel/power/swap.c +1 -1
@@ -29,7 +29,7 @@
 
  #include "power.h"
 
-#define SWSUSP_SIG	"S1SUSPEND"
+#define HIBERNATE_SIG	"LINHIB0001"
 
  /*
   *	The swap map is a data structure used for keeping track of each page

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 197

Quoted 3 lines
kernel/power/swap.c +0 -0
@@ -195,7 +195,7 @@ static int mark_swapfiles(struct swap_ma
  	if (!memcmp("SWAP-SPACE",swsusp_header->sig, 10) ||
  	    !memcmp("SWAPSPACE2",swsusp_header->sig, 10)) {
  		memcpy(swsusp_header->orig_sig,swsusp_header->sig, 10);

if no compression

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +0 -1
-		memcpy(swsusp_header->sig,SWSUSP_SIG, 10);

else

Quoted 9 lines
Quoted 3 lines

kernel/power/swap.c static int mark_swapfiles(struct swap_ma · line 198

Quoted 1 line
kernel/power/swap.c +1 -0
+		memcpy(swsusp_header->sig, HIBERNATE_SIG, 10);

??

I thought about that, but we'll need to drop the old signature when the image format changes (I think it will after your patch series) anyway. And the benefit is not really worth it IMO (it only affects people using the in-kernel hibernation on x86-64).

ACK. Lets keep this simple.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html