mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] arm: mmu: catch NULL pointer dereferences
Date: Sat, 31 Aug 2013 17:54:22 +0200	[thread overview]
Message-ID: <1377964462-10387-1-git-send-email-plagnioj@jcrosoft.com> (raw)

For high vectors if memory start at 0x0. We have to
live without being able to catch NULL pointer dereferences.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/cpu/mmu.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index e3ea3b6..2e69b16 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -218,9 +218,9 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
 /*
  * Map vectors and zero page
  */
-static void vectors_init(void)
+static void vectors_init(bool zero_valid_addr)
 {
-	u32 *exc, *zero = NULL;
+	u32 *exc;
 	void *vectors;
 	u32 cr;
 
@@ -235,10 +235,19 @@ static void vectors_init(void)
 		 * page table for the high vectors and zero page
 		 */
 		exc = arm_create_pte(0xfff00000);
-		zero = arm_create_pte(0x0);
 
-		/* Set the zero page to faulting */
-		zero[0] = 0;
+		/*
+		 * Memory start at 0x0. We have to
+		 * live without being able to catch NULL pointer dereferences
+		 */
+		if (!zero_valid_addr) {
+			u32 *zero = NULL;
+
+			zero = arm_create_pte(0x0);
+
+			/* Set the zero page to faulting */
+			zero[0] = 0;
+		}
 	} else {
 		/*
 		 * Otherwise map the vectors to the zero page. We have to
@@ -267,6 +276,7 @@ static int mmu_init(void)
 {
 	struct memory_bank *bank;
 	int i;
+	bool is_start_zero = 0;
 
 	arm_set_cache_functions();
 
@@ -303,7 +313,12 @@ static int mmu_init(void)
 	create_sections(0, 0, PAGE_SIZE, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ |
 			PMD_TYPE_SECT);
 
-	vectors_init();
+	for_each_memory_bank(bank) {
+		if (bank->start == 0x0)
+			is_start_zero = 1;
+	}
+
+	vectors_init(is_start_zero);
 
 	/*
 	 * First remap sdram cached using sections.
-- 
1.8.4.rc1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2013-08-31 15:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-31 15:54 Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-09-02  9:05 ` Sascha Hauer
2013-09-02 10:24   ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-04  7:07     ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377964462-10387-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox