From nobody Sat May 30 11:18:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1778251195; cv=none; d=zohomail.com; s=zohoarc; b=VygqkSxXU7evu7AF4jodwH9OfCzkSbAI4npGhdO69wes09b+CVrmRKistU81LE53DGos8dunBSOkNygAqO5mts1COzdu6AppPlXKCbStYhbhT5hY/SGG3MB72C3P/0lEvELzJyCTa1Teobo4tInrsR4OpvBvoD0oHPCoTr7knK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778251195; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qcH0oyDgGShFY8obpKeBe1gSWCv27CYVU+nGbBQx6uk=; b=RgMhu1J+gSPYsYAnl6Y7/SpR7I2CohP7cnfC4VLgXoazd6njzTv+aGgC1/ybRqnTRo8UELp9VkLKIizGDZqMuZ/bfmxUaeFFh2fjMK59ZyhYIjsYLJGWrZfg5IZQs9/4QU3XtAYBlntptYJ9ADV6P6cEkxLrvTJQ+lTE6u21sQo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1778251195149895.0672319107405; Fri, 8 May 2026 07:39:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1303726.1576975 (Exim 4.92) (envelope-from ) id 1wLMMd-00033F-Bc; Fri, 08 May 2026 14:39:39 +0000 Received: by outflank-mailman (output) from mailman id 1303726.1576975; Fri, 08 May 2026 14:39:39 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wLMMd-000338-8N; Fri, 08 May 2026 14:39:39 +0000 Received: by outflank-mailman (input) for mailman id 1303726; Fri, 08 May 2026 14:39:38 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wLMMc-000332-1q for xen-devel@lists.xenproject.org; Fri, 08 May 2026 14:39:38 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wLMMb-003Ice-15 for xen-devel@lists.xenproject.org; Fri, 08 May 2026 16:39:37 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69fdf59b-e002-0a2a0a5209dd-0a2a450acde4-20 for ; Fri, 08 May 2026 16:39:36 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69fdf5a8-56b3-0a2a450a0019-c387df83eda0-3 for ; Fri, 08 May 2026 16:39:36 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6A1DC5C115; Fri, 8 May 2026 14:39:36 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 215A5593A7; Fri, 8 May 2026 14:39:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GKQGB6j1/WlcVgAAD6G6ig (envelope-from ); Fri, 08 May 2026 14:39:36 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1778251176; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qcH0oyDgGShFY8obpKeBe1gSWCv27CYVU+nGbBQx6uk=; b=eIuw8rpP3+bLN054/2BzceWEYq44u78XjU+o/Hk63wuCt6dDM53cF6B9HfXABaLBH2U1xQ p6ltDFfK8+KEsrmabJzOTwdyfB5/COMiL9/p378+C/sLW+lOaj3LjigyBTFzadJe0Vq06w 0tPe7/qqbqbmOgDTAWLKAuhLF6d+zvE= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1778251176; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=qcH0oyDgGShFY8obpKeBe1gSWCv27CYVU+nGbBQx6uk=; b=eIuw8rpP3+bLN054/2BzceWEYq44u78XjU+o/Hk63wuCt6dDM53cF6B9HfXABaLBH2U1xQ p6ltDFfK8+KEsrmabJzOTwdyfB5/COMiL9/p378+C/sLW+lOaj3LjigyBTFzadJe0Vq06w 0tPe7/qqbqbmOgDTAWLKAuhLF6d+zvE= From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: kevin.brodsky@arm.com, marmarek@invisiblethingslab.com, Juergen Gross , Boris Ostrovsky , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , xen-devel@lists.xenproject.org Subject: [PATCH] x86/xen: Tolerate nested XEN_LAZY_MMU entering/leaving Date: Fri, 8 May 2026 16:39:33 +0200 Message-ID: <20260508143933.493013-1-jgross@suse.com> X-Mailer: git-send-email 2.54.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_TWELVE(0.00)[12]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Score: -2.80 X-purgate-ID: tlsNG-4011c0/1778251176-70F618B7-A88E1767/0/0 X-purgate-type: clean X-purgate-size: 1487 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1778251195725158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Kevin Brodsky Tested-by: Marek Marczykowski-G=C3=B3recki --- arch/x86/xen/mmu_pv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index c80d0058efd1..3eee5f84f8a7 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -2145,7 +2145,10 @@ static void xen_set_fixmap(unsigned idx, phys_addr_t= phys, pgprot_t prot) =20 static void xen_enter_lazy_mmu(void) { - enter_lazy(XEN_LAZY_MMU); + preempt_disable(); + if (xen_get_lazy_mode() !=3D XEN_LAZY_MMU) + enter_lazy(XEN_LAZY_MMU); + preempt_enable(); } =20 static void xen_flush_lazy_mmu(void) @@ -2182,7 +2185,8 @@ static void xen_leave_lazy_mmu(void) { preempt_disable(); xen_mc_flush(); - leave_lazy(XEN_LAZY_MMU); + if (xen_get_lazy_mode() !=3D XEN_LAZY_NONE) + leave_lazy(XEN_LAZY_MMU); preempt_enable(); } =20 --=20 2.54.0