From patchwork Thu Mar 30 11:48:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ayoun, Serge" X-Patchwork-Id: 9653987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83F6C60349 for ; Thu, 30 Mar 2017 11:48:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75C952853A for ; Thu, 30 Mar 2017 11:48:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A3DB2857F; Thu, 30 Mar 2017 11:48:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 075BD2853A for ; Thu, 30 Mar 2017 11:48:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 7412421DFA7BA; Thu, 30 Mar 2017 04:48:49 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B8BEE21DFA7BA for ; Thu, 30 Mar 2017 04:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490874527; x=1522410527; h=from:to:cc:subject:date:message-id; bh=h8hjfm7zXRNPz6mNDNm7SOaYzsUWX/ON8SddhTv9NKs=; b=MxlExAVf6QHT8K0YyRDzNGA9Z7Bb+lGSGLOukWkt1tLmQ7K8pB0XEZx5 k9pKzDgf7UZo0/iGBXSP2tSmuBkM+A==; Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Mar 2017 04:48:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,246,1486454400"; d="scan'208";a="71887382" Received: from skl-ubu14-02.iil.intel.com ([143.185.111.119]) by orsmga004.jf.intel.com with ESMTP; 30 Mar 2017 04:48:45 -0700 From: Serge Ayoun To: intel-sgx-kernel-dev@lists.01.org Date: Thu, 30 Mar 2017 14:48:22 +0300 Message-Id: <1490874502-2898-1-git-send-email-serge.ayoun@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [intel-sgx-kernel-dev] [PATCH] intel_sgx: EINIT errors exposed by ENCLAVE_INIT ioctl return value X-BeenThere: intel-sgx-kernel-dev@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Project: Intel® Software Guard Extensions for Linux*: https://01.org/intel-software-guard-extensions" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-sgx-kernel-dev-bounces@lists.01.org Sender: "intel-sgx-kernel-dev" X-Virus-Scanned: ClamAV using ClamSMTP ENCLS(EINIT) instruction errors (during ENCLAVE_INIT ioctl call) are now returned without a change instead of being translated to OS generic errors. Documentation updated. Signed-off-by: Serge Ayoun --- Documentation/x86/intel_sgx.rst | 24 ++++++++++++++++++++++++ drivers/platform/x86/intel_sgx_ioctl.c | 16 ---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Documentation/x86/intel_sgx.rst b/Documentation/x86/intel_sgx.rst index fb2f9df..1825c92 100644 --- a/Documentation/x86/intel_sgx.rst +++ b/Documentation/x86/intel_sgx.rst @@ -85,6 +85,29 @@ by using the ENCLS(EDBGRD) and ENCLS(EDBGWR) opcodes. The Intel provided launch enclave provides them always a valid EINITTOKEN and therefore they are a low hanging fruit way to try out SGX. +SGX_IOC_ENCLAVE_INIT Description: +================================ + +The SGX_IOC_ENCLAVE_INIT ioctl has a different behavior than the others: its +return value may reflect the possible error returned by the ENCLS(EINIT) +instruction: + +0x0: success +0x1: (SGX_INVALID_SIG_STRUCT) the sigstruct has an invalid field +0x2: (SGX_INVALID_ATTRIBUTE) the token or the sigstruct have an + unexpected or wrong attribute, mask or signer +0x4: (SGX_INVALID_MEASUREMENT) the token or the sigstruct has an invalid + measurement +0x8: (SGX_INVALID_SIGNATURE) signature validation check has failed +0x10: (SGX_INVALID_LICENSE) The token license validation has failed +0x20: (SGX_INVALID_CPUSVN) The token cpu svn used is not supported by + current cpu +0x80: (SGX_UNMASKED_EVENT) system too busy to perform EINIT +0x40000000: (SGX_POWER_LOSS) A sleep transition has occurred and the + enclave is not valid anymore +0x40000001: (SGX_LE_ROLLBACK) The launch enclave isv svn of the the + license is not supported + SGX uapi ======== @@ -94,3 +117,4 @@ SGX uapi sgx_ioc_enclave_init .. kernel-doc:: arch/x86/include/uapi/asm/sgx.h + diff --git a/drivers/platform/x86/intel_sgx_ioctl.c b/drivers/platform/x86/intel_sgx_ioctl.c index e0e2f14..057f311 100644 --- a/drivers/platform/x86/intel_sgx_ioctl.c +++ b/drivers/platform/x86/intel_sgx_ioctl.c @@ -848,22 +848,6 @@ static int __sgx_encl_init(struct sgx_encl *encl, char *sigstruct, out: if (ret) { sgx_dbg(encl, "EINIT returned %d\n", ret); - switch (ret) { - case SGX_UNMASKED_EVENT: - ret = -EBUSY; - break; - case SGX_INVALID_SIG_STRUCT: - case SGX_INVALID_ATTRIBUTE: - case SGX_INVALID_MEASUREMENT: - case SGX_INVALID_SIGNATURE: - case SGX_INVALID_LICENSE: - case SGX_INVALID_CPUSVN: - ret = -EPERM; - break; - default: - ret = -EFAULT; - break; - } } else { encl->flags |= SGX_ENCL_INITIALIZED;