[U-Boot,01/25] SPEAr: Fix ARM relocation support

Submitted by Amit Virdi on March 7, 2012, 12:03 p.m.

Details

Message ID 1331121854-20494-2-git-send-email-amit.virdi@st.com
State Superseded
Delegated to: Stefan Roese
Headers show

Commit Message

Amit Virdi March 7, 2012, 12:03 p.m.
While the u-boot code is running from the flash, it is essential that no access
is made to the bss segment. This is due to the fact that .rel.dyn and .bss areas
overlap and former contains information used in relocation. In SPEAr, this was
not taken into consideration. As a result, while the relocation wasn't complete,
dram_init populated an uninitialized global variable resulting in corruption of
.rel.dyn area, which resulted in u-boot crash.

This commit fixes this problem by removing code that accesses bss segment

Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 board/spear/common/spr_misc.c |   20 +-------------------
 1 files changed, 1 insertions(+), 19 deletions(-)

Comments

Stefan Roese March 7, 2012, 1:11 p.m.
On Wednesday 07 March 2012 13:03:50 Amit Virdi wrote:
> While the u-boot code is running from the flash, it is essential that no
> access is made to the bss segment. This is due to the fact that .rel.dyn
> and .bss areas overlap and former contains information used in relocation.
> In SPEAr, this was not taken into consideration. As a result, while the
> relocation wasn't complete, dram_init populated an uninitialized global
> variable resulting in corruption of .rel.dyn area, which resulted in
> u-boot crash.
> 
> This commit fixes this problem by removing code that accesses bss segment
> 
> Signed-off-by: Amit Virdi <amit.virdi@st.com>

Acked-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

Patch hide | download patch | download mbox

diff --git a/board/spear/common/spr_misc.c b/board/spear/common/spr_misc.c
index 0812c20..3ab278f 100644
--- a/board/spear/common/spr_misc.c
+++ b/board/spear/common/spr_misc.c
@@ -40,27 +40,9 @@  static struct chip_data chip_data;
 
 int dram_init(void)
 {
-	struct xloader_table *xloader_tb =
-	    (struct xloader_table *)XLOADER_TABLE_ADDRESS;
-	struct xloader_table_1_1 *table_1_1;
-	struct xloader_table_1_2 *table_1_2;
-	struct chip_data *chip = &chip_data;
-
+	/* Store complete RAM size and return */
 	gd->ram_size = get_ram_size(PHYS_SDRAM_1, PHYS_SDRAM_1_MAXSIZE);
 
-	if (XLOADER_TABLE_VERSION_1_1 == xloader_tb->table_version) {
-		table_1_1 = &xloader_tb->table.table_1_1;
-		chip->dramfreq = table_1_1->ddrfreq;
-		chip->dramtype = table_1_1->ddrtype;
-
-	} else if (XLOADER_TABLE_VERSION_1_2 == xloader_tb->table_version) {
-		table_1_2 = &xloader_tb->table.table_1_2;
-		chip->dramfreq = table_1_2->ddrfreq;
-		chip->dramtype = table_1_2->ddrtype;
-	} else {
-		chip->dramfreq = -1;
-	}
-
 	return 0;
 }