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: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id CD2B91F45E for ; Tue, 11 Feb 2020 12:14:15 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=Z2z4GarisEyphWbA b7fIygCizSUHJHW32z1pBnHE46RuDSNhSittlVZSXn+ajbMLzO65zEBo/WXRB+DF +IBHWDvOOXZAA+J1N3/khATHHaxtlLXUjRtEod1r62tzk5NjKB2FcrdvBt6Y45Jc X6w7yPLtUjU+vVip1Hj3vC8UeNQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=iDFjVph2B024aOLmSLukRG yF9Rs=; b=HxpkuHe+WInMI/ISWYGCBxpBkLQJ8bKOwrDHNxN5PhTGKuz/nXxrIC Bzm5hnMwfSEy0n/fXt5G4+K3g9h7DVKBHgg7F/p3vcTSk7RYYNfPP/O2WMUgqvcq n6KgUQ/c84q1nT1p6ktmjSQokoIUSGahQzFX2tPTFzmubUv3eDo5I= Received: (qmail 90514 invoked by alias); 11 Feb 2020 12:14:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 90505 invoked by uid 89); 11 Feb 2020 12:14:12 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-qv1-f65.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:cc:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=+FX1HgI7FVr/p2uNxA45m+RodiF6xaOPlCHP+UArtZA=; b=InjnvRApdVFqmLebctX7sxCkeQZPtLF6NkZra2njZOtepZ4wgblko5+0qBsiNm9DA+ KJstUjS3Vzq3U1iMw1lK2WV+yKkb9mwvTTtvwlIP7LEOcFhjRVTKtqNusYgZXHMJuEKl hNK9yHn1qXVw6P/agrsLz8cEESE4tYPJOurV0JXaSQvCd69EnuGagdM7REN/YO1/joC8 U7B+w3LP4i+6UQmy0DsYMcrAHPXZyzmk0AAZm4iG0PKgGb+ZX5Rp2KtOCGbjj9K1FL/A 1fpEPiVobIW6ROnFKbu2rr223KDOCyhpm9Gh/7vx9Y32rKlD168LBZdIrwZuJT+Pxy51 rBng== To: Florian Weimer Cc: libc-alpha@sourceware.org References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> <20200210192038.23588-2-adhemerval.zanella@linaro.org> <874kvxpe2x.fsf@oldenburg2.str.redhat.com> From: Adhemerval Zanella Subject: Re: [PATCH 02/15] powerpc: Use Linux kABI for syscall return Message-ID: Date: Tue, 11 Feb 2020 09:14:05 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <874kvxpe2x.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 11/02/2020 08:18, Florian Weimer wrote: > * Adhemerval Zanella: > >> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h >> index 01c26be24b..abdcfd4a63 100644 >> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h >> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h >> @@ -60,9 +60,8 @@ >> : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), \ >> "+r" (r7), "+r" (r8) \ >> : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory"); \ >> - err = (long int) r0; \ >> __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3)); \ >> - rval; \ >> + (long int) r0 & (1 << 28) ? -rval : rval; \ >> }) >> >> #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ >> @@ -110,21 +109,20 @@ >> : ASM_INPUT_##nr \ >> : "r9", "r10", "r11", "r12", \ >> "cr0", "ctr", "memory"); \ >> - err = r0; \ >> - r3; \ >> + r0 & (1 << 28) ? -r3 : r3; \ >> }) >> #define INTERNAL_SYSCALL(name, err, nr, args...) \ >> INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args) >> >> #undef INTERNAL_SYSCALL_DECL >> -#define INTERNAL_SYSCALL_DECL(err) long 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), __builtin_expect ((err) & (1 << 28), 0)) >> + ((unsigned long) (val) >= (unsigned long) -4095) >> >> #undef INTERNAL_SYSCALL_ERRNO >> -#define INTERNAL_SYSCALL_ERRNO(val, err) (val) >> +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) >> >> #if defined(__PPC64__) || defined(__powerpc64__) >> # define SYSCALL_ARG_SIZE 8 > > What's the baseline for this patch? To simplify the Linux syscall handling on all architectures by using the already set kABI interface (where returns values from 0xfffffffffffff000 to 0xffffffffffffffff indicates an error). The idea is initially to consolidate the INLINE_SYSCALL macro and remove the INTERNAL_SYSCALL_DECL macro. This refactoring is an initial one, my long-term goal is twofold: 1. Remove the assembly macros to define syscall and only use the C interface. It simplifies ports, requires less hackery to handle all its subtitles in C generations (static/pic/etc), and most likely would play nice on a possible LTO build. 2. Rework the syscall interfaces to use static inline instead of macros. It will avoid the argument handling that led to the subtle BZ#25523 bug and it defines a proper kABI interface.