Re: [PATCH] x86/xen: Tolerate nested XEN_LAZY_MMU entering/leaving

From: Jürgen Groß

Date: Tue May 12 2026 - 12:15:26 EST


On 12.05.26 18:05, Marek Marczykowski-Górecki wrote:
On Fri, May 08, 2026 at 04:39:33PM +0200, Juergen Gross wrote:
With the support of nested lazy mmu sections it can happen that
arch_enter_lazy_mmu_mode() is being called twice without a call of
arch_leave_lazy_mmu_mode() in between, as the lazy_mmu_*() helpers
are not disabling preemption when checking for nested lazy mmu
sections.

This is a problem when running as a Xen PV guest, as
xen_enter_lazy_mmu() and xen_leave_lazy_mmu() don't tolerate this
case.

Fix that in xen_enter_lazy_mmu() and xen_leave_lazy_mmu() in order
not to hurt all other lazy mmu mode users.

Fixes: 291b3abed657 ("x86/xen: use lazy_mmu_state when context-switching")
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

I have ran several test iterations with this patch (on top of 7.0.4) and
it seems to fix the issue. So,

Tested-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>

Thanks for testing.


I did run some tests also with 291b3abed657 reverted (instead of this
patch), and that seems to work too, but I didn't run enough of
iterations to be 100% sure. Would it be helpful to that that further
too?

I do prefer my variant, as it is on my preferred path to get rid of the
Xen-private lazy mode tracking.

So in my personal opinion you don't need to continue this test.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature