[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190614224131.q2gjai32la4zb42p@box>
Date: Sat, 15 Jun 2019 01:41:31 +0300
From: "Kirill A. Shutemov" <kirill@...temov.name>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Andrew Morton <akpm@...ux-foundation.org>, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...capital.net>,
David Howells <dhowells@...hat.com>,
Kees Cook <keescook@...omium.org>,
Dave Hansen <dave.hansen@...el.com>,
Kai Huang <kai.huang@...ux.intel.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
Alison Schofield <alison.schofield@...el.com>,
linux-mm@...ck.org, kvm@...r.kernel.org, keyrings@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH, RFC 13/62] x86/mm: Add hooks to allocate and free
encrypted pages
On Fri, Jun 14, 2019 at 03:43:35PM +0200, Peter Zijlstra wrote:
> On Fri, Jun 14, 2019 at 04:28:36PM +0300, Kirill A. Shutemov wrote:
> > On Fri, Jun 14, 2019 at 01:04:58PM +0200, Peter Zijlstra wrote:
> > > On Fri, Jun 14, 2019 at 11:34:09AM +0200, Peter Zijlstra wrote:
> > > > On Wed, May 08, 2019 at 05:43:33PM +0300, Kirill A. Shutemov wrote:
> > > >
> > > > > + lookup_page_ext(page)->keyid = keyid;
> > >
> > > > > + lookup_page_ext(page)->keyid = 0;
> > >
> > > Also, perhaps paranoid; but do we want something like:
> > >
> > > static inline void page_set_keyid(struct page *page, int keyid)
> > > {
> > > /* ensure nothing creeps after changing the keyid */
> > > barrier();
> > > WRITE_ONCE(lookup_page_ext(page)->keyid, keyid);
> > > barrier();
> > > /* ensure nothing creeps before changing the keyid */
> > > }
> > >
> > > And this is very much assuming there is no concurrency through the
> > > allocator locks.
> >
> > There's no concurrency for this page: it has been off the free list, but
> > have not yet passed on to user. Nobody else sees the page before
> > allocation is finished.
> >
> > And barriers/WRITE_ONCE() looks excessive to me. It's just yet another bit
> > of page's metadata and I don't see why it's has to be handled in a special
> > way.
> >
> > Does it relax your paranoia? :P
>
> Not really, it all 'works' because clflush_cache_range() includes mb()
> and page_address() has an address dependency on the store, and there are
> no other sites that will ever change 'keyid', which is all kind of
> fragile.
Hm. I don't follow how the mb() in clflush_cache_range() relevant...
Any following access of page's memory by kernel will go through
page_keyid() and therefore I believe there's always address dependency on
the store.
Am I missing something?
> At the very least that should be explicitly called out in a comment.
>
--
Kirill A. Shutemov
Powered by blists - more mailing lists