asm_riscv64.s 666 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2020 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build riscv64
  5. // +build gc
  6. #include "textflag.h"
  7. TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0
  8. // Rewind stack pointer so anything that happens on the stack
  9. // will clobber the test pattern created by the caller
  10. ADD $(1024*8), X2
  11. // Ask signaller to setgid
  12. MOV $1, X5
  13. FENCE
  14. MOVW X5, ·Baton(SB)
  15. FENCE
  16. // Wait for setgid completion
  17. loop:
  18. FENCE
  19. MOVW ·Baton(SB), X5
  20. OR X6, X6, X6 // hint that we're in a spin loop
  21. BNE ZERO, X5, loop
  22. FENCE
  23. // Restore stack
  24. ADD $(-1024*8), X2
  25. RET