This is the mail archive of the mailing list for the glibc 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]

[PATCH] PowerPC: Clear MSR_VSX for getcontext

This patch makes getcontext clear the MSR_VSX (indicating VSX usage)
from gregs[PT_MSR] so a following setcontext/swapcontext/makecontext
will not fail with invalid argument.

This patch fixes the testcases:

* stdlib/tst-setcontext,
* stdlib/tst-makecontext3, and
* tst-setcontext-fpscr

When building for PPC32 with --with-cpu=power7.


2013-11-17  Adhemerval Zanella  <>

        * sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
	(__getcontext): Clear MSR_VSX to avoid invalid argument in subsequent


diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
index a852e0d..b7527c1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/getcontext.S
@@ -35,13 +35,30 @@
 	.section ".text";
 ENTRY (__getcontext)
 	li	r4,0
+	stwu	r1,-16(r1)
 	li	r5,_UC_SIZE_2_3_4;
+	stw	r31,12(r1)
+	mr	r31,r3
 	DO_CALL (SYS_ify (swapcontext));
 	bso-	cr0,1f
+/* Since all VSX register are marked volatile the function clears
+   the MSR_VSX (23) bit from gregs[PT_MSR]:
+   ctx->uc_mcontext.uc_regs->gregs[PT_MSR] &= ~(1 << 23)
+   This is required because the kernel return EINVAL on a
+   following setcontext call if MSR_VSX is set.  */
+	lwz	r10,_UC_REGS_PTR(r31)
+	lwz	r31,12(r1)
+	lwz	r0,_UC_GREGS+(PT_MSR*4)(r10)
+	rlwinm	r0,r0,0,9,7
+	stw	r0,_UC_GREGS+(PT_MSR*4)(r10)
 /* the kernel does not set the return code for the success case */
 	li	r3,0
+	addi	r1,r1,16
+	addi	r1,r1,16
 	b	__syscall_error@local

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