0010-Revert-RISC-V-Save-and-restore-VCSR-when-doing-user-.patch 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. From edd15521391233dec3a1538c1e091881395b277b Mon Sep 17 00:00:00 2001
  2. From: "max.ma" <max.ma@starfivetech.com>
  3. Date: Wed, 9 Feb 2022 23:12:18 -0800
  4. Subject: [PATCH 10/12] Revert "RISC-V: Save and restore VCSR when doing user
  5. context switch"
  6. This reverts commit 1c08ed548a24c41542bdb7309e05c1aef70f135d.
  7. ---
  8. sysdeps/riscv/Makefile | 5 ---
  9. sysdeps/riscv/rtld-global-offsets.sym | 7 ----
  10. sysdeps/unix/sysv/linux/riscv/bits/hwcap.h | 31 ---------------
  11. sysdeps/unix/sysv/linux/riscv/getcontext.S | 22 +----------
  12. sysdeps/unix/sysv/linux/riscv/setcontext.S | 22 -----------
  13. sysdeps/unix/sysv/linux/riscv/swapcontext.S | 41 --------------------
  14. sysdeps/unix/sysv/linux/riscv/ucontext_i.sym | 6 ---
  15. 7 files changed, 1 insertion(+), 133 deletions(-)
  16. delete mode 100644 sysdeps/riscv/rtld-global-offsets.sym
  17. delete mode 100644 sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  18. diff --git a/sysdeps/riscv/Makefile b/sysdeps/riscv/Makefile
  19. index a5c2106a09..20a9968106 100644
  20. --- a/sysdeps/riscv/Makefile
  21. +++ b/sysdeps/riscv/Makefile
  22. @@ -2,11 +2,6 @@ ifeq ($(subdir),misc)
  23. sysdep_headers += sys/asm.h
  24. endif
  25. -ifeq ($(subdir),csu)
  26. -# get offset to rtld_global._dl_hwcap and rtld_global._dl_hwcap2.
  27. -gen-as-const-headers += rtld-global-offsets.sym
  28. -endif
  29. -
  30. # RISC-V's assembler also needs to know about PIC as it changes the definition
  31. # of some assembler macros.
  32. ASFLAGS-.os += $(pic-ccflag)
  33. diff --git a/sysdeps/riscv/rtld-global-offsets.sym b/sysdeps/riscv/rtld-global-offsets.sym
  34. deleted file mode 100644
  35. index ff4e97f2a6..0000000000
  36. --- a/sysdeps/riscv/rtld-global-offsets.sym
  37. +++ /dev/null
  38. @@ -1,7 +0,0 @@
  39. -#define SHARED 1
  40. -
  41. -#include <ldsodefs.h>
  42. -
  43. -#define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem)
  44. -
  45. -RTLD_GLOBAL_RO_DL_HWCAP_OFFSET rtld_global_ro_offsetof (_dl_hwcap)
  46. diff --git a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h b/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  47. deleted file mode 100644
  48. index e6c5ef5740..0000000000
  49. --- a/sysdeps/unix/sysv/linux/riscv/bits/hwcap.h
  50. +++ /dev/null
  51. @@ -1,31 +0,0 @@
  52. -/* Defines for bits in AT_HWCAP. RISC-V Linux version.
  53. - Copyright (C) 2021 Free Software Foundation, Inc.
  54. - This file is part of the GNU C Library.
  55. -
  56. - The GNU C Library is free software; you can redistribute it and/or
  57. - modify it under the terms of the GNU Lesser General Public
  58. - License as published by the Free Software Foundation; either
  59. - version 2.1 of the License, or (at your option) any later version.
  60. -
  61. - The GNU C Library is distributed in the hope that it will be useful,
  62. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  63. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  64. - Lesser General Public License for more details.
  65. -
  66. - You should have received a copy of the GNU Lesser General Public
  67. - License along with the GNU C Library; if not, see
  68. - <http://www.gnu.org/licenses/>. */
  69. -
  70. -#if !defined (_SYS_AUXV_H) && !defined (_LINUX_RISCV_SYSDEP_H)
  71. -# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
  72. -#endif
  73. -
  74. -/* The following must match the kernel's <asm/hwcap.h>. */
  75. -#define HWCAP_ISA_I 0x100 //(1 << ('I' - 'A'))
  76. -#define HWCAP_ISA_M 0x1000 //(1 << ('M' - 'A'))
  77. -#define HWCAP_ISA_A 0x1 //(1 << ('A' - 'A'))
  78. -#define HWCAP_ISA_F 0x20 //(1 << ('F' - 'A'))
  79. -#define HWCAP_ISA_D 0x8 //(1 << ('D' - 'A'))
  80. -#define HWCAP_ISA_C 0x4 //(1 << ('C' - 'A'))
  81. -#define HWCAP_ISA_V 0x200000 //(1 << ('V' - 'A'))
  82. -
  83. diff --git a/sysdeps/unix/sysv/linux/riscv/getcontext.S b/sysdeps/unix/sysv/linux/riscv/getcontext.S
  84. index 840d8feca4..d6a9bbca60 100644
  85. --- a/sysdeps/unix/sysv/linux/riscv/getcontext.S
  86. +++ b/sysdeps/unix/sysv/linux/riscv/getcontext.S
  87. @@ -16,8 +16,6 @@
  88. License along with the GNU C Library. If not, see
  89. <https://www.gnu.org/licenses/>. */
  90. -#include <sysdep.h>
  91. -#include <rtld-global-offsets.h>
  92. #include "ucontext-macros.h"
  93. /* int getcontext (ucontext_t *ucp) */
  94. @@ -41,25 +39,6 @@ LEAF (__getcontext)
  95. SAVE_INT_REG (s10, 26, a0)
  96. SAVE_INT_REG (s11, 27, a0)
  97. -#ifdef __riscv_vector
  98. -# ifdef SHARED
  99. - la t1, _rtld_global_ro
  100. - REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1)
  101. -# else
  102. - la t1, _dl_hwcap
  103. - REG_L t1, (t1)
  104. -# endif
  105. - li t2, HWCAP_ISA_V
  106. - and t2, t1, t2
  107. - beqz t2, 1f
  108. - addi t2, a0, MCONTEXT_EXTENSION
  109. - li t1, RVV_MAGIC
  110. - sw t1, (t2)
  111. - csrr t1, vcsr
  112. - REG_S t1, VCSR_OFFSET(t2)
  113. -1:
  114. -#endif
  115. -
  116. #ifndef __riscv_float_abi_soft
  117. frsr a1
  118. @@ -94,4 +73,5 @@ LEAF (__getcontext)
  119. 99: j __syscall_error
  120. PSEUDO_END (__getcontext)
  121. +
  122. weak_alias (__getcontext, getcontext)
  123. diff --git a/sysdeps/unix/sysv/linux/riscv/setcontext.S b/sysdeps/unix/sysv/linux/riscv/setcontext.S
  124. index d2404fbe9c..9510518750 100644
  125. --- a/sysdeps/unix/sysv/linux/riscv/setcontext.S
  126. +++ b/sysdeps/unix/sysv/linux/riscv/setcontext.S
  127. @@ -16,8 +16,6 @@
  128. License along with the GNU C Library. If not, see
  129. <https://www.gnu.org/licenses/>. */
  130. -#include <sysdep.h>
  131. -#include <rtld-global-offsets.h>
  132. #include "ucontext-macros.h"
  133. /* int __setcontext (const ucontext_t *ucp)
  134. @@ -66,26 +64,6 @@ LEAF (__setcontext)
  135. fssr t1
  136. #endif /* __riscv_float_abi_soft */
  137. -#ifdef __riscv_vector
  138. -#ifdef SHARED
  139. - la t1, _rtld_global_ro
  140. - REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1)
  141. -#else
  142. - la t1, _dl_hwcap
  143. - REG_L t1, (t1)
  144. -#endif
  145. - li t2, HWCAP_ISA_V
  146. - and t2, t1, t2
  147. - beqz t2, 1f
  148. - li t1, RVV_MAGIC
  149. - addi t2, t0, MCONTEXT_EXTENSION
  150. - lw a1, (t2)
  151. - bne a1, t1, 1f
  152. - REG_L t1, VCSR_OFFSET(t2)
  153. - csrw vcsr, t1
  154. -1:
  155. -#endif
  156. -
  157. /* Note the contents of argument registers will be random
  158. unless makecontext() has been called. */
  159. RESTORE_INT_REG (t1, 0, t0)
  160. diff --git a/sysdeps/unix/sysv/linux/riscv/swapcontext.S b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
  161. index 94ae8e4bdc..df0f69969c 100644
  162. --- a/sysdeps/unix/sysv/linux/riscv/swapcontext.S
  163. +++ b/sysdeps/unix/sysv/linux/riscv/swapcontext.S
  164. @@ -16,8 +16,6 @@
  165. License along with the GNU C Library. If not, see
  166. <https://www.gnu.org/licenses/>. */
  167. -#include <sysdep.h>
  168. -#include <rtld-global-offsets.h>
  169. #include "ucontext-macros.h"
  170. /* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp) */
  171. @@ -42,25 +40,6 @@ LEAF (__swapcontext)
  172. SAVE_INT_REG (s10, 26, a0)
  173. SAVE_INT_REG (s11, 27, a0)
  174. -#ifdef __riscv_vector
  175. -#ifdef SHARED
  176. - la t1, _rtld_global_ro
  177. - REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1)
  178. -#else
  179. - la t1, _dl_hwcap
  180. - REG_L t1, (t1)
  181. -#endif
  182. - li t2, HWCAP_ISA_V
  183. - and t2, t1, t2
  184. - beqz t2, 1f
  185. - addi t2, a0, MCONTEXT_EXTENSION
  186. - li t1, RVV_MAGIC
  187. - sw t1, (t2)
  188. - csrr t1, vcsr
  189. - REG_S t1, VCSR_OFFSET(t2)
  190. -1:
  191. -#endif
  192. -
  193. #ifndef __riscv_float_abi_soft
  194. frsr a1
  195. @@ -110,26 +89,6 @@ LEAF (__swapcontext)
  196. fssr t1
  197. #endif /* __riscv_float_abi_soft */
  198. -#ifdef __riscv_vector
  199. -#ifdef SHARED
  200. - la t1, _rtld_global_ro
  201. - REG_L t1, RTLD_GLOBAL_RO_DL_HWCAP_OFFSET(t1)
  202. -#else
  203. - la t1, _dl_hwcap
  204. - REG_L t1, (t1)
  205. -#endif
  206. - li t2, HWCAP_ISA_V
  207. - and t2, t1, t2
  208. - beqz t2, 1f
  209. - li t1, RVV_MAGIC
  210. - addi t2, t0, MCONTEXT_EXTENSION
  211. - lw a1, (t2)
  212. - bne a1, t1, 1f
  213. - REG_L t1, VCSR_OFFSET(t2)
  214. - csrw vcsr, t1
  215. -1:
  216. -#endif
  217. -
  218. /* Note the contents of argument registers will be random
  219. unless makecontext() has been called. */
  220. RESTORE_INT_REG (t1, 0, t0)
  221. diff --git a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
  222. index 4037473c9a..be55b26310 100644
  223. --- a/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
  224. +++ b/sysdeps/unix/sysv/linux/riscv/ucontext_i.sym
  225. @@ -2,7 +2,6 @@
  226. #include <signal.h>
  227. #include <stddef.h>
  228. #include <sys/ucontext.h>
  229. -#include <asm/sigcontext.h>
  230. -- Constants used by the rt_sigprocmask call.
  231. @@ -28,10 +27,5 @@ STACK_FLAGS stack (ss_flags)
  232. MCONTEXT_GREGS mcontext (__gregs)
  233. MCONTEXT_FPREGS mcontext (__fpregs)
  234. -MCONTEXT_EXTENSION mcontext (__reserved)
  235. UCONTEXT_SIZE sizeof (ucontext_t)
  236. -
  237. -VCSR_OFFSET offsetof (struct __riscv_v_state, vcsr)
  238. -
  239. -RVV_MAGIC
  240. --
  241. 2.33.1