From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id E39D83853D69 for ; Wed, 23 Nov 2022 03:40:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E39D83853D69 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1669174844; bh=Ytft3F5ELp5Wqktnc7B2V0ihqJqVlBK3vba0aKQZvgY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AbAzfpkWgJspuqbwqy5RoEgwygi/QBQC4gve/MBv5NRFASE9EhbLHp/nRzwBNEIxm oBzG2QZdC7HKM43iioOjBzgeTiDAv94g/7Ph7d69aF8y+x677t/yC8FCFVAtt/XDg5 ZneGxy7coAdUNgR77eXxR9NvCdotEHyRvhZVqTQg= Received: from [IPv6:240e:358:1199:2300:dc73:854d:832e:2] (unknown [IPv6:240e:358:1199:2300:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384)) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 347686695E; Tue, 22 Nov 2022 22:40:37 -0500 (EST) Message-ID: Subject: Re: [PATCH] LoongArch: Add syscall.c for getting correct return value From: Xi Ruoyao To: Xing Li , adhemerval.zanella@linaro.org Cc: libc-alpha@sourceware.org, i.swmail@xen0n.name, caiyinyu@loongson.cn, wanghongliang@loongson.cn, hejinyang@loongson.cn Date: Wed, 23 Nov 2022 11:40:28 +0800 In-Reply-To: <20221123015711.707809-1-lixing@loongson.cn> References: <20221123015711.707809-1-lixing@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,GIT_PATCH_0,KAM_SHORT,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP 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 Wed, 2022-11-23 at 09:57 +0800, Xing Li wrote: > The __SYS_mmap syscall should return 47bits value. If we use > the common syscall interface which defined in > sysdeps/unix/sysv/linux/syscall.c, the syscall return value > is 32bits with sign extend, which lead to mmap failure. Could we just change int r =3D INTERNAL_SYSCALL_NCS_CALL (number, a0, a1, a2, a3, a4, a5); in sysdeps/unix/sysv/linux/syscall.c to "long r =3D ..." instead? >=20 > Testcase: >=20 > =C2=A0#include > =C2=A0#include > =C2=A0#include >=20 > void main() > { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0long int ret; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ret =3D syscall(SYS_mmap,= NULL, 0x801000, PROT_READ | > PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0printf("map address is %l= x\n",ret); > } >=20 > Result: > [lixing@Sunhaiyong test]$ ./mmap > map address is fffffffff008c000 >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * sysdeps/unix/sysv/linux/loongarch/= syscall.c: New file > --- > =C2=A0sysdeps/unix/sysv/linux/loongarch/syscall.c | 34 > +++++++++++++++++++++ > =C2=A01 file changed, 34 insertions(+) > =C2=A0create mode 100644 sysdeps/unix/sysv/linux/loongarch/syscall.c >=20 > diff --git a/sysdeps/unix/sysv/linux/loongarch/syscall.c > b/sysdeps/unix/sysv/linux/loongarch/syscall.c > new file mode 100644 > index 0000000000..fe9672a403 > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/loongarch/syscall.c > @@ -0,0 +1,34 @@ > +/* system call interface.=C2=A0 Linux/LoongArch version. > +=C2=A0=C2=A0 Copyright (C) 2001-2022 Free Software Foundation, Inc. > +=C2=A0=C2=A0 This file is part of the GNU C Library. > + > +=C2=A0=C2=A0 The GNU C Library is free software; you can redistribute it= and/or > +=C2=A0=C2=A0 modify it under the terms of the GNU Lesser General Public > +=C2=A0=C2=A0 License as published by the Free Software Foundation; eithe= r > +=C2=A0=C2=A0 version 2.1 of the License, or (at your option) any later v= ersion. > + > +=C2=A0=C2=A0 The GNU C Library is distributed in the hope that it will b= e > useful, > +=C2=A0=C2=A0 but WITHOUT ANY WARRANTY; without even the implied warranty= of > +=C2=A0=C2=A0 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 = See the GNU > +=C2=A0=C2=A0 Lesser General Public License for more details. > + > +=C2=A0=C2=A0 You should have received a copy of the GNU Lesser General P= ublic > +=C2=A0=C2=A0 License along with the GNU C Library.=C2=A0 If not, see > +=C2=A0=C2=A0 .=C2=A0 */ > + > +#include > + > +long int > +syscall (long int syscall_number, long int arg1, long int arg2, long > int arg3, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 long int arg4, long int arg5,= long int arg6, long int arg7) > +{ > +=C2=A0 long int ret; > + > +=C2=A0 ret =3D INTERNAL_SYSCALL_NCS_CALL (syscall_number, arg1, arg2, ar= g3, > arg4, > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 arg5, arg6, arg7); > + > +=C2=A0 if (INTERNAL_SYSCALL_ERROR_P (ret)) > +=C2=A0=C2=A0=C2=A0 return __syscall_error (ret); > + > +=C2=A0 return ret; > +} --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University