arm64: Set PXN/UXN attributes for uncached mem
The attributes should be set to avoid speculative access to memory-mapped
peripherals.

The patch has been tested with:

noinline unsigned long nox(void)
{
	return get_pc();
}

static void xn_test(void)
{
	void *adr = (void *)SOME_SRAM_ADDRESS;
	unsigned long ret;
	unsigned long (*fn)(void) = adr;

	memcpy(adr, nox, 0x1000);

	sync_caches_for_execution();

	ret = fn();
	printf("pc: 0x%08lx\n", ret);
}

Without this patch nox() gets executed in SRAM, with it runs into a
abort as expected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent b5e57a4 commit a2481d09aa76bf50da6d9ce0b5607920988fccac
@Sascha Hauer Sascha Hauer authored on 26 Mar 2020
Showing 3 changed files
View
arch/arm/cpu/mmu-early_64.c
View
arch/arm/cpu/mmu_64.c
View
arch/arm/cpu/mmu_64.h