From patchwork Thu Feb 3 14:36:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734235 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 856FCC433F5 for ; Thu, 3 Feb 2022 14:38:40 +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=hKz+RPdFBuzNhLL5bRzH0foxNyGP5Haex0vFt4WFXUY=; b=r/Z6Jvfgfw4weQ tCWiSFBcuOhK9OMQO4S8IodASDCOH8+tBxa3fMENyOyIUIrxdVB+EyXUNWBdM+eJzg+j11r8Csttb MhYd/wj/EZ3XyxzRTFcKOpof2ibg8iyEWw/iuoUpts1B6ZszMEq48o9t5EinuoGyOzSd6mYKYnIPm D/1n7jZixb5M/wonm7p5yp9xGWYgAzJLtPOe0NlRgUCVtVB/+AxyhEMtbUjNZDBVDW9qax3j1tOeX lZdtF7AqgjBnSPFvl/mCgQt271Mk1CJhDNL6tPWMJpPONf6NGir70ZW4pLUvi5fqZPFCT00DSwZ5f YEsIepFiVQ6icx5izAQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEB-001dwc-2n; Thu, 03 Feb 2022 14:36:51 +0000 Received: from mail-db5eur01on060d.outbound.protection.outlook.com ([2a01:111:f400:fe02::60d] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdE6-001duU-DW for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:36:48 +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=LUoB+NdfYb5+9UmMMBLfBGN5SzGOEsh9NjPrPdqPYSE=; b=42dl03FhQUy0vfD2dZJzd70OmwO36EhOaVrWZl/wfw3Fi2OHxtuR2SD085X3PAT3MtY5vf1r7YRb1HoqfJMFlGCz+uFjOvNnw6KYdFahLLiN38sR6JhsAFEt/DcwmsyxKblUmjz5KwSgl/tfErDIa+9G5HsUXASqUtp2SzHt4P8= Received: from DB6P193CA0024.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::34) by DB6PR0802MB2501.eurprd08.prod.outlook.com (2603:10a6:4:a2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Thu, 3 Feb 2022 14:36:41 +0000 Received: from DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::8e) by DB6P193CA0024.outlook.office365.com (2603:10a6:6:29::34) 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:41 +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 DB5EUR03FT016.mail.protection.outlook.com (10.152.20.141) 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:41 +0000 Received: ("Tessian outbound 31aeb3346a45:v113"); Thu, 03 Feb 2022 14:36:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 69aa0c87b1b8f91a X-CR-MTA-TID: 64aa7808 Received: from b795a46e2754.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6CB74B8-F9EE-4659-8AF5-36E0B9E6ADE5.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 b795a46e2754.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=Uq8IgoK0PutlCej4b/2+YgjFsuIk3PLM9gtRlulu6ReVI2oGrfHEJc/EOzXfjw9IHsT73zMIW/lMi+kAejIkSPI6FKweHaNeaSkI8KejPTHqLO7VZxPQCerRYbck6/kUB6Fs2j5efPZYlwbo50KEOBdx28wh/Dpj4qh5bU0DC8cs8X3pujMCvEvVMC/nCXlqSsUzIKwgHsCR543fyspYoMweKw869NqZ8B879LdxV7zFUhaVBC1ovWKZcDOmfTR3pSbld7BKT25vznurTcKxEmx43gfTW+fTdd6l5PowaAVP1p/P5eBqzoMcufMPyJNWeGYnUV/P4DcP3uKdnrWoCQ== 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=LUoB+NdfYb5+9UmMMBLfBGN5SzGOEsh9NjPrPdqPYSE=; b=Vk+T0sNzuEACGTXY6ualeAaV9hpAHC6TK1ju93DB/ti0GbcX93wD9e939lUAQCTY66tXtR0vOVQmNXagIZYp+jW7kC4y868MXmbS9kGgCmuSMZ8DvyTCLiIcL57mQmMW669+2SqFCACo8Xlz6SxDnYSoMqSQOgLiTN+JPZ7S6fhSlFS8q7yM6GWvjZuuQP04CLSwWYxr3bzRHu+r6tab9LAihI+G1X0I33MmUyfcDCBQfXQM3WyMd4/aYmYSpf7UQQ+hNg9EjZjidR4iHwgjs4tl157kgkW8rZti79Ch70I3jpldhS6aMLzyCfSPaBrRVHMKpqoFBzUCuZyVbxcgAg== 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=LUoB+NdfYb5+9UmMMBLfBGN5SzGOEsh9NjPrPdqPYSE=; b=42dl03FhQUy0vfD2dZJzd70OmwO36EhOaVrWZl/wfw3Fi2OHxtuR2SD085X3PAT3MtY5vf1r7YRb1HoqfJMFlGCz+uFjOvNnw6KYdFahLLiN38sR6JhsAFEt/DcwmsyxKblUmjz5KwSgl/tfErDIa+9G5HsUXASqUtp2SzHt4P8= Received: from DB6PR07CA0100.eurprd07.prod.outlook.com (2603:10a6:6:2c::14) by AM7PR08MB5446.eurprd08.prod.outlook.com (2603:10a6:20b:107::11) 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: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:32 +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; Thu, 3 Feb 2022 14:36:32 +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; Thu, 3 Feb 2022 14:36:29 +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:31 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v2 1/6] kselftest/arm64: mte: user_mem: introduce tag_offset and tag_len Date: Thu, 3 Feb 2022 14:36:15 +0000 Message-ID: <20220203143620.30629-2-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: b56458da-4766-4bc3-c0d0-08d9e722981d X-MS-TrafficTypeDiagnostic: AM7PR08MB5446:EE_|DB5EUR03FT016:EE_|DB6PR0802MB2501:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: R4rNu+NvMr8tODDWDwXnuJhnEx3so7VqvSLBESyrIJf5GK4aw/WTJDgVQWvwpwderIpaYJaAtlMC8oqidSzi6xugMDLjR4wu5LLLUDsDLgIHcCzW2HaWf3PxL2rktM7J6rAX7laUGrIydn9CGtZfn0GeDi2RmbBAn8CJPI0IfWy+f7jgRSVq7aaTaT54m+lZs/cLSt+bgQdZ9O8xa8VOg7/o8nBD5kfS54B/v+klYyx9U7sH6rTYdjDaXgTI6/6P5Xr2cZ8ATQqwvb+6Jcayj8ttncxnSCIiV7HahvIPTO23OheoNknkfoL2wtKMrcD2isw669e1cdxdGOvYau4MQutiOxYRb7BWgX6hzbjlQJw4tUWMjA5kke05E6f1E/waykDYf9JxduU+QZc1QNBthxm4BFeoJ8Rch+xRta/PWllLJ//wjfGqPaNJtxrW8AMwsvkVpIGFYI+K5fbvUqmmd9aNLq3EYFRUjdfMDKtb9Z3X4+E7IiKs0fUyYrrkOG+kOJHl41kkhmlTJF9zhco+ncQMojNHaWUuUB734Ux+WH+MrPvKbLM8CsyOf7sZR/AZ/oQa/GtZ/PI/g9ZLFOGDT30TXCjiYpC9qK624NwTiYkNH6BR4mPNvkd+ZlEFefGzXHCaS6dTmAx4VGSQKwPy5GZJfWs8T4R440cgHXlkXeaMUyrmKfk4tdRG48e+u3Qn+IacS3FvvS7NqNJCVKcxyA== 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)(82310400004)(83380400001)(2906002)(86362001)(47076005)(40460700003)(44832011)(81166007)(356005)(36860700001)(8936002)(8676002)(4326008)(70586007)(36756003)(7696005)(508600001)(6666004)(316002)(54906003)(6916009)(70206006)(26005)(186003)(1076003)(2616005)(336012)(426003)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5446 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b9ed837d-1e34-40d3-2a38-08d9e72292b8 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Yp5byF/BGxtoEpQ/z0lflkqeegMBTEnvRfk3+r/qeGKPjs238gNExbYY+KkWA6ojJxfTbYCB+QHCM7LhDT8O5PYOcp2+/clzOsG0O9Wq9Sx7c5b66/zXZT5sdxxjVcV/fokHguaItFPu4onRqLQtHBY3ickVeu9J8YTAtowiriER+2+f6OvjC/f5z1f7Ov9pyDBLcVJXVP8nlc99BFn2zFc750FoMav2wHsaqmLFOoBqVqitwGhZG08hUS4aRoeZ5+J4kVRsFMoqX9hvx2V3KaV5GVaQS2xTYNTN/XS9yyhIq5TbpvEVEpoWwUfybGvjSCqU1A7in4vErZFmpcqcEOOiFCL2AKRXrkoFQCVt3Uq54FY/ApQRxzTU6wNkL0fVNGqzyRJ51kUKkVoZd9QR940cnPIaycWoi/eOCZHfmYPK+xCjG3nsk1SZLUojRibOrZQXaZw/v42pCJVnyMCbJSRqTPfPPxC63+lr2337PZganBrY2eg4OBYESZksOzUBIbweX7WJuyjUanYF5GXT/Iexp3Jy554n2mqwZpEJfhukfy38gfvUpa2QlNPNpe/9X9JsVo88ibNi1IQuN1Sqp0ciJBPAVkyGDoInUAMrTxAgGHKyXi4IpmJIPusoEZ9la3YhF7uEBUEQ4zSQX03TNSKKzHmqPHNDsAFks7NhcdHVDpXOZEOqhwKR5Vi9vlo 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)(4326008)(81166007)(44832011)(6666004)(107886003)(5660300002)(7696005)(508600001)(8676002)(8936002)(2906002)(70206006)(82310400004)(70586007)(83380400001)(426003)(36756003)(186003)(6916009)(316002)(2616005)(86362001)(47076005)(1076003)(26005)(54906003)(336012)(40460700003)(36860700001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:41.6552 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b56458da-4766-4bc3-c0d0-08d9e722981d 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: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0802MB2501 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063646_521213_16A7DAC3 X-CRM114-Status: GOOD ( 12.06 ) 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 These can be used to place a different tag not at a page size boundary. 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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 1de7a0abd0ae..5a5a7e1f5789 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -19,7 +19,8 @@ static size_t page_sz; -static int check_usermem_access_fault(int mem_type, int mode, int mapping) +static int check_usermem_access_fault(int mem_type, int mode, int mapping, + int tag_offset, int tag_len) { int fd, i, err; char val = 'A'; @@ -54,10 +55,12 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping) if (i < len) goto usermem_acc_err; - /* Tag the next half of memory with different value */ - ptr_next = (void *)((unsigned long)ptr + page_sz); + if (!tag_len) + tag_len = len - tag_offset; + /* Tag a part of memory with different value */ + ptr_next = (void *)((unsigned long)ptr + tag_offset); ptr_next = mte_insert_new_tag(ptr_next); - mte_set_tag_address_range(ptr_next, page_sz); + mte_set_tag_address_range(ptr_next, tag_len); lseek(fd, 0, 0); /* Copy from file into buffer with invalid tag */ @@ -100,14 +103,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), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0), "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), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0), "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), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0), "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), + evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0), "Check memory access from kernel in async mode, shared mapping and mmap memory\n"); mte_restore_setup(); 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); From patchwork Thu Feb 3 14:36: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: 12734238 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 4FD48C433EF for ; Thu, 3 Feb 2022 14:39:30 +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=BsMwqCMYm399Xyuvu6HfJOok1tlP0mBhtPlbkDhQi3Q=; b=IG169cni8di28B GyJSc4crDG+JwjMdSlgFvQfT8B6M/K9so1D7zG5LTWYQvaDuxvmmkfso1abSjkwNHAf2MfSqD7mM7 NSI8JLEllUGM7fDrJDV8dw+MCXoxc4W8D4u9qQ6SUQUDTp2I0/j9ir6mae9BzHlJycH7HIujCDhnu WR5CGypVkZtrsVB6KRsVSbemmm0DarWQ2JicQHHwR1Vlv1ek0DfS1AZf194Lrha0/4JItE0ZtDvx3 0mTkTwEQeVZ79dW69AyIqUeyz1/UiPcnoCwUk5YrQxGEM3A+GRvTs+9CyswwaWBguqD4cELgG71m8 K1ZpfP9QnnnYcEvUqHfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEv-001eAB-Bh; Thu, 03 Feb 2022 14:37:38 +0000 Received: from mail-eopbgr50050.outbound.protection.outlook.com ([40.107.5.50] helo=EUR03-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdED-001dxF-47 for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:36:55 +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=7/UNaQFR7Da7ds1vHyvVOHbNerkFvOHS8Myo1vQOinU=; b=uhEa6ImL+724dv3awfFARwM99EUw3dbVmVONrjdLQ4tzCWNXgn4iFJDSkiw6WxGQs586w29G3DbIYAVyXQ9wxo3t41rmgcSEheEEG4p5dyNvG2erg+PfD7tEb3d/jBj/p0lSLUuWSh4vRq4tXO3iA6eoHgh7aVi5HHy6SyxIRfU= Received: from DB6P193CA0019.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::29) by AM9PR08MB7031.eurprd08.prod.outlook.com (2603:10a6:20b:41d::8) 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 DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::57) by DB6P193CA0019.outlook.office365.com (2603:10a6:6:29::29) 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 DB5EUR03FT016.mail.protection.outlook.com (10.152.20.141) 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 31aeb3346a45:v113"); Thu, 03 Feb 2022 14:36:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 929cfffc6c733a40 X-CR-MTA-TID: 64aa7808 Received: from 5a5037bb5044.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8DF51FB9-A075-4265-9BF8-4A9D8AEE5E53.1; Thu, 03 Feb 2022 14:36:33 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5a5037bb5044.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yhz3Dl8ENy5ME1iX/oBtQ/WpQkwPndVp7X9a4zt9MFkjwu1m+ZN5vZv0TySRgP3b64jjma/NOmkbNi3Di+5PJzTMCwfn4reJo3Zrl7InrZhFz1aS2iMd9jDT2LXZGA9d7yQHXxG4xstY61m0z+NIqik9QkOUtUdzt5q06YsoUKxl2RpA7PtQmDrrwDtw9BILsmy/bJnqPP5Pol0gPFTWLR9XtodraeOd0pehBWZja8+K2ItdQSAe5+EQnLF539ZIyiqensQOj71ITkHUU4T+VY69elKaxNsujK/QEz+jM/4xZfN/c+1SqRPrYn6WaZxPttxgo43ep3kXUMvXJBsgAg== 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=7/UNaQFR7Da7ds1vHyvVOHbNerkFvOHS8Myo1vQOinU=; b=k6R2l/kRTzjfoe8+lhJ9i8hp+6IsxaAHscKlA0ZjWMJIifxu+Za8ChCNQF+GzaMmSIDEKofwP7hE74wje5N2yu27vNK010NR7FyUG4fU3aHNGKlHllubSARwjwQQb6gGGm4Ra3aHreXG7DYSs5rcbCc92uS39TMBSVa1NjVtttlg+2oqYLvI2Z56JEdPdn0rswhrSv92dRhrOer0+1prx32yIGtNcnKWjWNz7WwTzMJKLMcnn64Io/JGBzCuc7wOdGAUt5a25SfdXjeIjKHtn0SdQZw4jk8NZgn5ORiSAHqqZIkwA6KjlnT/3FBHiPIgxoudyKFK6squ0PbLjAK7nA== 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=7/UNaQFR7Da7ds1vHyvVOHbNerkFvOHS8Myo1vQOinU=; b=uhEa6ImL+724dv3awfFARwM99EUw3dbVmVONrjdLQ4tzCWNXgn4iFJDSkiw6WxGQs586w29G3DbIYAVyXQ9wxo3t41rmgcSEheEEG4p5dyNvG2erg+PfD7tEb3d/jBj/p0lSLUuWSh4vRq4tXO3iA6eoHgh7aVi5HHy6SyxIRfU= Received: from AM6PR08CA0013.eurprd08.prod.outlook.com (2603:10a6:20b:b2::25) by GV1PR08MB7347.eurprd08.prod.outlook.com (2603:10a6:150:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.11; Thu, 3 Feb 2022 14:36:31 +0000 Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::f0) by AM6PR08CA0013.outlook.office365.com (2603:10a6:20b:b2::25) 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:31 +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 AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) 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-EX03.Arm.com (10.251.24.31) 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 3/6] kselftest/arm64: mte: user_mem: check different offsets and sizes Date: Thu, 3 Feb 2022 14:36:17 +0000 Message-ID: <20220203143620.30629-4-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: 5971f84e-a5ca-4081-e432-08d9e72299f3 X-MS-TrafficTypeDiagnostic: GV1PR08MB7347:EE_|DB5EUR03FT016:EE_|AM9PR08MB7031: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: 0ZK6YDIw73OnJhrwQczBv8aCGxFwmHQe0W+nt4xWZ9Ss9OFwZbPGB5hzM61esQdULW3OY6/NdN/2r79OIH6vaTQSU+x1SbJuigRwfwZx2fTzAEoJpoSQPM+7TrSizXRAs1K6M57TST9U5HNUWMCV6TNOKBor0DZLX1Z1NDc5WZmx9bQdeU/OKNjBwr4xzgOZJsppaFv++28W+QbjsKkwqZo2bBixvVuysrZdfigaSrXIhoQU+S2CvvH1uP891SA1O/QKbWxlDyyJ1QmSB1/wPd7ypsZY8Hh0iV1BddzZrX7y3Ooo7CJm2s1qcrMRNJ+UFN2v6Nxa4RXInmAefhp4YFQNEH2kwL3MiZuHOMTxwmbE/UkEr1aXdrNl+6M3SHxWrbjgMpV4eF9kzfcLquFV5O3UltLfBewaulrCcel93RNtdvmSwyUmE424VDueIMEwTDTN/Et/Dl5R9oyRFqQcB9DWELK8i4Bi461/aWaQIbhP0+APA1PGRRfw1Xsxt6LR3TdHk31MorM4/GIxpgiMKyk/jJ2GBFuPs/b/u9zRGha/NekPgmqAWpa83qLW/ekgsy/+ZSUseSChU+VKCxmX2iw2HtRQRO9nxVbq/jK23F9sUx18e3DNxMs14TJa5CjmtE+95cJSmA1/yWdHgWaAGgbgbEXa/0uSoPmpm1KvTDuUKCT3Fw/oARDc3/Sg3WouFwZs040N+e9EXnLVsjPVKw== 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)(46966006)(40470700004)(86362001)(6916009)(5660300002)(2906002)(8676002)(44832011)(316002)(54906003)(70586007)(4326008)(70206006)(8936002)(508600001)(6666004)(426003)(81166007)(2616005)(7696005)(1076003)(336012)(82310400004)(356005)(36860700001)(186003)(26005)(47076005)(36756003)(40460700003)(83380400001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7347 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 730c3e0d-8069-4827-b998-08d9e722922c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TwWUBaVuDKWwFnhST4yLN4vF5AjaezDZb3CytAMZjjrAiOaMfb7z/6lkgKjmVShfgsdYtKHz/6k6gXGhcjuxYludFuHn2KvEE/QkibXAvRvGJ+qKnYW57CkjcYCg1U/0rIqDrqak1JN7RIjViXZOJI+3h59nNFkD8CCOEL/cgYRjmFHyNAj/+JLm0tKnlYPcqMeiYBE4e4uxF4vC59jTLQ5WakdN9Dgj5Rr/55A+XD5Y1XH7w5xGWobySq1BYTZ8VciZOnRPAbnyH7vlIt6I7EInGBRMerb8qqayV5nU/V4djCrVZeTI8pNsYxPVHBNqOujJ1v+a9rGTPU6b6kTwWWQtSUUO0AMzLJD8sS/cQnq0ZMWBuWZzIQuO3z6KRUUCUMnKc1R+Ahjhk2TWWCtsJrb7rqO3FKMNiRAT6Uhn8eGleT8pWBq7OlEO4c1N9hCLODDATfX3XzdqMsrr+IOTldloNezieWx9NFamT9TjA5PP7VIXRrk+pbKPPXn6lgIPML4O1FRvGZaPXaCu0GXxAzhGOMtQmQNXGe5iT6LZoGUNwGQ09CIWQxqSJv+/rS+O3tZ8iBUsQVNrcifwgedWV3ilyOi51u/444btVV4kkM5V/tnKt8a4fAqBvefmyuR2WrXcVWhYt2PAGVVAhB4fqGzeO13bORPvnUUzH+qu5koecI8tXJ6cIqA5IffJU4zz 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)(70206006)(6666004)(83380400001)(8936002)(2616005)(2906002)(70586007)(40460700003)(44832011)(4326008)(8676002)(82310400004)(107886003)(7696005)(26005)(336012)(186003)(36860700001)(1076003)(316002)(508600001)(6916009)(54906003)(5660300002)(47076005)(426003)(36756003)(86362001)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:44.7367 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5971f84e-a5ca-4081-e432-08d9e72299f3 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: DB5EUR03FT016.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB7031 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063653_223710_3FC9ABE2 X-CRM114-Status: GOOD ( 15.00 ) 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 Iterate over different file offsets, pointer offsets and buffer sizes to exercise and test different behaviour. 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 | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index e5bfeaeb64bb..35061ae23ed5 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -26,6 +26,8 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, char val = 'A'; size_t len, read_len; void *ptr, *ptr_next; + int fileoff, ptroff, size; + int sizes[] = {1, 2, 3, 8, 16, 32, 4096, page_sz}; err = KSFT_PASS; len = 2 * page_sz; @@ -66,26 +68,33 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, ptr_next = mte_insert_new_tag(ptr_next); mte_set_tag_address_range(ptr_next, tag_len); - lseek(fd, 0, 0); - /* Copy from file into buffer with invalid tag */ - read_len = read(fd, ptr, len); - mte_wait_after_trig(); - /* - * Accessing user memory in kernel with invalid tag should fail in sync - * mode without fault but may not fail in async mode as per the - * implemented MTE userspace support in Arm64 kernel. - */ - 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; + for (fileoff = 0; fileoff < 16; fileoff++) { + for (ptroff = 0; ptroff < 16; ptroff++) { + 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); + mte_wait_after_trig(); + /* + * Accessing user memory in kernel with invalid tag should fail in sync + * mode without fault but may not fail in async mode as per the + * implemented MTE userspace support in Arm64 kernel. + */ + 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 == size) { + /* test passed */ + } else { + err = KSFT_FAIL; + goto usermem_acc_err; + } + } + } } usermem_acc_err: mte_free_memory((void *)ptr, len, mem_type, true); From patchwork Thu Feb 3 14:36:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734237 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 3ABE3C433F5 for ; Thu, 3 Feb 2022 14:39:05 +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=3nzzK9rb9O/yrseHtBJUWgCT2ORY3g2AuSuNMKcn4E4=; b=lDJQ3wC7HL1OB4 5inM8U7Y5Hu8aLt6lrkSXUKwYD+ifOJkWJvaguT94eKBr7YGrMOZUa7QfbRJ5LnfyPnOz8KZf9sBS RGowVfN2n83IK5JbCMo6DerIVDyLIqwhXh6rzKK2td58rx/QW781vzD7SQoTj37+rwd0ND6j1L4G+ Q4B/UL7SNhfFrQNKd2+1IuSu4S/kg8g38eDP9jVijEtfOInSo4lA5PT61wrlVEE1mDahFFmj6RDTw 9g3ZF4Ocmh7NYjEMFt4vNDdPeKYkqzucwlMYH8FfgHa6xuqstVAE/fzqxFdbgqs9ItEAyLvJuNg+e K3HOqQ8A+ZEM2JDR073w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEe-001e58-Bm; Thu, 03 Feb 2022 14:37:20 +0000 Received: from mail-db3eur04on0612.outbound.protection.outlook.com ([2a01:111:f400:fe0c::612] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEB-001dwZ-4Y for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:36: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=QEbd6YbDY0c22G/n4D6CAxOgc6iW26+poXDHwjL0WnA=; b=dODTcwEPcNulgnQrno8dbNOXfkhyPB9bk2djxjyfbHQsQqSkBQ43MFmJEkgNrb/00VWm3Dr413IWClYSuN0MDh/S6i8CmM/utGiWUW96D1uIv86AvopWov4YpLuTvglAyGPALYijZAMGZ24ckE+NYmYnLhFptP7od2jhJh/RNmY= Received: from AS9PR05CA0021.eurprd05.prod.outlook.com (2603:10a6:20b:488::17) by AM6PR08MB3078.eurprd08.prod.outlook.com (2603:10a6:209:46::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:47 +0000 Received: from VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:488:cafe::47) by AS9PR05CA0021.outlook.office365.com (2603:10a6:20b:488::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22 via Frontend Transport; Thu, 3 Feb 2022 14:36:47 +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 VE1EUR03FT033.mail.protection.outlook.com (10.152.18.147) 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:46 +0000 Received: ("Tessian outbound 1f399c739551:v113"); Thu, 03 Feb 2022 14:36:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 78266317df00b46e X-CR-MTA-TID: 64aa7808 Received: from 7633e837fe14.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ADBEB308-5541-4378-A2AA-4E64C433E72F.1; Thu, 03 Feb 2022 14:36:39 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7633e837fe14.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KWTcomzZHJ8ATIWKVf2KUwEQk9I90neAtaS8oagxcGlJjV4wl6eqfxByaOvyLWZuP2LVduz07SkZLdAI4mJ4V8RO2YRUXLvjeI0cH9tJGtDMQUj78v2/ocXXoG/VixYDhi3VAIm9rL672ytApHftlEqOah+eXdhDvNvBCfvxoySZManwCZqNTDStPKwh3L0b/aYt9G3w+FSmuRktaMtBCs0sxh8d2dEeRRPgJiK21sC2vbIALgx/jlrfZoG6M0TP2A15Kxuv54TmDvfS2p3Z5wXxjcSj17yPUWcGtGdvjs443KCw366jOpapPs9Cop2z0OSL9HeXXDm5L6fGrclCbw== 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=QEbd6YbDY0c22G/n4D6CAxOgc6iW26+poXDHwjL0WnA=; b=Yce0YkoOzUTRM/QC2XFydOuQsGGfoQDWWwsdryI7roII068XDku6mfyl2uLwJKPhto6pEenNWFWc5gNeHRY6v6F8F43H2gsFYqIvRXEQjMtrFZnBLm+DfjufNbNSqu+4Spqfomufk9UGIG8/AOa+26iJzmbS6BHqge/hK06vzB4JfS3wGOz3XbCYTSeDY2ssHOMi68XPippfnkqkG526hMbDKoH34NVOBPUMlJCFuOVhrLWakIHueyAr22r+d3yabtoBg6f5IuWiu65Y3CUmIpmaDO0lXK9EWo7oJTGJVVWv7WFYcYixHnTC3GykKOyCKloYjYaIac503fFTJgeCpA== 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=QEbd6YbDY0c22G/n4D6CAxOgc6iW26+poXDHwjL0WnA=; b=dODTcwEPcNulgnQrno8dbNOXfkhyPB9bk2djxjyfbHQsQqSkBQ43MFmJEkgNrb/00VWm3Dr413IWClYSuN0MDh/S6i8CmM/utGiWUW96D1uIv86AvopWov4YpLuTvglAyGPALYijZAMGZ24ckE+NYmYnLhFptP7od2jhJh/RNmY= Received: from AM6PR08CA0008.eurprd08.prod.outlook.com (2603:10a6:20b:b2::20) by PAXPR08MB6717.eurprd08.prod.outlook.com (2603:10a6:102:131::15) 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:37 +0000 Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::b3) by AM6PR08CA0008.outlook.office365.com (2603:10a6:20b:b2::20) 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:37 +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 AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) 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:37 +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; Thu, 3 Feb 2022 14:36:33 +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; Thu, 3 Feb 2022 14:36:30 +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 4/6] kselftest/arm64: mte: user_mem: add test type enum Date: Thu, 3 Feb 2022 14:36:18 +0000 Message-ID: <20220203143620.30629-5-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: 8eb832d4-0bbf-4b9a-8544-08d9e7229b3d X-MS-TrafficTypeDiagnostic: PAXPR08MB6717:EE_|VE1EUR03FT033:EE_|AM6PR08MB3078:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WdZ3eGNN3+nQGp8DLg4MhEuhYPvvWg33nVNnTejOHnxVUEwU1fBEPlDX1B8RVog8gchsATmhFjkewj4X5ZTPi6+NSnYhQIWddwN0FcT8o9CbKlxHOU3nVsle+z2/UKCvJakCXDSpplOqBP/k1CyoTdJyIYAMIgW2tvBuGjN8VtJ6oRrNLS2kaUnRtLYA6YeI1MJNXg+oZMn/ubLDh9hy5BV0oIUohPcH9Em6g2kU6BsJIk7/H/4gOzumFaSZY0dcJ8QGMHWtft8O+iBt2FAy0qemvJ46fBUZ+qZEwakSwAyAn5T1BywSiKGTNYBZalKocmgmQNcNCbx3/qndBbHeE24Fk1cD977PlyP2Iei3XAwQ6muJocn727Ag3cazCZy5MgWqD/pJtIuouRIaDwMXd63z0kZ2Dl3ta2CJprGi5w+M9DRh7qgfOoono1kPzjip9LuWNCqE1qAuNa9VK6R9SfXUiaqUnTqJXROxrNA7Y7+Jx/pfsiE57bFY1MWXlhFuuFKaw0iuP92rO4W/jVw1QfHc/+dYO1xj0WGneZmjZFGRxmvL61jBPftj98Sgxsq5PaKrY39TaGSnkrVvwiBC42A0pXPJ4W6oBbT8eTH98dZcnr4ryv+sgcunrkbFEzgTUsTf8+I6z+mNrkwEllt/GqUCWWiO3jJegVz5/GfRmHxBqBZENLwZMlj8h6uw2EODP+P6xXU3L4NdWzSMMS0SCw== 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)(5660300002)(426003)(186003)(82310400004)(83380400001)(7696005)(36860700001)(336012)(26005)(44832011)(47076005)(2906002)(1076003)(2616005)(81166007)(6916009)(54906003)(86362001)(70586007)(70206006)(4326008)(356005)(508600001)(8936002)(316002)(6666004)(8676002)(40460700003)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6717 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: dc50ec99-885b-4c9c-665b-08d9e722959c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0Z2n1bkU0di70GpIFIpiN0OvvJGO8rNpnITnbb65eUJFW4HwM3pE/bOqJFLDo620blPo/0SvZZzkaN3dLwndnHSMTnfgv13CAk5jSvHfIHkoRz5AmikXn9azUu+7vaOuWLQLFJZgh4BDqAzNw7+JPeI4UT5p9iB56CFI/4IOBzGpqgi+FIdtcnhhA3V2bNXFiXxBqkwG/8CyuV1riSHXEaqRpEAS/FG2WWTnK+/57wuagM2Lc9U5ukK0UY14JjZZpQG6talBVg3ca/3sGQsocjUwxSUZuzwOOpfr8hqS1Pe5w8uMdV0bDWTmKatkZbFeFNlSkk7rijz6Ey93zYik+6YZM7NVAzy4dRDKUyvx2+ueY1cvcb547XwN4qg8EFHSLNdiq22VurY/zttcX0BF0NuXjBH6TjsMes6vvnKYRzlhbo1kuoheaLYcasFuzOeAvFAmzowzYk16j6BcDl/n7w/ZXkhhUaMxaASnO5tTfvp50NXeas/tS/1abJoHNq3zuyMgCV2viO/0vvG+C+OBhI9YO1Ph2hw8bFf8ouf7iJO9oFlGpLA8tS4On5Nl4BEOdpQ+3+65sifwd7Nj/FbBdnLZ5Yt0Jcy/Jg9xaK7D/OdbZy9n8uGRb9FnsF2JTcAZmd64SK0k8YeP5kyEE0VsFdycdG0ik1ie1TQ91XMphmgk023sL5GB+EBp032ypNNx 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)(81166007)(316002)(40460700003)(4326008)(86362001)(47076005)(36860700001)(83380400001)(82310400004)(2616005)(26005)(8936002)(508600001)(7696005)(6666004)(8676002)(36756003)(2906002)(1076003)(54906003)(426003)(336012)(107886003)(186003)(6916009)(5660300002)(70206006)(70586007)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:46.7946 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8eb832d4-0bbf-4b9a-8544-08d9e7229b3d 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: VE1EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3078 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063651_352613_DFE397CF X-CRM114-Status: GOOD ( 15.25 ) 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 enum will be used to parameterise the test to perform other syscalls than 'read'. 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 | 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 35061ae23ed5..6d4aeb14027b 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) { err = KSFT_FAIL; goto usermem_acc_err; } @@ -73,8 +79,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 @@ -85,9 +99,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, err = KSFT_FAIL; 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 { err = KSFT_FAIL; @@ -121,14 +135,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 Thu Feb 3 14:36:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734241 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 C0FABC433F5 for ; Thu, 3 Feb 2022 14:41:33 +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=3mmGu9Sfo3CP+yl0JI3Mr8kFnZO2UXbqROZdDaXYY+o=; b=TaLLUXC44jg/0n sWZ8Kd/wyZuJafS13YjlPSu21fsuVmzI7RnZlwDGF+nBbWHlpejvfomCeY521vMlj8vQ6Y6yizh1s hBoE8KLIIKHIfQYuNGau7MIHElad0Ch5AwcznlJWqSKS2Tm8VX5Misa6BjJ5zR3TMQby0zQ4/GJ4n zjktn1OZov+cJWJm4nTFvR/8PoUJ8EA8LGLfMulIWgs9ByvG48/T5GWF/S07r+1FToVSHpoZdOrch 3yTiAOos9OSUmvZjEu6v0Ruc+T7pSNhdZAAMVr5RvGs3EsNujiHbP9Le/vQ1vN3JSFUGteENFT0uv l9p56VeNh8cyruG8DxwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdGm-001erE-Pa; Thu, 03 Feb 2022 14:39:36 +0000 Received: from mail-vi1eur05on2057.outbound.protection.outlook.com ([40.107.21.57] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEK-001dz7-N6 for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:37:02 +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=+A+YaFUtTbKA4wC6CFhD5JfIeW6mEUyAs6nLmr98KvQ=; b=8tFu2gPuMknn2je0bA2BWc/cpQTPUnIkxyIKY+kw4lfP4vkSOh/sUl+BqtNba+o43DbgMPqnWOyC7tsFfe7Zf18qT6q4Osz5HJ35lKxZJDm6HUCY6dz619nD6Gh6PysXOr7SBt6C6ThKM13MQ65IjH3GCrNJFVSr9esgdnz1VnE= Received: from AM3PR07CA0092.eurprd07.prod.outlook.com (2603:10a6:207:6::26) by VI1PR08MB4079.eurprd08.prod.outlook.com (2603:10a6:803:e4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 3 Feb 2022 14:36:56 +0000 Received: from AM5EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:207:6:cafe::e7) by AM3PR07CA0092.outlook.office365.com (2603:10a6:207:6::26) 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:56 +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 AM5EUR03FT009.mail.protection.outlook.com (10.152.16.110) 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:56 +0000 Received: ("Tessian outbound 341d209a0e52:v113"); Thu, 03 Feb 2022 14:36:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9ab38ae07b9cfccd X-CR-MTA-TID: 64aa7808 Received: from 308d2697568c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2679B3FB-F5CE-4775-9399-6399ACF3BD7A.1; Thu, 03 Feb 2022 14:36:46 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 308d2697568c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ffyonNuVz4MqmasS5O/SmnF+XXj4BTDJOrXXki9KGIFVo2VzfgOQPi7iee+TOKE2Z+zPGuU48Q4n4RyOL71uqFo171K//HipLyhZlr4B0hBMtbRmMM/QjSeFSlvzdBmQO7LpZTjWr11r/w7cXIQMO/I05iOhgn8U2RP3q3tOhevpxrJpEPrXu7Xqc+znbsZJZZsOdu7TBPWhJ4pnI5frL/tgNouKJR4UKqj57oku1YC5Q0r24w71SHl8FjF9uNYl+LR84SLe49GXGScLwsIAxRcVIXLz4Hi0QAaf5y0SG6zhN8pUeuQw68uHwRdiP97Q59JtsMBJ/iaBaAsCmbjJbA== 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=+A+YaFUtTbKA4wC6CFhD5JfIeW6mEUyAs6nLmr98KvQ=; b=Nub4V58QdTd4TQAla78zzf2cWTaNXV7EXo0aeDyaGB8/Af+NB/t4QffKkcOLDc+jx+EXv4gOSkvcRN6sBXBIepn61MIo0toJOZJ2YjBaLpAfgtGD3MdZGAEC6FxRbmWtq3ExIL3XM7txaXuo4Z1Y6vW9F6mkIzcz4l0NT/T80wwVm9eQjr3nrBfQ5mD398KwvNzlj2ENVydyWqDXeLdyzVshdgtN8Z8qvFhylvJakhnWvr571EfyPqVdEh15SnLKBpKNqyQGhC76zRFytu7Elz5KO2+szU9UIRK/Q9DodptAu8qewSLNypad05Dttkgb2z6ErydTOABY0glfu2iveg== 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=+A+YaFUtTbKA4wC6CFhD5JfIeW6mEUyAs6nLmr98KvQ=; b=8tFu2gPuMknn2je0bA2BWc/cpQTPUnIkxyIKY+kw4lfP4vkSOh/sUl+BqtNba+o43DbgMPqnWOyC7tsFfe7Zf18qT6q4Osz5HJ35lKxZJDm6HUCY6dz619nD6Gh6PysXOr7SBt6C6ThKM13MQ65IjH3GCrNJFVSr9esgdnz1VnE= Received: from AM6PR08CA0005.eurprd08.prod.outlook.com (2603:10a6:20b:b2::17) by VI1PR08MB3375.eurprd08.prod.outlook.com (2603:10a6:803:87::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.20; Thu, 3 Feb 2022 14:36:33 +0000 Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::22) by AM6PR08CA0005.outlook.office365.com (2603:10a6:20b:b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 3 Feb 2022 14:36:33 +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 AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) 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:33 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:33 +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:33 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v2 5/6] kselftest/arm64: mte: user_mem: add more test types Date: Thu, 3 Feb 2022 14:36:19 +0000 Message-ID: <20220203143620.30629-6-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: 6d8bee01-b12a-4234-0fe5-08d9e722a0d2 X-MS-TrafficTypeDiagnostic: VI1PR08MB3375:EE_|AM5EUR03FT009:EE_|VI1PR08MB4079:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:1079;OLM:1079; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: +E4PPJ1Gexd/9aPVxEftTyV12IufxAwak1aEb2KUKTRjGUQZiL3PvZwx8PVeqGPxN+LfeytM5V70deOCibkR+PidNIv9Hg3HlEGx6f4DRPFxuSRKb9rkGyIrNjpRW+GmISlyHEntuNr5V4c6/rlP1+KIrlNqVEIa8jxWSsNzqZX4dsd//6O9TY1GL2uKVyQdvjl4rCdlpSO3gy1iFCsdmBXwZH8Dam1nitGdw2yvIA/NYm+liDWPjuMA8JgjxnBU0GpHyDIceoCRx14fj7rrvteacv2HeVIHHnB1lLR4CGNRVaaYqjCktYc+uF5KbAfE4/hXxnW8Vj6RwJayvymH2rkh6QH4tQRJZolfftLmEwQ1HjlnKVeVe8SA9Og+27XyZbeYaguWuqIfEfupHwASEx4GtFnAR1dbygTZ3JHcF1J6VEiYb+ZFr/5JuvL0XKG6N9m8jIdOXzeFnjC+LuNOUBuTnjzd4SlLjk2HiJS0BHfMQ329JGWyQX/WCPa78/3fW8ZD3ATSifgO4ncaaEj8DlpaduD03ve/y3xT0nwpuVGZw1RWvivTF+W5f/sbpHCx5f/tuEzrYHdHhMdulgExeC0hgaGyDcSyk2P1dJXtidQbhY0+If8z3ljQ1rG5SHzfDyKvVD7juLKGF8hD2uHAINB5oURTfn8U1jgQLV17R0gMRJHvl/kQxLO5rfwNz5nQOBeraxLN4GjHjDhoAN0wip6whRcbUPKl/Ot5Jost8Qh3To+K2yNocS2mibDsGdYo 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)(47076005)(83380400001)(36860700001)(2616005)(6916009)(36756003)(336012)(1076003)(186003)(26005)(426003)(508600001)(316002)(54906003)(8676002)(40460700003)(8936002)(5660300002)(4326008)(356005)(86362001)(7696005)(6666004)(82310400004)(70206006)(44832011)(70586007)(81166007)(2906002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3375 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 17edb797-d850-4a59-6a04-08d9e7229348 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mkxxWHHIUirqZYUwZDpnP6BVxtx48bcpCRPUSdtAhbLa6U6eURHQZlstrMi480zUU5SZEoYBYqIrG05AjIdfdPduCdAv/+VTVmcQBjyS88VlckFOH2b0/OWXbA3PdZM1wso3PiziHyuHvK1h85vHUm5S81g+EGXahPztnBmZ4R7eW/l2+70BPgWLhHJ0CN2wcnrg6B2n4VHdiCUQFvdKNsA2LdpSUOH6Jgt17EBMUjaNschXPgKTCAvqPnNVjgbDAmegtU3VmWk7qqN9pRXPkyN6FtADCsK4sj/by391xGU2KkChiZUHfEbAKwih9Lr/r8DxYVZ/sBmcb95Gdm9rPFnyLw/hb9c1uyFBgUDgkr6rn2fHddlF3r+gIrDY9DHE9+v/mGlPhtZt4qaEEZdsI/kRzYKS94PXtKPEzVpfXwH3tihrhDUudubKi0Q2y/ABaCEFVsPu1mNjG6tweIQ0UYPLcGtG2qEdHUIAOPfUaZnZAXr0799xJ5jdnCoTjCTlj6+LmHW24fu6DVZeoinU6U92z3xL0JfI/fvqFdctwKD8443tgXRigN8IiOBYooqOBGXjG2Ue7GHFhJ0eYxWXsaD/3PrmgptPtUyIx6Z3FLpSNo2xkD4XXasR/ixL6IyRuxNwXxTod7RqTVz16XULj7U0ftb9xUdZjuGO9I1dMoM= 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)(40470700004)(36840700001)(46966006)(8676002)(82310400004)(54906003)(6916009)(8936002)(6666004)(7696005)(508600001)(4326008)(40460700003)(86362001)(2616005)(70586007)(70206006)(107886003)(316002)(44832011)(36860700001)(426003)(83380400001)(81166007)(36756003)(336012)(47076005)(26005)(1076003)(186003)(5660300002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:56.2092 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d8bee01-b12a-4234-0fe5-08d9e722a0d2 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: AM5EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4079 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063700_784544_BC5BD223 X-CRM114-Status: GOOD ( 10.15 ) 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 Add test support for write, readv, and writev. 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 | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 6d4aeb14027b..c128bfa81502 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "kselftest.h" @@ -21,6 +22,9 @@ static size_t page_sz; enum test_type { READ_TEST, + WRITE_TEST, + READV_TEST, + WRITEV_TEST, LAST_TEST, }; @@ -85,6 +89,23 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, case READ_TEST: syscall_len = read(fd, ptr + ptroff, size); break; + case WRITE_TEST: + syscall_len = write(fd, ptr + ptroff, size); + break; + case READV_TEST: { + struct iovec iov[1]; + iov[0].iov_base = ptr + ptroff; + iov[0].iov_len = size; + syscall_len = readv(fd, iov, 1); + break; + } + case WRITEV_TEST: { + struct iovec iov[1]; + iov[0].iov_base = ptr + ptroff; + iov[0].iov_len = size; + syscall_len = writev(fd, iov, 1); + break; + } case LAST_TEST: goto usermem_acc_err; } From patchwork Thu Feb 3 14:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734239 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 9E41EC433F5 for ; Thu, 3 Feb 2022 14:40:05 +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=wT0NzuSJT7PmRys65B5j/qV14dlA7ZNCeL4XgubFam8=; b=sNJPp2FpMPNswL lMI6b+bAaeUMMa27E/Pk63CWGpMTMTGL3jyHaTwNzeIj8xA6TaSwGPvxzYiMAqfvjmlLUlWAZ1meX dH0odxtNBw7CG/9acE8M5UeB76uE22zP4/yurneIM2ovmBACJQ8CcNLhMdrZ7umynleOsb5e/cl3a xGC/ZVya4lZZHjYcepEtip3T2b2EkGZ746utzOklehWdxNhmLelZt7AZrFDluWp3jIjUa+TT0rR+L cL+z48sRkJE+B2r52RAAaJ4c8DYNW+YtXFOh8gwVYULoM8b1ykCTSJ/Qv2XHQU/9LK+qhpAYF0YeQ pNKUcHBrvVJhStoAyzUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdFP-001eJs-Mu; Thu, 03 Feb 2022 14:38:08 +0000 Received: from mail-vi1eur05on2042.outbound.protection.outlook.com ([40.107.21.42] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEI-001dyx-HH 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=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=OJI+o03xMr2F25ghxUB59FNJdmz2RYTe84P2wJ650kt1q3WLoe+Cyi9wUVokMmacqh7/Sc/M/cXDa7jNNl91qu8mu+lV1eg83cTKpmmX9x6braQt0MF9mjKgo/kmzOX7APc/Gq+sjBOZhQyO/twat/5qRXO+EvuF35klh4YBU1s= Received: from AS8PR04CA0147.eurprd04.prod.outlook.com (2603:10a6:20b:127::32) by AS8PR08MB6230.eurprd08.prod.outlook.com (2603:10a6:20b:29d::18) 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:55 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::75) by AS8PR04CA0147.outlook.office365.com (2603:10a6:20b:127::32) 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:55 +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 VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) 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:55 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Thu, 03 Feb 2022 14:36:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 423d894f5e3e9d8e X-CR-MTA-TID: 64aa7808 Received: from a055b9ddc5f1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0F9B40D0-0F66-4617-9D5A-99960424B853.1; Thu, 03 Feb 2022 14:36:48 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a055b9ddc5f1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i2RKt9PRgZUflB+h18UT/563qJwwPIH3vhiCchbSQMePvSyIEWJ7GiCBpZ+muORfAM+XLydNnGsQZQFo6AgQBrHEvVBURp8LDy8GJ3sqJ9U/3mmEunE2XQexvUUit0xOW1iHv/M2HR+b1dmlO7UXuDTnekoj8pznrCk83ucRK+qZY8Yq+6/QDJaXTUiSVx0JnZrhs1uy3gg3NM8bEy+x4BY32/rPfvQGUs1rhWopJ+M72JhFM8k9WCiYLGH8WD54t6EgT+M+rdJT/zAKqY/Y1P6B/OXiIstADwMH13ftTuOv8R70U6ViM6j+jcje66w2TPaprFet/PQA/LSJliTeHg== 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=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=Jq+stKYBQyJxnRr7A7+T2qG+kHR3Zvcv3/9adzT4WP6I4/6NpDALC0ZJ/C+9Zsaoy0reHGL7ULAeLgZc0g8EzEdtuyMEudsm/YQ1NK0mp1I+O488rGeToe8OmZU2Vpg+phYk8yRE33IV8lBPlGgamc3I04taWjXQEfVb2dZiQER4vjxXwNhSp+lgMowd3nkJ/HIGJBbaUd37W841PLtgMVaczMmPPVVCBZ5un/mmSZ1CGxNRrXARmtEHG76rCKk7N0j4+uSqoaunloSYZsyHqI7TxeoRaEDxoDoGi4Kjr5RIUQp7WbON8HXV9lEKEau+92ND439f+stXD3QPfloqfA== 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=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=OJI+o03xMr2F25ghxUB59FNJdmz2RYTe84P2wJ650kt1q3WLoe+Cyi9wUVokMmacqh7/Sc/M/cXDa7jNNl91qu8mu+lV1eg83cTKpmmX9x6braQt0MF9mjKgo/kmzOX7APc/Gq+sjBOZhQyO/twat/5qRXO+EvuF35klh4YBU1s= Received: from AM6PR08CA0005.eurprd08.prod.outlook.com (2603:10a6:20b:b2::17) by DB6PR08MB2933.eurprd08.prod.outlook.com (2603:10a6:6:1c::29) 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:38 +0000 Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::22) by AM6PR08CA0005.outlook.office365.com (2603:10a6:20b:b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 3 Feb 2022 14:36:38 +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 AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) 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:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:33 +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:33 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v2 6/6] kselftest/arm64: mte: user_mem: test more combinations of values Date: Thu, 3 Feb 2022 14:36:20 +0000 Message-ID: <20220203143620.30629-7-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: 9aa2522a-91fa-468d-fbda-08d9e722a042 X-MS-TrafficTypeDiagnostic: DB6PR08MB2933:EE_|VE1EUR03FT021:EE_|AS8PR08MB6230:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2201;OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AzcFAepNYvfHy95n2mBa2oBogx0JLFTSvLju4M0Md9P4Q+QmINHmTN39PRwBYYb3wV2yQAPdJPQmgvXfDQ5uTV8HcksrBAegZu7YegoXQ5CX2akjG9LshnlEgQO2k36zQbDY1FIIVxGrWtmgUDGIhBcf0gvHpyAxhwyPVp9BMmChIAgDR6FVbTmIwlq9GiWBavYKIS30cziR7xhhJbqRpQooj3rfB6u/Puj4Q0ohYgiAOUWo3Bfap4agJIBFEHftACDkSSeNh9rf9TvKhs1ll3hjCXGSq99xdPUEkUYJkyKvZN3QckGoAdNit5giCWu9bkPcCGL4auDtyrLERvu5psn/jCtAbN0dnkl1BY1wANU5ZhpoJvnr0HoIfYfNyaittHK1j4N0tGyhQ7f9bbChVUhABEiG+wRLUiCaxJjNWmtD2vuQ/8/UN5egKW0Cp9qOF0uanmijGipjAectxpuuk278HY89khmE47Zjp2FV2Bk3XZPdO5dDoKfK+NcE2iDy3aSY/8909895GdgvMK+HzOI3F8NiXKWVQ7L+8t06AblPXFUeL9ZEeb7H7vI39YltPd7z68deQhbLtRFCDE2grU5kObU2327LNCm77RmnPAvroM2o7kEHQkxBu/PvZwWkpYgX6hQY6+6qXqCzeLWv9bE/Ap3VDe11mR2QsnBvqAIhJbcOqeKBJr7v4QLBQbw1REofwjB3cbEiOkIWS+FQhg== 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)(316002)(1076003)(6916009)(186003)(508600001)(5660300002)(36860700001)(47076005)(86362001)(426003)(336012)(81166007)(36756003)(54906003)(70586007)(4326008)(8676002)(82310400004)(70206006)(6666004)(83380400001)(8936002)(44832011)(2616005)(7696005)(26005)(40460700003)(2906002)(356005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2933 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4ebc9c62-1a0d-4c7c-f45a-08d9e7229672 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ZvlyVXcd5EIGG4vo7o27WVo6JR0XwcXC4KPVmzrwz+NzupToDBkhhVLIhbyK11u3KFxzpkkBcha1gOZpq7S5crSbk4K/iunRnYzLLNHIBK4xBS8vSJw3336zAXx+5hW4UEatekStQL5I1UGJZfZlcVKlOwiyCj0jw0NMxXicYorPCy+4+nolrNwAchuThBjZDTeNeG8+C4V77tqqMnp5GMHisrqzII0zXWiqd09Vm8D9JdAS9Tpdg7syaHuno+Ca4OSkPyXjncTeGoAqqnuDMtijSabXuKa2GVw++qeDEfF/0kKzxpYU+RtXN2fB31rnmpVHkVNwZhkJJwxxhYAfVGbSyWjcxXEqtozkeqMsGTEZG8gtdHmMSDtL61l9RdAigOlZXksBCc1qOeXd+xs62MMhMJDezX1rPmFlqQ0FVMBIr4Dgow//jHem0HVOESbrZteP25c8mEJTGVMecvqZ9Nh9y5QbLXO/9Ew2d534WJo6CLJ+S3AVBE21ofxjm5PBg4kpOUwJK7WVCQ49ltBYmmyKEJd5p+/9Nj0xX00ib+q3EWwSD1cCtkAN81ZAaEms7N/leDn5OXVWUpXZFAspLrjS/21CzIfQK4iCJntI1Vu0GQQMb+YIZjqfD8q1CIoftcFeFzJ6/aWmKs2M0R9I3jLGY6TEPdKzgRT6bFskHMRelq7rgqPr+iz+kBxvV0i 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)(47076005)(86362001)(508600001)(70206006)(8936002)(70586007)(8676002)(4326008)(2616005)(83380400001)(1076003)(426003)(336012)(36860700001)(186003)(26005)(107886003)(82310400004)(6666004)(40460700003)(81166007)(2906002)(36756003)(54906003)(6916009)(316002)(5660300002)(7696005)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:55.2190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa2522a-91fa-468d-fbda-08d9e722a042 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: VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6230 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063658_645368_C64E6393 X-CRM114-Status: GOOD ( 12.45 ) 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 Expand the tests to cover more syscalls, tag offsets and tag lengths. 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 | 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 c128bfa81502..1aef855bf81a 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, @@ -137,9 +140,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) { @@ -154,17 +215,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();