All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] armv8: mmu: Detect page table overflow in emergency pt creation
@ 2016-07-30 21:13 Alexander Graf
  2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Graf @ 2016-07-30 21:13 UTC (permalink / raw)
  To: u-boot

We create 2 sets of page tables: One for normal operation, one for
emergency (used while modifying the former).

Because the page tables grow dynamically, we have code that checks
for overflow. Unfortunately we didn't adjust the available space
variable while creating the emergency tables, so potentially someone
might run into an overflow there (not seen in real world yet though!).

Fix it by properly adjusting the size as well as the base offset in
emergency page table creation.

Reported-by: York Sun <york.sun@nxp.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: York Sun <york.sun@nxp.com>

---

v1 -> v2:

  - Remove unnecessary paranthesis
---
 arch/arm/cpu/armv8/cache_v8.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index ac909a1..cd3f6c1 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -380,6 +380,7 @@ void setup_pgtables(void)
 static void setup_all_pgtables(void)
 {
 	u64 tlb_addr = gd->arch.tlb_addr;
+	u64 tlb_size = gd->arch.tlb_size;
 
 	/* Reset the fill ptr */
 	gd->arch.tlb_fillptr = tlb_addr;
@@ -388,10 +389,13 @@ static void setup_all_pgtables(void)
 	setup_pgtables();
 
 	/* Create emergency page tables */
+	gd->arch.tlb_size -= (uintptr_t)gd->arch.tlb_fillptr -
+			     (uintptr_t)gd->arch.tlb_addr;
 	gd->arch.tlb_addr = gd->arch.tlb_fillptr;
 	setup_pgtables();
 	gd->arch.tlb_emerg = gd->arch.tlb_addr;
 	gd->arch.tlb_addr = tlb_addr;
+	gd->arch.tlb_size = tlb_size;
 }
 
 /* to activate the MMU we need to set up virtual memory */
-- 
1.8.5.6

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

* [U-Boot] [U-Boot, v2] armv8: mmu: Detect page table overflow in emergency pt creation
  2016-07-30 21:13 [U-Boot] [PATCH v2] armv8: mmu: Detect page table overflow in emergency pt creation Alexander Graf
@ 2016-08-06  1:00 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2016-08-06  1:00 UTC (permalink / raw)
  To: u-boot

On Sat, Jul 30, 2016 at 11:13:03PM +0200, Alexander Graf wrote:

> We create 2 sets of page tables: One for normal operation, one for
> emergency (used while modifying the former).
> 
> Because the page tables grow dynamically, we have code that checks
> for overflow. Unfortunately we didn't adjust the available space
> variable while creating the emergency tables, so potentially someone
> might run into an overflow there (not seen in real world yet though!).
> 
> Fix it by properly adjusting the size as well as the base offset in
> emergency page table creation.
> 
> Reported-by: York Sun <york.sun@nxp.com>
> Signed-off-by: Alexander Graf <agraf@suse.de>
> Reviewed-by: York Sun <york.sun@nxp.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/11edb867/attachment.sig>

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

end of thread, other threads:[~2016-08-06  1:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-30 21:13 [U-Boot] [PATCH v2] armv8: mmu: Detect page table overflow in emergency pt creation Alexander Graf
2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini

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.