This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: PPC AltiVec request: add an abi variant


I think Matt's desire is to actually use AltiVec code in the kernel to enhance certain kernel operations, however he needs to ensure that the registers are restored to the state that started in to do this.

Since Linux/PPC does NOT use FP or Avec for anything inside the kernel this issue does not come up, and is why data corruption can occur if driver writers use fp and do not compile with soft-float.

- kumar

On Tuesday, March 4, 2003, at 08:52 AM, Peter Bergner wrote:

Matt Thomas wrote:
> Because the kernel is a separate "user" of AltiVec from a normal
> user process, unless the AltiVec state is preserved, any use of
> AltiVec will obliterate any previous user's state.  On entering
> the kernel, the kernel saves all the integer registers (along with
> LR, CTR, CR, etc.) so it can use them.  It then restores them when
> it returns to the user.  It could do the same thing for AltiVec but
> that's a significant amount of overhead.  But the kernel does not
> whether it will be using AltiVec so avoiding that overhead would be
> good.  Now if each routine that uses any AltiVec register could make
> sure that upon return that the register contents were identical to
> entry, then the need to always save and restore would do away.

I don't know the NetBSD kernel, but can't you play the same game
Linux/PPC does for AltiVec and the FP registers which uses lazy
save/restore (actually only lazy save on non-SMP kernels) of the
register contents using the FP unavailable and AltiVec unavailable
exceptions?

If so, then you just need to be careful to flush the FP/AltiVec state
(if any exists: look in MSR) before using the FP/AltiVrec registers.
In the Linux/PPC64 kernel, we require all FP use in the kernel to
excplitly flush the FP state and enable FP mode before any FP use.
We enforce that by panic'ing on a FP Unavailable exception that comes
from kernel state.... we've have problems with driver writers not
using -msoft-float during tere builds and it was causing data integrity
errors in userland code.


Peter


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