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