Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1347787pxb; Thu, 14 Apr 2022 04:20:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6986eCqkct+o/pKPob4mYcMRwjBujG9wzGygRYvxJuZtjnaLDubo2nAdEWXAPJr7LKbx2 X-Received: by 2002:a63:b51a:0:b0:39d:ac7f:d5ba with SMTP id y26-20020a63b51a000000b0039dac7fd5bamr1867282pge.497.1649935205544; Thu, 14 Apr 2022 04:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649935205; cv=none; d=google.com; s=arc-20160816; b=v8lsZGJLluQ8y6LTCYVGhLcQb3Hig8JEa2uM4KfvztJmTtlzRTr4+btCdUhy12ZDCO JxGB389HNIU5wCKTfMp7UlBsgCOQGYojF1t3OZgjM5g695LyBqlPKQdezChzOtX7xulF NpJuIxinqc8dxx9CFNfSNY4YpugZvY3swrI+sGm1048CL5y2jtakKdBAVUV/Ftt9T10W Rzslm4QHf3ZqF3qLNemsEIzCTQ6ZePan9PwmgzGttRIdES1mrkQ39Dd0Nt7Tkzu3F2yX CUx9GizeJTPCs0OKt7ZhpTUK2BqJS4g+24P1Sgc1HRc3R5Pc2Cwe4ys6eIK0qfwG3cYc rmFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BOuUsAwYU0ubDgehgJfzyd8fGERKmqPA3NGT1TO0Xrk=; b=GU8AQy/oKbm5vuKreGPerBJ4GSm24inJopNwHoKzGop/8Z8ETn4IRhTNBa2eDjlVyd rVHPsLsd31rlIgNU7liTU/6se3/uePnXoYadfs/c0i16B2zZ6RuST4ALKeO6w+gUg/6Z a6eYWy1u5wNdQxdhaGP3r6c6vo/BSSqqMfnt95b+I/fyXyx43vErJkR/7yinOLlqmVc2 0PPPtOQ6q5DlxIcKz1SwjeBkBx5RAiLEgjMtjcsNqdXH+fJxJ6Ugih2i1M74N9TEGsC2 tHflZ3DuHQCTjnG6nM3k3RSljqNB5gkB2DuuPCZViyewnj5ttCDzDTKIha7w2Sr6O1ZE qXfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JPDkBIF8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u21-20020a17090abb1500b001cde9966f04si1346994pjr.175.2022.04.14.04.19.51; Thu, 14 Apr 2022 04:20:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JPDkBIF8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238841AbiDMVOU (ORCPT + 99 others); Wed, 13 Apr 2022 17:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239054AbiDMVNN (ORCPT ); Wed, 13 Apr 2022 17:13:13 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70FD83BBD4; Wed, 13 Apr 2022 14:10:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649884251; x=1681420251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wuTlewmQK70KDihztEJudq9AVH8Fb8wzxHOAdBGQCNU=; b=JPDkBIF8juKUqiujJ8x3qjju488DCD9NWfNMcS/cUv/a6t0ZPKdEYtgD LCG+B2wQTt6xC5C4s539VmdYLAoam/PsbezkSY4WaOfvcJLkk2CQUgRis HIWO4CzaxtOGJrHZn8RcXvO3xWntA/w0t+gyHIYsr6fe9NbjiNwDinzN3 EiozWq6j2XvIbUkDi5pcG9JLdvUe5iX2FgDGjMbgMbI2sCLykqi7XdJJK kYg0YCC6eAlPptzmS0AW1GzevtNn2t8foPcPV/ws39UP4v0tpjjfvuns0 4AClwW7RAxMebDQRTkYnsH6HSedMvKX+4uSyclsycu90wUmaRgIInvi9v A==; X-IronPort-AV: E=McAfee;i="6400,9594,10316"; a="323219065" X-IronPort-AV: E=Sophos;i="5.90,257,1643702400"; d="scan'208";a="323219065" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 14:10:46 -0700 X-IronPort-AV: E=Sophos;i="5.90,257,1643702400"; d="scan'208";a="725054318" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2022 14:10:46 -0700 From: Reinette Chatre To: dave.hansen@linux.intel.com, jarkko@kernel.org, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: seanjc@google.com, kai.huang@intel.com, cathy.zhang@intel.com, cedric.xing@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, vijay.dhanraj@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: [PATCH V4 25/31] selftests/sgx: Introduce dynamic entry point Date: Wed, 13 Apr 2022 14:10:25 -0700 Message-Id: <9916be3aecbd1ec6fd78f4804ee3b84bcee3adb5.1649878359.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The test enclave (test_encl.elf) is built with two initialized Thread Control Structures (TCS) included in the binary. Both TCS are initialized with the same entry point, encl_entry, that correctly computes the absolute address of the stack based on the stack of each TCS that is also built into the binary. A new TCS can be added dynamically to the enclave and requires to be initialized with an entry point used to enter the enclave. Since the existing entry point, encl_entry, assumes that the TCS and its stack exists at particular offsets within the binary it is not able to handle a dynamically added TCS and its stack. Introduce a new entry point, encl_dyn_entry, that initializes the absolute address of that thread's stack to the address immediately preceding the TCS itself. It is now possible to dynamically add a contiguous memory region to the enclave with the new stack preceding the new TCS. With the new TCS initialized with encl_dyn_entry as entry point the absolute address of the stack is computed correctly on entry. Acked-by: Jarkko Sakkinen Signed-off-by: Reinette Chatre --- Changes since V3: - Add Jarkko's Acked-by tag. tools/testing/selftests/sgx/test_encl_bootstrap.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/sgx/test_encl_bootstrap.S b/tools/testing/selftests/sgx/test_encl_bootstrap.S index 82fb0dfcbd23..03ae0f57e29d 100644 --- a/tools/testing/selftests/sgx/test_encl_bootstrap.S +++ b/tools/testing/selftests/sgx/test_encl_bootstrap.S @@ -45,6 +45,12 @@ encl_entry: # TCS #2. By adding the value of encl_stack to it, we get # the absolute address for the stack. lea (encl_stack)(%rbx), %rax + jmp encl_entry_core +encl_dyn_entry: + # Entry point for dynamically created TCS page expected to follow + # its stack directly. + lea -1(%rbx), %rax +encl_entry_core: xchg %rsp, %rax push %rax -- 2.25.1