From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/3] arm64: Set PXN/UXN attributes for uncached mem
Date: Tue, 31 Mar 2020 10:33:54 +0200 [thread overview]
Message-ID: <252738c2-dc72-214f-efa8-6ee872ee086a@pengutronix.de> (raw)
In-Reply-To: <20200331080109.24402-3-s.hauer@pengutronix.de>
On 3/31/20 10:01 AM, Sascha Hauer wrote:
> 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>
> ---
> arch/arm/cpu/mmu_64.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/cpu/mmu_64.h b/arch/arm/cpu/mmu_64.h
> index a2a5477569..f5b7624037 100644
> --- a/arch/arm/cpu/mmu_64.h
> +++ b/arch/arm/cpu/mmu_64.h
> @@ -6,7 +6,8 @@
> PTE_BLOCK_AF)
> #define UNCACHED_MEM (PTE_BLOCK_MEMTYPE(MT_DEVICE_nGnRnE) | \
> PTE_BLOCK_OUTER_SHARE | \
> - PTE_BLOCK_AF)
> + PTE_BLOCK_AF | \
> + PTE_BLOCK_UXN)
Don't we need PXN in EL1?
The commit message also speaks of PXN.
Cheers
Ahmad
>
> /*
> * Do it the simple way for now and invalidate the entire tlb
>
--
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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-03-31 8:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 8:01 [PATCH 1/3] ARM64: Setup vectors in all lower execption levels Sascha Hauer
2020-03-31 8:01 ` [PATCH 2/3] ARM64: attribute argument to create_sections() is 64bit Sascha Hauer
2020-03-31 8:01 ` [PATCH 3/3] arm64: Set PXN/UXN attributes for uncached mem Sascha Hauer
2020-03-31 8:33 ` Ahmad Fatoum [this message]
2020-03-31 9:01 ` Sascha Hauer
2020-03-31 9:20 ` Sascha Hauer
2020-03-31 10:10 ` Ahmad Fatoum
2020-03-31 10:12 ` [PATCH v2] " Sascha Hauer
2020-03-31 10:18 ` Sascha Hauer
2020-03-31 10:17 ` Sascha Hauer
2020-03-31 10:27 ` Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=252738c2-dc72-214f-efa8-6ee872ee086a@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox