Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2259164ybi; Sat, 13 Jul 2019 10:14:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqy87NmIUkHxHSdef4jBcctGeDUdhm1eoMskI9/JtZnP3dDvPMQGGhWSVbH3oXm34o96NgR8 X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr18647263plg.190.1563038089217; Sat, 13 Jul 2019 10:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563038089; cv=none; d=google.com; s=arc-20160816; b=C2zHgeABQ0qounCdxsGub9COMW+IGEZrLZECQteu4xrS8szGBWDnRqdTCkuJtbJgOB I28pVz85LRhuh7W7VltR/RNt2Lzv7XdMArC4+hu1p31evL9Dggakap7TrMcCLmNlIGsH MaeA6/k98uIN8sw01VcmGC31KnmHr8Fk985JOAJrZESheanTEnjYuDMmejExyyrBlUss AtSUvEK+ozW+ub8qVbfdm+2A5S66jOgi8L6UgBotC4hJDA8xE1a1rrxsT/YkUdI31OtB ha8qA5FzsQcokHZMUdDtU2R16vVkzTu2uUOIOCfH0oLJkYDnALbaX7zTeKP6s/wdgDj6 o6/Q== 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=Y1sf3yn+WcWZEwFC+3yDrGhVTbU/0QvuwG3xJPTEfuQ=; b=lYtSmV4j2TYou7cKBF5RN3sYafxB0lmiVBLFgyd2iqTP1TxNfMdBFh6iUH6DkEqDri biJkguWUn3T7UK6BW1Rg3TVsQ2mdmtqCyaYxu34UX/so2d08rj56SyEU/hs5WgsI18TN xb8cUORQwn4FDLj1WNV0kQtFMVnsLv3PWF9dwZfRA91eG1c9VJwn2HqfML0QP8JxmDgL yTmNZrLiEJdDbzTh8XUAjjyXVFA0n/DQv6ivDF82DOqd0F6ykcR6agkLAky7s/eAkxYG hGDtWQuXdMg0hZa9OYVzR2Y8jDqDlUJwsEmuYtK4Wyu656QaBy8O5vB79TntdV4uHB10 feNg== 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 q3si11015009pgp.497.2019.07.13.10.14.33; Sat, 13 Jul 2019 10:14:49 -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 S1728309AbfGMRNi (ORCPT + 99 others); Sat, 13 Jul 2019 13:13:38 -0400 Received: from mga01.intel.com ([192.55.52.88]:19294 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727936AbfGMRNi (ORCPT ); Sat, 13 Jul 2019 13:13:38 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jul 2019 10:13:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,487,1557212400"; d="scan'208";a="341981751" Received: from hbriegel-mobl.ger.corp.intel.com (HELO localhost) ([10.252.50.48]) by orsmga005.jf.intel.com with ESMTP; 13 Jul 2019 10:13:28 -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, cedric.xing@intel.com, Jarkko Sakkinen Subject: [PATCH v21 28/28] docs: x86/sgx: Document the enclave API Date: Sat, 13 Jul 2019 20:08:04 +0300 Message-Id: <20190713170804.2340-29-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190713170804.2340-1-jarkko.sakkinen@linux.intel.com> References: <20190713170804.2340-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.20.1