linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jethro Beekman <jethro@fortanix.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	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>,
	"sean.j.christopherson@intel.com"
	<sean.j.christopherson@intel.com>
Cc: "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>,
	Andy Lutomirski <luto@amacapital.net>,
	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, 19 Dec 2018 08:41:12 +0000	[thread overview]
Message-ID: <598cd050-f0b5-d18c-96a0-915f02525e3e@fortanix.com> (raw)
In-Reply-To: <7706b2aa71312e1f0009958bcab24e1e9d8d1237.camel@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3795 bytes --]

On 2018-12-19 13:28, Jarkko Sakkinen wrote:
> I have pretty much figured out how to change the driver implementation
> from VMA based to file based. Most of the code in the driver can be
> reused with not that enormous changes. I think it is a clue that the
> architecture is somewhat right because changing the driver this
> radically does not seem to require any changes to the core.

One weird thing is the departure from the normal mmap behavior that the 
memory mapping persists even if the original fd is closed. (See man 
mmap: "closing the file descriptor does not unmap the region.")

> Using anon inode is the right choice because it is more robust interface
> to be able to create multiple enclaves.
> 
> The only remaining open that I have when it comes to implementing this
> is the backing storage. From API perspective the most robust choice
> would be to revert to use shmem file. It would be easy then to create a
> complete construction flow without any dependencies to mm_struct.
> 
> I do recognize the issue with accounting but to which process the
> backing storage should be accounted anyway in this new paradigm.
> 
> I've attached the new uapi header to this email that I'm going forward
> with.
> 
> /Jarkko
> 
> sgx.h
> 
> /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
> /**
>  * Copyright(c) 2016-18 Intel Corporation.
>  */
> #ifndef _UAPI_ASM_X86_SGX_H
> #define _UAPI_ASM_X86_SGX_H
> 
> #include <linux/types.h>
> #include <linux/ioctl.h>
> 
> #define SGX_MAGIC 0xA4
> 
> #define SGX_IOC_ENCLAVE_CREATE \
> 	_IOW(SGX_MAGIC, 0x00, struct sgx_enclave_create)
> #define SGX_IOC_ENCLAVE_ADD_PAGE \
> 	_IOW(SGX_MAGIC, 0x01, struct sgx_enclave_add_page)
> #define SGX_IOC_ENCLAVE_INIT \
> 	_IOW(SGX_MAGIC, 0x02, struct sgx_enclave_init)
> #define SGX_IOC_ENCLAVE_SET_ATTRIBUTE \
> 	_IOW(SGX_MAGIC, 0x03, struct sgx_enclave_set_attribute)
> 
> /* IOCTL return values */
> #define SGX_POWER_LOST_ENCLAVE		0x40000000
> 
> /**
>  * struct sgx_enclave_create - parameter structure for the
>  *                             %SGX_IOC_ENCLAVE_CREATE ioctl
>  * @src:	address for the SECS page data
>  * @enclave_fd:	file handle to the enclave address space (out)
>  */
> struct sgx_enclave_create  {
> 	__u64	src;
> 	__u64	enclave_fd;
> };
> 
> /**
>  * struct sgx_enclave_add_page - parameter structure for the
>  *                               %SGX_IOC_ENCLAVE_ADD_PAGE ioctl
>  * @eclave_fd:	file handle to the enclave address space
>  * @src:	address for the page data
>  * @secinfo:	address for the SECINFO data
>  * @mrmask:	bitmask for the measured 256 byte chunks
>  */
> struct sgx_enclave_add_page {
> 	__u64	enclave_fd;
> 	__u64	src;
> 	__u64	secinfo;
> 	__u16	mrmask;
> } __attribute__((__packed__));

Wouldn't you just pass enclave_fd as the ioctl fd parameter?

How to specify the address of the page that is being added?

> 
> 
> /**
>  * struct sgx_enclave_init - parameter structure for the
>  *                           %SGX_IOC_ENCLAVE_INIT ioctl
>  * @eclave_fd:	file handle to the enclave address space
>  * @sigstruct:	address for the SIGSTRUCT data
>  */
> struct sgx_enclave_init {
> 	__u64	enclave_fd;
> 	__u64	sigstruct;
> }; >
> /**
>  * struct sgx_enclave_set_attribute - parameter structure for the
>  *				      %SGX_IOC_ENCLAVE_INIT ioctl
>  * @addr:		address within the ELRANGE

Stray parameter in docs

>  * @eclave_fd:		file handle to the enclave address space
>  * @attribute_fd:	file handle of the attribute file in the securityfs
>  */
> struct sgx_enclave_set_attribute {
> 	__u64	enclave_fd;
> 	__u64	attribute_fd;
> };

What is this for?

> 
> #endif /* _UAPI_ASM_X86_SGX_H */

--
Jethro Beekman | Fortanix


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3990 bytes --]

  reply	other threads:[~2018-12-19  8:41 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 [this message]
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
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=598cd050-f0b5-d18c-96a0-915f02525e3e@fortanix.com \
    --to=jethro@fortanix.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=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sean.j.christopherson@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).