diff mbox

[U-Boot,v4,5/9] armv8: ls2080a: Declare spin tables as reserved for efi loader

Message ID 1466464039-51199-6-git-send-email-agraf@suse.de
State Superseded
Delegated to: Alexander Graf
Headers show

Commit Message

Alexander Graf June 20, 2016, 11:07 p.m. UTC
The efi loader code has its own memory map, so it needs to be aware where
the spin tables are located, to ensure that no code writes into those
regions.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Prabhakar Kushwaha June 22, 2016, 3:06 a.m. UTC | #1
Hi Alex,


> -----Original Message-----
> From: Alexander Graf [mailto:agraf@suse.de]
> Sent: Tuesday, June 21, 2016 4:37 AM
> To: u-boot@lists.denx.de
> Cc: york sun <york.sun@nxp.com>; Prabhakar Kushwaha
> <prabhakar.kushwaha@nxp.com>
> Subject: [PATCH v4 5/9] armv8: ls2080a: Declare spin tables as reserved for
> efi loader
> 
> The efi loader code has its own memory map, so it needs to be aware where
> the spin tables are located, to ensure that no code writes into those regions.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> index d17227a..91d6374 100644
> --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
> @@ -5,6 +5,7 @@
>   */
> 
>  #include <common.h>
> +#include <efi_loader.h>
>  #include <libfdt.h>
>  #include <fdt_support.h>
>  #include <phy.h>
> @@ -72,6 +73,11 @@ void ft_fixup_cpu(void *blob)
> 
>  	fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
>  			*boot_code_size);
> +#ifdef CONFIG_EFI_LOADER
> +	efi_add_memory_map((uintptr_t)&secondary_boot_code,
> +			   ALIGN(*boot_code_size, EFI_PAGE_SIZE) >>
> EFI_PAGE_SHIFT,
> +			   EFI_RESERVED_MEMORY_TYPE, false); #endif
>  }
>  #endif

I believe this place(during DTS fix-up) is too late for  adding this memory in EFI memory map. 
Not sure, grub2 user may write this memory before launching Linux.

--prabhakar
Alexander Graf June 22, 2016, 4:55 a.m. UTC | #2
> Am 22.06.2016 um 05:06 schrieb Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>:
> 
> Hi Alex,
> 
> 
>> -----Original Message-----
>> From: Alexander Graf [mailto:agraf@suse.de]
>> Sent: Tuesday, June 21, 2016 4:37 AM
>> To: u-boot@lists.denx.de
>> Cc: york sun <york.sun@nxp.com>; Prabhakar Kushwaha
>> <prabhakar.kushwaha@nxp.com>
>> Subject: [PATCH v4 5/9] armv8: ls2080a: Declare spin tables as reserved for
>> efi loader
>> 
>> The efi loader code has its own memory map, so it needs to be aware where
>> the spin tables are located, to ensure that no code writes into those regions.
>> 
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>> arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> 
>> diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
>> b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
>> index d17227a..91d6374 100644
>> --- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
>> +++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
>> @@ -5,6 +5,7 @@
>>  */
>> 
>> #include <common.h>
>> +#include <efi_loader.h>
>> #include <libfdt.h>
>> #include <fdt_support.h>
>> #include <phy.h>
>> @@ -72,6 +73,11 @@ void ft_fixup_cpu(void *blob)
>> 
>>    fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
>>            *boot_code_size);
>> +#ifdef CONFIG_EFI_LOADER
>> +    efi_add_memory_map((uintptr_t)&secondary_boot_code,
>> +               ALIGN(*boot_code_size, EFI_PAGE_SIZE) >>
>> EFI_PAGE_SHIFT,
>> +               EFI_RESERVED_MEMORY_TYPE, false); #endif
>> }
>> #endif
> 
> I believe this place(during DTS fix-up) is too late for  adding this memory in EFI memory map. 
> Not sure, grub2 user may write this memory before launching Linux.

The dt fixups get called in bootefi, so before grub2 starts :)


Alex
diff mbox

Patch

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index d17227a..91d6374 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <efi_loader.h>
 #include <libfdt.h>
 #include <fdt_support.h>
 #include <phy.h>
@@ -72,6 +73,11 @@  void ft_fixup_cpu(void *blob)
 
 	fdt_add_mem_rsv(blob, (uintptr_t)&secondary_boot_code,
 			*boot_code_size);
+#ifdef CONFIG_EFI_LOADER
+	efi_add_memory_map((uintptr_t)&secondary_boot_code,
+			   ALIGN(*boot_code_size, EFI_PAGE_SIZE) >> EFI_PAGE_SHIFT,
+			   EFI_RESERVED_MEMORY_TYPE, false);
+#endif
 }
 #endif