From patchwork Fri Dec 8 18:12:57 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: 175986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5631912vqy; Fri, 8 Dec 2023 10:13:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHf9X3HBn1DpBQLrJfgf+m7Fk1hh11FsRNwsBQiJQRsjAMqwAGe66x9QlvLHe1n/hPZL37b X-Received: by 2002:a05:6a00:1254:b0:6cb:913d:2cce with SMTP id u20-20020a056a00125400b006cb913d2ccemr533880pfi.15.1702059196125; Fri, 08 Dec 2023 10:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702059196; cv=none; d=google.com; s=arc-20160816; b=mI7xRTj6rmnd1u6/xW1o0chGQa2sgbA948Ba4sPd3uy4PGqy85pf8bdcuA8ko2BzPi wclnSCXB1ffqT9+wiBU0jmWjy3o8bBEo5nT+qyYlcOoBU3iIZwXKA7m28BGClFzUa4I6 dRncI3EnQOWBEJ5TllO9FkA1kEGn/jQOJXcMsW3DISqB7djPqIFuhpTyRQ3X3EElKAtc ShlJKWg2Ne0zJKWBIRJPFAyL/6K3NqACSByJO/D4idkqYcd7JgknYjbUUnEEipByA9W2 DEuJdxHw7KF8Cmh/A839QRRnqEc4z86jJYSXUJYzZ2ltyAwzeu+MC9/DGgttxfRejPqq n6pw== 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=i8RSaAj1FoNLBcjrSnL0NCPi3yBIbLyBZKtk3ha6yyA=; fh=NdptIAQysOQlidYXeN2I+7Z8M3wdEdDWch6LHJ8uuCQ=; b=wSJjjSlhVwtGMRMc1GlZ/xrV2fI33duczliDnkk07BQjBATY2WDhTxkRPQ2xTz5vfv XgnNwOGEHLjvX6W4Sp92LknZcS1T6f+6POgrAuULFKAaECOC7kOY3VNrqkHGAIv1hwVX yNKtwG5yHS8A3CK0IdN2VsYJFs0QV/dCtRR0Lrll8EZ28kXPYRm16UI6zVPsv2z8my3q lkfCgUFD8GywVLjA6w8Ggqgr4Tm4rQn69tG77JHc4bs4uTL/rczEoPofaX/rTAcwj3cF XzkE8aFp+hIaZiiKUkyLlTgdj+rsdwB1yoY2bJYf/xe4rMvgpF+uGuywNCmtSMk8a3zw Tbog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WOoKNHyY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v18-20020a631512000000b005b92d40e11bsi1903222pgl.168.2023.12.08.10.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 10:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=WOoKNHyY; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id D278B8101EC5; Fri, 8 Dec 2023 10:13:14 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574552AbjLHSM7 (ORCPT + 99 others); Fri, 8 Dec 2023 13:12:59 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 10:13:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784738423466447614 X-GMAIL-MSGID: 1784738423466447614 The following commit has been merged into the x86/sgx branch of tip: Commit-ID: a4c39ef4ed43103caef80029cd30427a9ff342d8 Gitweb: https://git.kernel.org/tip/a4c39ef4ed43103caef80029cd30427a9ff342d8 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.kuleuven.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/selftests/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 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __packed __attribute__((packed)) +#define __used __attribute__((used)) #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 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" /* - * 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 external + * test manipulating page permissions, so mark encl_buffer as "used" to make + * sure it is entirely preserved by the compiler. */ -static uint8_t encl_buffer[8192] = { 1 }; +static uint8_t __used encl_buffer[8192] = { 1 }; enum sgx_enclu_function { EACCEPT = 0x5,