x86/hyperv: Use memremap()/memunmap() instead of ioremap_cache()/iounmap()
authorMichael Kelley <mhklinux@outlook.com>
Mon, 19 Jan 2026 15:59:37 +0000 (07:59 -0800)
committerWei Liu <wei.liu@kernel.org>
Wed, 4 Feb 2026 06:29:45 +0000 (06:29 +0000)
commit5ed8cbcaccc0e0ed90e03dac153d01d5b13f6724
tree67035fd30d0a7e1c706868e4f805b04087b2a930
parent0236e75df4d0802a23e3c8d794dbce329cd34a60
x86/hyperv: Use memremap()/memunmap() instead of ioremap_cache()/iounmap()

When running with a paravisor and SEV-SNP, the GHCB page is provided
by the paravisor instead of being allocated by Linux. The provided page
is normal memory, but is outside of the physical address space seen by
Linux. As such it cannot be accessed via the kernel's direct map, and
must be explicitly mapped to a kernel virtual address.

Current code uses ioremap_cache() and iounmap() to map and unmap the page.
These functions are for use on I/O address space that may not behave as
normal memory, so they generate or expect addresses with the __iomem
attribute. For normal memory, the preferred functions are memremap() and
memunmap(), which operate similarly but without __iomem.

At the time of the original work on CoCo VMs on Hyper-V, memremap() did not
support creating a decrypted mapping, so ioremap_cache() was used instead,
since I/O address space is always mapped decrypted. memremap() has since
been enhanced to allow decrypted mappings, so replace ioremap_cache() with
memremap() when mapping the GHCB page. Similarly, replace iounmap() with
memunmap(). As a side benefit, the replacement cleans up 'sparse' warnings
about __iomem mismatches.

The replacement is done to use the correct functions as long-term goodness
and to clean up the sparse warnings. No runtime bugs are fixed.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311111925.iPGGJik4-lkp@intel.com/
Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
arch/x86/hyperv/hv_init.c