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

From: Jürgen Groß

Date: Sat May 09 2026 - 02:32:35 EST


On 08.05.26 22:54, Kevin Brodsky wrote:
On 08/05/2026 16:39, 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.

I think this is a correct description of the issue, i.e. potentially we
have arch_enter_lazy_mmu_mode() called twice *sequentially*. Therefore I
don't think that disabling preemption inside arch_enter_lazy_mmu_mode()
is enough - we have a problem with preemption occurring inside
lazy_mmu_mode_enable() generally, not necessarily inside
arch_enter_lazy_mmu_mode().

Preemption shouldn't matter if commit 291b3abed657 is reverted. AFAICT
this is the only easy fix.
The description wasn't really complete, I think.

The double call will only be possible if arch_end_context_switch() is
calling arch_enter_lazy_mmu_mode(), and this is happening for Xen PV only.
arch_end_context_switch() is a nop for all other cases.

So this can be handled completely internal of Xen (otherwise a revert of
291b3abed657 wouldn't help), and it is easy to do so as my patch is
showing.

As said, I'd like to get rid of the extra tracking by Xen regarding lazy mode.


Juergen

Attachment: OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature