Message ID | 1447282212-1818-2-git-send-email-yorksun@freescale.com |
---|---|
State | Superseded |
Headers | show |
Hi York, On 2015年11月12日 06:50, York Sun wrote: > diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h > index d0383f3..336f3a0 100644 > --- a/include/asm-generic/global_data.h > +++ b/include/asm-generic/global_data.h > @@ -58,6 +58,7 @@ typedef struct global_data { > > unsigned long relocaddr; /* Start address of U-Boot in RAM */ > phys_size_t ram_size; /* RAM size */ > + phys_addr_t secure_ram; /* Secure memory addr */ Shouldn't this be included only if CONFIG_SYS_MEM_RESERVE_SECURE ? > unsigned long mon_len; /* monitor len */ > unsigned long irq_sp; /* irq stack pointer */ > unsigned long start_addr_sp; /* start_addr_stackpointer */ Best regards, Thomas
On 11/11/2015 06:17 PM, Thomas Chou wrote: > Hi York, > > On 2015年11月12日 06:50, York Sun wrote: >> diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h >> index d0383f3..336f3a0 100644 >> --- a/include/asm-generic/global_data.h >> +++ b/include/asm-generic/global_data.h >> @@ -58,6 +58,7 @@ typedef struct global_data { >> >> unsigned long relocaddr; /* Start address of U-Boot in RAM */ >> phys_size_t ram_size; /* RAM size */ >> + phys_addr_t secure_ram; /* Secure memory addr */ > > Shouldn't this be included only if CONFIG_SYS_MEM_RESERVE_SECURE ? It can be. It will require checking CONFIG_SYS_MEM_RESERVE_SECURE every time this variable is used. I will add it in next version. Thanks. York
On Wed, 2015-11-11 at 19:34 -0800, York Sun wrote: > > On 11/11/2015 06:17 PM, Thomas Chou wrote: > > Hi York, > > > > On 2015年11月12日 06:50, York Sun wrote: > > > diff --git a/include/asm-generic/global_data.h b/include/asm > > > -generic/global_data.h > > > index d0383f3..336f3a0 100644 > > > --- a/include/asm-generic/global_data.h > > > +++ b/include/asm-generic/global_data.h > > > @@ -58,6 +58,7 @@ typedef struct global_data { > > > > > > unsigned long relocaddr; /* Start address of U-Boot in > > > RAM */ > > > phys_size_t ram_size; /* RAM size */ > > > + phys_addr_t secure_ram; /* Secure memory addr */ > > > > Shouldn't this be included only if CONFIG_SYS_MEM_RESERVE_SECURE ? > > It can be. It will require checking CONFIG_SYS_MEM_RESERVE_SECURE every time > this variable is used. I will add it in next version. Why would that be better than leaving it unifdeffed? -Scott
On 11/11/2015 10:28 PM, Scott Wood wrote: > On Wed, 2015-11-11 at 19:34 -0800, York Sun wrote: >> >> On 11/11/2015 06:17 PM, Thomas Chou wrote: >>> Hi York, >>> >>> On 2015年11月12日 06:50, York Sun wrote: >>>> diff --git a/include/asm-generic/global_data.h b/include/asm >>>> -generic/global_data.h >>>> index d0383f3..336f3a0 100644 >>>> --- a/include/asm-generic/global_data.h >>>> +++ b/include/asm-generic/global_data.h >>>> @@ -58,6 +58,7 @@ typedef struct global_data { >>>> >>>> unsigned long relocaddr; /* Start address of U-Boot in >>>> RAM */ >>>> phys_size_t ram_size; /* RAM size */ >>>> + phys_addr_t secure_ram; /* Secure memory addr */ >>> >>> Shouldn't this be included only if CONFIG_SYS_MEM_RESERVE_SECURE ? >> >> It can be. It will require checking CONFIG_SYS_MEM_RESERVE_SECURE every time >> this variable is used. I will add it in next version. > > Why would that be better than leaving it unifdeffed? Save a few bytes? I prefer not to use ifdef if possible, but I understand some platforms don't want to spare a few bytes. York
diff --git a/README b/README index ef8d437..61cbc82 100644 --- a/README +++ b/README @@ -3881,6 +3881,14 @@ Configuration Settings: Scratch address used by the alternate memory test You only need to set this if address zero isn't writeable +- CONFIG_SYS_MEM_RESERVE_SECURE + If defined, the size of CONFIG_SYS_MEM_RESERVE_SECURE memory + is substracted from total RAM and won't be reported to OS. + This memory can be used as secure memory. A variable + gd->secure_ram is used to track the location. In systems + the RAM base is not zero, or RAM is divided into banks, + this variable needs to be recalcuated to get the address. + - CONFIG_SYS_MEM_TOP_HIDE (PPC only): If CONFIG_SYS_MEM_TOP_HIDE is defined in the board config header, this specified memory area will get subtracted from the top diff --git a/common/board_f.c b/common/board_f.c index 725eb18..8061105 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -323,6 +323,15 @@ static int setup_dest_addr(void) * Ram is setup, size stored in gd !! */ debug("Ram size: %08lX\n", (ulong)gd->ram_size); +#ifdef CONFIG_SYS_MEM_RESERVE_SECURE + /* Reserve memory for secure MMU tables, and/or security monitor */ + gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE; + /* + * Record secure memory location. Need recalcuate if memory splits + * into banks, or the ram base is not zero. + */ + gd->secure_ram = gd->ram_size; +#endif #if defined(CONFIG_SYS_MEM_TOP_HIDE) /* * Subtract specified amount of memory to hide so that it won't diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index d0383f3..336f3a0 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -58,6 +58,7 @@ typedef struct global_data { unsigned long relocaddr; /* Start address of U-Boot in RAM */ phys_size_t ram_size; /* RAM size */ + phys_addr_t secure_ram; /* Secure memory addr */ unsigned long mon_len; /* monitor len */ unsigned long irq_sp; /* irq stack pointer */ unsigned long start_addr_sp; /* start_addr_stackpointer */ diff --git a/include/configs/ls2085a_common.h b/include/configs/ls2085a_common.h index 0011e72..adf132c 100644 --- a/include/configs/ls2085a_common.h +++ b/include/configs/ls2085a_common.h @@ -75,6 +75,12 @@ #define CONFIG_SYS_FSL_DDR_MAIN_NUM_CTRLS 2 /* + * Reserve secure memory + * To be aligned with MMU block size + */ +#define CONFIG_SYS_MEM_RESERVE_SECURE (2048 * 1024) /* 2MB */ + +/* * SMP Definitinos */ #define CPU_RELEASE_ADDR secondary_boot_func
Secure memory is at the end of memory, separated and reserved from OS, tracked by gd->secure_ram. Secure memory can host MMU tables, security monitor, etc. Signed-off-by: York Sun <yorksun@freescale.com> --- Changes in v2: Do not use CONFIG_SYS_MEM_TOP_HIDE mechanism Changes in v1: Initial patch. Depends on http://patchwork.ozlabs.org/patch/540248/ README | 8 ++++++++ common/board_f.c | 9 +++++++++ include/asm-generic/global_data.h | 1 + include/configs/ls2085a_common.h | 6 ++++++ 4 files changed, 24 insertions(+)