Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2233143pxb; Wed, 30 Mar 2022 20:09:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKp/Xa0Wz4QGmKCW9tNYnEzsbD9+5dZofd5yyw+bTNY22foC0/4qtg5apJutHsu9EE+2YS X-Received: by 2002:a17:90a:2d8b:b0:1c7:9120:4771 with SMTP id p11-20020a17090a2d8b00b001c791204771mr3555865pjd.164.1648696174044; Wed, 30 Mar 2022 20:09:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648696174; cv=none; d=google.com; s=arc-20160816; b=oUnuvT80v78GjeAO0cLaCy2/rsRiAd52X/CAwot+Rzhm4CPuySmhuRmKSedIie9qHx NJcUpnKhoHlXstH8AOCUS6m+iFcS+GAjcNpUnU3/9PQ460lJc2t6pcVLDh5aKV0Hle/+ 0ghpncrNelJBPT7fmzJpsanS4pZlAuE0+Az210ONSv/Dzi3gEpE80TjUoGhq7it/QBFs sSG5vDHCTazUa9D9yBGisA8aOg6+OM1QI4/CpzCm6pBlk/Culbt2tVpjtytECm9Qrtt5 +xtmCCb7SKAvEVTqj3GefGNWpVYOl0TKRt8HhPURCCQTgw9OlBSZ7rVv4s2vlxjOHBaD 8D3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Vk0IrcuxiTSc8yFnQkIRJPR2GhpeV1CL0DQ4Hb/fETQ=; b=JlAlCQf1+N2cPTnAvMk10dOts1JWNDVxwhSV1nS2ae/Rgna2yXsyAD7Ws/VGpdJ202 5TpJYPnuwsqEiB8q9/LXcfZp492Nvb6xaDYMEw2olirRg2xgQ7Y8j/6NRmgi9997jERy wWU3LdsLwMsQENx/2LjvtN87UhxUTr4lKl8+/2qb9rZCUp7+KxN2bIyryvIGrNCK8YCH SLg2uDRf866vfmwlLZ9AxwARxY152qOejtL2QFSyLVIdOkPLObn2dM7blUI7Fu4RqQy4 WYaTiT1xOM7SV6heYxk6SrD56tbe7cZQNcl5wgFL5T42uzPgQ5h6UFWwAIwGUO4wscZO Nm5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=usMyz6pz; 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 x10-20020a63310a000000b003829d3d1bb5si24297032pgx.83.2022.03.30.20.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:09:34 -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=usMyz6pz; 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 B90D4F1E85; Wed, 30 Mar 2022 19:46:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350598AbiC3WdM (ORCPT + 99 others); Wed, 30 Mar 2022 18:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351698AbiC3Wc4 (ORCPT ); Wed, 30 Mar 2022 18:32:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A955BD27; Wed, 30 Mar 2022 15:31:10 -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 0443F617C8; Wed, 30 Mar 2022 22:31:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F358C340EE; Wed, 30 Mar 2022 22:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648679469; bh=Vk0IrcuxiTSc8yFnQkIRJPR2GhpeV1CL0DQ4Hb/fETQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=usMyz6pz1sAuO70HtBJNE4C7ik1N2XSzCrRDTw0FE9RsNoDSxBBTfXMQx7fx3fI3Q ThRP0iJgodfkDyW+nXeWRcSM6dwiiMWmRXE8Lxj8IYPutVDeMGCpZdAYseUUy4hkRq nCofQQkeW1+Npua4PygZoGL1U5Ec3iuDgZRfH5VJT7R7GPHiH4gcItGo7/T6Nt32B4 55q+heL0EJNklGnBTLk8BujIbIg7h4qxSH2Nn2EvTqjD1QpAixV2r9144aK43PyCi+ c1jSvOTYNE+V8UghKKDBk8ESpwM8NCQ1YB/J2Zw5PSKPf8cMBvm7iEyvvr95Fk00gk yBKByQoBXLXwg== Message-ID: Subject: Re: [PATCH v2 1/2] selftests/sgx: Use rip relative addressing for encl_stack From: Jarkko Sakkinen To: Reinette Chatre Cc: Shuah Khan , Dave Hansen , Shuah Khan , "open list:INTEL SGX" , "open list:KERNEL SELFTEST FRAMEWORK" , open list Date: Thu, 31 Mar 2022 01:30:08 +0300 In-Reply-To: <595369cd-b7d4-985c-a7e0-7110ffe9a606@intel.com> References: <20220322074313.7444-1-jarkko@kernel.org> <7b7732ec-c7ff-cf92-510f-64c83ed985cd@intel.com> <0031a4f0-75f6-3104-1825-dcc2528f61b0@intel.com> <595369cd-b7d4-985c-a7e0-7110ffe9a606@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.42.4 MIME-Version: 1.0 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 Wed, 2022-03-30 at 14:29 -0700, Reinette Chatre wrote: > Hi Jarkko, >=20 > On 3/30/2022 1:40 PM, Jarkko Sakkinen wrote: > > On Wed, 2022-03-30 at 13:05 -0700, Reinette Chatre wrote: > > >=20 > > >=20 > > > On 3/30/2022 12:03 PM, Jarkko Sakkinen wrote: > > > > On Wed, 2022-03-30 at 10:40 -0700, Reinette Chatre wrote: > > > > > Could you please elaborate how the compiler will fix it up? > > > >=20 > > > > Sure. > > > >=20 > > > > Here's the disassembly of the RBX version: > > > >=20 > > > > [0x000021a9]> pi 1 > > > > lea rax, [rbx + loc.encl_stack] > > > >=20 > > > > Here's the same with s/RBX/RIP/: > > > >=20 > > > > [0x000021a9]> pi 5 > > > > lea rax, loc.encl_stack > > > >=20 > > > > Compiler will substitute correct offset relative to the RIP, > > > > well, because it can and it makes sense. > > >=20 > > > It does not make sense to me because, as proven with my test, > > > the two threads end up sharing the same stack memory. > >=20 > > I see, I need to correct my patch, thanks! > >=20 > > RBX gives correct results because of the binary organization, > > i.e. TCS's are placed to zero offset and forward, and=20 > > unrelocated symbol is just compiled in as an untranslated > > offset. > >=20 > > RPI is given correct results but how the semantics work > > right now is incompatible. > >=20 > > Still, even for kselftest, I would consider a switch > > because that way: > >=20 > > 1. You can layout binary however you wan and things > > =C2=A0=C2=A0 won't break. > > 2. You can point to any symbol not just stack, if > > =C2=A0=C2=A0 ever need. > > =C2=A0=C2=A0=20 > > I admit it works semantically but it just super > > unrobust. >=20 > I do not think that we need an exceptionally flexible > runtime as part of the SGX selftests but instead something > that is easy(*) to understand while also sufficient to support > the tests. >=20 > Reinette >=20 > * I do not actually consider the existing enclave test binary > =C2=A0 easy to understand (this thread is proof) but keeping its > =C2=A0 complexity to be minimal would benefit folks needing to > =C2=A0 ramp up on SGX and/or debug kselftest failures. Based on you feedback I refined the patch: https://lore.kernel.org/linux-sgx/20220330222834.139769-1-jarkko@kernel.org= /T/#u BR, Jarkko =09 =09 BR, Jarkko