Ping :-)

I *think* this particular one can be reviewed without PowerPC /
flash-specific knowledge.
-- 
Nick Withers

Embedded Systems Programmer
Department of Nuclear Physics, Research School of Physics and Engineering
The Australian National University (CRICOS: 00120C)

On Wed, 2014-02-12 at 10:15 -0500, Gedare Bloom wrote:
> Can someone with powerpc / flash knowledge please review these patches
> and suggest the proper course of action?
> 
> On Wed, Jan 29, 2014 at 9:15 PM, Nick Withers <nick.with...@anu.edu.au> wrote:
> > Hi all,
> >
> > The attached patch "flash_probe.patch" moves the invocation of a flash
> > device size probe[1] in the powerpc flash driver framework from
> > argcheck() to bankValidate(). Previously, the latter was called by the
> > former before the probe had happened and bankValidate()s subsequent call
> > of BSP_flashCheckId() caused it to access memory that is potentially
> > unmapped.
> >
> > On my MVME3100, this previous behaviour caused a machine check
> > exception.
> >
> > [1] In my ever-humble opinion, this whole probe business is a bad idea
> > from the get-go... The attached diff "flash_don't_probe.patch" - which
> > I'm not suggesting be committed, but *is* what I'm using - reworks it on
> > the MVME3100 so that the board's configuration is read from the "Vital
> > Product Data" EEPROM, giving the flash address and size. I've had
> > trouble with the VPD routines, however (and haven't fully debugged
> > that)... The attached "vpd.patch" seems to have sorted that or me in the
> > interim. I'd be interested in hearing others' thoughts on this :-)
> > --
> > Nick Withers
> >
> > Embedded Systems Programmer
> > Department of Nuclear Physics, Research School of Physics and Engineering
> > The Australian National University (CRICOS: 00120C)
> >
> > _______________________________________________
> > rtems-devel mailing list
> > rtems-de...@rtems.org
> > http://www.rtems.org/mailman/listinfo/rtems-devel
> >
>From 8b99fe9709ca5aaadb22b81cd037a9521f4de54b Mon Sep 17 00:00:00 2001
From: Nick Withers <nick.with...@anu.edu.au>
Date: Thu, 30 Jan 2014 12:58:41 +1100
Subject: [PATCH] Move the flash size probe into bankValidate()

Previously, bankValidate() could be called (e.g., BSP_flashWrite() -> regionCheckAndErase() -> argcheck() -> bankValidate()) without the probe having happened. When it then invoked BSP_flashCheckId(), unmapped memory could be read, possibly causing a fatal exception.
---
 c/src/lib/libbsp/powerpc/shared/flash/flash.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/shared/flash/flash.c b/c/src/lib/libbsp/powerpc/shared/flash/flash.c
index 0037fe7..b7f1678 100644
--- a/c/src/lib/libbsp/powerpc/shared/flash/flash.c
+++ b/c/src/lib/libbsp/powerpc/shared/flash/flash.c
@@ -456,6 +456,11 @@ struct bankdesc *b = BSP_flashBspOps.bankcheck(bank, quiet);
 		return 0;
 	}
 
+	if ( !b->size && !(b->size = BSP_flashProbeSize(b)) ) {
+		fprintf(stderr,"Configuration Error - unable to determine flash size\n");
+		return 0;
+	}
+
 	if ( !b->dd && !(b->dd = BSP_flashCheckId(b, b->start,1)) ) {
 		fprintf(stderr,"Error: unable to detect flash device in bank #%i\n", bank);
 		return 0;
@@ -485,10 +490,6 @@ struct bankdesc *b;
 		return 0;
 	}
 
-	if ( !b->size && !(b->size = BSP_flashProbeSize(b)) ) {
-		fprintf(stderr,"Configuration Error - unable to determine flash size\n");
-		return 0;
-	}
 	if ( offset + size > b->size ) {
 		fprintf(stderr,"Error: requested size exceeds available flash (0x%08"PRIx32" bytes)\n", b->size);
 		return 0;
-- 
1.8.5.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to