All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>,
	Jethro Beekman <jethro@fortanix.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"x86@kernel.org" <x86@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Haitao Huang <haitao.huang@linux.intel.com>,
	"Dr . Greg Wettstein" <greg@enjellic.com>
Subject: Re: x86/sgx: uapi change proposal
Date: Wed, 2 Jan 2019 12:47:52 -0800	[thread overview]
Message-ID: <20190102204752.GG7460@linux.intel.com> (raw)
In-Reply-To: <20181222082502.GA13275@linux.intel.com>

On Sat, Dec 22, 2018 at 10:25:02AM +0200, Jarkko Sakkinen wrote:
> On Sat, Dec 22, 2018 at 10:16:49AM +0200, Jarkko Sakkinen wrote:
> > On Thu, Dec 20, 2018 at 12:32:04PM +0200, Jarkko Sakkinen wrote:
> > > On Wed, Dec 19, 2018 at 06:58:48PM -0800, Andy Lutomirski wrote:
> > > > Can one of you explain why SGX_ENCLAVE_CREATE is better than just
> > > > opening a new instance of /dev/sgx for each encalve?
> > > 
> > > I think that fits better to the SCM_RIGHTS scenario i.e. you could send
> > > the enclav to a process that does not have necessarily have rights to
> > > /dev/sgx. Gives more robust environment to configure SGX.
> > 
> > Sean, is this why you wanted enclave fd and anon inode and not just use
> > the address space of /dev/sgx? Just taking notes of all observations.
> > I'm not sure what your rationale was (maybe it was somewhere). This was
> > something I made up, and this one is wrong deduction. You can easily
> > get the same benefit with /dev/sgx associated fd representing the
> > enclave.
> > 
> > This all means that for v19 I'm going without enclave fd involved with
> > fd to /dev/sgx representing the enclave. No anon inodes will be
> > involved.
> 
> Based on these observations I updated the uapi.
> 
> As far as I'm concerned there has to be a solution to do EPC mapping
> with a sequence:
> 
> 1. Ping /dev/kvm to do something.
> 2. KVM asks SGX core to do something.
> 3. SGX core does something.
> 
> I don't care what the something is exactly is, but KVM is the only sane
> place for KVM uapi. I would be surprised if KVM maintainers didn't agree
> that they don't want to sprinkle KVM uapi to random places in other
> subsystems.

It's not a KVM uapi.

KVM isn't a hypervisor in the traditional sense.  The "real" hypervisor
lives in userspace, e.g. Qemu, KVM is essentially just a (very fancy)
driver for hardware accelerators, e.g. VMX.  Qemu for example is fully
capable of running an x86 VM without KVM, it's just substantially slower.

In terms of guest memory, KVM doesn't care or even know what a particular
region of memory represents or what, if anything, is backing a region in
the host.  There are cases when KVM is made aware of certain aspects of
guest memory for performance or functional reasons, e.g. emulated MMIO
and encrypted memory, but in all cases the control logic ultimately
resides in userspace.

SGX is a weird case because ENCLS can't be emulated in software, i.e.
exposing SGX to a VM without KVM's help would be difficult.  But, it
wouldn't be impossible, just slow and ugly.

And so, ignoring host oversubscription for the moment, there is no hard
requirement that SGX EPC can only be exposed to a VM through KVM.  In
other words, allocating and exposing EPC to a VM is orthogonal to KVM
supporting SGX.  Exposing EPC to userspace via /dev/sgx/epc would mean
that KVM would handle it like any other guest memory region, and all EPC
related code/logic would reside in the SGX subsystem.

Oversubscription throws a wrench in the system because ENCLV can only
be executed post-VMXON and EPC conflicts generate VMX VM-Exits.  But
even then, KVM doesn't need to own the EPC uapi, e.g. it can call into
the SGX subsystem to handle EPC conflict VM-Exits and the SGX subsystem
can wrap ENCLV with exception fixup and forcefully reclaim EPC pages if
ENCLV faults.

I can't be 100% certain the oversubscription scheme will be sane without
actually writing the code, but I'd like to at least keep the option open,
i.e. not structure /dev/sgx/ in such a way that adding e.g. /dev/sgx/epc
is impossible or ugly.

  parent reply	other threads:[~2019-01-02 20:47 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 21:57 [RFC PATCH v5 0/5] x86: Add vDSO exception fixup for SGX Sean Christopherson
2018-12-14 21:57 ` [RFC PATCH v5 1/5] x86/vdso: Add support for exception fixup in vDSO functions Sean Christopherson
2018-12-14 21:57 ` [RFC PATCH v5 2/5] x86/fault: Add helper function to sanitize error code Sean Christopherson
2018-12-14 21:57 ` [RFC PATCH v5 3/5] x86/fault: Attempt to fixup unhandled #PF on ENCLU before signaling Sean Christopherson
2018-12-14 21:57 ` [RFC PATCH v5 4/5] x86/traps: Attempt to fixup exceptions in vDSO " Sean Christopherson
2018-12-14 21:57 ` [RFC PATCH v5 5/5] x86/vdso: Add __vdso_sgx_enter_enclave() to wrap SGX enclave transitions Sean Christopherson
2018-12-19  9:21   ` Jarkko Sakkinen
2018-12-18  4:18 ` [RFC PATCH v5 0/5] x86: Add vDSO exception fixup for SGX Jarkko Sakkinen
2018-12-18 15:08   ` Sean Christopherson
2018-12-19  4:43     ` Jarkko Sakkinen
2018-12-19  5:03       ` Jarkko Sakkinen
2018-12-19  7:58 ` x86/sgx: uapi change proposal Jarkko Sakkinen
2018-12-19  8:41   ` Jethro Beekman
2018-12-19  9:11     ` Jarkko Sakkinen
2018-12-19  9:36       ` Jethro Beekman
2018-12-19 10:43         ` Jarkko Sakkinen
2018-12-19 14:45         ` Sean Christopherson
2018-12-20  2:58           ` Andy Lutomirski
2018-12-20 10:32             ` Jarkko Sakkinen
2018-12-20 13:12               ` Jarkko Sakkinen
2018-12-20 13:19                 ` Jarkko Sakkinen
2018-12-22  8:16               ` Jarkko Sakkinen
     [not found]                 ` <20181222082502.GA13275@linux.intel.com>
2018-12-23 12:52                   ` Jarkko Sakkinen
2018-12-23 20:42                     ` Andy Lutomirski
2018-12-24 11:52                       ` Jarkko Sakkinen
2019-01-02 20:47                   ` Sean Christopherson [this message]
2019-01-03 15:02                     ` Jarkko Sakkinen
     [not found]                       ` <20190103162634.GA8610@linux.intel.com>
2019-01-09 14:45                         ` Jarkko Sakkinen
2018-12-21 16:28             ` Sean Christopherson
2018-12-21 17:12               ` Andy Lutomirski
2018-12-21 18:24                 ` Sean Christopherson
2018-12-21 23:41                   ` Jarkko Sakkinen
2018-12-23 20:41                   ` Andy Lutomirski
2018-12-24 12:01                     ` Jarkko Sakkinen
2018-12-21 23:37                 ` Jarkko Sakkinen
2018-12-22  6:32                 ` Jarkko Sakkinen
2019-01-08 19:27               ` Huang, Kai
2019-01-08 22:09                 ` Sean Christopherson
2019-01-08 22:54                   ` Andy Lutomirski
2019-01-09 16:31                     ` Sean Christopherson
2019-01-10 21:34                       ` Andy Lutomirski
2019-01-10 22:22                         ` Huang, Kai
2019-01-10 23:54                         ` Sean Christopherson
2019-01-11  0:30                           ` Andy Lutomirski
2019-01-11  1:32                             ` Sean Christopherson
2019-01-11 12:58                       ` Jarkko Sakkinen
2019-01-11 13:00                         ` Jarkko Sakkinen
2019-01-11 23:19                         ` Sean Christopherson
2019-01-18 14:37                           ` Jarkko Sakkinen
2019-01-10 17:45                     ` Jarkko Sakkinen
2019-01-10 21:36                       ` Andy Lutomirski
2019-01-11 16:07                         ` Jarkko Sakkinen
2019-01-09  5:24                   ` Huang, Kai
2019-01-09 17:16                     ` Sean Christopherson
2019-01-10  0:21                       ` Huang, Kai
2019-01-10  0:40                         ` Sean Christopherson
2019-01-10 17:43                 ` Jarkko Sakkinen
2018-12-20 10:30           ` Jarkko Sakkinen
2018-12-19 14:43     ` Dr. Greg
2018-12-20 10:34       ` Jarkko Sakkinen
2018-12-20 22:06         ` Dr. Greg
2018-12-21 13:48           ` Jarkko Sakkinen
2018-12-20 12:08     ` Arnd Bergmann
2018-12-20 12:49       ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190102204752.GG7460@linux.intel.com \
    --to=sean.j.christopherson@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=greg@enjellic.com \
    --cc=haitao.huang@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=jethro@fortanix.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.