This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
- From: Vineet Gupta <Vineet dot Gupta1 at synopsys dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: arcml <linux-snps-arc at lists dot infradead dot org>
- Date: Thu, 20 Feb 2020 20:39:30 +0000
- Subject: Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=synopsys.com; dmarc=pass action=none header.from=synopsys.com; dkim=pass header.d=synopsys.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vtp8iOOps+2l/J/ApCSWtxzxGByFXAtRvUvMbj20srQ=; b=Q6Wu/6HOnQnjNZIsU9fWusL8t8A3+XIRqv3yA0rx6lxnvXnf8Fdlk5pICXFJM5rmV1xFacXSOfPc5eZS+ureQaMKyRWJg+0QSblUoiCjcjmuekrDeqaVUd6c6AsAbYK2UwlFQliZflp2FHsn+BMdQP+lNl1sA/TEvJAzD1AY1gW6dh0seYbs7WkAPBayYllxeGHGb4twqW4aQ1457x4tF9yTZJMpeZ89kgeRiyKzMYXj4dUIcZ6SvBkM8pb2RtKw7ikLXb/Bjp8QaYKEpSQT19/NWRgyuTRbhgYBz9/eHr4lX122cQ/Nql+PBqUTK4FAScHnqEECiH6Ci778ETfeBA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CpJK0cvqh2YBOIDtQTspZsuXNu0j9ACVENYAgF+ODuM3e3UqEUBQPpNs+uDRfZOeGjEmTW8gxB8p2bG0Q1KWvXiT+SAbdw7zXogGk5/mfD2vL02iSYUdHHcvADgB0Qpx18r5QOTlXHTUwyGx5KhSn2PpKRW53pfmZqEjS7fp9r99xGx0MUiH59blvpG+P4qRx7MUJWGg9OrISyCxZPiy/MS1n2DHFKIqmSKijDzQiDhY0vJ1o1tHrCPBFA7NgwGZPDlaRl1PCJbbfPAURIzQGnhQQel3VFmJ983tjIfYWbQfRzOyL0VlDH4TAeLtxy9EOJZhRZ7U4cqZ1nB3XqJOEQ==
- References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> <20200210192038.23588-8-adhemerval.zanella@linaro.org> <10265c86-aba3-12f9-9208-4a4c6ad31d28@synopsys.com> <4d32b8a1-e294-d2b7-f150-2c55281614ed@linaro.org>
Hi Adhemerval,
On 2/20/20 5:14 AM, Adhemerval Zanella wrote:
>
>
> On 19/02/2020 18:40, Vineet Gupta wrote:
>> On 2/10/20 11:20 AM, Adhemerval Zanella wrote:
>>> It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
>>> value instead of 'r2' register value on 'err' macro argument.
>>>
>>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
>>>
>>> Checked with a build against nios2-linux-gnu.
>>> ---
>>> sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +++++-----
>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> index b02730bd23..eab888df32 100644
>>> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>>> @@ -157,13 +157,14 @@
>>> (int) result_var; })
>>>
>>> #undef INTERNAL_SYSCALL_DECL
>>> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
>>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>>
>>> #undef INTERNAL_SYSCALL_ERROR_P
>>> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) (err))
>>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>>> + ((unsigned long) (val) >= (unsigned long) -4095)
>>>
>>> #undef INTERNAL_SYSCALL_ERRNO
>>> -#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
>>> +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
>>>
>>> #undef INTERNAL_SYSCALL_RAW
>>> #define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
>>> @@ -180,8 +181,7 @@
>>> : "+r" (_r2), "=r" (_err) \
>>> : ASM_ARGS_##nr \
>>> : __SYSCALL_CLOBBERS); \
>>> - _sys_result = _r2; \
>>> - err = _err; \
>>> + _sys_result = _err != 0 ? -_r2 : -_r2; \
>>
>> Is there a typo here ? both cases seem to be -ve
>
> It is, thanks for catching it. I have pushed b790c8c2ed to fix and
> double checked nios2 syscall handling (arch/nios2/kernel/entry.S:205)
> to certify that the modification does follow nios2 kABI.
Actually the reason I spotted it was trying to replicate similar changes in ARC
port and it seems to be hosed now. It is quite likely a snaufu at my end, but I
don't quite understand the new logic.
Consider brk syscall which does
__curbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr);
Through a maze of defines this ends up calling INTERNAL_SYSCALL_RAW which seems be
unconditionally converting !0 value (success) into -ve and returning it. So won't
it convert a legit brk address return into a -ve and save in __curbrk.
Am I not following this correctly ?
Thx,
-Vineet