Skip to content

Commit e9b6047

Browse files
amitdanielkachhapwilldeacon
authored andcommitted
kselftest/arm64: Add utilities and a test to validate mte memory
This test checks that the memory tag is present after mte allocation and the memory is accessible with those tags. This testcase verifies all sync, async and none mte error reporting mode. The allocated mte buffers are verified for Allocated range (no error expected while accessing buffer), Underflow range, and Overflow range. Different test scenarios covered here are, * Verify that mte memory are accessible at byte/block level. * Force underflow and overflow to occur and check the data consistency. * Check to/from between tagged and untagged memory. * Check that initial allocated memory to have 0 tag. This change also creates the necessary infrastructure to add mte test cases. MTE kselftests can use the several utility functions provided here to add wide variety of mte test scenarios. GCC compiler need flag '-march=armv8.5-a+memtag' so those flags are verified before compilation. The mte testcases can be launched with kselftest framework as, make TARGETS=arm64 ARM64_SUBTARGETS=mte kselftest or compiled as, make -C tools/testing/selftests TARGETS=arm64 ARM64_SUBTARGETS=mte CC='compiler' Co-developed-by: Gabor Kertesz <gabor.kertesz@arm.com> Signed-off-by: Gabor Kertesz <gabor.kertesz@arm.com> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com> Tested-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Link: https://lore.kernel.org/r/20201002115630.24683-2-amit.kachhap@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent f75aef3 commit e9b6047

File tree

8 files changed

+1138
-1
lines changed

8 files changed

+1138
-1
lines changed

tools/testing/selftests/arm64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ARCH ?= $(shell uname -m 2>/dev/null || echo not)
55

66
ifneq (,$(filter $(ARCH),aarch64 arm64))
7-
ARM64_SUBTARGETS ?= tags signal
7+
ARM64_SUBTARGETS ?= tags signal mte
88
else
99
ARM64_SUBTARGETS :=
1010
endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
check_buffer_fill
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (C) 2020 ARM Limited
3+
4+
CFLAGS += -std=gnu99 -I.
5+
SRCS := $(filter-out mte_common_util.c,$(wildcard *.c))
6+
PROGS := $(patsubst %.c,%,$(SRCS))
7+
8+
#Add mte compiler option
9+
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep gcc),)
10+
CFLAGS += -march=armv8.5-a+memtag
11+
endif
12+
13+
#check if the compiler works well
14+
mte_cc_support := $(shell if ($(CC) $(CFLAGS) -E -x c /dev/null -o /dev/null 2>&1) then echo "1"; fi)
15+
16+
ifeq ($(mte_cc_support),1)
17+
# Generated binaries to be installed by top KSFT script
18+
TEST_GEN_PROGS := $(PROGS)
19+
20+
# Get Kernel headers installed and use them.
21+
KSFT_KHDR_INSTALL := 1
22+
endif
23+
24+
# Include KSFT lib.mk.
25+
include ../../lib.mk
26+
27+
ifeq ($(mte_cc_support),1)
28+
$(TEST_GEN_PROGS): mte_common_util.c mte_common_util.h mte_helper.S
29+
endif

0 commit comments

Comments
 (0)