From nobody Tue Dec 16 18:30:58 2025 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 C4E4EC4167B for ; Fri, 8 Dec 2023 18:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574572AbjLHSNB (ORCPT ); Fri, 8 Dec 2023 13:13:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbjLHSMx (ORCPT ); Fri, 8 Dec 2023 13:12:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD502133; Fri, 8 Dec 2023 10:12:59 -0800 (PST) Date: Fri, 08 Dec 2023 18:12:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702059178; 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=i8RSaAj1FoNLBcjrSnL0NCPi3yBIbLyBZKtk3ha6yyA=; b=WOoKNHyYaV+P3u37nwZGlqNKqqQt8D87qAKNyrcp/h2n6dAda5LnodpvTgBHNzaWCdvDDb FzzZg9dQwhd8HBVSwrOvn3s2o4im7LaROz4a74PvKa92AvvMK/06FAVTVked2/zawLXjyp vrDB9wzqINnHF5sE3eKJrqMOXrq3AdhXRdZfhv2hCvg2e7FA6q5g94v6pDThdskCmJYdQr tdtI/Eut/vkaQVxuKzARJAAczdlrcYDFVbqS5eqQjpXPvPxtA3JBSRihmp5TwPk0ib2jBO Vhd9LC2u9F9qGbSsNdZJtZ5uOGOmTTi7WO641sD1l0vGk8UZHFFaxqNZNl1NsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702059178; 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=i8RSaAj1FoNLBcjrSnL0NCPi3yBIbLyBZKtk3ha6yyA=; b=HmoS92ZVfedx998orBwSSrPw/uETEZQHm6yQYdjwOkKsfpnPMR++7150Fpj7fsbq5xbMF1 4kaFo8UlZDa/M2Cw== 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 test enclave buffer is entirely preserved Cc: Jo Van Bulck , Dave Hansen , Jarkko Sakkinen , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <170205917777.398.5382474413072090594.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/sgx branch of tip: Commit-ID: a4c39ef4ed43103caef80029cd30427a9ff342d8 Gitweb: https://git.kernel.org/tip/a4c39ef4ed43103caef80029cd30427a9= ff342d8 Author: Jo Van Bulck AuthorDate: Thu, 05 Oct 2023 17:38:51 +02:00 Committer: Dave Hansen CommitterDate: Fri, 08 Dec 2023 10:05:27 -08:00 selftests/sgx: Ensure test enclave buffer is entirely preserved Attach the "used" attribute to instruct the compiler to preserve the static encl_buffer, even if it appears it is not entirely referenced in the enclave code, as expected by the external tests manipulating page permissions. 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/a2732938-f3db-a0af-3d68-a18060f66e79@cs.k= uleuven.be/ Link: https://lore.kernel.org/all/20231005153854.25566-11-jo.vanbulck%40cs.= kuleuven.be --- tools/testing/selftests/sgx/defines.h | 1 + tools/testing/selftests/sgx/test_encl.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/sgx/defines.h b/tools/testing/selftest= s/sgx/defines.h index d8587c9..b8f4826 100644 --- a/tools/testing/selftests/sgx/defines.h +++ b/tools/testing/selftests/sgx/defines.h @@ -13,6 +13,7 @@ =20 #define __aligned(x) __attribute__((__aligned__(x))) #define __packed __attribute__((packed)) +#define __used __attribute__((used)) =20 #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/selfte= sts/sgx/test_encl.c index 649604c..7465f12 100644 --- a/tools/testing/selftests/sgx/test_encl.c +++ b/tools/testing/selftests/sgx/test_encl.c @@ -5,11 +5,12 @@ #include "defines.h" =20 /* - * Data buffer spanning two pages that will be placed first in .data - * segment. Even if not used internally the second page is needed by - * external test manipulating page permissions. + * 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 exter= nal + * test manipulating page permissions, so mark encl_buffer as "used" to ma= ke + * sure it is entirely preserved by the compiler. */ -static uint8_t encl_buffer[8192] =3D { 1 }; +static uint8_t __used encl_buffer[8192] =3D { 1 }; =20 enum sgx_enclu_function { EACCEPT =3D 0x5,