0001 // SPDX-License-Identifier: GPL-2.0-only
0002 // Copyright (C) 2021 ARM Limited.
0003
0004 #include "sme-inst.h"
0005
0006 .arch_extension sve
0007
0008 #define MAGIC 42
0009
0010 #define MAXVL 2048
0011 #define MAXVL_B (MAXVL / 8)
0012
0013 .pushsection .text
0014 .data
0015 .align 4
0016 scratch:
0017 .space MAXVL_B
0018 .popsection
0019
0020 .globl fork_test
0021 fork_test:
0022 smstart_za
0023
0024 // For simplicity just set one word in one vector, other tests
0025 // cover general data corruption issues.
0026 ldr x0, =scratch
0027 mov x1, #MAGIC
0028 str x1, [x0]
0029 mov w12, wzr
0030 _ldr_za 12, 0 // ZA.H[W12] loaded from [X0]
0031
0032 // Tail call into the C portion that does the fork & verify
0033 b fork_test_c
0034
0035 .globl verify_fork
0036 verify_fork:
0037 // SVCR should have ZA=1, SM=0
0038 mrs x0, S3_3_C4_C2_2
0039 and x1, x0, #3
0040 cmp x1, #2
0041 beq 1f
0042 mov x0, xzr
0043 b 100f
0044 1:
0045
0046 // ZA should still have the value we loaded
0047 ldr x0, =scratch
0048 mov w12, wzr
0049 _str_za 12, 0 // ZA.H[W12] stored to [X0]
0050 ldr x1, [x0]
0051 cmp x1, #MAGIC
0052 beq 2f
0053 mov x0, xzr
0054 b 100f
0055
0056 2:
0057 // All tests passed
0058 mov x0, #1
0059 100:
0060 ret
0061