Skip to content

Commit aeef8b5

Browse files
JeffMoyerKAGA-KOKO
authored andcommitted
x86/pat: Pass valid address to sanitize_phys()
The end address passed to memtype_reserve() is handed directly to sanitize_phys(). However, end is exclusive and sanitize_phys() expects an inclusive address. If end falls at the end of the physical address space, sanitize_phys() will return 0. This can result in drivers failing to load, and the following warning: WARNING: CPU: 26 PID: 749 at arch/x86/mm/pat.c:354 reserve_memtype+0x262/0x450 reserve_memtype failed: [mem 0x3ffffff00000-0xffffffffffffffff], req uncached-minus Call Trace: [<ffffffffa427b1f2>] reserve_memtype+0x262/0x450 [<ffffffffa42764aa>] ioremap_nocache+0x1a/0x20 [<ffffffffc04620a1>] mpt3sas_base_map_resources+0x151/0xa60 [mpt3sas] [<ffffffffc0465555>] mpt3sas_base_attach+0xf5/0xa50 [mpt3sas] ---[ end trace 6d6eea4438db89ef ]--- ioremap reserve_memtype failed -22 mpt3sas_cm0: unable to map adapter memory! or resource not found mpt3sas_cm0: failure at drivers/scsi/mpt3sas/mpt3sas_scsih.c:10597/_scsih_probe()! Fix this by passing the inclusive end address to sanitize_phys(). Fixes: 510ee09 ("x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses") Signed-off-by: Jeff Moyer <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Dan Williams <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 8596e58 commit aeef8b5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/x86/mm/pat/memtype.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,12 @@ int memtype_reserve(u64 start, u64 end, enum page_cache_mode req_type,
583583
int err = 0;
584584

585585
start = sanitize_phys(start);
586-
end = sanitize_phys(end);
586+
587+
/*
588+
* The end address passed into this function is exclusive, but
589+
* sanitize_phys() expects an inclusive address.
590+
*/
591+
end = sanitize_phys(end - 1) + 1;
587592
if (start >= end) {
588593
WARN(1, "%s failed: [mem %#010Lx-%#010Lx], req %s\n", __func__,
589594
start, end - 1, cattr_name(req_type));

0 commit comments

Comments
 (0)