On Thu, Nov 09, 2023 at 04:29:46PM +0100, Ahmad Fatoum wrote: > Testing zero_page_access only makes sense if we actually have RAM at > address 0 that we may read from. If it happens to I/O memory, the SoC > may hang or a data abort may be raised, which would make the test fail. > > Avoid this by explicitly checking for that case and skipping the test > without running. > > Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> > --- > test/self/mmu.c | 33 ++++++++++++++++++++++++++++++--- > 1 file changed, 30 insertions(+), 3 deletions(-) Applied, thanks Sascha > > diff --git a/test/self/mmu.c b/test/self/mmu.c > index ca58d718ffb3..58961daaab95 100644 > --- a/test/self/mmu.c > +++ b/test/self/mmu.c > @@ -9,6 +9,7 @@ > #include <abort.h> > #include <zero_page.h> > #include <linux/sizes.h> > +#include <memory.h> > > #define TEST_BUFFER_SIZE SZ_1M > #define TEST_BUFFER_ALIGN SZ_4K > @@ -171,6 +172,34 @@ static void test_remap(void) > free(mirror); > } > > +static bool zero_page_access_ok(void) > +{ > + struct memory_bank *bank; > + const char *reason; > + struct resource null_res = { > + .name = "null", > + .flags = IORESOURCE_MEM, > + .start = 0, > + .end = sizeof(int) - 1, > + }; > + > + if (!IS_ENABLED(CONFIG_ARCH_HAS_ZERO_PAGE)) { > + reason = "CONFIG_ARCH_HAS_ZERO_PAGE=n"; > + goto not_ok; > + } > + > + for_each_memory_bank(bank) { > + if (resource_contains(bank->res, &null_res)) > + return true; > + } > + > + reason = "no memory at address zero"; > + > +not_ok: > + pr_info("skipping rest of zero page tests because %s\n", reason); > + return false; > +} > + > static void test_zero_page(void) > { > void __iomem *null = NULL; > @@ -197,9 +226,7 @@ static void test_zero_page(void) > failed_tests++; > } > > - if (!IS_ENABLED(CONFIG_ARCH_HAS_ZERO_PAGE)) { > - pr_info("skipping %s because %s=n\n", > - "CONFIG_ARCH_HAS_ZERO_PAGE", __func__); > + if (!zero_page_access_ok()) { > skipped_tests += 2; > return; > } > -- > 2.39.2 > > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |