Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp41592ybb; Thu, 19 Mar 2020 11:18:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuit6vvglrAGiVBGn9JsIjhazwNxw7itAiTL3gJNUX0P2a83LInY5ys60jhYjBkjfPB5xCJ X-Received: by 2002:a05:6808:103:: with SMTP id b3mr3479534oie.46.1584641934660; Thu, 19 Mar 2020 11:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584641934; cv=none; d=google.com; s=arc-20160816; b=P99KTvAyQ9F4tYqNwZ/+aov1GHtIA4tISlIDwTic5ARvrkTVPRZI7xFtj5z3Av7L2r ncY50iTfKmfgFraAkTwgAywcnbEjn6nCHIbpoHW9Q5Adk8CRsdI0hTqdLDR7DvcB6XED 35Sa4n17iiVdZaruNCE87GLk/dXkoGypYCFgAw5IFJ8+AOith055X6AWwCJBoTjJq6lG Sd2S67E3aZ43d0HvEMUX8IxJrEi3C9pmxQ+zNgsO/jcDzf+dir1RgEreg/EQUCYTFeoB FigF3smCeVjX2BKkbg6urlUWfQZQy2HHw9j+ZY4mH9i86v3hWl98SxPY/mcUaln2eIX6 /DJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:in-reply-to:date:references:subject:cc:to:from; bh=/0VhoRpufkesQrOvH0f/km24kIdzEVStoDYV5YbdPa0=; b=ksBUy7IVl82nBxycF1bHhx6rBLlneTbe+zq/FtRz8i7SoGIZzKs61PGlYk3CmJbmdc i1uMq1Zu4cQFAHAU6iAWqSOx3mC+Xvk81YyHsjVeHrpMgaP0vVveyi+5LrLA3jvHx8PN 7khkAM84kGC3kvtaZbDJ0k/2tvGfKTgGGLVj538F66OdBxEKv3aCKH4HBUXJGEWAZ4iC X1krxPb9vjdTsPIrFebKhj4DjuP0drg6hHdCOaAzQNoFQenuYRO01GctidshyvvbaOR5 q4EqqL7hCOVc98vPUBo1EhUG/0wfdn6EK+mj+ThfK87tF/e+Cq6ZgmpB+65bpNkmJ1va ZvGw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si1287887oie.67.2020.03.19.11.18.24; Thu, 19 Mar 2020 11:18:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbgCSSRr convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 Mar 2020 14:17:47 -0400 Received: from albireo.enyo.de ([37.24.231.21]:51982 "EHLO albireo.enyo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgCSSRr (ORCPT ); Thu, 19 Mar 2020 14:17:47 -0400 Received: from [172.17.203.2] (helo=deneb.enyo.de) by albireo.enyo.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) id 1jEzjc-000123-KO; Thu, 19 Mar 2020 18:17:36 +0000 Received: from fw by deneb.enyo.de with local (Exim 4.92) (envelope-from ) id 1jEziG-0006VC-Ak; Thu, 19 Mar 2020 19:16:12 +0100 From: Florian Weimer To: Mathieu Desnoyers Cc: libc-alpha , carlos , Rich Felker , linux-api , Boqun Feng , Will Deacon , linux-kernel , Peter Zijlstra , Ben Maurer , Dave Watson , Thomas Gleixner , Paul , Paul Turner , Joseph Myers Subject: Re: [RFC PATCH glibc 4/8] glibc: Perform rseq(2) registration at C startup and thread creation (v15) References: <20200319144110.3733-1-mathieu.desnoyers@efficios.com> <20200319144110.3733-5-mathieu.desnoyers@efficios.com> <874kukpf9f.fsf@mid.deneb.enyo.de> <2147217200.3240.1584633395285.JavaMail.zimbra@efficios.com> <87r1xo5o2s.fsf@mid.deneb.enyo.de> <1302331358.3965.1584641354569.JavaMail.zimbra@efficios.com> Date: Thu, 19 Mar 2020 19:16:12 +0100 In-Reply-To: <1302331358.3965.1584641354569.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Thu, 19 Mar 2020 14:09:14 -0400 (EDT)") Message-ID: <87sgi4gqhf.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: >> You also need to add an assert that the compiler supports >> __attribute__ ((aligned)) because ignoring it produces an >> ABI-incompatible header. > > Are you aware of some helper macro I should use to do this, or > is it done elsewhere in glibc ? I don't think we have any such GCC-only types yet. max_align_t is provided by GCC itself. >> The struct rseq/struct rseq_cs definitions >> are broken, they should not try to change the alignment. > > AFAIU, this means we should ideally not have used __attribute__((aligned)) > in the uapi headers in the first place. Why is it broken ? Compilers which are not sufficiently GCC-compatible define __attribute__(X) as the empty expansion, so you silently get a different ABI. There is really no need to specify 32-byte alignment here. Is not even the size of a standard cache line. It can result in crashes if these structs are heap-allocated using malloc, when optimizing for AVX2. For example, clang turns void clear (struct rseq *p) { memset (p, 0, sizeof (*p)); } into: vxorps %xmm0, %xmm0, %xmm0 vmovaps %ymm0, (%rdi) vzeroupper retq My understanding is that vmovaps will trap if the pointer is misaligned (“When the source or destination operand is a memory operand, the operand must be aligned on a 32-byte boundary or a general-protection exception (#GP) will be generated.”). > However, now that it is in the wild, it's a bit late to change that. I had forgotten about the alignment crashes. I think we should seriously consider changing the types. 8-(