xen/arm: acpi: The fixmap area should always be cleared during failure/unmap
authorJulien Grall <jgrall@amazon.com>
Sat, 26 Sep 2020 18:53:27 +0000 (19:53 +0100)
committerHans van Kranenburg <hans@knorrie.org>
Sat, 27 Nov 2021 14:09:48 +0000 (15:09 +0100)
commit0b425b18fad5fa8084daedc9c3e0aed3aebd36b4
tree972bb3f43b6b1fac3b89049aea472cb86531964b
parentac5c3fa9c9c5e6a2c378b5dd62333d4c0c40113e
xen/arm: acpi: The fixmap area should always be cleared during failure/unmap

Commit 022387ee1ad3 "xen/arm: mm: Don't open-code Xen PT update in
{set, clear}_fixmap()" enforced that each set_fixmap() should be
paired with a clear_fixmap(). Any failure to follow the model would
result to a platform crash.

Unfortunately, the use of fixmap in the ACPI code was overlooked as it
is calling set_fixmap() but not clear_fixmap().

The function __acpi_os_map_table() is reworked so:
    - We know before the mapping whether the fixmap region is big
    enough for the mapping.
    - It will fail if the fixmap is already in use. This is not a
    change of behavior but clarifying the current expectation to avoid
    hitting a BUG().

The function __acpi_os_unmap_table() will now call clear_fixmap().

Reported-by: Wei Xu <xuwei5@hisilicon.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
(cherry picked from commit 4d625ff3c3a939dc270b03654337568c30c5ab6e)
xen/arch/arm/acpi/lib.c