Skip to contentSkip to conversation

S3 regression related to XSA-471 patches

DISCUSSION Marek Marczykowski-Górecki 4 participants 8 messages Aug 6, 2025 – Aug 22, 2025

lore
Share & tools
lore
#0 lore raw

Hi,

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

The problem manifests in system freezing on S3 resume. Sometimes it manages to show the screenlocker password prompt, and sometimes one can interact with it for a second or two. But then it freezes, mouse stops moving etc (but no reboot).
One time I managed to get pass the screenlocker and interact with dom0 for a few minutes before it frozen. Resuming domUs didn't happen (the qubes-specific script doing so resume hanged), and also no logs persisted on the disk from this case (on disk it looked like it never resumed). Generally it looked like some CPUs were stuck.

It appears to be more likely to hit the issue if some domUs are active at the suspend/resume time. While Qubes OS does suspend (not just pause) them for the host S3 time, some activity before/after does appear to matter. My test case that has ~30-40% reproduction rate involves several firefox instances playing youtube videos.

I've talked with Andrew about it a bit, with not much conclusions. Initial reports mentioned only MTL and RPL systems, so we focused on something related to weird topology. But just today I've got a report of the same happening on KBL too...

Another observation (possibly invalidated by today's report...) is that all reports were about systems running Coreboot (but not only Dasharo flavor - at least one was Star Labs).

Most reports are collected at https://github.com/QubesOS/qubes-issues/issues/10110

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#1 lore raw
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Jan

#2 lore raw
Quoted 11 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

Quoted 6 lines

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Sure, I'll try.

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#3 lore raw
Quoted 12 lines · Marek Marczykowski-Górecki
Quoted 11 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

Quoted 8 lines
Quoted 6 lines

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Sure, I'll try.

It appears this fixes the issue, at least in ~10 attempts so far (usually I could reproduce the issue after 2-3 attempts).

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#4 lore raw
Quoted 18 lines · Marek Marczykowski-Górecki
Quoted 17 lines · Marek Marczykowski-Górecki
Quoted 16 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Quoted 4 lines
Quoted 1 line

Sure, I'll try.

It appears this fixes the issue, at least in ~10 attempts so far (usually I could reproduce the issue after 2-3 attempts).

Can you show the exact code which seems to have made this stable?

We discussed this in the x86 maintainers meeting, and our best guess is a timer that's not torn down or recreated properly on S3, but this is largely speculation.

~Andrew

#5 lore raw
Quoted 19 lines · Andrew Cooper
Quoted 18 lines · Marek Marczykowski-Górecki
Quoted 17 lines · Marek Marczykowski-Górecki
Quoted 16 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Sure, I'll try.

It appears this fixes the issue, at least in ~10 attempts so far (usually I could reproduce the issue after 2-3 attempts).

Can you show the exact code which seems to have made this stable?

This patch: https://github.com/marmarek/qubes-vmm-xen/blob/7c9e9e312948c772d9a68090109964121c1d16fe/0001-DEBUG-S3.patch

Quoted 6 lines

We discussed this in the x86 maintainers meeting, and our best guess is a timer that's not torn down or recreated properly on S3, but this is largely speculation.

~Andrew

#6 lore raw
Quoted 22 lines · Marek Marczykowski-Górecki
Quoted 19 lines · Andrew Cooper
Quoted 18 lines · Marek Marczykowski-Górecki
Quoted 17 lines · Marek Marczykowski-Górecki
Quoted 16 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Sure, I'll try.

It appears this fixes the issue, at least in ~10 attempts so far (usually I could reproduce the issue after 2-3 attempts).

Can you show the exact code which seems to have made this stable?

This patch: https://github.com/marmarek/qubes-vmm-xen/blob/7c9e9e312948c772d9a68090109964121c1d16fe/0001-DEBUG-S3.patch

Hello,

Can you test if the patch below in isolation makes any difference?

Thanks, Roger.
---

xen/arch/x86/acpi/power.c +2 -0
index 2ac162c997fe..27d672ad5dbb 100644
@@ -19,6 +19,7 @@
 #include <xen/iommu.h>
 #include <xen/param.h>
 #include <xen/sched.h>
+#include <xen/softirq.h>
 #include <xen/spinlock.h>
 #include <xen/watchdog.h>
 
@@ -310,6 +311,7 @@ static int enter_state(u32 state)
     thaw_domains();
     system_state = SYS_STATE_active;
     spin_unlock(&pm_lock);
+    raise_softirq(TIMER_SOFTIRQ);
     return error;
 }
 
xen/arch/x86/apic.c +1 -3
index 0fd8bdba7067..9d66db861b74 100644
@@ -65,7 +65,6 @@ static struct {
     unsigned int apic_lvt0;
     unsigned int apic_lvt1;
     unsigned int apic_lvterr;
-    unsigned int apic_tmict;
     unsigned int apic_tdcr;
     unsigned int apic_thmr;
 } apic_pm_state;
@@ -658,7 +657,6 @@ int lapic_suspend(void)
     apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
     apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
     apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
-    apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
     apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
     if (maxlvt >= 5)
         apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
@@ -718,7 +716,7 @@ int lapic_resume(void)
         apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
     apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
     apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
-    apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
+    apic_write(APIC_TMICT, 0);
     apic_write(APIC_ESR, 0);
     apic_read(APIC_ESR);
     apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
#7 lore raw
Quoted 28 lines · Roger Pau Monné
Quoted 27 lines · Marek Marczykowski-Górecki
Quoted 24 lines · Andrew Cooper
Quoted 22 lines · Marek Marczykowski-Górecki
Quoted 11 lines · Marek Marczykowski-Górecki
Quoted 10 lines · Jan Beulich
Quoted 9 lines · Marek Marczykowski-Górecki

We've got several reports that S3 reliability recently regressed. We identified it's definitely related to XSA-471 patches, and bisection points at "x86/idle: Remove broken MWAIT implementation". I don't have reliable reproduction steps, so I'm not 100% sure if it's really this patch, or maybe an earlier one - but it's definitely already broken at this point in the series. Most reports are about Xen 4.17 (as that's what stable Qubes OS version currently use), but I think I've seen somebody reporting the issue on 4.19 too (but I don't have clear evidence, especially if it's the same issue).

Quoted 7 lines
Quoted 6 lines

At the time we've been discussing the explicit raising of TIMER_SOFTIRQ in mwait_idle_with_hints() a lot. If it was now truly missing, that imo shouldn't cause problems only after resume, but then it may have covered for some omission during resume. As a far-fetched experiment, could you try putting that back (including the calculation of the "expires" local variable)?

Sure, I'll try.

It appears this fixes the issue, at least in ~10 attempts so far (usually I could reproduce the issue after 2-3 attempts).

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Can you show the exact code which seems to have made this stable?

This patch: https://github.com/marmarek/qubes-vmm-xen/blob/7c9e9e312948c772d9a68090109964121c1d16fe/0001-DEBUG-S3.patch

Hello,

Can you test if the patch below in isolation makes any difference?

Seems to help too. At least a test similar as before did not hit the issue anymore.

Quoted 52 lines

Thanks, Roger.
---

xen/arch/x86/acpi/power.c +2 -0
index 2ac162c997fe..27d672ad5dbb 100644
@@ -19,6 +19,7 @@
 #include <xen/iommu.h>
 #include <xen/param.h>
 #include <xen/sched.h>
+#include <xen/softirq.h>
 #include <xen/spinlock.h>
 #include <xen/watchdog.h>
 
@@ -310,6 +311,7 @@ static int enter_state(u32 state)
     thaw_domains();
     system_state = SYS_STATE_active;
     spin_unlock(&pm_lock);
+    raise_softirq(TIMER_SOFTIRQ);
     return error;
 }
 
xen/arch/x86/apic.c +1 -3
index 0fd8bdba7067..9d66db861b74 100644
@@ -65,7 +65,6 @@ static struct {
     unsigned int apic_lvt0;
     unsigned int apic_lvt1;
     unsigned int apic_lvterr;
-    unsigned int apic_tmict;
     unsigned int apic_tdcr;
     unsigned int apic_thmr;
 } apic_pm_state;
@@ -658,7 +657,6 @@ int lapic_suspend(void)
     apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
     apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
     apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
-    apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
     apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
     if (maxlvt >= 5)
         apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
@@ -718,7 +716,7 @@ int lapic_resume(void)
         apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
     apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
     apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
-    apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
+    apic_write(APIC_TMICT, 0);
     apic_write(APIC_ESR, 0);
     apic_read(APIC_ESR);
     apic_write(APIC_LVTERR, apic_pm_state.apic_lvterr);
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab