Files
erofs-linux/include/uapi/linux
Naman Jain 404cd6bffe mshv_vtl: Fix vmemmap_shift exceeding MAX_FOLIO_ORDER
When registering VTL0 memory via MSHV_ADD_VTL0_MEMORY, the kernel
computes pgmap->vmemmap_shift as the number of trailing zeros in the
OR of start_pfn and last_pfn, intending to use the largest compound
page order both endpoints are aligned to.

However, this value is not clamped to MAX_FOLIO_ORDER, so a
sufficiently aligned range (e.g. physical range
[0x800000000000, 0x800080000000), corresponding to start_pfn=0x800000000
with 35 trailing zeros) can produce a shift larger than what
memremap_pages() accepts, triggering a WARN and returning -EINVAL:

  WARNING: ... memremap_pages+0x512/0x650
  requested folio size unsupported

The MAX_FOLIO_ORDER check was added by
commit 646b67d575 ("mm/memremap: reject unreasonable folio/compound
page sizes in memremap_pages()").

Fix this by clamping vmemmap_shift to MAX_FOLIO_ORDER so we always
request the largest order the kernel supports, in those cases, rather
than an out-of-range value.

Also fix the error path to propagate the actual error code from
devm_memremap_pages() instead of hard-coding -EFAULT, which was
masking the real -EINVAL return.

Fixes: 7bfe3b8ea6 ("Drivers: hv: Introduce mshv_vtl driver")
Cc: [email protected]
Signed-off-by: Naman Jain <[email protected]>
Reviewed-by: Michael Kelley <[email protected]>
Signed-off-by: Wei Liu <[email protected]>
2026-04-14 04:44:31 +00:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-01-18 11:22:53 -05:00
…
…
2025-10-28 22:59:19 +01:00
…
…
…
…
2025-11-25 19:20:42 -08:00
…
…
…
…
2025-09-05 09:11:28 +02:00
…
2025-11-24 17:52:11 +01:00
2025-11-24 17:52:11 +01:00
…
…
…
…
…
…
…
…
…
…
2025-11-29 21:39:58 +09:00
…
…
…
2025-12-23 12:29:14 +05:30
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-09-15 14:32:54 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-01-12 16:52:09 +01:00
…
…
2025-07-08 12:39:24 +02:00
…
…
…
…
…
…
…
2026-01-16 19:21:40 +01:00
…
2026-02-06 20:35:06 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-11-03 17:41:18 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-10-30 14:25:14 +01:00
…
…
…
…
…
…
…
…
…
…
2025-11-25 19:20:42 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-01-26 19:07:10 -08:00
…
…
…
2025-07-14 18:41:42 -07:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2025-06-19 14:28:22 +02:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2026-02-09 12:21:32 -05:00
…
…
2025-09-22 09:29:28 +01:00
2025-11-30 18:02:43 -05:00
2025-09-22 09:29:29 +01:00
…
…
…
…
…
…