Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5540641pxb; Wed, 26 Jan 2022 14:33:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzGB99oh3F0uS3V2Khy+OlZi+qCrcjujz0Dyo26TAU058nhZE0JaBCT3UdHNnXzi/xAa5gB X-Received: by 2002:a17:907:7f1f:: with SMTP id qf31mr773073ejc.84.1643236382372; Wed, 26 Jan 2022 14:33:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643236382; cv=none; d=google.com; s=arc-20160816; b=arUrdsIPH1rHdZf36yfpue3UqD2RDi3fU3SwzV5EObU1FAwkaIokVKXqpD4RRB7CrM eAm7/+FkEGKzNTeM2jWpMVNbOuRbjVtgONkRCFFADuEZSkdB1aqEfWTzyy272kWk0ao7 Q1nBakZfSRm+rZPr9vcjVmDEmSrXjFRQ+NqlP7crmmn0WoWol6xyrS7G9huxChAyGdI4 4Ga+kM8EyljWwoOTOMwdR2f2UIqnFsyY9Nba/Mcktk0QqnuC8/sn7xkzRCHKbMsX5q8M YwwC4ME1A9LxQKh6Ko9N/QM9ppjpxX7JHuWWA+pK3Ny3T3UbKbL0lN0mkcyw/aGyz4BV TT4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=eICVUmQzw3l/x0zzUTePtqPtDmFZX5u3Ntxlnfacxd4=; b=bBV1uLGMK5gfz7TkQiwZIQapmXhYt3NWnHeMtw7V71JNlPf1q4uddcWT6zx4XHBjhC a9z+MWb+eCX3y9eQiL7vFEDxECAWow3DGGBL/0oUFblRtg32nbxHHj5f1SwunshD2FQ8 WA65oEvLNfpPT1iMAJhEzD+ExROtdDBFd7U9zwsygpZBPfje2enER+I3KXNkSvZWpAfV N+pmCXXZP/Dhj2d/GysDADz5h4pd+h2fRn3CMeu2hsrGZavCirWaqcE7FdDgbv1TP6e1 4S/WdZpl5zX7uB0B6RAuYAVbHFWv6vaYsQ0ucx7uj8GSM2vO3MYrX2zGltBv+2or1vK6 0bWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=sJJ9BIbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id f15si258639ejl.58.2022.01.26.14.32.37; Wed, 26 Jan 2022 14:33:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=sJJ9BIbN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230349AbiAZS77 (ORCPT + 99 others); Wed, 26 Jan 2022 13:59:59 -0500 Received: from mail.efficios.com ([167.114.26.124]:52750 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbiAZS76 (ORCPT ); Wed, 26 Jan 2022 13:59:58 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 94D1C360747; Wed, 26 Jan 2022 13:59:57 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id JRH9cUaMSB7f; Wed, 26 Jan 2022 13:59:56 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id C518036099B; Wed, 26 Jan 2022 13:59:56 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com C518036099B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1643223596; bh=eICVUmQzw3l/x0zzUTePtqPtDmFZX5u3Ntxlnfacxd4=; h=Date:From:To:Message-ID:MIME-Version; b=sJJ9BIbNfPUQAYN4BQ7bO/SrcDKFM5m0qDZbfswYA1jLFKsCzOqzwIPoyVntAI7ld SRGV0U2uVIcFda6/I8d5N6B+NQ4pY/4kjVk8q75vp/7qCnh6+B1j1jBcjmeW66KZQT RoyHefximyQv79nvmWTh4cCNpcXMqhJI5oKtIA0wd8wZ/DhuCRmCL/yGNsOW/gaMiX LtEmS8/kq/oDQ85atWxHbjmGhGIF2A+5mXvU+0Y2IL8m8oxURv2QC2AYJsI4CJ0/4O cNf8GVz5DH5M8iqsbSkQ7Brm4OdzZ4v72njwxK3KAVuavJ6Ar7GIe1NGkk76e3uiOq mqyTIZYMIyXJQ== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4kzbJ7_h7Bql; Wed, 26 Jan 2022 13:59:56 -0500 (EST) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id A117A3606E5; Wed, 26 Jan 2022 13:59:56 -0500 (EST) Date: Wed, 26 Jan 2022 13:59:56 -0500 (EST) From: Mathieu Desnoyers To: David Laight Cc: Christian Brauner , Thomas Gleixner , linux-kernel , Peter Zijlstra , paulmck , Boqun Feng , "H. Peter Anvin" , Paul Turner , linux-api , shuah , linux-kselftest , Florian Weimer , Andy Lutomirski , Dave Watson , Andrew Morton , Russell King , Andi Kleen , Christian Brauner , Ben Maurer , rostedt , Josh Triplett , Linus Torvalds , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Message-ID: <1116876795.2062.1643223596536.JavaMail.zimbra@efficios.com> In-Reply-To: References: <20220124171253.22072-1-mathieu.desnoyers@efficios.com> <20220124171253.22072-3-mathieu.desnoyers@efficios.com> <20220125122156.v2f5anzcs35i3rii@wittgenstein> <1234069751.70438.1643121673355.JavaMail.zimbra@efficios.com> <1445357149.71067.1643137248305.JavaMail.zimbra@efficios.com> Subject: Re: [RFC PATCH 02/15] rseq: Remove broken uapi field layout on 32-bit little endian MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_4203 (ZimbraWebClient - FF96 (Linux)/8.8.15_GA_4203) Thread-Topic: rseq: Remove broken uapi field layout on 32-bit little endian Thread-Index: AdgS2G4EeBx+7+jyRfijfhRZbWR//oaEEpo8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jan 26, 2022, at 12:16 PM, David Laight David.Laight@ACULAB.COM wrote: > From: Mathieu Desnoyers >> Sent: 25 January 2022 19:01 >> >> ----- On Jan 25, 2022, at 9:41 AM, Mathieu Desnoyers >> mathieu.desnoyers@efficios.com wrote: >> >> > ----- On Jan 25, 2022, at 7:21 AM, Christian Brauner brauner@kernel.org wrote: >> [...] >> >>> include/uapi/linux/rseq.h | 17 ++++------------- >> [...] >> >>> union { >> >> >> >> A bit unfortunate we seem to have to keep the union around even though >> >> it's just one field now. >> > >> > Well, as far as the user-space projects that I know of which use rseq >> > are concerned (glibc, librseq, tcmalloc), those end up with their own >> > copy of the uapi header anyway to deal with the big/little endian field >> > on 32-bit. So I'm very much open to remove the union if we accept that >> > this uapi header is really just meant to express the ABI and is not >> > expected to be used as an API by user-space. >> > >> > That would mean we also bring a uapi header copy into the kernel >> > rseq selftests as well to minimize the gap between librseq and >> > the kernel sefltests (the kernel sefltests pretty much include a >> > copy of librseq for convenience. librseq is maintained out of tree). >> > >> > Thoughts ? >> >> Actually, if we go ahead and remove the union, and replace: >> >> struct rseq { >> union { >> __u64 ptr64; >> } rseq_cs; >> [...] >> } v; >> >> by: >> >> struct rseq { >> __u64 rseq_cs; >> } v; >> >> expressions such as these are unchanged: >> >> - sizeof(v.rseq_cs), >> - &v.rseq_cs, >> - __alignof__(v.rseq_cs), >> - offsetof(struct rseq, rseq_cs). >> >> So users of the uapi rseq.h (as an API) can still use rseq_abi->rseq_cs before >> and after the change. > > But: > v.rseq_cs.ptr_64 = (uintptr_t)&foo; > is broken. True. But v.rseq_cs.ptr (on 64-bit) and v.rseq_cs.ptr.ptr32 (on 32-bit) are also broken with the planned field removal. So how is the v.rseq_cs_ptr64 situation different ? My thinking here is that it does not matter if we break compilation for some users of the uapi as an API as long as the ABI stays the same, especially considering that all known users implement their own copy of the header. I suspect that as far as the API is concerned, it is nice that we have at least one way to access the field which works both before and after the change. Simply using "v.rseq_cs" works both before/after for all use-cases that seem to matter here. > >> Based on this, I am inclined to remove the union, and just make the rseq_cs >> field >> a __u64. > > It really is a shame that you can't do: > void *rseq_cs __attribute__((size(8))); > and have the compiler just DTRT on 32bit systems. Indeed, the "size" directive appears to be ignored by the compiler. Thanks, Mathieu > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, > UK > Registration No: 1397386 (Wales) -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com