From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by sourceware.org (Postfix) with ESMTPS id AC1DE3858D33 for ; Fri, 2 Feb 2024 00:06:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC1DE3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AC1DE3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706832420; cv=none; b=ND9BxfEH+3vTTjn0dnuLKfI9xshqFHqC8q1xGaFORMi2pVKU+1s8voNxtKoAdgNG/Zfsgqs+EMTGcnCzcrCzb6RivoLRjhhDIqClAfVIPvFMcrQ/RXEA52dBOyz/t6STVDZPAqdkgFStm6RLqxdwGuEZNhxkdFoQf/IgVeG/+6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706832420; c=relaxed/simple; bh=DMQAy7uzh6cFz42VtJoi2V4Xn73xmstpftOCNkE0QYU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=STFT/kSMU43//bvaiRiiFfEi2LNLXte9T993AzcRY/AikKFmrLCV+dSWJegolsBdRCQYRW+LFMpqA1vu9Oix7kPoku82KbJEeDp6NV8ivCsqC/XntZqaQZ8LS1+1jZUv54jF+3wmCBoF6cdBT9M25FeTGYZbBEL+Me/SRUCj4W0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-218dc74d850so907090fac.2 for ; Thu, 01 Feb 2024 16:06:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706832418; x=1707437218; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ii//ioRbxqEse2cIeaeAVfTvobYFjGQ+KlT0tayI6oE=; b=KYV7974xamBmuUTw7MZ9WnT6lXwvaP4VrZI8c3NLNT5LZYG9ZxsWXOQWa7NF4vlR/1 reUHfJjkB/4RVFH4VmDm7KwCk0jjKAimZv6CSjVcRpbf9M5iekogzqoph9Bf7QupSeF9 CgExn05KAKj93bx81xpwEtFeATi+XaQEpnZeqvTU57jvmjvl3s4TQVKAAeQNhF9zp5uo Y09WfjLe61ww3/GR0XaFSHXeSAyl6HkOeqVqcgvy70BYR6D8O3tFFmX893NJxb4cR58v vzFQpu0WUOPpEBYzArGayIdx3uHOUR75ye4Y39+AT1FbKgtR0v8mmsSNr02SCCJuEVoM 8KLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706832418; x=1707437218; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ii//ioRbxqEse2cIeaeAVfTvobYFjGQ+KlT0tayI6oE=; b=U24AYmTO1D8om6uP0QQsdDY0Yo9yRffovEqE80NfQY7EAelBTU4UiT8qfIcJLxam1T kSQti4kgclkSwoXj5DPEQ1Ns5gUGwFoUgZvO6NDiZIwNXSs1cXgGam+7uDrPKTNTKvg8 wZWStY6LkkCzezwZsbqlLsuRF5rDID8wGRDHe+KFtgZ+UaTcydbaHZSYWXFXSynjDeoc qGcMjebBMUOlFaBTYltZKTy2xw9VDdUAbAZ1MN9nMooO7j+PK2BFZEz968LvrARE+0kr SK+rfKggxymRnuH+BvK0CiJyRWh6TKrLL8zZj4z4k6O1d0pColLsad2SbUK8tPNlLcyi ID3w== X-Gm-Message-State: AOJu0YxmrWIRndVa46G5Xb9e2vQiaAaa/SH2XoumbNV5uRBt7ggqgFMZ 3I7uzB28t7xQuAw9nHxA76zg4gytnI9AMHWMVMYubQodmtrmQx2aVPackmwrWpZpiErWvdnkM3M zoExtxGP57QUByx/3qDUPm1+qC6zJOTgeYu6ZAA== X-Google-Smtp-Source: AGHT+IHfEO2h5fEKGiUcYZkH6NZz8Ba3M6ZoC53emhcLxWMuCih/k+DkmzOsWWffhU2wWQ759U8+4SYFaxMCfwZM6FQ= X-Received: by 2002:a05:6870:148e:b0:210:b2d9:aa0f with SMTP id k14-20020a056870148e00b00210b2d9aa0fmr419826oab.18.1706832417922; Thu, 01 Feb 2024 16:06:57 -0800 (PST) MIME-Version: 1.0 References: <20240201174103.798138-1-adhemerval.zanella@linaro.org> In-Reply-To: <20240201174103.798138-1-adhemerval.zanella@linaro.org> From: Khem Raj Date: Thu, 1 Feb 2024 16:06:31 -0800 Message-ID: Subject: Re: [PATCH] mips: FIx clone3 implementation (BZ 31325) To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Feb 1, 2024 at 9:41=E2=80=AFAM Adhemerval Zanella wrote: > > For o32 we need to setup a minimal stack frame to allow cprestore > on __thread_start_clone3 (which instruct the linker to save the > gp for PIC). Also, there is no guarantee by kABI that $8 will be > preserved after syscall execution, so we need to save it on the > provided stack. > > Checked on mipsel-linux-gnu. works ok on yocto reference mips ( Big-endian ) ( mips-linux-gnu ) Tested-by: Khem Raj > > Reported-by: Khem Raj > --- > sysdeps/unix/sysv/linux/mips/clone3.S | 32 ++++++++++++++++++++++----- > 1 file changed, 27 insertions(+), 5 deletions(-) > > diff --git a/sysdeps/unix/sysv/linux/mips/clone3.S b/sysdeps/unix/sysv/li= nux/mips/clone3.S > index e9fec2fa47..481b8ae963 100644 > --- a/sysdeps/unix/sysv/linux/mips/clone3.S > +++ b/sysdeps/unix/sysv/linux/mips/clone3.S > @@ -37,11 +37,6 @@ > > .text > .set nomips16 > -#if _MIPS_SIM =3D=3D _ABIO32 > -# define EXTRA_LOCALS 1 > -#else > -# define EXTRA_LOCALS 0 > -#endif > #define FRAMESZ ((NARGSAVE*SZREG)+ALSZ)&ALMASK > GPOFF=3D FRAMESZ-(1*SZREG) > NESTED(__clone3, SZREG, sp) > @@ -68,8 +63,31 @@ NESTED(__clone3, SZREG, sp) > beqz a0, L(error) /* No NULL cl_args pointer. */ > beqz a2, L(error) /* No NULL function pointer. */ > > +#if _MIPS_SIM =3D=3D _ABIO32 > + /* Both stack and stack_size on clone_args are defined as uint64_= t, and > + there is no need to handle values larger than to 32 bits for o= 32. */ > +# if __BYTE_ORDER =3D=3D __BIG_ENDIAN > +# define CL_STACKPOINTER_OFFSET 44 > +# define CL_STACKSIZE_OFFSET 52 > +# else > +# define CL_STACKPOINTER_OFFSET 40 > +# define CL_STACKSIZE_OFFSET 48 > +# endif > + > + /* For o32 we need to setup a minimal stack frame to allow cprest= ore > + on __thread_start_clone3. Also there is no guarantee by kABI = that > + $8 will be preserved after syscall execution (so we need to sa= ve it > + on the provided stack). */ > + lw t0, CL_STACKPOINTER_OFFSET(a0) /* Load the stack pointer= . */ > + lw t1, CL_STACKSIZE_OFFSET(a0) /* Load the stack_size. = */ > + addiu t1, -32 /* Update the stack size.= */ > + addu t2, t1, t0 /* Calculate the thread s= tack. */ > + sw a3, 0(t2) /* Save argument pointer.= */ > + sw t1, CL_STACKSIZE_OFFSET(a0) /* Save the new stack siz= e. */ > +#else > move $8, a3 /* a3 is set to 0/1 for syscall success/e= rror > while a4/$8 is returned unmodified. *= / > +#endif > > /* Do the system call, the kernel expects: > v0: system call number > @@ -125,7 +143,11 @@ L(thread_start_clone3): > > /* Restore the arg for user's function. */ > move t9, a2 /* Function pointer. */ > +#if _MIPS_SIM =3D=3D _ABIO32 > + PTR_L a0, 0(sp) > +#else > move a0, $8 /* Argument pointer. */ > +#endif > > /* Call the user's function. */ > jal t9 > -- > 2.34.1 >