Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 119c348a authored by Thomas Garnier's avatar Thomas Garnier Committed by Greg Kroah-Hartman
Browse files

PM / hibernate: Restore processor state before using per-CPU variables



commit 62822e2ec4ad091ba31f823f577ef80db52e3c2c upstream.

Restore the processor state before calling any other functions to
ensure per-CPU variables can be used with KASLR memory randomization.

Tracing functions use per-CPU variables (GS based on x86) and one was
called just before restoring the processor state fully. It resulted
in a double fault when both the tracing & the exception handler
functions tried to use a per-CPU variable.

Fixes: bb3632c6 (PM / sleep: trace events for suspend/resume)
Reported-and-tested-by: default avatarBorislav Petkov <bp@suse.de>
Reported-by: default avatarJiri Kosina <jikos@kernel.org>
Tested-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Tested-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarThomas Garnier <thgarnie@google.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent da40055e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -299,12 +299,12 @@ static int create_image(int platform_mode)
	save_processor_state();
	save_processor_state();
	trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true);
	trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true);
	error = swsusp_arch_suspend();
	error = swsusp_arch_suspend();
	/* Restore control flow magically appears here */
	restore_processor_state();
	trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false);
	trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false);
	if (error)
	if (error)
		printk(KERN_ERR "PM: Error %d creating hibernation image\n",
		printk(KERN_ERR "PM: Error %d creating hibernation image\n",
			error);
			error);
	/* Restore control flow magically appears here */
	restore_processor_state();
	if (!in_suspend)
	if (!in_suspend)
		events_check_enabled = false;
		events_check_enabled = false;