Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3186318imu; Fri, 23 Nov 2018 23:37:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VehCtr8z5NG/O3dbMBUUSnSH7drneWWdsMhQMhSw+n1KouqE4WZy5XBaTmli8ZkN9e7gEV X-Received: by 2002:a63:8c2:: with SMTP id 185mr17338751pgi.26.1543045027324; Fri, 23 Nov 2018 23:37:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543045027; cv=none; d=google.com; s=arc-20160816; b=oRYMZuZ2xUO2uRgSXKTmcmwnXHadBzb9VsNOZk16r5yZdG09otYl3425LwlYZal5F6 PEvuPEayuQDGzCBMALW86TvOUUdoh914qWj8wWX65JrHu1QO5U48Mo6wPH+EWfImzdqU uZU1mSD9URmYzB9k4Eql3gJXRJhDcZ9ecWqymHk63u3dwM8VIWAGKEyF8420aTLmPNWr 0mbRrhzsXnDpX/VALmGZYlBzQjaJMmAui5//WhZw6lN1RyOJRYsF81Qb4rXY9iZoPc6i JXunQjmSED802QszvkoxirPLuIBftYT2ONfs4xIGqzRZY2NcpIs3TjyIALao2yp2KCFV v0VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=yWk5Q2KMhxFtebTCYvLWJNAVtksZ74uiL41lCD1gibo=; b=CsJXDrjVo+zhauVo9sbbGsQBB8kA9BUVd5qNxZLUFrl3Aa97JQ5geRDBzZ8TIjgDKC LjMb8sCqxsY2v1oJoyOc/Rvvu7iVmzq1+BxuZgyD+fGYLLrSLjDlwFaymOy2mWieJIQd CDbkRHZjfegbRoPEqURYmI8aQhTUjQTJ6jA0S7CBWqhgUfF4YwZl2tl2q5552m3mYIon BGMS3bZFwgLQp4cuxhQj/ILeaCkx306+Isbl28/UV+BpCofBFlrPdkJAVd+jSbu2UoSJ D9vdueMr2w4ir2bujK2Hs1dj18znGQOylsC0CVZH0QcirYMki+WeY7O8Hxbr77BfMLpd zHhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="vF/rVIqa"; 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 v9si53742435pgo.23.2018.11.23.23.36.52; Fri, 23 Nov 2018 23:37:07 -0800 (PST) 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=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="vF/rVIqa"; 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 S2406756AbeKWHfM (ORCPT + 99 others); Fri, 23 Nov 2018 02:35:12 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46345 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731743AbeKWHfM (ORCPT ); Fri, 23 Nov 2018 02:35:12 -0500 Received: by mail-wr1-f66.google.com with SMTP id l9so10410735wrt.13 for ; Thu, 22 Nov 2018 12:54:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yWk5Q2KMhxFtebTCYvLWJNAVtksZ74uiL41lCD1gibo=; b=vF/rVIqaMPhwF9p+EBeHZmWm+gX9jSVviiwtAHK0ybpRFkWf7AQ5/t54m580ItKGSf p3KPht5N1pxnRP28k69UlX3YkEFw//lyfq4GE7Zq6XpKJYelvHVkn9YrYgRHowh3abbQ kdDL113OtEXzSW/241DIghIiTHxHXx1SQa26a04SFCtb6VcOhf6+h6LhItMIHuEgX2Ln 2Y9I2ZIW5fneanOKSdpJq73n21JeHbZwQzleS+srTHZ3no/8HJSue1cACZgJamu3tkvK QrNl03CkNjUnsyC6KgivOAI+mUlA5YvJdnIzyYXbq4rSrAzIkBQtU8QQx6j9bbtGHu0K NAIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yWk5Q2KMhxFtebTCYvLWJNAVtksZ74uiL41lCD1gibo=; b=TlRAqaJsHSgotxbVkJSAvSNiDK36ZJR9CIgFD//sE5tNNKNKkU2Rr+e4EkfzFUtdn/ ILw/jqeJ6vX3JtDp9YU2g1TyECQdOZD1EVHpaVMnAfkfssiWdKbP25DbCbUbJDYq8xu1 bnMCmeqY/1on/qkvvu8x6f8C9O86yRjeUNXfUu9QKU9t/m4723MAGQzqfPDP1wEerOz4 Q4nA3CpLbo4cgeFzHeBMd6hK4JmBh6QKDPeIHgrM9CLYxf3RETG2kWp8RCdwCPdvZPJd 20Jh5NS6Krizo1nR3S7AoL1UFZBGK2OnBCHJjyoSyK5DbyRL3s4yV93anX60/UPDzw0w +Euw== X-Gm-Message-State: AA+aEWbIEk9g0aD5FMixWci5j1nUcbhAWC2yPVFEHA2qi56gV42FL9lQ uIbNp4/98qAyBdYVygurD0lxNLNgINug0+yEjlmrkg== X-Received: by 2002:adf:ea81:: with SMTP id s1mr10927772wrm.309.1542920045656; Thu, 22 Nov 2018 12:54:05 -0800 (PST) MIME-Version: 1.0 References: <6f60afc9-0fed-7f95-a11a-9a2eef33094c@gmail.com> <386C0CB1-C4B1-43E2-A754-DA8DBE4FB3CB@gmail.com> <9373ccf0-f51b-4bfa-2b16-e03ebf3c670d@huawei.com> <2e52e103-15d0-0c26-275f-894dfd07e8ec@huawei.com> <1166e55c-0c06-195c-a501-383b4055ea46@gmail.com> <3BB9DE07-E0AE-43E2-99F1-E4AA774CD462@amacapital.net> <5e10c8e4-aa71-1eea-b1ce-50d7d0a60e8c@gmail.com> <20181122200416.GS3065@bombadil.infradead.org> In-Reply-To: <20181122200416.GS3065@bombadil.infradead.org> From: Andy Lutomirski Date: Thu, 22 Nov 2018 12:53:52 -0800 Message-ID: Subject: Re: [PATCH 10/17] prmem: documentation To: Matthew Wilcox Cc: Igor Stoppa , Andrew Lutomirski , Igor Stoppa , Nadav Amit , Kees Cook , Peter Zijlstra , Mimi Zohar , Dave Chinner , James Morris , Michal Hocko , Kernel Hardening , linux-integrity , LSM List , Dave Hansen , Jonathan Corbet , Laura Abbott , Randy Dunlap , Mike Rapoport , "open list:DOCUMENTATION" , LKML , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 12:04 PM Matthew Wilcox wrote: > > On Thu, Nov 22, 2018 at 09:27:02PM +0200, Igor Stoppa wrote: > > I have studied the code involved with Nadav's patchset. > > I am perplexed about these sentences you wrote. > > > > More to the point (to the best of my understanding): > > > > poking_init() > > ------------- > > 1. it gets one random poking address and ensures to have at least 2 > > consecutive PTEs from the same PMD > > 2. it then proceeds to map/unmap an address from the first of the 2 > > consecutive PTEs, so that, later on, there will be no need to > > allocate pages, which might fail, if poking from atomic context. > > 3. at this point, the page tables are populated, for the address that > > was obtained at point 1, and this is ok, because the address is fixed > > > > write_rare > > ---------- > > 4. it can happen on any available core / thread at any time, therefore > > each of them needs a different address > > No? Each CPU has its own CR3 (eg each CPU might be running a different > user task). If you have _one_ address for each allocation, it may or > may not be mapped on other CPUs at the same time -- you simply don't care. > > The writable address can even be a simple formula to calculate from > the read-only address, you don't have to allocate an address in the > writable mapping space. > Agreed. I suggest the formula: writable_address = readable_address - rare_write_offset. For starters, rare_write_offset can just be a constant. If we want to get fancy later on, it can be randomized. If we do it like this, then we don't need to modify any pagetables at all when we do a rare write. Instead we can set up the mapping at boot or when we allocate the rare write space, and the actual rare write code can just switch mms and do the write.