fpsimd.c 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /*
  2. * FP/SIMD context switching and fault handling
  3. *
  4. * Copyright (C) 2012 ARM Ltd.
  5. * Author: Catalin Marinas <catalin.marinas@arm.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/bitmap.h>
  20. #include <linux/bottom_half.h>
  21. #include <linux/bug.h>
  22. #include <linux/cache.h>
  23. #include <linux/compat.h>
  24. #include <linux/cpu.h>
  25. #include <linux/cpu_pm.h>
  26. #include <linux/kernel.h>
  27. #include <linux/linkage.h>
  28. #include <linux/irqflags.h>
  29. #include <linux/init.h>
  30. #include <linux/percpu.h>
  31. #include <linux/prctl.h>
  32. #include <linux/preempt.h>
  33. #include <linux/ptrace.h>
  34. #include <linux/sched/signal.h>
  35. #include <linux/sched/task_stack.h>
  36. #include <linux/signal.h>
  37. #include <linux/slab.h>
  38. #include <linux/stddef.h>
  39. #include <linux/sysctl.h>
  40. #include <asm/esr.h>
  41. #include <asm/fpsimd.h>
  42. #include <asm/cpufeature.h>
  43. #include <asm/cputype.h>
  44. #include <asm/processor.h>
  45. #include <asm/simd.h>
  46. #include <asm/sigcontext.h>
  47. #include <asm/sysreg.h>
  48. #include <asm/traps.h>
  49. #define FPEXC_IOF (1 << 0)
  50. #define FPEXC_DZF (1 << 1)
  51. #define FPEXC_OFF (1 << 2)
  52. #define FPEXC_UFF (1 << 3)
  53. #define FPEXC_IXF (1 << 4)
  54. #define FPEXC_IDF (1 << 7)
  55. /*
  56. * (Note: in this discussion, statements about FPSIMD apply equally to SVE.)
  57. *
  58. * In order to reduce the number of times the FPSIMD state is needlessly saved
  59. * and restored, we need to keep track of two things:
  60. * (a) for each task, we need to remember which CPU was the last one to have
  61. * the task's FPSIMD state loaded into its FPSIMD registers;
  62. * (b) for each CPU, we need to remember which task's userland FPSIMD state has
  63. * been loaded into its FPSIMD registers most recently, or whether it has
  64. * been used to perform kernel mode NEON in the meantime.
  65. *
  66. * For (a), we add a fpsimd_cpu field to thread_struct, which gets updated to
  67. * the id of the current CPU every time the state is loaded onto a CPU. For (b),
  68. * we add the per-cpu variable 'fpsimd_last_state' (below), which contains the
  69. * address of the userland FPSIMD state of the task that was loaded onto the CPU
  70. * the most recently, or NULL if kernel mode NEON has been performed after that.
  71. *
  72. * With this in place, we no longer have to restore the next FPSIMD state right
  73. * when switching between tasks. Instead, we can defer this check to userland
  74. * resume, at which time we verify whether the CPU's fpsimd_last_state and the
  75. * task's fpsimd_cpu are still mutually in sync. If this is the case, we
  76. * can omit the FPSIMD restore.
  77. *
  78. * As an optimization, we use the thread_info flag TIF_FOREIGN_FPSTATE to
  79. * indicate whether or not the userland FPSIMD state of the current task is
  80. * present in the registers. The flag is set unless the FPSIMD registers of this
  81. * CPU currently contain the most recent userland FPSIMD state of the current
  82. * task.
  83. *
  84. * In order to allow softirq handlers to use FPSIMD, kernel_neon_begin() may
  85. * save the task's FPSIMD context back to task_struct from softirq context.
  86. * To prevent this from racing with the manipulation of the task's FPSIMD state
  87. * from task context and thereby corrupting the state, it is necessary to
  88. * protect any manipulation of a task's fpsimd_state or TIF_FOREIGN_FPSTATE
  89. * flag with local_bh_disable() unless softirqs are already masked.
  90. *
  91. * For a certain task, the sequence may look something like this:
  92. * - the task gets scheduled in; if both the task's fpsimd_cpu field
  93. * contains the id of the current CPU, and the CPU's fpsimd_last_state per-cpu
  94. * variable points to the task's fpsimd_state, the TIF_FOREIGN_FPSTATE flag is
  95. * cleared, otherwise it is set;
  96. *
  97. * - the task returns to userland; if TIF_FOREIGN_FPSTATE is set, the task's
  98. * userland FPSIMD state is copied from memory to the registers, the task's
  99. * fpsimd_cpu field is set to the id of the current CPU, the current
  100. * CPU's fpsimd_last_state pointer is set to this task's fpsimd_state and the
  101. * TIF_FOREIGN_FPSTATE flag is cleared;
  102. *
  103. * - the task executes an ordinary syscall; upon return to userland, the
  104. * TIF_FOREIGN_FPSTATE flag will still be cleared, so no FPSIMD state is
  105. * restored;
  106. *
  107. * - the task executes a syscall which executes some NEON instructions; this is
  108. * preceded by a call to kernel_neon_begin(), which copies the task's FPSIMD
  109. * register contents to memory, clears the fpsimd_last_state per-cpu variable
  110. * and sets the TIF_FOREIGN_FPSTATE flag;
  111. *
  112. * - the task gets preempted after kernel_neon_end() is called; as we have not
  113. * returned from the 2nd syscall yet, TIF_FOREIGN_FPSTATE is still set so
  114. * whatever is in the FPSIMD registers is not saved to memory, but discarded.
  115. */
  116. struct fpsimd_last_state_struct {
  117. struct user_fpsimd_state *st;
  118. };
  119. static DEFINE_PER_CPU(struct fpsimd_last_state_struct, fpsimd_last_state);
  120. /* Default VL for tasks that don't set it explicitly: */
  121. static int sve_default_vl = -1;
  122. #ifdef CONFIG_ARM64_SVE
  123. /* Maximum supported vector length across all CPUs (initially poisoned) */
  124. int __ro_after_init sve_max_vl = SVE_VL_MIN;
  125. /* Set of available vector lengths, as vq_to_bit(vq): */
  126. static __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
  127. static void __percpu *efi_sve_state;
  128. #else /* ! CONFIG_ARM64_SVE */
  129. /* Dummy declaration for code that will be optimised out: */
  130. extern __ro_after_init DECLARE_BITMAP(sve_vq_map, SVE_VQ_MAX);
  131. extern void __percpu *efi_sve_state;
  132. #endif /* ! CONFIG_ARM64_SVE */
  133. /*
  134. * Call __sve_free() directly only if you know task can't be scheduled
  135. * or preempted.
  136. */
  137. static void __sve_free(struct task_struct *task)
  138. {
  139. kfree(task->thread.sve_state);
  140. task->thread.sve_state = NULL;
  141. }
  142. static void sve_free(struct task_struct *task)
  143. {
  144. WARN_ON(test_tsk_thread_flag(task, TIF_SVE));
  145. __sve_free(task);
  146. }
  147. /*
  148. * TIF_SVE controls whether a task can use SVE without trapping while
  149. * in userspace, and also the way a task's FPSIMD/SVE state is stored
  150. * in thread_struct.
  151. *
  152. * The kernel uses this flag to track whether a user task is actively
  153. * using SVE, and therefore whether full SVE register state needs to
  154. * be tracked. If not, the cheaper FPSIMD context handling code can
  155. * be used instead of the more costly SVE equivalents.
  156. *
  157. * * TIF_SVE set:
  158. *
  159. * The task can execute SVE instructions while in userspace without
  160. * trapping to the kernel.
  161. *
  162. * When stored, Z0-Z31 (incorporating Vn in bits[127:0] or the
  163. * corresponding Zn), P0-P15 and FFR are encoded in in
  164. * task->thread.sve_state, formatted appropriately for vector
  165. * length task->thread.sve_vl.
  166. *
  167. * task->thread.sve_state must point to a valid buffer at least
  168. * sve_state_size(task) bytes in size.
  169. *
  170. * During any syscall, the kernel may optionally clear TIF_SVE and
  171. * discard the vector state except for the FPSIMD subset.
  172. *
  173. * * TIF_SVE clear:
  174. *
  175. * An attempt by the user task to execute an SVE instruction causes
  176. * do_sve_acc() to be called, which does some preparation and then
  177. * sets TIF_SVE.
  178. *
  179. * When stored, FPSIMD registers V0-V31 are encoded in
  180. * task->thread.uw.fpsimd_state; bits [max : 128] for each of Z0-Z31 are
  181. * logically zero but not stored anywhere; P0-P15 and FFR are not
  182. * stored and have unspecified values from userspace's point of
  183. * view. For hygiene purposes, the kernel zeroes them on next use,
  184. * but userspace is discouraged from relying on this.
  185. *
  186. * task->thread.sve_state does not need to be non-NULL, valid or any
  187. * particular size: it must not be dereferenced.
  188. *
  189. * * FPSR and FPCR are always stored in task->thread.uw.fpsimd_state
  190. * irrespective of whether TIF_SVE is clear or set, since these are
  191. * not vector length dependent.
  192. */
  193. /*
  194. * Update current's FPSIMD/SVE registers from thread_struct.
  195. *
  196. * This function should be called only when the FPSIMD/SVE state in
  197. * thread_struct is known to be up to date, when preparing to enter
  198. * userspace.
  199. *
  200. * Softirqs (and preemption) must be disabled.
  201. */
  202. static void task_fpsimd_load(void)
  203. {
  204. WARN_ON(!in_softirq() && !irqs_disabled());
  205. if (system_supports_sve() && test_thread_flag(TIF_SVE))
  206. sve_load_state(sve_pffr(&current->thread),
  207. &current->thread.uw.fpsimd_state.fpsr,
  208. sve_vq_from_vl(current->thread.sve_vl) - 1);
  209. else
  210. fpsimd_load_state(&current->thread.uw.fpsimd_state);
  211. }
  212. /*
  213. * Ensure FPSIMD/SVE storage in memory for the loaded context is up to
  214. * date with respect to the CPU registers.
  215. *
  216. * Softirqs (and preemption) must be disabled.
  217. */
  218. void fpsimd_save(void)
  219. {
  220. struct user_fpsimd_state *st = __this_cpu_read(fpsimd_last_state.st);
  221. /* set by fpsimd_bind_task_to_cpu() or fpsimd_bind_state_to_cpu() */
  222. WARN_ON(!in_softirq() && !irqs_disabled());
  223. if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) {
  224. if (system_supports_sve() && test_thread_flag(TIF_SVE)) {
  225. if (WARN_ON(sve_get_vl() != current->thread.sve_vl)) {
  226. /*
  227. * Can't save the user regs, so current would
  228. * re-enter user with corrupt state.
  229. * There's no way to recover, so kill it:
  230. */
  231. force_signal_inject(SIGKILL, SI_KERNEL, 0);
  232. return;
  233. }
  234. sve_save_state(sve_pffr(&current->thread), &st->fpsr);
  235. } else
  236. fpsimd_save_state(st);
  237. }
  238. }
  239. /*
  240. * Helpers to translate bit indices in sve_vq_map to VQ values (and
  241. * vice versa). This allows find_next_bit() to be used to find the
  242. * _maximum_ VQ not exceeding a certain value.
  243. */
  244. static unsigned int vq_to_bit(unsigned int vq)
  245. {
  246. return SVE_VQ_MAX - vq;
  247. }
  248. static unsigned int bit_to_vq(unsigned int bit)
  249. {
  250. if (WARN_ON(bit >= SVE_VQ_MAX))
  251. bit = SVE_VQ_MAX - 1;
  252. return SVE_VQ_MAX - bit;
  253. }
  254. /*
  255. * All vector length selection from userspace comes through here.
  256. * We're on a slow path, so some sanity-checks are included.
  257. * If things go wrong there's a bug somewhere, but try to fall back to a
  258. * safe choice.
  259. */
  260. static unsigned int find_supported_vector_length(unsigned int vl)
  261. {
  262. int bit;
  263. int max_vl = sve_max_vl;
  264. if (WARN_ON(!sve_vl_valid(vl)))
  265. vl = SVE_VL_MIN;
  266. if (WARN_ON(!sve_vl_valid(max_vl)))
  267. max_vl = SVE_VL_MIN;
  268. if (vl > max_vl)
  269. vl = max_vl;
  270. bit = find_next_bit(sve_vq_map, SVE_VQ_MAX,
  271. vq_to_bit(sve_vq_from_vl(vl)));
  272. return sve_vl_from_vq(bit_to_vq(bit));
  273. }
  274. #ifdef CONFIG_SYSCTL
  275. static int sve_proc_do_default_vl(struct ctl_table *table, int write,
  276. void __user *buffer, size_t *lenp,
  277. loff_t *ppos)
  278. {
  279. int ret;
  280. int vl = sve_default_vl;
  281. struct ctl_table tmp_table = {
  282. .data = &vl,
  283. .maxlen = sizeof(vl),
  284. };
  285. ret = proc_dointvec(&tmp_table, write, buffer, lenp, ppos);
  286. if (ret || !write)
  287. return ret;
  288. /* Writing -1 has the special meaning "set to max": */
  289. if (vl == -1)
  290. vl = sve_max_vl;
  291. if (!sve_vl_valid(vl))
  292. return -EINVAL;
  293. sve_default_vl = find_supported_vector_length(vl);
  294. return 0;
  295. }
  296. static struct ctl_table sve_default_vl_table[] = {
  297. {
  298. .procname = "sve_default_vector_length",
  299. .mode = 0644,
  300. .proc_handler = sve_proc_do_default_vl,
  301. },
  302. { }
  303. };
  304. static int __init sve_sysctl_init(void)
  305. {
  306. if (system_supports_sve())
  307. if (!register_sysctl("abi", sve_default_vl_table))
  308. return -EINVAL;
  309. return 0;
  310. }
  311. #else /* ! CONFIG_SYSCTL */
  312. static int __init sve_sysctl_init(void) { return 0; }
  313. #endif /* ! CONFIG_SYSCTL */
  314. #define ZREG(sve_state, vq, n) ((char *)(sve_state) + \
  315. (SVE_SIG_ZREG_OFFSET(vq, n) - SVE_SIG_REGS_OFFSET))
  316. /*
  317. * Transfer the FPSIMD state in task->thread.uw.fpsimd_state to
  318. * task->thread.sve_state.
  319. *
  320. * Task can be a non-runnable task, or current. In the latter case,
  321. * softirqs (and preemption) must be disabled.
  322. * task->thread.sve_state must point to at least sve_state_size(task)
  323. * bytes of allocated kernel memory.
  324. * task->thread.uw.fpsimd_state must be up to date before calling this
  325. * function.
  326. */
  327. static void fpsimd_to_sve(struct task_struct *task)
  328. {
  329. unsigned int vq;
  330. void *sst = task->thread.sve_state;
  331. struct user_fpsimd_state const *fst = &task->thread.uw.fpsimd_state;
  332. unsigned int i;
  333. if (!system_supports_sve())
  334. return;
  335. vq = sve_vq_from_vl(task->thread.sve_vl);
  336. for (i = 0; i < 32; ++i)
  337. memcpy(ZREG(sst, vq, i), &fst->vregs[i],
  338. sizeof(fst->vregs[i]));
  339. }
  340. /*
  341. * Transfer the SVE state in task->thread.sve_state to
  342. * task->thread.uw.fpsimd_state.
  343. *
  344. * Task can be a non-runnable task, or current. In the latter case,
  345. * softirqs (and preemption) must be disabled.
  346. * task->thread.sve_state must point to at least sve_state_size(task)
  347. * bytes of allocated kernel memory.
  348. * task->thread.sve_state must be up to date before calling this function.
  349. */
  350. static void sve_to_fpsimd(struct task_struct *task)
  351. {
  352. unsigned int vq;
  353. void const *sst = task->thread.sve_state;
  354. struct user_fpsimd_state *fst = &task->thread.uw.fpsimd_state;
  355. unsigned int i;
  356. if (!system_supports_sve())
  357. return;
  358. vq = sve_vq_from_vl(task->thread.sve_vl);
  359. for (i = 0; i < 32; ++i)
  360. memcpy(&fst->vregs[i], ZREG(sst, vq, i),
  361. sizeof(fst->vregs[i]));
  362. }
  363. #ifdef CONFIG_ARM64_SVE
  364. /*
  365. * Return how many bytes of memory are required to store the full SVE
  366. * state for task, given task's currently configured vector length.
  367. */
  368. size_t sve_state_size(struct task_struct const *task)
  369. {
  370. return SVE_SIG_REGS_SIZE(sve_vq_from_vl(task->thread.sve_vl));
  371. }
  372. /*
  373. * Ensure that task->thread.sve_state is allocated and sufficiently large.
  374. *
  375. * This function should be used only in preparation for replacing
  376. * task->thread.sve_state with new data. The memory is always zeroed
  377. * here to prevent stale data from showing through: this is done in
  378. * the interest of testability and predictability: except in the
  379. * do_sve_acc() case, there is no ABI requirement to hide stale data
  380. * written previously be task.
  381. */
  382. void sve_alloc(struct task_struct *task)
  383. {
  384. if (task->thread.sve_state) {
  385. memset(task->thread.sve_state, 0, sve_state_size(current));
  386. return;
  387. }
  388. /* This is a small allocation (maximum ~8KB) and Should Not Fail. */
  389. task->thread.sve_state =
  390. kzalloc(sve_state_size(task), GFP_KERNEL);
  391. /*
  392. * If future SVE revisions can have larger vectors though,
  393. * this may cease to be true:
  394. */
  395. BUG_ON(!task->thread.sve_state);
  396. }
  397. /*
  398. * Ensure that task->thread.sve_state is up to date with respect to
  399. * the user task, irrespective of when SVE is in use or not.
  400. *
  401. * This should only be called by ptrace. task must be non-runnable.
  402. * task->thread.sve_state must point to at least sve_state_size(task)
  403. * bytes of allocated kernel memory.
  404. */
  405. void fpsimd_sync_to_sve(struct task_struct *task)
  406. {
  407. if (!test_tsk_thread_flag(task, TIF_SVE))
  408. fpsimd_to_sve(task);
  409. }
  410. /*
  411. * Ensure that task->thread.uw.fpsimd_state is up to date with respect to
  412. * the user task, irrespective of whether SVE is in use or not.
  413. *
  414. * This should only be called by ptrace. task must be non-runnable.
  415. * task->thread.sve_state must point to at least sve_state_size(task)
  416. * bytes of allocated kernel memory.
  417. */
  418. void sve_sync_to_fpsimd(struct task_struct *task)
  419. {
  420. if (test_tsk_thread_flag(task, TIF_SVE))
  421. sve_to_fpsimd(task);
  422. }
  423. /*
  424. * Ensure that task->thread.sve_state is up to date with respect to
  425. * the task->thread.uw.fpsimd_state.
  426. *
  427. * This should only be called by ptrace to merge new FPSIMD register
  428. * values into a task for which SVE is currently active.
  429. * task must be non-runnable.
  430. * task->thread.sve_state must point to at least sve_state_size(task)
  431. * bytes of allocated kernel memory.
  432. * task->thread.uw.fpsimd_state must already have been initialised with
  433. * the new FPSIMD register values to be merged in.
  434. */
  435. void sve_sync_from_fpsimd_zeropad(struct task_struct *task)
  436. {
  437. unsigned int vq;
  438. void *sst = task->thread.sve_state;
  439. struct user_fpsimd_state const *fst = &task->thread.uw.fpsimd_state;
  440. unsigned int i;
  441. if (!test_tsk_thread_flag(task, TIF_SVE))
  442. return;
  443. vq = sve_vq_from_vl(task->thread.sve_vl);
  444. memset(sst, 0, SVE_SIG_REGS_SIZE(vq));
  445. for (i = 0; i < 32; ++i)
  446. memcpy(ZREG(sst, vq, i), &fst->vregs[i],
  447. sizeof(fst->vregs[i]));
  448. }
  449. int sve_set_vector_length(struct task_struct *task,
  450. unsigned long vl, unsigned long flags)
  451. {
  452. if (flags & ~(unsigned long)(PR_SVE_VL_INHERIT |
  453. PR_SVE_SET_VL_ONEXEC))
  454. return -EINVAL;
  455. if (!sve_vl_valid(vl))
  456. return -EINVAL;
  457. /*
  458. * Clamp to the maximum vector length that VL-agnostic SVE code can
  459. * work with. A flag may be assigned in the future to allow setting
  460. * of larger vector lengths without confusing older software.
  461. */
  462. if (vl > SVE_VL_ARCH_MAX)
  463. vl = SVE_VL_ARCH_MAX;
  464. vl = find_supported_vector_length(vl);
  465. if (flags & (PR_SVE_VL_INHERIT |
  466. PR_SVE_SET_VL_ONEXEC))
  467. task->thread.sve_vl_onexec = vl;
  468. else
  469. /* Reset VL to system default on next exec: */
  470. task->thread.sve_vl_onexec = 0;
  471. /* Only actually set the VL if not deferred: */
  472. if (flags & PR_SVE_SET_VL_ONEXEC)
  473. goto out;
  474. if (vl == task->thread.sve_vl)
  475. goto out;
  476. /*
  477. * To ensure the FPSIMD bits of the SVE vector registers are preserved,
  478. * write any live register state back to task_struct, and convert to a
  479. * non-SVE thread.
  480. */
  481. if (task == current) {
  482. local_bh_disable();
  483. fpsimd_save();
  484. set_thread_flag(TIF_FOREIGN_FPSTATE);
  485. }
  486. fpsimd_flush_task_state(task);
  487. if (test_and_clear_tsk_thread_flag(task, TIF_SVE))
  488. sve_to_fpsimd(task);
  489. if (task == current)
  490. local_bh_enable();
  491. /*
  492. * Force reallocation of task SVE state to the correct size
  493. * on next use:
  494. */
  495. sve_free(task);
  496. task->thread.sve_vl = vl;
  497. out:
  498. update_tsk_thread_flag(task, TIF_SVE_VL_INHERIT,
  499. flags & PR_SVE_VL_INHERIT);
  500. return 0;
  501. }
  502. /*
  503. * Encode the current vector length and flags for return.
  504. * This is only required for prctl(): ptrace has separate fields
  505. *
  506. * flags are as for sve_set_vector_length().
  507. */
  508. static int sve_prctl_status(unsigned long flags)
  509. {
  510. int ret;
  511. if (flags & PR_SVE_SET_VL_ONEXEC)
  512. ret = current->thread.sve_vl_onexec;
  513. else
  514. ret = current->thread.sve_vl;
  515. if (test_thread_flag(TIF_SVE_VL_INHERIT))
  516. ret |= PR_SVE_VL_INHERIT;
  517. return ret;
  518. }
  519. /* PR_SVE_SET_VL */
  520. int sve_set_current_vl(unsigned long arg)
  521. {
  522. unsigned long vl, flags;
  523. int ret;
  524. vl = arg & PR_SVE_VL_LEN_MASK;
  525. flags = arg & ~vl;
  526. if (!system_supports_sve())
  527. return -EINVAL;
  528. ret = sve_set_vector_length(current, vl, flags);
  529. if (ret)
  530. return ret;
  531. return sve_prctl_status(flags);
  532. }
  533. /* PR_SVE_GET_VL */
  534. int sve_get_current_vl(void)
  535. {
  536. if (!system_supports_sve())
  537. return -EINVAL;
  538. return sve_prctl_status(0);
  539. }
  540. /*
  541. * Bitmap for temporary storage of the per-CPU set of supported vector lengths
  542. * during secondary boot.
  543. */
  544. static DECLARE_BITMAP(sve_secondary_vq_map, SVE_VQ_MAX);
  545. static void sve_probe_vqs(DECLARE_BITMAP(map, SVE_VQ_MAX))
  546. {
  547. unsigned int vq, vl;
  548. unsigned long zcr;
  549. bitmap_zero(map, SVE_VQ_MAX);
  550. zcr = ZCR_ELx_LEN_MASK;
  551. zcr = read_sysreg_s(SYS_ZCR_EL1) & ~zcr;
  552. for (vq = SVE_VQ_MAX; vq >= SVE_VQ_MIN; --vq) {
  553. write_sysreg_s(zcr | (vq - 1), SYS_ZCR_EL1); /* self-syncing */
  554. vl = sve_get_vl();
  555. vq = sve_vq_from_vl(vl); /* skip intervening lengths */
  556. set_bit(vq_to_bit(vq), map);
  557. }
  558. }
  559. void __init sve_init_vq_map(void)
  560. {
  561. sve_probe_vqs(sve_vq_map);
  562. }
  563. /*
  564. * If we haven't committed to the set of supported VQs yet, filter out
  565. * those not supported by the current CPU.
  566. */
  567. void sve_update_vq_map(void)
  568. {
  569. sve_probe_vqs(sve_secondary_vq_map);
  570. bitmap_and(sve_vq_map, sve_vq_map, sve_secondary_vq_map, SVE_VQ_MAX);
  571. }
  572. /* Check whether the current CPU supports all VQs in the committed set */
  573. int sve_verify_vq_map(void)
  574. {
  575. int ret = 0;
  576. sve_probe_vqs(sve_secondary_vq_map);
  577. bitmap_andnot(sve_secondary_vq_map, sve_vq_map, sve_secondary_vq_map,
  578. SVE_VQ_MAX);
  579. if (!bitmap_empty(sve_secondary_vq_map, SVE_VQ_MAX)) {
  580. pr_warn("SVE: cpu%d: Required vector length(s) missing\n",
  581. smp_processor_id());
  582. ret = -EINVAL;
  583. }
  584. return ret;
  585. }
  586. static void __init sve_efi_setup(void)
  587. {
  588. if (!IS_ENABLED(CONFIG_EFI))
  589. return;
  590. /*
  591. * alloc_percpu() warns and prints a backtrace if this goes wrong.
  592. * This is evidence of a crippled system and we are returning void,
  593. * so no attempt is made to handle this situation here.
  594. */
  595. if (!sve_vl_valid(sve_max_vl))
  596. goto fail;
  597. efi_sve_state = __alloc_percpu(
  598. SVE_SIG_REGS_SIZE(sve_vq_from_vl(sve_max_vl)), SVE_VQ_BYTES);
  599. if (!efi_sve_state)
  600. goto fail;
  601. return;
  602. fail:
  603. panic("Cannot allocate percpu memory for EFI SVE save/restore");
  604. }
  605. /*
  606. * Enable SVE for EL1.
  607. * Intended for use by the cpufeatures code during CPU boot.
  608. */
  609. void sve_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
  610. {
  611. write_sysreg(read_sysreg(CPACR_EL1) | CPACR_EL1_ZEN_EL1EN, CPACR_EL1);
  612. isb();
  613. }
  614. /*
  615. * Read the pseudo-ZCR used by cpufeatures to identify the supported SVE
  616. * vector length.
  617. *
  618. * Use only if SVE is present.
  619. * This function clobbers the SVE vector length.
  620. */
  621. u64 read_zcr_features(void)
  622. {
  623. u64 zcr;
  624. unsigned int vq_max;
  625. /*
  626. * Set the maximum possible VL, and write zeroes to all other
  627. * bits to see if they stick.
  628. */
  629. sve_kernel_enable(NULL);
  630. write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
  631. zcr = read_sysreg_s(SYS_ZCR_EL1);
  632. zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
  633. vq_max = sve_vq_from_vl(sve_get_vl());
  634. zcr |= vq_max - 1; /* set LEN field to maximum effective value */
  635. return zcr;
  636. }
  637. void __init sve_setup(void)
  638. {
  639. u64 zcr;
  640. if (!system_supports_sve())
  641. return;
  642. /*
  643. * The SVE architecture mandates support for 128-bit vectors,
  644. * so sve_vq_map must have at least SVE_VQ_MIN set.
  645. * If something went wrong, at least try to patch it up:
  646. */
  647. if (WARN_ON(!test_bit(vq_to_bit(SVE_VQ_MIN), sve_vq_map)))
  648. set_bit(vq_to_bit(SVE_VQ_MIN), sve_vq_map);
  649. zcr = read_sanitised_ftr_reg(SYS_ZCR_EL1);
  650. sve_max_vl = sve_vl_from_vq((zcr & ZCR_ELx_LEN_MASK) + 1);
  651. /*
  652. * Sanity-check that the max VL we determined through CPU features
  653. * corresponds properly to sve_vq_map. If not, do our best:
  654. */
  655. if (WARN_ON(sve_max_vl != find_supported_vector_length(sve_max_vl)))
  656. sve_max_vl = find_supported_vector_length(sve_max_vl);
  657. /*
  658. * For the default VL, pick the maximum supported value <= 64.
  659. * VL == 64 is guaranteed not to grow the signal frame.
  660. */
  661. sve_default_vl = find_supported_vector_length(64);
  662. pr_info("SVE: maximum available vector length %u bytes per vector\n",
  663. sve_max_vl);
  664. pr_info("SVE: default vector length %u bytes per vector\n",
  665. sve_default_vl);
  666. sve_efi_setup();
  667. }
  668. /*
  669. * Called from the put_task_struct() path, which cannot get here
  670. * unless dead_task is really dead and not schedulable.
  671. */
  672. void fpsimd_release_task(struct task_struct *dead_task)
  673. {
  674. __sve_free(dead_task);
  675. }
  676. #endif /* CONFIG_ARM64_SVE */
  677. /*
  678. * Trapped SVE access
  679. *
  680. * Storage is allocated for the full SVE state, the current FPSIMD
  681. * register contents are migrated across, and TIF_SVE is set so that
  682. * the SVE access trap will be disabled the next time this task
  683. * reaches ret_to_user.
  684. *
  685. * TIF_SVE should be clear on entry: otherwise, task_fpsimd_load()
  686. * would have disabled the SVE access trap for userspace during
  687. * ret_to_user, making an SVE access trap impossible in that case.
  688. */
  689. asmlinkage void do_sve_acc(unsigned int esr, struct pt_regs *regs)
  690. {
  691. /* Even if we chose not to use SVE, the hardware could still trap: */
  692. if (unlikely(!system_supports_sve()) || WARN_ON(is_compat_task())) {
  693. force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc);
  694. return;
  695. }
  696. sve_alloc(current);
  697. local_bh_disable();
  698. fpsimd_save();
  699. fpsimd_to_sve(current);
  700. /* Force ret_to_user to reload the registers: */
  701. fpsimd_flush_task_state(current);
  702. set_thread_flag(TIF_FOREIGN_FPSTATE);
  703. if (test_and_set_thread_flag(TIF_SVE))
  704. WARN_ON(1); /* SVE access shouldn't have trapped */
  705. local_bh_enable();
  706. }
  707. /*
  708. * Trapped FP/ASIMD access.
  709. */
  710. asmlinkage void do_fpsimd_acc(unsigned int esr, struct pt_regs *regs)
  711. {
  712. /* TODO: implement lazy context saving/restoring */
  713. WARN_ON(1);
  714. }
  715. /*
  716. * Raise a SIGFPE for the current process.
  717. */
  718. asmlinkage void do_fpsimd_exc(unsigned int esr, struct pt_regs *regs)
  719. {
  720. siginfo_t info;
  721. unsigned int si_code = FPE_FLTUNK;
  722. if (esr & ESR_ELx_FP_EXC_TFV) {
  723. if (esr & FPEXC_IOF)
  724. si_code = FPE_FLTINV;
  725. else if (esr & FPEXC_DZF)
  726. si_code = FPE_FLTDIV;
  727. else if (esr & FPEXC_OFF)
  728. si_code = FPE_FLTOVF;
  729. else if (esr & FPEXC_UFF)
  730. si_code = FPE_FLTUND;
  731. else if (esr & FPEXC_IXF)
  732. si_code = FPE_FLTRES;
  733. }
  734. clear_siginfo(&info);
  735. info.si_signo = SIGFPE;
  736. info.si_code = si_code;
  737. info.si_addr = (void __user *)instruction_pointer(regs);
  738. send_sig_info(SIGFPE, &info, current);
  739. }
  740. void fpsimd_thread_switch(struct task_struct *next)
  741. {
  742. bool wrong_task, wrong_cpu;
  743. if (!system_supports_fpsimd())
  744. return;
  745. /* Save unsaved fpsimd state, if any: */
  746. fpsimd_save();
  747. /*
  748. * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's
  749. * state. For kernel threads, FPSIMD registers are never loaded
  750. * and wrong_task and wrong_cpu will always be true.
  751. */
  752. wrong_task = __this_cpu_read(fpsimd_last_state.st) !=
  753. &next->thread.uw.fpsimd_state;
  754. wrong_cpu = next->thread.fpsimd_cpu != smp_processor_id();
  755. update_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE,
  756. wrong_task || wrong_cpu);
  757. }
  758. void fpsimd_flush_thread(void)
  759. {
  760. int vl, supported_vl;
  761. if (!system_supports_fpsimd())
  762. return;
  763. local_bh_disable();
  764. memset(&current->thread.uw.fpsimd_state, 0,
  765. sizeof(current->thread.uw.fpsimd_state));
  766. fpsimd_flush_task_state(current);
  767. if (system_supports_sve()) {
  768. clear_thread_flag(TIF_SVE);
  769. sve_free(current);
  770. /*
  771. * Reset the task vector length as required.
  772. * This is where we ensure that all user tasks have a valid
  773. * vector length configured: no kernel task can become a user
  774. * task without an exec and hence a call to this function.
  775. * By the time the first call to this function is made, all
  776. * early hardware probing is complete, so sve_default_vl
  777. * should be valid.
  778. * If a bug causes this to go wrong, we make some noise and
  779. * try to fudge thread.sve_vl to a safe value here.
  780. */
  781. vl = current->thread.sve_vl_onexec ?
  782. current->thread.sve_vl_onexec : sve_default_vl;
  783. if (WARN_ON(!sve_vl_valid(vl)))
  784. vl = SVE_VL_MIN;
  785. supported_vl = find_supported_vector_length(vl);
  786. if (WARN_ON(supported_vl != vl))
  787. vl = supported_vl;
  788. current->thread.sve_vl = vl;
  789. /*
  790. * If the task is not set to inherit, ensure that the vector
  791. * length will be reset by a subsequent exec:
  792. */
  793. if (!test_thread_flag(TIF_SVE_VL_INHERIT))
  794. current->thread.sve_vl_onexec = 0;
  795. }
  796. set_thread_flag(TIF_FOREIGN_FPSTATE);
  797. local_bh_enable();
  798. }
  799. /*
  800. * Save the userland FPSIMD state of 'current' to memory, but only if the state
  801. * currently held in the registers does in fact belong to 'current'
  802. */
  803. void fpsimd_preserve_current_state(void)
  804. {
  805. if (!system_supports_fpsimd())
  806. return;
  807. local_bh_disable();
  808. fpsimd_save();
  809. local_bh_enable();
  810. }
  811. /*
  812. * Like fpsimd_preserve_current_state(), but ensure that
  813. * current->thread.uw.fpsimd_state is updated so that it can be copied to
  814. * the signal frame.
  815. */
  816. void fpsimd_signal_preserve_current_state(void)
  817. {
  818. fpsimd_preserve_current_state();
  819. if (system_supports_sve() && test_thread_flag(TIF_SVE))
  820. sve_to_fpsimd(current);
  821. }
  822. /*
  823. * Associate current's FPSIMD context with this cpu
  824. * Preemption must be disabled when calling this function.
  825. */
  826. void fpsimd_bind_task_to_cpu(void)
  827. {
  828. struct fpsimd_last_state_struct *last =
  829. this_cpu_ptr(&fpsimd_last_state);
  830. last->st = &current->thread.uw.fpsimd_state;
  831. current->thread.fpsimd_cpu = smp_processor_id();
  832. if (system_supports_sve()) {
  833. /* Toggle SVE trapping for userspace if needed */
  834. if (test_thread_flag(TIF_SVE))
  835. sve_user_enable();
  836. else
  837. sve_user_disable();
  838. /* Serialised by exception return to user */
  839. }
  840. }
  841. void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *st)
  842. {
  843. struct fpsimd_last_state_struct *last =
  844. this_cpu_ptr(&fpsimd_last_state);
  845. WARN_ON(!in_softirq() && !irqs_disabled());
  846. last->st = st;
  847. }
  848. /*
  849. * Load the userland FPSIMD state of 'current' from memory, but only if the
  850. * FPSIMD state already held in the registers is /not/ the most recent FPSIMD
  851. * state of 'current'
  852. */
  853. void fpsimd_restore_current_state(void)
  854. {
  855. if (!system_supports_fpsimd())
  856. return;
  857. local_bh_disable();
  858. if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
  859. task_fpsimd_load();
  860. fpsimd_bind_task_to_cpu();
  861. }
  862. local_bh_enable();
  863. }
  864. /*
  865. * Load an updated userland FPSIMD state for 'current' from memory and set the
  866. * flag that indicates that the FPSIMD register contents are the most recent
  867. * FPSIMD state of 'current'
  868. */
  869. void fpsimd_update_current_state(struct user_fpsimd_state const *state)
  870. {
  871. if (!system_supports_fpsimd())
  872. return;
  873. local_bh_disable();
  874. current->thread.uw.fpsimd_state = *state;
  875. if (system_supports_sve() && test_thread_flag(TIF_SVE))
  876. fpsimd_to_sve(current);
  877. task_fpsimd_load();
  878. fpsimd_bind_task_to_cpu();
  879. clear_thread_flag(TIF_FOREIGN_FPSTATE);
  880. local_bh_enable();
  881. }
  882. /*
  883. * Invalidate live CPU copies of task t's FPSIMD state
  884. */
  885. void fpsimd_flush_task_state(struct task_struct *t)
  886. {
  887. t->thread.fpsimd_cpu = NR_CPUS;
  888. }
  889. void fpsimd_flush_cpu_state(void)
  890. {
  891. __this_cpu_write(fpsimd_last_state.st, NULL);
  892. set_thread_flag(TIF_FOREIGN_FPSTATE);
  893. }
  894. #ifdef CONFIG_KERNEL_MODE_NEON
  895. DEFINE_PER_CPU(bool, kernel_neon_busy);
  896. EXPORT_PER_CPU_SYMBOL(kernel_neon_busy);
  897. /*
  898. * Kernel-side NEON support functions
  899. */
  900. /*
  901. * kernel_neon_begin(): obtain the CPU FPSIMD registers for use by the calling
  902. * context
  903. *
  904. * Must not be called unless may_use_simd() returns true.
  905. * Task context in the FPSIMD registers is saved back to memory as necessary.
  906. *
  907. * A matching call to kernel_neon_end() must be made before returning from the
  908. * calling context.
  909. *
  910. * The caller may freely use the FPSIMD registers until kernel_neon_end() is
  911. * called.
  912. */
  913. void kernel_neon_begin(void)
  914. {
  915. if (WARN_ON(!system_supports_fpsimd()))
  916. return;
  917. BUG_ON(!may_use_simd());
  918. local_bh_disable();
  919. __this_cpu_write(kernel_neon_busy, true);
  920. /* Save unsaved fpsimd state, if any: */
  921. fpsimd_save();
  922. /* Invalidate any task state remaining in the fpsimd regs: */
  923. fpsimd_flush_cpu_state();
  924. preempt_disable();
  925. local_bh_enable();
  926. }
  927. EXPORT_SYMBOL(kernel_neon_begin);
  928. /*
  929. * kernel_neon_end(): give the CPU FPSIMD registers back to the current task
  930. *
  931. * Must be called from a context in which kernel_neon_begin() was previously
  932. * called, with no call to kernel_neon_end() in the meantime.
  933. *
  934. * The caller must not use the FPSIMD registers after this function is called,
  935. * unless kernel_neon_begin() is called again in the meantime.
  936. */
  937. void kernel_neon_end(void)
  938. {
  939. bool busy;
  940. if (!system_supports_fpsimd())
  941. return;
  942. busy = __this_cpu_xchg(kernel_neon_busy, false);
  943. WARN_ON(!busy); /* No matching kernel_neon_begin()? */
  944. preempt_enable();
  945. }
  946. EXPORT_SYMBOL(kernel_neon_end);
  947. #ifdef CONFIG_EFI
  948. static DEFINE_PER_CPU(struct user_fpsimd_state, efi_fpsimd_state);
  949. static DEFINE_PER_CPU(bool, efi_fpsimd_state_used);
  950. static DEFINE_PER_CPU(bool, efi_sve_state_used);
  951. /*
  952. * EFI runtime services support functions
  953. *
  954. * The ABI for EFI runtime services allows EFI to use FPSIMD during the call.
  955. * This means that for EFI (and only for EFI), we have to assume that FPSIMD
  956. * is always used rather than being an optional accelerator.
  957. *
  958. * These functions provide the necessary support for ensuring FPSIMD
  959. * save/restore in the contexts from which EFI is used.
  960. *
  961. * Do not use them for any other purpose -- if tempted to do so, you are
  962. * either doing something wrong or you need to propose some refactoring.
  963. */
  964. /*
  965. * __efi_fpsimd_begin(): prepare FPSIMD for making an EFI runtime services call
  966. */
  967. void __efi_fpsimd_begin(void)
  968. {
  969. if (!system_supports_fpsimd())
  970. return;
  971. WARN_ON(preemptible());
  972. if (may_use_simd()) {
  973. kernel_neon_begin();
  974. } else {
  975. /*
  976. * If !efi_sve_state, SVE can't be in use yet and doesn't need
  977. * preserving:
  978. */
  979. if (system_supports_sve() && likely(efi_sve_state)) {
  980. char *sve_state = this_cpu_ptr(efi_sve_state);
  981. __this_cpu_write(efi_sve_state_used, true);
  982. sve_save_state(sve_state + sve_ffr_offset(sve_max_vl),
  983. &this_cpu_ptr(&efi_fpsimd_state)->fpsr);
  984. } else {
  985. fpsimd_save_state(this_cpu_ptr(&efi_fpsimd_state));
  986. }
  987. __this_cpu_write(efi_fpsimd_state_used, true);
  988. }
  989. }
  990. /*
  991. * __efi_fpsimd_end(): clean up FPSIMD after an EFI runtime services call
  992. */
  993. void __efi_fpsimd_end(void)
  994. {
  995. if (!system_supports_fpsimd())
  996. return;
  997. if (!__this_cpu_xchg(efi_fpsimd_state_used, false)) {
  998. kernel_neon_end();
  999. } else {
  1000. if (system_supports_sve() &&
  1001. likely(__this_cpu_read(efi_sve_state_used))) {
  1002. char const *sve_state = this_cpu_ptr(efi_sve_state);
  1003. sve_load_state(sve_state + sve_ffr_offset(sve_max_vl),
  1004. &this_cpu_ptr(&efi_fpsimd_state)->fpsr,
  1005. sve_vq_from_vl(sve_get_vl()) - 1);
  1006. __this_cpu_write(efi_sve_state_used, false);
  1007. } else {
  1008. fpsimd_load_state(this_cpu_ptr(&efi_fpsimd_state));
  1009. }
  1010. }
  1011. }
  1012. #endif /* CONFIG_EFI */
  1013. #endif /* CONFIG_KERNEL_MODE_NEON */
  1014. #ifdef CONFIG_CPU_PM
  1015. static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
  1016. unsigned long cmd, void *v)
  1017. {
  1018. switch (cmd) {
  1019. case CPU_PM_ENTER:
  1020. fpsimd_save();
  1021. fpsimd_flush_cpu_state();
  1022. break;
  1023. case CPU_PM_EXIT:
  1024. break;
  1025. case CPU_PM_ENTER_FAILED:
  1026. default:
  1027. return NOTIFY_DONE;
  1028. }
  1029. return NOTIFY_OK;
  1030. }
  1031. static struct notifier_block fpsimd_cpu_pm_notifier_block = {
  1032. .notifier_call = fpsimd_cpu_pm_notifier,
  1033. };
  1034. static void __init fpsimd_pm_init(void)
  1035. {
  1036. cpu_pm_register_notifier(&fpsimd_cpu_pm_notifier_block);
  1037. }
  1038. #else
  1039. static inline void fpsimd_pm_init(void) { }
  1040. #endif /* CONFIG_CPU_PM */
  1041. #ifdef CONFIG_HOTPLUG_CPU
  1042. static int fpsimd_cpu_dead(unsigned int cpu)
  1043. {
  1044. per_cpu(fpsimd_last_state.st, cpu) = NULL;
  1045. return 0;
  1046. }
  1047. static inline void fpsimd_hotplug_init(void)
  1048. {
  1049. cpuhp_setup_state_nocalls(CPUHP_ARM64_FPSIMD_DEAD, "arm64/fpsimd:dead",
  1050. NULL, fpsimd_cpu_dead);
  1051. }
  1052. #else
  1053. static inline void fpsimd_hotplug_init(void) { }
  1054. #endif
  1055. /*
  1056. * FP/SIMD support code initialisation.
  1057. */
  1058. static int __init fpsimd_init(void)
  1059. {
  1060. if (elf_hwcap & HWCAP_FP) {
  1061. fpsimd_pm_init();
  1062. fpsimd_hotplug_init();
  1063. } else {
  1064. pr_notice("Floating-point is not implemented\n");
  1065. }
  1066. if (!(elf_hwcap & HWCAP_ASIMD))
  1067. pr_notice("Advanced SIMD is not implemented\n");
  1068. return sve_sysctl_init();
  1069. }
  1070. core_initcall(fpsimd_init);