From patchwork Thu Feb 3 14:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 12734239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E41EC433F5 for ; Thu, 3 Feb 2022 14:40:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wT0NzuSJT7PmRys65B5j/qV14dlA7ZNCeL4XgubFam8=; b=sNJPp2FpMPNswL lMI6b+bAaeUMMa27E/Pk63CWGpMTMTGL3jyHaTwNzeIj8xA6TaSwGPvxzYiMAqfvjmlLUlWAZ1meX dH0odxtNBw7CG/9acE8M5UeB76uE22zP4/yurneIM2ovmBACJQ8CcNLhMdrZ7umynleOsb5e/cl3a xGC/ZVya4lZZHjYcepEtip3T2b2EkGZ746utzOklehWdxNhmLelZt7AZrFDluWp3jIjUa+TT0rR+L cL+z48sRkJE+B2r52RAAaJ4c8DYNW+YtXFOh8gwVYULoM8b1ykCTSJ/Qv2XHQU/9LK+qhpAYF0YeQ pNKUcHBrvVJhStoAyzUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdFP-001eJs-Mu; Thu, 03 Feb 2022 14:38:08 +0000 Received: from mail-vi1eur05on2042.outbound.protection.outlook.com ([40.107.21.42] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nFdEI-001dyx-HH for linux-arm-kernel@lists.infradead.org; Thu, 03 Feb 2022 14:37:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=OJI+o03xMr2F25ghxUB59FNJdmz2RYTe84P2wJ650kt1q3WLoe+Cyi9wUVokMmacqh7/Sc/M/cXDa7jNNl91qu8mu+lV1eg83cTKpmmX9x6braQt0MF9mjKgo/kmzOX7APc/Gq+sjBOZhQyO/twat/5qRXO+EvuF35klh4YBU1s= Received: from AS8PR04CA0147.eurprd04.prod.outlook.com (2603:10a6:20b:127::32) by AS8PR08MB6230.eurprd08.prod.outlook.com (2603:10a6:20b:29d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 3 Feb 2022 14:36:55 +0000 Received: from VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:127:cafe::75) by AS8PR04CA0147.outlook.office365.com (2603:10a6:20b:127::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT021.mail.protection.outlook.com (10.152.18.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:55 +0000 Received: ("Tessian outbound 63bb5eb69ee8:v113"); Thu, 03 Feb 2022 14:36:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 423d894f5e3e9d8e X-CR-MTA-TID: 64aa7808 Received: from a055b9ddc5f1.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0F9B40D0-0F66-4617-9D5A-99960424B853.1; Thu, 03 Feb 2022 14:36:48 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a055b9ddc5f1.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Feb 2022 14:36:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i2RKt9PRgZUflB+h18UT/563qJwwPIH3vhiCchbSQMePvSyIEWJ7GiCBpZ+muORfAM+XLydNnGsQZQFo6AgQBrHEvVBURp8LDy8GJ3sqJ9U/3mmEunE2XQexvUUit0xOW1iHv/M2HR+b1dmlO7UXuDTnekoj8pznrCk83ucRK+qZY8Yq+6/QDJaXTUiSVx0JnZrhs1uy3gg3NM8bEy+x4BY32/rPfvQGUs1rhWopJ+M72JhFM8k9WCiYLGH8WD54t6EgT+M+rdJT/zAKqY/Y1P6B/OXiIstADwMH13ftTuOv8R70U6ViM6j+jcje66w2TPaprFet/PQA/LSJliTeHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=Jq+stKYBQyJxnRr7A7+T2qG+kHR3Zvcv3/9adzT4WP6I4/6NpDALC0ZJ/C+9Zsaoy0reHGL7ULAeLgZc0g8EzEdtuyMEudsm/YQ1NK0mp1I+O488rGeToe8OmZU2Vpg+phYk8yRE33IV8lBPlGgamc3I04taWjXQEfVb2dZiQER4vjxXwNhSp+lgMowd3nkJ/HIGJBbaUd37W841PLtgMVaczMmPPVVCBZ5un/mmSZ1CGxNRrXARmtEHG76rCKk7N0j4+uSqoaunloSYZsyHqI7TxeoRaEDxoDoGi4Kjr5RIUQp7WbON8HXV9lEKEau+92ND439f+stXD3QPfloqfA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xNgOdDazMlRuVgwtYzGuYWxr1FNWSU0TcGC8c5zTSKY=; b=OJI+o03xMr2F25ghxUB59FNJdmz2RYTe84P2wJ650kt1q3WLoe+Cyi9wUVokMmacqh7/Sc/M/cXDa7jNNl91qu8mu+lV1eg83cTKpmmX9x6braQt0MF9mjKgo/kmzOX7APc/Gq+sjBOZhQyO/twat/5qRXO+EvuF35klh4YBU1s= Received: from AM6PR08CA0005.eurprd08.prod.outlook.com (2603:10a6:20b:b2::17) by DB6PR08MB2933.eurprd08.prod.outlook.com (2603:10a6:6:1c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Thu, 3 Feb 2022 14:36:38 +0000 Received: from AM5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::22) by AM6PR08CA0005.outlook.office365.com (2603:10a6:20b:b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 3 Feb 2022 14:36:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by AM5EUR03FT040.mail.protection.outlook.com (10.152.17.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4951.12 via Frontend Transport; Thu, 3 Feb 2022 14:36:38 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Thu, 3 Feb 2022 14:36:33 +0000 Received: from e124191.cambridge.arm.com (10.1.197.45) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2308.20 via Frontend Transport; Thu, 3 Feb 2022 14:36:33 +0000 From: Joey Gouly To: CC: , , , , , Subject: [PATCH v2 6/6] kselftest/arm64: mte: user_mem: test more combinations of values Date: Thu, 3 Feb 2022 14:36:20 +0000 Message-ID: <20220203143620.30629-7-joey.gouly@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220203143620.30629-1-joey.gouly@arm.com> References: <20220203143620.30629-1-joey.gouly@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 9aa2522a-91fa-468d-fbda-08d9e722a042 X-MS-TrafficTypeDiagnostic: DB6PR08MB2933:EE_|VE1EUR03FT021:EE_|AS8PR08MB6230:EE_ X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:2201;OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AzcFAepNYvfHy95n2mBa2oBogx0JLFTSvLju4M0Md9P4Q+QmINHmTN39PRwBYYb3wV2yQAPdJPQmgvXfDQ5uTV8HcksrBAegZu7YegoXQ5CX2akjG9LshnlEgQO2k36zQbDY1FIIVxGrWtmgUDGIhBcf0gvHpyAxhwyPVp9BMmChIAgDR6FVbTmIwlq9GiWBavYKIS30cziR7xhhJbqRpQooj3rfB6u/Puj4Q0ohYgiAOUWo3Bfap4agJIBFEHftACDkSSeNh9rf9TvKhs1ll3hjCXGSq99xdPUEkUYJkyKvZN3QckGoAdNit5giCWu9bkPcCGL4auDtyrLERvu5psn/jCtAbN0dnkl1BY1wANU5ZhpoJvnr0HoIfYfNyaittHK1j4N0tGyhQ7f9bbChVUhABEiG+wRLUiCaxJjNWmtD2vuQ/8/UN5egKW0Cp9qOF0uanmijGipjAectxpuuk278HY89khmE47Zjp2FV2Bk3XZPdO5dDoKfK+NcE2iDy3aSY/8909895GdgvMK+HzOI3F8NiXKWVQ7L+8t06AblPXFUeL9ZEeb7H7vI39YltPd7z68deQhbLtRFCDE2grU5kObU2327LNCm77RmnPAvroM2o7kEHQkxBu/PvZwWkpYgX6hQY6+6qXqCzeLWv9bE/Ap3VDe11mR2QsnBvqAIhJbcOqeKBJr7v4QLBQbw1REofwjB3cbEiOkIWS+FQhg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(316002)(1076003)(6916009)(186003)(508600001)(5660300002)(36860700001)(47076005)(86362001)(426003)(336012)(81166007)(36756003)(54906003)(70586007)(4326008)(8676002)(82310400004)(70206006)(6666004)(83380400001)(8936002)(44832011)(2616005)(7696005)(26005)(40460700003)(2906002)(356005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR08MB2933 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4ebc9c62-1a0d-4c7c-f45a-08d9e7229672 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ZvlyVXcd5EIGG4vo7o27WVo6JR0XwcXC4KPVmzrwz+NzupToDBkhhVLIhbyK11u3KFxzpkkBcha1gOZpq7S5crSbk4K/iunRnYzLLNHIBK4xBS8vSJw3336zAXx+5hW4UEatekStQL5I1UGJZfZlcVKlOwiyCj0jw0NMxXicYorPCy+4+nolrNwAchuThBjZDTeNeG8+C4V77tqqMnp5GMHisrqzII0zXWiqd09Vm8D9JdAS9Tpdg7syaHuno+Ca4OSkPyXjncTeGoAqqnuDMtijSabXuKa2GVw++qeDEfF/0kKzxpYU+RtXN2fB31rnmpVHkVNwZhkJJwxxhYAfVGbSyWjcxXEqtozkeqMsGTEZG8gtdHmMSDtL61l9RdAigOlZXksBCc1qOeXd+xs62MMhMJDezX1rPmFlqQ0FVMBIr4Dgow//jHem0HVOESbrZteP25c8mEJTGVMecvqZ9Nh9y5QbLXO/9Ew2d534WJo6CLJ+S3AVBE21ofxjm5PBg4kpOUwJK7WVCQ49ltBYmmyKEJd5p+/9Nj0xX00ib+q3EWwSD1cCtkAN81ZAaEms7N/leDn5OXVWUpXZFAspLrjS/21CzIfQK4iCJntI1Vu0GQQMb+YIZjqfD8q1CIoftcFeFzJ6/aWmKs2M0R9I3jLGY6TEPdKzgRT6bFskHMRelq7rgqPr+iz+kBxvV0i X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(47076005)(86362001)(508600001)(70206006)(8936002)(70586007)(8676002)(4326008)(2616005)(83380400001)(1076003)(426003)(336012)(36860700001)(186003)(26005)(107886003)(82310400004)(6666004)(40460700003)(81166007)(2906002)(36756003)(54906003)(6916009)(316002)(5660300002)(7696005)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Feb 2022 14:36:55.2190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9aa2522a-91fa-468d-fbda-08d9e722a042 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT021.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6230 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220203_063658_645368_C64E6393 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Expand the tests to cover more syscalls, tag offsets and tag lengths. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Cc: Mark Brown Cc: Shuah Khan Reviewed-by: Shuah Khan --- .../selftests/arm64/mte/check_user_mem.c | 94 ++++++++++++++++--- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_user_mem.c b/tools/testing/selftests/arm64/mte/check_user_mem.c index c128bfa81502..1aef855bf81a 100644 --- a/tools/testing/selftests/arm64/mte/check_user_mem.c +++ b/tools/testing/selftests/arm64/mte/check_user_mem.c @@ -3,6 +3,7 @@ #define _GNU_SOURCE +#include #include #include #include @@ -20,6 +21,8 @@ static size_t page_sz; +#define TEST_NAME_MAX 100 + enum test_type { READ_TEST, WRITE_TEST, @@ -137,9 +140,67 @@ static int check_usermem_access_fault(int mem_type, int mode, int mapping, return err; } +void format_test_name(char* name, int name_len, int type, int sync, int map, int len, int offset) { + const char* test_type; + const char* mte_type; + const char* map_type; + + switch (type) { + case READ_TEST: + test_type = "read"; + break; + case WRITE_TEST: + test_type = "write"; + break; + case READV_TEST: + test_type = "readv"; + break; + case WRITEV_TEST: + test_type = "writev"; + break; + default: + assert(0); + break; + } + + switch (sync) { + case MTE_SYNC_ERR: + mte_type = "MTE_SYNC_ERR"; + break; + case MTE_ASYNC_ERR: + mte_type = "MTE_ASYNC_ERR"; + break; + default: + assert(0); + break; + } + + switch (map) { + case MAP_SHARED: + map_type = "MAP_SHARED"; + break; + case MAP_PRIVATE: + map_type = "MAP_PRIVATE"; + break; + default: + assert(0); + break; + } + + snprintf(name, name_len, + "test type: %s, %s, %s, tag len: %d, tag offset: %d\n", + test_type, mte_type, map_type, len, offset); +} + int main(int argc, char *argv[]) { int err; + int t, s, m, l, o; + int mte_sync[] = {MTE_SYNC_ERR, MTE_ASYNC_ERR}; + int maps[] = {MAP_SHARED, MAP_PRIVATE}; + int tag_lens[] = {0, MT_GRANULE_SIZE}; + int tag_offsets[] = {page_sz, MT_GRANULE_SIZE}; + char test_name[TEST_NAME_MAX]; page_sz = getpagesize(); if (!page_sz) { @@ -154,17 +215,28 @@ int main(int argc, char *argv[]) mte_register_signal(SIGSEGV, mte_default_handler); /* Set test plan */ - ksft_set_plan(4); - - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), - "Check memory access from kernel in sync mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_SYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), - "Check memory access from kernel in sync mode, shared mapping and mmap memory\n"); - - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE, page_sz, 0, READ_TEST), - "Check memory access from kernel in async mode, private mapping and mmap memory\n"); - evaluate_test(check_usermem_access_fault(USE_MMAP, MTE_ASYNC_ERR, MAP_SHARED, page_sz, 0, READ_TEST), - "Check memory access from kernel in async mode, shared mapping and mmap memory\n"); + ksft_set_plan(64); + + for (t = 0; t < LAST_TEST; t++) { + for (s = 0; s < ARRAY_SIZE(mte_sync); s++) { + for (m = 0; m < ARRAY_SIZE(maps); m++) { + for (l = 0; l < ARRAY_SIZE(tag_lens); l++) { + for (o = 0; o < ARRAY_SIZE(tag_offsets); o++) { + int sync = mte_sync[s]; + int map = maps[m]; + int offset = tag_offsets[o]; + int tag_len = tag_lens[l]; + int res = check_usermem_access_fault(USE_MMAP, sync, + map, offset, + tag_len, t); + format_test_name(test_name, TEST_NAME_MAX, + t, sync, map, tag_len, offset); + evaluate_test(res, test_name); + } + } + } + } + } mte_restore_setup(); ksft_print_cnts();