[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201005124221.GA191854@linux.intel.com>
Date: Mon, 5 Oct 2020 15:42:21 +0300
From: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: x86@...nel.org, linux-sgx@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org, linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>,
Jethro Beekman <jethro@...tanix.com>,
Haitao Huang <haitao.huang@...ux.intel.com>,
Chunyang Hui <sanqian.hcy@...fin.com>,
Jordan Hand <jorhand@...ux.microsoft.com>,
Nathaniel McCallum <npmccallum@...hat.com>,
Seth Moore <sethmo@...gle.com>,
Darren Kenny <darren.kenny@...cle.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Suresh Siddha <suresh.b.siddha@...el.com>,
andriy.shevchenko@...ux.intel.com, asapek@...gle.com, bp@...en8.de,
cedric.xing@...el.com, chenalexchen@...gle.com,
conradparker@...gle.com, cyhanish@...gle.com,
dave.hansen@...el.com, haitao.huang@...el.com, kai.huang@...el.com,
kai.svahn@...el.com, kmoy@...gle.com, ludloff@...gle.com,
luto@...nel.org, nhorman@...hat.com, puiterwijk@...hat.com,
rientjes@...gle.com, tglx@...utronix.de, yaozhangx@...gle.com,
mikko.ylinen@...el.com
Subject: Re: [PATCH v39 11/24] x86/sgx: Add SGX enclave driver
On Mon, Oct 05, 2020 at 11:42:46AM +0200, Greg KH wrote:
> > > You use gpl-only header files in this file, so how in the world can it
> > > be bsd-3 licensed?
> > >
> > > Please get your legal department to agree with this, after you explain
> > > to them how you are mixing gpl2-only code in with this file.
> >
> > I'll do what I already stated that I will do. Should I do something
> > more?
>
> This was written before your previous response.
OK, that is weird, I got this one some time later.
> > > > + mutex_lock(&encl->lock);
> > > > + atomic_or(SGX_ENCL_DEAD, &encl->flags);
> > >
> > > So you set a flag that this is dead, and then instantly delete it? Why
> > > does that matter? I see you check for this flag elsewhere, but as you
> > > are just about to delete this structure, how can this be an issue?
> >
> > It matters because ksgxswapd (sgx_reclaimer_*) might be processing it.
>
> I don't see that happening in this patch, did I miss it?
It's implemented in 16/24:
https://lore.kernel.org/linux-sgx/20201004223921.GA48517@linux.intel.com/T/#u
> > It will use the flag to skip the operations that it would do to a victim
> > page, when the enclave is still alive.
>
> Again, why are you adding flags when the patch does not use them?
> Please put new functionality in the specific patch that uses it.
>
> And can you really rely on this? How did sgx_reclaimer_* (whatever that
> is), get the reference on this object in the first place? Again, I
> don't see that happening at all in here, and at a quick glance in the
> other patches I don't see it there either. What am I missing?
I went through the patch, and yes, they can be migrated to 16/24.
I agree with this, no excuses.
In 16/24 pages are added to sgx_active_page_list from which they are
swapped by the reclaimer to the main memory when Enclave Page Cache
(EPC), the memory where enclave pages reside, gets full.
When a reclaimer thread takes a victim page from that list, it will also
get a kref to the enclave so that struct sgx_encl instance does not
get wiped while it's doing its job.
> > Because ksgxswapd needs the alive enclave instance while it is in the
> > process of swapping a victim page. The reason for this is the
> > hierarchical nature of the enclave pages.
> >
> > As an example, a write operation to main memory, EWB (SDM vol 3D 40-79)
>
> What is that referencing?
https://software.intel.com/content/dam/develop/public/us/en/documents/332831-sdm-vol-3d.pdf
> > needs to access SGX Enclave Control Structure (SECS) page, which is
> > contains global data for an enclave, like the unswapped child count.
>
> Ok, but how did it get access to this structure in the first place, like
> I ask above?
I guess I answered that, and I also fully agree with your suggestions.
It used to be many iterations ago that enclaves were not file based but
just memory mappings (long story short: was not great way to make them
multiprocess, that's why file centered now), and then refcount played a
bigger role. Having those "extras" in this patch is by no means
intentional but more like cruft of many iterations of refactoring.
Sometimes when you work long with this kind of pile of code, which has
converged through many iterations, you really need someone else to point
some of the simple and obvious things out.
> > There is a patch that adds "sgx/provision".
>
> What number in this series?
It's 15/24.
>
> > Either works for me. Should I flatten them to "sgx_enclave" and
> > "sgx_provision", or keep them as they are?
>
> Having 2 char nodes in a subdir is better than one, I will give you
> that. But none is even better, don't you think?
I think that having just "sgx_enclave" and "sgx_provision" would be
better.
I've been thinking about this for a while but at the same time try not
to be too proactive without feedback. One reason would be that "enclave"
and "provision" without the subdir are not good identifiers.
I also recalled this discussion:
https://lkml.org/lkml/2019/12/23/158
and was wondering how that subdir would even play with /sys/class/misc,
if we decide to add attributes? Not enough knowledge to answer this.
Anyway, I'll put a note to my backlog on this, and also to move the
previously discussed cruft to the correct patch.
> thanks,
>
> greg k-h
Thank you.
/Jarkko
Powered by blists - more mailing lists