Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1443495imm; Tue, 3 Jul 2018 11:12:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWkKLVbx79rD3StPbjRdbDTieCl7jUqs20bogEcWrlbND7FO0oxi1fyQuH8+S4TmMnezP6 X-Received: by 2002:a63:8c0b:: with SMTP id m11-v6mr15078050pgd.372.1530641520954; Tue, 03 Jul 2018 11:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530641520; cv=none; d=google.com; s=arc-20160816; b=cGohs40LM724WbppglkaxJjLolSkM8+jUwU1DpntFZbSqzQw5X2jMsCUmTECsg/CWS mbdUeOH3vmZAIMc2sPE95jB1OIGS5JKMVoASRpFTEG5ttukHcY1Npea5ZMbn07X1+iu6 284+zCAq45QCJbZNQDwK11TG6AYjNjZ3y4Hn7J0Q3oD1PGjbbEhtdUDhnkv7EiYEJBnM Dz1NJzwB8ey94DhSzHMAP6Ot4yvIyK7QI8Ic6970LSM5atkxnMP7mFvjeRnOsBh9df1k B726CrbBkMS2TQQuRa5bULOp9r4NhRBnOsz1DmsY8Aan4EmJTECdQa7LmVu3/kW7EEoo QCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=5GpCN1O2T7w7UlC8gaY+fbCc7hcRVDtZAmFMwCst9Xo=; b=fXZ0QgYMTgMYDSyJOA7VgJUYRdoRNPxGQUvDSI79atd8f8Cqo4H7yQWSBgP2ZsU352 WAp6lNBrw+sLdZTCUpxt0BbSEjVZCYEwKIfsx5j6+ixzJZCD+Qn0qecnlbnHUAgPoG1J 7trDcM2T26BcT2buDl2AzNAkMyDn9ON4Zs0kUOAVqWo9L9P70fFHhnK1HLriGXC9n0yX 8ja4soR6kmj0npq/5V6x8nJ/eI6i+xblx2NrTSPzU9BFr7EyypiXo8jHgiyWP7IX9/ih dHUNTKFpUzCvt6I1pbFhPoysqMiaRBoRFiaUgZ10Pg4nvrCIP68QEKNGtefMdDQF/j3k d4OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Gyp2obm6; 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 m70-v6si1820039pfa.45.2018.07.03.11.11.46; Tue, 03 Jul 2018 11:12:00 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=Gyp2obm6; 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 S934480AbeGCSLC (ORCPT + 99 others); Tue, 3 Jul 2018 14:11:02 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:59780 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934141AbeGCSLA (ORCPT ); Tue, 3 Jul 2018 14:11:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5GpCN1O2T7w7UlC8gaY+fbCc7hcRVDtZAmFMwCst9Xo=; b=Gyp2obm6AuLRLH8H0Ur5ThF6J fyg9ZFnBveFe4/QFU1X30F0Qanh1H5EtehaWfFtzPBCIK+Po9ZUuy1rDQRRaewSni/BpipXXHT8h+ RvhqoxpkerOlLD+e7ak9a+NsYNoCfGw6JJT/6iL+cZIlL/zvSgMuqQo5fLAK20fOxHZKC+Ud97D7W NW1LvDTsH5RZTTo99sTCgik5A2hec9dNzpLFD8/mJvdgNRwBL+JdTejLTTre1Rwjr1CHmwjRWedJP aERtW0u7+6oNxTD8HK+4VnQErRjgtjYQg2MdNy4pHhDZ5kX6elaKmHnF3p41zI2hzB/+6jNZiS0pk Eb5NGQrGg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1faPl1-0003Jg-4H; Tue, 03 Jul 2018 18:10:31 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id ED52B20289CE4; Tue, 3 Jul 2018 20:10:28 +0200 (CEST) Date: Tue, 3 Jul 2018 20:10:28 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Mathieu Desnoyers , Andi Kleen , Heiko Carstens , Andy Lutomirski , Thomas Gleixner , Linux Kernel Mailing List , Linux API , Paul McKenney , Boqun Feng , Dave Watson , Paul Turner , Andrew Morton , Russell King - ARM Linux , Ingo Molnar , Peter Anvin , Christoph Lameter , Ben Maurer , Steven Rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes , Michal Simek , Martin Schwidefsky , gor@linux.ibm.com Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs Message-ID: <20180703181028.GA2494@hirez.programming.kicks-ass.net> References: <20180703082955.GH3704@osiris> <20180703084312.GU2494@hirez.programming.kicks-ass.net> <20180703085546.GJ3704@osiris> <20180703092113.GV2494@hirez.programming.kicks-ass.net> <20180703164048.i2te5gjemcafqzwf@two.firstfloor.org> <20180703173451.GX2494@hirez.programming.kicks-ass.net> <399697782.11820.1530639539750.JavaMail.zimbra@efficios.com> <20180703174833.GZ2494@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 03, 2018 at 10:59:45AM -0700, Linus Torvalds wrote: > On Tue, Jul 3, 2018 at 10:49 AM Peter Zijlstra wrote: > > > > > I can simply document that loads/stores from/to all struct rseq fields > > > should be thread-local then ? > > > > I'm not sure that covers things sufficiently. You really want the > > userspace load/stores to be single instructions. > > Actually, I think we should try very hard to limit even that to _just_ > the rseq pointer itself. > So I'd suggest that the only part we aim to have any "atomic" behavior > at all is for the individual fields in "struct rseq" itself. So the > cpu id and the base pointer and the flags. And even they are > thread-local, so the atomicity is not about the kernel, but about user > space needing to read and update them in word-sized chunks. > > End result: absolutely nothing is atomic for the kernel. Yes, agreed, that is what I meant but very poorly expressed. Only the rseq bits themselves need this single-copy atomic stuff -- for userspace.