From patchwork Thu Jun 22 15:55:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angie Chinchilla X-Patchwork-Id: 9805257 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 2FB9C60386 for ; Thu, 22 Jun 2017 19:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CB3927FB6 for ; Thu, 22 Jun 2017 19:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D6F7285E3; Thu, 22 Jun 2017 19:58:52 +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=-0.3 required=2.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_NONE 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 A7B8127FB6 for ; Thu, 22 Jun 2017 19:58:51 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C4E0721C943F8; Thu, 22 Jun 2017 12:57:25 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 4E9AC21A07AA1 for ; Thu, 22 Jun 2017 12:57:24 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jun 2017 12:58:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,374,1493708400"; d="scan'208";a="102584980" Received: from unknown (HELO skl-edmm.rd.intel.com) ([10.243.12.167]) by orsmga002.jf.intel.com with ESMTP; 22 Jun 2017 12:58:40 -0700 From: Angie Chinchilla To: intel-sgx-kernel-dev@lists.01.org Date: Thu, 22 Jun 2017 11:55:53 -0400 Message-Id: <1498146953-13117-1-git-send-email-angie.v.chinchilla@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [intel-sgx-kernel-dev] [PATCH v2] intel_sgx: Fix max enclave size calculation 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 sgx_encl_size_max_64 and sgx_encl_size_max_32 calculations are incorrect, causing failures creating large enclaves. 2^EDX[7:0] should be used for max enclave size in 32-bit mode 2^EDX[15:8] should be used for max enclave size in 64-bit mode Signed-off-by: Angie Chinchilla --- Changes in v2: - 1ULL should be shifted, not 2ULL drivers/platform/x86/intel_sgx/sgx_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel_sgx/sgx_main.c b/drivers/platform/x86/intel_sgx/sgx_main.c index cf1e6ec..962768d 100644 --- a/drivers/platform/x86/intel_sgx/sgx_main.c +++ b/drivers/platform/x86/intel_sgx/sgx_main.c @@ -312,9 +312,9 @@ static int sgx_drv_probe(struct platform_device *pdev) cpuid_count(SGX_CPUID, 0x0, &eax, &ebx, &ecx, &edx); if (edx & 0xFFFF) { #ifdef CONFIG_X86_64 - sgx_encl_size_max_64 = 2ULL << (edx & 0xFF); + sgx_encl_size_max_64 = 1ULL << ((edx >> 8) & 0xFF); #endif - sgx_encl_size_max_32 = 2ULL << ((edx >> 8) & 0xFF); + sgx_encl_size_max_32 = 1ULL << (edx & 0xFF); } return sgx_dev_init(&pdev->dev);