Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1618975pxb; Mon, 12 Apr 2021 02:32:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNIE8ZGLW/z/bWj1bBmwCoEMJVZ09GUgD7nNwP897p8WMNgZ5WTdzJ1azfYdSI/tXDROxd X-Received: by 2002:a63:1716:: with SMTP id x22mr26237687pgl.261.1618219955235; Mon, 12 Apr 2021 02:32:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618219955; cv=pass; d=google.com; s=arc-20160816; b=z4W1+WvmO1NQzHxxVZdEf03q4wulJhh2L8RN/M+1RLpHHrh/LAzJbxr6d8xw1oY5MH YHq58bqRU5PL8rnPbvb1n41m6JgrU2fqCm1VxykZez5AG7mY960GzTQ3+PAF/PWcRUKH uDj1KKf35gu351uYz09rMEf5O2rAEImHe+T+QtEznvCxOU0TtLPoWrkB9FcEsTe+o0bF 1yirCarHefopu/lThKqhcVGVOZtaDrFwEv0hCk3TmuOTIRUM5PorjhC1ZuqsaVNjy1cF 8g4SLNAehzcgeeUZZzUV5m9qkNb0g1VZzudqQHUGCTQVvMIyVbIdXJC6AjVDsoAS1FEz WSuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:autocrypt :references:to:subject:from:dkim-signature; bh=0TIMyh1T7JtlOImyWg9N1qmyoboI7O2xx1L9OBV80WA=; b=MZy/e2a6Vrq+drcHeWEAw0oo22Os8rmJ14KZHg6I2g8ANAWp02KSgZkRThZ3lmqO+L /EXsH6DWqhuKpjHb4yjtKhSuQHKabt1ohJRB3lhZkKks6ZGEP8flg4XuchKrzqqF93Ha 9mmLdiHbQFrGzWimEWYUaOd3pbCaxGL4COoarLmb0mwOr9pnxGGOe6RtvzZ6TKaVgkOP /CxF1Fvfj/2MG1XKp7jQcIco1ZfnZFijcGxwmr8QpCiWejgctG43IPFIf0YOZHZ8T7ig GCQUPHAVn+JQCIuNZ9qQNZDeS2S79rBl4P7vvxbIws6konZZvmBGAvTxuA5UiNLczuaQ OJ4w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fortanix.onmicrosoft.com header.s=selector2-fortanix-onmicrosoft-com header.b=amGMm+5U; arc=pass (i=1 spf=pass spfdomain=fortanix.com dkim=pass dkdomain=fortanix.com dmarc=pass fromdomain=fortanix.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fortanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k71si13810485pfd.329.2021.04.12.02.32.21; Mon, 12 Apr 2021 02:32:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fortanix.onmicrosoft.com header.s=selector2-fortanix-onmicrosoft-com header.b=amGMm+5U; arc=pass (i=1 spf=pass spfdomain=fortanix.com dkim=pass dkdomain=fortanix.com dmarc=pass fromdomain=fortanix.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=fortanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237964AbhDLJ3r (ORCPT + 99 others); Mon, 12 Apr 2021 05:29:47 -0400 Received: from mail-dm6nam12on2125.outbound.protection.outlook.com ([40.107.243.125]:21408 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240410AbhDLJF7 (ORCPT ); Mon, 12 Apr 2021 05:05:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UdtQiae4CiTlqk25m8FCCdg4Ve0p5XYyoyugg8R1CZddoSWlBDeRCbMrT4Nn1B4LI7eJgc+nGSQtpaQQfLliKN3JEOYC799ja2iSNF02R8uVKw7Wmcr/4MnTuXDIJnaR+ona+yA8lopazaCqIjjNlF5eBuplAc18thnEPrTI2dLgcpn/BcDyrFjZ7K+gHPW8Rn5nafxJLh6cG36aKNjL8FJFnzNutEcDf2Ykv91qqh2yIsOQOUDZmFRgGLGeXSWFzSAAnGUCz+EbpW0H19RhoOfvvxo++puaY5xrEuAApMpufrY25omH+SXolFJJHNul7IIQDq5O+EyHEF1qlHWNZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0TIMyh1T7JtlOImyWg9N1qmyoboI7O2xx1L9OBV80WA=; b=ln/B7skjQnHMZL0haMEMS+spALykwLGbvZJoTMa4orkuGGdFncluy+P1uUYsWVhK2V8jtGJkuBL9xrTXTNGL7YcYJRm/J4UJI46ysSXzt5b8hqc86COxctuo0ipTGfBQtQCWjBQIynL8+B5moMKW3i1soZHvnW6yvNk/RwHZ7tf8LgDxyhMRXq9c5s7HlTfa4AfKC8JTOKqjzCvl4S7cyjnCY0/nONrDiqsWnf+K0UN8jV6h/QB9iyxyYDzsClVYQ/NXeIlLoKGsCTAu+DZvEDDfi3cRyIkEVHElnnNOY0urCYf60LcKtdNnw1b5K/996ije67eOOcve/zqhLgWtpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=fortanix.com; dmarc=pass action=none header.from=fortanix.com; dkim=pass header.d=fortanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fortanix.onmicrosoft.com; s=selector2-fortanix-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0TIMyh1T7JtlOImyWg9N1qmyoboI7O2xx1L9OBV80WA=; b=amGMm+5UujIHQWWbjeG0J768uuboRyq11Weg0bCCB7gmpGJCUl0xpbuRZewFtaxbO+pNQpOsOj5+qujQtoBqTafX+S9CdzMmSuKiyeuODeRk/E0QSyo/CVCUzmbncFr6atAU8adPaxyvxeDoxFkXORGPUPOj1pUR4fZClCXBQdA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=fortanix.com; Received: from CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) by CY4PR11MB1384.namprd11.prod.outlook.com (2603:10b6:903:2c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.21; Mon, 12 Apr 2021 09:05:25 +0000 Received: from CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1]) by CY4PR11MB1783.namprd11.prod.outlook.com ([fe80::f052:14fe:c2a9:5fb1%3]) with mapi id 15.20.4020.022; Mon, 12 Apr 2021 09:05:25 +0000 From: Raoul Strackx Subject: [PATCH v2 3/3] x86/sgx: eextend ioctl selftest To: Jarkko Sakkinen , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org References: Autocrypt: addr=raoul.strackx@fortanix.com; keydata= LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgptUUlOQkYyb2lmOEJFQURN UkFMT1ZjRkYyTlQva1FsWTBtVnN3YlMrYi9WNzR1azZFcDdxenpoNHpHbEtSS1pzClplS0I4 WmpFT2h5Q2pZaExwdnJHTVh2cTV1bm5pWENIbG9BR1hZRm9rN0Q0SGd2Q0djYnlTYVRMQjds NHc4MFIKOStYUkp2SnJpMEdPSmVubjRnNUpIQU5RN2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3FCZ3RK am9wS2NWVGsxRnRLVGUyZHJ3Z25Bb1M2dkh4bTdRTWxJVwpaMTluS25GOFAyN0pFanU0ckdX Z1h3NkgxSmFKMTF4YVVkZG9qdk53T1RKRVcvb3Jhd2tuUUF1ZW5EYnpBR1Z1CkdMV0w3T2ov RGZyTFBBemNXV25GblV2VVc2NEFEWFNBOTh0SWNBY3lod05uY2lqYnNIUkFTQlJidkg5RFhJ c2wKaEwxMDArdzZNTWNMeFpNVmJ4UHBTWWVHaGp4SjdNUysyeGp3eDB4MWlMNmszZk5UNHNT Q3dZa0xRZjJlKzhxYwpFYjNTa0Q0VFR3RDQxUW85SFNuUlkwdnRqblNyZkwyQ3JhVmptOXhh MXhmNlJDQ3kvaXpKNU5TQTZZMXduT0U3Ck1IOHorcVFUM1NxMld0a0NzU1M5K1U2VU9OWmFK dFN5MWNvZ1ZhMDV1QWdRY0tHT3FvcHg3QWlmZUhIUFpqZnIKakVNaHJZQ3Q5WXgzR1VET0hs MnRObDJIOStqZC9BVjByMDRKUTNxSHRWM1Z5UTNxN0N1UTlCTTdnQzVpK1JleQpHSU14Zm0v a09GWTRLRUxOeVYrV01PK2lXRHpZS21tTUxnUkVXNitqZk5jMzhrYWhaQjI2RmJOZTh6QmxU cVpPCmhxYmNZR1ZZNW9Ec004YSthbkwyZDhmaStnPT0KPW9ZT0QKLS0tLS1FTkQgUEdQIFBV QkxJQyBLRVkgQkxPQ0stLS0tLQo= Message-ID: Date: Mon, 12 Apr 2021 11:05:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [81.164.43.210] X-ClientProxiedBy: AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) To CY4PR11MB1783.namprd11.prod.outlook.com (2603:10b6:903:11d::20) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.101] (81.164.43.210) by AM0PR10CA0049.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:150::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Mon, 12 Apr 2021 09:05:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b277c64-2977-4d30-bfca-08d8fd921c31 X-MS-TrafficTypeDiagnostic: CY4PR11MB1384: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJXKH+bZzhcVZisvDlT/PpoE498M5uFjdFxQe+sI/0RsvWUiMDlbpQVJEDvE5jLP8chfWSaSUNA97cmBqg9qZoE+httsOwRSpA8I0EEuF0Zzk+7FE64lzvzKdnLYYe6LydTkRAqeQouziJXcjPU6NfaxsVC32BfIgRPDsF+weyPGKGYIl+R5810A0qi4WSrurIzk7HAAte+DC3bwxofwkT/LvpoQ8vww8zt6oDJQE8cDf+Lv8bMu0GmbIVfY+nQQ8mrERKRbiZB63W6jiphMtLy8H8BZY8E5IMyxcSo0DETkm0vnX6rugRa5SqFZ+z/kfYBcFPhNE+hweRsmCWu0EVWviMWDRY4rb8RcXkida8kQU3qC9UM7eC/YeCR/FvPfELosSp4CFKFE5+IMYx5YNf8eHgzKcSRnNOic4XsFzOcNc3nPnUvH8mvMWdCHrhPPVncZKbjBWw6wOkMgBODWCsLcuwpZFnl0iycfNX8W3qRBXsXgI8kUwrvV0ygC3vip1PCotACjmEgiRCN1YwHavNjXJUwNFqLbypCzvUSRPuz1km7Z70G0hMKPfpv/NJMXvyhCXhMEMiadzh1YX7/0BaMmdQLczp+EYawr+nNVJphzTS0ybcz0gMqVS4ES1T7VtXRYamonvU4lj66yM2oGmB/zD3d4GEil3tGOfcqGLX/n9JYuvR97EfTfPOEew6yUQZ1y0ejeHRz2YXtrd33izUEFsgi/4M1M0lvxVwY00SI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1783.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(346002)(39830400003)(376002)(136003)(396003)(366004)(26005)(66476007)(6486002)(186003)(16526019)(66556008)(44832011)(5660300002)(2616005)(38350700002)(316002)(86362001)(6666004)(956004)(66946007)(52116002)(31686004)(8936002)(8676002)(110136005)(36756003)(16576012)(2906002)(83380400001)(478600001)(38100700002)(31696002)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?blVTM21SNzkzTldVMytjbWJjbGtUUVlsYmtpMC92R1VMVDBUbjRta1lBemhU?= =?utf-8?B?UXY3Z2d5a2M4VzlsRTJwMHRmR1JOaktUU1l0SjlrQ2NXSVlFUUNhalFqWmFO?= =?utf-8?B?VEl2STlpTjJFYUxQS2tJeDlzYzErMlhjU3FKRzl5ckNibFJkTHpYR3B1Rk1T?= =?utf-8?B?RGowSU5SNm1wZFpRSEFXQzhmUUo4YjhtQlIvNS80c3RFNWFGUDlkcGVtQlhU?= =?utf-8?B?UmZla0lKdDhjKzhiZDZWRWhmUCtOVnBnaUR1aUpBODJGeE1VUzNxVUpIODVp?= =?utf-8?B?M0VMb2UzZFhia05qaFlYZWNqSlJHOVc2SFNYUWd2Wk14MVZkUTJObFFnNlQ0?= =?utf-8?B?UmtGaDhMUVRZbXplNE1OM0dIbHF5ZVdRdGE1Q2JDZThoQ1cvNWczUXRscktj?= =?utf-8?B?amd1S2tiaThZZlp1YUphaUZoempudGw2TmJPSzBTYkE2UGllYXRTYmp6SGxk?= =?utf-8?B?bWppci8vVlplbXgrS0hXbjdwcDR1anpoVFpqdHZNbGthTmdSTUJ2WHdGcElI?= =?utf-8?B?UkVlNCtLc2VraVExS2pTc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FvS1hwZmM1T3ZtY09rNURXVXluWTNHdm52a1JEOFFWOXUrd1FH?= =?utf-8?B?US90ZTVxSnQ2eE9DZXptaDFZdWxNN0NYMGZVMXNSTngxTGFhRy9LdW1QM3hU?= =?utf-8?B?RXlCQlFWTzVRb01yY05jNnVRNUFIN2QydjJRNmM3YUZSZHVvK2xxWXp3YUlw?= =?utf-8?B?dFEwVG9GSHVTNmtmYXhCV2M5anFPTVlKVjM2MmFTTU16dWFUZTFKSFVWOE5j?= =?utf-8?B?N1BvWWwxZEVTbXU2eklpMmRIY1JGMThheEEzSGhyM2p4a21LMGdYd09VM1pL?= =?utf-8?Q?x3sgpFUy1d+4ojwdcHBvJMBSPBBgAYu92zxCZEZ?= X-OriginatorOrg: fortanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b277c64-2977-4d30-bfca-08d8fd921c31 X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1783.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2021 09:05:25.5139 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: de7becae-4883-43e8-82c7-7dbdbb988ae6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0wWAfBmcR+UJOyDaFugcZtCrh8OcznnjAOuX4Hhk8qzdhkAJ2y3/GDqccNCsbI7SkuL6D9RV1Nl4goyGcendxReThj9zVliamPCNNNH6ob8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB1384 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to test the new eextend ioctl, the SGX selftest is modified to only partially measure the last page of segments. Most segments are larger than 4k, so the MEASURE flag for SGX_IOC_ENCLAVE_ADD_PAGE is still being tested. Signed-off-by: Raoul Strackx --- tools/testing/selftests/sgx/defines.h | 1 + tools/testing/selftests/sgx/load.c | 57 ++++++++++++++++++++++++++++----- tools/testing/selftests/sgx/main.h | 1 + tools/testing/selftests/sgx/sigstruct.c | 38 +++++++++++----------- 4 files changed, 69 insertions(+), 28 deletions(-) diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftests/sgx/defines.h index 592c1cc..c09550d 100644 --- a/tools/testing/selftests/sgx/defines.h +++ b/tools/testing/selftests/sgx/defines.h @@ -10,6 +10,7 @@ #define PAGE_SIZE 4096 #define PAGE_MASK (~(PAGE_SIZE - 1)) +#define SGX_EEXTEND_BLOCK_SIZE 256 #define __aligned(x) __attribute__((__aligned__(x))) #define __packed __attribute__((packed)) diff --git a/tools/testing/selftests/sgx/load.c b/tools/testing/selftests/sgx/load.c index 9d43b75..39484fc 100644 --- a/tools/testing/selftests/sgx/load.c +++ b/tools/testing/selftests/sgx/load.c @@ -102,28 +102,69 @@ static bool encl_ioc_create(struct encl *encl) static bool encl_ioc_add_pages(struct encl *encl, struct encl_segment *seg) { struct sgx_enclave_add_pages ioc; + struct sgx_enclave_extend ioc_extend; struct sgx_secinfo secinfo; + uint64_t size_full_pages; + uint64_t size; + uint64_t chunk_offset; int rc; + size_full_pages = size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE) & PAGE_MASK; + size = size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE); + memset(&secinfo, 0, sizeof(secinfo)); secinfo.flags = seg->flags; + // Add and extend full pages ioc.src = (uint64_t)encl->src + seg->offset; ioc.offset = seg->offset; - ioc.length = seg->size; ioc.secinfo = (unsigned long)&secinfo; + ioc.length = size_full_pages; ioc.flags = SGX_PAGE_MEASURE; - rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); - if (rc < 0) { - fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", - errno); - return false; + if (ioc.length > 0) { + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", + errno); + return false; + } + } + + if (size_full_pages < size) { + // Add last, partly measured page + ioc.offset = seg->offset + size_full_pages; + ioc.length = 0x1000; + ioc.flags = 0; + + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_ADD_PAGES, &ioc); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_ADD_PAGES failed: errno=%d.\n", + errno); + return false; + } + + // extend chunks + for (chunk_offset = 0; chunk_offset < size - size_full_pages; + chunk_offset += SGX_EEXTEND_BLOCK_SIZE) { + ioc_extend.offset = seg->offset + size_full_pages + chunk_offset; + rc = ioctl(encl->fd, SGX_IOC_ENCLAVE_EXTEND, &ioc_extend); + if (rc < 0) { + fprintf(stderr, "SGX_IOC_ENCLAVE_EXTEND failed: errno=%d.\n", + errno); + return false; + } + } } return true; } +uint64_t size_fit(uint64_t size_in_bytes, uint64_t block_size) +{ + return (size_in_bytes + block_size - 1) & (~(block_size - 1)); +} + bool encl_load(const char *path, struct encl *encl) { Elf64_Phdr *phdr_tbl; @@ -197,7 +238,7 @@ bool encl_load(const char *path, struct encl *encl) } seg->offset = (phdr->p_offset & PAGE_MASK) - src_offset; - seg->size = (phdr->p_filesz + PAGE_SIZE - 1) & PAGE_MASK; + seg->size = phdr->p_filesz; printf("0x%016lx 0x%016lx 0x%02x\n", seg->offset, seg->size, seg->prot); @@ -209,7 +250,7 @@ bool encl_load(const char *path, struct encl *encl) encl->src = encl->bin + src_offset; encl->src_size = encl->segment_tbl[j - 1].offset + - encl->segment_tbl[j - 1].size; + size_fit(encl->segment_tbl[j - 1].size, PAGE_SIZE); for (encl->encl_size = 4096; encl->encl_size < encl->src_size; ) encl->encl_size <<= 1; diff --git a/tools/testing/selftests/sgx/main.h b/tools/testing/selftests/sgx/main.h index 67211a7..9d63bda 100644 --- a/tools/testing/selftests/sgx/main.h +++ b/tools/testing/selftests/sgx/main.h @@ -34,6 +34,7 @@ void encl_delete(struct encl *ctx); bool encl_load(const char *path, struct encl *encl); bool encl_measure(struct encl *encl); bool encl_build(struct encl *encl); +uint64_t size_fit(uint64_t size_in_bytes, uint64_t block_size); int sgx_call_vdso(void *rdi, void *rsi, long rdx, u32 function, void *r8, void *r9, struct sgx_enclave_run *run); diff --git a/tools/testing/selftests/sgx/sigstruct.c b/tools/testing/selftests/sgx/sigstruct.c index aac9cbc..eba7c86 100644 --- a/tools/testing/selftests/sgx/sigstruct.c +++ b/tools/testing/selftests/sgx/sigstruct.c @@ -260,28 +260,25 @@ static bool mrenclave_eextend(EVP_MD_CTX *ctx, uint64_t offset, const uint8_t *data) { struct mreextend mreextend; - int i; - for (i = 0; i < 0x1000; i += 0x100) { - memset(&mreextend, 0, sizeof(mreextend)); - mreextend.tag = MREEXTEND; - mreextend.offset = offset + i; + memset(&mreextend, 0, sizeof(mreextend)); + mreextend.tag = MREEXTEND; + mreextend.offset = offset; - if (!mrenclave_update(ctx, &mreextend)) - return false; + if (!mrenclave_update(ctx, &mreextend)) + return false; - if (!mrenclave_update(ctx, &data[i + 0x00])) - return false; + if (!mrenclave_update(ctx, &data[0x00])) + return false; - if (!mrenclave_update(ctx, &data[i + 0x40])) - return false; + if (!mrenclave_update(ctx, &data[0x40])) + return false; - if (!mrenclave_update(ctx, &data[i + 0x80])) - return false; + if (!mrenclave_update(ctx, &data[0x80])) + return false; - if (!mrenclave_update(ctx, &data[i + 0xC0])) - return false; - } + if (!mrenclave_update(ctx, &data[0xC0])) + return false; return true; } @@ -289,12 +286,13 @@ static bool mrenclave_eextend(EVP_MD_CTX *ctx, uint64_t offset, static bool mrenclave_segment(EVP_MD_CTX *ctx, struct encl *encl, struct encl_segment *seg) { - uint64_t end = seg->offset + seg->size; + uint64_t end = seg->offset + size_fit(seg->size, SGX_EEXTEND_BLOCK_SIZE); uint64_t offset; - for (offset = seg->offset; offset < end; offset += PAGE_SIZE) { - if (!mrenclave_eadd(ctx, offset, seg->flags)) - return false; + for (offset = seg->offset; offset < end; offset += SGX_EEXTEND_BLOCK_SIZE) { + if (offset % PAGE_SIZE == 0) + if (!mrenclave_eadd(ctx, offset, seg->flags)) + return false; if (!mrenclave_eextend(ctx, offset, encl->src + offset)) return false; -- 2.7.4