From patchwork Tue Mar 22 00:17:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 12787979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E301C433EF for ; Tue, 22 Mar 2022 00:19:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233865AbiCVAUx (ORCPT ); Mon, 21 Mar 2022 20:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbiCVAUx (ORCPT ); Mon, 21 Mar 2022 20:20:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E253A996A; Mon, 21 Mar 2022 17:18:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id 964E0B81AD4; Tue, 22 Mar 2022 00:16:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACEECC340E8; Tue, 22 Mar 2022 00:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647908207; bh=YlyUCO5y2ERrucJsUmGBREikf0B6qtk2gUE7OvCynHE=; h=From:To:Cc:Subject:Date:From; b=bIqL1HycAoJkZtTfxeoUwrUfOlD03Opn23/+tsl/fj0UjSM+rJtIqWFaYAw1UgB2l e8UwyfpFHrlzixhnS39BoWngU5xFsjHVT2qC/fmwAx3sxS7WEZ7vMuI8rIV7+TUiTh KE9Io/A7Jk0ALTkfTtc0+nDQEFpURxQ8Yw69OpXZFIvWazZrBF/yK+/KsPrzOW0M4t MFlbL9Z7aiY3n2+Ypo+61MZjSPW+9FeI1ENnQc9OISDkqZztSTP9CyvNi8/04tkclh lsRLPG0/p3jfAMtS3HGgvjCRObA2/UmODU3OeM9OoyTilhadzJoXJukvfIpY86mGmV smWSyeUnT3DHg== From: Jarkko Sakkinen To: linux-sgx@vger.kernel.org Cc: Jarkko Sakkinen , Reinette Chatre , Dave Hansen , Shuah Khan , linux-kselftest@vger.kernel.org (open list:KERNEL SELFTEST FRAMEWORK), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] selftest/sgx: Use rip relative addressing for encl_stack Date: Tue, 22 Mar 2022 02:17:41 +0200 Message-Id: <20220322001742.34974-1-jarkko@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org 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 --- This has been in my mind for a while and since the kselftest is seemingly growing, I thought it is better to get rid off such an artificial limitation on the binary layout. 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