From nobody Wed Oct 8 04:19:40 2025 Received: from mail187-29.suw11.mandrillapp.com (mail187-29.suw11.mandrillapp.com [198.2.187.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49A5B223339 for ; Wed, 2 Jul 2025 09:48:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.2.187.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751449730; cv=none; b=Pn9PK3aQTKJ6Q9ymSAfbLl14+GfsChJ/BONUImwUFWlRUbQRLmwMMaCn7jcjHGENL3x8iYAGVsAY1qWAFlZcCz9gUOyLvXd0AWGLR7s/bAl3a8PoPdR/SrpDoyez1vroAuOLquhE381Xjgww93dFVNVTSx5RsOtVPkmAT8ohPsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751449730; c=relaxed/simple; bh=ISdpG1QNUqMvPpZim7SIb2eWx2VudgLouDOUPZqGh+0=; h=From:Subject:To:Cc:Message-Id:Date:MIME-Version:Content-Type; b=p+nvbgnIlxqRpG+NIEdkrMqbH5LW4hlxWezEpDhJ5JY9mRUo1ATlizasQxRUSa9YeqOiLx8SBxTIR+hQOeHC3GPpn7+Rw86Gu6AvK28pKOw084si4kgOggL66oWqzzisj88wNMT3P5Q1cqfrNmwUWXCsj4VV2aTPfRsNr8PLEt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=vates.tech; spf=pass smtp.mailfrom=bounce.vates.tech; dkim=pass (2048-bit key) header.d=mandrillapp.com header.i=@mandrillapp.com header.b=w/V5op1H; dkim=pass (2048-bit key) header.d=vates.tech header.i=teddy.astie@vates.tech header.b=oIqyzEIn; arc=none smtp.client-ip=198.2.187.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=vates.tech Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bounce.vates.tech Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mandrillapp.com header.i=@mandrillapp.com header.b="w/V5op1H"; dkim=pass (2048-bit key) header.d=vates.tech header.i=teddy.astie@vates.tech header.b="oIqyzEIn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1751449726; x=1751719726; bh=FHgL1whZVBmBSD9h9bZZ8bhpnADjwgrqmGTO+bcYsPU=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=w/V5op1HvBY1onsk3VJY+KLX1YcId73hczT4qANYvsTN0lnvWzq3FoDmMb34uEIwG 25gabQQj7LYTCvVcRToV+EgashIYKusRx49SxXjuf8ZvCHKB4gAQf4C3OiQn+LA/KE ei+BAc+uv4ZJmC89WItjiQgcEQ7FuC9b38UgpXzCMi/gbH9kM1I/y85ycnL//cCl6Z 0xbFhKYNRp0MYDGxIdrb7lgK40+bJErNzsCLHeUwSHuSahAdjBakBWJQMHKtQHqyoA dsRdu+l+J0U+Y/FYSPj1bi3RvQULiDr/dilxAE3thY026C0YfCihtbmaVBR6W4HGUl teKs4lBWXsnpA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1751449726; x=1751710226; i=teddy.astie@vates.tech; bh=FHgL1whZVBmBSD9h9bZZ8bhpnADjwgrqmGTO+bcYsPU=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=oIqyzEInM3vSn0bb7p/5THfq2VmR3h/6Q/ix9k8avxhQq1gdYm7l+NXcAAbqfx0eU pE3Y7B1BX4SEr1HjSnAsOXDmnrsLfPWrBBkGyXkECH964jK+zo1G6HjmoyMydhaMaS omEyS1M7OLMzMxBzlrAalT5uZIWmBJdoRSkLIGY0UiVw55N7PfgGmq+FJHiS1Ko/qL 3ukhOOXSQpm6SRyUNLvH47sSqq45BXCI1JVTOybo7erL1XDAidgWAFvkk+JhMiskMd iq1U0lLW4PjmgHJ9vmPpcXV+arviHXY2UQoyV5BS1b/DShpaqTn8Fvcv/cHi/q8vCZ BBDKR/2OR8Xfw== Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-29.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4bXFTV1p1Fz7lmgWY for ; Wed, 2 Jul 2025 09:48:46 +0000 (GMT) From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=205.15.y=20v2]=20xen:=20replace=20xen=5Fremap()=20with=20memremap()?= Received: from [37.26.189.201] by mandrillapp.com id 1345525288b54e389c5d6931b119a54f; Wed, 02 Jul 2025 09:48:46 +0000 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: 1751449724214 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: <816ab25650e06a5fb51c5a51ec0108aa2238271a.1751449523.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.1345525288b54e389c5d6931b119a54f?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250702:md Date: Wed, 02 Jul 2025 09:48:46 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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] --- v2: - also remove xen_remap/xen_unmap on ARM --- arch/x86/include/asm/xen/page.h | 3 --- drivers/xen/grant-table.c | 6 +++--- drivers/xen/xenbus/xenbus_probe.c | 3 +-- include/xen/arm/page.h | 3 --- 4 files changed, 4 insertions(+), 11 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/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