Thread (1 message) 1 message, 1 author, 2007-12-30

Re: [PATCH] Hibernation: Document __save_processor_state() on x86-64

From: Pavel Machek <hidden>
Date: 2007-12-30 20:17:34

Possibly related (same subject, not in this thread)

On Sun 2007-12-30 14:30:07, Rafael J. Wysocki wrote:
On Sunday, 30 of December 2007, Pavel Machek wrote:
quoted
Hi!
quoted
From: Rafael J. Wysocki <redacted>

Document the fact that __save_processor_state() has to save all CPU
registers referred to by the kernel in case a different kernel is
used to load and restore a hibernation image containing it. 
quoted
Sigend-off-by: Rafael J. Wysocki [off-list ref]
---
 arch/x86/kernel/suspend_64.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Index: linux-2.6/arch/x86/kernel/suspend_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/suspend_64.c
+++ linux-2.6/arch/x86/kernel/suspend_64.c
@@ -19,6 +19,21 @@ extern const void __nosave_begin, __nosa
 
 struct saved_context saved_context;
 
+/**
+ *	__save_processor_state - save CPU registers before creating a
+ *		hibernation image and before restoring the memory state from it
+ *	@ctxt - structure to store the registers contents in
+ *
+ *	NOTE: If there is a CPU register the modification of which by the
+ *	boot kernel (ie. the kernel used for loading the hibernation image)
+ *	might affect the operations of the restored target kernel (ie. the one
+ *	saved in the hibernation image), then its contents must be saved by this
+ *	function.  In other words, if kernel A is hibernated and different
+ *	kernel B is used for loading the hibernation image into memory, the
+ *	kernel A's __save_processor_state() function must save all registers
+ *	needed by kernel A, so that it can operate correctly after the resume
+ *	regardless of what kernel B does in the meantime.
+ */
Maybe this warning should be appended to struct saved_context
definition? Reordering its fields (etc) would be bad news, too,
Hmm, I think they can be reordered without any problem.  It's always the same
kernel using them, although at different times.
Aha... ok, then. I misunderstood how it works.
quoted
and documentation near data structures is easier to find...
Well, I'll add a coment next to the definition of struct saved_context to
explain what it's for, but IMO the behavior of __save_processor_state() is what
_really_ matters (ie. it doesn't matter how and where exactly it saves the
registers as long as __restore_processor_state() can restore their "old"
values).
Yep, right.

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help