public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] efi_loader: Always flush in cache line size granularity
@ 2016-04-04  7:32 Alexander Graf
  2016-04-04  7:56 ` Marek Vasut
  2016-04-10 22:24 ` Andreas Färber
  0 siblings, 2 replies; 9+ messages in thread
From: Alexander Graf @ 2016-04-04  7:32 UTC (permalink / raw)
  To: u-boot

The cache line flush helpers only work properly when they get aligned
start and end addresses. Round our flush range to cache line size. It's
safe because we're guaranteed to flush within a single page which has the
same cache attributes.

Reported-by: Marek Vasut <marex@denx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 lib/efi_loader/efi_runtime.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 22bcd08..40acec0 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -194,7 +194,8 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
 #endif
 
 		*p = newaddr;
-		flush_dcache_range((ulong)p, (ulong)&p[1]);
+		flush_dcache_range((ulong)p & ~(CONFIG_SYS_CACHELINE_SIZE - 1),
+			ALIGN((ulong)&p[1], CONFIG_SYS_CACHELINE_SIZE));
 	}
 
 #ifndef IS_RELA
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [U-Boot] [PATCH] efi_loader: Always flush in cache line size granularity
@ 2016-04-11 21:20 Alexander Graf
  2016-04-13 12:53 ` Andreas Färber
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Graf @ 2016-04-11 21:20 UTC (permalink / raw)
  To: u-boot

The cache line flush helpers only work properly when they get aligned
start and end addresses. Round our flush range to cache line size. It's
safe because we're guaranteed to flush within a single page which has the
same cache attributes.

Reported-by: Marek Vasut <marex@denx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - Fix compilation on systems without CONFIG_SYS_CACHELINE_SIZE

diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 22bcd08..3ee27ca 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -20,6 +20,13 @@ static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_unimplemented(void);
 static efi_status_t EFI_RUNTIME_TEXT EFIAPI efi_device_error(void);
 static efi_status_t EFI_RUNTIME_TEXT 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
@@ -194,7 +201,8 @@ void efi_runtime_relocate(ulong offset, struct efi_mem_desc *map)
 #endif
 
 		*p = newaddr;
-		flush_dcache_range((ulong)p, (ulong)&p[1]);
+		flush_dcache_range((ulong)p & ~(EFI_CACHELINE_SIZE - 1),
+			ALIGN((ulong)&p[1], EFI_CACHELINE_SIZE));
 	}
 
 #ifndef IS_RELA

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

end of thread, other threads:[~2016-04-13 12:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04  7:32 [U-Boot] [PATCH] efi_loader: Always flush in cache line size granularity Alexander Graf
2016-04-04  7:56 ` Marek Vasut
2016-04-10 22:24 ` Andreas Färber
2016-04-10 22:31   ` Alexander Graf
2016-04-10 22:36     ` Marek Vasut
2016-04-12  0:39       ` Tom Rini
2016-04-12  0:59         ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2016-04-11 21:20 Alexander Graf
2016-04-13 12:53 ` Andreas Färber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox