Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4316305yba; Wed, 17 Apr 2019 09:00:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqySpMKp+nbfoEZzXjft71bQOK7XKmMuFQv799rFkBfhUDZgnMOlO8uxY3DgywCs/66qRQaq X-Received: by 2002:a63:2b41:: with SMTP id r62mr79640340pgr.403.1555516839373; Wed, 17 Apr 2019 09:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555516839; cv=none; d=google.com; s=arc-20160816; b=botQY/NHwPf8sy7m6JTBbmVmAN3S9QVVbKuOkJzHDT1Op/YftUrbMfui/jzzyB6NNH /WUOawYRL+cG2Ax1y2qHKry33MVOHZidKrUc3Eb/tUemJhEAi/GYRjRXZpEp/JLl6SN/ ihOin5T617ioK2Gt29eUDZIi4aqx61pZXjx0kABuZU16EiQuKhkQuMoSpFiurc3MP+ei TO9LoT8WeZTGGp2c2QBHFjJa9jHid/SzFgRQhPe39R3g9jBo3XkN0/EQVdOrH7ktl9dB spK/XERxF2nBj4YiwUl7rqWNPl1LMDTefXilCTK+49D34wlgKuiMkeGT/MHWkPnJobJS rcjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=dnR8YugPKegltgLqamxAPBl6gUcWSxmEPI9eF8Ze/fk=; b=A3QkwAH+ua8802aLoT6/MJedu2w8ym2j5PX14BTg0uGzbr+z8em8YoSLVlONtJF+Sh R2cORGIABzZOAHwlBRGNTJtr6PMsngRMJPAzg7EqQEornwSJECrwubVHkUiAjYTh+Amr G6CHDSFSp2MhNCJt2fYcd6ZYXEBewjgR2xkfMAE5ldoFPgCSvMs6Xl5l0pHEpBHbDuRJ VxfklHR0Vhi1XFB51Q0Oa9xIVlQ8wAuTEjWnXNGPuKg0DtdHIJLARP2FsZGZ7bOTTTpL kkFmEB4jLONKULIhIRW4rrMlpd8ulDraAwf+nq8qvkBYT65JH8/Fr8dljqzF1xdhfo/L JiAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=CpzeGPzQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7si44892185plq.31.2019.04.17.09.00.23; Wed, 17 Apr 2019 09:00:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=CpzeGPzQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732399AbfDQP7b (ORCPT + 99 others); Wed, 17 Apr 2019 11:59:31 -0400 Received: from mail.efficios.com ([167.114.142.138]:59930 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729395AbfDQP7b (ORCPT ); Wed, 17 Apr 2019 11:59:31 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 070421D77E3; Wed, 17 Apr 2019 11:59:30 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id DIEi-4633uHk; Wed, 17 Apr 2019 11:59:29 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 56ECF1D77DC; Wed, 17 Apr 2019 11:59:29 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 56ECF1D77DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1555516769; bh=dnR8YugPKegltgLqamxAPBl6gUcWSxmEPI9eF8Ze/fk=; h=Date:From:To:Message-ID:MIME-Version; b=CpzeGPzQ154KXht4CSM6lwrJPfHzxaOGxQHhzWReRjVER7NWYY+GKd7+ZY4EDvOBi M+T4mtRttkXUncF62CjiWdVFbja7Gg6KqgD6+X2Db42Od4DWwZ8hn+5nMZPzpcK+qa 6psWb+L9ewV49cEdBer5XUuVbpzaIlj9FKPo6lMcrWRc1c4LSM7xne+TUiFC/lfU8/ WV5pU5UFw2vmfwoSWsG2ugynxVxBxAxK2L5RkVL+xb1uMpQvCLK2Jc1qamw1DNMW7K 7jowo7CK5MYY+Y9E2gMhD8XH5QNIob7AD95ozgKvoEJ0rhDmtdeWEYxypsoHsDdR1P ij2Yqua2lYi0A== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id JT5xUcD0TKEO; Wed, 17 Apr 2019 11:59:29 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 3E3961D77D5; Wed, 17 Apr 2019 11:59:29 -0400 (EDT) Date: Wed, 17 Apr 2019 11:59:29 -0400 (EDT) From: Mathieu Desnoyers To: carlos , Will Deacon Cc: Florian Weimer , Joseph Myers , Szabolcs Nagy , libc-alpha , Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Dave Watson , Paul Turner , Rich Felker , linux-kernel , linux-api Message-ID: <364803063.586.1555516769056.JavaMail.zimbra@efficios.com> In-Reply-To: <20190416173216.9028-2-mathieu.desnoyers@efficios.com> References: <20190416173216.9028-1-mathieu.desnoyers@efficios.com> <20190416173216.9028-2-mathieu.desnoyers@efficios.com> Subject: Re: [PATCH 1/5] glibc: Perform rseq(2) registration at C startup and thread creation (v8) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.12_GA_3794 (ZimbraWebClient - FF66 (Linux)/8.8.12_GA_3794) Thread-Topic: glibc: Perform rseq(2) registration at C startup and thread creation (v8) Thread-Index: SE1CutRP0aDD1UrXyGqfkCvIJpHajA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 16, 2019, at 1:32 PM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote: [...] > diff --git a/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h > b/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h > new file mode 100644 > index 0000000000..b02471a89a > --- /dev/null > +++ b/sysdeps/unix/sysv/linux/aarch64/bits/rseq.h > @@ -0,0 +1,32 @@ > +/* Restartable Sequences Linux aarch64 architecture header. > + > + Copyright (C) 2019 Free Software Foundation, Inc. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#ifndef _SYS_RSEQ_H > +# error "Never use directly; include instead." > +#endif > + > +/* RSEQ_SIG is a signature required before each abort handler code. > + > + It is a 32-bit value that maps to actual architecture code compiled > + into applications and libraries. It needs to be defined for each > + architecture. When choosing this value, it needs to be taken into > + account that generating invalid instructions may have ill effects on > + tools like objdump, and may also have impact on the CPU speculative > + execution efficiency in some cases. */ > + > +#define RSEQ_SIG 0xd428bc00 /* BRK #0x45E0. */ After further investigation, we should probably do the following to handle compiling with -mbig-endian on aarch64, which generates binaries with mixed code vs data endianness (little endian code, big endian data): #ifdef __ARM_BIG_ENDIAN #define RSEQ_SIG 0x00bc28d4 /* BRK #0x45E0. */ #else #define RSEQ_SIG 0xd428bc00 /* BRK #0x45E0. */ #endif Else mismatch between code endianness for the generated signatures and data endianness for the RSEQ_SIG parameter passed to the rseq registration will trigger application segmentation faults when the kernel try to abort rseq critical sections. For ARM32, the situation is a bit more complex. Only armv6+ generates mixed-endianness code vs data with -mbig-endian. Prior to armv6, the code and data endianness matches. Therefore, I plan to #ifdef the reversed endianness handling with: #if __ARM_ARCH >= 6 && __ARM_BIG_ENDIAN on arm32. Thoughts ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com