Subject: Re: MSR_SPE - being turned off...

From: Michael Neuling <[email-masked]>
Date: Wed, 06 May 2009 10:01:39 +1000

> Hi Kumar/Michael...
> 
> Sorry, I really didn't explain myself very well...
> 
> The Problem (answer to Michael):
> =========================> =======
> We started using a new compiler that upon -O2 optimization - added
> heavy SPE related instructions into our applications (where the older
> compiler might not use as many). Once this was done, we started 
> experiencing problems with data being 'shifted' and/or corrupted 
> throughout the applications which didn't immediately cause problems,
> but either scribbled on someone else's memory and/or bad results...
> We knew where one of the offending scribbles started (by the shifting 
> by 1 byte of a structure) and found by comparing binaries with 'older'
> compiler vs. this one that the only major difference was the 'density' 
> of the SPE instructions...
> 
> As to your question, Kumar: 
> =========================> ==
> Naively, I explicitly enabled the SPE in a BSP 'early_init' program 
> (as well as enabling Machine Checks) - which is what I meant by
> Enabling SPE...

Yeah, you don't want to do this.  It'll potentially break your
application.

I'm not that familiar with the CPU you are using but I'm guessing that
you can't write the MSR from user space anyway.

> Michael explained that it is 'normal' if we asynchronously polled
> the MSR (in an application and/or in the kernel) that it might be
> disabled at the moment, but that you do a 'lazy switch' that 
> enables it...and gets turned on when an SPE exception comes in...
> 
> ...ok...I can live with that...
> 
> -------where I was really going---------
> 
> This is where I was trying to go. A developer at our company (who no
> longer works for us) - did some research/development on the SPE 
> functionality, in the hopes that we could create an optimized library.
> The results were successful, but because of some of the restrictions 
> (including 8 byte alignment for some instructions) - we decided not
> to incorporate this library into our application(s)
> 
> But, this developer in his results, indicated that he believed our
> kernels were NOT properly saving/restoring the upper 32bits of the
> GPR (which can/will be used in the SPE instructions)... Thus, if the
> upper 32bits were not saved (and restored when the application got
> the SPE to operate on)...then, he thought there would be problems.
> He unfortunately, was unable to finish his work and fix these 'bugs'
> before he left our company...
> 
> Again, I am only going on his results, and not my own investigations
> (I am not sure where to start to find this problem to begin with)...
> 
> So, I was REALLY asking - has anybody else run into this type of
> problem, and/or the Linux community has recognized this problem and
> has fixed this?

If GPRs where getting corrupted in userspace, that would be a serious
bug and would be noticed by someone pretty quickly.

We'd really need a test case to get anywhere with this report.  

Mikey