From patchwork Fri Jun 14 02:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hubbard X-Patchwork-Id: 13697740 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C4B8C27C7B for ; Fri, 14 Jun 2024 02:36:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59A926B00C0; Thu, 13 Jun 2024 22:33:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 54A8B6B00C1; Thu, 13 Jun 2024 22:33:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C4AF6B00C3; Thu, 13 Jun 2024 22:33:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 1F94B6B00C0 for ; Thu, 13 Jun 2024 22:33:31 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D196F14042F for ; Fri, 14 Jun 2024 02:33:30 +0000 (UTC) X-FDA: 82227922980.13.D483824 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2085.outbound.protection.outlook.com [40.107.93.85]) by imf27.hostedemail.com (Postfix) with ESMTP id 0A74640016 for ; Fri, 14 Jun 2024 02:33:27 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=RIFBUElG; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.93.85 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718332406; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5Lt2eL/4RhlpXOKr7DkYkcD248gcAkhriafXFFjq05w=; b=2GIfJexOe3tJJHPExCrKwhaE7yZ4ATPvsqCIXJ7SQZ5EVmsSKiAUOpaWzQqOKp5ECJ68kK mCGIw5FpGT9M0Erp7kBY6gCyYzqaRFaoEzjlJzQvetn+WaNmbf4V9ac4jesPaHWviqTt3p WZzNydehCrQJQNB8tEPKDVzaNJ9+xFQ= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1718332406; a=rsa-sha256; cv=pass; b=EjxHAYHqmmZfB/X/y7XURDL2nRLOEmmYaZf3U8fkIAiaq9MFjzeeG0krhKTHCgahJaJQNH POpeVUhLlJ8DdwXWg1YSAvmwWJIDZF5LVNELLL9p155214pBy0KayNpplyKnloKizE1Ilu DScJXyTnQMx1WLyixu1BQXQyQrz1csI= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=RIFBUElG; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf27.hostedemail.com: domain of jhubbard@nvidia.com designates 40.107.93.85 as permitted sender) smtp.mailfrom=jhubbard@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ahhm3SO59FFI0hWMFNbVVuzdzlcM+L8Ene8ZXq6ypw4VwEF15lwGMZiYgZ+V6e77FaviBvLF2mOMIQeJLlJZqYXvFi/kN4quG0eUPKCNhaLNj4MwWwpEJ+V0/vjeo2DGs+3T/Je7I+MiwYFbjtCiqLMsTxPD399t9lpRgEZ0RFhvXZIAhijWvBcOJuK60oUvmqKaYxxL14u34K/aLiRNDb3OE41452lB+u+aROqs+aeEDu154qJvl4ZJ8TCtLwoC3dfEjzdA+TDurS6rNKlI1gPTgs0aat3ut5nMe6b/WNymO6BUtDE/Vdo8W8BudKE7WBPJYrxy3RIOsp/QWC69Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5Lt2eL/4RhlpXOKr7DkYkcD248gcAkhriafXFFjq05w=; b=P445YND6x3/fXFCgtTUyiPs5lVlw1EhDSalwEM8NLEsMfQ+v7DeN7+VtMWZGAqt+tR1RHuDGxYV5wSVN1bl6GUav8Q9dIxXQN556P19FllOT9n+lS8E6JKNzCEsACFjh920udHKxByomQMa5TKpruoOpClo5k/S5zqIMVUR/th1lYlLs9JZdDf8om4btOYg3cLQaAbk0wzYLp/8cvDcIZBy0HwyJs8lis27dejDZVPxmFSpE/QG3DSOVj9dPt1ouPiCyGmJi7Lq4V3XP2KrsrE5j6RjqD2b4S1dCGQEPc8rVPacQyZx5xy1CEF4Vxz/6dWQlczF7uzKxT7vI9Dgmcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5Lt2eL/4RhlpXOKr7DkYkcD248gcAkhriafXFFjq05w=; b=RIFBUElGJ6Xii+oqIG/1vAvDgcMq8av4OPfBHNMuSWtBA5SEbUypGGAerH4f6hfqmruSNlnSXSRnGQdVTuRMI48bRFsEws7u9yVLojn5iB9+wYDHILVE25qJpdUvRvI282HU4TEtD+2XdjaSQMceFxWx7icn6M8FtN/tT0/vShZDntPsYtosrGRXQL1+/8HLglAZFhTgk+eyefA/zBjEEv4bIPh6eUTL5Nj2agnweUWeBU6EbrdNLCC3YL1PYWDGWfM5GFzhAtyKz9EO+H+2e+0/S678crqUwEsuV1Gho24rSykHRqNv3TyM5UTLyFCEkCh+zf5sA/l2OCRL7E3kVA== Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by PH0PR12MB7932.namprd12.prod.outlook.com (2603:10b6:510:280::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.37; Fri, 14 Jun 2024 02:30:12 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::2cf4:5198:354a:cd07%4]) with mapi id 15.20.7633.037; Fri, 14 Jun 2024 02:30:12 +0000 From: John Hubbard To: Andrew Morton , Jeff Xu , Shuah Khan Cc: Andrei Vagin , Axel Rasmussen , Christian Brauner , David Hildenbrand , Kees Cook , Kent Overstreet , "Liam R . Howlett" , Muhammad Usama Anjum , Peter Xu , Rich Felker , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, LKML , John Hubbard Subject: [PATCH v2 2/6] selftests/mm: mseal, self_elf: factor out test macros and other duplicated items Date: Thu, 13 Jun 2024 19:30:05 -0700 Message-ID: <20240614023009.221547-3-jhubbard@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240614023009.221547-1-jhubbard@nvidia.com> References: <20240614023009.221547-1-jhubbard@nvidia.com> X-NVConfidentiality: public X-ClientProxiedBy: SJ0PR13CA0161.namprd13.prod.outlook.com (2603:10b6:a03:2c7::16) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR12MB4130:EE_|PH0PR12MB7932:EE_ X-MS-Office365-Filtering-Correlation-Id: fe1acee1-14f4-4c58-3847-08dc8c19eb0f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230035|1800799019|366011|7416009|376009; X-Microsoft-Antispam-Message-Info: OlQudQyAfA73L6cLVJs9FxKdgvH8/XgSmT+AKuQYLbbsNDgmxp3XUhvVfvuQuFuVgBp2vU0Lw/ywS4AGSNGHLOq6YQnLmtjTdaU5aPz+g1rF+MAwPKVhvaDxjg2ne7Ql65ww3eJIeepL9EhFWwWIElKzgXbRhACBm+MhzUrIbdwXmMl3qJu5oqYNshyryHFP8FSrmOzOkDUHQfo5sy9d+63Q03JQ8iygVNHVRSnPcUAyE5LbzHI6TaLKC9pg8ml8ZoVIVs3OCXGXXd8lsvJ04lChnRnaTrysnPMnz5XfEYQp7vQA5ogv0rciJrCD7euZhH2GsZk741Tfx2/P/qJvvXrH8rJ8EpywGEajP3cqQCCpNoZaVpVy1ASMrEZw6+pHQonctL/Wl0GeYpGYT2J37I7kavHaDpIMtDrxS3ybuL6gAETr7Yjv46b4KhbrsiC+qG42Gcc69ZYHFmDTn+MMy4BwS3+HNKa0IgWXy0hDs6AAUx0VakO4aSmPsEVLYUrolMTDZ8F0ar5+BEf4nIAeYkzpoZtRg/i00eotErBkBmfp9z3kZeYKNWOJld1uSTUQ4SlY1UZAa26wJ/Cm4X8OVo63XChG3PJN+aZAYam0SFfV3Kgrsp/LEkIZIwVTooeMx/WmkR4VKVv+e1RGLqHKJfXZYqzKcjGcNcn11QrDU2/iMZqM438U4mHay4Me2aOUAiNdDck1rjBR0UFdGtrUnDfdQzNs60DWsFTwOQ33n5dPUSI0Jn7dOqvektEAEYb01JPfAhQHz0m2cNwU8IOpcDrm/DA/4qcd31r/nEbuaAVe2cA2rVVASApjGCiZpIhPsnlo3F14pvyATnovZAzNs1NgGnSVFPCUiHHPeIzQssSV2DEPVw2VU9tW18dbR43MY5ZYYFrTtpbEJsF3pN5El+KCXVJnFYDIos+wIAX/Ftbqvmeo5yJj/HZIp7id7bP2SnuxlA84NO2iRiE6ahCQAfsE9PSmVS7Rc0/01bNddTszYR5dDnskeNvIeyjogAXo0psb/8DXRk83Ro38FvGV7IpWXG9RucTlENzbhfzAImAoZDfbHY19lI1W/n/YmEbKZ//tozN93ruX2Urncj5Np4ymQ9m9qPS5wEpolWVWzjJ0KFeclX3a7lcKT1DhZtVUVHxLHv54jP+95pGSyqzysH8bFUPTSCbbrk6MpRmNJeCYvuojuf9k/+IRFT0sGzYc8qs6/hkzcWuik+h66KKbosuzY89kDXMBILDlLLXS8KQPoRzxBSSOLW+lHvhPzgjGGdmwwRKYFviF5QpU5zGlIIIFbgll/1eXv//46TzXAta4WFsHOadrYKAjoKftSsRs X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230035)(1800799019)(366011)(7416009)(376009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l3ngnR539LgbgcQtgzKX4yn/g6GQ4ZvABl+NMsJoAWqbSVHUkTO9BfHWrCX6a6fLVbhqCgtvJnuwdpzm5KDoJUlnAxPWakI3UsG/NQiz8/T78Qc6ncHq2zrt/WvywOf/J+jbairIf4lSSuv6UB6qxbzArxoVsT2LMOpYYGoSzPPj5+vMbO8r8R8cehOjBt9vTXnbIXzPf8Hp83lMvC0U9kSRITABcWS0OI11BwydLHY4WK6HGTJpe04KhfEHkO3setCtfra6jEAVi6S0daPa5jDQF8czM9AcfN8+p0bfva7SP1zyeoDTaZ7q56Llb3DTo9dl3L61TqIw4LAR9V4mNEOmHrkZaVNQ8k+etRrfMrAdAADyc1Mfz9Ccmi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jsCLvooHcopx9zn8RKneCe6nT3KfJdWvA7KQT6oK/01e5sxFXWlhoeabCruTAJ2TL4hZOKfWMk36xmQKl68WCFAoKDMopc25t0JdPVhRi2wQc1sJrjkh9hD/2wnrOUCjlG6y+hm6um17NjjLII3MPHj5z X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe1acee1-14f4-4c58-3847-08dc8c19eb0f X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2024 02:30:12.6029 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: z4oLGoKrZxJrdHGIzDLrtezh7BvHUFep7LiCiyR9EpzWqPdksy0iQfR4JTnl1FtIDCnLRI0+w0oNbJJYxmQgHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7932 X-Rspamd-Queue-Id: 0A74640016 X-Stat-Signature: cfn3hz9d6tecodtrb56u5digx8xie3th X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1718332407-891561 X-HE-Meta: U2FsdGVkX1/JZorjMR64MeHY8fT2ird9psdLzI2OIuEs++bmn97f29K/o2KQvZFOzXyuMvSaB2r+d70vov8YLEKqcYhDBlBfr9fBDTmv0hFjcKp+03iMo2OQ8MxcKS9V5WOBKDZjf2X6HwtwnCxCeC1Mourc7MskuJQW1SVEsPJK9hatabBVix7OUl4+tjrgbrzcoDfYsva0rFKksXkPfnDvn/nZkwZMcXCBZJwzPMfflq6FeKswSMoipKXQCZJD6pLmAVNvEZCA68IjYfh+ZIjRUN2IIFDj4+im4G9osA9x/TZfruSlCY1qBwJPrDmGSKg5YTHZfzVXY70rFOk0qYSK1/7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m@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Clean up and move some copy-pasted items into a new mseal_helpers.h. 1. The test macros can be made safer and simpler, by observing that they are invariably called when about to return. This means that the macros do not need an intrusive label to goto; they can simply return. 2. PKEY* items. We cannot, unfortunately use pkey-helpers.h. The best we can do is to factor out these few items into mseal_helpers.h. 3. These tests still need their own definition of u64, so also move that to the header file. Cc: Jeff Xu Cc: David Hildenbrand Signed-off-by: John Hubbard Acked-by: David Hildenbrand Reviewed-by: Jeff Xu --- tools/testing/selftests/mm/mseal_helpers.h | 41 ++++++++++++++++++ tools/testing/selftests/mm/mseal_test.c | 49 +--------------------- tools/testing/selftests/mm/seal_elf.c | 33 +-------------- 3 files changed, 43 insertions(+), 80 deletions(-) create mode 100644 tools/testing/selftests/mm/mseal_helpers.h diff --git a/tools/testing/selftests/mm/mseal_helpers.h b/tools/testing/selftests/mm/mseal_helpers.h new file mode 100644 index 000000000000..108d3fd0becb --- /dev/null +++ b/tools/testing/selftests/mm/mseal_helpers.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#define FAIL_TEST_IF_FALSE(test_passed) \ + do { \ + if (!(test_passed)) { \ + ksft_test_result_fail("%s: line:%d\n", \ + __func__, __LINE__); \ + return; \ + } \ + } while (0) + +#define SKIP_TEST_IF_FALSE(test_passed) \ + do { \ + if (!(test_passed)) { \ + ksft_test_result_skip("%s: line:%d\n", \ + __func__, __LINE__); \ + return; \ + } \ + } while (0) + +#define TEST_END_CHECK() ksft_test_result_pass("%s\n", __func__) + +#ifndef PKEY_DISABLE_ACCESS +#define PKEY_DISABLE_ACCESS 0x1 +#endif + +#ifndef PKEY_DISABLE_WRITE +#define PKEY_DISABLE_WRITE 0x2 +#endif + +#ifndef PKEY_BITS_PER_PKEY +#define PKEY_BITS_PER_PKEY 2 +#endif + +#ifndef PKEY_MASK +#define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) +#endif + +#ifndef u64 +#define u64 unsigned long long +#endif diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index b65bc20c04fc..a28912fbecab 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -17,54 +17,7 @@ #include #include #include - -/* - * need those definition for manually build using gcc. - * gcc -I ../../../../usr/include -DDEBUG -O3 -DDEBUG -O3 mseal_test.c -o mseal_test - */ -#ifndef PKEY_DISABLE_ACCESS -# define PKEY_DISABLE_ACCESS 0x1 -#endif - -#ifndef PKEY_DISABLE_WRITE -# define PKEY_DISABLE_WRITE 0x2 -#endif - -#ifndef PKEY_BITS_PER_PKEY -#define PKEY_BITS_PER_PKEY 2 -#endif - -#ifndef PKEY_MASK -#define PKEY_MASK (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) -#endif - -#define FAIL_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - -#define SKIP_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - - -#define TEST_END_CHECK() {\ - ksft_test_result_pass("%s\n", __func__);\ - return;\ -test_end:\ - return;\ -} - -#ifndef u64 -#define u64 unsigned long long -#endif +#include "mseal_helpers.h" static unsigned long get_vma_size(void *addr, int *prot) { diff --git a/tools/testing/selftests/mm/seal_elf.c b/tools/testing/selftests/mm/seal_elf.c index 6212434bd6e3..7f6a95613dd6 100644 --- a/tools/testing/selftests/mm/seal_elf.c +++ b/tools/testing/selftests/mm/seal_elf.c @@ -16,38 +16,7 @@ #include #include #include - -/* - * need those definition for manually build using gcc. - * gcc -I ../../../../usr/include -DDEBUG -O3 -DDEBUG -O3 seal_elf.c -o seal_elf - */ -#define FAIL_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_fail("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - -#define SKIP_TEST_IF_FALSE(c) do {\ - if (!(c)) {\ - ksft_test_result_skip("%s, line:%d\n", __func__, __LINE__);\ - goto test_end;\ - } \ - } \ - while (0) - - -#define TEST_END_CHECK() {\ - ksft_test_result_pass("%s\n", __func__);\ - return;\ -test_end:\ - return;\ -} - -#ifndef u64 -#define u64 unsigned long long -#endif +#include "mseal_helpers.h" /* * define sys_xyx to call syscall directly.