From: Sascha Hauer <sha@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 12/18] ARM64: mmu: add dynamic optee memory mapping support
Date: Thu, 18 Jan 2024 11:17:05 +0100 [thread overview]
Message-ID: <20240118101705.GM4700@pengutronix.de> (raw)
In-Reply-To: <20240118091343.r25gx5nrids2mgpd@pengutronix.de>
On Thu, Jan 18, 2024 at 10:13:43AM +0100, Marco Felsch wrote:
> On 24-01-17, Sascha Hauer wrote:
> > On Tue, Jan 16, 2024 at 06:07:32PM +0100, Marco Felsch wrote:
> > > Use the dynamic optee memory base address for the early mapping if
> > > possible and fallback to the static mapping if the query failed.
> > >
> > > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> > > ---
> > > arch/arm/cpu/mmu_64.c | 14 ++++++++++++--
> > > arch/arm/mach-imx/esdctl.c | 4 ++++
> > > common/Makefile | 2 +-
> > > 3 files changed, 17 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
> > > index 84f45bc2c3c1..27fd15ea1233 100644
> > > --- a/arch/arm/cpu/mmu_64.c
> > > +++ b/arch/arm/cpu/mmu_64.c
> > > @@ -20,6 +20,7 @@
> > > #include <memory.h>
> > > #include <asm/system_info.h>
> > > #include <linux/pagemap.h>
> > > +#include <tee/optee.h>
> > >
> > > #include "mmu_64.h"
> > >
> > > @@ -310,6 +311,7 @@ static void init_range(size_t total_level0_tables)
> > > void mmu_early_enable(unsigned long membase, unsigned long memsize)
> > > {
> > > int el;
> > > + u64 optee_membase;
> > > unsigned long ttb = arm_mem_ttb(membase + memsize);
> > >
> > > pr_debug("enabling MMU, ttb @ 0x%08lx\n", ttb);
> > > @@ -326,8 +328,16 @@ void mmu_early_enable(unsigned long membase, unsigned long memsize)
> > > * Set 1:1 mapping of VA->PA. So to cover the full 1TB range we need 2 tables.
> > > */
> > > init_range(2);
> > > - early_remap_range(membase, memsize - OPTEE_SIZE, MAP_CACHED);
> > > - early_remap_range(membase + memsize - OPTEE_SIZE, OPTEE_SIZE, MAP_FAULT);
> > > +
> > > + if (optee_get_membase(&optee_membase)) {
> > > + /* Fallback and place OP-TEE at the memory end region */
> > > + early_remap_range(membase, memsize - OPTEE_SIZE, MAP_CACHED);
> > > + early_remap_range(membase + memsize - OPTEE_SIZE, OPTEE_SIZE, MAP_FAULT);
> > > + } else {
> > > + early_remap_range(membase, memsize, MAP_CACHED);
> > > + early_remap_range(optee_membase, OPTEE_SIZE, MAP_FAULT);
> > > + }
> >
> > You could replace the above with:
> >
> > early_remap_range(membase, memsize, MAP_CACHED);
> >
> > optee_membase = membase + memsize - OPTEE_SIZE;
> > optee_get_membase(&optee_membase);
> > early_remap_range(optee_membase, OPTEE_SIZE, MAP_FAULT);
>
> Nice catch, thanks a lot. How about:
>
> early_remap_range(membase, memsize, MAP_CACHED);
>
> if (optee_get_membase(&optee_membase))
> optee_membase = membase + memsize - OPTEE_SIZE;
> early_remap_range(optee_membase, OPTEE_SIZE, MAP_FAULT);
Also fine.
Sascha
--
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 |
next prev parent reply other threads:[~2024-01-18 10:18 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 17:07 [PATCH v2 00/18] Dynamic OP-TEE Loading Marco Felsch
2024-01-16 17:07 ` [PATCH v2 01/18] ARM: i.MX8M: atf: make use of imx8m*_save_bootrom_log macros Marco Felsch
2024-01-16 17:07 ` [PATCH v2 02/18] ARM: i.MX8M: bundle imx-scratch code Marco Felsch
2024-01-17 14:36 ` Sascha Hauer
2024-01-18 9:11 ` Marco Felsch
2024-01-18 10:16 ` Sascha Hauer
2024-01-16 17:07 ` [PATCH v2 03/18] ARM: i.MX8M: scratch: make imx_scratch_space private Marco Felsch
2024-01-16 17:07 ` [PATCH v2 04/18] ARM: i.MX8M: romapi: refactor saving the bootrom log Marco Felsch
2024-01-16 17:07 ` [PATCH v2 05/18] ARM: i.MX8M: scratch: add optee_hdr area Marco Felsch
2024-01-17 15:00 ` Sascha Hauer
2024-01-18 9:07 ` Marco Felsch
2024-01-16 17:07 ` [PATCH v2 06/18] common: limit BOOTM_OPTEE to 32bit systems Marco Felsch
2024-01-16 17:07 ` [PATCH v2 07/18] common: add OPTEE_SHM_SIZE to configure optee shared memory Marco Felsch
2024-01-16 17:07 ` [PATCH v2 08/18] optee: add support to verify 64-bit headers as well Marco Felsch
2024-01-16 17:07 ` [PATCH v2 09/18] optee: add header version check Marco Felsch
2024-01-16 17:07 ` [PATCH v2 10/18] optee: add helper functions to set/get the optee memory base Marco Felsch
2024-01-16 17:07 ` [PATCH v2 11/18] optee: optee_verify_header: constify optee_header Marco Felsch
2024-01-16 17:07 ` [PATCH v2 12/18] ARM64: mmu: add dynamic optee memory mapping support Marco Felsch
2024-01-17 14:33 ` Sascha Hauer
2024-01-18 9:13 ` Marco Felsch
2024-01-18 10:17 ` Sascha Hauer [this message]
2024-01-16 17:07 ` [PATCH v2 13/18] ARM: i.MX8M: add dynamic optee memory of-fixup support Marco Felsch
2024-01-16 17:07 ` [PATCH v2 14/18] drivers: tee: optee: add support for dynamic optee memory base address Marco Felsch
2024-01-16 17:07 ` [PATCH v2 15/18] ARM: i.MX8M: atf: add support for optee hdr parsing Marco Felsch
2024-01-16 17:07 ` [PATCH v2 16/18] ARM: i.MX8M: allow board code to configure the bl33 loadaddr Marco Felsch
2024-01-16 17:07 ` [PATCH v2 17/18] ARM: i.MX8M: cleanup MX8M*_ATF_BL33_BASE_ADDR defines Marco Felsch
2024-01-16 17:07 ` [PATCH v2 18/18] ARM: i.MX8M: fix optee of-fixup logic Marco Felsch
2024-01-18 15:30 ` Sascha Hauer
2024-01-18 16:52 ` Marco Felsch
2024-01-19 8:02 ` [PATCH v2 00/18] Dynamic OP-TEE Loading Sascha Hauer
2024-01-19 8:09 ` Sascha Hauer
2024-01-19 8:20 ` Marco Felsch
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=20240118101705.GM4700@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@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