From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-1.6 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, PDS_OTHER_BAD_TLD,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A276F1F910 for ; Wed, 23 Nov 2022 03:41:06 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="n1uOpU+X"; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 94DA53853D45 for ; Wed, 23 Nov 2022 03:41:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94DA53853D45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669174865; bh=Ytft3F5ELp5Wqktnc7B2V0ihqJqVlBK3vba0aKQZvgY=; h=Subject:To:Cc:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=n1uOpU+XHtDk9J3nLV3nfDW+v8ui0Skm4U4i3HGHj6gUWjQuAYKcBFKAsrn9lDYPh 2BORLewLYh7IiRiio5uJ2DHRcpV30KOD+e7d4Bcui69QH4SInM4gKw7Wvg+o1fe07Q nUI5NQQkGEwAQ/+pLh44nivIAGvuAZ0F4MDflrbc= 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 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 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-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Xi Ruoyao via Libc-alpha Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" 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