* [PATCH] xen: take system_transition_mutex on suspend
@ 2025-09-21 16:28 Marek Marczykowski-Górecki
2025-09-22 6:06 ` Jürgen Groß
0 siblings, 1 reply; 3+ messages in thread
From: Marek Marczykowski-Górecki @ 2025-09-21 16:28 UTC (permalink / raw)
To: linux-kernel
Cc: Marek Marczykowski-Górecki, Jürgen Groß,
stable, Stefano Stabellini, Oleksandr Tyshchenko,
Rafael J. Wysocki, Mario Limonciello,
moderated list:XEN HYPERVISOR INTERFACE
Xen's do_suspend() calls dpm_suspend_start() without taking required
system_transition_mutex. Since 12ffc3b1513eb moved the
pm_restrict_gfp_mask() call, not taking that mutex results in a WARN.
Take the mutex in do_suspend(), and use mutex_trylock() to follow
how enter_state() does this.
Suggested-by: Jürgen Groß <jgross@suse.com>
Fixes: 12ffc3b1513eb "PM: Restrict swap use to later in the suspend sequence"
Link: https://lore.kernel.org/xen-devel/aKiBJeqsYx_4Top5@mail-itl/
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Cc: stable@vger.kernel.org # v6.16+
---
drivers/xen/manage.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c
index b4b4ebed68daf..f78d970949c0a 100644
--- a/drivers/xen/manage.c
+++ b/drivers/xen/manage.c
@@ -11,6 +11,7 @@
#include <linux/reboot.h>
#include <linux/sysrq.h>
#include <linux/stop_machine.h>
+#include <linux/suspend.h>
#include <linux/freezer.h>
#include <linux/syscore_ops.h>
#include <linux/export.h>
@@ -101,10 +102,16 @@ static void do_suspend(void)
shutting_down = SHUTDOWN_SUSPEND;
+ if (!mutex_trylock(&system_transition_mutex))
+ {
+ pr_err("%s: failed to take system_transition_mutex\n", __func__);
+ goto out;
+ }
+
err = freeze_processes();
if (err) {
pr_err("%s: freeze processes failed %d\n", __func__, err);
- goto out;
+ goto out_unlock;
}
err = freeze_kernel_threads();
@@ -160,6 +167,8 @@ static void do_suspend(void)
out_thaw:
thaw_processes();
+out_unlock:
+ mutex_unlock(&system_transition_mutex);
out:
shutting_down = SHUTDOWN_INVALID;
}
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen: take system_transition_mutex on suspend
2025-09-21 16:28 [PATCH] xen: take system_transition_mutex on suspend Marek Marczykowski-Górecki
@ 2025-09-22 6:06 ` Jürgen Groß
2025-09-24 16:24 ` Mario Limonciello
0 siblings, 1 reply; 3+ messages in thread
From: Jürgen Groß @ 2025-09-22 6:06 UTC (permalink / raw)
To: Marek Marczykowski-Górecki, linux-kernel
Cc: stable, Stefano Stabellini, Oleksandr Tyshchenko,
Rafael J. Wysocki, Mario Limonciello,
moderated list:XEN HYPERVISOR INTERFACE
[-- Attachment #1.1.1: Type: text/plain, Size: 747 bytes --]
On 21.09.25 18:28, Marek Marczykowski-Górecki wrote:
> Xen's do_suspend() calls dpm_suspend_start() without taking required
> system_transition_mutex. Since 12ffc3b1513eb moved the
> pm_restrict_gfp_mask() call, not taking that mutex results in a WARN.
>
> Take the mutex in do_suspend(), and use mutex_trylock() to follow
> how enter_state() does this.
>
> Suggested-by: Jürgen Groß <jgross@suse.com>
> Fixes: 12ffc3b1513eb "PM: Restrict swap use to later in the suspend sequence"
> Link: https://lore.kernel.org/xen-devel/aKiBJeqsYx_4Top5@mail-itl/
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Cc: stable@vger.kernel.org # v6.16+
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen: take system_transition_mutex on suspend
2025-09-22 6:06 ` Jürgen Groß
@ 2025-09-24 16:24 ` Mario Limonciello
0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-09-24 16:24 UTC (permalink / raw)
To: Jürgen Groß, Marek Marczykowski-Górecki, linux-kernel
Cc: stable, Stefano Stabellini, Oleksandr Tyshchenko,
Rafael J. Wysocki, moderated list:XEN HYPERVISOR INTERFACE
On 9/22/25 1:06 AM, Jürgen Groß wrote:
> On 21.09.25 18:28, Marek Marczykowski-Górecki wrote:
>> Xen's do_suspend() calls dpm_suspend_start() without taking required
>> system_transition_mutex. Since 12ffc3b1513eb moved the
>> pm_restrict_gfp_mask() call, not taking that mutex results in a WARN.
>>
>> Take the mutex in do_suspend(), and use mutex_trylock() to follow
>> how enter_state() does this.
>>
>> Suggested-by: Jürgen Groß <jgross@suse.com>
>> Fixes: 12ffc3b1513eb "PM: Restrict swap use to later in the suspend
>> sequence"
>> Link: https://lore.kernel.org/xen-devel/aKiBJeqsYx_4Top5@mail-itl/
>> Signed-off-by: Marek Marczykowski-Górecki
>> <marmarek@invisiblethingslab.com>
>> Cc: stable@vger.kernel.org # v6.16+
>
> Reviewed-by: Juergen Gross <jgross@suse.com>
>
>
> Juergen
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-24 16:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-21 16:28 [PATCH] xen: take system_transition_mutex on suspend Marek Marczykowski-Górecki
2025-09-22 6:06 ` Jürgen Groß
2025-09-24 16:24 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®