Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1873497pxb; Wed, 30 Mar 2022 11:39:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw50RkaNGT40e8her1SsnCVYPeN0JxrFpjqjqSKNBOlj/DjmijZwhDKDYbw2HggMjLQdZj5 X-Received: by 2002:a05:6402:3553:b0:419:6552:11b7 with SMTP id f19-20020a056402355300b00419655211b7mr12576692edd.286.1648665585896; Wed, 30 Mar 2022 11:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648665585; cv=none; d=google.com; s=arc-20160816; b=et1g8JYH5OXe6tK+LrTiCtqRAAjGl8nUIMR9ND6nsTEa8YyoKDqzWPtxFDJT7js+Dg TCU10dBFLwMrsoT/GR2CR5/BXuYCp2B0zO/d6BptH5asEyeYKlVW+KivinPR2byJjjIf inIxbGy0DykiHehp2EkbuVWloKDqh1XyBmn+VHW90lCduoWFMVT3PpsljMYWY2Ks2TPO uhkjQsoOFig3m/YffTleas1C7TFLBIoVNP1uYKsQiFko5BGLFZv2wju+dhyAeAjKaLot 1U1DIKe3RvSF2piY/p2tkGI7c3nlkaaAsVEo5wYDQkiKoT5A01gUEr/kfNfoJ/kgKOGd j4SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CSy+47K2vSSBleSgshmm32avRw8pMhvThBYS40bUPb8=; b=IXOeuAEe52bYHR7wMQdMXrM3GcQW/K9QyzzkGAs8Q8jlW099xijZgxd3vdKM0syOQF 9EdCwr2KeLU3UpqRiKovp/lMYXXl+HsLZx/SFwoHDJhdfhu23uAxPPkiv9ZRBq5zfUiD CJ77IVFwxk1n9L/aSDYzq4wAcjwV/WBvwcO0lTYThCzEgUvyILWxNONM49ZpNICiKCiP l7JPXO3NwxGj6UHGYa3Q75n1BRsdZSXprwp73Yasjm22kBpUYLaW5NRQbigYftlhsFco Bn27EV7W3RowYusL86flJwaJ7GYDF+VJtzrG4JlzTltOci8Am8DtWeScffOLvDt3eQVI NkgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qOdNWakp; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id go41-20020a1709070da900b006df76385cccsi23878405ejc.364.2022.03.30.11.39.19; Wed, 30 Mar 2022 11:39:45 -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=@kernel.org header.s=k20201202 header.b=qOdNWakp; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347666AbiC3O7r (ORCPT + 99 others); Wed, 30 Mar 2022 10:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347217AbiC3O7m (ORCPT ); Wed, 30 Mar 2022 10:59:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F466406; Wed, 30 Mar 2022 07:57:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1C719615E7; Wed, 30 Mar 2022 14:57:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F800C340EC; Wed, 30 Mar 2022 14:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648652272; bh=0ohAXybc8U6+eIxqZN8sbhR7Ie+atDMwd4Z+q/8cZrQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qOdNWakpz/tB38GgP8O5A5OkgxV+edpaqvyeXZJRKovfi9gcnM/Sfq2ktTdITpTa/ AQKIdOXnQZW1SDESCygsZIEf86+xzsvfPN8GyAV5xPw70T1r8bTccgC2f9coijHJKr ZxvejzJKpznFwR+YPK/1Z24OvNTjZR1AAqsTfG2iQTTqt9Wzgyj5PP8Be4NbcSwGS4 yNqunFW8MvG9dFtpXpe3TY1IurDIV78e9EL5ULfPbAGGyWRRCfHgJrZf9KWVqDUgCf 7gVgHwd/LiXwi8gQsKHP+d8hePHK9ZAiDZpMcG/c5+8QZTqh/DT6QKd8PtNU6/H3tY jqHyp9RIRiEbg== Date: Wed, 30 Mar 2022 17:56:51 +0300 From: Jarkko Sakkinen To: Reinette Chatre Cc: Shuah Khan , Dave Hansen , Shuah Khan , "open list:INTEL SGX" , "open list:KERNEL SELFTEST FRAMEWORK" , open list Subject: Re: [PATCH v2 1/2] selftests/sgx: Use rip relative addressing for encl_stack Message-ID: References: <20220322074313.7444-1-jarkko@kernel.org> <7b7732ec-c7ff-cf92-510f-64c83ed985cd@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 On Wed, Mar 30, 2022 at 05:54:18PM +0300, Jarkko Sakkinen wrote: > On Mon, Mar 28, 2022 at 02:49:04PM -0700, Reinette Chatre wrote: > > Hi Jarkko, > > > > On 3/22/2022 12:43 AM, Jarkko Sakkinen wrote: > > > Simplify the test_encl_bootstrap.S flow by using rip-relative addressing. > > > Compiler does the right thing here, and this removes dependency on where > > > TCS entries need to be located in the binary, i.e. allows the binary layout > > > changed freely in the future. > > > > > > Cc: Reinette Chatre > > > Cc: Dave Hansen > > > Signed-off-by: Jarkko Sakkinen > > > --- > > > tools/testing/selftests/sgx/test_encl_bootstrap.S | 6 +----- > > > 1 file changed, 1 insertion(+), 5 deletions(-) > > > > > > diff --git a/tools/testing/selftests/sgx/test_encl_bootstrap.S b/tools/testing/selftests/sgx/test_encl_bootstrap.S > > > index 82fb0dfcbd23..1c1b5c6c4ffe 100644 > > > --- a/tools/testing/selftests/sgx/test_encl_bootstrap.S > > > +++ b/tools/testing/selftests/sgx/test_encl_bootstrap.S > > > @@ -40,11 +40,7 @@ > > > .text > > > > > > encl_entry: > > > - # RBX contains the base address for TCS, which is the first address > > > - # inside the enclave for TCS #1 and one page into the enclave for > > > - # TCS #2. By adding the value of encl_stack to it, we get > > > - # the absolute address for the stack. > > > - lea (encl_stack)(%rbx), %rax > > > + lea (encl_stack)(%rip), %rax > > > xchg %rsp, %rax > > > push %rax > > > > > > > The goal of the above snippet is to set RSP to ensure that each thread has its own stack. > > > > Since EENTER computes RIP as EnclaveBase + TCS.OENTRY, by using offset from RIP this > > would result in all TCS with OENTRY of encl_entry to use the same stack, no? > > > > Could you please consider the following as an alternative: > > https://lore.kernel.org/lkml/65c137c875bd4da675eaba35316ff43d7cfd52f8.1644274683.git.reinette.chatre@intel.com/ > > > > The idea in that patch is that a new TCS would always need to be accompanied by a > > dedicated stack so, at least for testing purposes, the TCS and stack can be dynamically > > allocated together with the TCS page following its stack. This seems much simpler > > to me and also makes the following patch unnecessary. > > There's no better alternative than use rip. Compiler will fix it up. > > So, no, I won't consider that. This a dead obvious change. How you organize TCS and stack is completely unrelated topic. BR, Jarkko