[Fwd: [PATCH] ppc64: 2.6 altivec support, sys_swapcontext & signal32 rework]

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Dec 1 16:15:05 EST 2003

(Re-post with the patch bzip2'ed...)

Hi !

It wasn't very easy to split this patch, so here it is in one piece
for now. It does a few things:

 - Adds basic Altivec support to the context switching code
 - Adds Altivec support to the 64 bits sigcontext
 - Rewrite part of the signal32 compat code based on the new
   ppc32 implementation, with Altivec support in the contexts,
   factors out some sigset flipping code, and fixes a long standing
   bug where an 32 bits RT context would have an incorrectly flipped
   sigset (a 64 bits one instead of a 32 bits one).
 - Adds sys_swapcontext syscall (and sys32_swapcontext) for kernel
   based implementation of {set,get,swap}_context with Altivec

So far, it appears to work fine (when run as part of my G5 kernel which
contains a bunch of other changes though). It would need some more testing

What is needed now is a glibc implementation of the ucontext calls for
both 32 and 64 bits that makes use of the new sys_swapcontext, at least
with 2.6. I may give it a try, but I'm sure somebody more familiar with
glibc than I am would get this done much much more quickly... So if you
are that person, please speak up ;)

Regarding the details of the Altivec stuff: On a ppc64 signal frame, a
kernel that supports altivec (AT_HWCAP) will always fill properly the
pointer to the altivec context. In there, VRSAVE is always set, regardless
of the usage of altivec done by the process. MSR:VEC in the regs context
will be set is the other altivec registers (vr0..31 and vscr) have valid
values in the context.

It is important to split vrsave from the rest of the context as a process
may set vrsave prior to doing its first vector operation, and get preempted
with a signal in between those, thus having a valid vrsave context that
needs to be saved & restored without having taken its first altivec
exception yet, thus not having an altivec context to save yet.

I'm not sure what's the best way to deal with the availability of vrsave
on ppc32 contexts, it's a bit more nasty here. (kernel version ?). Some
ppc32 kernels will report supporting altivec via AT_HWCAP without actually
implementing altivec sig/u context stuff. We may need to based ourself on
some kernel versioning here, maybe consider 2.4.23 as the minimum version
to rely on kernel sigcontext containing proper vrsave for ppc32 ?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ppc64-altivec_and_sig.diff.bz2
Type: application/x-bzip
Size: 17700 bytes
Desc: not available
Url : http://ozlabs.org/pipermail/linuxppc64-dev/attachments/20031201/2e38bba6/attachment.bin 

More information about the Linuxppc64-dev mailing list