Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp5812642imd; Wed, 31 Oct 2018 02:22:43 -0700 (PDT) X-Google-Smtp-Source: AJdET5fZgnpH5L6KLTc4L4Ixz7czSJkywBCyUySfZI2iDtEO8B4PHpRuK3boOFZrQmJ7sgBKbrKu X-Received: by 2002:a62:90db:: with SMTP id q88-v6mr2524476pfk.98.1540977763483; Wed, 31 Oct 2018 02:22:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540977763; cv=none; d=google.com; s=arc-20160816; b=YPHGq2pFS5brQhxEullXbi6QUZcWgVkUvSzkh2FloG5sZsZCCdMGJnDuNHwcR5qgXY n6lQJ+Hsy9Qk3G1eUeJA9eBzbpdpERBJ3ci2jPjidB+4PaZH0WQHOtXBZGb/TinThrwU qXDlz/TnFYHgrIqj74dLmtk0shTfTbTzxTDTbskrvi+X7Zu21OSFTGKLEnsKDcMSLHpz Tq6OaFsbPBOePzCvPEpwcFXOtekjLOFLtSgacxcwGfEjNIjfRhQOgmQpO39mRV7QKCWa XUTuiAkW5fosxo5JoSI9M5mOwNQq+E8OnziTlepu36oddJaxnDpdYKPgdrf4fVjkp0kx +dgg== 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; bh=HFdRiotsZPgF4qiPJpcnOuxOYwo8hghVuCSCnAayKTw=; b=TtN3GkgpbyBQqPy/JJ4RKTmEJn8TQGvxt/gWnPfo59NRih/RaaylBVN8J1opIDCXl4 BIaiD+6zBXiEhC0DfBcg3V6/7XFwkTNM94aTD8ygoNhgI6A3HT/eeGvo0ri4cMEl6R0r 6OSDLXtnJIiwjFSKwJMMg0wrp81nF0nA9YEvvls+satdHowgp5ETs6RwnghoCKm+EFwq 4ehbQDl8w/G3E+GCphwljvZNCS0BS3PgqEW+laEk5etqd4L4wSjFBJZPJcO1mBElM6vz dZBAfq9eXttE+kca7DFwa93ck7+8cvu4I38Dqnvru2G3iSxIF3kErwGry9KRLkXHJhRW KMrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=OpJ8Bz2g; 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 p13-v6si27023461pgj.399.2018.10.31.02.22.27; Wed, 31 Oct 2018 02:22:43 -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=merlin.20170209 header.b=OpJ8Bz2g; 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 S1727821AbeJaSId (ORCPT + 99 others); Wed, 31 Oct 2018 14:08:33 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34670 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727436AbeJaSId (ORCPT ); Wed, 31 Oct 2018 14:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=HFdRiotsZPgF4qiPJpcnOuxOYwo8hghVuCSCnAayKTw=; b=OpJ8Bz2gJW3qCAIynQBZGmexu Fcn33YPpIhvE1K5OI5oXO77d6nT9ZQ7/O0xbMY2H30bDFuYK9ijwHJdomKxvDqSg4gJLxi2ryNS90 nK7fcfjxiVK57QdqeR61VMpBapsMrYpBnyDrwan/bTP0lgn29vUiT9Xb4DGgalwDCt56MgGMOBvMB MIDPAO1eyfvFAljBuMXLk9czrEbIJFbUkiPTx4omJxkcFeizNVMXlI1Dt6iR2ZZ5O8K9bh8dYuTXM JbBKEFUImT+Hbk+6utvPvtzg4N7lDFeeaa/4YE+IRKy0yWf1CYdPr2MF8ixCnx4tFpyJpH4GAiX+K Tw5X/2xnA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gHmWY-0002Og-Fg; Wed, 31 Oct 2018 09:10:50 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CC84D2029FA14; Wed, 31 Oct 2018 10:10:48 +0100 (CET) Date: Wed, 31 Oct 2018 10:10:48 +0100 From: Peter Zijlstra To: Will Deacon Cc: Igor Stoppa , Mimi Zohar , Kees Cook , Matthew Wilcox , Dave Chinner , James Morris , Michal Hocko , kernel-hardening@lists.openwall.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, igor.stoppa@huawei.com, Dave Hansen , Jonathan Corbet , Laura Abbott , Boqun Feng , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 16/17] prmem: pratomic-long Message-ID: <20181031091048.GH744@hirez.programming.kicks-ass.net> References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-17-igor.stoppa@huawei.com> <20181025001312.GA3159@worktop.c.hoisthospitality.com> <806bfff0-8d62-9918-480d-ec791b93841e@gmail.com> <20181030155841.GF8177@hirez.programming.kicks-ass.net> <20181030162815.GB20827@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030162815.GB20827@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 30, 2018 at 04:28:16PM +0000, Will Deacon wrote: > On Tue, Oct 30, 2018 at 04:58:41PM +0100, Peter Zijlstra wrote: > > Like mentioned elsewhere; if you do write_enable() + write_disable() > > thingies, it all becomes: > > > > write_enable(); > > atomic_foo(&bar); > > write_disable(); > > > > No magic gunk infested duplication at all. Of course, ideally you'd then > > teach objtool about this (or a GCC plugin I suppose) to ensure any > > enable reached a disable. > > Isn't the issue here that we don't want to change the page tables for the > mapping of &bar, but instead want to create a temporary writable alias > at a random virtual address? > > So you'd want: > > wbar = write_enable(&bar); > atomic_foo(wbar); > write_disable(wbar); > > which is probably better expressed as a map/unmap API. I suspect this > would also be the only way to do things for cmpxchg() loops, where you > want to create the mapping outside of the loop to minimise your time in > the critical section. Ah, so I was thikning that the altnerative mm would have stuff in the same location, just RW instead of RO. But yes, if we, like Andy suggets, use the userspace address range for the aliases, then we need to do as you suggest.