]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
x86/mm/pat: Prevent hang during boot when mapping pages
authorMatt Fleming <matt@codeblueprint.co.uk>
Tue, 20 Sep 2016 13:26:21 +0000 (14:26 +0100)
committerMatt Fleming <matt@codeblueprint.co.uk>
Tue, 20 Sep 2016 13:53:00 +0000 (14:53 +0100)
commite535ec0899d1fe52ec3a84c9bc03457ac67ad6f7
treec200ffeff46430c1413e2b25e7f6cacf9da59c77
parent3be7988674ab33565700a37b210f502563d932e6
x86/mm/pat: Prevent hang during boot when mapping pages

There's a mixture of signed 32-bit and unsigned 32-bit and 64-bit data
types used for keeping track of how many pages have been mapped.

This leads to hangs during boot when mapping large numbers of pages
(multiple terabytes, as reported by Waiman) because those values are
interpreted as being negative.

commit 742563777e8d ("x86/mm/pat: Avoid truncation when converting
cpa->numpages to address") fixed one of those bugs, but there is
another lurking in __change_page_attr_set_clr().

Additionally, the return value type for the populate_*() functions can
return negative values when a large number of pages have been mapped,
triggering the error paths even though no error occurred.

Consistently use 64-bit types on 64-bit platforms when counting pages.
Even in the signed case this gives us room for regions 8PiB
(pebibytes) in size whilst still allowing the usual negative value
error checking idiom.

Reported-by: Waiman Long <waiman.long@hpe.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
CC: Theodore Ts'o <tytso@mit.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Scott J Norton <scott.norton@hpe.com>
Cc: Douglas Hatch <doug.hatch@hpe.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
arch/x86/mm/pageattr.c