Skip to contentSkip to conversation

PM: hibernate: Don't lose create_image() errors to arch_resume_nosmt()

PATCH In review Cole Leavitt 2 participants 3 messages Oct 18 – Nov 13

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

PATCH 1/1 PM: hibernate: Don't lose create_image() errors to arch_resume_nosmt()

create_image() calls arch_resume_nosmt() on every path that returns with in_suspend cleared and assigns its return value to error. That includes the error paths taken when pm_sleep_disable_secondary_cpus() or syscore_suspend() fails, which jump to Enable_cpus/Enable_irqs.

When SMT is not disabled (for example on CPUs without SMT, where cpu_smt_control is CPU_SMT_NOT_SUPPORTED), arch_resume_nosmt() returns 0, so the failure is lost: create_image() returns 0 with in_suspend unset, hibernation_snapshot() treats that as a successful restore and hibernate() reports success to user space although no image was created. A wakeup event that aborts image creation in syscore_suspend() is thus indistinguishable from resuming a hibernation image.

Only call arch_resume_nosmt() when image creation succeeded. Failures now propagate, so a wakeup event that makes syscore_suspend() fail returns -EBUSY to user space, like wakeup aborts in freeze_processes() and dpm_suspend() already do.

Fixes ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")

---

Notes:
Tested on a Lenovo ThinkPad P16 Gen 3 (Core Ultra 9 275HX, JHL9580 Barlow Ridge host, I226 Ethernet), in daily use since 2026-09-17.

 kernel/power/hibernate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/hibernate.c +1 -1
index c13f68ab7f6e..f53f844114a1 100644
@@ -380,7 +380,7 @@ static int create_image(int platform_mode)
 	pm_sleep_enable_secondary_cpus();
 
 	/* Allow architectures to do nosmt-specific post-resume dances */
-	if (!in_suspend)
+	if (!in_suspend && !error)
 		error = arch_resume_nosmt();
 
  Platform_finish:

base-commit: 32c52ec87d6245ee2d12ed5dd509e40062939b50

Signature · 1 line
2.54.0
#1 lore raw
Quoted 14 lines · Cole Leavitt

create_image() calls arch_resume_nosmt() on every path that returns with in_suspend cleared and assigns its return value to error. That includes the error paths taken when pm_sleep_disable_secondary_cpus() or syscore_suspend() fails, which jump to Enable_cpus/Enable_irqs.

When SMT is not disabled (for example on CPUs without SMT, where cpu_smt_control is CPU_SMT_NOT_SUPPORTED), arch_resume_nosmt() returns 0, so the failure is lost: create_image() returns 0 with in_suspend unset, hibernation_snapshot() treats that as a successful restore and hibernate() reports success to user space although no image was created. A wakeup event that aborts image creation in syscore_suspend() is thus indistinguishable from resuming a hibernation image.

Quoted 8 lines

Only call arch_resume_nosmt() when image creation succeeded. Failures now propagate, so a wakeup event that makes syscore_suspend() fail returns -EBUSY to user space, like wakeup aborts in freeze_processes() and dpm_suspend() already do.

Fixes ec527c318036 ("x86/power: Fix 'nosmt' vs hibernation triple fault during resume")

Sashiko has feedback on this that needs to be addressed:

https://sashiko.dev/#/patchset/20261018164004.132785-1-cole%40unwrap.rs

Quoted 28 lines

---

Notes:
Tested on a Lenovo ThinkPad P16 Gen 3 (Core Ultra 9 275HX, JHL9580 Barlow Ridge host, I226 Ethernet), in daily use since 2026-09-17.

 kernel/power/hibernate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/hibernate.c +1 -1
index c13f68ab7f6e..f53f844114a1 100644
@@ -380,7 +380,7 @@ static int create_image(int platform_mode)
        pm_sleep_enable_secondary_cpus();
 
        /* Allow architectures to do nosmt-specific post-resume dances */
-       if (!in_suspend)
+       if (!in_suspend && !error)
                error = arch_resume_nosmt();
 
  Platform_finish:

base-commit: 32c52ec87d6245ee2d12ed5dd509e40062939b50 --
2.54.0

#2 lore raw
Quoted 3 lines · Rafael J. Wysocki (Intel)

Sashiko has feedback on this that needs to be addressed:

https://sashiko.dev/#/patchset/20261018164004.132785-1-cole%40unwrap.rs

Thanks for pointing me to it. Sashiko is right that devices are resumed with PMSG_RESTORE when hibernation aborts before the image is taken, because in_suspend is only set right before swsusp_arch_suspend(). This is older than my patch: before it, arch_resume_nosmt() reset error to 0 on those paths and the message was PMSG_RESTORE as well. A dpm_suspend() failure in hibernation_snapshot() gets the same message.

I don't think the suggested fix of choosing PMSG_RECOVER whenever error is set is right, though. arch_resume_nosmt() can also fail after a real restore, and there the devices need their ->restore*() callbacks.

I'll send a v2 with a separate patch that records whether the snapshot was taken and uses PMSG_RECOVER only for errors before that point. v2 also adds a patch that makes a wakeup event pending after syscore_suspend() fail image creation with -EBUSY. That case currently returns 0 and is reported as a successful restore.

Thanks,
Cole