From nobody Thu Oct 30 22:42:12 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1756805330; cv=none; d=zohomail.com; s=zohoarc; b=dRWQYvExwaD/iBQ0YbnZqoIr8iZPGayucA9VCP2sLVao+6+zWvjbeqAbWm+7M8jaGGdQa8Qy4ygXLShsh6fwe0RgvDt5naWBsjlnM77zUbDOR4H7z959iHKXbuzwOLjbCbUdTYqMd+MhkS3ERhSS5lE+crUi5xSZnqgdiNwH8pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756805330; h=Content-Type: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=mVE2bxoiaJc/omf+Xbgpgc0UASpoGRaDW87GrKaH4u4=; b=gmxFCbDNe+dM9KpIpFJFdIIUNp4PsaSBeX+VLXGcEJc5N+g2Rbe/YyGrMVKIM0wOFxDLBak3DjAM95nz5bMobZTvSX9j7ItkvDzIlH4oehfXgY/wK+86xSmGo1QUuF+4nycO7QdG6mUAx+9mFhY7cjzb5X8DCBHPLOHLaeVOb8I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1756805330706527.0033347573017; Tue, 2 Sep 2025 02:28:50 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1105916.1456729 (Exim 4.92) (envelope-from ) id 1utNJd-0005qV-D5; Tue, 02 Sep 2025 09:28:37 +0000 Received: by outflank-mailman (output) from mailman id 1105916.1456729; Tue, 02 Sep 2025 09:28:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1utNJd-0005qO-A4; Tue, 02 Sep 2025 09:28:37 +0000 Received: by outflank-mailman (input) for mailman id 1105916; Tue, 02 Sep 2025 09:28:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1utNJc-0005f4-AK for xen-devel@lists.xenproject.org; Tue, 02 Sep 2025 09:28:36 +0000 Received: from mail180-6.suw31.mandrillapp.com (mail180-6.suw31.mandrillapp.com [198.2.180.6]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 32c7d3ab-87df-11f0-8adc-4578a1afcccb; Tue, 02 Sep 2025 11:28:35 +0200 (CEST) Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail180-6.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4cGL5Z0m2xz2K2671 for ; Tue, 2 Sep 2025 09:28:34 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 5a36f42ca8a1486e95ff20a990a02aa7; Tue, 02 Sep 2025 09:28:34 +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" X-Inumbo-ID: 32c7d3ab-87df-11f0-8adc-4578a1afcccb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1756805314; x=1757075314; bh=mVE2bxoiaJc/omf+Xbgpgc0UASpoGRaDW87GrKaH4u4=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=j++PI+0++pbjylfCeY3fQ8zK7noV+3ix9tvCMfLs35RsyaYSl7FXBbv32p5T2E+mE s994SlUyEug3Z+9MsB3EkGMJbUIcBVTX/nxvg4hysRQfpAQf1JnTMvCMTrSaYYhNg5 nc2pEunUbMVta/9hj0n9IsU4VlXH9V+ra4wguTuPOd9fpzubkBQeXdig29XWeKqUmi aBy0PpKDR/YOKIJcuJrpzn6TXV/l2B3qdXtlfrlQLEDA2MzeSTh6S3sf5E2fSKOrPF Gdi2B8zcFtt7/8SB1BDwpxSfjmMKqtWDfM8Amkwcog/KqypGJfA1Z4RsHu6CwUo7CJ ec5IsIAuyUulQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1756805314; x=1757065814; i=teddy.astie@vates.tech; bh=mVE2bxoiaJc/omf+Xbgpgc0UASpoGRaDW87GrKaH4u4=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=P5jNEKVKz+utMDl8M2yH9csSGHgrN+yiv7VTbmU8+WkqLjHDqKQ06bldcG0RrqNfA mA+OhCDbKlVemaDZ7SGAEzeGRyCpdrM7w0Ado5Kao1/jD7DRYaIcM+pwH/nYGJ6Sym lz7p+XLrcY4tinD+Z9uG+F1c7Ip3Dj+zEbrd/i2Q9mKtwhK1gIFuyEMLWWT6ZSRheg IV7zmDAQ201pyYbkxsOOKd/E3f32ErgSLJg6+1AWV8GR/dX/T9yjO5PkjL9jxKdzVN zcpa00vEw6L/ZdkgTlXLBe5Qvjic/SvOiAXEb1N7TQ6njV+LSiRA+azRt+rpJ2/6YB ebuY34HSD9qKQ== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v5.10.y]=20xen:=20replace=20xen=5Fremap()=20with=20memremap()?= X-Mailer: git-send-email 2.51.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1756805309861 To: xen-devel@lists.xenproject.org, stable@vger.kernel.org Cc: "Juergen Gross" , "kernel test robot" , "Boris Ostrovsky" , "Stefano Stabellini" , "Teddy Astie" , "Anthoine Bourgeois" , "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "Dave Hansen" , "H. Peter Anvin" , "Greg Kroah-Hartman" , "Jiri Slaby" Message-Id: <4cc9c1f583fb4bfca02ff7050b9b01cb9abb7e7f.1756803599.git.teddy.astie@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.5a36f42ca8a1486e95ff20a990a02aa7?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250902:md Date: Tue, 02 Sep 2025 09:28:34 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity teddy.astie@vates.tech) X-ZM-MESSAGEID: 1756805333344124100 Content-Type: text/plain; charset="utf-8" From: Juergen Gross From: Juergen Gross [ upstream commit 41925b105e345ebc84cedb64f59d20cb14a62613 ] xen_remap() is used to establish mappings for frames not under direct control of the kernel: for Xenstore and console ring pages, and for grant pages of non-PV guests. Today xen_remap() is defined to use ioremap() on x86 (doing uncached mappings), and ioremap_cache() on Arm (doing cached mappings). Uncached mappings for those use cases are bad for performance, so they should be avoided if possible. As all use cases of xen_remap() don't require uncached mappings (the mapped area is always physical RAM), a mapping using the standard WB cache mode is fine. As sparse is flagging some of the xen_remap() use cases to be not appropriate for iomem(), as the result is not annotated with the __iomem modifier, eliminate xen_remap() completely and replace all use cases with memremap() specifying the MEMREMAP_WB caching mode. xen_unmap() can be replaced with memunmap(). Reported-by: kernel test robot Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Acked-by: Stefano Stabellini Link: https://lore.kernel.org/r/20220530082634.6339-1-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Teddy Astie [backport to 5.10.y] --- Cc: Anthoine Bourgeois Cc: Juergen Gross Cc: Boris Ostrovsky Cc: Stefano Stabellini Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" Cc: Greg Kroah-Hartman Cc: Jiri Slaby arch/x86/include/asm/xen/page.h | 3 --- drivers/tty/hvc/hvc_xen.c | 2 +- drivers/xen/grant-table.c | 6 +++--- drivers/xen/xenbus/xenbus_probe.c | 3 +-- include/xen/arm/page.h | 3 --- 5 files changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/pag= e.h index 5941e18edd5a..c183b7f9efef 100644 --- a/arch/x86/include/asm/xen/page.h +++ b/arch/x86/include/asm/xen/page.h @@ -355,9 +355,6 @@ unsigned long arbitrary_virt_to_mfn(void *vaddr); void make_lowmem_page_readonly(void *vaddr); void make_lowmem_page_readwrite(void *vaddr); =20 -#define xen_remap(cookie, size) ioremap((cookie), (size)); -#define xen_unmap(cookie) iounmap((cookie)) - static inline bool xen_arch_need_swiotlb(struct device *dev, phys_addr_t phys, dma_addr_t dev_addr) diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index 4886cad0fde6..7b472ab2f34f 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -270,7 +270,7 @@ static int xen_hvm_console_init(void) if (r < 0 || v =3D=3D 0) goto err; gfn =3D v; - info->intf =3D xen_remap(gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE); + info->intf =3D memremap(gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE, MEMREMAP_WB= ); if (info->intf =3D=3D NULL) goto err; info->vtermno =3D HVC_COOKIE; diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 0a2d24d6ac6f..a10e0741bec5 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -743,7 +743,7 @@ int gnttab_setup_auto_xlat_frames(phys_addr_t addr) if (xen_auto_xlat_grant_frames.count) return -EINVAL; =20 - vaddr =3D xen_remap(addr, XEN_PAGE_SIZE * max_nr_gframes); + vaddr =3D memremap(addr, XEN_PAGE_SIZE * max_nr_gframes, MEMREMAP_WB); if (vaddr =3D=3D NULL) { pr_warn("Failed to ioremap gnttab share frames (addr=3D%pa)!\n", &addr); @@ -751,7 +751,7 @@ int gnttab_setup_auto_xlat_frames(phys_addr_t addr) } pfn =3D kcalloc(max_nr_gframes, sizeof(pfn[0]), GFP_KERNEL); if (!pfn) { - xen_unmap(vaddr); + memunmap(vaddr); return -ENOMEM; } for (i =3D 0; i < max_nr_gframes; i++) @@ -770,7 +770,7 @@ void gnttab_free_auto_xlat_frames(void) if (!xen_auto_xlat_grant_frames.count) return; kfree(xen_auto_xlat_grant_frames.pfn); - xen_unmap(xen_auto_xlat_grant_frames.vaddr); + memunmap(xen_auto_xlat_grant_frames.vaddr); =20 xen_auto_xlat_grant_frames.pfn =3D NULL; xen_auto_xlat_grant_frames.count =3D 0; diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_= probe.c index fb5358a73820..23595fdd053d 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -919,8 +919,7 @@ static int __init xenbus_init(void) #endif xen_store_gfn =3D (unsigned long)v; xen_store_interface =3D - xen_remap(xen_store_gfn << XEN_PAGE_SHIFT, - XEN_PAGE_SIZE); + memremap(xen_store_gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE, MEMREMAP_WB); break; default: pr_warn("Xenstore state unknown\n"); diff --git a/include/xen/arm/page.h b/include/xen/arm/page.h index ac1b65470563..f831cfeca000 100644 --- a/include/xen/arm/page.h +++ b/include/xen/arm/page.h @@ -109,9 +109,6 @@ static inline bool set_phys_to_machine(unsigned long pf= n, unsigned long mfn) return __set_phys_to_machine(pfn, mfn); } =20 -#define xen_remap(cookie, size) ioremap_cache((cookie), (size)) -#define xen_unmap(cookie) iounmap((cookie)) - bool xen_arch_need_swiotlb(struct device *dev, phys_addr_t phys, dma_addr_t dev_addr); --=20 2.51.0 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech