On Tue, 2017-11-21 at 01:08 +0200, Jarkko Sakkinen wrote: > On Sat, Nov 18, 2017 at 12:34:33AM +0100, Thomas Gleixner wrote: > > > > This is architecural. From the cursory read of that series it seems there > > are two parts to it: > > > > 1) The actual core handling, which should be in arch/x86 because that > > hardly qualifies as a 'platform' device driver. > > > > 2) The user space interface, which can be separated out perhaps. > > > > I don't know how intertwingled they are, but that's hard to tell from the > > actual patches w/o doing a deep inspection. Jarkko should be able to answer > > that. > > > > Thanks, > > > > tglx > Darren, tglx, > > You can leave user space device as separate module as sgx_ioctl.c merely > calls stuff that I have inside sgx_encl.c. VMA creation is bound to file > operations. > > My questions would be: > > 1. What is your recommendation on the deployment under arch/x86? > 2. Which parts should be compilable as a LKM? Only the user interface > or both parts? > > /Jarkko To enable KVM and a cgroup for EPC accounting, at a minimum arch/x86 needs to manage the EPC pages (alloc/free/lrus/reclaim/etc...) and LE hash MSRs. IMO, ideally everything else would be left in the device driver, e.g. anything involving ENCLS. Keeping the majority of the driver out of arch/x86 minimizes the footprint in arch/x86 and thereby the size of KVM's dependency required to virtualize SGX, and allows the various SGX pieces, e.g. arch, driver and KVM, to evolve more independently. Preferably the arch/x86 code would not be a loadable module, e.g. to simplify KVM support. I have a branch based on Jarkko's patches (I believe it's up-to-date with v5) that implements what I described. I'd be happy to send RFC patches if that would help. Branches for those interested: https://github.com/sean-jc/linux.git sgx/arch - move core EPC to arch/x86 https://github.com/sean-jc/linux.git sgx/kvm - KVM support for SGX https://github.com/sean-jc/linux.git sgx/lc - KVM support for Launch Control https://github.com/sean-jc/linux.git sgx/cgroup - EPC cgroup branch relationships: Jarkko's patches | | sgx/arch / \ sgx/kvm sgx/cgroup / sgx/lc