From patchwork Wed Feb 9 15:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 541297 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 64919C433F5 for ; Wed, 9 Feb 2022 15:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235743AbiBIPXB (ORCPT ); Wed, 9 Feb 2022 10:23:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbiBIPXA (ORCPT ); Wed, 9 Feb 2022 10:23:00 -0500 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140049.outbound.protection.outlook.com [40.107.14.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7A3C05CB89 for ; Wed, 9 Feb 2022 07:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=eofYRzQ8pZPRoLcovHKuWmM43dwWP/YPRK3RigWkAq3Wk16ZnUwY0eK4/D85IVb+hrN6EnaMohmMY0908M8lYoadjK1n+O/VGuN2GIDMKvF3yrGnCRb4KFUKBPrDlqZSYwiTNlu9mgCkJ4BGETWb9WT7TSmhP6+e9tJRMgHO3CQ= Received: from AS9PR06CA0288.eurprd06.prod.outlook.com (2603:10a6:20b:45a::19) by VI1PR08MB5309.eurprd08.prod.outlook.com (2603:10a6:803:133::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:22:57 +0000 Received: from AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45a:cafe::c7) by AS9PR06CA0288.outlook.office365.com (2603:10a6:20b:45a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14 via Frontend Transport; Wed, 9 Feb 2022 15:22:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT041.mail.protection.outlook.com (10.152.17.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:57 +0000 Received: ("Tessian outbound 2877e54fe176:v113"); Wed, 09 Feb 2022 15:22:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 75ed4d2460b9115f X-CR-MTA-TID: 64aa7808 Received: from e8c803774e21.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2CF22B2F-50B4-4D32-9119-613B9F1D3A2B.1; Wed, 09 Feb 2022 15:22:50 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e8c803774e21.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C3nbLnrTuFifHqkNQp+8qMLhd67RK0C88qnvhvesaLDxaX4LD3TvmBm3rn8jCcFtfpu8FaUoXKaquvk0J7vtwH77dc8PAPIXp4H3aRExHXLUyNyMMKPNnSV4HnLaiM4gLJOu+YvfqDKwYvoxAp3K5pT0t4WERidiCZbaoyDWEAvUGBw+O54FzopBg+j6HeWBxWlqURx+lWXR8PmDmf3wKzKSMgE67jxtQxCpsAjGvtbJpANhmhvcAkUMSmnJ6pnbD4Da6AEzJJmV+l1F1q7nZFqFx8LZTIvXtQtJ+tIt3Hq0fuxBg06vwb8YBS7MO5/h2mU4bB5wZ8aAJIztchCv9w== 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=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=RWcryQWprqEXhYYkdVja/S4RV7+5JxPgMQs2VjR/Gf1r2hYdrckCrE12Rb0ZzUF9RoBcqkQxJD4O6RAE9odlQWMepHwcau2wtsnN5kVjth5P/ShVbVZqamrs89/iHg2tyccm+OxTLfhwZ87Uuj6nRJ9ls6WxtHMAubEaAzaexJaCghf5qr9SfV8fs01uvYt8fOEqmcAxifmQuaI5mm2MAOsWHQznlFoLWjdN2whVnUMxcUUIauB0WfgJM/vuTU7/31JHF09Q6xvnk/xZN51/1PYwiv483Yh14xQPdyEk6VrCRs8VGjuFbV0PqYlNz3gmr1AAIzo/ewfERjnN/CgsTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=eofYRzQ8pZPRoLcovHKuWmM43dwWP/YPRK3RigWkAq3Wk16ZnUwY0eK4/D85IVb+hrN6EnaMohmMY0908M8lYoadjK1n+O/VGuN2GIDMKvF3yrGnCRb4KFUKBPrDlqZSYwiTNlu9mgCkJ4BGETWb9WT7TSmhP6+e9tJRMgHO3CQ= Received: from AS9PR05CA0032.eurprd05.prod.outlook.com (2603:10a6:20b:489::30) by VE1PR08MB5055.eurprd08.prod.outlook.com (2603:10a6:803:115::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:22:48 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::25) by AS9PR05CA0032.outlook.office365.com (2603:10a6:20b:489::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:22:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:47 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:50 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:45 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Wed, 9 Feb 2022 15:22:49 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 2/6] kselftest/arm64: mte: user_mem: rework error handling Date: Wed, 9 Feb 2022 15:22:36 +0000 Message-ID: <20220209152240.52788-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: cbf42059-4bd7-46fd-5670-08d9ebe00d09 X-MS-TrafficTypeDiagnostic: VE1PR08MB5055:EE_|AM5EUR03FT041:EE_|VI1PR08MB5309:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: r7GR9BleRN2DP3GHnld5guZfhnmjnyUx33yq7ljHD2pMc8MKKFCiHx8bdQzPs/6+xmeWwVE/FfAfN0nAK3iF2wgDM82/APa3d3nzlnt5sOQeZP8WJHW/+Ip1RIS3kGtFU6D8xyGfzXylZFCWToOHvFfjMdMrLyReKrwSv52uZ2H5SjXWC2EDNXt8B5Jf9IrmT6WunIB5DcRs0iTvbu1wCIhdxkzN6x1pa+V1ht9c7VO8hCan8SwaeJEsq2J8Hy2VZrSAVO0E0EZsKIPdgurMSUo4ujxDAMWNWlBy5LnWfIqZIowdXEFsQvt1sRMWYj352GbsrKO7lhQj9wqVKhGEMFurSCWPcKHIkyGqojWLsbI3zYzMsCQ/by1eHz3KSG2MG+BPq+fmPtF6aiabwj8KkRMx92edUoJh5aAikvxWuun21sv4sdXVjdUmdND/O/r6MTjOkrzVrYWFbkriH+rH8aPDJjh8FYmQ5azBQpBY9D/ngvp3MxqhARAouB2Xkzr0Cn8FtHP4olmY/VWtPQeedlwLxQCc+unlYnBQkVyS7HNUSVXLJN19lumhAW8nc5ZrymY8zxScn8lPLLWlyOYcN147nIl7P0NtOi4ZxBxqZSw8TJY4GL5x3bJlohHv0We/S/mP0iL5UPhljFeJGOz88cu5ExiguhMIdShHpGaOkbha5vhHPuJhwBzc9zLCHdAHfmvwuQRg9qRg/xPYvy5ibA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(1076003)(47076005)(356005)(81166007)(6666004)(70206006)(7696005)(83380400001)(70586007)(44832011)(5660300002)(2906002)(86362001)(316002)(4326008)(8936002)(336012)(508600001)(40460700003)(426003)(54906003)(26005)(186003)(82310400004)(36860700001)(6916009)(8676002)(2616005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5055 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 33631bb3-2ebc-485b-9d7f-08d9ebe00731 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wfsldFbK0EM8+WLoqZF4Hjz7PjSn6ajgTzSb9xX4NmAfFauqpAbtQ7UxiG7+raXtKpbff0OkqnJx/B3NdF65SPxRrdib7oZeyVCmrXwupW7Mk0Ouh0nt6Qz1eVf50rUFOqMggRt6S9ykbkRc0Bm4LnRaKgYYabWBvKcrTAAcC2OVKseJdp9HwKjmYPjx0TVtfcKd9ZNbvAsN4v51Oc2ra8StpuCJylH9iZN6rlJpKYrMDEpFre70CTPDgqs7JbA4VnmouveQyHsZxW2/Yd1HtmP+iBkIWMRjGBhG5f1svHGvebFtt+HJHl9oEdqckTI2of662xppNSNImV48eqhNsxB4nJ9l5cgYmBDPFS6P9w1Q/M/jmyvM/EaK+Le9KwmI6EkLmkTVup93Oeqkj88gSjXDMqJap2zv9ZRfHDUkwpkKMB0+LJmHtgtUMZJO1TU2fVJepGID8qhLf09fdE3rqhaeJ848OrEzXn5eNT5WCYgNisXKLuT9t3U2nzPZqErM8boeAEgXSxyjSccaCDNxfD31gUgBorBrHSAr7ycz8LOHw724Ug0uY7P941vIRo3xCHesOXPTTlkXlabhHGUhEBneuffYZfhKkzZfv7tORhm72Kmera9TuxCn6IQLXnKGVDf73p3jKAZ//xopfUjSF1YIhlsMt+hGZf7Gj7CfedoK5T2Y2B4dOKfm8OLhnu2y X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(1076003)(83380400001)(4326008)(44832011)(54906003)(36860700001)(336012)(70586007)(81166007)(316002)(426003)(26005)(86362001)(40460700003)(186003)(47076005)(2906002)(7696005)(6666004)(6862004)(8676002)(2616005)(8936002)(508600001)(36756003)(82310400004)(5660300002)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:22:57.1365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbf42059-4bd7-46fd-5670-08d9ebe00d09 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5309 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Future commits will have multiple iterations of tests in this function, so make the error handling assume it will pass and then bail out if there is an error. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan --- .../selftests/arm64/mte/check_user_mem.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 5a5a7e1f5789..2afcc9fb9ae8 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -27,7 +27,7 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, size_t len, read_len; void *ptr, *ptr_next; - err = KSFT_FAIL; + err = KSFT_PASS; len = 2 * page_sz; mte_switch_mode(mode, MTE_ALLOW_NON_ZERO_TAG); fd = create_temp_file(); @@ -71,14 +71,22 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, * mode without fault but may not fail in async mode as per the * implemented MTE userspace support in Arm64 kernel. */ - if (mode == MTE_SYNC_ERR && - !cur_mte_cxt.fault_valid && read_len < len) { - err = KSFT_PASS; - } else if (mode == MTE_ASYNC_ERR && - !cur_mte_cxt.fault_valid && read_len == len) { - err = KSFT_PASS; + if (cur_mte_cxt.fault_valid) + goto usermem_acc_err; + + if (mode == MTE_SYNC_ERR && read_len < len) { + /* test passed */ + } else if (mode == MTE_ASYNC_ERR && read_len == len) { + /* test passed */ + } else { + goto usermem_acc_err; } + + goto exit; + usermem_acc_err: + err = KSFT_FAIL; +exit: mte_free_memory((void *)ptr, len, mem_type, true); close(fd); return err; From patchwork Wed Feb 9 15:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 541295 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 C4241C433EF for ; Wed, 9 Feb 2022 15:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233045AbiBIPXe (ORCPT ); Wed, 9 Feb 2022 10:23:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233738AbiBIPX1 (ORCPT ); Wed, 9 Feb 2022 10:23:27 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70059.outbound.protection.outlook.com [40.107.7.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C8FEC05CB90 for ; Wed, 9 Feb 2022 07:23:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=sgaam0UTxXxWfEGrukZGN2qYudMkdhvbpPagnHIDx1h3KQLI6A848sLoZilDe5HES96TeOUzbPPnF8mi6OQlK8qtbwqpSfrwBRfSXi4yvrYB8eL5AJVSwpVHb2+AeQx+JSRillBwvIle7OHzFXg7oF2uF9OVsPdv9qH8a49Gfhc= Received: from AM5PR0601CA0076.eurprd06.prod.outlook.com (2603:10a6:206::41) by VI1PR08MB4336.eurprd08.prod.outlook.com (2603:10a6:803:fe::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.14; Wed, 9 Feb 2022 15:23:23 +0000 Received: from VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:0:cafe::cf) by AM5PR0601CA0076.outlook.office365.com (2603:10a6:206::41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:23:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT062.mail.protection.outlook.com (10.152.18.252) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:22 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Wed, 09 Feb 2022 15:23:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 12beb7a43d10e576 X-CR-MTA-TID: 64aa7808 Received: from f12f5f16e401.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9F163494-A6BE-442E-97BD-2562E1D2019B.1; Wed, 09 Feb 2022 15:23:16 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f12f5f16e401.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:23:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bkNtA6agkJM4K0obZHZchmiRIowMFGKh8sYQSxSHmhLCHi058Wvl6CpAHFvszuIWt82BpAOyVQ0r9F9PnXLE9Jf0k1BYlSmuJLU6fXhzs9EwlKxeqHWuGlFiJ1YVx2psSKVrBpg/efKg47D9730ctYnizuJPtSGrh2CoI9TxO4cfUsM+ssgVheIwUM341C/cHe6QODMxcz3O3NEvN6nJlAKbW2p6pT8JvyhoZ0hMrvfXK1UwYodJHavVJDC6/aJ6/wklk79aPrYpVVblpSAj3WvndHs8vZIYLi8pkVc57oNhqP2xtnM/8j8XdgFY2kwZlYqYdKHEZ6rIU4hbFgKxVQ== 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=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=bPASvwMi58DGrnVPlJJlZVmg8QDrRhjDKwVtEpPaKK7/w1ihoadvsgF/irsdicEX5wRitFjTgI2M5WUsY15XpKMxIauadenK/JNppSBbsiLYB3/egR0Ek3ULceX6rhxAMxfDIrsSWulqdzk/ySOnQF9OKd9XtPR6+3K1b8DknjuPjWtLPLBV408ypoqDpdC6FgudpNSrROvaEYFLu3DUrypkGta5eZ6PIRL3XmNgLlEHkGowLybdewuJdHTP0vTLM24HiwoqCUzxsnYF5sCLM6fxXQ7YzA5TfmRH7fFm7ytrPFNZ0McSupQWYVEb0tkvhUAWgt5rtyT6xtq+Z6kz3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=sgaam0UTxXxWfEGrukZGN2qYudMkdhvbpPagnHIDx1h3KQLI6A848sLoZilDe5HES96TeOUzbPPnF8mi6OQlK8qtbwqpSfrwBRfSXi4yvrYB8eL5AJVSwpVHb2+AeQx+JSRillBwvIle7OHzFXg7oF2uF9OVsPdv9qH8a49Gfhc= Received: from AM6P194CA0040.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::17) by AS8PR08MB6679.eurprd08.prod.outlook.com (2603:10a6:20b:393::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 15:23:14 +0000 Received: from AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::a) by AM6P194CA0040.outlook.office365.com (2603:10a6:209:84::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:23:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT022.mail.protection.outlook.com (10.152.16.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:14 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:50 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:46 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Wed, 9 Feb 2022 15:22:50 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 4/6] kselftest/arm64: mte: user_mem: add test type enum Date: Wed, 9 Feb 2022 15:22:38 +0000 Message-ID: <20220209152240.52788-5-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: a2b2c379-afc3-4b7c-37c1-08d9ebe01c4c X-MS-TrafficTypeDiagnostic: AS8PR08MB6679:EE_|VE1EUR03FT062:EE_|VI1PR08MB4336:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XByxhaBfo3gIfeLXZ/Zf74jNW1t/y+ITSY4yb6Y49DqypKxdd3i1ZtPYYglKalsXMhEiYXHcx0us7n4KY1M1rLIyofS071nqyYcaEt5/6Bbj3tMVcRcwvU0itgHEkHWdwEtDPK6YpLU9Xwo1T5GofIbaUXJNa0bmsHs7VFi8oO8N10ELb7IuCv4jJd1w1llTBWHrGWM05jASQA4VN+/0NHp7HE6Q0xzEP1XU4O4ckl5DXyRrq4qWODBEjp+IOTXCmW0oBgLCxjqihsJzTir884VRgMFV4rPENebRgLA4W4kJ73cQxwfcR/YPGkFPSgSl1VPgqrB77AUXyKjpP74HnEUdYq9z0jZ7LSRP6E7kmiFhhdsFUPFrT4mcNDiIuRaItmyQxDqjBL5jRuXRbgV+VoeHNiI/5oGEgx2YMyU6O6xEhYjokmzvr3mZ6ofL/uMz7HmAzyYQliV9tjvmaebB3xyVE2W8JgrWtW+DGNsN0Ra8Ujx8nA4hpoxc6Zj0W0+tFuffvOYKP+sPcWZDSf1jEspPSmvy7ClIb/wkzzQ7u3q1Q4QZIbbu3/hP+pCmA03AL12bJcidzxEQ+DBwSxJvBIpGBBLHJRFROA2YBiT8sxmW8tYgCvi+5drnNRsFWni8hno/v50CzkDGJ13ze1z/2GdQhiqJtT6sYqjOxdLkew0Ij4uxOe+FiM2/Css9+WKWBAu+JtFzZqrWPHhhYbXVxA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(356005)(36756003)(336012)(36860700001)(5660300002)(82310400004)(426003)(316002)(7696005)(508600001)(6666004)(83380400001)(86362001)(47076005)(186003)(26005)(40460700003)(8676002)(2616005)(8936002)(70206006)(44832011)(2906002)(70586007)(81166007)(54906003)(6916009)(4326008)(1076003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6679 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c1c813a8-800a-4036-bb4d-08d9ebe01707 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7xmf3gTGjuH3zgkLrfO65nKVAUcVNNS2a5p6LhrgzUHIV3xcLCCYS/Dn+gdZ0YWII9HzT6F3LNb4ScOUBx4SRfeQ9OQpNYo39D4J7xlc6JIzW0UgqyXxMtJLL4C7K4b9RMuDhLq06aqQbuc7W/KkIjJyvr7DV7G75hDnYy4wLaLOc2pQt+xIoPc9I2SsWlMK8eSKRMPslfw550v7dzFAWMhbQYXeSY6jk4ARFurcRFh8tnR0gImIDJDrVETXUg9l/xTYeZHfBpupoDeZu772SO3+DUgTofn2uMptF2UGu3iqLV8vq/oPPkwTInXcaHre6tZD6vmkZzoJUZVqYCtlEEU22dNNneyTS1zh5UqRih8Yhbv1uk/Y6A52v0vAJ3AWC6X8VKL5jkf8Edii3fYtdBXSGNtzSV2NvZWyLvO74ZRqxpIX5cGzGmZmanyrnqal8Ni0rFtnmd93XBSw+KyqF6ZS9cObbEzAcoBv+E65XjaG9TI16YZJJBeeILkqEMxoOsrhn2SnMa+YDi92xAg2PMGrTlB1G34cbMBemPKkVDqnHdt53qX0h6oa4SNNIIv5Zl1qmTe/7tTT7+wRm59NgeGNJ/FUS4ZsXpjkZLQYfv17kASJo4GcxvXPTEYbaKN3KKMXpN0M1WEZbd/+01BkzfnW0KakgW0yTQYPDGxDhqs= X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(6666004)(86362001)(2616005)(70586007)(7696005)(82310400004)(40460700003)(508600001)(36860700001)(5660300002)(54906003)(8676002)(47076005)(70206006)(6862004)(8936002)(316002)(1076003)(44832011)(83380400001)(36756003)(26005)(426003)(4326008)(81166007)(336012)(186003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:23:22.8526 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a2b2c379-afc3-4b7c-37c1-08d9ebe01c4c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4336 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The test is currently hardcoded to use the `read` syscall, this commit adds a test_type enum to support expanding the test coverage to other syscalls. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan --- .../selftests/arm64/mte/check_user_mem.c | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 89c861ee68fa..58b1b272ca80 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -19,12 +19,18 @@ static size_t page_sz; +enum test_type { + READ_TEST, + LAST_TEST, +}; + static int check_usermem_access_fault(int mem_type, int mode, int mapping, - int tag_offset, int tag_len) + int tag_offset, int tag_len, + enum test_type test_type) { int fd, i, err; char val = 'A'; - size_t len, read_len; + ssize_t len, syscall_len; void *ptr, *ptr_next; int fileoff, ptroff, size; int sizes[] = {1, 2, 3, 8, 16, 32, 4096, page_sz}; @@ -46,9 +52,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, } mte_initialize_current_context(mode, (uintptr_t)ptr, len); /* Copy from file into buffer with valid tag */ - read_len = read(fd, ptr, len); + syscall_len = read(fd, ptr, len); mte_wait_after_trig(); - if (cur_mte_cxt.fault_valid || read_len < len) + if (cur_mte_cxt.fault_valid || syscall_len < len) goto usermem_acc_err; /* Verify same pattern is read */ for (i = 0; i < len; i++) @@ -69,8 +75,16 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, for (i = 0; i < ARRAY_SIZE(sizes); i++) { size = sizes[i]; lseek(fd, 0, 0); - /* Copy from file into buffer with invalid tag */ - read_len = read(fd, ptr + ptroff, size); + + /* perform file operation on buffer with invalid tag */ + switch (test_type) { + case READ_TEST: + syscall_len = read(fd, ptr + ptroff, size); + break; + case LAST_TEST: + goto usermem_acc_err; + } + mte_wait_after_trig(); /* * Accessing user memory in kernel with invalid tag should fail in sync @@ -80,9 +94,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, if (cur_mte_cxt.fault_valid) { goto usermem_acc_err; } - if (mode == MTE_SYNC_ERR && read_len < len) { + if (mode == MTE_SYNC_ERR && syscall_len < len) { /* test passed */ - } else if (mode == MTE_ASYNC_ERR && read_len == size) { + } else if (mode == MTE_ASYNC_ERR && syscall_len == size) { /* test passed */ } else { goto usermem_acc_err; @@ -120,14 +134,14 @@ int main(int argc, char *argv[]) /* Set test plan */ ksft_set_plan(4); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), "Check memory access from kernel in sync mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), "Check memory access from kernel in sync mode, shared mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), "Check memory access from kernel in async mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), "Check memory access from kernel in async mode, shared mapping and mmap memory\n"); mte_restore_setup(); From patchwork Wed Feb 9 15:22:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 541296 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 B2881C4332F for ; Wed, 9 Feb 2022 15:23:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231447AbiBIPXR (ORCPT ); Wed, 9 Feb 2022 10:23:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235322AbiBIPXQ (ORCPT ); Wed, 9 Feb 2022 10:23:16 -0500 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2065.outbound.protection.outlook.com [40.107.20.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 454ACC05CB8F for ; Wed, 9 Feb 2022 07:23:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=vnujyJ6NJQ5Qi3moFlGJhZ84M4+kihDSDQW9zihgGWEj3EJr6E8c+246KGKg7mhAEmYdFycDANHlcwhbTh9whdWRJe6RnvUIdzB6cqB+9wOfO+eY51JKl+X8zIHADqqcWHtLMjus04h6nGCyGrhZYgJdUSMyTjZHH13rGewz8Wg= Received: from AM6P193CA0053.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::30) by AM6PR08MB4103.eurprd08.prod.outlook.com (2603:10a6:20b:a4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:22:59 +0000 Received: from AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::9b) by AM6P193CA0053.outlook.office365.com (2603:10a6:209:8e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT046.mail.protection.outlook.com (10.152.16.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:59 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Wed, 09 Feb 2022 15:22:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7e58cded069838b5 X-CR-MTA-TID: 64aa7808 Received: from 7e25753eca15.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5769496F-6A58-4D61-87E7-9BDDC57C399A.1; Wed, 09 Feb 2022 15:22:53 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7e25753eca15.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJhX0R608cIjVEXRGVgRQfciptyOmVAtvffvu5Ls5qc7/+KmCFFqqyG3IZIp0Dp+F6YAWZLeXLTRraO5FaryDFNjZpj6ZN2fGcqzlZxe5Yn3FXBzn9yFTQ9JUqsYRFfw50qHoHl4bd9Z9+Tdqr4RYN5zogvOufqMXaf7kudgo0Jys3ysPupktv7E6QGPBxwCOiEwq987hvl/GY3onfhZByiqaOXnM7lHtK9Y7uN5N4WONW9f/8dM7TF5BEetLW4AtxqeGFhe9OMRMhJi5+pRyLdRgcAPCQwQVQnXrdZSJ4vjwwPl5MXsUwDxTHuinE2xj20i2I6G1BT4C/Fycwkw8g== 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=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=bfEisWYGFCGIMeqBiXlUKIBUj+D28smsy3Cbb2bf68QYGzKLNwpwdpJ+Cc+spiRrqbwfnqATCi35TTolG3qPb5pSqczqbIvg1UOFjKXLUGrp8XA33aa858X/0AbSM9LE09dkDlOj7B1bEoI9jLTbk/0cqSJxmrdUB3Ha2ysQ/whWlzG/pCWTIRWeb7BeynWtuxKoKvpVbchK4v8ffc3vvk1SomLa7sz4hMvb1o8/HytELQ5jg3KJbNSyg9/RGUh8d+tfRC705D0pL/I9+9EnAg35kBzBuLVr5xpoyzoWl5LkSygJR38fYGK9EkEoQXr1EB61qr1Oe+f3+Yn0JwPUXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=vnujyJ6NJQ5Qi3moFlGJhZ84M4+kihDSDQW9zihgGWEj3EJr6E8c+246KGKg7mhAEmYdFycDANHlcwhbTh9whdWRJe6RnvUIdzB6cqB+9wOfO+eY51JKl+X8zIHADqqcWHtLMjus04h6nGCyGrhZYgJdUSMyTjZHH13rGewz8Wg= Received: from AS9PR05CA0045.eurprd05.prod.outlook.com (2603:10a6:20b:489::11) by PR3PR08MB5609.eurprd08.prod.outlook.com (2603:10a6:102:81::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Wed, 9 Feb 2022 15:22:51 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::65) by AS9PR05CA0045.outlook.office365.com (2603:10a6:20b:489::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:22:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:50 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:51 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.20; Wed, 9 Feb 2022 15:22:46 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Wed, 9 Feb 2022 15:22:51 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 6/6] kselftest/arm64: mte: user_mem: test a wider range of values Date: Wed, 9 Feb 2022 15:22:40 +0000 Message-ID: <20220209152240.52788-7-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: b1bc5bbe-b623-43b0-7b43-08d9ebe00e30 X-MS-TrafficTypeDiagnostic: PR3PR08MB5609:EE_|AM5EUR03FT046:EE_|AM6PR08MB4103:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:989;OLM:989; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FKd1cpuMxDz4udbUMdzQYeZYFfpAun7ycxLdWXBUSiHLDw62nJ1eGuPZNB4i2Zb/xRXoCeRs5ayNmywMtRcrDQpZmQ9EcWcR+u6B2NXJ5IyFDvKeoy5PxSDLBJ+qVdDdzx6SK4OedJawzp/AshHERq2aNSaqN5Ml4nu2KHIiSm/1aNl/tuz9bahwzqjVPtYhrYchU4ZxRIt5L+wxEBXkBLUu6NS0UmVojtwfzODF6n4MVyPyPJWT6eYyBGpdhYXfi7WPjZhGMMEouvC2QGHc0uEP/G8/fxf2rQCBn0DxWv5O9b/rvc+VybJgTqoF0ia0pSBLmiWv1eW/BcAVWfrL9R/hMLDUptjxcOzjRQL1OKZMNskyUUedBLRfFaU18TVfIAmgMxceNyiYxjPJsR2Y2mKXjsXhzca/zNlretP9cWxnQz7AvkanzJ/cjQ90Oc0R1WcRIhvC7eqXRiFw3Ybu7W860aAgx6/Bn3tY4yK4IpNHIbvwt+1HGLZKe33xC9Jw0LFxGlkYeXwZaAi4JZZW1WtgmQnecZslCXqIm7HL0k4AtgkEUncYhU+TE4Soh2wC0VkB7oDItN6kiUX+fx/v0CNozv5wxA7eVwHfEgHLHoTOepyhmIXNdNUMYJRAd6rffu9AEyfFOHUjN+DBQj+q6RBVbHFBbAv0EC3vFvwfy0H9xklcD1Rly28EQLWm1dRgfwj5wDOOtP1NCNFEbiyD7Q== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(47076005)(5660300002)(4326008)(44832011)(508600001)(2616005)(356005)(81166007)(1076003)(26005)(8676002)(8936002)(54906003)(40460700003)(70206006)(70586007)(36756003)(2906002)(7696005)(6666004)(36860700001)(82310400004)(6916009)(316002)(186003)(83380400001)(86362001)(336012)(426003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5609 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f3b3c1a2-c09d-49ae-2df6-08d9ebe00913 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lzEfOXtDSxwLEGSS6C2IAvANBvA5UzkQToSj0ZTGum9fdQO7SqHca/pRi6k6FkRQpwiyLAUrRtBayKwOUuxQCuE/4PQvcN9/qEuNPZTdM9gYR39ptR9Y8eEWxynU3d4KSfDFPkeYwEok7Xu9l3jnezts/ZKgmkMD//YpT0IJs77u/TdBrU0DucB2N97D/vVpgeLGM3gddzlUyKK0zMhGbOeotcUZx50SFP839mlSA2Y86arGkLxJ+NSIF7nah3r1L0+sZFPeI28Lned+eTsSgqVB7LiGFk9kVs5X4XrUMGiwKyQ31NQmbyrwf4P+7zqbV/ra0US1Nr/LJcQjYKygyXzwWRS5WHITMwRTeCA6QRbthOXo5Clm1XFMCkXCPDUgVLFPXCpSWa5N8Un2qwTouX/8aRvzuvc24BtUs7h5SbPsekY6E921bedqDebHJOvRDVl7IbWCatCjFUwWzrHKLmGoY8Cf/W8etGzquG2K0/RaTADIROpjJwJKvaSHHNzSU1CWQbn1ty9aTqiySFVLuvD+cMGs8zXb7Wzp/PVPxuk/Duo+3E2JydILvqIArccbqcRC1ZnduKPH0dnqS8672VfzOi2oJdsSR785J8/dQ0mnkwcrUOzZQYLzSzsgrs24TQrPHXHt+wIdlxP2kiqcmHvnIRmMWLhYmxT7/smLIRQMe3jpAgNalcymrka/ROso X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70206006)(70586007)(426003)(1076003)(6862004)(26005)(44832011)(336012)(4326008)(83380400001)(186003)(8676002)(5660300002)(86362001)(81166007)(47076005)(54906003)(40460700003)(36756003)(8936002)(2906002)(2616005)(316002)(7696005)(6666004)(508600001)(82310400004)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:22:59.2114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b1bc5bbe-b623-43b0-7b43-08d9ebe00e30 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM5EUR03FT046.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4103 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Instead of hard coding a small amount of tests, generate a wider range of tests to try catch any corner cases that could show up. These new tests test different MTE tag lengths and offsets, which previously would have caused infinite loops in the kernel. This was fixed by 295cf156231c ("arm64: Avoid premature usercopy failure"), so these are regressions tests for that corner case. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan --- .../selftests/arm64/mte/check_user_mem.c | 94 ++++++++++++++++--- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index bb4974c437f8..f4ae5f87a3b7 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -3,6 +3,7 @@ #define _GNU_SOURCE +#include #include #include #include @@ -20,6 +21,8 @@ static size_t page_sz; +#define TEST_NAME_MAX 100 + enum test_type { READ_TEST, WRITE_TEST, @@ -136,9 +139,67 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, return err; } +void format_test_name(char* name, int name_len, int type, int sync, int map, int len, int offset) { + const char* test_type; + const char* mte_type; + const char* map_type; + + switch (type) { + case READ_TEST: + test_type = "read"; + break; + case WRITE_TEST: + test_type = "write"; + break; + case READV_TEST: + test_type = "readv"; + break; + case WRITEV_TEST: + test_type = "writev"; + break; + default: + assert(0); + break; + } + + switch (sync) { + case MTE_SYNC_ERR: + mte_type = "MTE_SYNC_ERR"; + break; + case MTE_ASYNC_ERR: + mte_type = "MTE_ASYNC_ERR"; + break; + default: + assert(0); + break; + } + + switch (map) { + case MAP_SHARED: + map_type = "MAP_SHARED"; + break; + case MAP_PRIVATE: + map_type = "MAP_PRIVATE"; + break; + default: + assert(0); + break; + } + + snprintf(name, name_len, + "test type: %s, %s, %s, tag len: %d, tag offset: %d\n", + test_type, mte_type, map_type, len, offset); +} + int main(int argc, char *argv[]) { int err; + int t, s, m, l, o; + int mte_sync[] = {MTE_SYNC_ERR, MTE_ASYNC_ERR}; + int maps[] = {MAP_SHARED, MAP_PRIVATE}; + int tag_lens[] = {0, MT_GRANULE_SIZE}; + int tag_offsets[] = {page_sz, MT_GRANULE_SIZE}; + char test_name[TEST_NAME_MAX]; page_sz = getpagesize(); if (!page_sz) { @@ -153,17 +214,28 @@ int main(int argc, char *argv[]) mte_register_signal(SIGSEGV, mte_default_handler); /* Set test plan */ - ksft_set_plan(4); - - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), - "Check memory access from kernel in sync mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), - "Check memory access from kernel in sync mode, shared mapping and mmap memory\n"); - - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), - "Check memory access from kernel in async mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), - "Check memory access from kernel in async mode, shared mapping and mmap memory\n"); + ksft_set_plan(64); + + for (t = 0; t < LAST_TEST; t++) { + for (s = 0; s < ARRAY_SIZE(mte_sync); s++) { + for (m = 0; m < ARRAY_SIZE(maps); m++) { + for (l = 0; l < ARRAY_SIZE(tag_lens); l++) { + for (o = 0; o < ARRAY_SIZE(tag_offsets); o++) { + int sync = mte_sync[s]; + int map = maps[m]; + int offset = tag_offsets[o]; + int tag_len = tag_lens[l]; + int res = check_usermem_access_fault(USE_MMAP, sync, + map, offset, + tag_len, t); + format_test_name(test_name, TEST_NAME_MAX, + t, sync, map, tag_len, offset); + evaluate_test(res, test_name); + } + } + } + } + } mte_restore_setup(); ksft_print_cnts();