From patchwork Fri Jun 16 21:57:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Angie Chinchilla X-Patchwork-Id: 9793879 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 6CE9D600C5 for ; Sat, 17 Jun 2017 02:00:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53FB628423 for ; Sat, 17 Jun 2017 02:00:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48A2D28547; Sat, 17 Jun 2017 02:00:16 +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 74C2628423 for ; Sat, 17 Jun 2017 02:00:12 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id F1DC621A143F1; Fri, 16 Jun 2017 18:58:52 -0700 (PDT) X-Original-To: intel-sgx-kernel-dev@lists.01.org Delivered-To: intel-sgx-kernel-dev@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 799C921A143F1 for ; Fri, 16 Jun 2017 18:58:51 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jun 2017 19:00:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,349,1493708400"; d="scan'208";a="115994723" Received: from unknown (HELO skl-edmm.rd.intel.com) ([10.243.12.156]) by fmsmga006.fm.intel.com with ESMTP; 16 Jun 2017 19:00:09 -0700 From: Angie Chinchilla To: intel-sgx-kernel-dev@lists.01.org Date: Fri, 16 Jun 2017 17:57:21 -0400 Message-Id: <1497650241-17149-1-git-send-email-angie.v.chinchilla@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [intel-sgx-kernel-dev] [PATCH] 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 --- 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..1840f81 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 = 2ULL << ((edx >> 8) & 0xFF); #endif - sgx_encl_size_max_32 = 2ULL << ((edx >> 8) & 0xFF); + sgx_encl_size_max_32 = 2ULL << (edx & 0xFF); } return sgx_dev_init(&pdev->dev);