xref: /linux/tools/testing/selftests/arm64/fp/za-fork-asm.S (revision f2745dc0ba3dadd8fa2b2c33f48253d78e133a12)
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (C) 2021 ARM Limited.
3
4#include "sme-inst.h"
5
6.arch_extension sve
7
8#define MAGIC     42
9
10#define MAXVL     2048
11#define MAXVL_B   (MAXVL / 8)
12
13.pushsection .text
14.data
15.align 4
16scratch:
17	.space	MAXVL_B
18.popsection
19
20.globl fork_test
21fork_test:
22	smstart_za
23
24	// For simplicity just set one word in one vector, other tests
25	// cover general data corruption issues.
26	ldr	x0, =scratch
27	mov	x1, #MAGIC
28	str	x1, [x0]
29	mov	w12, wzr
30	_ldr_za 12, 0			// ZA.H[W12] loaded from [X0]
31
32	// Tail call into the C portion that does the fork & verify
33	b	fork_test_c
34
35.globl verify_fork
36verify_fork:
37	// SVCR should have ZA=1, SM=0
38	mrs	x0, S3_3_C4_C2_2
39	and	x1, x0, #3
40	cmp	x1, #2
41	beq	1f
42	mov	x0, xzr
43	b	100f
441:
45
46	// ZA should still have the value we loaded
47	ldr	x0, =scratch
48	mov	w12, wzr
49	_str_za 12, 0			// ZA.H[W12] stored to [X0]
50	ldr	x1, [x0]
51	cmp	x1, #MAGIC
52	beq	2f
53	mov	x0, xzr
54	b	100f
55
562:
57	// All tests passed
58	mov	x0, #1
59100:
60	ret
61
62