From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id BCF9D385BF81 for ; Tue, 14 Jul 2020 17:03:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCF9D385BF81 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-480-cfgeh06AOReuN45atU6scg-1; Tue, 14 Jul 2020 13:03:11 -0400 X-MC-Unique: cfgeh06AOReuN45atU6scg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 043E98014D7; Tue, 14 Jul 2020 17:03:10 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-246.ams2.redhat.com [10.36.112.246]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B7B779814; Tue, 14 Jul 2020 17:03:08 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: Szabolcs Nagy , Christian Brauner , libc-alpha , Joseph Myers Subject: Re: [RFC PATCH glibc] Linux: Use fixed rseq_len value for rseq registration References: <20200713193434.30440-1-mathieu.desnoyers@efficios.com> <87zh826x9s.fsf@oldenburg2.str.redhat.com> <20200714133352.ykv6qg6brzqlrc26@wittgenstein> <87v9iq6w25.fsf@oldenburg2.str.redhat.com> <1165023597.11584.1594735445006.JavaMail.zimbra@efficios.com> <87lfjm6spp.fsf@oldenburg2.str.redhat.com> <191373869.11732.1594740618639.JavaMail.zimbra@efficios.com> <20200714160120.GA28180@arm.com> <386668376.11934.1594743122356.JavaMail.zimbra@efficios.com> Date: Tue, 14 Jul 2020 19:03:05 +0200 In-Reply-To: <386668376.11934.1594743122356.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Tue, 14 Jul 2020 12:12:02 -0400 (EDT)") Message-ID: <87eepe6ncm.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Tue, 14 Jul 2020 17:03:15 -0000 * Mathieu Desnoyers: > ----- On Jul 14, 2020, at 12:01 PM, Szabolcs Nagy szabolcs.nagy@arm.com wrote: > >> The 07/14/2020 11:30, Mathieu Desnoyers via Libc-alpha wrote: >>> > I think we are looking at this from the wrong perspective. It's not >>> > userspace that is setting the size here, it's the kernel based on the >>> > features it supports. So the kernel should put the size into the >>> > auxiliary vector, and the registration should use that size. But that >>> > doesn't align well with the use of an ELF TLS symbol. >> >> this is why it is better to use a function that returns >> a pointer than a tls symbol as public abi. >> >>> We have a few possible ways to do things here: >>> >>> 1) Kernel exports supported size, incompatible with ELF TLS symbol, >>> >>> 2) Userspace dictates supported size, compatible with ELF TLS symbol, >>> triggers failure if the kernel supports a smaller size, >>> >>> 3) Userspace lets kernel know how much space is available for struct rseq >>> (through user_size field), and the kernel lets user-space know how much >>> of that structure is being filled (through kernel_size field). This >>> would also be compatible with ELF TLS symbol AFAIU, and would allow >>> extending struct rseq. >>> >>> Option (3) would allow us to have the speed gains that come with using a >>> TLS from the fast-path, while allowing extension of struct rseq. >>> >>> Or is there anything in that scheme that breaks ELF rules or C language >>> requirements ? >> >> how would users access those extension fields? > > if (__rseq_abi.flags & RSEQ_TLS_FLAG_SIZE) { > /* Allowed to access user_size and kernel_size. */ > if (__rseq_abi.kernel_size >= offsetof(struct rseq, myfield) + sizeof(((struct rseq *)NULL)->myfield)) { > /* Allowed to access __rseq_abi.myfield. User code should remember this, e.g. in a static variable. */ > } > } Technically, this needs a compiler extension, so that the allowed accesses to the __rseq_abi.myfield field are not moved before the flags and size checks. Thanks, Florian