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: 12740379 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4205FC433F5 for ; Wed, 9 Feb 2022 15:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=D+aBu29AK1Co9UqlG5PnAWmzPYwbfgRzflS/cdJwNX8=; b=F+400LNYu1Ospn lVAQT+jYVz+VDqa2XLEGgR/NciA5iXjTJBAEmHjqPhSyd0xW/c4XNGpJw8hNWSuFdD9DCcn5RE2xF iQm86QyIq8vYjpnq4Noaxf3hzv1nsKUI4Ajq3SEzun9WTOJ67xvwEbTspLaaqGtazMfvBX/jS/ioy bM64ZSmGkueLMSMuXw3Um1C7c5VwbDYKwfVj46twh/eBPxCk/ZVhi/qbxdVpyYKfy5fBRV6nih/QY RwZUDgMWFFr1GzZ7AZOoe2V3wkJ8JhIxAgeSvcQRbBwtNAbX0EDCdmSPejKrRwLmFC+LYveZie2qm JDaTn/5LKghRl2PzJNgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooH-000YBd-Hh; Wed, 09 Feb 2022 15:23:10 +0000 Received: from mail-db8eur05on20611.outbound.protection.outlook.com ([2a01:111:f400:7e1a::611] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooC-000Y94-A9 for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:06 +0000 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 DU2PR04CA0080.eurprd04.prod.outlook.com (2603:10a6:10:232::25) by DB7PR08MB3338.eurprd08.prod.outlook.com (2603:10a6:5:1b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 15:22:57 +0000 Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:232:cafe::45) by DU2PR04CA0080.outlook.office365.com (2603:10a6:10:232::25) 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: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 DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) 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:56 +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: aaf08bbc-bd61-4bb6-5aae-08d9ebe00cd4 X-MS-TrafficTypeDiagnostic: VE1PR08MB5055:EE_|DB5EUR03FT054:EE_|DB7PR08MB3338: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: DB5EUR03FT054.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: RbCf+cZw6RqtXuXVJTaIGmSGpBGbhsogGU/LI6KZFU1Kvht3eFW2Kphod+wISR0WxNhaAwONcKy8TghNKa0zUFOANGTrieAvkGpUUJcQ0iu35hBNlChtcDskrRfG0wehaPzKOXWrUHjyxFD9P9nwo5xzcPOvyzhFJIlCjXHiLppN7Z5i0HTBfJyVaHoFRY5Xd01vfTaFZsjp9HBoHhERkVLZ312lTnZdpkLG8xzokp+mb0JY3fC+nF09M1X995kVLRDnM5rYmtppEnX/4n5BJWxfTYc7Z+L+glrm1VzWtbXLDprnwTDMWPZ8QluGUCMLlnsJmUZJ+H2yF4fTwL7HyD3gX7lvI/CbWiNeey3ZHuk37ZQbdljnBz4eW62c9YCUqsX4FyOG4m5L8JaeWZDCeAxprmtZbCV5ksyXPwU+wZQT4qBsbaPCcgpu97xBcyq1Stv5eRxqZDGx9jgO1qUv0C3uZhXq3l4ChAsh07KNx1v3bZI7SlCJEeu+c0MFKVpsVdmdWAh8PHkhJ5U2mEoK3GXjpuCWI5Ie4iVbJ63hgz1ZrfurZUYqpc70qi5PmodxE5Vg/E0fJ/iQ4mPjgVqE7lj6UD6kS9JR8qPrCLJOB7flv3kc6swX1c7DcnR+Ifi2VTUc2vgQk08Zs67WzLNChjjj2uh7KLreEN/lQZgSZ0hquyfwqiTW2KUJat/51NOZ 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)(46966006)(40470700004)(47076005)(5660300002)(2906002)(8936002)(26005)(107886003)(8676002)(186003)(336012)(70206006)(36756003)(70586007)(44832011)(4326008)(2616005)(426003)(7696005)(86362001)(83380400001)(6916009)(6666004)(54906003)(316002)(1076003)(40460700003)(81166007)(36860700001)(82310400004)(508600001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:22:56.9924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aaf08bbc-bd61-4bb6-5aae-08d9ebe00cd4 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: DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3338 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072304_428901_C5F43780 X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Reviewed-by: Catalin Marinas --- .../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;