Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4057225yba; Wed, 17 Apr 2019 03:45:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy6G99Lw0cJYhGSw5QcCNQSR5+IPOhtXVCwKpK10TSW9Fc4vHW61Nx1mE9iGuOn5QNB9uiW X-Received: by 2002:a65:430a:: with SMTP id j10mr3661111pgq.143.1555497928446; Wed, 17 Apr 2019 03:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555497928; cv=none; d=google.com; s=arc-20160816; b=0D2Kpu/W3ErnrZHYveuFKgFbm3DJP/pLmzKudzGoELMQ+cxqeI3d9m6MjykTac2AhL IcedyQ/S+XJR1rE0jUlbJtsI74A1wsp7lg63Raz+JQvqgaX3SCM+p8uN32J2MFWFRAPj ysCPhfi2M1c0Z3KpaXYjEMIkDaA19H1b5I1Fqf+ck177GiAO9YfNlNu3dg0nmhnSdVNt s0f7kxOZe4y4s/jhg1DgbSecET/CgFhENaNU5lMKNSVTpgkYWF4OxpXbdCjZ79LSVI6Q 8plAiVPJQOlnnPafw7pyx0AX8UL9bh2e6Cec6Y5A/9qtrsGUvTJQUzQidJEi0cExRTGU 73Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=X0ionzIub6NGaI2YQ3b3AsIzZ7nk0uWfVaElcQLHmxk=; b=sW1KlCUw9mkY+149gHI7fcOAXLiT54LxKgwWWyge6mSzyi/0UM7mxmhiliBybNzCFS UD0uWVYIUMZb/Lq2nyK6ks6R1Yq1p9Fp0KhzPNk9ipGOjUafc3FkDs9LsLEWoc97Yy83 vv6/brXeIXQp9C3xdBjQW99mDQ9uW76vZHaC7lqQ5Coa6cfpwk6d4+AcW4Phukbmfetv VcoOHLXB//MZJRp9k/XeyP8Bgtg3Euxz5NDep9nwKBPmy7PsgzUlAVYJ0HsVKLCZo6ld ljULbjstQXrdIU9B0HqgLkoxfMqamy47K0V8r4fmZ5IP96kQGnWIm65wa6L+W5wOD7rX SQVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si50490355pga.257.2019.04.17.03.45.13; Wed, 17 Apr 2019 03:45:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732053AbfDQKnW (ORCPT + 99 others); Wed, 17 Apr 2019 06:43:22 -0400 Received: from mga05.intel.com ([192.55.52.43]:7938 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731813AbfDQKnW (ORCPT ); Wed, 17 Apr 2019 06:43:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 03:43:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,361,1549958400"; d="scan'208";a="150131067" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.189]) by FMSMGA003.fm.intel.com with ESMTP; 17 Apr 2019 03:43:17 -0700 From: Jarkko Sakkinen To: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org Cc: akpm@linux-foundation.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, serge.ayoun@intel.com, shay.katz-zamir@intel.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, Jarkko Sakkinen Subject: [PATCH v20 28/28] docs: x86/sgx: Document the enclave API Date: Wed, 17 Apr 2019 13:39:38 +0300 Message-Id: <20190417103938.7762-29-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> References: <20190417103938.7762-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document the enclave driver API i.e. the set of ioctl's used to create and manage enclaves and set their privileges Signed-off-by: Jarkko Sakkinen --- Documentation/x86/sgx/3.API.rst | 27 +++++++++++++++++++++++++++ Documentation/x86/sgx/index.rst | 1 + 2 files changed, 28 insertions(+) create mode 100644 Documentation/x86/sgx/3.API.rst diff --git a/Documentation/x86/sgx/3.API.rst b/Documentation/x86/sgx/3.API.rst new file mode 100644 index 000000000000..b113aeb05f54 --- /dev/null +++ b/Documentation/x86/sgx/3.API.rst @@ -0,0 +1,27 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=== +API +=== + +The enclave life-cycle starts by opening `/dev/sgx/enclave`. After this there is +already a data structure inside kernel tracking the enclave that is initially +uncreated. After this a set of ioctl's can be used to create, populate and +initialize the enclave. + +You can close (if you want) the fd after you've mmap()'d. As long as the file is +open the enclave stays alive so you might want to do that after you don't need +it anymore. Even munmap() won't destruct the enclave if the file is open. +Neither will closing the fd as long as you have mmap() done over the fd (even +if it does not across the range defined in SECS). + +Finally, there is ioctl to authorize priviliged attributes: +`SGX_IOC_ENCLAVE_SET_ATTRIBUTE`. Each of them is presented by a file inside +`/dev/sgx/`. Right now there is only one such file `/dev/sgx/provision`, which +controls the `PROVISON_KEY` attribute. + +.. kernel-doc:: arch/x86/kernel/cpu/sgx/driver/ioctl.c + :functions: sgx_ioc_enclave_create + sgx_ioc_enclave_add_page + sgx_ioc_enclave_init + sgx_ioc_enclave_set_attribute diff --git a/Documentation/x86/sgx/index.rst b/Documentation/x86/sgx/index.rst index 5d660e83d984..de0b78328611 100644 --- a/Documentation/x86/sgx/index.rst +++ b/Documentation/x86/sgx/index.rst @@ -15,3 +15,4 @@ potentially malicious. 1.Architecture 2.Kernel-internals + 3.API -- 2.19.1