From nobody Tue Oct 7 23:01:43 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=1751633400; cv=none; d=zohomail.com; s=zohoarc; b=RFa8hoOI/UA0A1o3DNnoz/AKnstKHgR7DQf0ewIUraR2qXwA/y5Cb9f9Hj6toE83OUjF0fAAYsZWz2khOf3BjnFdwfFp3165RqqSl3RRdZqPMFOwe9AT2OKefeIDgYh04Yg7q/GWHQvm30kxZzMszhASGZZrJ3Wt1mLxJY+S+w0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751633400; 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=tt0oM0tqOxl3axHhNxXYGkg2bRs4dsH6dn0uDyBVvW8=; b=DM8aCHpd1Q7Y2kjn3cUgK9MKQCqIwlBcr7UD5HoBY+fAsTFWrRmGWFnABx5IlFNy7YVlxM32y+ZYAEZASyPKkcZVYt/AKjzrKLw/gYQFGzWKzN7mGrDr2GT/FB+Ey93TEXtWhJb1BudZZ3PbBeNJLPTY+cIEthbLTuj8fs7NCzk= 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 1751633400466228.2977482784679; Fri, 4 Jul 2025 05:50:00 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1033372.1406775 (Exim 4.92) (envelope-from ) id 1uXfr7-00066O-2K; Fri, 04 Jul 2025 12:49:29 +0000 Received: by outflank-mailman (output) from mailman id 1033372.1406775; Fri, 04 Jul 2025 12:49:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uXfr6-00066H-VW; Fri, 04 Jul 2025 12:49:28 +0000 Received: by outflank-mailman (input) for mailman id 1033372; Fri, 04 Jul 2025 12:49:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uXfr5-00066B-KJ for xen-devel@lists.xenproject.org; Fri, 04 Jul 2025 12:49:27 +0000 Received: from mail135-23.atl141.mandrillapp.com (mail135-23.atl141.mandrillapp.com [198.2.135.23]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4da0a144-58d5-11f0-b894-0df219b8e170; Fri, 04 Jul 2025 14:49:20 +0200 (CEST) Received: from pmta14.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail135-23.atl141.mandrillapp.com (Mailchimp) with ESMTP id 4bYYNv26kBz35j3lX for ; Fri, 4 Jul 2025 12:49:19 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 4d9f154c666f4dc68183ed5fc006f81e; Fri, 04 Jul 2025 12:49:19 +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: 4da0a144-58d5-11f0-b894-0df219b8e170 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1751633359; x=1751903359; bh=tt0oM0tqOxl3axHhNxXYGkg2bRs4dsH6dn0uDyBVvW8=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=UtYtt2DHL8jHnIaR4MLf5CQeeheH0VTv4YttLG5A5LGCPGWJ6/OS1/rrCVNQKKTVm fPEVC2xB1iuUsl0Tz5IN8if1Mg0OxR4CWcShaESQ4rzBZte5b0Lxvi1zaHOyL057vl wwq3lMtCMwuWZC2EJpJQkKE+fqEZWt9Y4+P9bqjcLCCQyxHNRjQouCAMNCb9+8T7L0 qF4HFTl+y5KCLZUpDtl6B6g/GGhouu9VNak8u9/BqB08Z3l9ZLVIVLQyUOodBrG7om uIbMPeyt4Dwaeen/Rs8JjKerF2cV745+EE6qOqGZf/HRZBg0+cwfrye+NXNLkq3EuU YMDS+Ud6JRcSg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1751633359; x=1751893859; i=teddy.astie@vates.tech; bh=tt0oM0tqOxl3axHhNxXYGkg2bRs4dsH6dn0uDyBVvW8=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=VBcFSLCEE/g/EjBMS1yoTvh5L5CyKxv+cR0sOgaG/o3ku91fMj+n4944ODX5p9/w7 jQPEpzxB2Q8nnfI8vgHjp+sHhu/GSR0azPEaVRiFHMMwfSshqwg8NFUyL3zdy+qkp4 dPbRCNbDjVmSQ2Tptaqh7WSWgKN79IWGgCuZkmywFNsrOLKkmOBxPYXB3S60lfGql4 hGEzlk8ArSupxnyoXeroTXRhdSMNcwBK0lH6dk0PRs9GLPLxw+oovM8mSidfriShPX ZvfqiLt4P3nnJxjqKM2OE8FMC1Rbpa27jS+D6azdwYAzjyVBP3VdQKq6Q7gWhE703f ECtcVvOhsMOPw== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=205.15.y=20v3]=20xen:=20replace=20xen=5Fremap()=20with=20memremap()?= X-Mailer: git-send-email 2.50.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1751633357597 To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Boris Ostrovsky" , "Juergen Gross" , "Stefano Stabellini" , "Greg Kroah-Hartman" , "Sasha Levin" , "Jason Andryuk" , stable@vger.kernel.org, "kernel test robot" Message-Id: 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.4d9f154c666f4dc68183ed5fc006f81e?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250704:md Date: Fri, 04 Jul 2025 12:49:19 +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: 1751633401725116600 Content-Type: text/plain; charset="utf-8" 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.15.y] --- v3: - add missing hvc_xen.c change v2: - also remove xen_remap/xen_unmap on ARM --- 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 1a162e559753..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 141acc662eba..6a11a4177a16 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 2068f83556b7..77ca24611293 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -982,8 +982,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.50.0 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech