[v3,5/8] efi_loader: Use EFI_CACHELINE_SIZE in the image loader too

Message ID 20180423055950.78818-6-agraf@suse.de
State Accepted
Commit 89aea436425c1b947dd812b478e9dbe29eff3e2b
Headers show
Series
  • riscv: Enable efi_loader support
Related show

Commit Message

Alexander Graf April 23, 2018, 5:59 a.m.
We were using our EFI_CACHELINE_SIZE define only in the runtime service
code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE.

This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts
the image loader to use it.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 include/efi_loader.h              | 7 +++++++
 lib/efi_loader/efi_image_loader.c | 2 +-
 lib/efi_loader/efi_runtime.c      | 7 -------
 3 files changed, 8 insertions(+), 8 deletions(-)

Comments

Heinrich Schuchardt April 23, 2018, 7:19 a.m. | #1
On 04/23/2018 07:59 AM, Alexander Graf wrote:
> We were using our EFI_CACHELINE_SIZE define only in the runtime service
> code, but left the image loader to use plain CONFIG_SYS_CACHELINE_SIZE.
> 
> This patch moves EFI_CACHELINE_SIZE into efi_loader.h and converts
> the image loader to use it.
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

> ---
>   include/efi_loader.h              | 7 +++++++
>   lib/efi_loader/efi_image_loader.c | 2 +-
>   lib/efi_loader/efi_runtime.c      | 7 -------
>   3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 17f9d3d1ef..0b1b3df55a 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -76,6 +76,13 @@ const char *__efi_nesting_dec(void);
>   		##__VA_ARGS__); \
>   	})
>   
> +#ifdef CONFIG_SYS_CACHELINE_SIZE
> +#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
> +#else
> +/* Just use the greatest cache flush alignment requirement I'm aware of */
> +#define EFI_CACHELINE_SIZE 128
> +#endif
> +
>   extern struct efi_runtime_services efi_runtime_services;
>   extern struct efi_system_table systab;
>   
> diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
> index d5fbba3138..2476a97a6a 100644
> --- a/lib/efi_loader/efi_image_loader.c
> +++ b/lib/efi_loader/efi_image_loader.c
> @@ -290,7 +290,7 @@ void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
>   
>   	/* Flush cache */
>   	flush_cache((ulong)efi_reloc,
> -		    ALIGN(virt_size, CONFIG_SYS_CACHELINE_SIZE));
> +		    ALIGN(virt_size, EFI_CACHELINE_SIZE));
>   	invalidate_icache_all();
>   
>   	/* Populate the loaded image interface bits */
> diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
> index 8558124c0a..573a5d6ac1 100644
> --- a/lib/efi_loader/efi_runtime.c
> +++ b/lib/efi_loader/efi_runtime.c
> @@ -30,13 +30,6 @@ static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
>   static efi_status_t __efi_runtime EFIAPI efi_device_error(void);
>   static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
>   
> -#ifdef CONFIG_SYS_CACHELINE_SIZE
> -#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
> -#else
> -/* Just use the greatest cache flush alignment requirement I'm aware of */
> -#define EFI_CACHELINE_SIZE 128
> -#endif
> -
>   #if defined(CONFIG_ARM64)
>   #define R_RELATIVE	1027
>   #define R_MASK		0xffffffffULL
>

Patch

diff --git a/include/efi_loader.h b/include/efi_loader.h
index 17f9d3d1ef..0b1b3df55a 100644
--- a/include/efi_loader.h
+++ b/include/efi_loader.h
@@ -76,6 +76,13 @@  const char *__efi_nesting_dec(void);
 		##__VA_ARGS__); \
 	})
 
+#ifdef CONFIG_SYS_CACHELINE_SIZE
+#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
+#else
+/* Just use the greatest cache flush alignment requirement I'm aware of */
+#define EFI_CACHELINE_SIZE 128
+#endif
+
 extern struct efi_runtime_services efi_runtime_services;
 extern struct efi_system_table systab;
 
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index d5fbba3138..2476a97a6a 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -290,7 +290,7 @@  void *efi_load_pe(void *efi, struct efi_loaded_image *loaded_image_info)
 
 	/* Flush cache */
 	flush_cache((ulong)efi_reloc,
-		    ALIGN(virt_size, CONFIG_SYS_CACHELINE_SIZE));
+		    ALIGN(virt_size, EFI_CACHELINE_SIZE));
 	invalidate_icache_all();
 
 	/* Populate the loaded image interface bits */
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 8558124c0a..573a5d6ac1 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -30,13 +30,6 @@  static efi_status_t __efi_runtime EFIAPI efi_unimplemented(void);
 static efi_status_t __efi_runtime EFIAPI efi_device_error(void);
 static efi_status_t __efi_runtime EFIAPI efi_invalid_parameter(void);
 
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define EFI_CACHELINE_SIZE CONFIG_SYS_CACHELINE_SIZE
-#else
-/* Just use the greatest cache flush alignment requirement I'm aware of */
-#define EFI_CACHELINE_SIZE 128
-#endif
-
 #if defined(CONFIG_ARM64)
 #define R_RELATIVE	1027
 #define R_MASK		0xffffffffULL