On Tue, Mar 20, 2012 at 12:48 PM, Jonas Bonn <[email protected]> wrote:

>
> Hi Matthew,
>
> On Tue, 2012-03-20 at 10:55 -0500, Matthew Hicks wrote:
> > Before creating and posting the patch, it was a consensus that using
> > the l.movhi instruction was a better way to clear register values
> > (since it doesn't require any register as input) than the other ways
> > of doing it.  I haven't downloaded the kernel since Dec.,
>
> ...but that patch is from January 2011.  You should have it.
>

I do have it, but it was causing an error when I was simulating Linux and a
custom exception handler (I re-purposed the IIE).   When I created
exceptions early in the boot process the system would crash due to the
propagation of X (i.e., uninitialized) values from r0 to other registers.
 This all stemmed from r0 not being cleared correctly.  Moving to the
l.movhi instruction correctly set r0 = 0 and allowed the system to run
correctly.

This was not an easy bug to trace and I hope that we could move to using
l.movhi to save someone else the hassle.


> > so I don't know what all has been changed.  It is essential that the
> > CLEAR_GPR macro be changed (as in the patch) as it relies on r0 == 0,
> > which may not be true, especially when resetting r0.
>
> I think setting r0=0 as the 2nd instruction after reset pretty much
> guarantees it to be true.
>

It doesn't as r0 will not be set to 0 in some environments.  In some cases
32'hXXXXXXXX AND 32'h0 != 32'h0, but l.movhi r0, 0 always sets r0 = 32'h0.
 Note that r0 starts in ModelSim with the value 32'hXXXXXXXX.


---Matthew Hicks
_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc

Reply via email to