mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	barebox@lists.infradead.org
Subject: Re: [PATCH 5/8] of: add reserved_mem_read initcall
Date: Tue, 20 Apr 2021 12:36:20 +0200	[thread overview]
Message-ID: <7f1cd016-a20b-b135-29c0-54b7d9811152@pengutronix.de> (raw)
In-Reply-To: <20210420075700.246124-5-r.czerwinski@pengutronix.de>

Hello Rouven,

On 20.04.21 09:56, Rouven Czerwinski wrote:
> Add a reserved_mem_read initcall which parses the reserved-memory
> entries and adds barebox of reserve entries. Also remove the OP-TEE size
> of reserve entry, since this is now parsed from the DT and does not need
> to be statically configured any longer.
> 
> Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
> ---
>  arch/arm/cpu/start.c      |  3 ---
>  drivers/of/Makefile       |  1 +
>  drivers/of/reserved-mem.c | 41 +++++++++++++++++++++++++++++++++++++++
>  3 files changed, 42 insertions(+), 3 deletions(-)
>  create mode 100644 drivers/of/reserved-mem.c
> 
> diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
> index 10ac070fe3..811de056c0 100644
> --- a/arch/arm/cpu/start.c
> +++ b/arch/arm/cpu/start.c
> @@ -226,9 +226,6 @@ __noreturn __no_sanitize_address void barebox_non_pbl_start(unsigned long membas
>  
>  	mem_malloc_init((void *)malloc_start, (void *)malloc_end - 1);
>  
> -	if (IS_ENABLED(CONFIG_BOOTM_OPTEE))
> -		of_add_reserve_entry(endmem - OPTEE_SIZE, endmem - 1, OF_RESERVE_ENTRY_FLAG_XN);
> -

That silently breaks BOOTM_OPTEE, doesn't it? Either this should remain
or CONFIG_OPTEE_SIZE != 0 should loudly complain that people need to put
this into the device tree..

>  	pr_debug("starting barebox...\n");
>  
>  	start_barebox();
> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
> index b6847752d2..749fe16a2a 100644
> --- a/drivers/of/Makefile
> +++ b/drivers/of/Makefile
> @@ -4,6 +4,7 @@ obj-$(CONFIG_OF_GPIO) += of_gpio.o
>  obj-$(CONFIG_OF_PCI) += of_pci.o
>  obj-y += partition.o
>  obj-y += of_net.o
> +obj-y += reserved-mem.o
>  obj-$(CONFIG_MTD) += of_mtd.o
>  obj-$(CONFIG_OF_BAREBOX_DRIVERS) += barebox.o
>  obj-$(CONFIG_OF_OVERLAY) += overlay.o resolver.o of_firmware.o
> diff --git a/drivers/of/reserved-mem.c b/drivers/of/reserved-mem.c
> new file mode 100644
> index 0000000000..ee15ae880c
> --- /dev/null
> +++ b/drivers/of/reserved-mem.c
> @@ -0,0 +1,41 @@
> +#include <common.h>
> +#include <init.h>
> +#include <io.h>
> +#include <of.h>
> +#include <of_address.h>
> +#include <malloc.h>
> +#include <partition.h>
> +
> +static int reserved_mem_read(void)
> +{
> +	struct device_node *node, *child;
> +	struct resource resource;
> +	int flag;
> +
> +	node = of_get_root_node();
> +	if (!node)
> +		return 0;
> +
> +	node = of_find_node_by_path("/reserved-memory");
> +	if (!node)
> +		return 0;
> +
> +	for_each_child_of_node(node, child) {
> +		flag = OF_RESERVE_ENTRY_FLAG_NO_RESERVE;
> +
> +		of_address_to_resource(child, 0, &resource);
> +
> +		pr_err("Res-Mem start: 0x%08x\n", resource.start);
> +		pr_err("Res-Mem end: 0x%08x\n", resource.end);
> +
> +		if(of_find_property(child, "no-map", 0)) {
> +			pr_err("Res-Mem: no-map\n");
> +			flag |= OF_RESERVE_ENTRY_FLAG_XN;
> +		}
> +
> +		of_add_reserve_entry(resource.start, resource.end, flag);
> +	}
> +
> +	return 0;
> +}
> +postconsole_initcall(reserved_mem_read);
> 

-- 
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


  parent reply	other threads:[~2021-04-20 10:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-20  7:56 [PATCH 1/8] of: reserve: add xn flag mem entries Rouven Czerwinski
2021-04-20  7:56 ` [PATCH 2/8] of: export of_get_reserve_map Rouven Czerwinski
2021-04-20  8:47   ` Ahmad Fatoum
2021-04-20  7:56 ` [PATCH 3/8] ARM: mmu: use reserve mem entries to modify maps Rouven Czerwinski
2021-04-20  9:09   ` Ahmad Fatoum
2021-04-20  7:56 ` [PATCH 4/8] of: add flag to not create resmem DT entries Rouven Czerwinski
2021-04-20  9:22   ` Ahmad Fatoum
2021-04-20  7:56 ` [PATCH 5/8] of: add reserved_mem_read initcall Rouven Czerwinski
2021-04-20  9:23   ` Ahmad Fatoum
2021-04-20 10:36   ` Ahmad Fatoum [this message]
2021-04-20  7:56 ` [PATCH 6/8] pbl: fdt: add support to parse reserved mem Rouven Czerwinski
2021-04-20 10:29   ` Ahmad Fatoum
2021-04-20  7:57 ` [PATCH 7/8] ARM: mmu-early: map no-map entries XN & uncached Rouven Czerwinski
2021-04-20  9:00   ` Lucas Stach
2021-04-20  7:57 ` [PATCH 8/8] PBL: enable LIBFDT for OP-TEE early loading Rouven Czerwinski
2021-04-20 10:33   ` Ahmad Fatoum
2021-04-20  8:45 ` [PATCH 1/8] of: reserve: add xn flag mem entries 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=7f1cd016-a20b-b135-29c0-54b7d9811152@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@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