From patchwork Tue Jan 25 15:09:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12723954 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 3AF53C433FE for ; Tue, 25 Jan 2022 15:24:56 +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=5uZHddbm3FEl0lJsBiLrPZmHbGc+3tM/3V+oCAzCHvM=; b=glqObuUVVOcGJt gdNoyrFshDDwhHZ3Kj8PkHaovJVuNZabudHgep6R2SEDIUNZD2Jj07aJli0wUIeFU+1gw3macLaGW Sh1Q/OmL3bQRxqUY6XGhy8QXUJCTfq9+GaI0oHtFqutp19EssLtncVMCIJXRmwd1j7+7uXdpPLET9 oZfbHXBS75jqf9e2i/WEugfsjoF27JXIlEga5AkRq17jKbbOd+g9p9mOXoVjnOx0H4KoHiJv8A8Cd mCit8wJAKinx66GBHdOz2gOaxy/EBMXxVUIylqFTvDj8X4u3ew2LjIC/oTl5hmyCplvieNbpoPGAd mmYi8BXmla32+t6kvsXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCNeD-008MGW-PC; Tue, 25 Jan 2022 15:22:19 +0000 Received: from mail-eopbgr30087.outbound.protection.outlook.com ([40.107.3.87] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCNS8-008IGG-8e for linux-arm-kernel@lists.infradead.org; Tue, 25 Jan 2022 15:09:52 +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=n8RZXb3UAJqcQfKRAYKnk/ciO5TVsCERIQCGQGGTdo8=; b=j8M9lozo4H5s2s+fuTtDnzhkpe0A4NqlSjBl0kpEG/F5EM4za5hekJAaQw1TpjXNq2Ql9tNOyV7BDgBovbYkyc2HB0419z72Q5yrT8rAt1pCWCNRBuinVWNLWTIvC5Cgvh7Hk/7T+zDj3O8WaKJgyAxheqlLMfGAsGb/di54Hms= Received: from AM6PR10CA0043.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::20) by AM0PR08MB4611.eurprd08.prod.outlook.com (2603:10a6:208:10c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 15:09:37 +0000 Received: from AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::93) by AM6PR10CA0043.outlook.office365.com (2603:10a6:209:80::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 15:09:37 +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 AM5EUR03FT004.mail.protection.outlook.com (10.152.16.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 15:09:37 +0000 Received: ("Tessian outbound 1f399c739551:v113"); Tue, 25 Jan 2022 15:09:37 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d045720f2df44ff8 X-CR-MTA-TID: 64aa7808 Received: from 3662a102de8a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A4A84CFD-9130-481A-8696-C457EFBCFFB0.1; Tue, 25 Jan 2022 15:09:30 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3662a102de8a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Jan 2022 15:09:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LHquMVrsQBB21sv/CG2gtu3ZNzDv3hO52FvOJNixZZyH2a/kNRHQgrmkgFh8hkgn8WGH445Vi2ok/fydl6PaClfcDa3l9Vy5AfxACAz4xkojJjEuR6DFL83cLvhh4nKHmi36msiHSUWBCDhpsG6lm0dcFTOl2qLPg7PM9uR0UhZbXH0RF0Jby+qLmF+m+Mf3GC1q7PxUGZ6my3WuoENDeKnlxv9sGGF0wXbnxq1Nk0YCxUBS4PeYCyDgSrs47dlbSGgm1bURy4qHLJ2HHEpQnsHmlmEMmhYKZudjKk85AItZk0G5F+2IblVOxDkzwL982mn4F+x/RS9wi/qPBdAN1g== 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=n8RZXb3UAJqcQfKRAYKnk/ciO5TVsCERIQCGQGGTdo8=; b=S+UfFQiyohPfbyhmyKB6iO7i4DAjEKBtUMWcx0jDTDSZhsY2Amza+rgvneCiP0owJyAX0xgXsoxFtPoVdMh7wTaAYkVRVq1LFA2QGlX0kaER5dZM4RWFZma8pjANJfXQVVoWYDFXonpETSmILpq1DKQDGGL2EnyUVIjHc80SL8xwHygFCTMpxy1b9wReahW0cv9GacMcD/vJHWoJXXDtoIX4mqlcsUE2KiRjsYaMaio1z5XHo7fCFF0QJPftYutsyQ6m+zWYjaLYsDO21a7egtEDYYJDO95wyiGlOnkKAxSikvCPA7gQq94+Ky1Tp6QsGx3IPZdIfeL2H88yOvLwfA== 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=n8RZXb3UAJqcQfKRAYKnk/ciO5TVsCERIQCGQGGTdo8=; b=j8M9lozo4H5s2s+fuTtDnzhkpe0A4NqlSjBl0kpEG/F5EM4za5hekJAaQw1TpjXNq2Ql9tNOyV7BDgBovbYkyc2HB0419z72Q5yrT8rAt1pCWCNRBuinVWNLWTIvC5Cgvh7Hk/7T+zDj3O8WaKJgyAxheqlLMfGAsGb/di54Hms= Received: from AM6PR10CA0048.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::25) by AM9PR08MB6274.eurprd08.prod.outlook.com (2603:10a6:20b:2d5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Tue, 25 Jan 2022 15:09:28 +0000 Received: from AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::81) by AM6PR10CA0048.outlook.office365.com (2603:10a6:209:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Tue, 25 Jan 2022 15:09:28 +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 AM5EUR03FT004.mail.protection.outlook.com (10.152.16.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 15:09:28 +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; Tue, 25 Jan 2022 15:09:27 +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; Tue, 25 Jan 2022 15:09:26 +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; Tue, 25 Jan 2022 15:09:26 +0000 From: Joey Gouly To: CC: , , , , Subject: [PATCH v1 4/7] kselftest/arm64: mte: user_mem: rework error handling Date: Tue, 25 Jan 2022 15:09:17 +0000 Message-ID: <20220125150920.23955-5-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220125150920.23955-1-joey.gouly@arm.com> References: <20220125150920.23955-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 4edd93c9-33bd-4330-60ea-08d9e014b443 X-MS-TrafficTypeDiagnostic: AM9PR08MB6274:EE_|AM5EUR03FT004:EE_|AM0PR08MB4611:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: abgnwWTfQEVWW+aUOOitPC/HmuheBFbQ77DSYb1KvzYGlVLYFm/MnNsTE3Y+suvUzxMylZReDI5mAJc+aFtQWHsU1HeKpVpTUFi6I86fj/5vx1PKOUhFyRa73nJUnOzhKzkRMLyFrSMFlZkMnzs9HmCTKHux/CBQPSvq+vgwanNyaA1NKjg/v+PAdHGuwAt6VndsGE6FeliYRwNRTTk8yEMClqiOJE71nFRnL6M43LgerT1iCJRxwXhBHp04rP7BHJPtz8ZvxKc5DDnsK0YQLQLFtfajWmklHsotVlzJLfWG2ndlv/t2WxT5k6mxjyP9ILzF1vZGgWU42L8RbWPK0XEwfgubRY3EgU5ivPVsAV2zu6YWSq5AEW3IevpFukleqHGd5XH38/6vaZsaNf0vy7P87qTUAOQ+BoozX/I0hgTAwJdM0W6gSWPidtMjoFH46MqqaA2XPj6rRmUUWa6Q3spWOf9m2+N4lOChO65PuP1FHMeoLvbF28hb70Gtvt7NRU2wiigO+0Hi/eYizXZJuieYO2/GiGfVzYnrqBv/iJAtmuURCMWUlK+HXfcucGkWGFNEFCLjB3ZPMSs7yJoj+IO8ESn2scclfN+NSxGqNpr2rescUsAlIcUtIefvMQBhp0VFTrGGGFlPLFNq13hx5QsR+3gpkiYY3aARuOW2GW9veAjt7Iv4UZVVUTWZMyMjsRt+GiFUV8DCZpdD2Ws3yQ1fMlvmhzm7IG4fKGyAQU58RxLvsWM0R4NMj7bBokSI8e/G0XNTkFyEVgCT+VhBpV1KcVZYIEqWneK8TVKH21o= 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:(4636009)(46966006)(40470700004)(36840700001)(2616005)(5660300002)(4326008)(36756003)(7696005)(26005)(336012)(316002)(426003)(1076003)(36860700001)(70586007)(2906002)(508600001)(83380400001)(356005)(54906003)(86362001)(82310400004)(44832011)(81166007)(6916009)(8676002)(6666004)(47076005)(40460700003)(186003)(8936002)(70206006)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6274 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: adf20e93-cd45-4658-74ac-08d9e014aef4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QUCL8kAM577Qcy2mTBaTAvcbo2tkLdMIm/SGLfuyurVFsSoy2aryksoofLm9tNCP8XHvDDePTgi2eeQhMosJhnQdOjaSPuQTSmUvg9oRuJOb9xtgOgqUIt678qn7abevUK80kMtz1FUzeWituQ5Fn3+93Vh/J65+1oVvrpJ1DxGSHqMALkORPUksAfcbdPM4W+CBimprmkHnIOgDPn5dJUW67NNENhFnEgG9uSbTk4Seof7V38f8fdzGD1prykb9cpADuZxlb9IHqkqJfQ+OO5Tj7vzEzT2YusKmThhzFypHOYhF7KEgb3cZZEdZ/Gz5BjVPWyrU8AaXRzVOq3bzRUiGYABPwVn7uVLDQ0N4/zgBD1QcZ8LfxK5mkV8wCbULSgtfVEpeUx+LfP9vXwf9+a+4bTG4BZq4cPO9pItHM7Ewt12tX36aRMUrEGThaBm6jWC5l1BkSTlFUa5aQVNf5R6v93vrMEDzWyN/9cRw/VmOuoh/MiuXDaig4PZeR5L4Flykaj9IncNxad0eGDJT9YFQOSiToC0CPMLd7og5Bhm7EibUMQC9Oa2R8vZb2loD6QQ1wlXclFiguHRtTVifD2aBlO9goh/Q7ETykMeR3zGxt4rnl5do1SBFIvwMBsTCwHpMxZQkCuZ1OCnegYDSyHaL5OksKyzl+WRe36kQAo3gzrTHeqmWLBnFKcxEIiiCmhOTCVAJDo9a5INlBxM0roOvP/qRus0lIcmhUb1Ay4Nx6E2N9eYdLS5ROxn7p0mScSzyDsG0i/HacH5IJqmsJw== 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:(4636009)(36840700001)(46966006)(40470700004)(5660300002)(36860700001)(2616005)(54906003)(6916009)(70586007)(26005)(36756003)(47076005)(6666004)(508600001)(44832011)(4326008)(81166007)(86362001)(186003)(8676002)(2906002)(107886003)(336012)(426003)(8936002)(316002)(70206006)(83380400001)(82310400004)(1076003)(40460700003)(7696005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 15:09:37.7293 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4edd93c9-33bd-4330-60ea-08d9e014b443 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: AM5EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_070948_454004_16EC97B6 X-CRM114-Status: GOOD ( 14.93 ) 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 This makes it easier to have multiple iterations in the test. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon --- .../selftests/arm64/mte/check_user_mem.c | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 3497960851a9..f54143ec057a 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_helper(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(); @@ -46,14 +46,18 @@ static int check_usermem_access_fault_helper(int mem_type, int mode, int mapping /* Copy from file into buffer with valid tag */ read_len = read(fd, ptr, len); mte_wait_after_trig(); - if (cur_mte_cxt.fault_valid || read_len < len) + if (cur_mte_cxt.fault_valid || read_len < len) { + err = KSFT_FAIL; goto usermem_acc_err; + } /* Verify same pattern is read */ for (i = 0; i < len; i++) if (*(char *)(ptr + i) != val) break; - if (i < len) + if (i < len) { + err = KSFT_FAIL; goto usermem_acc_err; + } if (!tag_len) tag_len = len - tag_offset; @@ -71,12 +75,17 @@ static int check_usermem_access_fault_helper(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) { + err = KSFT_FAIL; + 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 { + err = KSFT_FAIL; + goto usermem_acc_err; } usermem_acc_err: mte_free_memory((void *)ptr, len, mem_type, true);