From patchwork Wed Feb 9 15:22:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740383 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 45150C433EF for ; Wed, 9 Feb 2022 15:26:19 +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=gQaRb+jUhROGOrEEj6n+S6zVULVcEemMJOpZSHPhxJg=; b=q6pzXzBplJzP1e Uj/DnptbHiCGpA3ICxghGbafAO4KWyLkBxGcGWBgUluzCKPFiDMVuvbRTc1iQJRQZsGbx06XjNoU3 XkxIojGrpF7HgU0W28iGZoWBZOtgQNUzNBaR4MtAG0+tm5lA/yGqLiTzQNipUmnr2qLPHDo+hHYSQ skXj0ctjeeJNDaHqUaYr/o/o5k2q0oKkYF/e3Um4ApBKHmuwcNadLbnMOUQ8seJCBWK3iazYH+OH7 N/oMXHLxpDiuNwKA7TFS77ZTqhdC3moXyZ4mgiwHuUlX3iDMnRKE6PV0Avmeu3A2+CMai1GetncNg HhF+s6UUNEWJKIE3sDqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHopS-000YY2-KR; Wed, 09 Feb 2022 15:24:22 +0000 Received: from mail-vi1eur04on0614.outbound.protection.outlook.com ([2a01:111:f400:fe0e::614] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooI-000YBY-08 for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:14 +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=ZanT3lyN1gc3fQ/1uYZewHTiTDHs37oT+i2jKj450Ro=; b=DTgseelI/togpL+Po2OVRYC+eN/M9Biv7q9WeAQV+2ctVn9cyrpf2mL/wfutsVWIVX+zf+7w6nnd4LyGfORfkiGRCfrjK26sqfjadqMvNBWb0vVCwe53MzzGt5Rhuq9/kzkic9WCeFMXGlaGITaZmYicErpC/eBfuq1Lzfykhbs= Received: from AS8PR05CA0007.eurprd05.prod.outlook.com (2603:10a6:20b:311::12) by PAXPR08MB7041.eurprd08.prod.outlook.com (2603:10a6:102:1d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:23:05 +0000 Received: from AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:311:cafe::3e) by AS8PR05CA0007.outlook.office365.com (2603:10a6:20b:311::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:23:05 +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 AM5EUR03FT033.mail.protection.outlook.com (10.152.16.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:05 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Wed, 09 Feb 2022 15:23:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3c0223871a9261da X-CR-MTA-TID: 64aa7808 Received: from ece15a54c64a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 52E19A3B-1094-46AB-9DE6-B5E2A04C8133.1; Wed, 09 Feb 2022 15:22:55 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ece15a54c64a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kgwu0xORQQ9ZikGSX/fhxzQfsAJhJP4IJBCEIbpjGDYYysHhxupU+JUiHLzg56QVNi2K3mTgbVn8WEEZIBiSdUAEVoXtgPKlJ/tUfcAewOYp02QT4klrzkox2DA3xFV4yr1ZyJ1o0MqLxC9kkE5BWmZ0C0R/nCSsvDjugK5wgNMzqjTwUJBU7pliD2/sefuuHpvMg6SwRfH0nJfa56SpYGBT4pcttwlpdpp1qR/4u/lyE2fM3cmArpfbgz8+StuWrqQJajUTMRl8XkbgC03QSvj8p3/2qppeMRpg7S/fDntBfmqTNSZ+vsE1GNh2uCbbMREwx9rIjsBwSHmGxZ7oYg== 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=ZanT3lyN1gc3fQ/1uYZewHTiTDHs37oT+i2jKj450Ro=; b=N0pdEJwiUMAeg/JH6uP1hFHVKxT/irkIoOf+YAw+JXHgv8EdV2zddhXcCoglaR3unMB39A7jROzPO/dC563pSrSCku0EtMndXfeu7pDKXh6OCuw5C0AbENayO09GVpnfSeXHUzljaye9sVdifDtzJlnIwTkoWHtBeF7JW6sGFmQPBl/IGT2kS+YO/FIUkoBFi4t7hrx/m1XGe7BHPGDcuuOtkfly6K+U9iDZDsDi6fiSZejw9yfwlSogSxKeAl5G5sRnBq7Owkq79PrROxL3N5NH32jch7ClAM4oODiW2ZhEoTAluLW8C0gqdnrsTLMxlKRu0niXGwHkB4Gn/RowMg== 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=ZanT3lyN1gc3fQ/1uYZewHTiTDHs37oT+i2jKj450Ro=; b=DTgseelI/togpL+Po2OVRYC+eN/M9Biv7q9WeAQV+2ctVn9cyrpf2mL/wfutsVWIVX+zf+7w6nnd4LyGfORfkiGRCfrjK26sqfjadqMvNBWb0vVCwe53MzzGt5Rhuq9/kzkic9WCeFMXGlaGITaZmYicErpC/eBfuq1Lzfykhbs= Received: from AM6PR02CA0023.eurprd02.prod.outlook.com (2603:10a6:20b:6e::36) by GV1PR08MB7329.eurprd08.prod.outlook.com (2603:10a6:150:1c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:22:53 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:6e:cafe::29) by AM6PR02CA0023.outlook.office365.com (2603:10a6:20b:6e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:22:53 +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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:52 +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; Wed, 9 Feb 2022 15:22:49 +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; Wed, 9 Feb 2022 15:22:49 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 1/6] kselftest/arm64: mte: user_mem: introduce tag_offset and tag_len Date: Wed, 9 Feb 2022 15:22:35 +0000 Message-ID: <20220209152240.52788-2-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: f38f9a5c-995d-4a04-8a09-08d9ebe011ea X-MS-TrafficTypeDiagnostic: GV1PR08MB7329:EE_|AM5EUR03FT033:EE_|PAXPR08MB7041:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 0nt3vRsz0pCNNLFi2D9egZVgy2iFyCAJpHWBrbIk8HQ5pDJzrnb9dHjefNJ11M7yJw2obddMF+Af1aO8UXJZIVTPq9b4j1qL3yxpYQpl2i2OzGzlWDqLR0enmvh0T+m8ByCQoobIx5/zRrDRwL8nvXOkt4s/IXXEYEuDFOaULBnRkHaNw36z2zU2foCclimp4bO0pg43CB9/jKuDOqaHOEPxJkSIU1CSyFB9+ctTc1m+p3aXHBnwSyi8AN979NfObT84nTwg+z1lqbtlD7vBFpiV2Fm4D5kI+cTD2xv+iIZucMllKrE1hOyjX1kcPln/hYwCWt8B6cZP8JH0BA8wvY2zebIGAOpNi/WCPaPt8JYTfgKcHm0Qai5p9KZ5C7tKCNYiIOxDjOvoLof8IpC4gSCmeDyVsSV49/MBduvF+zJoalaLjUmPhvT1Bx5wO03/o4t4uPg1Yx7Pe8ENmuoOfjG+UpI71kXPuQCQMfgrJlxxOOM97axcsS14EAJWzwDsShkSthhzI5yhTGvLUZsurUaxQSPY46Qh5WMaq08fcilQUDgf3Fi8627h66Ydtkj7MooxiZrbqTcAH2/ukxPIevWKPcwMAtTsScSwGhatRXm5Jk/iTGQ28VPpCN5Iz/HWt3NofSPX2vcm1FLFJ6jhtx5rkwepyZwn2rbr0GK+VSbbbXTevGAeeez0MpZ0tOA/W+lCt769e4hHGMWLecEVlw== 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)(40470700004)(36840700001)(6666004)(86362001)(6916009)(2616005)(70586007)(7696005)(82310400004)(40460700003)(508600001)(36860700001)(5660300002)(54906003)(8676002)(47076005)(70206006)(8936002)(316002)(1076003)(44832011)(83380400001)(36756003)(26005)(426003)(356005)(4326008)(81166007)(336012)(186003)(2906002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7329 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 64f74e5b-62cc-4639-a0af-08d9ebe00a6b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wn8IN9xpBPUXO6eU8VEqJGefuhcZv4us/xWXQj+s89oQcYPrGHzeTgDaQBQ9UwNjeIuIQQrsganWEtaWGM9L3oaGLttCNO7UG0IDBt2IUSVoMfdAkeyP2VxPV9sOejYtWt2XtbHmKV4q/qaN1yXdKCShEJKVkZ2s50AkOI4MdApkB24g7DsCEJIpZWVtOe6DZD2ArbUxM8mxsnPAp4bdhW976hIG25yverj2nRERfWxBNQDiqVizCRGCVrgvyFFv5KkljBr0uudUnxnEpZuC4KexB9p3griQrBXSApg1zlI1ndnz6IZJx7ZVdiKigmsZ2GB5zd6jGPXGFloM00pcgcCyedbSTiRGhgpFqe6tCRhkeofELI9kOWq4joXQGEY8x5cKkX9hLspVzwyefyQh3+LbkcdLOEA7RDaMZVAZ+fulc5eZk4z7cD9Z+fmYXJVicrjHFQgcldOBlLZY6rZFkEm4XGEXUkWeZBDLJsSqrFWr0NGsV43OuxGQfbjwt0x6rUUo+0CXFqHmegedv9WhieffEv8lDl4erKFBecItSckhYJsin0xp/2W6WvHQHlIZLCllIZDpcxvoQESMO4oZbf6BgEwwEbFZ4Fn9kYNtzo/HhKPxylmbW6Gm+v1EVUqhRJNMOe+cd8zckCljR9JzYwmpuqkZ/wbDw2R0ekGf3wYWn7YMtMTwzDcgKRjo9Qdm 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)(86362001)(7696005)(40460700003)(508600001)(8936002)(54906003)(70206006)(70586007)(5660300002)(2906002)(36860700001)(186003)(81166007)(6916009)(316002)(4326008)(47076005)(36756003)(1076003)(426003)(2616005)(6666004)(8676002)(107886003)(83380400001)(82310400004)(26005)(336012)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:23:05.4952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f38f9a5c-995d-4a04-8a09-08d9ebe011ea 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: AM5EUR03FT033.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7041 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072310_098716_7C474119 X-CRM114-Status: GOOD ( 12.80 ) 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 an MTE tag at an address that is not at a page size boundary. The kernel prior to 295cf156231c ("arm64: Avoid premature usercopy failure"), would infinite loop if an MTE tag was placed not at a PAGE_SIZE boundary. This is because the kernel checked if the pages were readable by checking the first byte of each page, but would then fault in the middle of the page due to the MTE tag. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../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 Wed Feb 9 15:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740379 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 4205FC433F5 for ; Wed, 9 Feb 2022 15:24:57 +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=D+aBu29AK1Co9UqlG5PnAWmzPYwbfgRzflS/cdJwNX8=; b=F+400LNYu1Ospn lVAQT+jYVz+VDqa2XLEGgR/NciA5iXjTJBAEmHjqPhSyd0xW/c4XNGpJw8hNWSuFdD9DCcn5RE2xF iQm86QyIq8vYjpnq4Noaxf3hzv1nsKUI4Ajq3SEzun9WTOJ67xvwEbTspLaaqGtazMfvBX/jS/ioy bM64ZSmGkueLMSMuXw3Um1C7c5VwbDYKwfVj46twh/eBPxCk/ZVhi/qbxdVpyYKfy5fBRV6nih/QY RwZUDgMWFFr1GzZ7AZOoe2V3wkJ8JhIxAgeSvcQRbBwtNAbX0EDCdmSPejKrRwLmFC+LYveZie2qm JDaTn/5LKghRl2PzJNgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooH-000YBd-Hh; Wed, 09 Feb 2022 15:23:10 +0000 Received: from mail-db8eur05on20611.outbound.protection.outlook.com ([2a01:111:f400:7e1a::611] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooC-000Y94-A9 for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:06 +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=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=eofYRzQ8pZPRoLcovHKuWmM43dwWP/YPRK3RigWkAq3Wk16ZnUwY0eK4/D85IVb+hrN6EnaMohmMY0908M8lYoadjK1n+O/VGuN2GIDMKvF3yrGnCRb4KFUKBPrDlqZSYwiTNlu9mgCkJ4BGETWb9WT7TSmhP6+e9tJRMgHO3CQ= Received: from DU2PR04CA0080.eurprd04.prod.outlook.com (2603:10a6:10:232::25) by DB7PR08MB3338.eurprd08.prod.outlook.com (2603:10a6:5:1b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 15:22:57 +0000 Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:232:cafe::45) by DU2PR04CA0080.outlook.office365.com (2603:10a6:10:232::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:22:57 +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 DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:56 +0000 Received: ("Tessian outbound 2877e54fe176:v113"); Wed, 09 Feb 2022 15:22:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 75ed4d2460b9115f X-CR-MTA-TID: 64aa7808 Received: from e8c803774e21.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2CF22B2F-50B4-4D32-9119-613B9F1D3A2B.1; Wed, 09 Feb 2022 15:22:50 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e8c803774e21.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C3nbLnrTuFifHqkNQp+8qMLhd67RK0C88qnvhvesaLDxaX4LD3TvmBm3rn8jCcFtfpu8FaUoXKaquvk0J7vtwH77dc8PAPIXp4H3aRExHXLUyNyMMKPNnSV4HnLaiM4gLJOu+YvfqDKwYvoxAp3K5pT0t4WERidiCZbaoyDWEAvUGBw+O54FzopBg+j6HeWBxWlqURx+lWXR8PmDmf3wKzKSMgE67jxtQxCpsAjGvtbJpANhmhvcAkUMSmnJ6pnbD4Da6AEzJJmV+l1F1q7nZFqFx8LZTIvXtQtJ+tIt3Hq0fuxBg06vwb8YBS7MO5/h2mU4bB5wZ8aAJIztchCv9w== 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=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=RWcryQWprqEXhYYkdVja/S4RV7+5JxPgMQs2VjR/Gf1r2hYdrckCrE12Rb0ZzUF9RoBcqkQxJD4O6RAE9odlQWMepHwcau2wtsnN5kVjth5P/ShVbVZqamrs89/iHg2tyccm+OxTLfhwZ87Uuj6nRJ9ls6WxtHMAubEaAzaexJaCghf5qr9SfV8fs01uvYt8fOEqmcAxifmQuaI5mm2MAOsWHQznlFoLWjdN2whVnUMxcUUIauB0WfgJM/vuTU7/31JHF09Q6xvnk/xZN51/1PYwiv483Yh14xQPdyEk6VrCRs8VGjuFbV0PqYlNz3gmr1AAIzo/ewfERjnN/CgsTA== 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=TnQ2a7+r9tAcGqJnhjaZ6Xuq0tSBsq/+9bztvJcnbak=; b=eofYRzQ8pZPRoLcovHKuWmM43dwWP/YPRK3RigWkAq3Wk16ZnUwY0eK4/D85IVb+hrN6EnaMohmMY0908M8lYoadjK1n+O/VGuN2GIDMKvF3yrGnCRb4KFUKBPrDlqZSYwiTNlu9mgCkJ4BGETWb9WT7TSmhP6+e9tJRMgHO3CQ= Received: from AS9PR05CA0032.eurprd05.prod.outlook.com (2603:10a6:20b:489::30) by VE1PR08MB5055.eurprd08.prod.outlook.com (2603:10a6:803:115::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:22:48 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::25) by AS9PR05CA0032.outlook.office365.com (2603:10a6:20b:489::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:22:47 +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 AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:47 +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; Wed, 9 Feb 2022 15:22:50 +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; Wed, 9 Feb 2022 15:22:45 +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; Wed, 9 Feb 2022 15:22:49 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 2/6] kselftest/arm64: mte: user_mem: rework error handling Date: Wed, 9 Feb 2022 15:22:36 +0000 Message-ID: <20220209152240.52788-3-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: aaf08bbc-bd61-4bb6-5aae-08d9ebe00cd4 X-MS-TrafficTypeDiagnostic: VE1PR08MB5055:EE_|DB5EUR03FT054:EE_|DB7PR08MB3338:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: r7GR9BleRN2DP3GHnld5guZfhnmjnyUx33yq7ljHD2pMc8MKKFCiHx8bdQzPs/6+xmeWwVE/FfAfN0nAK3iF2wgDM82/APa3d3nzlnt5sOQeZP8WJHW/+Ip1RIS3kGtFU6D8xyGfzXylZFCWToOHvFfjMdMrLyReKrwSv52uZ2H5SjXWC2EDNXt8B5Jf9IrmT6WunIB5DcRs0iTvbu1wCIhdxkzN6x1pa+V1ht9c7VO8hCan8SwaeJEsq2J8Hy2VZrSAVO0E0EZsKIPdgurMSUo4ujxDAMWNWlBy5LnWfIqZIowdXEFsQvt1sRMWYj352GbsrKO7lhQj9wqVKhGEMFurSCWPcKHIkyGqojWLsbI3zYzMsCQ/by1eHz3KSG2MG+BPq+fmPtF6aiabwj8KkRMx92edUoJh5aAikvxWuun21sv4sdXVjdUmdND/O/r6MTjOkrzVrYWFbkriH+rH8aPDJjh8FYmQ5azBQpBY9D/ngvp3MxqhARAouB2Xkzr0Cn8FtHP4olmY/VWtPQeedlwLxQCc+unlYnBQkVyS7HNUSVXLJN19lumhAW8nc5ZrymY8zxScn8lPLLWlyOYcN147nIl7P0NtOi4ZxBxqZSw8TJY4GL5x3bJlohHv0We/S/mP0iL5UPhljFeJGOz88cu5ExiguhMIdShHpGaOkbha5vhHPuJhwBzc9zLCHdAHfmvwuQRg9qRg/xPYvy5ibA== 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)(1076003)(47076005)(356005)(81166007)(6666004)(70206006)(7696005)(83380400001)(70586007)(44832011)(5660300002)(2906002)(86362001)(316002)(4326008)(8936002)(336012)(508600001)(40460700003)(426003)(54906003)(26005)(186003)(82310400004)(36860700001)(6916009)(8676002)(2616005)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5055 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 33631bb3-2ebc-485b-9d7f-08d9ebe00731 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RbCf+cZw6RqtXuXVJTaIGmSGpBGbhsogGU/LI6KZFU1Kvht3eFW2Kphod+wISR0WxNhaAwONcKy8TghNKa0zUFOANGTrieAvkGpUUJcQ0iu35hBNlChtcDskrRfG0wehaPzKOXWrUHjyxFD9P9nwo5xzcPOvyzhFJIlCjXHiLppN7Z5i0HTBfJyVaHoFRY5Xd01vfTaFZsjp9HBoHhERkVLZ312lTnZdpkLG8xzokp+mb0JY3fC+nF09M1X995kVLRDnM5rYmtppEnX/4n5BJWxfTYc7Z+L+glrm1VzWtbXLDprnwTDMWPZ8QluGUCMLlnsJmUZJ+H2yF4fTwL7HyD3gX7lvI/CbWiNeey3ZHuk37ZQbdljnBz4eW62c9YCUqsX4FyOG4m5L8JaeWZDCeAxprmtZbCV5ksyXPwU+wZQT4qBsbaPCcgpu97xBcyq1Stv5eRxqZDGx9jgO1qUv0C3uZhXq3l4ChAsh07KNx1v3bZI7SlCJEeu+c0MFKVpsVdmdWAh8PHkhJ5U2mEoK3GXjpuCWI5Ie4iVbJ63hgz1ZrfurZUYqpc70qi5PmodxE5Vg/E0fJ/iQ4mPjgVqE7lj6UD6kS9JR8qPrCLJOB7flv3kc6swX1c7DcnR+Ifi2VTUc2vgQk08Zs67WzLNChjjj2uh7KLreEN/lQZgSZ0hquyfwqiTW2KUJat/51NOZ 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)(47076005)(5660300002)(2906002)(8936002)(26005)(107886003)(8676002)(186003)(336012)(70206006)(36756003)(70586007)(44832011)(4326008)(2616005)(426003)(7696005)(86362001)(83380400001)(6916009)(6666004)(54906003)(316002)(1076003)(40460700003)(81166007)(36860700001)(82310400004)(508600001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:22:56.9924 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aaf08bbc-bd61-4bb6-5aae-08d9ebe00cd4 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: DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3338 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072304_428901_C5F43780 X-CRM114-Status: GOOD ( 13.23 ) 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 Future commits will have multiple iterations of tests in this function, so make the error handling assume it will pass and then bail out if there is an error. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../selftests/arm64/mte/check_user_mem.c | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 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..2afcc9fb9ae8 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(); @@ -71,14 +71,22 @@ 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) + 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 { + goto usermem_acc_err; } + + goto exit; + usermem_acc_err: + err = KSFT_FAIL; +exit: mte_free_memory((void *)ptr, len, mem_type, true); close(fd); return err; From patchwork Wed Feb 9 15:22:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740381 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 F3B41C433F5 for ; Wed, 9 Feb 2022 15:25:27 +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=+JZCe1hDPkRlrihJnuLbylrV678RKSRE6y1GYePWuxw=; b=qsy/Qw4vANkvbJ ik+ohUk0GlaPG+yrAND4RIrgbiWO73zG/ZnX7BcloaZJx1J6QI9m7yrjUonIShsY3VdwiOHH1yX/e b9JZ6SCCK+qXuKc7OhZxg9sYO3AyOJFr6t5UIDwxtLNbEQ9RbqhKqvgi3kPb5UeBo9B4n3+eLIjNj QGZdCveeWxFKQurBuieTsmFYMMHOqI54s5l98kvn7WwfwUXsf8CPC4SrmHYbKwDjNva70+vs4bJKQ kA3/sE6xD9ZSisKmZhs2w9R2xof5789EvxnelTV5qH9Mks8frdLwCpNSjggRKavf4mwiK5TxXwTmr bALTuLu96z2rzpj5HGXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHook-000YKy-4w; Wed, 09 Feb 2022 15:23:38 +0000 Received: from mail-db5eur01on0602.outbound.protection.outlook.com ([2a01:111:f400:fe02::602] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooH-000YBV-JM for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:11 +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=7zrFR/5yfryMYPJxbnasHVRAHNFbLp4MPEyNkzpxB0U=; b=3lyo/kg5MdO5OvqXUYJYOueq3dPsLYDmvEdrvllLkCFf84THD8Idc86djq78w3ql9L1LjvW5urrba82HeP4nyNmRWtZuMiq+sEpTUuEzi22etWS0q1tTSv1w7j1di1hlccZKPMZZpRMqp3FkgQ0IFZ/w4TmsTvFcPw4XF4h/CO4= Received: from AM6PR05CA0006.eurprd05.prod.outlook.com (2603:10a6:20b:2e::19) by AM8PR08MB5636.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:23:06 +0000 Received: from AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::45) by AM6PR05CA0006.outlook.office365.com (2603:10a6:20b:2e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:23:06 +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 AM5EUR03FT048.mail.protection.outlook.com (10.152.17.177) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:06 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Wed, 09 Feb 2022 15:23:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3e56b5aebf36f51a X-CR-MTA-TID: 64aa7808 Received: from f8e88ca1b39e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4A2C5390-15E0-4B9E-8DA4-E09E9902D79D.1; Wed, 09 Feb 2022 15:22:59 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8e88ca1b39e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kULLDDWYzFWET/+u64l+1EF6wq/s6gF9bYPVrC7QeEjoXsryiUyo50ei/QEHgQXnlYRrUzcw1+7pRYqlezFWgDNa0hiizQxPwUkuCFJM7BTyrAqCMxZmUxhkK/DYXtq8FyR4zGUN4T/M7Wnd4E+grXVP2QDPF/5EXtoX4krlpDX7kaE5JQ/eI3o+oNZOXCisZb01CKdm75Z9STRcOVIuaG4TIOPrF4HObZEWvozXCk0vLXA3E6otPmpABVCPC7ALr79rTEAuhUH4I5ej7vMBewYf2gcvx6yA78+JQAO99BZuPzjpK+Sx4D9RyrukftLn69XE+v4e3+YyvW94i4g+Hw== 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=7zrFR/5yfryMYPJxbnasHVRAHNFbLp4MPEyNkzpxB0U=; b=lXedgpTgZ2WI7fok7vb/8pv9JsJbMa453ifpsOXE1VAYbhzfh+A08kC/CplaVlFUxzizD76ITj/Smu5teEdrCXptNVwV6tHZOBYntwARoDzmR/7D5iKyi9STH1uv/CyD9ixpqN4bvc4Q6qQU1V2HIHGJNShQHlhCCa0uAp8bv/wfDKrXGRDbvUR3/l0Q5seh/6Vuv/JiwkUR2UC3+wT3wcREwelYhqlCIeqgxFLbs3o5O8PZO59vsDP35y2FjJfPFdPIE8jHNfUZF0YcAtGzEvyV+J+QRwsrZotknBuzRgA3nNU02JvPqqtITMqUdFAD3v4HRCG6VJOBGgsYv7vODg== 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=7zrFR/5yfryMYPJxbnasHVRAHNFbLp4MPEyNkzpxB0U=; b=3lyo/kg5MdO5OvqXUYJYOueq3dPsLYDmvEdrvllLkCFf84THD8Idc86djq78w3ql9L1LjvW5urrba82HeP4nyNmRWtZuMiq+sEpTUuEzi22etWS0q1tTSv1w7j1di1hlccZKPMZZpRMqp3FkgQ0IFZ/w4TmsTvFcPw4XF4h/CO4= Received: from AM6PR02CA0019.eurprd02.prod.outlook.com (2603:10a6:20b:6e::32) by HE1PR08MB2923.eurprd08.prod.outlook.com (2603:10a6:7:2b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 15:22:56 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:6e:cafe::9b) by AM6PR02CA0019.outlook.office365.com (2603:10a6:20b:6e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19 via Frontend Transport; Wed, 9 Feb 2022 15:22:56 +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 AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:56 +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; Wed, 9 Feb 2022 15:22:50 +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; Wed, 9 Feb 2022 15:22:50 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 3/6] kselftest/arm64: mte: user_mem: check different offsets and sizes Date: Wed, 9 Feb 2022 15:22:37 +0000 Message-ID: <20220209152240.52788-4-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: d5b743b3-5064-41c3-0fc9-08d9ebe01287 X-MS-TrafficTypeDiagnostic: HE1PR08MB2923:EE_|AM5EUR03FT048:EE_|AM8PR08MB5636:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: npbCxEm940+s0nO0Yy20R2gIFzzkgkmDWxhKvmeulZeADWS52IgTpYgSFFxfAo8zuoQFmyl0H1lbwPXY+YRMjjERkmDFpOYtgoUWHEjDcm8HqfdTx7clALB1OnaBEpG+77CaXWrGUiF55udpPNEwkfZDpTj++52LPEwLzHpmHVYIKrFqiyJLlZWtN1MooWXkerMg1CNvAEaLcF+F1GacgXbF8rZTDOfEwEMNXnQKPfgzDuDnMq4LMrxQCb2DmDy6c0I42bTRYzByi2ozrMM+MvyNsWPoQ+fySt/S5JoPf45BJ/Xds9gJ+pf0Eoq0u0hdnCWpSmHNiWNQz8gCjJMkHLFsAW4XLaptqKQAt8AIutzeNnwujFpc1u+2QK9URdODQjdWFLXYjjHCTsiva8TjgpY2+Ku1QlU7okAl0KVP9yLMs0fdZiub1ECDZ4qOSJIhhwutfEfqT2wDBYjV97cdnI2+ruUGNXZk2nR2ImLdKt+dwf/diEJ3m2k47o6dc2eSl9BXxoYE7m9WICDi0dPm0DEZdgFrX5jHxqgQz3Ti+sG7DkyygsD729AmytjGjTcvT9rhIS/4swGPqgn2SfrI1hnG9W4ZZPJYbO0zB4+njq6ZlsSrcALqI7fuGVKJTef6GDbG8mWkMVWoUBHLKU3+KYWAUXPqbYKGXc/fYmiRgpY0zPIj4wKKpvGdsLqwxU5zaTkubqB13Uk0L+dCLgJZNg== 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)(46966006)(36840700001)(36860700001)(26005)(4326008)(8936002)(8676002)(86362001)(1076003)(336012)(426003)(70206006)(70586007)(6916009)(82310400004)(54906003)(186003)(316002)(81166007)(7696005)(2906002)(6666004)(47076005)(356005)(2616005)(36756003)(40460700003)(83380400001)(44832011)(508600001)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2923 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7d558006-94ad-406a-bc63-08d9ebe00c56 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LGFh/GcrOkj7u2NXFQZnFvquvDV1c+rRYKBcaIHNMWH5w0lpHmUljSI+IMD3Kg2dpIGSaRpTPk/8L19KWJCHGK4IPgIrXcd0jIA3ZArmU9oNHOlLc/OtUrl2yltriVMIs72mVs4nNQyaqcfVHGPDyvJcWQTCvhQiSqv1SSwN+aXIB4UVevEEVNFPvd9m5DMa1U9yDS0amkbK09KJtoeBi3WxL6Y1y4FIlPjD4WByOu8TgDUKFT1gA0rwC5vEisL3O8gNcaX0MztLmR1OaQDeSSXKCOcS3s1v2sp8yDQbtZdlGKgkNXTK40fWXvVHrjIcPkbZRAzV2PNHm9g+NyYlaXgwrE+ct2EiAPVUUDin1uM6JD68VKT6/d0gP5BTgOmaBtuuoXRLstL4RSea74aHrcjRQqDOFc/miIDAINxOFvj6aTIuj7BGT0ek4i25T+k4MhogQ7EqX+jA9XJiVY7QNKGLnbzIemCqVG09T0mETDVtmbDPVqBORNIG08knIb0aqvGal37yZQLPJg0ht89mYUxR8DJUpx4KnOMSjEcO1cGsTxfAA0mtjaxKzwyhCL4mRsJgn47K0eCCkPCLZSLlgEtSdDj8mMsKn7Jx60CtN5r97VzmA0GsYMtoUD9e6hH8y1P+HDpeVBTCoAJ/CqflbpOXtgzMiR8u91pzNTGNh3CNSN2HlBIQW2ApWSb1o8SX 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)(81166007)(47076005)(44832011)(426003)(508600001)(4326008)(8676002)(5660300002)(70586007)(8936002)(86362001)(83380400001)(70206006)(6916009)(40460700003)(26005)(316002)(336012)(186003)(7696005)(1076003)(6666004)(54906003)(36860700001)(2616005)(2906002)(107886003)(36756003)(82310400004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:23:06.5210 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5b743b3-5064-41c3-0fc9-08d9ebe01287 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: AM5EUR03FT048.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5636 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072309_707913_DF1D984F X-CRM114-Status: GOOD ( 17.13 ) 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 To check there are no assumptions in the kernel about buffer sizes or alignments of user space pointers, expand the test to cover different sizes and offsets. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../selftests/arm64/mte/check_user_mem.c | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index 2afcc9fb9ae8..89c861ee68fa 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; @@ -62,24 +64,31 @@ 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) - 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 { - 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) { + 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 { + goto usermem_acc_err; + } + } + } } goto exit; From patchwork Wed Feb 9 15:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740384 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 E40E7C433EF for ; Wed, 9 Feb 2022 15:27:06 +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=m1YyofhYavduTyYO8tysUOtTLG17JpiPX7y75MlFQ80=; b=Nl8e0xeTvbzGIy NouOv+qVGLihxyy2vFNtfnIutTP1t2E11s16XPl/bilm/4LCITvrmmcy+Fzw34IKu3t9DlS7u4C12 t0pHzaQwlSPDRR0x/kJ6tEeFsnNnbpNE27l3/a3aZaKakVjZdBWYn2UJutePo27rF0vRcogA+/I1k /hujx6Yo+MZZxYxpX73sWQWH1W8Sr3wleFm2NXuwrevaMTBy337kTkCM/DHV3uuiqiB2JUc+CU/j/ SSD88i0ZIzNKm5lA4WAi3EiB/syw9/1SJwp9AxcYvg0w1PNqnZHxdvpcKUzFNOJaFfhmC/mljp/Np 62TBXJIDoHsa2CvMhfaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHoq9-000YnL-Oy; Wed, 09 Feb 2022 15:25:07 +0000 Received: from mail-vi1eur05on20626.outbound.protection.outlook.com ([2a01:111:f400:7d00::626] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooZ-000YHZ-3j for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:29 +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=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=sgaam0UTxXxWfEGrukZGN2qYudMkdhvbpPagnHIDx1h3KQLI6A848sLoZilDe5HES96TeOUzbPPnF8mi6OQlK8qtbwqpSfrwBRfSXi4yvrYB8eL5AJVSwpVHb2+AeQx+JSRillBwvIle7OHzFXg7oF2uF9OVsPdv9qH8a49Gfhc= Received: from AM6PR08CA0021.eurprd08.prod.outlook.com (2603:10a6:20b:b2::33) by AM6PR08MB4965.eurprd08.prod.outlook.com (2603:10a6:20b:e5::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 15:23:22 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::ef) by AM6PR08CA0021.outlook.office365.com (2603:10a6:20b:b2::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:22 +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 AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:22 +0000 Received: ("Tessian outbound 741ca6c82739:v113"); Wed, 09 Feb 2022 15:23:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 12beb7a43d10e576 X-CR-MTA-TID: 64aa7808 Received: from f12f5f16e401.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9F163494-A6BE-442E-97BD-2562E1D2019B.1; Wed, 09 Feb 2022 15:23:16 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f12f5f16e401.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:23:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bkNtA6agkJM4K0obZHZchmiRIowMFGKh8sYQSxSHmhLCHi058Wvl6CpAHFvszuIWt82BpAOyVQ0r9F9PnXLE9Jf0k1BYlSmuJLU6fXhzs9EwlKxeqHWuGlFiJ1YVx2psSKVrBpg/efKg47D9730ctYnizuJPtSGrh2CoI9TxO4cfUsM+ssgVheIwUM341C/cHe6QODMxcz3O3NEvN6nJlAKbW2p6pT8JvyhoZ0hMrvfXK1UwYodJHavVJDC6/aJ6/wklk79aPrYpVVblpSAj3WvndHs8vZIYLi8pkVc57oNhqP2xtnM/8j8XdgFY2kwZlYqYdKHEZ6rIU4hbFgKxVQ== 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=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=bPASvwMi58DGrnVPlJJlZVmg8QDrRhjDKwVtEpPaKK7/w1ihoadvsgF/irsdicEX5wRitFjTgI2M5WUsY15XpKMxIauadenK/JNppSBbsiLYB3/egR0Ek3ULceX6rhxAMxfDIrsSWulqdzk/ySOnQF9OKd9XtPR6+3K1b8DknjuPjWtLPLBV408ypoqDpdC6FgudpNSrROvaEYFLu3DUrypkGta5eZ6PIRL3XmNgLlEHkGowLybdewuJdHTP0vTLM24HiwoqCUzxsnYF5sCLM6fxXQ7YzA5TfmRH7fFm7ytrPFNZ0McSupQWYVEb0tkvhUAWgt5rtyT6xtq+Z6kz3w== 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=mk8UCdrCbfHrikHsK0eP/ECI2A9aeI8O1MImQnAZT2c=; b=sgaam0UTxXxWfEGrukZGN2qYudMkdhvbpPagnHIDx1h3KQLI6A848sLoZilDe5HES96TeOUzbPPnF8mi6OQlK8qtbwqpSfrwBRfSXi4yvrYB8eL5AJVSwpVHb2+AeQx+JSRillBwvIle7OHzFXg7oF2uF9OVsPdv9qH8a49Gfhc= Received: from AM6P194CA0040.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::17) by AS8PR08MB6679.eurprd08.prod.outlook.com (2603:10a6:20b:393::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 15:23:14 +0000 Received: from AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::a) by AM6P194CA0040.outlook.office365.com (2603:10a6:209:84::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:23:14 +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 AM5EUR03FT022.mail.protection.outlook.com (10.152.16.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:14 +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; Wed, 9 Feb 2022 15:22:50 +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; Wed, 9 Feb 2022 15:22:46 +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; Wed, 9 Feb 2022 15:22:50 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 4/6] kselftest/arm64: mte: user_mem: add test type enum Date: Wed, 9 Feb 2022 15:22:38 +0000 Message-ID: <20220209152240.52788-5-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: a5625c62-eabf-4a46-98f8-08d9ebe01c42 X-MS-TrafficTypeDiagnostic: AS8PR08MB6679:EE_|AM5EUR03FT029:EE_|AM6PR08MB4965:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XByxhaBfo3gIfeLXZ/Zf74jNW1t/y+ITSY4yb6Y49DqypKxdd3i1ZtPYYglKalsXMhEiYXHcx0us7n4KY1M1rLIyofS071nqyYcaEt5/6Bbj3tMVcRcwvU0itgHEkHWdwEtDPK6YpLU9Xwo1T5GofIbaUXJNa0bmsHs7VFi8oO8N10ELb7IuCv4jJd1w1llTBWHrGWM05jASQA4VN+/0NHp7HE6Q0xzEP1XU4O4ckl5DXyRrq4qWODBEjp+IOTXCmW0oBgLCxjqihsJzTir884VRgMFV4rPENebRgLA4W4kJ73cQxwfcR/YPGkFPSgSl1VPgqrB77AUXyKjpP74HnEUdYq9z0jZ7LSRP6E7kmiFhhdsFUPFrT4mcNDiIuRaItmyQxDqjBL5jRuXRbgV+VoeHNiI/5oGEgx2YMyU6O6xEhYjokmzvr3mZ6ofL/uMz7HmAzyYQliV9tjvmaebB3xyVE2W8JgrWtW+DGNsN0Ra8Ujx8nA4hpoxc6Zj0W0+tFuffvOYKP+sPcWZDSf1jEspPSmvy7ClIb/wkzzQ7u3q1Q4QZIbbu3/hP+pCmA03AL12bJcidzxEQ+DBwSxJvBIpGBBLHJRFROA2YBiT8sxmW8tYgCvi+5drnNRsFWni8hno/v50CzkDGJ13ze1z/2GdQhiqJtT6sYqjOxdLkew0Ij4uxOe+FiM2/Css9+WKWBAu+JtFzZqrWPHhhYbXVxA== 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)(356005)(36756003)(336012)(36860700001)(5660300002)(82310400004)(426003)(316002)(7696005)(508600001)(6666004)(83380400001)(86362001)(47076005)(186003)(26005)(40460700003)(8676002)(2616005)(8936002)(70206006)(44832011)(2906002)(70586007)(81166007)(54906003)(6916009)(4326008)(1076003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6679 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c1c813a8-800a-4036-bb4d-08d9ebe01707 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F0AwfL/SAGN6UhOFWcuV8I64T7Nk7ivcDoOf59kvGjtkeHVbMWJXhnz9it+K2SyIOpg49ZV2YtfKiw0NoAb0RlznpYvxb8N1zofaQSUcK6bI2Ct8JZgZSHoiCGXgz9uYF7M1if2YwhWxFdLXXePAhowqQu9eaYgsT1dUL3s8AosJBYHBr7yuer29NmZz5nk5GSFZRSvbRjDMLd1FPozrMan+o1zhtYqYZ+fy1N4eKUqzeJ5dkOcpG0jCoe+mS2zIT9Ea+0TBBBnNBh93XVY/dmuhpU1XGnFHD3huhhrmJSp2djhD8ahjaXjJsTQs7qlYptkriAsr/F+WiW7jjXV0OkjeHHZeDqC3sB32suI6yPsYdPMIS2So7esRd1oOm1AG4MTpdZQ22UxLxt3ga5GEIflKq3Y9i0JpRS3QXtXIA6nV0V0slJUWiC+eV0pQXoXWqM7PrFNMdyVtZygDDx0bYmbRSyhy440vV1UPfe2MmsdN8vkVlJM0sOHBlf9nY2uw+rhD3+RwrxyoA4YpOmVy4qsrPBvun6yloiK2TWNZ6Rw05aMNH+AUykP3lRdA3f1QVDsdwNNWPPbmp4I7MQoelsNQ+Wgj53rVW8PuS56BJOBCmLyG33xZMy9tAChcVe8vLkrqeqqHV+m4HKWI+tAJQdnsz4MvNqPOlW0VDP/hHFQ= 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)(40470700004)(36840700001)(4326008)(6666004)(8936002)(36756003)(508600001)(5660300002)(70206006)(2616005)(8676002)(107886003)(26005)(86362001)(83380400001)(2906002)(7696005)(6916009)(316002)(36860700001)(47076005)(336012)(82310400004)(70586007)(426003)(44832011)(81166007)(1076003)(40460700003)(54906003)(186003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:23:22.8495 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a5625c62-eabf-4a46-98f8-08d9ebe01c42 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: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4965 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072327_359015_BAD222EC X-CRM114-Status: GOOD ( 16.39 ) 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 The test is currently hardcoded to use the `read` syscall, this commit adds a test_type enum to support expanding the test coverage to other syscalls. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../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 89c861ee68fa..58b1b272ca80 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) goto usermem_acc_err; /* Verify same pattern is read */ for (i = 0; i < len; i++) @@ -69,8 +75,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 @@ -80,9 +94,9 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, if (cur_mte_cxt.fault_valid) { 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 { goto usermem_acc_err; @@ -120,14 +134,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 Wed Feb 9 15:22:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740385 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 CC613C433F5 for ; Wed, 9 Feb 2022 15:27:53 +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=EC2AL37AfVBHB2HoIv0BQhgwp/NrN4G7+EjXM8i4r4w=; b=KAZB1/OWakRsIc DgaZTzw+QAlBcaBA3PCr03L3RvYnUCjfNlSQq6VE7gxamEbTQVwi+kIPCy0ntViUQQ6aCvNZKiflD +2lcBSbyOA1Bmu9TPiZwZimSLtcJDNE4Q8jI6f0Zash5UAyhLTZfx3P7VxfgNXZb4/6oqhgLNnwFK aiJv/f1dJsQyGMk9JObL3EBw4z6iThk+5Y+761ZLrWYLma3SRcEFyaj0ZuYHkXd4AAs9FihrBm3ot Od1Gelz/uNCDBGFEhVBQykcFrbBtZGrKb02/rj/PHFzF5yILcvjXhytvBwSwBpx7Yr/cjzKlfoJv8 HN/uTtku1ZP/sXsmx/iw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHor3-000Z8y-Jw; Wed, 09 Feb 2022 15:26:02 +0000 Received: from mail-ve1eur02on061d.outbound.protection.outlook.com ([2a01:111:f400:fe06::61d] helo=EUR02-VE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooe-000YJA-Gi for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:34 +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=vBWkP3xTDqEI9nZFAGoaqV6fBxjZyDpGtlpDd0o4wHg=; b=rJuu4RIa7MnnraHG6gJzRLPMmNfl2Ad3QTXW8cZiikWbousyWghwHRAcXjK7e4GprlBcH1oA4Z6nYWEm69D4QM8XuqqpzP8Vnqar+G7wZtOXReGh1ofRsan2tcIOHGSSEMSgH8xHt0F56pnWETyjjaRGQZ/nK29tSJ602iJZJ14= Received: from AM6P193CA0094.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::35) by AM8PR08MB5796.eurprd08.prod.outlook.com (2603:10a6:20b:1d1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 15:23:23 +0000 Received: from VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::71) by AM6P193CA0094.outlook.office365.com (2603:10a6:209:88::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; Wed, 9 Feb 2022 15:23:22 +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 VE1EUR03FT034.mail.protection.outlook.com (10.152.18.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:22 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Wed, 09 Feb 2022 15:23:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 797637f393daa84b X-CR-MTA-TID: 64aa7808 Received: from 75e4919ea095.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A75D58E6-37C5-4AEC-ADFA-5EF4F6699137.1; Wed, 09 Feb 2022 15:23:15 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 75e4919ea095.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:23:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j9NQ6gm+yEc0d7UI8fdaiothQiRlvwanVPtl5vDHcvdOE/XAiCf/r1KbwCwH+jSBVmbLpJ1l75TWHfHq8dt0ovahqt3CCGlWcQKx7hEpF4z99I2xsoyKEufwS3p7Ffrlaqb3Rso7Ri/2aVZpggVN0ln3URMgyApAhSxUWnzT0gXiYQvIp8ST9h7fk9RIOBtDp9oLSFi+Dg6yqw3pOhJEiW2yug63DRLGM9+GEnNGSRgBQIwhQAgOVJwYb9Dy4EYbPkrypI0w7oMhja5mZtbQHxW1xyEcnyiBgdEs9i1/DqkNjjoe/wFAYMI7uHfQc0awUBGYiaE+rdWXl4UfudkISQ== 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=vBWkP3xTDqEI9nZFAGoaqV6fBxjZyDpGtlpDd0o4wHg=; b=KH/5VEqNn+O1TV/fVK1wH87LfUO++JmueX588e5pTcndEAvhrP2Nzad7C/dc6FRPrGd7GoMdOBV7oJ+XPhGpzIgGqMxb6WABhaXftC1GjbMDrwfA1E8FRRGHnKO1vEl9/bgQfqn196kTZ/YQZls0tJitDOtHcxl6Ey1OYG0/xUmscNudfTcAj94wR35TV9nqxC4PEU3R1lUq7H5GCFfOE7ZdqIIERQ9ARfTggtLAX5lX0WturguRqs/NGYTtSw5BnTaYzzkLEO0anQtsXga0hT+UkuAmUe/omkXPnnP3lXBWTzl0MHDCB8SSpwzTk3rE6taXAPnIjvr4Rp0+hlVopQ== 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=vBWkP3xTDqEI9nZFAGoaqV6fBxjZyDpGtlpDd0o4wHg=; b=rJuu4RIa7MnnraHG6gJzRLPMmNfl2Ad3QTXW8cZiikWbousyWghwHRAcXjK7e4GprlBcH1oA4Z6nYWEm69D4QM8XuqqpzP8Vnqar+G7wZtOXReGh1ofRsan2tcIOHGSSEMSgH8xHt0F56pnWETyjjaRGQZ/nK29tSJ602iJZJ14= Received: from AM6P194CA0038.EURP194.PROD.OUTLOOK.COM (2603:10a6:209:84::15) by DB9PR08MB7219.eurprd08.prod.outlook.com (2603:10a6:10:2be::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 15:23:13 +0000 Received: from AM5EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:84:cafe::bd) by AM6P194CA0038.outlook.office365.com (2603:10a6:209:84::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:13 +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 AM5EUR03FT022.mail.protection.outlook.com (10.152.16.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:23:13 +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; Wed, 9 Feb 2022 15:22:50 +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; Wed, 9 Feb 2022 15:22:50 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 5/6] kselftest/arm64: mte: user_mem: add more test types Date: Wed, 9 Feb 2022 15:22:39 +0000 Message-ID: <20220209152240.52788-6-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: d8e714ef-6489-4167-b164-08d9ebe01c38 X-MS-TrafficTypeDiagnostic: DB9PR08MB7219:EE_|VE1EUR03FT034:EE_|AM8PR08MB5796:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3044;OLM:3044; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: mEJayZ/8YA66+sLfsjUZOCL649PGRprNRJ8fMzYIYkonVSqiyGu9yzFUqtwwMXCsVETqljsZ1Q0SZqMdC+YRoMOFJA4EDo02incDFjNT0jZlhjYTa9QKeCoD6rR0/pWcPx/T0+f8u3uv6dccd9ut0QrXkIF1jmd4HAyrZrKddBOXQ6hSfyPs+M5VXvPr6NmTPoLf7zNVZR0K0yaOlQRno2xNhvIpHaQxbmKc9gJ5XMUvDuvcdTxetwm09VUHhsfWlqS+oRRFIO6U4mslixTPLYU4KnulSb8WHv5cYD5IME/MG/G93wIOTNAfM4R6sFxQzXRBmG/zX7jtxeq7Rm8iGKS3NiQLrcyAHUxLMckE6nzHFj5SAIU9nGsKSdZxxTfpOpw4to+YodSF+sDe37cRi26VOiuwO/cqb/XIYWfcBwugTqpDdXvTcnqDyWenD81JP8XvbppIvIfjbVtL8BMg2lhL+6HFrZ4qv+8EgS9NMqwWjoC57C/HXLs6zhIG2vFYOCP2x0JhF//f/kwnI4VsJvVaGksOTipiNdv8dcI2VPUp4fQ4N8b9LsXCnh7tInTJzHWhk2X7JiPN3ISugVVYrQNPIDs3pRMpklcdCoKlx7BGKVxgvWV5MBe9KDmP9dASKfmpjBIhowauhDP7IpLaO9FOINwMKHPWvms9ki7U18LixdAa3GUXz11DaTQDhhCTWO+O6TFNPrNLwKYKoE9pjA== 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)(2616005)(356005)(36756003)(40460700003)(508600001)(8936002)(4326008)(70586007)(5660300002)(83380400001)(1076003)(47076005)(26005)(8676002)(81166007)(36860700001)(6916009)(44832011)(70206006)(186003)(82310400004)(426003)(336012)(7696005)(86362001)(316002)(54906003)(2906002)(6666004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7219 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a838568f-9ebb-4d85-aaa4-08d9ebe016d5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UT/UUoNR879GhAZdW999CNI2R4ufzcnk6Znd61WfPQfG3KvIj85fiyQuCM/RPWGeaGxJrK6RRTr9HLG31Mo7POtF90XQ3mLzfD27fIqgiRAh1yvb/XTwTeFWkIOY8GgbncESnDxU1uKBchE7p0l6hbkwwwG38gbCLLJie+tYXncSAcOzd+1sR8uNreZ1yFUqw9aVR/Xq1oPeHMaXpEMkFWXD3sx8bXx1KVODKNeaQ7WRd9DSlbMLAo0gKw34ElV2QooLUlhJm/8VgUnTRa3bRj9QKzM28J+JC1jDP+dO+IajYPds2VfyJbyVIW9ZBX/K4r519Qieivu6SeXhlGE/c91kyaM204A4iD5KYyk5B5HExzZInlK5xbtG18hZzYz0qQ10gMQ36RJfKl+NF7GjZDiKrIwe4RVss00JngUXl35tfsIeYGUCfQPz3Wm4LoMShu1W77MttcDuPVBATP5o36MB+pci+43Qose+x5b6DnE2hfQCOnylJFt3NmO5tWYC7jcvItCHYXg2x12dQXGQWbUI4/Xge0JleYJjb8doq1VQB4mhtbO9ciuRqsE9vvkJg49B/KjLVv6or0ClR3AdnFsuDwXD4MUEVHH4gMyjhe/tLqSnmBE8Rx0Ytwb2lCev6jcNtCZlbPbtb8vyWR22jNtv5SdobOKhAr+HQ/YFZbI= 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)(1076003)(7696005)(107886003)(186003)(2616005)(6666004)(26005)(83380400001)(36860700001)(47076005)(82310400004)(44832011)(2906002)(8936002)(5660300002)(40460700003)(336012)(426003)(70206006)(70586007)(316002)(508600001)(8676002)(4326008)(54906003)(81166007)(86362001)(36756003)(6916009); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:23:22.7377 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8e714ef-6489-4167-b164-08d9ebe01c38 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: VE1EUR03FT034.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5796 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072332_601314_9B56FDD6 X-CRM114-Status: UNSURE ( 9.78 ) X-CRM114-Notice: Please train this message. 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 To expand the test coverage for MTE tags in userspace memory, also perform the test with `write`, `readv` and `writev` syscalls. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../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 58b1b272ca80..bb4974c437f8 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, }; @@ -81,6 +85,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 Wed Feb 9 15:22:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12740382 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 E1A1FC433EF for ; Wed, 9 Feb 2022 15:25:48 +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=amtYIRYt2AYtJn89b6encyqVRSwn3WMu4K5H7xbFqnQ=; b=jYMxonHz9OBxoc le3sDC9Y4RNFnASq8flrBDeZeFxr6CVFKLDfvFVznt1puGetK7txrRewl4ccGldnxmRziitoyH0bI RM13ycVagvEKjIS/Iie5JighGyhtkArDuAPu/+Jz8q+c15C7ettf9+qiiPd7gpvp1NCTeaiwfIxpN oaIKfkXFGSp5OxxjzNGNl4XbZGgNLXsPe7lyaFCC6AdaXPQfFhapC4jka74+AjaQqoi8jmyf+tglg 5foSnyiXXhVrGmMoSIR6zNdNMYFa0ofALSMPXVGN1CQBhxqupSGpziONar8/ivBmvImVUI77UuInl t1ZyT320cz/VqYKxi68A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooy-000YOn-8T; Wed, 09 Feb 2022 15:23:52 +0000 Received: from mail-db3eur04on060c.outbound.protection.outlook.com ([2a01:111:f400:fe0c::60c] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nHooH-000YBZ-Ni for linux-arm-kernel@lists.infradead.org; Wed, 09 Feb 2022 15:23:14 +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=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=vnujyJ6NJQ5Qi3moFlGJhZ84M4+kihDSDQW9zihgGWEj3EJr6E8c+246KGKg7mhAEmYdFycDANHlcwhbTh9whdWRJe6RnvUIdzB6cqB+9wOfO+eY51JKl+X8zIHADqqcWHtLMjus04h6nGCyGrhZYgJdUSMyTjZHH13rGewz8Wg= Received: from DU2PR04CA0283.eurprd04.prod.outlook.com (2603:10a6:10:28c::18) by AS8PR08MB7321.eurprd08.prod.outlook.com (2603:10a6:20b:440::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Wed, 9 Feb 2022 15:22:59 +0000 Received: from DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28c:cafe::25) by DU2PR04CA0283.outlook.office365.com (2603:10a6:10:28c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:22:59 +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 DB5EUR03FT053.mail.protection.outlook.com (10.152.21.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:59 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Wed, 09 Feb 2022 15:22:59 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7e58cded069838b5 X-CR-MTA-TID: 64aa7808 Received: from 7e25753eca15.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5769496F-6A58-4D61-87E7-9BDDC57C399A.1; Wed, 09 Feb 2022 15:22:53 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7e25753eca15.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 09 Feb 2022 15:22:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YJhX0R608cIjVEXRGVgRQfciptyOmVAtvffvu5Ls5qc7/+KmCFFqqyG3IZIp0Dp+F6YAWZLeXLTRraO5FaryDFNjZpj6ZN2fGcqzlZxe5Yn3FXBzn9yFTQ9JUqsYRFfw50qHoHl4bd9Z9+Tdqr4RYN5zogvOufqMXaf7kudgo0Jys3ysPupktv7E6QGPBxwCOiEwq987hvl/GY3onfhZByiqaOXnM7lHtK9Y7uN5N4WONW9f/8dM7TF5BEetLW4AtxqeGFhe9OMRMhJi5+pRyLdRgcAPCQwQVQnXrdZSJ4vjwwPl5MXsUwDxTHuinE2xj20i2I6G1BT4C/Fycwkw8g== 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=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=bfEisWYGFCGIMeqBiXlUKIBUj+D28smsy3Cbb2bf68QYGzKLNwpwdpJ+Cc+spiRrqbwfnqATCi35TTolG3qPb5pSqczqbIvg1UOFjKXLUGrp8XA33aa858X/0AbSM9LE09dkDlOj7B1bEoI9jLTbk/0cqSJxmrdUB3Ha2ysQ/whWlzG/pCWTIRWeb7BeynWtuxKoKvpVbchK4v8ffc3vvk1SomLa7sz4hMvb1o8/HytELQ5jg3KJbNSyg9/RGUh8d+tfRC705D0pL/I9+9EnAg35kBzBuLVr5xpoyzoWl5LkSygJR38fYGK9EkEoQXr1EB61qr1Oe+f3+Yn0JwPUXw== 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=+rFtWJxLVhYuLjiP61fT9Jzk8/FSoAfCPlO+An3ySwc=; b=vnujyJ6NJQ5Qi3moFlGJhZ84M4+kihDSDQW9zihgGWEj3EJr6E8c+246KGKg7mhAEmYdFycDANHlcwhbTh9whdWRJe6RnvUIdzB6cqB+9wOfO+eY51JKl+X8zIHADqqcWHtLMjus04h6nGCyGrhZYgJdUSMyTjZHH13rGewz8Wg= Received: from AS9PR05CA0045.eurprd05.prod.outlook.com (2603:10a6:20b:489::11) by PR3PR08MB5609.eurprd08.prod.outlook.com (2603:10a6:102:81::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Wed, 9 Feb 2022 15:22:51 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:489:cafe::65) by AS9PR05CA0045.outlook.office365.com (2603:10a6:20b:489::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 15:22:51 +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 AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 15:22:50 +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; Wed, 9 Feb 2022 15:22:51 +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; Wed, 9 Feb 2022 15:22:46 +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; Wed, 9 Feb 2022 15:22:51 +0000 From: Joey Gouly To: CC: , , , , , , , Subject: [PATCH v3 6/6] kselftest/arm64: mte: user_mem: test a wider range of values Date: Wed, 9 Feb 2022 15:22:40 +0000 Message-ID: <20220209152240.52788-7-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220209152240.52788-1-joey.gouly@arm.com> References: <20220209152240.52788-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 586a087a-5ab1-4175-65e6-08d9ebe00e11 X-MS-TrafficTypeDiagnostic: PR3PR08MB5609:EE_|DB5EUR03FT053:EE_|AS8PR08MB7321:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:989;OLM:989; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FKd1cpuMxDz4udbUMdzQYeZYFfpAun7ycxLdWXBUSiHLDw62nJ1eGuPZNB4i2Zb/xRXoCeRs5ayNmywMtRcrDQpZmQ9EcWcR+u6B2NXJ5IyFDvKeoy5PxSDLBJ+qVdDdzx6SK4OedJawzp/AshHERq2aNSaqN5Ml4nu2KHIiSm/1aNl/tuz9bahwzqjVPtYhrYchU4ZxRIt5L+wxEBXkBLUu6NS0UmVojtwfzODF6n4MVyPyPJWT6eYyBGpdhYXfi7WPjZhGMMEouvC2QGHc0uEP/G8/fxf2rQCBn0DxWv5O9b/rvc+VybJgTqoF0ia0pSBLmiWv1eW/BcAVWfrL9R/hMLDUptjxcOzjRQL1OKZMNskyUUedBLRfFaU18TVfIAmgMxceNyiYxjPJsR2Y2mKXjsXhzca/zNlretP9cWxnQz7AvkanzJ/cjQ90Oc0R1WcRIhvC7eqXRiFw3Ybu7W860aAgx6/Bn3tY4yK4IpNHIbvwt+1HGLZKe33xC9Jw0LFxGlkYeXwZaAi4JZZW1WtgmQnecZslCXqIm7HL0k4AtgkEUncYhU+TE4Soh2wC0VkB7oDItN6kiUX+fx/v0CNozv5wxA7eVwHfEgHLHoTOepyhmIXNdNUMYJRAd6rffu9AEyfFOHUjN+DBQj+q6RBVbHFBbAv0EC3vFvwfy0H9xklcD1Rly28EQLWm1dRgfwj5wDOOtP1NCNFEbiyD7Q== 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)(40470700004)(36840700001)(47076005)(5660300002)(4326008)(44832011)(508600001)(2616005)(356005)(81166007)(1076003)(26005)(8676002)(8936002)(54906003)(40460700003)(70206006)(70586007)(36756003)(2906002)(7696005)(6666004)(36860700001)(82310400004)(6916009)(316002)(186003)(83380400001)(86362001)(336012)(426003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR08MB5609 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f3b3c1a2-c09d-49ae-2df6-08d9ebe00913 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CnimKlltxhEgvPa/gFqlrftJktI3pWujyRHOIVYCf/cVONKnCCeiF1chJ4kthPoV8Tj8KKwH4+HG8eiUSCfAuX1WTrwp4hMdJMlsLDVFIoWQ0GcnAwJRe7OmiBmiBNbYt4IJVBTzDkTXskXPBtwpHO3Q6DENNJQJkiI9e0kIIr2zRtjOK0y5AqlY8n05eeViPX+YzORRS4FLBfIOeEMNtZ16VAvZqijFZRoolPrVEb7apfukpR4PoRadB2gBrhNtOzYKBNV7nncLvrBGBOL324uFKvJX0oqoMs+URqluXB+MYUkuqXcKFJJisLBt18AXlz5PRbhDA81+Bz969WSc0npaMnmOCLWn9rReOpE757agzCWfgbJDAYrqWQfeE+YL+FIIN/a5hm918orO3raFc6/1Ocs7BDhwxie3zJb9udayTxX3ntFWbVECga1ep8GG0PWSyvNA8TRhezTzyqyoKwe+sB1EFraEWGIJQKWEr3zO6q1rrJnXp2wAlydaNrwGk3h8KpGyl29qI2HXe/Z4/8GgLTauA1fnFiBmm5H2NvPGa8nS8EzVmo9dpgiBbWymkb3AZNMhWH9bkkUdRJ9HckReUIR2gT1pDpLFzmpgB+1PokYB35nGrvvfFih/FG4k7Gw0cQOXZbfYXqcGZPBrExFZUNV7vmU5EzeaRZ+E5tLtsE4v+g9Ath0KlACvG6vW 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)(186003)(26005)(508600001)(2616005)(1076003)(82310400004)(107886003)(336012)(7696005)(86362001)(6666004)(36860700001)(426003)(40460700003)(83380400001)(70586007)(47076005)(81166007)(4326008)(70206006)(8676002)(316002)(6916009)(54906003)(44832011)(36756003)(2906002)(5660300002)(8936002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 15:22:59.0783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 586a087a-5ab1-4175-65e6-08d9ebe00e11 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: DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7321 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220209_072309_994143_B95567DC X-CRM114-Status: GOOD ( 14.57 ) 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 Instead of hard coding a small amount of tests, generate a wider range of tests to try catch any corner cases that could show up. These new tests test different MTE tag lengths and offsets, which previously would have caused infinite loops in the kernel. This was fixed by 295cf156231c ("arm64: Avoid premature usercopy failure"), so these are regressions tests for that corner case. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Mark Brown Tested-by: Mark Brown Reviewed-by: Shuah Khan Reviewed-by: Catalin Marinas --- .../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 bb4974c437f8..f4ae5f87a3b7 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, @@ -136,9 +139,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) { @@ -153,17 +214,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();