Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp20622pxb; Wed, 30 Mar 2022 21:43:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypeED3B3KUTtYb/HspkDmu8hn4qcZV6sonUcln8KQH0rPh9MGF9+W/cMH4y7EidZNGd0gL X-Received: by 2002:a17:902:db0c:b0:154:1b36:6a7a with SMTP id m12-20020a170902db0c00b001541b366a7amr3538437plx.36.1648701793134; Wed, 30 Mar 2022 21:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648701793; cv=none; d=google.com; s=arc-20160816; b=pzlzf4oMLzHUujrLlBo6d8EnGjD24aBsMyr0NnAp2EI0NIWMbhEySPely14UsXVWxu fpRx6crbFt6m7SeUdkZBOvt5fy2jjN6ab81ENaJaCjqjluXwA0WUMJeF3HmUWwaJb8EE x+fE6bfi07YSxwh5GBX2Goe+OXh8MAZSXvlA0om2Y+M1xyMgOuUxds98gJakdVLMIq4S e5qIAL8ebmkLei4ocmLacArimSKdF5k+ORKacMIRxSIxDz+hyGyxX6yjj9gpvqa4zwEN DS4bAANGNcPv3uczpEGb7zeh46dfDpFsJWkZ9WzkvghGLNrv/EOPdo7eiHhfoxH28V9+ 6e7Q== 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=7PGEXQa6HG9MqmQC61wWvyEKEpW712M035wKE3edpqs=; b=dYf479b6KgCGkKg6RYNSyw8RAAUwiMG+OEDIo/Ol2KzRg2J+RC5m41x39cxiVEa4r9 Y42EzehjadQeve5fN/Jsx4B/oabcwrIfzyYkRqXv0y4gwDTjqGtkVi/4TBM3ZY10/Y0Z EM3F8OFmjq9ofCQjHLx7BO5+NlXkl/EIt2OG36WDU4+Owk6uY57T0hp7IUFBXHa1GheN Ow0rpBTuilscHegEau4ZqLqnAS88V6Gp0L3W6T0tuNz+DZXIs0PSS24YbweW1ua+C4F3 4IQP3MnZBLk/MYQh1hH5tD9SoSvIuufqMayAdn1v2E/R/Y3x9GKS4RJf4Kf0JEcCKcc5 OBWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XHDr0Bv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j9-20020a170902758900b00153b2d1647asi22171924pll.130.2022.03.30.21.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:43:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XHDr0Bv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71546270860; Wed, 30 Mar 2022 20:40:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347490AbiC3O5J (ORCPT + 99 others); Wed, 30 Mar 2022 10:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347567AbiC3O5E (ORCPT ); Wed, 30 Mar 2022 10:57:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E01124925A; Wed, 30 Mar 2022 07:55:16 -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 774E96097C; Wed, 30 Mar 2022 14:55:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63E91C340EC; Wed, 30 Mar 2022 14:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648652115; bh=I+yJk0OAWbSGqwnxt70vNBRoJxFYe+GVrXI+LY7+JQ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XHDr0Bv1y+gtIMF36FJE/RlvVVR3GpNLnf4Te7RHach2xV6WCgDhZjupJ9bCFwSHj NJXMax2wgDt2Evna03tIBlaqDvT44j219GN9+5mEIqOnBsVjabCH0JLOC9vk6nObnY ifAkXfPYZT8cU6veasvCWt6pAntlMRKCJKNTtvu//nUaHvZR8YhG8pOw5Bh7/4NQma e6b0uwyluHx0DqfFjQtjaHn4P11uc+DI9QpBM0SR2ks7Vp+HWlQkI+1ahf2/SFpjXh /qQDmYkQrbozmATqqOygKTJJ+wM4mifYVCspp+9Yhohz3SEHk0HHbWtt+tNT079we7 HCtzLz5b1571w== Date: Wed, 30 Mar 2022 17:54:14 +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: <7b7732ec-c7ff-cf92-510f-64c83ed985cd@intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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. BR, Jarkko