All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb
@ 2018-09-17  2:45 Alexander Graf
  2018-09-17  5:42 ` Heinrich Schuchardt
  2018-09-17  5:47 ` Heinrich Schuchardt
  0 siblings, 2 replies; 4+ messages in thread
From: Alexander Graf @ 2018-09-17  2:45 UTC (permalink / raw)
  To: u-boot

The UEFI spec mandates that runtime sections are 64kb aligned to enable
support for 64kb page size OSs.

This patch ensures that we extend the runtime section to 64kb to be spec
compliant.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_memory.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 4f8cb545ad..66ad54a152 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -11,6 +11,7 @@
 #include <mapmem.h>
 #include <watchdog.h>
 #include <linux/list_sort.h>
+#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -526,10 +527,10 @@ static void add_u_boot_and_runtime(void)
 	uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
 	efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
 
-	/* Add Runtime Services */
-	runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
+	/* Add Runtime Services,must be 64kb aligned */
+	runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K - 1);
 	runtime_end = (ulong)&__efi_runtime_stop;
-	runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
+	runtime_end = (runtime_end + SZ_64K - 1) & ~(SZ_64K - 1);
 	runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
 	efi_add_memory_map(runtime_start, runtime_pages,
 			   EFI_RUNTIME_SERVICES_CODE, false);
-- 
2.12.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb
  2018-09-17  2:45 [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb Alexander Graf
@ 2018-09-17  5:42 ` Heinrich Schuchardt
  2018-09-17 11:43   ` Alexander Graf
  2018-09-17  5:47 ` Heinrich Schuchardt
  1 sibling, 1 reply; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-09-17  5:42 UTC (permalink / raw)
  To: u-boot

On 09/17/2018 04:45 AM, Alexander Graf wrote:
> The UEFI spec mandates that runtime sections are 64kb aligned to enable
%s/kb/ kiB/g
The spec requires a multiple of 64,000 not of 65,536.

> support for 64kb page size OSs.
> 
> This patch ensures that we extend the runtime section to 64kb to be spec
> compliant.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  lib/efi_loader/efi_memory.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 4f8cb545ad..66ad54a152 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -11,6 +11,7 @@
>  #include <mapmem.h>
>  #include <watchdog.h>
>  #include <linux/list_sort.h>
> +#include <linux/sizes.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -526,10 +527,10 @@ static void add_u_boot_and_runtime(void)
>  	uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
>  	efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
>  
> -	/* Add Runtime Services */
> -	runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> +	/* Add Runtime Services,must be 64kb aligned */
> +	runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K - 1);

Please, add a comment in the code referring to the requirement in the
UEFI spec.

Best regards

Heinrich

>  	runtime_end = (ulong)&__efi_runtime_stop;
> -	runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> +	runtime_end = (runtime_end + SZ_64K - 1) & ~(SZ_64K - 1);
>  	runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
>  	efi_add_memory_map(runtime_start, runtime_pages,
>  			   EFI_RUNTIME_SERVICES_CODE, false);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb
  2018-09-17  2:45 [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb Alexander Graf
  2018-09-17  5:42 ` Heinrich Schuchardt
@ 2018-09-17  5:47 ` Heinrich Schuchardt
  1 sibling, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-09-17  5:47 UTC (permalink / raw)
  To: u-boot

On 09/17/2018 04:45 AM, Alexander Graf wrote:
> The UEFI spec mandates that runtime sections are 64kb aligned to enable
> support for 64kb page size OSs.

Where in the spec did you find this? I could neither find the term
"runtime section" nor "64kb" in the text.

Best regards

Heinrich

> 
> This patch ensures that we extend the runtime section to 64kb to be spec
> compliant.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> ---
>  lib/efi_loader/efi_memory.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
> index 4f8cb545ad..66ad54a152 100644
> --- a/lib/efi_loader/efi_memory.c
> +++ b/lib/efi_loader/efi_memory.c
> @@ -11,6 +11,7 @@
>  #include <mapmem.h>
>  #include <watchdog.h>
>  #include <linux/list_sort.h>
> +#include <linux/sizes.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -526,10 +527,10 @@ static void add_u_boot_and_runtime(void)
>  	uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
>  	efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
>  
> -	/* Add Runtime Services */
> -	runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
> +	/* Add Runtime Services,must be 64kb aligned */
> +	runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K - 1);
>  	runtime_end = (ulong)&__efi_runtime_stop;
> -	runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
> +	runtime_end = (runtime_end + SZ_64K - 1) & ~(SZ_64K - 1);
>  	runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
>  	efi_add_memory_map(runtime_start, runtime_pages,
>  			   EFI_RUNTIME_SERVICES_CODE, false);
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb
  2018-09-17  5:42 ` Heinrich Schuchardt
@ 2018-09-17 11:43   ` Alexander Graf
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2018-09-17 11:43 UTC (permalink / raw)
  To: u-boot



On 16.09.18 22:42, Heinrich Schuchardt wrote:
> On 09/17/2018 04:45 AM, Alexander Graf wrote:
>> The UEFI spec mandates that runtime sections are 64kb aligned to enable
> %s/kb/ kiB/g
> The spec requires a multiple of 64,000 not of 65,536.

The other way around you mean I guess? We do usually use "kb" for
multiples of 1024 though, no?

> 
>> support for 64kb page size OSs.
>>
>> This patch ensures that we extend the runtime section to 64kb to be spec
>> compliant.
>>
>> Signed-off-by: Alexander Graf <agraf@suse.de>
>> ---
>>  lib/efi_loader/efi_memory.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
>> index 4f8cb545ad..66ad54a152 100644
>> --- a/lib/efi_loader/efi_memory.c
>> +++ b/lib/efi_loader/efi_memory.c
>> @@ -11,6 +11,7 @@
>>  #include <mapmem.h>
>>  #include <watchdog.h>
>>  #include <linux/list_sort.h>
>> +#include <linux/sizes.h>
>>  
>>  DECLARE_GLOBAL_DATA_PTR;
>>  
>> @@ -526,10 +527,10 @@ static void add_u_boot_and_runtime(void)
>>  	uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
>>  	efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
>>  
>> -	/* Add Runtime Services */
>> -	runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
>> +	/* Add Runtime Services,must be 64kb aligned */
>> +	runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K - 1);
> 
> Please, add a comment in the code referring to the requirement in the
> UEFI spec.

Sure, it's part of 2.6.3 (AArch64 Platforms) in the 2.7 spec.


Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-17 11:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-17  2:45 [U-Boot] [PATCH] efi_loader: Align runtime section to 64kb Alexander Graf
2018-09-17  5:42 ` Heinrich Schuchardt
2018-09-17 11:43   ` Alexander Graf
2018-09-17  5:47 ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.