This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Check for illegal address range in io/flash


On Dec 11, 2007 10:42 AM, Andrew Lunn <andrew@lunn.ch> wrote:
> On Tue, Dec 11, 2007 at 10:02:32AM +0100, ?yvind Harboe wrote:
> > io/flash has a broken address range check for flash_erase(). There is no address
> > range check for flash_program_buf().
> >
> > This patch adds address range check & returns error if the address is invalid.
> >
> > Alternatively, address range checks could be left to higher level code and the
> > broken flash_erase() addreess range check can be removed.
> >
> > Or alternatively, I'm about to get egg all over my face and hopefully someone
> > will take pity and tell me what's really happening here.  :-)
>
> Well, i would expect the lower levels to fail. This could happen in a
> number of ways. Your MMU could throw an exception, since you are
> accessing addresses that do not exist. Or the flash operation would
> fail, generally with a timeout.
>
> It seems to me the lower levels are very likely to give you some
> indication you did something stupid. So why bloat the middle level
> with an extra check? Maybe an ASSERT makes sense so not to bloat
> production images?

I mainly want the busted check in flash_erase() to be removed.
ASSERT's are probably fine.

>
> Now presumably, you have a platform that did not tell you and you
> wrote past the end of the flash? Is your MMU correctly configured?
> Does a timeout return an error code?

I'm using eCos flash support as drivers for a JTAG debugger. :-)

I have a small jump table which I link w/libtarget.a and voila! a JTAG
flash driver.

Perhaps flash.c could grow a new function flash_check_address_range() that upper
levels can use? Of course the flash_info structure is available to applications
so implementing such a function is not a problem.

Again: I mainly want the busted check in flash_erase() to be deleted.

>
>   Andrew
>



-- 
Øyvind Harboe
http://www.zylin.com - eCos ARM & FPGA  developer kit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]