Skip to contentSkip to conversation

kexec_core: Fix and cleanup for the KEXEC_JUMP flow

PATCH Applied Rafael J. Wysocki 3 participants 7 messages Jul 10, 2025 – Jul 11, 2025

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

cover kexec_core: Fix and cleanup for the KEXEC_JUMP flow

Hi Everyone,

These two patches fix an error code path issue in the KEXEC_JUMP flow (patch [1/2]) and clean it up a bit afterward (patch [2/2]).

Please see patch changelogs for details.

Thanks!

#1 lore raw

PATCH 1/2 kexec_core: Fix error code path in the KEXEC_JUMP flow

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

If dpm_suspend_start() fails, dpm_resume_end() must be called to recover devices whose suspend callbacks have been called, but this does not happen in the KEXEC_JUMP flow's error path due to a confused goto target label.

Address this by using the correct target label in the goto statement in question.

Fixes 2965faa5e03d ("kexec: split kexec_load syscall from kexec core code")
---
 kernel/kexec_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec_core.c +1 -1
@@ -1080,7 +1080,7 @@
 		console_suspend_all();
 		error = dpm_suspend_start(PMSG_FREEZE);
 		if (error)
-			goto Resume_console;
+			goto Resume_devices;
 		/*
 		 * dpm_suspend_end() must be called after dpm_suspend_start()
 		 * to complete the transition, like in the hibernation flows
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] kexec_core: Fix error code path in the KEXEC_JUMP flow

Quoted 9 lines · Rafael J. Wysocki

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

If dpm_suspend_start() fails, dpm_resume_end() must be called to recover devices whose suspend callbacks have been called, but this does not happen in the KEXEC_JUMP flow's error path due to a confused goto target label.

Address this by using the correct target label in the goto statement in question.

Sounds very reasonable, thanks for the fix.

Quoted 21 lines
Fixes 2965faa5e03d ("kexec: split kexec_load syscall from kexec core code")
---
 kernel/kexec_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec_core.c +1 -1
@@ -1080,7 +1080,7 @@
 		console_suspend_all();
 		error = dpm_suspend_start(PMSG_FREEZE);
 		if (error)
-			goto Resume_console;
+			goto Resume_devices;
 		/*
 		 * dpm_suspend_end() must be called after dpm_suspend_start()
 		 * to complete the transition, like in the hibernation flows
#3 lore raw

Re: [PATCH v1 1/2] kexec_core: Fix error code path in the KEXEC_JUMP flow

Quoted 9 lines · Baoquan He
Quoted 7 lines · Rafael J. Wysocki

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

If dpm_suspend_start() fails, dpm_resume_end() must be called to recover devices whose suspend callbacks have been called, but this does not happen in the KEXEC_JUMP flow's error path due to a confused goto target label.

Quoted 6 lines
Quoted 2 lines

Address this by using the correct target label in the goto statement in question.

Sounds very reasonable, thanks for the fix.

Thanks!

I've queued it up for 6.17 along with the [2/2].

Quoted 22 lines
Quoted 21 lines
Fixes 2965faa5e03d ("kexec: split kexec_load syscall from kexec core code")
---
 kernel/kexec_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec_core.c +1 -1
@@ -1080,7 +1080,7 @@
              console_suspend_all();
              error = dpm_suspend_start(PMSG_FREEZE);
              if (error)
-                     goto Resume_console;
+                     goto Resume_devices;
              /*
               * dpm_suspend_end() must be called after dpm_suspend_start()
               * to complete the transition, like in the hibernation flows
#4 lore raw

PATCH 2/2 kexec_core: Drop redundant pm_restore_gfp_mask() call

In reply to Rafael J. Wysocki

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

Drop the direct pm_restore_gfp_mask() call from the KEXEC_JUMP flow in kernel_kexec() because it is redundant. Namely, dpm_resume_end() called beforehand in the same code path invokes that function and it is sufficient to invoke it once.

---
 kernel/kexec_core.c |    1 -
 1 file changed, 1 deletion(-)
kernel/kexec_core.c +0 -1
@@ -1136,7 +1136,6 @@
  Resume_devices:
 		dpm_resume_end(PMSG_RESTORE);
  Resume_console:
-		pm_restore_gfp_mask();
 		console_resume_all();
 		thaw_processes();
  Restore_console:
Acked-by on v1 2/2
#5 lore raw

Re: [PATCH v1 2/2] kexec_core: Drop redundant pm_restore_gfp_mask() call

Quoted 11 lines · Rafael J. Wysocki

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

Drop the direct pm_restore_gfp_mask() call from the KEXEC_JUMP flow in kernel_kexec() because it is redundant. Namely, dpm_resume_end() called beforehand in the same code path invokes that function and it is sufficient to invoke it once.

---
 kernel/kexec_core.c |    1 -
 1 file changed, 1 deletion(-)

LGTM,

Quoted 14 lines
kernel/kexec_core.c +0 -1
@@ -1136,7 +1136,6 @@
  Resume_devices:
 		dpm_resume_end(PMSG_RESTORE);
  Resume_console:
-		pm_restore_gfp_mask();
 		console_resume_all();
 		thaw_processes();
  Restore_console: