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();