From patchwork Fri Feb 21 09:33:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13985071 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 986391FFC6A for ; Fri, 21 Feb 2025 09:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740130417; cv=none; b=PS+RzxU86sGVYxcRkQAewFOUksFW/YALEi0mlpOJivihClOR5ZBISD2117bHrDA3zyiyKeiU57Xw8h0AR2JCOWoblVjqPcwIVEZO+WQV4hDbOGHNBduBCT2qcvQxhkEg2wKP4YH7BpY93ufp2ogLWBzoHnD/sKFWFO6lLyPkeHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740130417; c=relaxed/simple; bh=rB3sKCNcAvS2k2MiPjdBaQ4gAzv+DXj2dzV8m3LLkjI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BMEs064/iNlBrvq+j2Q/Y4E1ZtigjDOremdG1ev0HEJG5tp+17H6Af27Q9IidfQIyDAhrxiFSSkg5BmOfUs0lN27DcyyYLJINf3CqQsnXe8/uDDgd0PM+b1QUyDOryYzFVEsDubJ9Jcv91OEZNeG25yih6ZUsjgJVdWeo87zXAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9DD2C4CEDD; Fri, 21 Feb 2025 09:33:35 +0000 (UTC) From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org Cc: Naresh Kamboju , Yang Shi , Shuah Khan Subject: [PATCH 1/2] kselftest/arm64: mte: Use the correct naming for tag check modes in check_hugetlb_options.c Date: Fri, 21 Feb 2025 09:33:30 +0000 Message-Id: <20250221093331.2184245-2-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250221093331.2184245-1-catalin.marinas@arm.com> References: <20250221093331.2184245-1-catalin.marinas@arm.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The architecture doesn't define precise/imprecise MTE tag check modes, only synchronous and asynchronous. Use the correct naming and also ensure they match the MTE_{ASYNC,SYNC}_ERR type. Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests") Cc: Yang Shi Signed-off-by: Catalin Marinas Reviewed-by: Yang Shi --- tools/testing/selftests/arm64/mte/check_hugetlb_options.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c index 303260a6dc65..11f812635b51 100644 --- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c +++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c @@ -270,13 +270,13 @@ int main(int argc, char *argv[]) "Check clear PROT_MTE flags with private mapping and sync error mode and mmap/mprotect memory\n"); evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB), - "Check child hugetlb memory with private mapping, precise mode and mmap memory\n"); + "Check child hugetlb memory with private mapping, sync error mode and mmap memory\n"); evaluate_test(check_child_hugetlb_memory_mapping(USE_MMAP, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB), - "Check child hugetlb memory with private mapping, precise mode and mmap memory\n"); + "Check child hugetlb memory with private mapping, async error mode and mmap memory\n"); evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_SYNC_ERR, MAP_PRIVATE | MAP_HUGETLB), - "Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n"); + "Check child hugetlb memory with private mapping, sync error mode and mmap/mprotect memory\n"); evaluate_test(check_child_hugetlb_memory_mapping(USE_MPROTECT, MTE_ASYNC_ERR, MAP_PRIVATE | MAP_HUGETLB), - "Check child hugetlb memory with private mapping, precise mode and mmap/mprotect memory\n"); + "Check child hugetlb memory with private mapping, async error mode and mmap/mprotect memory\n"); mte_restore_setup(); free_hugetlb(); From patchwork Fri Feb 21 09:33:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 13985072 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33EF83FD4 for ; Fri, 21 Feb 2025 09:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740130419; cv=none; b=Uwzsb69zy5i/xZ+59xAU1JmHA+2HueBBNiUqcfgjdoFXKwsynoHK1uxhQeAtvQ3kVXjV+j/vfIMCTo8C8ycibJSXPbZOYuJ2kksqaDzRMflbnLMcAWb4TVg9gLz4Vb/I7xdJcxyDaCfqlZ0Q1usCOCnhuhBzFqQm/RGeLTkOKoE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740130419; c=relaxed/simple; bh=AgiPjyj+GZGQVfJyADV4HcULtk2jTxWfn2MGp4+sU5g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bUd55DS5tIOFSjyKMX0/ISzC2ixVDxxs//ai8CrHdN0vzsVmUXfIVYA8vVPBNAhunMmU4MafnAdTlJkOfoyr1t3EbiwYUWx3551M/PuvfFX6Egz1lLSaJ6RoLSpsSksUTNMmQKdSai5VKeYjXPfCqBjzyCMj6DKhjZT35n8mkts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E015C4CED6; Fri, 21 Feb 2025 09:33:37 +0000 (UTC) From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org Cc: Naresh Kamboju , Yang Shi , Shuah Khan Subject: [PATCH 2/2] kselftest/arm64: mte: Skip the hugetlb tests if MTE not supported on such mappings Date: Fri, 21 Feb 2025 09:33:31 +0000 Message-Id: <20250221093331.2184245-3-catalin.marinas@arm.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250221093331.2184245-1-catalin.marinas@arm.com> References: <20250221093331.2184245-1-catalin.marinas@arm.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While the kselftest was added at the same time with the kernel support for MTE on hugetlb mappings, the tests may be run on older kernels. Skip the tests if PROT_MTE is not supported on MAP_HUGETLB mappings. Fixes: 27879e8cb6b0 ("selftests: arm64: add hugetlb mte tests") Cc: Yang Shi Reported-by: Naresh Kamboju Signed-off-by: Catalin Marinas Reviewed-by: Yang Shi Reviewed-by: Dev Jain --- .../selftests/arm64/mte/check_hugetlb_options.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c index 11f812635b51..3bfcd3848432 100644 --- a/tools/testing/selftests/arm64/mte/check_hugetlb_options.c +++ b/tools/testing/selftests/arm64/mte/check_hugetlb_options.c @@ -227,6 +227,8 @@ static int check_child_hugetlb_memory_mapping(int mem_type, int mode, int mappin int main(int argc, char *argv[]) { int err; + void *map_ptr; + unsigned long map_size; err = mte_default_setup(); if (err) @@ -243,6 +245,15 @@ int main(int argc, char *argv[]) return KSFT_FAIL; } + /* Check if MTE supports hugetlb mappings */ + map_size = default_huge_page_size(); + map_ptr = mmap(NULL, map_size, PROT_READ | PROT_MTE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); + if (map_ptr == MAP_FAILED) + ksft_exit_skip("PROT_MTE not supported with MAP_HUGETLB mappings\n"); + else + munmap(map_ptr, map_size); + /* Set test plan */ ksft_set_plan(12);