From patchwork Thu Feb 3 14:36:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734240 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 B19E4C433F5 for ; Thu, 3 Feb 2022 14:40:41 +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=4g6FY7jphAgSx8MMo1brTAmp4Rac+DKv70XXc4OnY2A=; b=1zMFt+XmuEBqIM 3u5+uf2YbGNNwU97WLLhonp+dE2eBrefwsV78kkly5jHoDktpKFW5w7QXsX0/i76NYpnwfVkn5m8/ cbERQqPIp+hTLQpOeuIfI7QsqWHgce1UY2ZijMj1AFF20+3SU9p03I/K9pC4u++vOhAO4zrMeGk5e JWgHI2IrisJoFG3KR57lVxxje3Savo2EagsF8r531D9tLowUDl0+jj1q452veIYtlfPXqW7nwZCC7 ZSWytJHjofvHVVwJuu98NonQaNRdJAnY3DcntwwQr9nnFB9StaTR6nCNaxSfkcsgxjIJgO26VqmEg FRE0rEYckJ224tD/gLOA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdFt-001eUY-KF; Thu, 03 Feb 2022 14:38:39 +0000 Received: from mail-he1eur04on060f.outbound.protection.outlook.com ([2a01:111:f400:fe0d::60f] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEI-001dyw-FW for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:37:00 +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=/SsRvnbCKI0T4kZo+KHXSmAjtPRnIzUJLwyHeREHq8A=; b=ojPGfKBt6T94HOdVisEkvVfaMpmE0bHdwOAraXzFKh1cyJ4DKywPvfLhhVOKUMbk0UwXBsLFhqKZOEJdN/l0RSHmfWaIeVyfXcHK9xHrdASWPZLDNXxBjBQ5aug6/OktPCkRff7cFrBUWAx8cy1X3H0itgCkHAXbEDmAoVZgFhs= Received: from DU2P250CA0030.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:231::35) by DB9PR08MB7146.eurprd08.prod.outlook.com (2603:10a6:10:2ca::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 3 Feb 2022 14:36:44 +0000 Received: from DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:231:cafe::4b) by DU2P250CA0030.outlook.office365.com (2603:10a6:10:231::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:44 +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 DB5EUR03FT007.mail.protection.outlook.com (10.152.20.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:44 +0000 Received: ("Tessian outbound 341d209a0e52:v113"); Thu, 03 Feb 2022 14:36:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0400eb831e0393e3 X-CR-MTA-TID: 64aa7808 Received: from 41c76ab11ac6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7D024713-9ED7-4D68-85C8-2E88E90EA4B7.1; Thu, 03 Feb 2022 14:36:34 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 41c76ab11ac6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bG8KQqdrjBw9v37z7sJ6hNN2U2+ITeQBDxfW1cC1xuG4JaFhUmxyIkCY7HZBqqfOc8sLWBnmDC8MlJEhv690p5023U4VUFd/VdDYm03NUKTlnclPqJFNLnBfhYogHTGz6mNbDxP+He/i8et4/KqidtFoH0kp6nJp5NmpozjHlmRCwW9hOqUAlc1/iQBaSr+k/fHKK7MTAeiGCIz7+v1ZbtcN5eaDxzdFett9Bsxx7GdQ15/sZHPPaE0FEDDj84WhaDT3WUEPJt6bK7/qZHy5l9pLyatHOgfct8wUX5ylrt4aQb+tbTa4pmT3D0RggMvghK9epVrxCTffAehljJ4bbw== 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=/SsRvnbCKI0T4kZo+KHXSmAjtPRnIzUJLwyHeREHq8A=; b=a59NQm/+1Z05eNHght029G55f/ThNMReCQBqQSxJr5JSgLgNE0dOMUYDeqlZaotdc72+eYqefx7d+jNm8NQ+AQnAJaKGQDe5ehoxvyGXvnMzNUAxwFFh2BDUQXuF8dt5Sg6urQLtk6oR7UwuZ7KQ2FUBJGLq4vWeEZ+dsWaV6po3V613zwsDQNDsiuELFP4P0gjua3ka9Xf6teLwumqo33Wj2c0vTwanhuyeN21GKhweULw/TcfnTl86l09uLku2XaB9ImAZh2wFDFzvjjqDeUtvTH0f95A9Dff13yOYDwGpngVJzCQ3zmF/bDcEh0u42tbvxh8Lp8urQI0Rl9u98g== 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=/SsRvnbCKI0T4kZo+KHXSmAjtPRnIzUJLwyHeREHq8A=; b=ojPGfKBt6T94HOdVisEkvVfaMpmE0bHdwOAraXzFKh1cyJ4DKywPvfLhhVOKUMbk0UwXBsLFhqKZOEJdN/l0RSHmfWaIeVyfXcHK9xHrdASWPZLDNXxBjBQ5aug6/OktPCkRff7cFrBUWAx8cy1X3H0itgCkHAXbEDmAoVZgFhs= Received: from DB6PR07CA0100.eurprd07.prod.outlook.com (2603:10a6:6:2c::14) by VI1PR08MB3279.eurprd08.prod.outlook.com (2603:10a6:803:4e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.17; Thu, 3 Feb 2022 14:36:32 +0000 Received: from DB5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::41) by DB6PR07CA0100.outlook.office365.com (2603:10a6:6:2c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.5 via Frontend Transport; Thu, 3 Feb 2022 14:36:32 +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 DB5EUR03FT015.mail.protection.outlook.com (10.152.20.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:31 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 3 Feb 2022 14:36:32 +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; Thu, 3 Feb 2022 14:36:32 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v2 2/6] kselftest/arm64: mte: user_mem: rework error handling Date: Thu, 3 Feb 2022 14:36:16 +0000 Message-ID: <20220203143620.30629-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220203143620.30629-1-joey.gouly@arm.com> References: <20220203143620.30629-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: ccc0e704-9ea9-42ec-0670-08d9e72299f9 X-MS-TrafficTypeDiagnostic: VI1PR08MB3279:EE_|DB5EUR03FT007:EE_|DB9PR08MB7146: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: oGzIp4aVPrFvOzfGFIEfpSvLxZ3vSBOY/joU6VPnx3kFUOn2eJTutMKZhRKNcsEAezZawMNuV0B7J8fnRRd7RbV6f1IgravSMH/6WK4pH3xflt8AnaU+V0vFiE1rsHTJI6Qwupih/paIktmtQE/7WJBT0AU5AHuLbOfmn1ewRrvRXfNcjNCgc3PPOXFHMX2Rpz3sOxex5BQSMsO3+YfUoTClQW8Z9r3pCBJYf+b19jPZ1oLauX3ojXV8xHvu8y1aNx295gcDffXvcggo0bmGQebWuDvL64ZnUHlGNMnXxFw5BfcgKuHDPvDRGPEIU78KvcZHe9IHt5p3wBSfFTHQdnuZ0PuZhwH6iYhwPoc+suSVGBrlKU6q94v0FWm/MqOTKcozUc4ErlrhbJj29eFAhToq2Hafli/scN5VKwxaVtsidN96Ql2CrJCHbWU8+OSJcZz2g2wrw73RJhAxGxmslIhqgihL2Ya18W9xJ6tio2JG1H/CAUa4A5VNN9hjHHrIMI3kekNyfnIWC6laoPX5MEV5DqCFnMxMjLr4Nrf4medi2zieaL2BiDLE+W6N0yNLS/36+s0KKiIegSrAo56IQOz7i7OyMTIaYGT+I8EDHKTN67qHuD+SzGgGo2F4IyzdKD7sQ76/o1U/BNUkk1WXccv1tNOjuI1VxaSvP3XrCgtS7of5UW0CEz1+ZhI3s297lxMC4knz2k4k9Jh9SNkyUg== 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)(36840700001)(40470700004)(82310400004)(186003)(86362001)(26005)(2906002)(2616005)(8936002)(4326008)(70206006)(1076003)(70586007)(5660300002)(44832011)(83380400001)(8676002)(6666004)(81166007)(7696005)(508600001)(47076005)(54906003)(316002)(356005)(336012)(6916009)(36756003)(36860700001)(426003)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3279 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a7e31ba1-c6cd-4038-d809-08d9e7229255 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /KRxp4ZFx5GlJHvlyLHHMtv8BFJa+J2Bwu5XA6ny1vQcvkqfEJCIZ559pGA9mWBwBOQPGn+GKauyfqF5RS9wMS8PGSXKILMsvOrzQHsbSycICA8FxB7Mig59HPewB6CR4GBioyaMdCzuT0wNe/fdfmcTWIv9t1qTnq9QiffCepFZqL8HD7H+vBO9/B2s2aMuqBs17gwvrKS6Biz9+wz0tkEoU8sMN+Lk8wLyIp1cli5+ZOP0Fq7h9ASz82cObskrCailtLswEpLwvyKqcqC3vcmttysQQ/Zv0qg7H73IISd4eLn8VhwlWutEvewW2d9gPITz1UJk8Wlv6RUN3QKw3Oh/U4mVj6ojVxm2RvUxn1SBORdm0QJCIWgDKQIaVIVLCOhHOZj8E16OuPVTGWfiZQ4fnnk8edwSfhtq1Q+jDOqijrdtScVdaJUkKJFj+Qlp/OBFUS0el6VRA3ls3+nm5JUbeRDd2lY+Q0kslIVZoStYimoqp0OKc1ZWq4F4hr8HPtq9GINib+DimvC6Dq1FGZPNYuBgdDQoluQkD8u0sIjIM7A04FUPPOhgSalOofGDHBYbJO9f3K8vJhpXbNdZ4b4ui/qmMvCU00z1IiKnisblpBpjDGxGWnhi0Rz4I0BwG75BIFgby6TmCWw+kAuqhdAIX5QC/qPVbAQlLJyZj0r3GR2qQ9K2apiNvHkA84W1 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)(83380400001)(426003)(336012)(26005)(186003)(1076003)(81166007)(36860700001)(47076005)(107886003)(82310400004)(5660300002)(44832011)(70206006)(70586007)(8936002)(4326008)(8676002)(36756003)(40460700003)(2906002)(6666004)(508600001)(7696005)(2616005)(316002)(6916009)(86362001)(54906003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:44.7774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ccc0e704-9ea9-42ec-0670-08d9e72299f9 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: DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7146 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063658_562952_11F85E28 X-CRM114-Status: GOOD ( 14.31 ) 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 Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Shuah Khan --- .../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 5a5a7e1f5789..e5bfeaeb64bb 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(); @@ -46,14 +46,18 @@ static int check_usermem_access_fault(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(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);