Commit 45944378 authored by Juergen Gross's avatar Juergen Gross
Browse files

x86/xen: Tolerate nested XEN_LAZY_MMU entering/leaving



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: 291b3abe ("x86/xen: use lazy_mmu_state when context-switching")
Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Message-ID: <20260508143933.493013-1-jgross@suse.com>
parent 28e03f78
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2145,7 +2145,10 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t phys, pgprot_t prot)

static void xen_enter_lazy_mmu(void)
{
	preempt_disable();
	if (xen_get_lazy_mode() != XEN_LAZY_MMU)
		enter_lazy(XEN_LAZY_MMU);
	preempt_enable();
}

static void xen_flush_lazy_mmu(void)
@@ -2182,6 +2185,7 @@ static void xen_leave_lazy_mmu(void)
{
	preempt_disable();
	xen_mc_flush();
	if (xen_get_lazy_mode() != XEN_LAZY_NONE)
		leave_lazy(XEN_LAZY_MMU);
	preempt_enable();
}