mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org, rcz@pengutronix.de
Subject: Re: [PATCH 03/10] memory: define reserve_sdram_region helper
Date: Tue, 16 Aug 2022 10:46:42 +0200	[thread overview]
Message-ID: <20220816084642.GL17485@pengutronix.de> (raw)
In-Reply-To: <20220815153209.2422662-4-a.fatoum@pengutronix.de>

On Mon, Aug 15, 2022 at 05:32:02PM +0200, Ahmad Fatoum wrote:
> We use request_sdram_regions both for code that barebox wants to use for
> itself (e.g. barebox stack or initrd) and to reserve regions for secure
> firmware that barebox shouldn't overwrite. We need to differentiate
> between them, so we can apply difference caching flags depending on

s/difference/different/

Sascha

> region, so add a new reserve_sdram_region helper that may be used and
> also add an for_each_reserved_region iterator for use in the MMU code
> that applied the different caching flags later on.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  include/memory.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/memory.h b/include/memory.h
> index 31da5d74d568..ffd66db02ba0 100644
> --- a/include/memory.h
> +++ b/include/memory.h
> @@ -4,6 +4,7 @@
>  
>  #include <linux/types.h>
>  #include <linux/list.h>
> +#include <linux/ioport.h>
>  
>  void mem_malloc_init(void *start, void *end);
>  ulong mem_malloc_start(void);
> @@ -22,6 +23,9 @@ int barebox_add_memory_bank(const char *name, resource_size_t start,
>  				    resource_size_t size);
>  
>  #define for_each_memory_bank(mem)	list_for_each_entry(mem, &memory_banks, list)
> +#define for_each_reserved_region(mem, rsv) \
> +	list_for_each_entry(rsv, &(mem)->res->children, sibling) \
> +	if (((rsv)->flags & IORESOURCE_BUSY))
>  
>  struct resource *__request_sdram_region(const char *name, unsigned flags,
>  					resource_size_t start, resource_size_t size);
> @@ -34,6 +38,14 @@ static inline struct resource *request_sdram_region(const char *name,
>  	return __request_sdram_region(name, 0, start, size);
>  }
>  
> +/* use for secure firmware to inhibit speculation */
> +static inline struct resource *reserve_sdram_region(const char *name,
> +						    resource_size_t start,
> +						    resource_size_t size)
> +{
> +	return __request_sdram_region(name, IORESOURCE_BUSY, start, size);
> +}
> +
>  int release_sdram_region(struct resource *res);
>  
>  void memory_bank_find_space(struct memory_bank *bank, resource_size_t *retstart,
> -- 
> 2.30.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 |



  reply	other threads:[~2022-08-16  8:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 15:31 [PATCH 00/10] ARM: mmu: inhibit speculation into secure memory Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 01/10] resource: add flags parameter to __request_region Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 02/10] common: allow requesting SDRAM regions with custom flags Ahmad Fatoum
2022-08-16  7:35   ` Ulrich Ölmann
2022-08-15 15:32 ` [PATCH 03/10] memory: define reserve_sdram_region helper Ahmad Fatoum
2022-08-16  8:46   ` Sascha Hauer [this message]
2022-08-15 15:32 ` [PATCH 04/10] init: define new postmem_initcall() Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 05/10] of: reserved-mem: reserve regions prior to mmu_initcall() Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 06/10] ARM: mmu64: map reserved regions uncached Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 07/10] ARM: mmu: define attrs_uncached_mem() helper Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 08/10] ARM: mmu: use reserve mem entries to modify maps Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 09/10] ARM: early-mmu: don't cache/prefetch OPTEE_SIZE bytes from end of memory Ahmad Fatoum
2022-08-15 15:32 ` [PATCH 10/10] commands: iomem: point out [R]eserved regions 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=20220816084642.GL17485@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rcz@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