za-fork-asm.S 979 B

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