Pierre-Clément Tosi 4b36f01201 arm64: Fix map_range() not splitting mapped blocks
The implementation of map_range() creates the requested mapping by
walking the page tables, iterating over multiple PTEs and/or descending
into existing table mappings as needed. When doing so, it assumes any
pre-existing valid PTE to be a table mapping. This assumption is wrong
if the platform code attempts to successively map two overlapping ranges
where the latter intersects a block mapping created for the former.

As a result, map_range() treats the existing block mapping as a table
mapping and descends into it i.e. starts interpreting the
previously-mapped range as an array of PTEs, writing to them and
potentially even descending further (extra fun with MMIO ranges!).

Instead, pass any valid non-table mapping to split_block(), which
ensures that it actually was a block mapping (calls panic() otherwise)
before splitting it.

Fixes: 41e2787f5ec4 ("arm64: Reduce add_map() complexity")
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Tested-by: Fabio Estevam <festevam@gmail.com>
Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Toradex Verdin AM62
Reviewed-by: Marc Zyngier <maz@kernel.org>
2024-04-10 08:41:00 -06:00
..
2023-04-25 15:31:27 -04:00
2023-03-06 17:03:55 -05:00
2022-04-01 16:56:53 -04:00
2023-01-31 15:46:39 +01:00
2023-01-18 11:49:13 -07:00
2023-06-12 13:24:31 +02:00
2023-02-07 14:33:49 -05:00
2023-01-31 15:46:39 +01:00
2024-02-29 09:24:22 -05:00