xref: /linux/tools/testing/selftests/arm64/fp/fp-pidbench.S (revision daa2be74b1b2302004945b2a5e32424e177cc7da)
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2021 ARM Limited.
3// Original author: Mark Brown <broonie@kernel.org>
4//
5// Trivial syscall overhead benchmark.
6//
7// This is implemented in asm to ensure that we don't have any issues with
8// system libraries using instructions that disrupt the test.
9
10#include <asm/unistd.h>
11#include "assembler.h"
12
13.arch_extension sve
14
15.macro test_loop per_loop
16	mov	x10, x20
17	mov	x8, #__NR_getpid
18	mrs	x11, CNTVCT_EL0
191:
20	\per_loop
21	svc	#0
22	sub	x10, x10, #1
23	cbnz	x10, 1b
24
25	mrs	x12, CNTVCT_EL0
26	sub	x0, x12, x11
27	bl	putdec
28	puts	"\n"
29.endm
30
31// Main program entry point
32.globl _start
33function _start
34	puts	"Iterations per test: "
35	mov	x20, #10000
36	lsl	x20, x20, #8
37	mov	x0, x20
38	bl	putdec
39	puts	"\n"
40
41	// Test having never used SVE
42	puts	"No SVE: "
43	test_loop
44
45	// Check for SVE support - should use hwcap but that's hard in asm
46	mrs	x0, ID_AA64PFR0_EL1
47	ubfx	x0, x0, #32, #4
48	cbnz	x0, 1f
49	puts	"System does not support SVE\n"
50	b	out
511:
52
53	// Execute a SVE instruction
54	puts	"SVE VL: "
55	rdvl	x0, #8
56	bl	putdec
57	puts	"\n"
58
59	puts	"SVE used once: "
60	test_loop
61
62	// Use SVE per syscall
63	puts	"SVE used per syscall: "
64	test_loop "rdvl x0, #8"
65
66	//  And we're done
67out:
68	mov	x0, #0
69	mov	x8, #__NR_exit
70	svc	#0
71