----- Ursprüngliche Nachricht ----- Von: Radu Rendec Gesendet am: 25 Aug 2011 23:28:02
> I have only one question, though. Suppose you have a function that > allocates let's say 40 bytes on the stack. An example could be declaring > "char foo[40]" as a local variable. Let's say R1/SP is only a few bytes > above the stack "bottom" before entering this function. When you enter > the function, the guard code that is placed immediately before the stack > space is now located somewhere in the middle of the stack space reserved > for the "foo" variable. If the function only touches the first few bytes > of "foo", it may "corrupt" data but still keep your guard codes intact. > Then the thread switching code won't be able to detect this. Could this > be possible or did I just misunderstand the procedure you're describing? You're right, this might happen. If the local array is still on the stack, the task switch code will detect that the SP is out-of-bounds and act as if the guard code were overwritten. (In my implementation, it will not detect which other thread might have been affected, if at all) Of course this is not 100% secure. For that I had to calculate a CRC for the stack of the thread I'm leaving. This would detect the violation when I reactivate the other thread whose stack has been clobbered. But I think that's too much overhead. However, there is no 100% safety. Since there is no separate protected memory, any access to anything can accidentally overwrite someting somewhere. :) Hey, there must be something left to do for the programmer. One really weird thought: One could set up a second MSP that acts as a protected mode supervisor. It is programmed through e.g. SPI by the applciation MSP and sets access and limit breakpoints through JTAG. If a breakpoint is hit (the SP is set lower than allowed, or whatever condition is programmed by the multithreader) it will trigger a proper interrupt (throug JTAG too, so it is an NMI). Even the multithreading code could be timed and executed through JTAG, executing only the threads on the applicaiton MSP. Well, I think, if you need something like this, you should look for a different processor instead, e.g. an embedded 80386. ;) And JTAG is slow... JMGross ------------------------------------------------------------------------------ EMC VNX: the world's simplest storage, starting under $10K The only unified storage solution that offers unified management Up to 160% more powerful than alternatives and 25% more efficient. Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev _______________________________________________ Mspgcc-users mailing list Mspgcc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mspgcc-users