summaryrefslogtreecommitdiff
path: root/tools/perf/tests/shell/coresight/trap_entry_exit.sh
blob: 4521e4f4ba58100c7da7a915d729df7ad814f031 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# CoreSight emulated instruction entry and exit (exclusive)

. "$(dirname "$0")/../lib/coresight_exception.sh"

test_trap_entry_exit()
{
	local attempt result

	# traploop reads ID_AA64ISAR0_EL1 from EL0. The kernel emulates MRS and
	# advances the saved PC, so IRET must resume four bytes after the trap.
	for attempt in 1 2 3; do
		echo "Recording emulated instructions (attempt $attempt/3)"
		if ! record_trace traploop 256; then
			cat "$tmpdir/record.log"
			echo "Failed to record the traploop workload"
			return 1
		fi
		decode_trace || return 1
		# Select MRS Xt, ID_AA64ISAR0_EL1; the low five bits select Xt.
		check_exception_pairs "int.*insn: [01][[:xdigit:]] 06 38 d5" "iret" 4
		result=$?

		# An instruction page fault at MRS can also match the opcode filter.
		# Retry failed checks to tolerate such transient faults.
		case $result in
		0) return 0 ;;
		1|2) continue ;;
		*) return "$result" ;;
		esac
	done

	echo "FAIL: No valid trap pair after three recordings"
	return 1
}

setup_exception_test || exit $?
test_trap_entry_exit