target/arm: Correctly handle overlapping small MPU regions
commit9d2b5a58f85be2d8e129c4b53d6708ecf8796e54
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 23 Jul 2018 14:21:26 +0000 (23 15:21 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 23 Jul 2018 14:21:26 +0000 (23 15:21 +0100)
treec306bdb8e833f685597570ecae46b3cdfb2c70cb
parent03a31776e8fb239fee98625dd83b85f5cbe3ccba
target/arm: Correctly handle overlapping small MPU regions

To correctly handle small (less than TARGET_PAGE_SIZE) MPU regions,
we must correctly handle the case where the address being looked
up hits in an MPU region that is not small but the address is
in the same page as a small region. For instance if MPU region
1 covers an entire page from 0x2000 to 0x2400 and MPU region
2 is small and covers only 0x2200 to 0x2280, then for an access
to 0x2000 we must not return a result covering the full page
even though we hit the page-sized region 1. Otherwise we will
then cache that result in the TLB and accesses that should
hit region 2 will incorrectly find the region 1 information.

Check for the case where we miss an MPU region but it is still
within the same page, and in that case narrow the size we will
pass to tlb_set_page_with_attrs() for whatever the final
outcome is of the MPU lookup.

Reported-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20180716133302.25989-1-peter.maydell@linaro.org
target/arm/helper.c