Skip to content

Commit 41925b1

Browse files
committed
xen: replace xen_remap() with memremap()
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 <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Acked-by: Stefano Stabellini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent 0a19bab commit 41925b1

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

arch/x86/include/asm/xen/page.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ unsigned long arbitrary_virt_to_mfn(void *vaddr);
347347
void make_lowmem_page_readonly(void *vaddr);
348348
void make_lowmem_page_readwrite(void *vaddr);
349349

350-
#define xen_remap(cookie, size) ioremap((cookie), (size))
351-
#define xen_unmap(cookie) iounmap((cookie))
352-
353350
static inline bool xen_arch_need_swiotlb(struct device *dev,
354351
phys_addr_t phys,
355352
dma_addr_t dev_addr)

drivers/tty/hvc/hvc_xen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static int xen_hvm_console_init(void)
253253
if (r < 0 || v == 0)
254254
goto err;
255255
gfn = v;
256-
info->intf = xen_remap(gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE);
256+
info->intf = memremap(gfn << XEN_PAGE_SHIFT, XEN_PAGE_SIZE, MEMREMAP_WB);
257257
if (info->intf == NULL)
258258
goto err;
259259
info->vtermno = HVC_COOKIE;

drivers/xen/grant-table.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,15 @@ int gnttab_setup_auto_xlat_frames(phys_addr_t addr)
632632
if (xen_auto_xlat_grant_frames.count)
633633
return -EINVAL;
634634

635-
vaddr = xen_remap(addr, XEN_PAGE_SIZE * max_nr_gframes);
635+
vaddr = memremap(addr, XEN_PAGE_SIZE * max_nr_gframes, MEMREMAP_WB);
636636
if (vaddr == NULL) {
637637
pr_warn("Failed to ioremap gnttab share frames (addr=%pa)!\n",
638638
&addr);
639639
return -ENOMEM;
640640
}
641641
pfn = kcalloc(max_nr_gframes, sizeof(pfn[0]), GFP_KERNEL);
642642
if (!pfn) {
643-
xen_unmap(vaddr);
643+
memunmap(vaddr);
644644
return -ENOMEM;
645645
}
646646
for (i = 0; i < max_nr_gframes; i++)
@@ -659,7 +659,7 @@ void gnttab_free_auto_xlat_frames(void)
659659
if (!xen_auto_xlat_grant_frames.count)
660660
return;
661661
kfree(xen_auto_xlat_grant_frames.pfn);
662-
xen_unmap(xen_auto_xlat_grant_frames.vaddr);
662+
memunmap(xen_auto_xlat_grant_frames.vaddr);
663663

664664
xen_auto_xlat_grant_frames.pfn = NULL;
665665
xen_auto_xlat_grant_frames.count = 0;

drivers/xen/xenbus/xenbus_probe.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,8 @@ static void xenbus_probe(void)
752752
xenstored_ready = 1;
753753

754754
if (!xen_store_interface) {
755-
xen_store_interface = xen_remap(xen_store_gfn << XEN_PAGE_SHIFT,
756-
XEN_PAGE_SIZE);
755+
xen_store_interface = memremap(xen_store_gfn << XEN_PAGE_SHIFT,
756+
XEN_PAGE_SIZE, MEMREMAP_WB);
757757
/*
758758
* Now it is safe to free the IRQ used for xenstore late
759759
* initialization. No need to unbind: it is about to be
@@ -1009,8 +1009,8 @@ static int __init xenbus_init(void)
10091009
#endif
10101010
xen_store_gfn = (unsigned long)v;
10111011
xen_store_interface =
1012-
xen_remap(xen_store_gfn << XEN_PAGE_SHIFT,
1013-
XEN_PAGE_SIZE);
1012+
memremap(xen_store_gfn << XEN_PAGE_SHIFT,
1013+
XEN_PAGE_SIZE, MEMREMAP_WB);
10141014
if (xen_store_interface->connection != XENSTORE_CONNECTED)
10151015
wait = true;
10161016
}

include/xen/arm/page.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
109109
return __set_phys_to_machine(pfn, mfn);
110110
}
111111

112-
#define xen_remap(cookie, size) ioremap_cache((cookie), (size))
113-
#define xen_unmap(cookie) iounmap((cookie))
114-
115112
bool xen_arch_need_swiotlb(struct device *dev,
116113
phys_addr_t phys,
117114
dma_addr_t dev_addr);

0 commit comments

Comments
 (0)