This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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: [PATCH] getpid/vfork/raise fix


Jakub Jelinek <jakub@redhat.com> writes:

> Can you use a local register for saving oldval accross the syscall though?
> Registers in the register window can be saved to the backing store, if that
> happens, vfork child restores it from the backing store, calls some routine
> and something else is stored into that location in backing store, vfork
> parent will afterwards restore a different value.

I think you are right.

> IMHO only a call clobbered register preserved accross system call can be
> used, and is it is not available, vfork has to choose a slower way:
>
> int oldval = self->pid;
> int newval = oldval ? -oldval : 0x80000000;
> self->pid = newval;
> vfork syscall
> newval = self->pid;
> oldval = (newval & 0x7fffffff) ? -newval : 0;
> self->pid = oldval;

That doesn't seem to work, though.  I'm getting p3 != p4 in the posix
vfork tests.  Or do you see any error in my implementation?

ENTRY(__vfork)
	alloc r2=ar.pfs,0,0,2,0
	adds r14=PID,r13
	;; 
	ld4 r16=[r14]
	;;
	sub r15=0,r16
	cmp.eq p0,p6=0,r16
	;;
(p6)	movl r15=0x80000000
	mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD
	mov out1=0		/* Standard sp value.			*/
	;;
	st4 [r14]=r15
	DO_CALL_VIA_BREAK (SYS_ify (clone))
	cmp.eq p6,p0=0,r8
	adds r14=PID,r13
(p6)	br.cond.dptk 1f
	;;
	ld4 r15=[r14]
	;;
	extr.u r16=r15,0,31
	;;
	cmp.eq p0,p6=0,r16
	;;
(p6)	sub r16=0,r15
	;;
	st4 [r14]=r16
1:
	cmp.eq p6,p0=-1,r10
(p6)	br.cond.spnt.few __syscall_error
	ret
PSEUDO_END(__vfork)

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


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