From patchwork Tue Jan 25 15:09: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: 12723953 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 15B22C433EF for ; Tue, 25 Jan 2022 15:23:39 +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=pGbV4c8bLpjNeLaSJpIuuiQXo/EtsgQIpN670aeSP0A=; b=VPh0quvS0Px47b APBG442eKir9VxAPiSZlflq18QkAyQ0vpbRM5aNcsrmO5nAvOU+O5HYCY6xwMDF0fr+3E0EhAqPmv Tq//C4eUi2WEuNpFxN4jQHynH54D9bvRKZRgyZElAqSTkfd1N0IYgmkivHcvynfQKsz8WmA6PWZM2 sAd9MISgTuXGgx4v93Ntf/EqH/S9eMddVSiP8JrApEqPKCUMeojAWRI8FtpUXIkHoLAPegaNTwUjZ O8E6AEqe9SJFc7atAqu4gUZR7VpO3WLphtW97xW4OQDUWDK9o+YKJPHVpyWNF6dJdeaivqRC9SxjE UtZpk07E+owkyBnK3cfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCNcy-008LvK-Ak; Tue, 25 Jan 2022 15:21:02 +0000 Received: from mail-vi1eur05on2068.outbound.protection.outlook.com ([40.107.21.68] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nCNS5-008IEf-TD for linux-arm-kernel@lists.infradead.org; Tue, 25 Jan 2022 15:09:50 +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=rtkOfjJPSAw2fJiTl86U5jpp+ihaR3Yu+Fenu5m+P5c=; b=3IQpQJlCncTBpTc4ba6gID0h6oCZzSFT12sTBucdC3G15PDbw76bqSn4WzC47J3wJ4zDmOtSpG0uXgjRQdS3MmW5usGREo4+xX5mQHlYu0wvS916HbZXnBk5v1Nnz4lqE9ZJiNuBZwumR7aqGO2HyRXVKGqQvt4ubefSSFYgZ2A= Received: from AS8PR04CA0088.eurprd04.prod.outlook.com (2603:10a6:20b:313::33) by AS8PR08MB6759.eurprd08.prod.outlook.com (2603:10a6:20b:395::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.10; Tue, 25 Jan 2022 15:09:40 +0000 Received: from AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:313:cafe::17) by AS8PR04CA0088.outlook.office365.com (2603:10a6:20b:313::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.17 via Frontend Transport; Tue, 25 Jan 2022 15:09:40 +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 AM5EUR03FT057.mail.protection.outlook.com (10.152.17.44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 15:09:40 +0000 Received: ("Tessian outbound 18e50a6f0513:v113"); Tue, 25 Jan 2022 15:09:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a12cb82f27904e3d X-CR-MTA-TID: 64aa7808 Received: from f9017ecfe735.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 69400553-1735-4CF8-BB72-97EC5EE6EA6C.1; Tue, 25 Jan 2022 15:09:34 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f9017ecfe735.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 25 Jan 2022 15:09:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/hH6RoimzQnnT3sNjL5P3nmXWCBVWXbLwdfgBLb0d8c7oHBnWRyNzQylTXSCB7BeilZUPRqFxK4Iy9cHCogOBHFrWmMe8XEV251mWHtcAqr04e1rUzoWdTeT+SMg+SfZt6o1FCLgHsJiLRvYdzIXaPUD6zepW4iB+UQKs4mmmcga99JECiwBkXbN5POKrX1RbJgB+yzyWZWBM2a0vZzYZWvDz2rr8lvaPF/nThIc3dZip+cZ9ypM+thKgii0rkYpcqNphpgalbHshYttVzMtLCjTxai+YU6m6Amzxx8U0hkp0Z+IViE8ZW/mym/9WJs0LZ/F5DisBU7E4nSzdCu3Q== 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=rtkOfjJPSAw2fJiTl86U5jpp+ihaR3Yu+Fenu5m+P5c=; b=RXywJXGD23BfM4UBF/nzNU7132HVXzf2+wr/ofsD+3ZtJHFqm8KC7rWEqjviaIGTtp54Ko19UgHqGfxS+hwdoBuZUbOCQ3Jw+Rnvesd1FNYhhiIpS9USELnMh9AN9exGBMenflCoEJPpKjDLQxUvAckRQo7cfdmLEXtnxvY4fixYlIjwfTK2JKSYfLaYCBkSvuu618Jd/Cq3CWL1l29+2+izKFZXXelLbvVBL/ya0OEZ1xe+HgbD5sb2aIudPv7SyDx+C0IO9XddOcrgryhG/C+70wLUwPiNUONEje+JMO64qxBeJNKrLLMtuPv/TPpLP3lmpbreudXQG+06jMnhXA== 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=rtkOfjJPSAw2fJiTl86U5jpp+ihaR3Yu+Fenu5m+P5c=; b=3IQpQJlCncTBpTc4ba6gID0h6oCZzSFT12sTBucdC3G15PDbw76bqSn4WzC47J3wJ4zDmOtSpG0uXgjRQdS3MmW5usGREo4+xX5mQHlYu0wvS916HbZXnBk5v1Nnz4lqE9ZJiNuBZwumR7aqGO2HyRXVKGqQvt4ubefSSFYgZ2A= Received: from DB8PR06CA0053.eurprd06.prod.outlook.com (2603:10a6:10:120::27) by PAXPR08MB7490.eurprd08.prod.outlook.com (2603:10a6:102:2b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.8; Tue, 25 Jan 2022 15:09:33 +0000 Received: from DB5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::f) by DB8PR06CA0053.outlook.office365.com (2603:10a6:10:120::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 15:09: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 DB5EUR03FT033.mail.protection.outlook.com (10.152.20.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4909.7 via Frontend Transport; Tue, 25 Jan 2022 15:09: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; Tue, 25 Jan 2022 15:09:27 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Tue, 25 Jan 2022 15:09:27 +0000 From: Joey Gouly To: CC: , , , , Subject: [PATCH v1 5/7] kselftest/arm64: mte: user_mem: check different offsets and sizes Date: Tue, 25 Jan 2022 15:09:18 +0000 Message-ID: <20220125150920.23955-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220125150920.23955-1-joey.gouly@arm.com> References: <20220125150920.23955-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 0d87b884-07fe-4d18-c0fd-08d9e014b611 X-MS-TrafficTypeDiagnostic: PAXPR08MB7490:EE_|AM5EUR03FT057:EE_|AS8PR08MB6759: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: ewtdZRuLQ7by7a/JvepHYtHV4qGHc+OJQWPx0CHh2+uBtmnWT8P4GNsFm0nG+cxP50/WZOE42V5WLMjiRMdI7BalcvSvaqdFbpd0x5iUiMg2o50zaCbdfVCm37lc0lJnqDUEMLNytYlKUDzVvLGQ7QSrTPrQCdhW03Tg4vhrMA8JJZktu+Wswzx0umnfMfUn0+TMKKik+H0Sw9Xw07LFXBpd9HOka0lQ+TxVFwfL03dbAJJBpZIRsC6KY/lRMv4oiQbHnKq0jq85GDfTLY8jY4Jl3DQx3k7NlsuP5/QsSkuCLCXW09j6xSQhYVlnlSFqrxQ2dO9AEEw6C6dx1ZsErvDEbhDFFhgZeFf6dY6nbKXcBgXWVAxJl6/O3YgYVB1ax94YdQldLG3UEMSW8CaeuGIl2T3t2Zo0pEAykMIqDrEfyXnBxDa9APGllLW4J8A8LlWjjK9inIXMJlOT5IKM9Tf9UoVoqGuzrfAzL2Ou2nU7yXUAFIidVNwUQcpqWMc64OV1DbyOklWIkASL0BH8xRTF3cNNPKYHxRXXWtpoGHV57QaG9YAlns4TbQN++GaxJ2sVdapxHChw5bjRKjKvIkbRt3/OJMzd4SWZNw9gqP5gWO0E53Dfd8V3vOLFQrtwaFay2VX+q0zHTBOaw+tA6JHgAwDybhlnsDoXoz05b3Yb6FC+TgBPm0XodkcLpMl1svxmwduBXZn7o036lrLZvFYkYQAO4thonldlKIdYtg6H19phdBSpRLI6HYrLiaj+uT2QBMl7wJTfBT0uUx7Zpa0BBRMDEYQbq1WfWhfWQ5Y= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(4636009)(46966006)(40470700004)(36840700001)(1076003)(6666004)(2906002)(83380400001)(186003)(40460700003)(47076005)(336012)(2616005)(6916009)(81166007)(8936002)(4326008)(54906003)(44832011)(356005)(82310400004)(8676002)(26005)(7696005)(36860700001)(70586007)(5660300002)(426003)(86362001)(508600001)(70206006)(36756003)(316002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7490 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b2116992-c7d8-483e-232c-08d9e014b16c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9GpV63amuC1IethV5PGnG9tIHE3m4wpB31GygzanuacvN4sG1FV1CqVzox8HqJtFBnagBfjGtZzNN+IgwS/rxpDfr+Ax2AxVjBHrO14z8pywU0SlO9lZ3TQTmuVQJcDQYwWqC/PJp9gZnY68znCISiaCVisD7LlFz9JeJmfgsxyc6CL41tlKFaHzdu1w+sCNKcYI8nJORKSXZLnInPm74PthQFdtYgF1A+Z1WIOHEE0JSl0jHO8eYQ218CJ2D9V5cPwuRtHn6MBRoUcxLBsyeMIh13jvmVYVhQosiytRunlmsYBwr0ahKDuBgOIQdevFsxI6O8mN+cK5sokTbfO1l0fSJQ92QBpUJQw/GNBN2XrG0NaZhxJO6WhFS1W4S/LEO1I/+GVCmTdGF9MlXKKBoqPrfESVZb9+rMQ9Lzy2ySjLCUPr5mxZyGGM9bJWf9FumfxQkTN7NZ1/nDYWCr152h8DJ+BOc5yO5oJnP2JuAvmscJpQCGBrOn+C94l1SYY9HDUaH+QGyYYluIIhyn4/ZG+hh/UzkAHxBBUSGRwo4Dp6AzT1nR7qwP47VQ7mL0jNXCeAxnI9Du8ojqGvtvySw2ziWvVUHWM7pSq2HjLkClSoxEjKuPjXTXkUsrFpfkoeQArhCyIo6sZDSiQPYPXm4wzI4k63Yk+u9ZrijIFjvu9N2Z2kg20ZzOsSMjXWD1Q5IfTcvZxhu7SsTJBxlt4T6j2ou87Yj9W8C/TG2Y+y5I/B/5LQdLKJ9Mt7Vu9/VvHyKqnKgD5Vgw/rqhM89Tf9Eg== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(4636009)(40470700004)(36840700001)(46966006)(1076003)(426003)(4326008)(8936002)(70206006)(2906002)(2616005)(7696005)(8676002)(44832011)(26005)(186003)(40460700003)(508600001)(54906003)(336012)(107886003)(86362001)(6666004)(36860700001)(5660300002)(316002)(70586007)(6916009)(47076005)(36756003)(83380400001)(82310400004)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2022 15:09:40.7595 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0d87b884-07fe-4d18-c0fd-08d9e014b611 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: AM5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6759 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220125_070946_022245_D5A92342 X-CRM114-Status: GOOD ( 15.82 ) 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 --- .../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 f54143ec057a..8b1b586f3df8 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_helper(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}; err = KSFT_PASS; len = 2 * page_sz; @@ -66,26 +68,33 @@ static int check_usermem_access_fault_helper(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);