From patchwork Fri Dec 8 18:12:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 175990 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5632133vqy; Fri, 8 Dec 2023 10:13:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IE05b8Bgl8G+FV5xqNQkDgeexlpKwaiykoIbaJd0dGTvundUeG2gRQn1YgLU83jH/Ra3XoR X-Received: by 2002:a17:90a:aa09:b0:286:a2a3:1e56 with SMTP id k9-20020a17090aaa0900b00286a2a31e56mr450556pjq.29.1702059216159; Fri, 08 Dec 2023 10:13:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702059216; cv=none; d=google.com; s=arc-20160816; b=ri1fmn6tc1bFrlwuDIRWe4LNcqGm/No1m+fwsdrGmRhqjst1ilHev0+p+Cz7LMc17z TK+z75Jsa1fshmF+SKF4I4Z2n8ehM257DkL5yw8briWYL22zCr4WRBDhjnGLae/l9aTn jyCRPAmdANeqjIedt2Ls3u9nd0zEhHihavSY+Dy8W2x5WE5k/f48Qz1tgBvj3rxxLzwa hnWsbQqOZRh0V8qIBBgjQOI4KTxYkeyOE3ElPRxwOFRi52UZc59hei41BW8/dgzyjVb6 jqiHjOW3Wf8gKsu8t+rEEAi39cDf4sc0bAyc9LSGSde4pFQp+wKEApIkuHtfIj7x9As7 8KBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=Zn/FVBnPio9SbNtzmjX08TH6ufNpTFSAMDK6aNVelYM=; fh=NdptIAQysOQlidYXeN2I+7Z8M3wdEdDWch6LHJ8uuCQ=; b=I2/f5BtS7XLIkvS2UFLX6+yv6tWR+n5NfP2TKW7PrThRmRrB+HABzTwBA1cK9lgYdy 9s/sWBQBlp+I0wOOQwGNK5+PD/FM2MRHCFRofPuIU3pg+NljuDLiWtMa9gMu3dUsrB1G eu6r/CIh738WEINnksMqFdA72ai6OqkBlrkghwRNo7+PhpR2CsOqltGkV02qq5SAnaFy OzMNRzk6eMzWW0DL82Vh7G2TFkKa4cIWZOMhuVPp/G/GTSfDcS8HkkbOcZninivaGtn4 SgYrRcpmLkj0CfXlZ+PKlG/HqQs/4WlUC4Pdo9w6lA+WJtyFAoj4nAPCDUITbq/8oa4E ZKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e+t5TsZ0; dkim=neutral (no key) header.i=@linutronix.de header.b=aor1wBqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id i8-20020a17090a974800b00286e6980c12si1952546pjw.93.2023.12.08.10.13.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 10:13:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=e+t5TsZ0; dkim=neutral (no key) header.i=@linutronix.de header.b=aor1wBqm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 93733807C5C9; Fri, 8 Dec 2023 10:13:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574514AbjLHSM4 (ORCPT + 99 others); Fri, 8 Dec 2023 13:12:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233790AbjLHSMw (ORCPT ); Fri, 8 Dec 2023 13:12:52 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2A311F; Fri, 8 Dec 2023 10:12:59 -0800 (PST) Date: Fri, 08 Dec 2023 18:12:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702059177; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Zn/FVBnPio9SbNtzmjX08TH6ufNpTFSAMDK6aNVelYM=; b=e+t5TsZ0JlcVFOldOzRLkG4V3VRg2II18RrnqBlVDVBbzGXHHSm+RDfZ1FttK9nK8WpWvZ WeIvVH14LQWCU7Vv/0BYWWNAXLaRwRo8Kth/DE//Aj9rF6jG7bB0HV8q2o5QIAyJywKNOL xrk3OtVCxQbNQZt6JzO599qMD02vFvundqgFbnQ8ZCszoNRj8jB6/YBUiA+HS2rQbttaTg m8u2tPdvP5S/37o4Ya0/IZvEh264x3xCsDBqAcQXHudVD4KNIzDUGxxMP5Sd4oZNz0KwDt LgbQVIpFzbNZRCynHB38Sxo5ZSVZFS6DEbW4t/Ljx+N6FRDbNe4lleB5iP7AsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702059177; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Zn/FVBnPio9SbNtzmjX08TH6ufNpTFSAMDK6aNVelYM=; b=aor1wBqmvDhV9fSoWFSYy3KsOX63G4y1gTKs4MmaBOPozxxgpNF6Uw5pZqquqCmpD/Ze2j Ac/8HfxasiXUA/AQ== From: "tip-bot2 for Jo Van Bulck" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/sgx] selftests/sgx: Ensure expected location of test enclave buffer Cc: Jo Van Bulck , Dave Hansen , Jarkko Sakkinen , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <170205917698.398.13586264713492467391.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 08 Dec 2023 10:13:31 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784738444637827080 X-GMAIL-MSGID: 1784738444637827080 The following commit has been merged into the x86/sgx branch of tip: Commit-ID: 022416496008bd51cb7b33975cc0008749329a86 Gitweb: https://git.kernel.org/tip/022416496008bd51cb7b33975cc0008749329a86 Author: Jo Van Bulck AuthorDate: Thu, 05 Oct 2023 17:38:52 +02:00 Committer: Dave Hansen CommitterDate: Fri, 08 Dec 2023 10:05:27 -08:00 selftests/sgx: Ensure expected location of test enclave buffer The external tests manipulating page permissions expect encl_buffer to be placed at the start of the test enclave's .data section. As this is not guaranteed per the C standard, explicitly place encl_buffer in a separate section that is explicitly placed at the start of the .data segment in the linker script to avoid the compiler placing it somewhere else in .data. Signed-off-by: Jo Van Bulck Signed-off-by: Dave Hansen Reviewed-by: Jarkko Sakkinen Acked-by: Kai Huang Link: https://lore.kernel.org/all/20231005153854.25566-12-jo.vanbulck%40cs.kuleuven.be --- tools/testing/selftests/sgx/defines.h | 1 + tools/testing/selftests/sgx/test_encl.c | 8 ++++---- tools/testing/selftests/sgx/test_encl.lds | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftests/sgx/defines.h index b8f4826..402f878 100644 --- a/tools/testing/selftests/sgx/defines.h +++ b/tools/testing/selftests/sgx/defines.h @@ -14,6 +14,7 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __packed __attribute__((packed)) #define __used __attribute__((used)) +#define __section(x)__attribute__((__section__(x))) #include "../../../../arch/x86/include/asm/sgx.h" #include "../../../../arch/x86/include/asm/enclu.h" diff --git a/tools/testing/selftests/sgx/test_encl.c b/tools/testing/selftests/sgx/test_encl.c index 7465f12..2c4d709 100644 --- a/tools/testing/selftests/sgx/test_encl.c +++ b/tools/testing/selftests/sgx/test_encl.c @@ -6,11 +6,11 @@ /* * Data buffer spanning two pages that will be placed first in the .data - * segment. Even if not used internally the second page is needed by external - * test manipulating page permissions, so mark encl_buffer as "used" to make - * sure it is entirely preserved by the compiler. + * segment via the linker script. Even if not used internally the second page + * is needed by external test manipulating page permissions, so mark + * encl_buffer as "used" to make sure it is entirely preserved by the compiler. */ -static uint8_t __used encl_buffer[8192] = { 1 }; +static uint8_t __used __section(".data.encl_buffer") encl_buffer[8192] = { 1 }; enum sgx_enclu_function { EACCEPT = 0x5, diff --git a/tools/testing/selftests/sgx/test_encl.lds b/tools/testing/selftests/sgx/test_encl.lds index 6ffdfc9..333a3e7 100644 --- a/tools/testing/selftests/sgx/test_encl.lds +++ b/tools/testing/selftests/sgx/test_encl.lds @@ -24,6 +24,7 @@ SECTIONS } : text .data : { + *(.data.encl_buffer) *(.data*) } : data